Understand xwindow

xiaoxiao2021-03-06  70

Many people are using xwindow, but they are using some of the XWindows under covering, those packaging are somewhat unstable, occupying a lot of resources, so that some people say that xwindow is garbage. In fact, XWindow is a very good graphics system, you should complain that those unstable packaging, not xwindow itself.

XWindow is very clever design, many times it is conceptually more advanced than other window systems, so that it is still the industrial standards on the workstation for many years. Many other window systems are learned from XWindow.

XWindow can say too much. Below only to distinguish between the concepts that are easily confusing, some suggestions that use it correctly.

Dismissal X Server and X Client

This is what I have been asked many times by others. I really don't want to say it anymore, so I wrote it here to steal a lazy, hehe.

Many people who are familiar with the principle of the Internet will make mistakes for the first time I encounter XWindow. If he logs in to a Sun server from a Windows machine with Exceed through xdmcp, he says Exceed is a client, and the Sun Machine is a server. This is completely wrong.

Understand the working principle of XWindow, this difference will be obvious. X Server does not refer to the machine you logged in, but refers to a program that is responsible for accepting customer requirements on a machine, displaying graphics requested on the screen, and notifying the message (keyboard, mouse, window message) Customer program.

For example, Exceed in the above example is a X Server, which is responsible for controlling the display (Display), the program on the Sun machine, XTERM, XXGDB, DTWM (CDE Window Manager), ... is a client program. They usually use the TCP 6000 port to connect to the Windows machine, and the 6000 port of the Windows machine is made by Exceed Bind and Listen, how, our Internet expert, Exceed looks a server :)

For example, when you launch the xterm on the Sun machine through the Telnet, you will display a window on the Exceed screen. The actual thing is: XTERM requests to connect to the 6000 number of the Windows machine, connected to the Exceed, then the xterm requests the resource, then the xterm requests a window on the screen.

When you press the "A" button in the XTERM window, Exceed will notify the xterm process, then Xterm will send a datagram, request Exceed, "Please display a letter A at the coordinate (100, 30), then The rectangle is displayed as a cursor. "So, you will display a letter more in your xterm window.

Did you understand this? Do not? That is still useful, experience it.

XWindow's network transparency

Just now, his client program can not only run on the Sun machine, but also can run on other machines in the network, or on this machine. For example, he may be able to log in to several Sun workstations through Telnet, several Linux PCs, he can boot XTERM on those machines, displayed on this Windows machine on Exceed. If it installs Cygwin, he can also start the xterm of the Cygwin on this machine, display it in the same way.

If he uses XRDB in this machine's Exceed set xterm style, such as background midnightblue, foreground white, font - * - Adobe-coier - *, ..., then, Sun, Linux, Cygwin's XTERM, although there is no configuration But they know: "This X Server requires me to use this background color, this foreground, this font ...", they will display the same style window on your screen. Use the mouse to select a paragraph, then you can press the character in the middle of the other program to paste the characters. No matter where this program is running.

Take a look at a bigger picture: there is three machines on your screen, the GVIM on the two machines, the Mozilla on the two machines is displayed, and they are allocated by this machine's FVWM manipulation, they can freely Copy the copy paste ... From here you can initially get the network transparency of XWindow, which makes you convenient to operate a lot of machines.

What is window manager?

Many people don't know what the window manager is going. They think GNOME and KDE are window manager, and the window manager is capable of providing a toolbar, configuring a desktop background, setting a lot of menus. In fact, window manager is only part of GNOME and KDE, and its main function is that you usually have no attention, but it is very important. The main features of the window manager are: mobile windows, change window size, iconization (minimize) window, change window laminated order ...

Usually the X client does not need to know someone want to move it, it only knows what to listen to the window manager. If there is no window manager running, your program will be a pile, you can't manipulate the program covered below, you can only use the top programs, and you can't move it, you can't change its size. Such systems cannot be used at all!

In fact, the title, button, beautiful border on your window is all provided by the window manager, not the program yourself, so you can change any windows with the window manager. When you click on the button at close the window, you actually click on the window manager to place a small window above your program window. After it is clicked, window manager will notify the program: "Hey! Some people want to Fall you, you are ready to prepare for the post, then quit it. "

Different machines are displayed in the window, unified and commanded by the window manager. For example, the window manager determines: there should be four buttons above the XTERM window, one on the left, click it to display the window operation menu, and the other three are maximized, minimize and close, respectively. The window uses the 7pixel thick border, and the window will first find an empty position on the desktop. If you can't find it, find a location that can minimize other windows ...

These are the duties of the window manager.

What is GNOME and KDE?

Some people call GNOME and KDE called window manager, and even some people call them xwindow. I often see someone asking: "Which xwindow is good? GNOME is still KDE?" In fact, you don't have GNOME and KDE to use XWindow.

GNOME and KDE are "Desktop System", a collection of many programs and libraries. Their design purpose is to provide a consistent convenient way of operation to meet the needs of ordinary users. They not only contain window manager, but also many utilities and applications, such as configuration programs, toolbars, editors, plot tools ... In fact, GNOME can work with many window manager, in history, GNOME useful window management ENGLIGHTENMENT, SAWMILL, SAWFISH, METACITY. The window manager of KDE is called KWIN. You also know, design a complete set of applications: editor, drawing program, browser, ... is very difficult. So they are definitely a dedicated editor, drawing program, browser. However, users who require less high can also use them.

Do a fun test with XWindow

Now let's make a trial to cause you to interested in xwindow.

Many people don't know how to start "xwindow". In fact, XWindow's start-up mode is simple.

First, start your X Server. Under Linux, you can enter "X &" directly, let a X Server run in the background. In this way, an arbulus that occupies the entire screen (root window) will appear. If you are Exceed or X-Win32, you need to set the screen to "Single Window" to see this window.

Then, Linux users need to set a password with XAuth, so others can't illegally connect your X Server. You need Ctrl-Alt-F1 to switch to TTY1 to enter this command. Users of Exceed and X-Win32 don't need this step. The following example only uses Linux as an example, and the user of other systems can paint scoop.

XAUTH Add: 0. `Mcookie`

Ok, now you can try to start a xterm to this X Server:

xterm -display: 0

Switch to X by ALT-F7, you see a xterm that is not managed by Window Manager. Try to move it? Switch to TTY1 to start another XTERM, two xterm coincident? How do you enter it in the first xterm? Is this painful? Then you can launch a window manager in xterm, such as TWM, run "TWM &" directly.

You find that the XTERM window has been added with the title bar, buttons, and borders, you can now move them. Try to kill TWM, look at those title bar, buttons, do you disappear? You know the role of the window manager.

Now tell you how to use XDMCP Broadcast, bypass the CDE's login interface, use the CDE on the Sun machine. In fact, you only need to change the "TWM" of the example to the CDE, or start the DTSession. They are generally under / usr / dt / bin. SUN has another window manager called OpenLook, it is called OLWM in the system, you can find it yourself.

Now if you install a fvwm on the Sun machine, you know how to get fvwm by bypassing the CDE login? You don't need to be root, you can use the FVWM you like.

The role of .xdefaults file

After you understand the working principle of X, you can use .xdefaults to configure your program. Some people don't understand .xdefaults is used to do what, I like to use shell alias to have some commands with many parameters, or write some shell script, only one line with many lines with many parameters, and then he said: ". Xdefaults is useless "Actually .xdefaults have many benefits than these methods. First, almost all X client programs can get configuration information from the .xdefaults file, such as foreground color, background color, font ... so you can configure all X programs in the same file, without writing so many shell script .

Also, if you write these configuration information to the data structure of the root window with XRDB .XDefaults, not the X program on the local machine will also follow the same style. For example, if you have this content in your .xdefaults:

Xterm.Background: MidNightBlue

Xterm.Foreground: White

Then you use xrdb ~ / .xdefaults, then all xterm will use MidNightBlue as a background color to use white display characters. These configurations use X terminology, resource.

Sometimes you will open a lot of XTERM windows on the machine, they come from different remote machines, this time if they use the same look and font, you will not easily distinguish them. For example, one day, I opened a lot of XTERM on the laboratory PC, they came from the machine, laboratory Sun server, an HP server in my dormitory machine and database laboratory. Before I walked, I want to close the local machine. I entered "shutdown -h now" on one of the local xterm, the result, wait for a while, I turned back to see the machine is not turned off, just that xterm stopped. response. I took my head: I worse, I turned off the machine's machine!

To avoid this, you can edit different .xdefaults on different machines, without using XRDB imports these configurations on the root window. In this way, Xterm on different machines uses different colors, you will not be easy to make mistakes.

How to learn more about XWindow?

Ouch! I have wanted to write a lot, and later I found too much to write. I have not so much time, no way, give the reference book, you go to see.

Learning to use xwindow is not learning to use gnome, kde, ... a lot of books how to use GNOME, KDE menu, configuration program ... The result is that the last user still does not know what XWindow is going. Who will use those menu? It's really wasting everyone.

Learning XWindow, in fact, one of the best ways is to look at XLIB programming books, you can find such a book in the library, I recommend O'Reily's XLIB programming book (I forgot the name), although it is very Old, but the principle of the XWindow's work above has never changed.

If you don't make a program, you can get a lot of in-depth concepts, such as window properties, fonts, colors, ..., these things are greatly helpful when you use Xwindow. If you really want to write an XLIB program, this book is out of time, you'd better go to www.x.org to download the latest XLIB manual for free.

转载请注明原文地址:https://www.9cbs.com/read-89309.html

New Post(0)