This talk was presented at the Cherry Hill Linux User’s Group 6 April 2007

?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

  • V was an operating system developed at Stanford University
  • W was its windowing system

  • Jim Gettys and Bob Scheifler at MIT tried running W on Unix, but found it too slow

  • They replaced the W Window System’s synchronous protocol with an asynchronous protocol and called the result the X Window System

  • X version 1 through X version 6 were developed between May 1984 and January 1985

  • X version 7 through X version 10 were developed between February 1985 and January 1986

  • Many of the current features of the X Window System were implimented during these first two years. For example, colour support.

  • 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

  • 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.

  • In 1992 the XFree86 project started and forked the reference implimentation for the purpose of porting X to the x86 archetecture

  • The XFree86 implimentation remained under a free license

  • The XFree86 project added many features to the X Window System that were accepted into the reference implimentation

    • They also wrote many widely used extensions for X11
  • 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

    • Early versions of Red Hat supported CDE
  • 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.

    • KDE used the then proprietary Q toolkit; also called Qt
  • 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:

    • 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

    • The second project was Harmony, which was an attempt to reimpliment the Qt libraries as free software.

  • In November 1998, the owners of Qt decided to free Qt by licensing the libraries under the GPL. Work on the Harmony project ceased.

  • The developers of KDE and GNOME, once seperated by a legal and moral chasm, have increasingly worked together

  • 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

  • In February 2004, the XFree86 project leader, David Dawes announced he was changing the licensing terms of for that project’s X window system distribution

  • The Debian Project, the Free Software Foundation, and many others decided the new license was not compatible with the GPL

  • 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

  • In the 3 years since, freedesktop.org has rapidly implimented many new features for the Xorg distribution.
  • 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

II. Basics

  • X is a network protocol.

  • 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

  • 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.

  • Window managers run as normal X clients

  • But to manage windows, window managers ask the server to tell them when certain events happen

  • When the window manager receives notification of an event, it can request the server perform an action

    • For example, I showed you xterm running in X by itself without a window manager.

    Xnest :1 & xterm -display :1

    • 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

    • More technically, blackbox re-parents the original window—making it a sub-window of the toolbar window

    • 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

    • 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.

    • 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.

    • Finally, if I interupt blackbox by pressing ^c in the xterm, all of its immediate children die with it. Re-parented windows do not.

    • Many useful features are only available if X clients communicate with each other

    • For example, clients can share configuration information about how they look or act

      • Inter-client communication is most often implimented through libraries called toolkits

      • Popular toolkits include Xt, Motif, Qt, and GTK

III. Problems

  • 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

    • 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.

    • In this case, the window manager receives the instruction to change window after the first client receives the keystrokes

  • 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

    • 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
  • 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

  • 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.

    • 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

    • 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

    • 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 think 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

  • Xnest
  • xfontsel

    xfontsel # choose a font and select it xterm -fn ‘<font-name>’

  • xwd

    xwd | xwdtopnm | pnmtopng > screendump.png

  • 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

  • xmodmap

    xmodmap -e ‘remove Lock = Caps_Lock’

  • startx
  • xterm
  • xwininfo

    xwininfo -root -tree

  • xsetroot

    xsetroot -solid red

  • xdpyinfo

Unoffical Commands & Protocol Features

  • Network transparency with SSH encryption

    ssh -X somehost xeyes

  • VNC
  • x-copy (and xclip)
  • (X requires a Unix-style operating system, but Unix-style operating systems don’t require X.)
  • Window Manager choice (slideshow)