Windowing Systems
Total Page:16
File Type:pdf, Size:1020Kb
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 direcQons determines the display’s resoluQon. § Add a mouse device as a poinQng device § Provides (x,y) coordinates or relave moQon § KeyBoard conQnues 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 desQned for, or coming from, user-level applicaons which requires synchronizaon Between the OS kernel device driver rouQnes and the user-level code that consumes or produces the data. ¢ Buffering is typically supported inside the OS to allow applicaons 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 soGware § Like the OS, windowing systems have Become massive pieces of so[ware. § In many cases they are Qghtly 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 alternave implementaons of the windowing system. ¢ Enhance the device driver of a graphical user display § Provide higher level API calls that applicaons can invoke to manipulate the display. § Provide common “window system abstracQons” needed By most applicaons. examples include text windows, Bu\ons, radio Boxes, menus, scrollBars, etc. § Hide many of the mouse interrupts from the applicaon, only passing key “events” to the applicaon. For example, mouse moQon are o[en handled By the windowing system, only passing mouse click events to the applicaon. 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 Consorum. ¢ It is a networked windowing system implying that it can used By remote applicaons ¢ 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 applicaons use the network (TCP/IP) to interact with the X-server and create the “windows” required By the applicaon. 7 CS 485 Systems Programming X window applicaons 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 Operang System X Display Driver Hardware 9 CS 485 Systems Programming X-Window Architecture X Server Operang System X Display Driver Hardware 10 CS 485 Systems Programming X-Window Architecture App 1 X Server ApplicaJons “speak” Operang 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 Operang System X Display Driver Hardware 12 CS 485 Systems Programming Xlib ¢ A library that handles all X communicaJon for ApplicaJons ¢ Supports basic “drawing” operaons § Draw a line at this locaon § Tell me that the mouse moved, or the mouse was clicked § etc ¢ While it simplifies talking to the X server, it is sJll difficult to create the types of nice user interface things that people are used to using (e.g., buons, sliders, etc). 13 CS 485 Systems Programming X-Window Architecture App 1 X Server Toolkit Xlib Operang System X Display Driver Hardware 14 CS 485 Systems Programming Toolkits ¢ Toolkits are designed to help applicaon create useful graphical user interfaces. ¢ They do not necessary define the “look and feel”, But rather help create the “funcQonality”. ¢ 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: § MoQf § Gtk § Qt § Xforms § FLTK § LessTif 15 CS 485 Systems Programming X-Window Architecture Window Manager App 1 X Server Toolkit Xlib Operang 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 Qtle Bars and what features those Qtle Bars support § etc ¢ Window managers are just X clients like applicaons – alBeit special applicaons. ¢ 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 Operang System Operang 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 Operang System Operang 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 .