Опубликован: 06.08.2012 | Уровень: специалист | Доступ: платный
Лекция 28:

XFree86 in depth

< Лекция 27 || Лекция 28: 1234 || Лекция 29 >

The Screen section

The final section is the Screen section, which describes the display on a monitor. The default looks something like this:

Section "Screen "
    Identifier    "Screen0 " 
    Device    "Card0 " 
    Monitor    "Monitor0 "
    SubSection    "Display "
      Depth    1
    EndSubSection
    SubSection "Display "
      Depth    4
    EndSubSection
    Subsection "Display "
      Depth    8
    EndSubSection
    SubSection "Display "
      Depth    15
    EndSubSection
    SubSection "Display "
      Depth    16 
    EndSubSection
    SubSection "Display "
      Depth    24 
    EndSubSection
EndSection

The first three lines describe the relationship between the screen display, the video board that creates it, and the monitor on which it is displayed. Next come a number of subsections describing the possible bit depths that the screen may have. For each display depth, you can specify which mode lines you wish to use. Modern display hardware has plenty of memory, so you'll probably not want to restrict the display depth. On the other hand, you may want to have multiple mode lines. Your display card and monitor are good enough to display 2048x1536 at 24 bits per pixel, but occasionally you'll get images (in badly designed web pages, for example) so miniscule that you'll want to zoom in, maybe going all the way back to 640x480 in extreme cases. You can toggle through the available resolutions with the key combinations Ctrl-Alt-Numeric + and Ctrl-Alt-Numeric -.You're probably not interested in pixel depths lower than 640x480, so your Screen section might look like:

Section "Screen "
   Identifier  "Screen0 "
   Device  "Card0 "
   Monitor  "Monitor0 "
   DefaultDepth  24 
   SubSection  "Display " 
    Depth  24
    Modes  "2048x1536 " "1600x1200 " "1024x768 " "640x480 "
   EndSubSection
EndSection

This section includes a DefaultDepth entry for the sake of example. In this case, it's not strictly needed, because there's only one pixel depth. If there were more than one Display subsection, it would tell xinit which depth to use by default.

Multiple monitors and servers

We've seen above that X provides for more than one monitor per server. If you have multiple display cards and monitors, let the server generate the XF86Config file: it generates a file that supports all identified devices. The resultant server layout section might look like this:

Section "ServerLayout "
    Identifier     "XFree86 Configured "
    Screen    0    "Screen0 " 0 0
    Screen    1    "Screen1 " RightOf "Screen0 "
    Screen    2    "Screen2 " RightOf "Screen1 "
    InputDevice    "Mouse0 " "CorePointer "
    InputDevice    "Keyboard0 " "CoreKeyboard "
EndSection

The file will also have multiple monitor, device and screen sections. The server can't know about the real physical layout of the screen, of course, so you may have to change the ordering of the screens. When you run the server without any other specifications, it is assigned server number 0, so these screens will be numbered :0.0, :0.1 and :0.2.

Multiple servers

It's also possible to run more than one X server on a single system, even if it only has a single monitor. There can be some good reasons for this: you may share a system amongst your family members, so each of them can have their own server. Alternatively, you may have a laptop with a high-resolution display and need to do a presentation on overhead projectors that can't handle more than 1024x768 pixels. It's not practical to simply switch to a lower resolution, because the overall screen size doesn't change, and it's difficult to avoid sliding the image around when you move the cursor.

For each server, you require one virtual terminal—see page 109 for more details. If you're using the same hardware, you can also use the same XF86Config file. The only difference is in the way in which you start the server. For example, you could start three X servers, one with the fvwm2 window manager, one with KDE and one with GNOME, with the following script:

xinit &
xinit .xinitrc-kde - - :1 &
xinit .xinitrc-gnome - - :2 -xf86config XF86Config.1024x768 &

Due to different command line options, you must use xinit here, and not startx. The first xinit starts a server with the default options: it reads its commands from .xinitrc, it has the server number 0, and it reads its configuration from the default XF86Config file. The second server reads its commands from .xinitrc-kde, it has the server number 1, and it reads its configuration from the default XF86Config file. The third server reads its commands from .xinitrc-gnome, it has the server number 2, and the configuration file is XF86Config.1024x768. Assuming that you reserve virtual terminals /dev/ttyv7, /dev/ttyv8 and /dev/ttyv9 for the servers, you can switch between them with the key combinations Ctrl-Alt-F8, Ctrl-Alt-F9 and Ctrl-Alt-F10.

X in the network

X is a network protocol. So far we have looked at the server. The clients are the individual programs, such as xterm, emacs or a web browser, and they don't have to be on the same machine. A special notation exists to address X servers and screens:

System name: server number .screen number

When looking at X client-server interaction, remember that the server is the software component that manages the display. This means that you're always sitting at the server, not at the client. For example, if you want to start an xterm client on freebie and display it on presto, you'll be sitting at presto. To do this, you could type in, on presto,

$ ssh freebie xterm -ls -display presto:0 &

The fag -ls tells xterm that this is a login shell, which causes it to read in the startup files.

For this to work, you must tell the X server to allow the connection. There are two things to do:

  • Use xhost to specify the names of the systems that have access
    $ xhost freebie presto bumble wait gw
    

    This enables access from all the systems on our reference network, including the one on which it is run. You don't need to include your own system, which is enabled by default, but if you do, you can use the same script on all systems on the network.

  • xhost is not a very robust system, so by default startx starts X with the option -nolisten tcp. This completely blocks access from other systems. If you want to allow remote clients to access your X server, modify /usr/X11R6/bin/startx, which contains the text:
    listen_tcp= "-nolisten tcp "
    

    Change this line to read:

    listen_tcp=
    

    This enables remote connections the next time you start the server.

Multiple monitors across multiple servers

We saw above that a server can handle multiple monitors, and a system can handle multiple servers. One problem with multiple monitors is that most computers can only handle a small number of display boards: a single AGP board and possibly a number of PCI boards. But PCI boards are difficult to find nowadays, and they're slower and have less memory.

If you have a number of machines located physically next to each other, you have the alternative of running X on each of them and controlling everything from one keyboard and mouse. You do this with the x11/x2x port. For example: freebie, presto and bumble have monitors next to each other, and presto has two monitors. From left to right they are freebie:0.0, presto: 0.0, presto:0.1 and bumble. 0.0. The keyboard and mouse are connected to presto. To incorporate freebie:0.0 and bumble:0.0 in the group, enter these commands on presto:

$ DISPLAY=:0.0 x2x -west -to freebie:0 &
$ DISPLAY=:0.1 x2x -east -to bumble:0 &

After this, you can move to the other machines by moving the mouse in the corresponding direction. It's not possible to continue to a further machine, but it is possible to connect in other directions (north and south) from each monitor on presto, which in this case would allow connections to at least six other machines. Before that limitation becomes a problem, you need to find space for all the monitors.

Stopping X

To stop X, press the key combination Ctrl-Alt-Backspace, which is deliberately chosen to resemble the key combination Ctrl-Alt-Delete used to reboot the machine. Ctrl-Alt-Backspace stops X and returns you to the virtual terminal in which you started it. If you run from xdm, it redisplays a login screen.

< Лекция 27 || Лекция 28: 1234 || Лекция 29 >
Бехзод Сайфуллаев
Бехзод Сайфуллаев
Узбекистан, Бухара, Бухарский институт высоких технологий, 2013
Василь Остапенко
Василь Остапенко
Россия