
User Interface Programming X Window Jozef Mlích Department of Computer Graphics and Multimedia Faculty of Information Technology, Brno University of Technology Božetěchova 2, 612 66 Brno, Czech Republic http://www.fit.vutbr.cz/~imlich/ [email protected] 13.10.2010 Agenda History How things works – XServer – XProtocol – Extensions – Useful tools Programing of XApplications – Xlib – toolkits (xtoolkit, motif, gtk, qt, wxWindows) – Makefile/imake/qmake/autotools/cmake – printf(ªHello XWindow\nº); http://www.fit.vutbr.cz/~imlich/ ITU: X Window | 2 / 26 History June 1984 - X1 First use of the name "X" February 1986 - X10R3 First release outside MIT. September 15, 1987 ± X11 First release of the current protocol. March 31, 1998 - X11R6.4 Xinerama April 6, 2004 - X11R6.7.0 First X.Org Foundation release October 2, 2009 ± x.org 1.7 Multi-pointer X (MPX) http://www.fit.vutbr.cz/~imlich/ ITU: X Window | 3 / 26 How things works - XServer What is XServer? extension of the operating system providing a graphical user interface (for Linux / QNX / windows / etc.) Features: client-server architecture network transparent hardware independent the system is not only centralized or only distributed extendable http://www.fit.vutbr.cz/~imlich/ ITU: X Window | 4 / 26 How things works - XServer 2 Graphical user interface in this case consists of X Server window manager – window position and layout (KDE, gnome, blackbox, ..) session manager – manages the environment related to one session (xsm, ksmserver) – X Session Management Protocol (XSMP) toolkits (Qt, Gtk, Xtoolkit, Motif) applications http://www.fit.vutbr.cz/~imlich/ ITU: X Window | 5 / 26 How things works - XServer 3 Windows are in tree hierarchy Main window is window manager (kde/gnome/xfce/etc.) Position of window elements is relative to parent window Each window is processed in the X server separately http://www.fit.vutbr.cz/~imlich/ ITU: X Window | 6 / 26 How things works - XServer 4 single session (single user) KDE window manager – takes care about title bar, borders of window – contains special applications (desktop icons/panel with task list..) Applications – programmed in different toolkits (konsole is based on KDE/Qt, Epiphany is based on Gtk) http://www.fit.vutbr.cz/~imlich/ ITU: X Window | 7 / 26 How things works - XServer 5 http://www.fit.vutbr.cz/~imlich/ ITU: X Window | 8 / 26 How things works - XServer 6 X Server ± X Klient vs. Server ± Klient X server is running on graphical workstation ± takes care about rendering, keyboard and mouse events X Clients is on backend of program (computationally intensive simulation / database connection / etc. ) http://www.fit.vutbr.cz/~imlich/ ITU: X Window | 9 / 26 How things works - X Window Core Protocol standardized (ICCCM, EWMH, XDS, Freedesktop) could use TCP/IP, pipes or shared memory used by all applications (including window manager and session manager) different XServers are compatible with different XClients open source / binary compatible http://www.fit.vutbr.cz/~imlich/ ITU: X Window | 10 / 26 How things works - X Window Core Protocol 2 requests – The client requests information from the server or requests it to perform an action. replies – The server responds to a request. Not all requests generate replies. events – The server sends an event to the client, e.g., keyboard or mouse input, or a window being moved /resized/exposed. errors – The server sends an error packet if a request is invalid. http://www.fit.vutbr.cz/~imlich/ ITU: X Window | 11 / 26 How things works - X Window Core Protocol 3 Windows – defined by size and position – tree hierarchy – InputOutput vs. InputOnly (invisible, event handling) Pixmaps – few memory chunks / rendered on request – it is possible to display it into the window (double buffering) Graphical Context (GC) and fonts – similar like in windows – structure for window rendering (including foreground and background color, font, destination pixmap or window, etc.) – accesible only by Xfunctions http://www.fit.vutbr.cz/~imlich/ ITU: X Window | 12 / 26 How things works - X Window Core Protocol 4 Resources and identifiers – Identifier is just ªpointerº (32-bit integer) on resource – Resource: Window, Pixmap, Font, Colormap, Graphic context Events – KeyPressed, etc. – Expose (XClient want to repaint part of window) Atoms – 32-bit integer http://www.fit.vutbr.cz/~imlich/ ITU: X Window | 13 / 26 How things works - Extension XServer is designed to be robust. DPMS ± power management MIT-SHM ± shared memory SHAPE ± non-rectangular windows RANDR ± dynamical change of resolution, screen rotation RENDER ± antialiasing, alpha blending, atd. XKEYBOARD ± enhanced keyboard layout handling. XINEREMA ± desktop on more monitors XVideo (XV) ± hardware acceleration of video http://www.fit.vutbr.cz/~imlich/ ITU: X Window | 14 / 26 How things works - useful tools Remote connection – ssh -X – xming (http://sourceforge.net/projects/xming), xwinlogon xnest – more xservers on same computer xdpyinfo – list of supported extensions xwininfo – detailed information about window glxinfo – detailed information about OpenGL extension of X Window System http://www.fit.vutbr.cz/~imlich/ ITU: X Window | 15 / 26 How things works - useful tools 2 xrandr – Section "Screen" Option "RandRRotation" "true" xev – X events of window zenity/kdialog/xdialog – very nice in combination with bash/shell scripts – zenity --file-selection – kdialog --yesno "Is this boring?" xnee ± tool for users actions recording and replaying xrestop ± resources allocated by xserver http://www.fit.vutbr.cz/~imlich/ ITU: X Window | 16 / 26 How things works - useful tools 3 xwit ± command line tool for setting of window parameters xautomation ± set of command line tools (xte) http://www.fit.vutbr.cz/~imlich/ ITU: X Window | 17 / 26 Programing of XApplications - Xlib Xlib provides C API for X Protocol Some basic functions – XOpenDisplay(char *display_name), XCloseDisplay, XSetCloseDownMode – char *display_name=ªhostname:number.screen_numberº – XLockDisplay, XUnlockDisplay – XAddConnectionWatch, XRemoveConnectionWatch – XCreateWindow, XcreateSimpleWindow, XDestroyWindow, XDestroySubwindows – _X11TransConnectDisplay, _X11TransGetConnectionNumber, _XSendClientPrefix, _X11TransGetConnectionNumber http://www.fit.vutbr.cz/~imlich/ ITU: X Window | 18 / 26 Programing of XApplications - Xlib 2 Graphical Operations – XDrawPoint, XDrawLine, XDrawRectangle, XDrawSegments, XDrawArc, XDrawString, XDrawImageString, XDrawText, XCopyArea, XCopyPlane, XPutImage, XDefineCursor User interaction – KeyPress, KeyRelease, MappingNotify, FocusIn, FocusOut – ButtonPress, ButtonRelease, MotionNotify, EnterNotify, LeaveNotify http://www.fit.vutbr.cz/~imlich/ ITU: X Window | 19 / 26 Programing of XApplications - Xlib 3 Notification about application state – Expose, GraphicsExpose, NoExpose, ColormapNotify, VisibilityNotify – CirculateNotify, ConfigureNotify, CreateNotify, DestroyNotify, GravityNotify, MapNotify, ReparentNotify, UnmapNotify Messages from different application – ClientMessage, PropertyNotify, SelectionClear, SelectionRequest, SelectionNotify http://www.fit.vutbr.cz/~imlich/ ITU: X Window | 20 / 26 Programing of XApplications - Xlib 4 ± Xlib vs. WinAPI http://www.fit.vutbr.cz/~imlich/ ITU: X Window | 21 / 26 Programing of XApplications - Xlib 5 Conclusions: Xlib is to low level for normal GUI applications but it is very nice for low level things – user interface analysis, reader for blind people – own gui toolkit – XServer hacking (acceleration, new features) Future: XCB (X C Binding) ± less complex, closer to X protocol http://www.fit.vutbr.cz/~imlich/ ITU: X Window | 22 / 26 Programing of XApplications - Xtoolkit, motif extension of Xlib by some basic elements (buttons, scrollbars, etc.) still very low level and programer unfriendly http://www.fit.vutbr.cz/~imlich/ ITU: X Window | 23 / 26 Programing of XApplications - Gtk, Gtkmm very popular because of licence GUI description is in Glade Gtkmm is object oriented extension of Gtk http://www.fit.vutbr.cz/~imlich/ ITU: X Window | 24 / 26 Programing of XApplications - Qt qtassistant ± documentation qdesigner ± gui designer (paint the gui, save as xml, compile to header file) qmake ± qenerator of makefile for Qt cmake ± generator of makefile for KDE moc ± meta object compiler (there is a macro language designed for internal communication based on ªslotsº and ªsignalsº) http://www.fit.vutbr.cz/~imlich/ ITU: X Window | 25 / 26 Credits Materials are based on GUX and ITU Lectures writen by ing. Lampa http://en.wikipedia.org/wiki/X_Window_System http://en.wikipedia.org/wiki/X_protocol http://tronche.com/gui/x/xlib/ http://www.kiv.zcu.cz/~luki/vyuka/stare-materialy/os/oslinux/2.0.31/sak4/xx.htm http://wiki.qtcentre.org/ https://fedoraproject.org/wiki/JaroslavReznik/Presentations/FUDCon2008Brno http://www.fit.vutbr.cz/~imlich/ ITU: X Window | 26 / 26 .
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages26 Page
-
File Size-