5Topics X Windows X Protocol Classic X apps Starting X apps Window managersDesktop environmentsDesktop applications
6X WindowThe X Window system was developed as part of Project Athena at MIT. In 1987, X Version 11 is released. X is now controlled and maintained by the Open Group.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.
7The Graphic User Interface in X X Window uses a bit-mapped display where each pixel can be manipulated individually.The entire display is known as the root window, and individual applications are displayed as windows on this root window.X is started with the startx or xinit commands.X can also be invoked during system startup
8X ProtocolThe 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.
9X Protocol cont’dThe X Protocol is also divided into device dependent and device independent layers.
10X Server Design Device Dependent Layer It is this layer that is responsible for localizing the X server to the native environment, be it MS Windows or Solaris.This layer swaps bytes of data from machines with differing byte ordering. Byte ordering (MSB and LSB) is noted in each X request.This layer hides the architectural differences in hardware and operating systems.Maintains device driver dependencies for keyboard, mouse and video.
11Networked WindowingX Window designed to allow apps to run on remote machinesUses client-server modelX Serverstd system softwareClientapp softwareNetworkUser
12X architectureThe client-server nature of the X Protocol allows a single X server to support many clients (applications) on several hosts.
13Client-Server Window System Could be Window ManagerClient ApplicationProgramsApplication 1Application 2Application nVirtual display 1Virtual display 2Virtual display nServerResource allocatorDevice-independent abstraction levelDevicedriverTranslates abstraction into reality:one per terminal typeWindow 1DevicesKeyboardMouseWindow 2Window n(After Fig 10.2, Dix, Finlay, Abowd and Beale)
14X Protocol messagesRequests – client sends requests to the server (e.g. create window)Replies – server response to client requestsEvents – server forwards events (such as mouse clicks or keyboard entry) to the clientErrors – server reports errors to the client
16X Server The X server therefore: displays drawing requests on the screen.replies to information requests.reports an error in a request.Manages the keyboard, mouse and display device.Multiplexes keyboard and mouse input onto the network (or via local IPC) to the respective X clients. (X events)creates, maps and destroys windows.writes and draws in windows
17X Client sends requests to the server. receives events from server. receives errors from the server
18Protocol Messages Requests X clients make requests to the X server for a certain action to take place. i.e.: Create WindowTo enhance performance, the X client normally does not expect nor wait for a response. The request is typically left to the reliable network layer to deliver.
19Protocol Messages Replies The X server will respond to certain X client requests that require a reply. As noted, not all requests require a reply.
20Protocol Messages Events The X server will forward to the X client an event that the application is expecting. This could include keyboard or mouse input. To minimize network traffic, only expected events are sent to X clients.X events are 32 bytes
21Protocol Messages Errors The X server will report errors in requests to the X client. Errors are like an event but are handled differently.X errors are the same size as events to simplify their handling. They are sent to the error handling routine of the X client.
22X Windows Protocol Overview X Windows is the predominate windowing system on UNIX computers, developed by the X Consortium, lead by M.I.T. An X server manages the display on the workstation. Clients can connect to server via TCP/IP and perform graphics operations. This makes X Windows much more network capable than Microsoft Windows, for example, which can only be accessed via a local API.X Windows operates over TCP, typically using server port numbers starting with The X server for a system's first display listens on port 6000; if the system has a second display, its server listens on port 6001; a third display would listen on 6002; etc. The protocol used over this reliable stream connection is essentially request/reply, and it's reputation is as a fat protocol that consumes a lot of bandwidth. Lightweight X (LWX), introduced in X11R6, attempts to reduces X's bandwidth needs to the point where it can be run over dialup modem connections.The X Protocol, documented in a postscript file, defines dozens of messages that can be exchanged between a client and a server. They can generally be classified into four categories: Requests, Replies, Events, and Errors. Typical requests include Draw PolyLine, Draw Text, Create Window, Fill. Replies are matched to particular Requests. Events are asynchronous occurances such as keystrokes and mouse clicks. Errors are matched to particular Requests.If a window is partially or fully obscured by another, overlapping window, the server has two options available to it. The server can allocate additional memory, called backing store, to record to contents of the obscured window. This is purely optional, however. The server can simply ignore the obscured part of the window. Later, when that part of the window becomes visible again, the server sends an Expose event to the client, which must then redraw the affected area. The client, therefore, must be prepared to redraw any part of its windows at any time.Applications do not need to access the X Windows protocol directly. X Windows supports several APIs. The most basic of these is Xlib, which interfaces fairly directly to the underlying network protocol. Most X client applications are linked against Xlib, which allows them to operate on either a local or remote X server, simply by adjusting either an environment variable or a command-line argument.Widgets layer on top of Xlib and provide X Windows with an object-oriented programming model. A widget is an X window capable of handling most of its own protocol interaction. The most popular widget sets are Athena Widgets (aw) and Motif.X Window's security model is all-or-nothing. Either an application can perform any operation on an X desktop, or it can perform none. There is no concept of limiting an application to a single top-level window, for example. Although there is power in this model, such as allowing the window manager to be a normal X client, there are also serious security implications. A hostile X client could connect to an X server and arrange to capture any screen image, or even to capture keystrokes as a password is being typing in one of the windows. For this reasons, X servers are typically fairly restrictive about which clients they will accept connections from. Two major security models are available. Host-based security (traditionally controlled by the xhost program), permits or denies connections based on their source IP addresses. Authentication (traditionally controlled by the xauth program), requires the connecting program to possess a secret password, typically stored in a UNIX file and subject to standard UNIX access controls. Kerberos-based authentication is also available.
23Starting X WindowsOn a local PC or workstation, you can usually start the X server with the “xinit” (“startx”) command or it may be started automatically by “xdm” (graphical login display).Configuration stored in /etc/XF86ConfigUsually edited with utility /usr/X11R6/bin/xf86configor /usr/X11R6/bin/xf86cfg
25Configuring X Windows mouseconfig xconfigurator Command used to configure a mouse for use by X WindowsxconfiguratorA program that is used to configure video adapter card and monitor information for use by X Windowsredhat-config-xfree86 used in recent Red Hat & in Fedora
26Configuring X Windows Fedora and X Windows configuration Fedora has greatly improved video & monitor detectionNot included in Fedora (Red Hat only):SuperProbeXf86configXconfigurator
27Starting 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 +remotehost2) The target display for the remote application.setenv DISPLAY=server:display[hostname]:displaynumber[.screennumber]not needed, if same host“0” in most casesdefaults to “0”
28/etc/X11/xinit/xinitrc (xinit) or /home/g/.xsession (xdm) #!/bin/sh# $Id: xinitrc,v /02/27 19:03:30 jharper Exp $xrdb -load $HOME/.Xresourcesxsetroot -solid gray &xclock -g 50x bw 0 &xterm &# start the window managerexec twmloads resources: default fonts, colours, window sizeslast line: replaces shell-script with window manager, will terminate all background processes on exitxinit executes this script
29GUI HistoryIn 1962, Douglas Engelbart invented the first “mouse,” which he called an “X-Y Position Indicator.”It was a little gizmo housed in a wooden box on wheels that moved around the desktop and took the cursor with it on the display.Sketchpad pioneered the concepts of graphical computing, including memory structures to store objects, rubber-banding of lines, the ability to zoom in and out on the display, and the ability to make perfect lines, corners, and joints.Source: US Patent Office
30GUI HistoryIn 1963 a grad student at MIT, Ivan Sutherland, submitted as his thesis a program called “Sketchpad.” This was the first GUI (Graphical User Interface) long before the term was coined."
31GUI HistoryIn the 1970s, at Xerox’s PARC facility, Alan Keys created an object-oriented graphical programming language called “Smalltalk.” Smalltalk featured a graphical user interface (GUI) that looked suspiciously similar to later iterations from both Apple and Microsoft.First system based upon usability engineeringinspired designextensive paper prototyping and usage analysisusability testing with potential usersiterative refinement of interface
32GUI History1981, Xerox attempted to market the “Star.” It introduced the idea of what you see is what you get (WYSIWYG).Commercial failurecost ($15,000);IBM had just announced a less expensive machinelimited functionalitye.g., no spreadsheetclosed architecture,3rd party vendors could not add applicationsperceived as slowbut really fast!slavish adherence to direct manipulation
33Apple gets a GUI In 1983, the Apple Lisa was first GUI offering. Apple II, 1980Lisa
34Apple gets a GUIIn 1984, Macintosh was the first computer with a GUI marketed to the masses.“old ideas” but well done!Commercial success because:aggressive pricing ($2500)did not need to trail blazelearned from mistakes of Lisa and corrected them; ideas now “mature”market now ready for themdeveloper’s toolkit encouraged 3rd party non-Apple softwareinterface guidelines encouraged consistency between applicationsdomination in desktop publishing because of affordable laser printer and excellent graphicsFull Microsoft Office suite (Apple was the dominant player at this time.)
35Microsoft Gets a GUI Microsoft introduced Windows 1.0 in 1985 Tiled Windows, no overlappingWindows 2.03 in 1987Overlapping windowsWindows 3.0 in 1990Features Program Manager
36Unix Gets a GUIThe X Windows System was introduced in the mid-1980s to provide graphical support for unix operating systems.The implementation was a client-server approach, where an X window system server ran on the displaying machine, and the client programs communicated with it using a network protocol.X provides only a communication mechanism, not policy. At least three major user interface look & feel styles are widely used on X - MIT's own Athena style, Sun and AT&T's OpenLook, and OSF's Motif (supported primarily by HP and IBM).
37ShellsUnix and DOS operating systems circa 1980s support text-based user interfaces via a program called a shell. These shells insert another layer between the user and the operating system. Typical text shells under unix are csh and ksh. The typical text shell under microsoft is command.com. It is still emulated today by cmd.exe.Original unix and Microsoft GUI support was also implemented as shells. The dominant unix GUI library became an open library called X11 supported by the X.org foundation. Microsoft introduced Windows 1.0 as a shell that ran on a layer above MS-DOS.The original Apple GUI is embedded into its operating system kernel. Windows migrated to embedding GUI support beginning with Windows NT.The Microsoft shell command.com is delivered as part of its MS-DOS operating system. IBM’s proprietary clone PC-DOS, and its original competitor DR-DOS.
38Windows TimelineIt took roughly 15 years to consolidate its shell-based GUI architecture offerings with its embedded GUI architecture offerings.
39Window managers One can use X11 without a window manager. Typically, one writes a session script which starts an "xterm" at a "-geometry" location. One then starts other X11 clients by giving their "-geometry" explicitly, because there is no window managerThe 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.When a window manager is running, some of interaction between the X server and its clients is redirected through the window manager.Classic window managers include:TWMMWM - Motif Window ManagerNowadays, KDE (kwm) and GNOME (sawfish) are two widely used window managers in Linux.
41xtermThe most important X application is, rather ironically, the terminal program xterm.Old school xterm:
42xterm: The Main ClientYou can invoke all UNIX commands and X programs form the UNIX command line available in an xterm window.xterm can also be used with a scrollbar(-sb), and the number of lines saved can be specified (-sl).You can position and specify the size and position of a window (-geometry) and its foreground and background color (-fg and -bg).You can start a program as an icon (-icon) and provide a name (-name) or title (-title).
43Some classic X appsxclock – pretty self-explanatory
44Some classic X appsxeyes – ok, this is really the most important
48X and the GUIX itself provides the back end needed for a GUI. It doesn’t, however, provide an interface itself.Window management functions – e.g. moving or resizing windows – are performed by a window manager, which is itself an X client. These range from the spartan (twm) to the complex and graphically intensive (Enlightenment).There are various different toolkits for creating graphical applications, providing libraries of widgets such as buttons etc. These range from the old and ugly (Motif) to the new and shiny (GTK+, Qt)No two users can be assumed to have the same window manager and different applications can use different toolkits (or even write their own). Therefore, there’s a lack of consistency about the average X desktop – this makes things ugly and can be hard to use.
49Why not only a basic X11 environment? Most X11 applications have important shortcomings:Application Interoperability is too hardUser Interface is inconsistent and of unequal qualityModern desktop environment brings the "glue"Drag & Drop, Session Management, etc...Consistent "look and feel"Unified Help SystemEasy dialog based desktop configurationCommon application development framework (-> MFC)Compound document framework (-> OLE)New exciting possibilities:Hundreds of new applications (including Office)Powerful application development environment
54KDE KDE is the traditional desktop environment used on Linux systems K Windows Manager (kwm)The window manager that works under the KDE Desktop EnvironmentQt toolkitSoftware toolkit used with the KDE Desktop environment
55Linux Developement Qt Class Library C++ Cross Platform Qt/WindowsQt/X11 (Linux, Solaris, HPUX, AIX, etc)Qt/MacGPL – Free for non-commercial appsQt was used to build KDEfrom Trolltech in Norway
58Gnome GNOME Desktop Environment Default desktop environment in Red Hat LinuxTypically uses the Sawfish Window Manager and the GTK+ toolkit for the C programming languageThe GTK+ toolkit was originally developed for the GNU Image Manipulation Program (GIMP)Ported also to MS Win, MacOS X planned
59BluecurveBluecurveBoth a visual theme and a set of modifications to the KDE and GNOME environmentsGives both a common “look & feel”Smooths out inconsistent behaviors between the different WMs
65What is a desktop? It is the top of a desk It is a pc cabinet for the desktopIt is the graphical user interface (GUI) on a pcIt is the graphical enviroment for the average user on a pc
66KDE and GNOME K Desktop Environment KDE is a "complete desktop environment that try to make linux accessible to everybody"At present KDE 3.5GNU Network Object Model EnvironmentAIM: "GNOME Intends to build a complete, user- friendly desktop, similar to CDE or KDE, but based entirely on free software"At present GNOME 2.14
87Using X windows remotely on a MS-Windows machine. You need to get a program called an “Xserver”. Exceed works well and is free for academic use. Cygwin is another option.You must allow X-forwarding through your ssh client. Putty is good for this.
92X server security configuration xhostxhost simply allows you to specify which machines are, or aren't allowed to connect to the X server, this is a very simplistic security mechanism and is not really suitable in any modern environment, however used in conjunction with other mechanisms it can help. The command is quite simple: 'xhost +example.org' adds example.org, 'xhost -example.org' removes example.org from the list, you must also specify 'xhost -' to turn on the access control list, or else everyone is let in by default.mkxauthmkxauth is definitely a step up from xhost. mkxauth helps create ~/.Xauthority files, and merge them, which are used to specify hostnames and the related magic cookies (basically a token used to gain access). These cookies can then be used to gain access to a remote X host (you essentially have a copy of the cookie on each end) and are transferred either plain text (insecure) or DES encrypted (quite secure). Using this method you can be relatively safe and secure. Xauthority files can also be used in conjunction with Kerberos, removing the necessity to copy Xauthority files around and keep them in synchronization. Hosts authenticate to each other through a central Kerberos key server(s) in an encrypted fashion, this method is most appropriate for large installations/etc. mkxauth has an excellent man page 'man mkxauth' and more generalized details are available in the Xsecurity man page (not sure how common this name page is) 'man Xsecurity'.SSH tunnelSSH or OpenSSH can be used to create a tunnel between hosts (or more specifically between two X servers), thus encrypting the channel, providing authentication, and generally making things safer. The following web page explains it
94Apple’s Boiled Sweets diagram Mac OS X ArchitectureApple’s Boiled Sweets diagram
95The Smartphone Platform With the iPhone being the first to the marketplace it sets the configuration of the Smartphone Platform3G/4G connectivityWiFi connectivityBluetooth connectivityaccelerometer w/compassambient light sensorproximity sensorGPSgyroscope
96What is iOSApple’s mobile OS for phones (iPhone), tablets (iPad), handhelds (iPod),based on BSD UnixApplication programming done in Objective CSupports Bluetooth, Wi-Fi, and 3G and 4G networking
98What is AndroidAndroid is an open source operating system, created by Google specifically for use on mobile devices (cell phones and tablets)Linux based (2.6 kernel)Can be programmed in C/C++ but most app development is done in Java (Java access to C Libraries via JNI (Java Native Interface))Supports Bluetooth, Wi-Fi, and 3G and 4G networking
100Main GUI parts Status Bar Home Screen App Screen Favourites Tray Navigation bar(Android 3.0+)
101Commonly Used Packages User interface controls and widgetsUser interface layoutSecure networking and web browsingStructured storage and relational databases (SQLite RDBMS)2D and 3D Graphics SGL and OpenGLAudio and visual media supportAccess to optional hardware (GPS)
109Android Basics Open source OS Uses Linux kernel Optimized for limited-resource environmentApps typically written in JavaApps run on the Dalvik Virtual MachineNot a JVM, but works similarly from developer’s point of viewUsually one app per DVMEach DVM runs under Linux as a separate userApp permissions set at install timePossible to use C or C++ compiled to machine code, but still runs on VM.