LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1067|回复: 1

X基础进阶[半原创]

[复制链接]
发表于 2005-4-16 15:59:00 | 显示全部楼层 |阅读模式
这篇文章摘录于一个外国网站上,我觉得讲的还不错,加上本来对X原理有些兴趣,于是加上了我的一些理解,并加了中文注释,希望对大家有点帮助,同时希望更加懂X的朋友跟贴,帮我补充一些!!!
小弟在此感激不敬

X Window System

21.1 Pieces

X Server (一般是/usr/X11/bin/X)
在终端运行 X & 即可看到它
The X-server is responsible for managing resources for X-clients. These resources typically include the screen, keyboard, and mouse. The X server runs on the machine that the user interacts with. It passes user input back to the X-clients and outputs information from the X-clients back to the user via the screen.
X SERVER负责管理x-client的资源,这些资源一般是屏幕,键盘,鼠标的控制和驱动,它传递输入信息给X客户程序,并输出客户程序反馈的信息到屏幕上

X Clients
X-clients connect to the X-server in order to use it's resources. X-clients can be ran locally on the same machine as the X-server or remotely (in which case they connect to the local X-server).
x客户连接到x服务器为了使用他的资源,x客户可以运行在本地和远程机器上

X Protocol   X协议我不太清楚,渴望高手来讲一下
X-clients and X-servers communicate using this protocol.


21.2 Configuration Tools  x配置工具

Xconfigurator (现在是redhat-config-xfree86)

GUI based. 基于图形GUI
Primary configuration tool used on RH machines.
Automatically probes video card for necessary configuration information.
If probe fails, use "SuperProbe" to determine video card.
Recommended configuration tool.
Use "--expert" option in order to override probed values.

xf86config

Character based. 基于字符界面
Xconfigurator recommended over this for exam.

SuperProbe 这个用于测定显卡类型

Part of XFree86.
Can be used to determine video card if Xconfigurator fails.
May freeze system when probing.

21.3 Configuration Recommendations

Choose "No Clockchip Setting"
Select multiple video modes in case one doesn't work
If your card is unsupported, choose the generic SVGA or VGA support.

Files X文件介绍

X Configuration

Default font path - /usr/X11R6/lib/X11/fonts X默认字体是"fixed"  

User configuration files
~/.xinitrc - Starts specified xclients in background and then execs a window manager (e.g. exec startkde). 执行~/.Xclients,/etc/x11/xinit/xinitrc.d下面和窗口管理器的教本文件

~/.Xclients - execs .Xclients-default. Created by switchdesk.
定义桌面环境等的配置文件
~/.Xclients-default - Starts desktop environment (e.g. exec startkde or exec wmaker). This is used to override the default desktop environment specified in /etc/sysconfig/desktop. This file is created by switchdesk.
定义桌面环境等的配置文件
以上两个文件可由switchdesk创建,用于用户的自定义启动桌面配置

~/.xsession - Used by display managers (e.g. xdm,kdm,gdm).
使用显示管理器登陆时使用到文件,它配置要启动的客户程序
~/.Xresources -
自定义颜色,字体
等的资源文件~/.Xkbmap -
~/.xmodmap -
定义键盘map的文件

System configuration files
/etc/X11/<window manager>/ - Window manager specific files.
窗口管理器的目录(xdm/gdm/kdm)

/etc/X11/XF86Config-4 - XFree 4.X primary configuration file.
/etc/X11/XF86Config - XFree 3.X primary configuration file.

/etc/X11/xinit/xinitrc - Same purpose as .xinitrc in users $HOME. Only used if .xinitrc doesn't exist. 当.xinitrc 不存在时使用的系统客户程序配置文件

/etc/X11/xinit/xinitrc.d/ - Contains additional init scripts for X startup. Executed by /etc/X11/xinit/xinitrc   此目录下的文件会自动执行

/etc/X11/xdm/Xsession - Session configuration. Executed by display manager (e.g. xdm, kdm, gdm). 此文件作用等同与etc/X11/xinit/xinitrc用于配置客户程序

/etc/X11/xdm/xdm-config - Configuration file for xdm.

/etc/X11/ 下目录简介

applnk/ - Directory structure for menu items.
fs/ - Built-in font server configuration.  xfs字体服务器的配置文件
<window manager>/ - Window manager specific files.
gdm/ - Configuration files for gdm display manager.
xdm/ - Configuration files for xdm display manager.
xinit/ - Configuration files needed for X startup & initialization.

/usr/X11R6/ 下目录简介
bin/ - X binaries X自带命令所在
lib/
modules/ - X server extensions/modules. 扩展模块目录
xscreensaver/ - Screen saver programs.
X11/fonts/ - Default font path. 字体目录
X11/app-defaults/ - Application defaults.
X11/locale/ - Locale information. (这里我不太懂)
X11/xkb/ - X related keyboard information. (这里我不太懂)

/etc/X11/X

XFree 4.X
/etc/X11/X is a symlink to /usr/X11R6/bin/XFree86


XFree 3.X
/etc/X11/X is a symlink to the actual X server.


Common X Client Options 通常的 x客户程序的搭配参数
-display      server:0.0
-display 主机名:显示编号.屏幕编号

-geometry     100x100+10+20     # A box 100x100 pixels that is 10 pixels from the left
+num+num 右上角  具体MAN X

-geometry  象素(大小)  显示位置   指定客户程序显示时的参数
                                # and 20 from the top of the screen
-font         font name 显示的字体格式
-background   color背景色
-foreground   color前景色
-title        string 标题文字
-bordercolor  color边框色
-borderwidth  pixels边框字体

21.6 Window Managers 窗口管理器

A special type of x-client. 一个特殊的客户程序
Controls how other x-clients appear. 控制其它客户程序的显示形态
Causes all x-clients to display with common features (title bar, minimize & maximize buttons, etc.)
Basically controls look & feel of window session. 控制win回话的基本显示状态

Common Window Managers: 常用的几个有:
fvwm - Can be configured to emulate other windowing environments(e.g. Windows 95, Motif).
WindowMaker - Resembles NEXTSTEP.
Enlightenment - Previous default window manager for GNOME.
Sawfish - Current default window manager for GNOME.
Configuration files stored in /etc/X11/<window manager>/

21.7 Desktop Environments 桌面环境

Provide more features than a window manager. 提供比窗口管理器更多的功能
A window manager is one part of the desktop environment.
窗口管理器是桌面环境的重要组成部分
Attempts to create a consistent environment for all applications.
Common Desktop Environments:
KDE - K Desktop Environment (QT based)
GNOME - GNU Network Object Model Environment (GTK based)

21.8 Display Managers 显示管理器

X-client. 也是一个客户程序
Handles authentication. 用来处理用户认证
Examples: xdm, gdm, kdm.
To change, edit /etc/X11/prefdm  它通过/etc/sysconfig/desktop来调用哪个显示管理器

21.9 Session Managers 客户会话管理

Executes display managers:
xdm - /usr/bin/xsession
kdm - /usr/bin/kwm
gdm - /usr/bin/gnome-session
Doesn't execute ~/.xinitrc
Will execute ~/.xsession if it exists, otherwise ~/.Xclients is executed.
以上是各个显示管理器内定客户程序配置文件

21.10 Starting X  

startx
/usr/X11R6/bin/startx
Basic Operation

if exists (~/.xinitrc)
        client = ~/.xinitrc
else
        client = /etc/X11/xinit/xinitrc
寻找xinitrc客户脚本文件
if exists (~/.xserverrc)
        server = ~/.xserverrc
else
        server = /etc/X11/xinit/xserverrc
寻找X服务器脚本文件
# Authorization setup
xauth add $display_name . $magic_cookie

xinit $client -- $server
# If $server isn't specified, xinit defaults to X:0
        默认X客户程序使用X:0屏幕编号

/etc/X11/xinit/xinitrc 脚本分析

if exists (/etc/X11/Xresources)
        xrdb -merge /etc/X11/Xresources (系统)
xrdb:Xserver resource datebase utility
xrdb命令用来专门用来调入此资源文件(这个命令具体如何用望高手指点)

if exists (~/.Xresources)
        xrdb -merge ~/.Xresources(客户自定义)

if exists (/etc/X11/Xkbmap)
        setxkbmap `cat /etc/X11/Xkbmap`
用来设定键盘等 (这个命令具体如何用望高手指点)
if exists (~/.Xkbmap)
        setxkbmap `cat ~/.Xkbmap`

if exists (/etc/X11/Xmodmap)
        xmodmap /etc/X11/Xmodmap
if exists (~/.Xmodmap)
        xmodmap ~/.Xmodmap(这里我不太懂)
(这个命令具体如何用望高手指点)

execute any scripts in /etc/X11/xinit/xinitrc.d/

if exists (~/.Xclients)
        exec ~/.Xclients
else if exists /etc/X11/init/Xclients
        exec /etc/X11/init/Xclients
else
        exec fvwm2
        
找寻xclient,前面说过 xclient 主要来启动窗口管理器等东西,如找不到就用fvwm2

xdm (Display Manager)
/etc/X11/xdm/xsession
Basic Operation

execute any scripts in /etc/X11/xinit/xinitrc.d/

if exists (~/.xsession)
        exec ~/.xsession
用户可以将自己的客户程序加入此文件
else if exists (~/.Xclients)
        exec ~/.Xclients
else if exists (/etc/X11/xinit/Xclients
        exec /etc/X11/xinit/Xclients
else
        exec xsm
        


21.11 Remote Display of X Applications

Security
xhost controls access to the local X server. Access information is stored in ~/.Xauthority. 它可由xauth命令配置

Format of xhost command:

xhost [+|-]name   X服务器访问控制工具
        

Where name is in the format of family:name. Family can be one of the following: inet(default),dnet,nis,krb,local.
xhost +                     # Grant access from everywhere
xhost -                     # Revoke access from everywhere
xhost +server.domain.com    # Grant access from server.domain.com
xhost -server.domain.com    # Revoke access from server.domain.com
xhost +local:bob            # Allow local user bob access
        


Specifying a different display
Two ways to specify a display: 设定display的两种方法


Per client:
xterm -display server.domain.com:0.0 直接加上比较麻烦一点


For all clients:
export DISPLAY=server.domain.com:0.0 设定DISLPAY变量值

"DISPLAY" used by xclients to determine where to send output.


Putting it all together
To allow remote.xyz.com to display clients on local.xyz.com, perform the following steps:


On local.xyz.com:
xhost +remote.xyz.com
On remote.xyz.com:
export DISPLAY=remote.xyz.com:0.0
xterm
      

SSH
If X-Forwarding is enabled, SSH automatically configures everything for you so that can display X-clients from the remote host to your local host.


21.12 Troubleshooting X

Startup Problems

1.X starts, but window manager doesn't. X服务器启动了,窗口管理器没有启动

Check .xinitrc file to see if the window manager is exec'd at the end.

Check to see if window manager files are readable by user.

Try renaming user's window manager configuration files and restart X.

2.X won't start.  X服务器无法启动起来

Save existing XF86Config file and use Xconfigurator to build a new one.

Verify selected video card and it's attributes with SuperProbe.

Mouse Problems

Check physcial connection.

Run mouseconfig.

If it doesn't work in X or gpm, it's probably a problem with the mouse itself.

3.Can't login to Display Manager 无法从显示管理器登陆

Verify that the user can log successfully from a virtual terminal.

Try a different window manager.

Rename the user's window manager configuration files and try again.

Display Alignment is off

Try adjusting monitor settings.

Use xvidtune to adjust mode lines in the XF86Config file.
注xvidtune是调整显卡模式的工具(我不太会用,谁教一下)
发表于 2005-4-16 16:14:09 | 显示全部楼层
Steve`s RHCE Study Guide
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表