Presentation is loading. Please wait.

Presentation is loading. Please wait.

27.9.2016 User Interface Programming X Window Jozef Mlích Department of Computer Graphics and Multimedia Faculty of Information Technology, Brno University.

Similar presentations


Presentation on theme: "27.9.2016 User Interface Programming X Window Jozef Mlích Department of Computer Graphics and Multimedia Faculty of Information Technology, Brno University."— Presentation transcript:

1 27.9.2016 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/ imlich@fit.vutbr.cz

2 ITU: X Window | 2 / http://www.fit.vutbr.cz/~imlich/ 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”);

3 ITU: X Window | 3 / http://www.fit.vutbr.cz/~imlich/ 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)

4 ITU: X Window | 4 / http://www.fit.vutbr.cz/~imlich/ 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

5 ITU: X Window | 5 / http://www.fit.vutbr.cz/~imlich/ 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

6 ITU: X Window | 6 / http://www.fit.vutbr.cz/~imlich/ 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

7 ITU: X Window | 7 / http://www.fit.vutbr.cz/~imlich/ 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)

8 ITU: X Window | 8 / http://www.fit.vutbr.cz/~imlich/ How things works - XServer 5

9 ITU: X Window | 9 / http://www.fit.vutbr.cz/~imlich/ 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. )

10 ITU: X Window | 10 / http://www.fit.vutbr.cz/~imlich/ 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

11 ITU: X Window | 11 / http://www.fit.vutbr.cz/~imlich/ 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.

12 ITU: X Window | 12 / http://www.fit.vutbr.cz/~imlich/ 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

13 ITU: X Window | 13 / http://www.fit.vutbr.cz/~imlich/ 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

14 ITU: X Window | 14 / http://www.fit.vutbr.cz/~imlich/ 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

15 ITU: X Window | 15 / http://www.fit.vutbr.cz/~imlich/ 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

16 ITU: X Window | 16 / http://www.fit.vutbr.cz/~imlich/ 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

17 ITU: X Window | 17 / http://www.fit.vutbr.cz/~imlich/ How things works - useful tools 3 xwit – command line tool for setting of window parameters xautomation – set of command line tools (xte)

18 ITU: X Window | 18 / http://www.fit.vutbr.cz/~imlich/ 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

19 ITU: X Window | 19 / http://www.fit.vutbr.cz/~imlich/ 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

20 ITU: X Window | 20 / http://www.fit.vutbr.cz/~imlich/ 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

21 ITU: X Window | 21 / http://www.fit.vutbr.cz/~imlich/ Programing of XApplications - Xlib 4 – Xlib vs. WinAPI

22 ITU: X Window | 22 / http://www.fit.vutbr.cz/~imlich/ 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

23 ITU: X Window | 23 / http://www.fit.vutbr.cz/~imlich/ Programing of XApplications - Xtoolkit, motif extension of Xlib by some basic elements (buttons, scrollbars, etc.) still very low level and programer unfriendly

24 ITU: X Window | 24 / http://www.fit.vutbr.cz/~imlich/ Programing of XApplications - Gtk, Gtkmm very popular because of licence GUI description is in Glade Gtkmm is object oriented extension of Gtk

25 ITU: X Window | 25 / http://www.fit.vutbr.cz/~imlich/ 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”)

26 ITU: X Window | 26 / http://www.fit.vutbr.cz/~imlich/ 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/FUDC on2008Brno


Download ppt "27.9.2016 User Interface Programming X Window Jozef Mlích Department of Computer Graphics and Multimedia Faculty of Information Technology, Brno University."

Similar presentations


Ads by Google