I recently started using Linux (where I work is a Microsoft shop, so I only code in C#, work with MS products etc).
我最近开始使用Linux(我工作的地方是Microsoft商店,因此我只使用C#编写代码,使用MS产品等)。
I'm trying to understand at a high level how some basic things in Linux hang together. I've been reading www.linfo.org
我试图在高层次上理解Linux中的一些基本内容是如何结合在一起的。我一直在阅读www.linfo.org
Anyway I've never quite got what X is.
无论如何,我从来没有得到X是什么。
From reading this article it seems to me that X is layer that sits on top of the operating system (one X server sitting on top of the OS??) and X client applications make requests to the X server. I think KDE, Xfce and Gnome are display managers, are they X server clients then?
从阅读本文开始,我认为X是位于操作系统顶部的层(一个X服务器位于操作系统之上),X客户端应用程序向X服务器发出请求。我认为KDE,Xfce和Gnome都是显示管理器,那么它们是X服务器客户端吗?
I'm quite confused where everything sits.
我对所有事情都很困惑。
Any explanation would be really appreciated!
任何解释都会非常感激!
4 个解决方案
#1
28
It's all very modular and flexible; however this leads to complexity.
它非常模块化和灵活;然而,这会导致复杂性。
The "X Server" drives the display device. It provides graphics services to clients, and those services are pretty simple - such as:
“X服务器”驱动显示设备。它为客户提供图形服务,这些服务非常简单 - 例如:
"Give me a window frame to draw in"
"Put this bitmap here"
"Draw a horizontal black line 100px wide"
"Render the text 'hello' at (100,100)"
"Tell me if any mouse clicks or key presses have been aimed at my window frame"
There is a library called Xlib, provided by X, that has a standard interface for all these simple services. Any program that wants to use the X server's display eventually uses this client library and is called an X Client. Xlib knows how to connect to an arbitrary X server - on the local machine, or via TCP/IP across the LAN, or across the world - to call these services.
X提供了一个名为Xlib的库,它为所有这些简单服务提供了标准接口。任何想要使用X服务器显示的程序最终都使用此客户端库,称为X客户端。 Xlib知道如何连接到任意X服务器 - 在本地机器上,或通过LAN或全世界的TCP / IP - 来调用这些服务。
The Window Manager, which is just another X client program, is in charge of the "look and feel" of the desktop - how you move and arrange windows, etc. Because the window manager draws all the window decorations, it can make the desktop look like WindowsXP, or a Mac, or NeXTSTEP.
窗口管理器,它只是另一个X客户端程序,负责桌面的“外观和感觉” - 如何移动和排列窗口等。因为窗口管理器绘制所有窗口装饰,它可以使桌面看起来像WindowsXP,Mac或NeXTSTEP。
Part of the philosophy of X was to define "mechanism and not policy" - meaning, they give you tools to do it, but don't tell you how to use those tools. One such tool is the window manager, which can be replaced at will.
X的哲学的一部分是定义“机制而非政策” - 意思是,它们为您提供了工具,但不告诉您如何使用这些工具。一个这样的工具是窗口管理器,可以随意更换。
Many modern X applications are written to use a desktop enviroment such as Gnome or KDE. This offers these programs a consistent set of buttons and controls to draw, and a consistent interface for some things not traditionally included in X, but often considered part of a desktop - such as how to respond to drag-and-drop or how to present a standard file chooser dialog box.
编写许多现代X应用程序以使用诸如Gnome或KDE之类的桌面环境。这为这些程序提供了一组一致的按钮和控件来绘制,并为一些传统上不包含在X中的东西提供了一致的界面,但通常被认为是桌面的一部分 - 例如如何响应拖放或如何呈现标准文件选择器对话框。
The desktop environment usually provides an object model or programmatic interface that takes care of making all the simple X client requests and lets the program handle more important things. Removing these low-level calls yields another important benefit - platform independence.
桌面环境通常提供对象模型或编程接口,负责处理所有简单的X客户端请求,并让程序处理更重要的事情。删除这些低级别调用会产生另一个重要好处 - 平*立性。
Many desktop environments include a window manager, so that the look and feel of window controls and buttons is consistent and works with the desktop metaphor provided by the environment. However, it can usually still be switched out.
许多桌面环境都包含一个窗口管理器,因此窗口控件和按钮的外观和感觉是一致的,并且与环境提供的桌面隐喻一起使用。但是,它通常仍然可以关闭。
The separation of the X Server (running the display) and the X Client (wanting to use the display) has a few implications:
X服务器(运行显示器)和X客户端(想要使用显示器)的分离有一些含义:
-
The graphics system is separate from the GUI programs, and they are separated about as completely as a web browser and web server are.
图形系统与GUI程序是分开的,它们与Web浏览器和Web服务器完全分开。
-
So the GUI program might not be displaying on the local machine - just like a web browser doesn't have to point at a web server on the local machine.
因此GUI程序可能不会在本地计算机上显示 - 就像Web浏览器不必指向本地计算机上的Web服务器一样。
-
A machine can run JUST the client, with the X server elsewhere.
一台机器可以运行JUST客户端,X服务器可以在别处运行。
-
The machine with the display doesn't have to run the client - it can run JUST the X server, and all the clients can run on a dedicated machine. This is the original thin client: big programs running on big central server - with graphical user interaction handled by dedicated hardware on the desk in front of the user.
具有显示器的机器不必运行客户端 - 它可以运行JUST X服务器,并且所有客户端都可以在专用机器上运行。这是最初的瘦客户端:在大型*服务器上运行的大型程序 - 图形用户交互由用户面前的桌面上的专用硬件处理。
-
You need to know what your X server's network address is so you can tell GUI programs where to display their GUI. (this is usually done by setting the DISPLAY environment variable)
您需要知道X服务器的网络地址是什么,这样您就可以告诉GUI程序在哪里显示其GUI。 (这通常通过设置DISPLAY环境变量来完成)
-
You can display many programs, from many different machines, all on the same desktop at the same time. It is all handled seamlessly, including cut-and-paste.
您可以在同一台桌面上同时显示许多不同计算机上的许多程序。它全部无缝处理,包括剪切和粘贴。
#2
4
X11 is a network protocol, currently at release 7 (hence X11R7). It encapsulates graphics and input information, and connects an X client (application or window manager) running on a local or remote machine to the X server currently driving the local screen and input devices.
X11是一种网络协议,目前处于第7版(因此为X11R7)。它封装图形和输入信息,并将在本地或远程计算机上运行的X客户端(应用程序或窗口管理器)连接到当前驱动本地屏幕和输入设备的X服务器。
Gnome, KDE, XFCE, and LXDE are desktop environments; they contain pieces that talk to/with the X server (metacity, kwin, etc.), but also consist of specifications that applications must follow and libraries that are available in order for an application to "belong" to the DE.
Gnome,KDE,XFCE和LXDE是桌面环境;它们包含与X服务器通信的部分(metacity,kwin等),但也包括应用程序必须遵循的规范以及可用于应用程序“属于”DE的库。
#3
2
In addition, it's worth remembering that the X server is just another program that gets run under linux. There's nothing special about it, it just happens to know how to grab onto the graphics card and take over the monitor using video drivers. You can (theoretically) run linux very happily without ever running an X server - although of course, you would be limited to the command line programs.
此外,值得记住的是,X服务器只是另一个在linux下运行的程序。它并没有什么特别之处,它恰好知道如何抓住显卡并使用视频驱动程序接管显示器。您可以(理论上)非常愉快地运行Linux而无需运行X服务器 - 当然,您将受限于命令行程序。
That's how linux organises itself - kernel at the base, then a set of programs that provide functionality to higher level programs, which themselves provide functionality to higher level programs, all building up into a complete stack of software oriented to whatever the job of the machine is (say, general desktop, software development, web server, etc).
这就是linux组织自己的方式 - 基础内核,然后是一组程序,为更高级别的程序提供功能,这些程序本身为更高级别的程序提供功能,所有程序都构建成一个完整的软件堆栈,面向机器的任何工作。是(例如,通用桌面,软件开发,Web服务器等)。
Beyond the kernel and it's modules, nothing is 'special'.
除了内核和它的模块之外,没有什么是“特殊的”。
#1
28
It's all very modular and flexible; however this leads to complexity.
它非常模块化和灵活;然而,这会导致复杂性。
The "X Server" drives the display device. It provides graphics services to clients, and those services are pretty simple - such as:
“X服务器”驱动显示设备。它为客户提供图形服务,这些服务非常简单 - 例如:
"Give me a window frame to draw in"
"Put this bitmap here"
"Draw a horizontal black line 100px wide"
"Render the text 'hello' at (100,100)"
"Tell me if any mouse clicks or key presses have been aimed at my window frame"
There is a library called Xlib, provided by X, that has a standard interface for all these simple services. Any program that wants to use the X server's display eventually uses this client library and is called an X Client. Xlib knows how to connect to an arbitrary X server - on the local machine, or via TCP/IP across the LAN, or across the world - to call these services.
X提供了一个名为Xlib的库,它为所有这些简单服务提供了标准接口。任何想要使用X服务器显示的程序最终都使用此客户端库,称为X客户端。 Xlib知道如何连接到任意X服务器 - 在本地机器上,或通过LAN或全世界的TCP / IP - 来调用这些服务。
The Window Manager, which is just another X client program, is in charge of the "look and feel" of the desktop - how you move and arrange windows, etc. Because the window manager draws all the window decorations, it can make the desktop look like WindowsXP, or a Mac, or NeXTSTEP.
窗口管理器,它只是另一个X客户端程序,负责桌面的“外观和感觉” - 如何移动和排列窗口等。因为窗口管理器绘制所有窗口装饰,它可以使桌面看起来像WindowsXP,Mac或NeXTSTEP。
Part of the philosophy of X was to define "mechanism and not policy" - meaning, they give you tools to do it, but don't tell you how to use those tools. One such tool is the window manager, which can be replaced at will.
X的哲学的一部分是定义“机制而非政策” - 意思是,它们为您提供了工具,但不告诉您如何使用这些工具。一个这样的工具是窗口管理器,可以随意更换。
Many modern X applications are written to use a desktop enviroment such as Gnome or KDE. This offers these programs a consistent set of buttons and controls to draw, and a consistent interface for some things not traditionally included in X, but often considered part of a desktop - such as how to respond to drag-and-drop or how to present a standard file chooser dialog box.
编写许多现代X应用程序以使用诸如Gnome或KDE之类的桌面环境。这为这些程序提供了一组一致的按钮和控件来绘制,并为一些传统上不包含在X中的东西提供了一致的界面,但通常被认为是桌面的一部分 - 例如如何响应拖放或如何呈现标准文件选择器对话框。
The desktop environment usually provides an object model or programmatic interface that takes care of making all the simple X client requests and lets the program handle more important things. Removing these low-level calls yields another important benefit - platform independence.
桌面环境通常提供对象模型或编程接口,负责处理所有简单的X客户端请求,并让程序处理更重要的事情。删除这些低级别调用会产生另一个重要好处 - 平*立性。
Many desktop environments include a window manager, so that the look and feel of window controls and buttons is consistent and works with the desktop metaphor provided by the environment. However, it can usually still be switched out.
许多桌面环境都包含一个窗口管理器,因此窗口控件和按钮的外观和感觉是一致的,并且与环境提供的桌面隐喻一起使用。但是,它通常仍然可以关闭。
The separation of the X Server (running the display) and the X Client (wanting to use the display) has a few implications:
X服务器(运行显示器)和X客户端(想要使用显示器)的分离有一些含义:
-
The graphics system is separate from the GUI programs, and they are separated about as completely as a web browser and web server are.
图形系统与GUI程序是分开的,它们与Web浏览器和Web服务器完全分开。
-
So the GUI program might not be displaying on the local machine - just like a web browser doesn't have to point at a web server on the local machine.
因此GUI程序可能不会在本地计算机上显示 - 就像Web浏览器不必指向本地计算机上的Web服务器一样。
-
A machine can run JUST the client, with the X server elsewhere.
一台机器可以运行JUST客户端,X服务器可以在别处运行。
-
The machine with the display doesn't have to run the client - it can run JUST the X server, and all the clients can run on a dedicated machine. This is the original thin client: big programs running on big central server - with graphical user interaction handled by dedicated hardware on the desk in front of the user.
具有显示器的机器不必运行客户端 - 它可以运行JUST X服务器,并且所有客户端都可以在专用机器上运行。这是最初的瘦客户端:在大型*服务器上运行的大型程序 - 图形用户交互由用户面前的桌面上的专用硬件处理。
-
You need to know what your X server's network address is so you can tell GUI programs where to display their GUI. (this is usually done by setting the DISPLAY environment variable)
您需要知道X服务器的网络地址是什么,这样您就可以告诉GUI程序在哪里显示其GUI。 (这通常通过设置DISPLAY环境变量来完成)
-
You can display many programs, from many different machines, all on the same desktop at the same time. It is all handled seamlessly, including cut-and-paste.
您可以在同一台桌面上同时显示许多不同计算机上的许多程序。它全部无缝处理,包括剪切和粘贴。
#2
4
X11 is a network protocol, currently at release 7 (hence X11R7). It encapsulates graphics and input information, and connects an X client (application or window manager) running on a local or remote machine to the X server currently driving the local screen and input devices.
X11是一种网络协议,目前处于第7版(因此为X11R7)。它封装图形和输入信息,并将在本地或远程计算机上运行的X客户端(应用程序或窗口管理器)连接到当前驱动本地屏幕和输入设备的X服务器。
Gnome, KDE, XFCE, and LXDE are desktop environments; they contain pieces that talk to/with the X server (metacity, kwin, etc.), but also consist of specifications that applications must follow and libraries that are available in order for an application to "belong" to the DE.
Gnome,KDE,XFCE和LXDE是桌面环境;它们包含与X服务器通信的部分(metacity,kwin等),但也包括应用程序必须遵循的规范以及可用于应用程序“属于”DE的库。
#3
2
In addition, it's worth remembering that the X server is just another program that gets run under linux. There's nothing special about it, it just happens to know how to grab onto the graphics card and take over the monitor using video drivers. You can (theoretically) run linux very happily without ever running an X server - although of course, you would be limited to the command line programs.
此外,值得记住的是,X服务器只是另一个在linux下运行的程序。它并没有什么特别之处,它恰好知道如何抓住显卡并使用视频驱动程序接管显示器。您可以(理论上)非常愉快地运行Linux而无需运行X服务器 - 当然,您将受限于命令行程序。
That's how linux organises itself - kernel at the base, then a set of programs that provide functionality to higher level programs, which themselves provide functionality to higher level programs, all building up into a complete stack of software oriented to whatever the job of the machine is (say, general desktop, software development, web server, etc).
这就是linux组织自己的方式 - 基础内核,然后是一组程序,为更高级别的程序提供功能,这些程序本身为更高级别的程序提供功能,所有程序都构建成一个完整的软件堆栈,面向机器的任何工作。是(例如,通用桌面,软件开发,Web服务器等)。
Beyond the kernel and it's modules, nothing is 'special'.
除了内核和它的模块之外,没有什么是“特殊的”。