28 - Linux X server

Lecture



Today we will talk about graphics in Linux . Unlike Windows, the graphical subsystem in Linux is not an integral part - it exists separately from the system kernel. That is why it is possible to work in Linux without the graphics subsystem - only in alphanumeric mode.

The Linux graphics engine is called the X Window System . It was originally developed as a client / server model, and therefore consists of two parts: the server and the client. The X-server process acts as a server , and graphical applications as clients. The client and server communicate with each other according to the rules described in the X-protocol . Actually, the X-server itself consists of two large parts: a set of drivers for working with I / O devices and an X-protocol for working with applications.

Now it is important to understand that it is the X-server that interacts with input devices (keyboard, mouse and others) and output devices (video adapters, monitors and others), and not applications. We will not go deep into the details of the X-protocol and the subtlety of the interaction of all components. Note that the X-server interacts with applications using the unix-sockets and internet-sockets mechanism. The ability to communicate via Internet sockets allows the X-server and client to work in a bundle while on different networked computers.

Let's try to perform several practical exercises that will help to understand the basics of the interaction of the X-server and applications. As a rule, one instance of the X server is already running on the workstation. Let's launch another instance of com *** d (com *** and should be run on behalf of the superuser):

one
X: 1

or com *** th:

one
X localhost: 1

As a result, an instance of the X-server will be launched on one of the virtual consoles. On this console, you will see a black (or gray) screen with a cross instead of the mouse pointer. Now go to the free console and type a com *** at:

one
xclock -display: 1 &

Go to the console where the X server is running . You should see an analog clock in the upper left corner. The xclock program in this example is a client for the X server . Using the -display key , we indicated to the program with which X-server it needs to interact, that is, which X-server will display an xclock image on the output device (monitor).

The X server that is started by default when the system is booted has the sequence number 0. That is, com *** and xclock -display: 0 will display the clock on the seventh virtual console.

Let's return to our watch on the second copy of the X-server . You see that the program does not have the usual edging of the window with the buttons to minimize, maximize, close. The fact is that they are not drawn by the X-server , but by another process called the window manager . The window manager is also involved in scaling and moving the image of programs. This separation of functions also increases the flexibility of the entire X Window graphics subsystem. So how can you choose which window manager to use to draw the application framework.

To launch the default window manager on our second X server, execute the following *** at x-window-manager –display = 0: 1 and return to the console where the second X server is running . Now you see around the clock a familiar frame and the top strip of a window with three familiar buttons. The window can be scaled and moved around the screen using the “mouse”, as well as close it by clicking on the familiar “cross”.

As already mentioned, the X-server works with input / output devices. The main configuration file in which the X server settings are stored is /etc/X11/xorg.conf . Although in many modern desktop distributions this file is empty, since another subsystem is responsible for setting up the hardware, nevertheless, the X server continues to read the configuration from this file. Consider this file, as situations are possible when the parameters of your I / O devices are automatically detected incorrectly and then manually editing the /etc/X11/xorg.conf file can help solve the problem.

The /etc/X11/xorg.conf file is partitioned using the section and end section keywords . Consider the most important sections.

The “ ServerFlags ” section indicates the options with which the X server is running :

one
2
3
section "ServerFlags"
...
end section

The “ Files ” section indicates the paths to files that may be needed in the X server operation. For example, here is the path to the X server fonts. Moreover, the path may point to another computer on the network on which XFS is installed (X Font Server):

one
2
3
four
five
6
section "Files"
...
FontPath "/ usr / share / fonts / X11 / misc"
FontPath "tcp / 192.168.1.1: 7100"
...
end section

The “ Modules ” section indicates the modules that will be loaded when the X server is loaded:

one
2
3
four
...
Load "dri"
Load "glx"
...

Section “ InputDevice “. There may be several such sections and they differ by a unique identifier. One section “ Input Device ” is responsible for one input device. That is, in desktop computers there are at least two such sections: one for describing the keyboard, and one for describing the mouse.

one
2
3
four
five
6
7
eight
9
ten
eleven
12
13
14
15
sixteen
17
Section "InputDevice"
Identifier "Generic Keyboard"
Driver "kbd"
Option "CoreKeyboard"
Option "XkbRules" "xorg"
Option "XkbModel" "pc104"
Option "XkbLayout" "us"
Endsection

Section "InputDevice"
Identifier "Configured Mouse"
Driver "mouse"
Option "CorePointer"
Option "Device" "/ dev / input / mice"
Option "Protocol" "ImPS / 2"
Option "Emulate3Buttons" "true"
Endsection

A quick note to the “ InputDevice ” section for the keyboard. It is in this section that the keyboard layouts for the graphical environment are defined. I draw your attention to this, since for an alphanumeric mode (virtual consoles, for example), the layout supports the terminal driver built into the kernel.

If you have a mouse with more than three buttons and additional buttons do not work, then the response to these additional buttons can be defined in the section “ InputDevice ” for this device. For example, the Option parameter “ZAxisMapping” “4 5 ″ is responsible for scrolling the“ mouse ”wheel. If the numbers 4 and 5 are swapped, the scrolling will be performed in the opposite direction.

The “ Device ”, “ Monitor ” and “ Screen ” sections are sections that are responsible for information output devices. The “ Device ” section contains information about the video adapter and drivers for it, the “ Monitor ” section describes the monitor's characteristics, and the “ Screen ” section describes the screen characteristics (resolution and other). The number of these sections may be different depending on the configuration, but at least each of them is present in a single instance in the xorg.conf file.

one
2
3
four
five
6
7
eight
9
ten
eleven
12
13
14
15
sixteen
17
18
nineteen
20
21
22
23
24
25
26
Section "Device"
Identifier "Intel Corporation 82815 CGC [Chipset Graphics Controller]"
Driver "i810"
BusID "PCI: 0: 2: 0"
Endsection

Section "Monitor"
Identifier "Universal Monitor"
Option "DPMS"
HorizSync 28-64
VertRefresh 43-60
Endsection

Section "Screen"
Identifier "Default Screen"
Device "Intel Corporation 82815 CGC [Chipset Graphics Controller]"
Monitor "Universal Monitor"
DefaultDepth 24
Subsection "Display"
Depth 16
Modes "1280x1024" "1024x768" "800x600"
EndSubSection
Subsection "Display"
Depth 24
Modes "1280x1024" "1024x768" "800x600"
EndSubSection

Section “ ServerLayout “. There may also be several such sections. They contain information about the options for using the X server I / O devices. That is, if you have several monitors or keyboards, then you can register several sections of “ ServerLayout “. In one, one keyboard will be indicated, in the other - another.

one
2
3
four
five
6
Section "ServerLayout"
Identifier "Default Layout"
Screen "Default Screen"
InputDevice "Generic Keyboard"
InputDevice "Configured Mouse"
Endsection

You can read more about these and other parameters in the Linux help — man Xserver , man xorg.conf , man X, and other sections.

In the “ Monitor ” section there may be an important parameter - modeline . Consider it in more detail. As a rule, the X-server correctly determines the technical characteristics of the monitor, if the monitor gives information about these characteristics using the DDC protocol . Without going into details, it is enough to know that there should be two or three additional wires in the monitor's VGA-cord , along which this information enters the video adapter and further to the X-server . As a rule, they are there, and the X server correctly determines and adjusts the frequencies and resolutions of the monitor. But there are situations when the DDC information does not arrive and it is necessary to independently register the technical parameters of the monitor — the vertical and horizontal frequencies, the resolution, and others.

To do this, in the “ Monitor ” section, you must register one or more modeline parameters. Consider for example the following line:

one
modeline “1024 × 768 @ 60 ″ 65.0 1024 1048 1184 1344 768 771 777 806 -vsync -hsync

In quotes, the name of the modeline parameter is “1024 × 768 @ 60 ″ - it can be anything and does not affect any characteristics. Next comes the number indicating the clock frequency of the video adapter ( dot clock ) - 65.0. The following four numbers - 1024 1048 1184 1344 - indicate the horizontal resolution. 1024 - this is the very resolution horizontally - the number of visible points in the line. 1048 is the total number of points in a line, including invisible ones (black edge of the screen). 1184 is the number of sweeps from the beginning of the line to the synchronization pulse, and 1344 is the total number of ticks needed to form one line.

The numbers 768 771 777 806 mean the same information for vertical resolution only. If you do not quite understand what these parameters mean, do not be discouraged. In any case, you do not need to calculate them manually, since they must be specified in the documentation for your monitor. And your task is to simply find these parameters and correctly register them in the modeline line.

-vsync , -hsync or may be + vsync , + hsync , indicate the type of sync pulse. These parameters are also taken from the documentation for the monitor.

There may be several modeline strings , or only one - for the resolution you need.

Although such manual addition of parameters is already rare, it can still occur, and therefore be careful in setting these parameters, as incorrect installation of them may even lead to monitor failure.

When solving problems with the launch of the X server , a lot of information can be gathered from the file /var/log/Xorg.0.log , where you can see all the messages about the process of starting the X server .

Let's now talk in more detail about the display managers (or display managers ).

You have to remember that in order to start working in alphanumeric mode, you must enter the login and password that the getty console program requests. getty verifies the entered data, and if it is correct, it allows the user into the system, giving access to the command interpreter. The display manager is a graphical analogue of getty . The main task of the screen manager is to provide the user with a graphical interface for entering a login and password, verify the entered login and password, and, if successful, let the user into the system by running the graphical shell or window manager for it.

The term graphical shell is very often referred to as window managers ( WindowMaker , IceWM , Blackbox , JWM, and others), as well as full-featured graphical skins ( GNOME , KDE , XFCE, and others).

The base Linux display manager is xdm . For the two most popular graphical shells, Gnome and KDE have their own display managers, gdm and kdm, respectively. In addition to the main function, display managers also have a number of additional ones: the ability to select an input language, provide the ability to select a window manager or a graphical shell, the ability, without logging in, to turn off the computer.

The xdm manager display configuration files are located in the / etc / X11 / xdm / directory. The user’s successful login to the system using xdm will execute the Xsession script located in / etc / X11 / xdm / . This script will run the / etc / X11 / Xsession script , which will continue to load the graphics subsystem.

The configuration files for the gdm manager display are located in the / etc / gdm / directory, and for kdm in the / etc / kde4 / kdm directory (for the fourth version of KDE ).

If you are working in alphanumeric mode, then to switch to the graphic mode, it is enough to execute the *** command from startx . This will launch the graphical environment by default. The display manager does not start up during the execution of the startx script, since the user has already been authenticated in the system using the getty program


Comments


To leave a comment
If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

LINUX operating system

Terms: LINUX operating system