COMP 121-401: UNIX Programming X Windows Andrew Nashel nashel@cs.unc.edu Department of Computer Science February 4, 2004 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Course topics • X Windows ♦ ♦ ♦ ♦ X Protocol Window managers Classic X apps Starting X apps The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL X Windows The X Windows System, also referred to as ‘X’ or “X11”, is the standard graphical engine for Unix and Linux. It is largely OS and hardware independent, it is network-transparent, and it supports many different desktops. The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL X Windows cont’d X was developed in the mid 80’s to provide a standard GUI for Unix systems, similar to Microsoft Windows. Windows only runs locally on the machine, but X Windows uses the X Protocol to separate the processing and display for an application. The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL X Protocol The X Protocol provides a client-server architecture at the application level: The X client is the processing part of the application and often runs on a remote machine. The X server is the display and interaction system. The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL X Protocol cont’d The X Protocol is also divided into device dependent and device independent layers. The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL X architecture The client-server nature of the X Protocol allows a single X server to support many clients (applications) on several hosts. The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Client-server design X server • Runs locally and accepts multiple X clients • Displays drawing requests and errors • Handles keyboard, video, and mouse • Creates and destroys windows X client • An application written using X libraries (e.g. Xlib) • Sends request and receives events and errors The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL X Protocol messages Requests – client sends requests to the server (e.g. create window) Replies – server response to client requests Events – server forwards events (such as mouse clicks or keyboard entry) to the client Errors – server reports errors to the client The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL An aside: XFree86 What is XFree86? “In short, XFree86 is an open source X11based desktop infrastructure.” – xfree86.org It runs primarily on Unix and Unix-like OSes such as Linux (and also under Cygwin). The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Using X Windows First, an X server must be running: On a local PC or workstation, you can usually start the X server with the “startx” command or it may start automatically, presenting a graphical login display. Historical note: An X terminal is a dumb terminal that only runs the X server locally, and always connects to X clients on a remote host. The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL xterm The most important X application is, rather ironically, the terminal program xterm. Old school xterm: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Xterm cont’d Fancy xterm: OS X xterm: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL An aside: Copying text In X Windows, the copying interaction is very different from the Ctrl-C/Ctrl-V of Windows. In an xterm or other X application, highlight the text with the left button, and then paste by middle clicking in any window accepting input. The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Some classic X apps xman – manual pages app Not this The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Some classic X apps xbiff – mail notification Back when we didn’t have mail servers (and we liked it!), mail was stored in local spool files and a process notified the user of new mail. xbiff is named after biff, which is named after Biff the dog, who barked at the postman. Seriously. The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Some classic X apps xeyes – ok, this is really the most important The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Some classic X apps xclock – pretty self-explanatory The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Window managers The window manager is a special X client that controls the placement and movement of applications, provides title bars and control buttons, menus and taskbars. Some support virtual desktops and very fancy graphics. Classic window managers include: twm, mwm, olwm, fvwm The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Starting X applications To launch an X client from a remote host for display on the local X server, you need to set two things: 1) Permission for the remote host to display X clients on the local machine. xhost +remotehost 2) The target display for the remote application. setenv DISPLAY=server:display The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
© Copyright 2025 Paperzz