CS 485 Systems Programming
Windowing Systems
CS 485 Systems Programming Fall 2015
Instructor: James Griffioen
1 CS 485 Systems Programming
User Interfaces
¢ Terminals § Simple devices connected via serial lines § Character-oriented devices § Support both input and output (keyboard + terminal) § Input/output generates hardware interrupts to the OS on every character ¢ Graphical Users Displays § Replace the simply terminal with a (color) bitmapped display § Display divided into pixels § Color of each pixel is defined by a number § The pixel depth (number of bits per pixel) defines the number of colors supported § The number of pixels in the x and y direc ons determines the display’s resolu on. § Add a mouse device as a poin ng device § Provides (x,y) coordinates or rela ve mo on § Keyboard con nues to provide character input § Keyboard, mouse, and display generate interrupts to the OS § Most displays are now driven by GPUs (graphics processing units) that offload work that would otherwise have to be done by OS/Windowing system code running on the CPU.
2 CS 485 Systems Programming
Device Driver Basics
¢ Device drivers handle interrupts from devices ¢ Are device-specific and o en include low-level code wri en in ASM ¢ O en must handle both input and output interrupts ¢ Data is usually des ned for, or coming from, user-level applica ons which requires synchroniza on between the OS kernel device driver rou nes and the user-level code that consumes or produces the data. ¢ Buffering is typically supported inside the OS to allow applica ons to run ahead of output or run behind input. ¢ Because buffers are finite, blocking is necessary to prevent buffer overflow.
3 CS 485 Systems Programming
Device Drivers
App
I/O Systems Calls
Kernel I/O Buffer
I/O Handler
CPU MEM TTY
5 CS 485 Systems Programming
Windowing Systems
¢ Are complex pieces of so ware § Like the OS, windowing systems have become massive pieces of so ware. § In many cases they are ghtly integrated with the OS (i.e., the windowing system is integral to the OS). In other cases windowing system is modular, and can be (easily) replaced with alterna ve implementa ons of the windowing system. ¢ Enhance the device driver of a graphical user display § Provide higher level API calls that applica ons can invoke to manipulate the display. § Provide common “window system abstrac ons” needed by most applica ons. Examples include text windows, bu ons, radio boxes, menus, scrollbars, etc. § Hide many of the mouse interrupts from the applica on, only passing key “events” to the applica on. For example, mouse mo on are o en handled by the windowing system, only passing mouse click events to the applica on.
6 CS 485 Systems Programming
X Windows
¢ A modular windowing system used on most Unix systems ¢ Developed as part of the Athena project at MIT in the mid 1980’s and was later taken over and supported by the X Consor um. ¢ It is a networked windowing system implying that it can used by remote applica ons ¢ It has a well-defined protocol (the X protocol) that defines the messages that can be sent to, and received from the Windowing system. ¢ A server, knows as the X-server, controls/manages the physical graphical display, rendering images on the display and handling interrupts from the mouse and keyboard. ¢ User applica ons use the network (TCP/IP) to interact with the X-server and create the “windows” required by the applica on.
7 CS 485 Systems Programming
X window applica ons can run anywhere
Window Window on main on laptop frame
Window Window on on smart super phone computer
8 CS 485 Systems Programming
X-Window Architecture
X Server
Opera ng System X Display Driver
Hardware
9 CS 485 Systems Programming
X-Window Architecture
X Server
Opera ng System X Display Driver
Hardware
10 CS 485 Systems Programming
X-Window Architecture
App 1 X Server
Applica ons “speak” Opera ng System the X protocol to the X server. X Display Driver
Hardware
11 CS 485 Systems Programming
X-Window Architecture
App 1 X Server
Xlib Opera ng System X Display Driver
Hardware
12 CS 485 Systems Programming
Xlib
¢ A library that handles all X communica on for Applica ons ¢ Supports basic “drawing” opera ons § Draw a line at this loca on § Tell me that the mouse moved, or the mouse was clicked § Etc ¢ While it simplifies talking to the X server, it is s ll difficult to create the types of nice user interface things that people are used to using (e.g., bu ons, sliders, etc).
13 CS 485 Systems Programming
X-Window Architecture
App 1 X Server Toolkit Xlib Opera ng System X Display Driver
Hardware
14 CS 485 Systems Programming
Toolkits
¢ Toolkits are designed to help applica on create useful graphical user interfaces. ¢ They do not necessary define the “look and feel”, but rather help create the “func onality”. ¢ Toolkits offer common widgets via a “widget library”. Example widgets include bu ons, scroll bars, radio bu ons, sliders, etc. They o en also support “canvas” widgets that provide an area of the screen on which other things can be drawn or displayed. ¢ Many different widget libraries and toolkits: § Mo f § Gtk § Qt § Xforms § FLTK § LessTif
15 CS 485 Systems Programming
X-Window Architecture
Window Manager
App 1 X Server Toolkit Xlib Opera ng System X Display Driver
Hardware
16 CS 485 Systems Programming
Window Managers
¢ Window managers manage the way windows look and feel § The way windows are placed on the display § How windows are moved around on the screen § How they are iconified § Possibly defining whether they have tle bars and what features those tle bars support § Etc ¢ Window managers are just X clients like applica ons – albeit special applica ons. ¢ Example Window Managers include: § twm § fvwm § sawfish § kwm § icewm § enlightenment § metacity
17 CS 485 Systems Programming
X-Window Architecture
Window Manager
App 1 App 2 X Server Toolkit Toolkit Xlib Xlib Opera ng System Opera ng X Display Driver System Hardware Hardware
Network
18 CS 485 Systems Programming
X-Window Architecture
Desktop Window Manager
App 1 App 2 X Server Toolkit Toolkit Xlib Xlib Opera ng System Opera ng X Display Driver System Hardware Hardware
Network
19 CS 485 Systems Programming
Desktops
¢ Desktops are used to § Define a consistent look and feel across windows § Provide useful services and features (e.g., panels, a visible “desktop” folder, lauch bars, trash, etc.) ¢ Example Desktops include: § Gnome § KDE § Xfce
20