Inquiry X WINDOW System Running and Startup Process (nios.org)

xiaoxiao2021-03-06  40

Inquiry X WINDOW System Running and Startup Process

The first time I went Xfree86 in Debian, StartX launched TWM, after installing gnome, StartX started the GNOME environment, why? What files have been modified when installing GNOME? Originally, I wanted to figure out these items to start researching this topic. I didn't expect many other things ^ _ ^ This article mainly explains the basic operation principle of X Window System, its launch process, and common cross-network operation x Window system.

A) Basic operation principle

X Window System uses a C / S structure, but different from our common C / S. Among the common C / S structures, one side of the providing service is Server, an HTTP service, FTP service, etc., using the service called Client, ie the client. However, in X Window System, the client is one of the execution programs, performs various X programs above, and Server is responsible for displaying the window of the Client running program.

X Window System's composition can be divided into X Server, X Client, X Protocol. X Server mainly controls input and output, maintain font, color and other related resources. It accepts the input information of the input device and passes it to the X Client, and the information returned after the information is processed, and the X Server is responsible for outputting to the output device (ie we see the display). X Server is passed to X Client's information called Event, mainly information on keyboard mouse input and window status. The information transmitted to x Server is called Request, mainly requiring the X Server setting window, changing the window size location, or draws the output text on the window. X Client is mainly part of the application calculation processing, does not accept user input information, and the input information is input to X Server, and then passed by X Server to X Client in Event (here you feel similar to Windows message mechanism, The system receives the user's input information, and then passes to the window in the form of a message, and then processes the message processing process of the window). X Client After the received Event, if you need to output it to the screen or change the appearance of the screen, issue request to X Server, which is responsible for display by x server.

Common situations are X Server and X Client run on the same computer, but they can also be located on different computers on the network. In X Window System, X Client is independent of hardware, it doesn't care what the video card is the display of the display, what is the keyboard mouse, which is only related to X Server. The configuration we usually run after XFree86 after XF86Config or XF86CFG is actually related to X Server, it is to be configured to configure X Server, do not configure it can run x client programs (such as xserver) The top 0 screen (screen number displayNumber is 0) displays the big eyes on the screen).

X Protocol is the agreement between X Server communication between X Client. X Protocol supports currently common network communication protocols. I can only test TCP / IP, you can see X Server listen on the TCP 6000 port. The x protocol is located above the transportation layer, should it belong to the application layer? .

Summarize the running process:

(1) The user issued the operation command by the X Server through the mouse keyboard

(2) X Server uses Event to pass user operation information to X Client (3) X Client for program operation

(4) X Client uses the result that the request is backatically displayed

(5) X Server will display the result on the screen

2) Startup process

We entered X from the console usually use the startX command. The following will be analyzed from STARTX. First, Man StartX and Man Xinit can see the use of Staratx and xinit:

StartX [[Client] Options .....] [- [Server] Options ....

xinit [[Client] Options] [- [Server] [Display] Options]

The top [Client] and [Server] are called the Client program and the Server program, respectively. The Manbook is written in / or ./.

Let's take a look at the STARTX this script.

Code:

#! / bin / sh

Userclientrc = $ home / .xinitrc # user's client definition file

Userserverrc = $ home / .xserverrc # user's Server definition file

sysclientrc = / usr / x11r6 / lib / x11 / xinit / xinitrc # system

Sysserverrc = / usr / x11r6 / lib / x11 / xinit / xserverrc # server server

DefaultClient = / usr / x11r6 / bin / xterm # default Client program

DefaultServer = / usr / x11r6 / bin / x # default server program

DefaultClientargs = "" "The following defines the parameter variables for Client and Server

DefaultServerags = ""

Clientargs = "" "

Serverargs = ""

# If the user client file exists, use the client defined in the user file, otherwise use the system-defined Client.

IF [-f $ userclientrc]; then

DefaultClientargs = $ UserClienTrc

ELIF [-f $ sysclientrc]; then

DefaultClientargs = $ sysclientrc

Fi

# If the user server file exists, use the server defined in the user file, otherwise the system-defined Server

IF [-f $ userserverrc]; then

DefaultServeraggs = $ USERSERVERRC

Elif [-f $ sysserverrc]; then

DefaultServeraggs = $ sysserverrc

Fi

# 下 下 处理 处理 处理 处理 处理 处理 处理 参 处理 参

Whosegs = "client"

While [x "$ 1"! = x]; Do # If the first parameter is empty, exit the loop

Case "$ 1" in

# '' Required to prevent CPP from what "/ *" as a c comment.

/ '' *|/./' '*) # If $ 1 is / * or. /* form (xinit program requires the client program and the server program in its parameter must be / or. / Will be regarded as a client. The parameters of the program and the Server program, see Man Xinit) IF ["$ whosegs" = "client"]; then # If the current is handling the parameters

IF [x "$ clientargs" = x]; then # If Clientargs is empty, it assigns $ 1 to the client variable, that is, the [Client] parameter in the top #startx method.

Client = "$ 1"

Else

Clientargs = "$ clientargs $ 1" # otherwise the clientgs assigns $ clientargs $ 1, that is, the above #startx uses the Options parameters in the # method.

Fi

Else # Currently handled the parameters of Server, the meaning of the code is

IF [x "$ serverags" = x]; then

Server = "$ 1"

Else

Serverargs = "$ serverags $ 1"

Fi

Fi

;

-) # If $ 1 is -, it means that the parameters of the start process, - the boundaries of the client and Server parameters

Whosegs = "server"

;

*)

IF ["$ whosegs" = "client"]; then # processing to the client program

Clientargs = "$ clientargs $ 1"

ELSE # Treat Parameters for Server programs

# Display Must Be The First Server Argument? # DISPLAY MUST BE

# The screen number must be the first parameter to the Server program, in the form of x (x is digital), which can be from above StartX and Xinit

The difference between the method of use, xinit is more [Display], which is filtered here [Display]. Try it to see these two commands:

Xinit / USR / BIN / X11 / XEYES -DISPLAY LOCALHOST: 1 - / USR / BIN / X11 / X: 1 - DPI 70 &

xinit / usr / bin / x11 / xeyes -display localhost: 1 - / usr / bin / x11 / x -dpi 70: 1 &

It will be seen that the number of the first Server parameter does not use the screen number.

IF [x "$ serverags" = x] && excver "$ 1": ': [0-9] [0-9] * $'> / dev / null 2> & 1; then

DISPLAY = "$ 1"

Else # Treat parameters other than screen numbers

Serverargs = "$ serverags $ 1"

Fi

Fi

;

ESAC

Shift # All parameters are left once

DONE

# Process Client Arguments

IF [x "$ client" = x]; then # If the client program is empty

# ified # i c c c u,

IF [x "$ clientargs" = x]; the # and clientargs are empty, assign $ defaultclientargs to the client program

Client = "$ defaultclientargs" ELSE

Client = $ defaultclient # Using the default client program

Fi

Fi

# Process Server Arguments Handling Server parameters,

IF [x "$ server" = x]; then

# if no server arguments or display each rc file instead

IF [x "$ serverargs" = x -a x "$ display" = x]; then

Server = "$ defaultserverags"

Else

Server = $ defaultserver

Fi

Fi

# .......... Several authorization code

XINIT $ CLIENT $ CLIENTARGS - $ Server $ Display $ Serverags # 把 处理 处理 参 程序 处理 处理

# ............

STARTX is primarily set by the above code, and the location of X Client and X Server is processed, and the related parameters are handled, and finally handed over to XINIT processing. It can be seen that the position of the StartX setting X Client is to search for $ home / .xinitrc, then / etc / x11 / xinit / xinitrc; set the x server location is to search for $ home / .xserverrc, then / etc / x11 / Xin XServerrc. This explains why we usually say that the .xinitrc and .xserverrc file priority in the user directory when you start X WINDOW. So when we launch X with the startX command, if the user directory exists. Xinitrc and .xserverrc file, it is actually equivalent to the command xinit $ home / .xinitrc - $ home / .xserverrc. If the user directory does not exist that two files, equivalent to xinit / usr / x11r6 / lib / x11 / xinit / xinitrc - / usr / x11r6 / lib / x11 / xinit / xserver. Other situations are pushed.

As for xinit, start X Server according to the parameters passed by StartX, and then start X Client according to xinitrc.

The above is the startup process of X Window System, and StartX is only responsible for some parameters pass, and the real X startup is implemented by xinit. In fact, it can be divided into two parts that start X Server and start X Client. The following is constructed in the user directory. Xinitrc (ie xclient) and .xserverrc (ie x server) files. Write / usr / bin / x11 / x: 1 in .xserverrc. . xinitrc write / usr / bin / x11 / xeyes -display localhost: 1. This is the simplest x server x client, but only changes the screen number from the default 0 to 1, here X Server is / usr / bin / x11 / x program, X Client is / usr / bin / x11 / Xeyes program.

Summarize the single machine with the StartX boot process:

(1) Startx places the position of X Client and X Server, processing parameters and calls xinit

(2) XINIT starts X Server according to the parameters passed, and call X Client after successful

(3) Setting the related resources, start the window manager, input method, and other applications according to XINITRC.

But I haven't figured out how GNOME is gone! GNOME is of course a X Client, see step (3) of the above startup process.

Here are two cases, the first is the use of the system's xinitrc file. See / etc / x11 / xinit / xinitrc file (my Sarge X-window-system-core and gnome-core), only contain. / Etc / x11 / xsession sentence. Then look at the / etc / x11 / xsession this script, just look at the key section. The last face has: code:

SessionFiles = $ (run_parts $ syssessiondir)

IF [-n "$ sessionfiles"]; then

For sessionfile in $ sessionfiles; do

. $ Sessionfile

DONE

Fi

exit 0 [code]

Then look at Run_PARTS (), located in this file: [code]

Run_PARTS () {

# Until Run-Parts --Noexec Is IMplement

IF [-z "$ 1"]; then

INTERNAL_ERRORMSG "Run_Parts () Called without an argument."

Fi

IF [! -D "$ 1"]; then

INTERNAL_ERRORMSG "Run_PARTS () Called, But /" $ 1 / "Does NOT OR IS" /

NOT A DIRECTORY. "

Fi

For f in $ (ls $ 1); do

If EXPR "$ f": '[[: alnum:] _-] / $'> / dev / null 2> & 1; then

IF [-f "$ 1 / $ f"]; then

Echo "$ 1 / $ f"

Fi

Fi

DONE

}

Probably means Run_PARTS () takes the file name in the $ syssessionDir directory to assign the value to $ SessionFiles, and then loops running the files in the directory. Take a look at the directory, ie /etc/x11/xsession.d directory, you can see a few files starting with numbers, in fact, these values ​​indicate the priority of these files, and the number is high. Because the files are displayed in the directory in the above Run_PARTS (), the front number is smaller than the LS in front, so

Code:

For sessionfile in $ sessionfiles; do

. $ Sessionfile

DONE

This FOR cycle is also executed. See the /etc/x11/xsession.d directory has a 55gnome-session_gnomerc file, which is mentioned in the Startup variable. Then run:

XDKUI @ Debian: /etc/x11/xsession.d - Free $ GREP Startup *

See the 50xFree86-Common_Determine-Startup file. it's inside

Code:

IF [-z "$ startup"]; then

IF [-x / usr / bin / x-session-manager]; THEN

Startup = X-session-manager

Elif [-x / usr / bin / x-window-manager]; then

Startup = X-WINDOW-Manager

Elif [-x / usr / bin / x-terminal-emulator]; then

Startup = X-Terminal-Emulator

Fi

Fi

That is, set the launcher, actually set the startup variable, if the above programs are not found, the error exit, that is, the X environment is not started. Run xdkui @ debian: /etc/x11/xsession.d (Grep Startup *

Seeing the 99xFree86-Common_Start file that is the last 99xfree86-commit_start file that is last run, there is only one sentence:

EXEC $ Startup

Ok, let's start our X Client here, finally finished ^ _ ^. Summarize the startup process of this first way, simply the three files of / usr / bin / x-session-manager, x-window-manager, / usr / bin / x-terminal-emulator sequentially sequentially. If there is, start it, that is, X Client. If three do not exist, the error exits. See the / usr / bin / x-session-manager file can be seen as a symbolic connection, eventually connected to / usr / bin / gnome-session, that is, GNOME. As for us to start the input method, we will set the startup method when you start, and you will not be analyzed by the GNOME-Session. You can try to change the / usr / bin / x-session-manager to point to XFCE4-Session (if installed), then StartX will start the XFCE4 environment. What is the reacting connection to this connection is the implementation of the redhat's SwitchDesk tool. . Or delete the / usr / bin / x-session-manager, then startX, only the Window Manager pointed to by / USR / BIN / X-WINDOW-Manager, I am BlackBox.

Look at the second case, that is, the xinitrc file of the user directory $ HOME / .XINITRC. Contrast Hiweed-Debian-Desktop_0.55_i386, there is a $ home / .xinitrc file, there is an Exec Xfce4-session inside. Therefore, its x client can say that the most important X-session-manger is started from $ home / .xinitrc. There is also a process of execution of the first situation above.

Finally, the startup process of GNOME (or X-session-manger) is finally understood, and it is said to it. The xinit program starts the X Server and X Client simultaneously, which can be on a single machine. If the two computers located on the network are Client and Server, Xinit is powerless. At this time, you have to start X. The following simple "manual" starts X Server and X Client: Run the command in CUI mode:

XDKUI @ Debian: ~ $ x: 1 &

I saw a gray full screen and a mouse pointer, this is X Server, and its screen number is 1. The following constructs X Client, press Ctrl Alt F1 to return to the CUI (Ctrl Alt F7 corresponds to the first startup of the unit, Ctrl Alt F8 corresponds to the second, some people say F7 corresponding screen number The X Server for 0 is actually not right. If the first started screen number is 1, the second started number is 0, then F7 corresponds to 1 screen, F8 corresponds to 0 screen), runs command: xdkui @ Debian: ~ $ xeyes -display localhost: 1 &

Then press CTRL Alt F7, seeing our X Client is Xeyes. Go back to CUI, run

XDKUI @ Debian: ~ $ &

Open a screen number 0 X Server, CUI runs XDKUI @ Debian: ~ $ xterm &

At this time, Ctrl Alt F7 corresponds to the screen number 1; and F8 corresponds to the screen number 0, and its x client is xterm. First quit the two X Server above, the following complex dots are manually started with our gnome, first

XDKUI @ Debian: ~ $ &

then

XDKUI @ Debian: ~ $ GNOME-Session

When you see the X started with StartX, X Server is this program, X Client is a gnome-session and its start-up window manager. I feel that I feel that xinit is not large (not knowing correct), and simple scripts can be implemented. Originally, I wanted to make XINIT disassembled. It can be too lazy to do ^ _ ^ This is the case where the X Server and X Client are located in different hosts. Part III below.

Personally feel that it is important to understand the X WINDOW SYSTEM. General X Server is very simple, that is, / usr / bin / x11 / x program; X Client has a wide variety of tricks, from advanced CDE, GNOME, KDE, to the low-level TWM, Window Maker, Blackbox, etc. The simplest single X program such as XTERM, RXVT, Xeyes. It is because of the various matchs of X Client, making our X Window System look diverse. This may also be one of the biggest selling points in X Window System ^ _ ^

3) Transf network Run x window system

Generally used to make a server (Linux, FreeBSD, Solaris, etc.) will not load X Server, and even there are many displays. This can be installed in these systems, which remotely displays in the X Server sitting in the administrator in the way. Our laboratory uses FreeBSD to do a gateway, providing WWW, FTP service, usually in the administrator's local machine, then SSH or Telnet access, the x client program is displayed on the local display, of course, you can use XDMCP (x display Manager control protocol Xinitrc, so you can start the GUI in both StartX and Display Manager, and you'd better start the X Client file in the XSession file. Remote Run X Client Programs requires a Display environment variable, set to host name: screen number (eg 192.168.1.2:0, indicating that x server is zero on this machine); or give xclient program Add a -Display parameter. Due to the conditions limit, only the TCP / IP network environment is tested, and the X Server is 192.168.1.2, X Client is 192.168.1.1.

1) Windows system is X Server

a) Way with ssh or telnet

There are many kinds of X Server software below Windows, I use X-Win32 here. Run the X-Win32 program in Windows, equivalent to the local machine is a X Server. Remote login on debian (I am using VMware emulation network environment, directly into the virtual machine, ^ _ ^), run: xdkui @ xclient: ~ $ export display = 192.168.1.2: 0

XDKUI @ xclient: ~ $ xterm &

At this time, X Server in Windows has seen XTERM. As for what X Client is still running, you need to see your needs, file manager, resource viewer, etc. Of course, the X-Win32 is to set the authorization, it seems that the default is to prevent access control, that is, any x client can use this X Server.

b) XDMCP mode

Common Display Manager has XDM, GDM, KDM, etc. I am using GDM here. You need to modify the GDM profile /etc/x11/gdm/gdm.conf, modify the Enable = true of the [XDMCP] segment so that you can log in remotely and run the GDM in X Client.

Built an XDMCP in X-Win32, the query method is filled in the IP to run the GDM. Connection, you can see the login interface, don't say it below, enjoy it.

2) Linux and Linux interconnection

a) SSH or Telnet method

In Linux, you can pay a X Server, you need to pay attention to authorization issues, create file /etc/x0.hosts, fill in X Client's IP192.168.1.1, where X0.Hosts represents the Local 0th screen to allow the X Client address that allows the connection to connect, Building a x1.hosts file is the X Client address that is allowed to connect to the local first screen, which is pushed, and there is in the Man XServer. run

XDKUI @ x Server: ~ $ x &

Don't add the -nolisten parameter when running the program, otherwise you will not listen on the network.

At this time, CTRL Alt F7 is X Server, returns Ctrl Alt F1 or on the X Client machine on the X Client machine.

Then log in to X Client, run

XDKUI @ xclient: ~ $ xterm -display 192.168.1.2:0

You can see xterm in the local x server, if any, you can also display the GNOME-Session locally. You can also do this in VMware in Linux, you need to use your wrist ^ _ ^

b) XDMCP mode

Run GDM in our X Client (don't forget to modify gdm.conf), then run x -query 192.168.1.1 under local X Server CUI (X Client's address of the GDM machine). You can see the login interface.

I am testing in VMware in Linux, talking about the wrist used. Run StartX & Start GUI under Ctrl Alt F1 CUI, at this time, Ctrl Alt F7 is the GNOME that is started with my X Server, X Client, and then runs VMware opens the Debian virtual machine and runs GDM. Then return to Ctrl Alt F1, run x: 1 -query 192.168.1.1. See the login interface. At this time, Ctrl Alt F7 is the 0 screen, and the virtual machine is run. Ctrl Alt F8 is No. 1 screen, logged in to X Client on the remote GUI. It is equivalent to two x server locally. X Window System is really quite amazing, and it is dazzling. admire………

PS: This article refers to the "X Window thorough research" published by the People's Posts and Telecommunications. Summary is the original words inside. Interested to see, but only 2 ~ 3 chapters are worth seeing, less than an hour, but it is helpful to understand X Window System. I have hit so many words, I hope to help the friends who want to know, otherwise I have a hard work. If there is any mistake, please refer to ^ _ ^

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

New Post(0)