Introduction to the X Window Programming and Motif (5 days)

C programming and basic UNIX skills

What you should be able to say before taking this course:

  • I know what a Makefile does and how to use one
  • I know vi, emacs or xedit
  • I have a good knowledge of C programming and how pointers and structures work in C
  • I know the UNIX operating system well enough to get around move and copy files, look at a directory listing and compile a C program

What you will be able to say following the course:

  • I understand the different levels of programming with the X Window System: Motif, Xt and Xlib
  • I understand the event-driven and client-server models of programming, and know about: events, windows, displays, screens, window managers
  • I know what a GC is, and how to use it for drawing lines, circles, etc.
  • I understand the X color model and how it works
  • I know the difference between a bitmap and a pixmap and how to manipulate both
  • I can write an Xt or Xlib based program, integrate Xlib calls into Xt-based programs, and am familiar with the advanced features of both
  • I know what a callback is and how it works and the difference between client data and call data
  • I know what the resource manager is and what it does and I can write app-defaults files which specify resource values
  • I understand the Motif widget set, what it contains, the job that each widget does, and how to use them
  • I understand the difference between widget classes and instances, how inheritance works and how it is used in creating a widget class tree
  • I know what a compound string is and how it is used
  • I can create dialogs and pop them up and down
  • I can use the Xlib, Xt and Motif reference books effectively
  • I have a small library of X and Motif programs


Course Outline(short version):
Lecture One: Introduction to the X Window System
Lecture Two: The X Resource Manager
Lecture Three: Introduction to Xlib
Lecture Four: Graphics in X
Lecture Five: More Advanced Drawing
Lecture Six: Advanced Topics
Lecture Seven: Introducing Motif
Lecture Eight: Part Two of the Motif Widget Set
Lecture Nine: The Rest of the Motif Widget Set
Lecture Ten: UIL

Course Materials (included with tuition)

  • Volume 2: Xlib Reference Manual *
  • Volume 5: X Toolkit Intrinsics Reference Manual *
  • Volume 6B: Motif Reference Manual, 2nd Edition For Motif 2.1 *
  • Course Notes (Programming the X Window System and Programming Motif)

(*From O'Reilly & Associates)

Course Outline:

Lecture One

  • What is X?
  • Clients and Servers
  • X Application Architecture
  • Xlib, Widgets, Xt & Widget Sets
  • What is Xt-based?
  • Naming Conventions
  • Event Driven Programming
  • First code — Hello World of Xt Programming
  • Basic Programming Steps for Xt Programs
  • Application Contexts — What Are They?
  • Callbacks — What Are They and How Do They Work?
  • Motif Convenience Functions
  • Widget Resources — What Are They?
  • What, How, When and Where to Setting Widget Resources
  • Variable Argument Interfaces
  • Second Code Example

Lab One

  • Building and Running an X Application
  • Passing Client Data to Callbacks
  • Setting Resources in Code

Lecture Two

  • Where do Resources Come From?
  • C Subclassing and How it Works
  • Different Widget Trees and Widget Sets
  • Classifying Widgets
  • The X Resource Manager and How it Works
  • The .xinitrc and .mwmrc Files

Lab Two

  • Changing Style & Functionality Through Resource Files

Lecture Three — Introduction to Xlib

  • How do Xt and Xlib Fit Together?
  • What is Xlib?
  • Definitions: Server, Server Resources, Display, Screen, Window Manager & Display
  • Program Flow for Xlib Programs
  • First Xlib Example
  • The Xlib Calls
  • All About Windows
  • Dealing with the Window Manager
  • Selecting for Events
  • Events — What Are They?
  • How Many Events Are There?
  • When Do You Get Certain Events?
  • The XEvent Structure
  • Sample Code to Look at Event Handling in Xlib
  • Mouse Events
  • Key Events
  • Configure Notify Events
  • Expose Events
  • Xlib and Xt — Making Them Work Together

Lab Three — Xlib Programming

  • Building an Xlib Program
  • Selecting & Acting on Events in Xlib [Button Events, Key Events, etc.]

Lecture Four — Graphics in X

  • Graphics Vocabulary
  • Graphics Contexts — All About Them
  • Drawing Operations (Points, Lines, Arcs, Rectangles, Text, Polygons, Fills)
  • Graphics Example
  • Pixmaps — Creating and Using
  • Using Pixmaps as Backing Store

Lab Four — Using Xlib Graphics

  • Working with GC's
  • Interactive Drawing
  • Rubber Banding in X
  • Handling Program Resize

Lecture Five — More Advanced Drawing

  • Drawing Text
  • All about Fonts
  • Changing the Cursor — Predefined Ones and Creating Your Own RGB Color Model
  • Pixels and Colormaps
  • How Many Colors Possible vs. How Many Can Be Displayed
  • Display Hardware
  • Visual classes
  • Shared and Private Color Cells
  • How to Use Color in Your Application
  • Functions for Using Color
  • Private Color Functions
  • Private Colormaps

Lab Five

  • Tying Xlib and Xt Together
  • Implementing a Fully Functional Graphics Editor

Lecture Six — Advanced Topics

  • Sensitivity
  • Destroying Widgets and Windows
  • Memory Allocation in X
  • Synchronicity
  • Sending Events
  • Event Handlers
  • Actions and Translations
  • Fallback Resources
  • Application Resources
  • Command-line Options
  • Introduction to: Timers, Work Procs, Additional Input Sources, Properties & Selections, Sending Events, Error Handling, X Images

Lab Six

  • More Work on Graphics Editor

Lecture Seven — Introducing Motif

  • General Overview of How Motif, Xt and Xlib Work Together
  • The Prefixes Used
  • Convenience Widgets
  • Compound Strings & Multiple Fonts
  • Cosmetic Resources
  • Primitive Widgets — Similarities and Resources
  • Special Text Widget Properties and Callbacks
  • The Composite Widgets — What they do
  • Menu Widgets — What Do They Do?

Lab Seven — Starting with the Widgets

  • Start Building a Simple Application, Using Many of the Widgets Learned

Lecture Eight — Part Two of the Motif Widget Set

  • XmScale
  • XmScrollBar
  • XmScrolledWindowXmPanedWindow
  • XmFrame
  • XmDrawingArea
  • XmOptionMenu
  • Option Menu Example Code
  • XmPopupMenu and How it Works
  • Popup Menu Sample Code
  • Mnemonics and Accelerators
  • Tear Off Menus
  • Simple Menus in Motif
  • Hints on Designing Menus

Lab Eight

  • Using More Motif Widgets

Lecture Nine — The Rest of the Motif Widget Set

  • Dialogs — What Are They and What Do They Do?
  • How Do They Work?
  • Types and Styles of Dialogs
  • Common Dialog Resources
  • XmSelectionBox
  • XmFileSelectionBox
  • XmMessageBox
  • FormDialog & BulletinBoardDialog
  • Creating and Using Dialogs
  • Gadgets — What Are They?
  • Gadget Resources
  • Restrictions and Why Not to Use Them
  • How to Use Them
  • Shell Widgets — What They Are
  • Examining the Shell Widget
  • Shell Resources
  • MWM — its Resources and Behavior
  • Adding Keyboard Traversal to Your Application
  • Virtual Keyboard Bindings
  • Drag and Drop
  • Internationalization (I18N)
  • Building a Better Interface - Hints on Designing Your GUI

Lab Nine

  • Continue Working on the Lab By Using Some New Widgets

Lecture Ten — UIL

  • User Interface Language (UIL)
  • Who is Interested in UIL
  • UIL Syntax
  • Compiling UIL Code
  • The Motif Resource Manager and Fetching Interfaces from a UID File

Lab Ten — Working with UIL

  • Creating and Modifying Interfaces with UIL