Author: MAA (Taiwan User) Ideal Rewriting
Foreword X Window System is a set of window systems for a Client-Server architecture that is a graphical interface (including Linux, FreeBSD etc.). This article is introduced by the PROGrammer's point of view, making the reader to let the reader have a clear X concept before start writing X applications: (the author will assume that you are familiar with the X Window environment)
What is x window system Before 1984, many commercial companies have started to develop graphical user interfaces for UNIX systems. Since the graphical interface specifications developed by each company are inconsistent, and the system developed is mostly used in each company. Computer system (Mainframe, Mini Computer, Workstation, etc.), each graphical interface is not only possible to communicate with each other, but also make applications to execute on multiple systems, but also a difficult thing; at the same time, due to different interface specifications, procedures The method will also vary with the platform, and Programmer has also increased many troubles.
A user is easy to familiarize with graphical interface systems such as Microsoft Windows or Apple Macintosh, but for programmers, write Windows programs and procedures to write Machintosh, their methods and style are completely different two things (because of the program interface Inconsistency); more, these window systems are limited to hardware environment and operating system manufacturers, can be run on the MCrosoft Windows platform, which cannot be implemented on Macintosh, but only in the PC environment (here Refers to a program that contains a graphical interface program code).
In view of this, MIT, MASSACHUSETTS Institute of Technology has started the Client-Server development plan of the Client-Server architecture in 1984. X Window Development Goals, "To provide a NetWork Transparent) graphic interface environment, allowing all kinds of operating systems to perform X WINDOW (unrelated to hardware), program The method of design is consistent (unified), and the X resources on other computers can be shared through the network.
Client-Server architecture
Figure one
X Server and X Client X Window System is a graphics interface system for [Client-Server Structure]. X Client refers to a wide range of applications (paper processing, database applications, network software, etc.), and X Server is primarily handled from X Client Applications, drawing graphics on the screen (so also known as Display Server And responsible for managing system resources such as glyphs and screens available, read users' input (from keyboard or mouse), transfer keyboard, mouse event, and window status information to X Client (which is application).
X protocol In X Window System, X Server and X Client are exchanged through x protocol, and X protocol defines the message exchange format between X Server and X Client. About X Protocol, readers will slowly experience its existence after touching more X Programming; now you can temporarily play X Protocol in the role played in X Window System, Imagine the HTTP Protocol in Web Server and Web Client The communication role in the Browser is the same. In X Window System, X Protocol allows X Server and X Client to exchange messages across the network, which means that X Server and X Client are not allowed to execute on the same machine, available in different computers. Upon execution.
As shown in Figure 2, X Server is executed on the same computer as the X Client. This example assumes that after the XINIT Script is activated, the screen you see when X Server is activated. After the window in the upper left corner is activated in the X Server, XINIT will execute the X Terminal (a X Client). If you just want to activate X Server, don't run other x client, just enter the X command execution, usually only see a gray bottom desktop (Desktop, also known as rootwindow).
Figure 2
Figure 3 is an example of X Server and X Client executing on a different computer. After you activate X Server on your computer, we will then Telnet online (as Computer 2 and Computer 3 in the figure), transfer other computers to the execution result of X Clients, back to your own screen. Of course, X Server must perform on your own computer so that we can see why the execution result of the application (X Clients).
Read here, the reader may have some doubts about the word [Client-Server structure] mentioned here, that is because in the world of X Window System, X Client and X Server [Client-Server Architecture] relationship, And the word [Client-Server Structure] in the general computer science, the two are somewhat different. In general, Server refers to a program that provides some service on the network, such as FTP, HTTP, BBS, Email, etc. Service; and Client is a program that requires services to these Servers, like Browser, Email Client (Pine, Kmail, etc. And in X Window System, X Client refers to a variety of applications that can be performed on any computer on the network, and their execution results must be transmitted to a screen display, and responsible for the execution result to the screen Managing procedures for various system resources is X Server.
For Programmers, write X Client, X Client is performed on different computers, and does not affect the program's method. Because X Client will get X Server locations from the Display this environment variable, which will be transmitted to which of the execution results should be transmitted to. These are all because x protocol makes X Server and X Client (maybe in the local machine, perhaps on the network) becomes transparent (Programmer can't see, do not need to know), this Features We call "Network Transparent". There is also a point worth noting that most of the window systems are related to the underlying operating system learning, without the underlying operating system, it is not survive, but X is not part of the operating system, we can install X installed in various operating systems On, such as Unix Series (FreeBSD, Linux, etc.), IBM OS / 2, Microsoft Windows and even DOS can. Therefore, it is more fully utilized to share the Server and Client resources on each platform.
Display and Screen From the previous description We already know that the so-called X Server is Display Server, which is mainly responsible for the processing of graphics and message events. The next thing to introduce is another special feature of X Window System: "A Display Server can control the output of multiple Screen (screen displays)". The author directly below:
Figure four
As can be seen from the figure, if you have multiple Screen (screen display), you can control the Display Server, called it to output the X Client's execution result to any Screen. Screen's number starts from 0, if you have only one computer, one screen, then there will be Screen 0.
Even, you can also run multiple X Server on the same computer, which may feel doubtful for users who use other window systems (such as Microsoft Windows), but those who are familiar with Linux / FreeBSD system must know UNIX systems. There are multiple Virtual Terminal available. The same truth, when you activate X Server, X Server will take up TTY7 this Terminal if you activate the second X Server, which will use TTY8 Terminal. The method of activating the second X Server is as follows (Display Number, as the Screen Number starts from 0, so the instruction parameters are: 1):
xinit -: 1
Or:
StartX -: 1
Previously, in addition to activating X Server, xinit Script also executed XTERM applications; and StartX Script In addition to activating X Server, the STARTX Script will set some system resources based on your environment, like a glyph , Color, language setting, and activation specified application with preset Window Manager et al. (See later described later). If you just want to activate the second X Server, don't run any x client, the instruction is x: 1; just, after this way is activated, you will only see a gray desktop and a "" X "Mouse cursor, no way to enter instructions or perform any applications, if you want to close X Server, press the [Ctrl Alt Backspace] button. After activating multiple X Server, switch to the first X server, press [CTRL Alt F7] button, how to switch to the second X Server is [Ctrl Alt F8] button, and push .
The Window Manager is in X Window System, Window Manager is a very important X Client application. The so-called Window Manager, as the name suggests to manage other windows (X Clients), including letting you move window, zoom in, zoom out, and will add some consistency to each window (Decorations: Title Column, Zoom , Enlarge the icon oriented decoration).
The author believes that readers may still be unable to figure out what is Window Manager, but we can try to see if there is no WINDOW Manager when we try to see if there is no Window Manager. Very simple, try to execute X Server and xterm to activate X Server and XTERM, the result will only see the X Terminal, even a window title column, and there is no way to move with the mouse. window.
Don't close the X Server, in this X Terminal, enter FVWM2 to open F (?) Virtual Window Manager, as shown in Figure 5. Continue, we will be in the window titled "Login" (ie the original xterm has been decorated by fvwm2), press [Ctrl C] to turn off fvwm2, then enter KFM to open K Window Manager, the result will Figure 6. I think readers should be slightly felt slightly, there is no difference between Window Manager and have Window Manager (such as Figure 5 and Figure 6); if you carefully compare with actual operation, you will find two Windows. Manager (FVWM2 and KFM) changes to Decorations on each window on the desktop, as well as the difference in operation.
Note: The reader can test the Window Manager on its own system, not limited to FVWM2 or KFM. Remember, WINDOW Manager is also a client, readers can use X network characteristics, online to other FVWM2 or KFMs, and transmit their execution results back. As for the method of executing the remote x client, please refer to the related file. )
Figure 5
There are already very many Window Manager, such as FVWM, FVWM95, Afterstep, Enlightment, MTIF Window Manager, Lesstif, Windowsmaker, and KWM (K Window Manager), each of the Window Manager has its own characteristics. Your desktop has a completely different look and feel (Look and Feel). In http://www.plig.org/xwinman/, a variety of Window Manager's profiles and comparison information are collected, and the reader may wish to go to the network. X Programming APIS
Xlib If the reader has a note, the words of XLIB should be seen on the X Client block of Figure 1. The x library (XLIB) is the lowest-order program design interface in X Window System, which is like the role of Microsoft Windows than Windows Apis (or Windows SDK), as the program design of the closest window system. Interface, XLIB's functionality is only the most basic 缯 图 和 缯 缯 缯 缯 缯 缯 缯 缯 处理 处理 处理 处理
Since XLIB can only be written in the C / C language, the program's writing is relatively low-class complexity. Therefore, usually we will choose X Toolkits (GUI Libraries) to write X's applications.
X Tookits The so-called X Toolkits, in fact, Menus, Labels, Buttons, or Scrollbars, "User InterfaceComponents", in the X World, these USER Interface Components are called "Widgets".
Special little, x Toolkits has many sets available, relatively well-known, such as Motif, Openlook, TCL / TK, and QT / KDE with GTK / GNOME, and more. The "Widget Set" of these card-wide libraries has their own features, and the appearance of the appearance is different, so it is also a feature of the X Window System.
About Xfree86, KDE and GNOME
X11R6 and XFree86 Because many companies identify the advantages of X WINDOW SYSTEM, X system is constantly designed and improved and updated, and the most widely known version is X11 R6 (X Version 11, Release 6) for the industry.
As for what is Xfree86, the description of the XFree86 website is as follows:
The XFree86 Project, Inc is a non-profit organisation that produces XFree86. XFree86 is a freely redistributable implementation of the X Window System that runs on UNIX (R) and UNIX-like operating systems (and OS / 2). The XFree86 Project has traditionally focused on Intel x86-based platforms (which is where the `86 'in our name comes from), but our current release also supports other platforms. One of our current goals is to increase the range of platforms that XFree86 runs on. of As soon as this is, Xfree86 is mainly for free X Window System for X86-Based machine, and the current Linux, FreeBSD and other operating systems are also used with XFree86.
KDE and GNOME First, the pen is said to "KDE AND GNOME ARE * NOT * JUST Window Managers". Many people have always regarded KDE or GNOME as a Window Manager, which can be counted, or it is only one quarter. Correctly, KDE and gnome should be consideration Desktop Environment, not just Window Manager, because Window Manager is just a part of their components (the KWM running before the reader is a KDE built-in Window Manager).
The so-called Desktop Environment refers to "providing a complete X application, setting tool, easy-to-use desktop, start menu, and built-in Window Manager." Previously, Sun Microsystems CDE (Common Desktop Environment), and the general popular Desktop Environment on Linux / FreeBSD system is two sets for KDE (GNU Network Object Model Environment).
Desktop Environment usually contains the following parts:
Item Description Applications is a variety of applications, from a general instrument processing, network software, database processing tools to program development tools, and more. KDE attached to the software usually starts with K alphabet, such as KPackage, KDevelop, Kmysql, etc., and GNOME's software is starting with G letters, such as gedit, gimp, gnorpm, etc. Desktop consistency desktop, panel tool (Panel), and Start Up Menu, etc. And when the user is offline (logout), Desktop Environment will record the execution status of the application to recover when the next user logs in, this part is called "Session Ma