Icon of a thin page Icon of a thick page

The X Window System

David A. Harding

This talk was presented at the Cherry Hill Linux User's Group (CHLUG) on 6 April 2007
I'm posting these notes on my blog because they were lost in my recent site redesign.

Window Manager 2

Window Manager Screenshots From Around The Web
Hover Mouse Over Images to See Tooltip

AfterStep Window Manager Blackbox Window Manager on Debian Scum Window Manger Window Manger Improved 2 (Wmii) Four Dimensional (4D) Window Manager Enlightenment (DR17) Window Manager Fluxbox Window Manager F Virtual Window Manger K Desktop Environment (KDE) Motif Window Manger Joe Window Manager P Window Manager Ratpoison Window Manager Stump Window Manager Tabbed Window Manager Waimea Window Manager (Blackbox-based) Gnome Desktop Environment Ice Window Manager Ion Window Manager Window Maker Window Manager I don't know what this is Dynamic Window Manager Lars Window Manager Window Lab Window Manager The XEmacs Window Manager
[Legend]
Date
Product
Term
Command block
Local Hyperlink
Wikipedia Link
Offsite Hyperlink

Some Xtra Bits, my follow-up email to the CHLUG mailing list after the presentation, and Joe Terranova's blog about that CHLUG meeting might also be interesting to read.

I. History

  1. V was an operating system developed at Stanford University
  2. W was its windowing system
  3. Jim Gettys and Bob Scheifler at MIT tried running W on Unix, but found it too slow
  4. They replaced the W Window System's synchronous protocol with an asynchronous protocol and called the result the X Window System
  5. X version 1 through X version 6 were developed between May 1984 and January 1985
  6. X version 7 through X version 10 were developed between Febuary 1985 and January 1986
  7. Many of the current features of the X Window System were implimented during these first two years. For example, colour support.
  8. The current protocol version, X version 11 (commonly called X11) was developed by a consortium of developers from MIT and the Digital Equipment Corporation (DEC) between May 1986 and September 1987
  9. The X reference implimenation starting with version 9 has been free software (licensed under the liberal MIT X11 license). Vendors have frequently forked the reference implimentation, extended it, and made the result proprietary software.
  10. In 1992 the XFree86 project started and forked the reference implimentation for the purpose of porting X to the x86 archetecture
  11. The XFree86 implimentation remained under a free license
  12. The XFree86 project added many features to the X Window System that were accepted into the reference implimentation
    1. They also wrote many widely used extensions for X11
  13. In 1993 HP, IBM, Novell, and Sun began to work on the Common Desktop Environment (CDE) for the X Windows System and used the proprietary Motif toolkit
    1. Early versions of Red Hat supported CDE
  14. In 1996, Matthais Ettrich proposed a unified ``look and feel'' for graphical applications in Unix and, with help, started the K Desktop Enviroment project, or KDE.
    1. KDE used the then proprietary Q toolkit; also called Qt
  15. The KDE project became propular in the community of free software users, and in August 1997, the GNU project started two projects to free users from the proprietary Qt library:
    1. The first project is GNOME, a desktop environment like KDE but that used the GIMP toolkit (also called GTK) which is licensed under the GNU Lesser General Public License
    2. The second project was Harmony which was an attempt to reimpliment the Qt libraries as free software
  16. In November 1998, the owners of Qt decided to free Qt by licensing the libraries under the GPL. Work on the Harmony project ceased.
  17. The developers of KDE and GNOME, once seperated by a legal and moral chasm, have increasingly worked together
  18. In March 2000, some developers from KDE, GNOME, and XFree86 began working together on the freedesktop.org project to design and build the future of the X Windows System
  19. In Febuary 2004, the XFree86 project leader, David Dawes announced he was changing the licensing terms of for that project's X window system distribution
    1. The Debian Project, the Free Software Foundation, and many others decided the new license was not compatible with the GPL
  20. The freedesktop.org project forked the X window system from XFree86 under the old GPL-compatible license and began distributing it as the X.org X window system
  21. In the 3 years since, freedesktop.org has rapidly implimented many new features for the Xorg distribution.
  22. Recently the Xorg reference implimentation released the X11 release 7 branch (7.2 presently)

slide 0 Slide 1 Slide 2 Slide 3 Slide 4 Slide 5 Slide 6 Slide 7 Slide 8 Slide 9 Slide 10 Slide 11 Slide 12 Slide 13 Slide 14 Slide 15 Slide 16
Slides

II. Basics

  1. X is a network protocol.
  2. In X terminology, the X server is what runs on the computer connected to the display. X clients are programs that connect to the server.
    Xnest :1                                # X without windows
    
    Xnest :1 & xterm -display :1                # X with 1 window
    
    Xnest :1 &                                  # X with twm
      twm -display :1                       # 
    
    Xnest :1 &                                  # Remote clients
      xhost +                               # connecting to my
      xmessage "Run xterm -display ...      # X server 
  3. You may have heard the axiom, in Unix everything is a file. A similar axiom applies to X: In X, everything is a window. Both axioms are flawed but are mostly useful.
  4. Window managers run as normal X clients
  5. But to manage windows, window managers ask the server to tell them when certain events happen
  6. When the window manager receives notification of an event, it can request the server perform an action
    1. For example, I showed you xterm running in X by itself without a window manager.
      Xnest :1 & xterm -display :1 
    2. If I start blackbox, a window manager, it will build a slightly larger window around the xterm that has a toolbar at the top. blackbox will also add a toolbar at the bottom of the screen
      blackbox  # from the xterm 
    3. More technically, blackbox re-parents the original window--making it a sub-window of the toolbar window
    4. blackbox knows how to talk to toolbar window, and so when I click the toolbar and move the mouse, blackbox tells the X server to move the window
      1. xeyes uses the same mechanism for following the mouse as blackbox. This is a reminder that the window manager doesn't have any special capabilities.
    5. Likewise, if I click on the minmize, maximize, or close buttons on the toolbar, blackbox either hides both windows, changes the size attributes of both windows to fit the entire screen, or terminates both window's connection to the xserver.
    6. Finally, if I interupt blackbox by pressing ^c in the xterm, all of its immediate children die with it. Re-parented windows do not.
  7. Many useful features are only available if X clients communicate with each other
    1. For example, clients can share configuration information about how they look or act
  8. Inter-client communication is most often implimented through libraries called toolkits
    1. Popular toolkits include Xt, Motif, Qt, and GTK

III. Problems

  1. The asynchronous nature of the X Window System protocol can lead to many RACE conditions. Toolkit libraries and good programing avoid most of these conditions but poor programming in alpha or beta quality clients often leads to user confusion
    1. For example, on a slow system you can change windows, say with ALT-Tab and start typing something only to have it appear in the previous window.
    2. In this case, the window manager receives the instruction to change window after the first client receives the keystrokes
  2. Inter-client communication is a difficult standard to follow and many clients and even toolkits don't fully impliment the standard or, worse, explicitly ignore parts of it
    1. Firefox is one of those applications that ignores part of the standard. When I run firefox in my preferend window manager, ion3, some of the dialouge boxes don't behave in a useful manner
  3. The network transparent natrue of the X Window System protocol uses more resources compared to other non-network transparent window systems like early Microsoft Windows and Apple Macintosh window systems
  4. Finally, important parts of the system can die and leave the system in an unusable state. We saw this when we killed blackbox earlier: without an xterm, restarting blackbox or starting any other program from within X would've been impossible.
    1. Worse problems occur; for example, clients can steal focus from all other programs, freeze or die, and never return focus control. The result is what looks like a frozen server
    2. The X server can die and not return control of the keyboard to the operating system. The Linux kernel contains code to fix common occurances of this, but it remains a hackish solution
  5. In the 5 years since I started using GNU+Linux and X, I've noticed the occurances of these problems is in sharp decline, but I believe anyone who uses X for a long time with a broad scope of actions will encounter all of these problems eventually.

IV. Useful Features

Official Commands
  1. Xnest
  2. xfontsel
    xfontsel   # choose a font and select it
    xterm -fn '<x-paste>'
  3. xwd
    xwd | xwdtopnm | pnmtopng > screendump.png 
  4. xev
    xev   # get keycode for volume up/down buttons 
    less /usr/share/hotkeys/inspiron8100.def  # show keycodes
    hotkeys -t inspiron8100   
    ogg123 xws/doc/frantic.ogg   # and press volume keys
  5. xmodmap
    xmodmap -e 'remove Lock = Caps_Lock'
  6. startx
  7. xterm
  8. xwininfo
    xwininfo -root -tree
  9. xsetroot
    xsetroot -solid red
  10. xdpyinfo
Unoffical Commands & Protocol Features
  1. Network transparency with SSH encryption
    ssh -X somehost
    xeyes
  2. VNC
  3. x-copy (and xclip)
  4. (X requires a Unix-style operating system, but Unix-style operating systems don't require X.)
  5. Window Manager choice (slideshow)