X, Xorg and D-Bus: what is the difference

d-buswindow-managerx11xorg

In the process of learning to do certain things in GUI programming (e.g., reserving space on the screen for an application), I have to learn more about the Window Manager, usually X11 on Linux (I'm not sure whether there even are distro's, which use anything else than X11, although I heard about Wayland, which is not yet implemented in any.)

I'm quite new to programming, and impatient; so I'm just diving into it. Now I am reading the ICCCM, with the hope to learn more. This document however aims at a public that knows (way) more than me. So I came across some information, and I would love to get some clarifications.

Section 2 of the ICCCM quotes:

Note that all data transferred between an owner and a requestor must usually go by means of the server in a X Version 11 environment. A client cannot assume that another client can open the same files or even communicate directly. The other client may be talking to the server by means of a completely different networking mechanism (for example, one client might be DECnet and the other TCP/IP). Thus, passing indirect references to data (such as file names, host names and port numbers, and so on) is permitted only if both clients specifically agree.

As far as I understand, X Window Manager is built on Top of X Server (thanks Wikipedia). In the quote above: it says the client can communicate with the server using DECnet or TCP/IP. So far I thought that "server" was a figure of speech, now I am doubting: is X server a server as in a "web server"? How should I understand its function/definition?

Then, there often are references to X11, Xorg, X Server and/or X Window Manager. It gets confusing: is X11 a bundle including Xorg and X Window Manager? If so, is there anything else in this X11 bundle?

X also needs mouse or keyboard or any other kind of input: is this part of X Server's functions too? Is X Window Manager strictly looking after the display only?

Finally, the quote here above also mentions client communicating or not with each other: this reminded me of D-Bus, which I've used a bit for learning purposes. With D-Bus you can also trigger window events. That gets me a bit confused as to how programs should communicate with one another: *what difference is there between programs interacting using X Server or using D-Bus? *

It's a shame this information remains somehow obscure, it makes it harder to learn, but hopefully you can bring some light on this 🙂 Thanks.

Best Answer

You are asking five questions here, and might be better asking five questions ☺ But I'll jump in:

  1. X is a server and can be compared to a "web server" in that it is a process that listens for incoming connections that speak a particular protocol (the X protocol) and it issues answers. The connections come from X clients, which may be on the local host or on a remote host accessed over a network.

  2. X11 is a "major version" of the X protocol, which has evolved since inception. X11 is the most recent protocol and the most common. (Xorg is an implementation of an X server, X libraries and a collection of clients, all talking X11. There are other implementations: the largely defunct XFree86; commercial ones such as Hummingbird Exceed; forks such as XQuartz, which runs on Mac OS X)

  3. A "window manager" is an X client which manages windows. It typically has the responsibility to decorate windows with bevels/borders, drop shadows, a menu bar containing buttons, etc. -- and handle the logic of window placement; support windows being dragged, resized or re-arranged, etc.

  4. X requires input and it has a shared responsibility to manage that with the Kernel. Historically, X did a lot of hardware management itself. In modern times, on the Linux platform, X is gradually becoming "smaller" and delegating this responsibility to the Linux kernel. The advantages of this are: smaller X codebase; fewer "crossed-wires" with the kernel and X both trying to manage the same stuff. (an example of this is the Linux event interface, where events from mice etc. are interpreted and translated by the kernel and its drivers into the standard interface at /dev/input/event*, which is consumed by the X server). Note that on other platforms (BSD, Solaris) X is still quite monolithic.

  5. There are many, many ways for processes to communicate with each other. I believe X clients can interact by way of the X protocol (for example, traditional X window managers need to know when other clients draw windows, in order to decorate them; pagers need to know when a window's size or position changes, in order to reflect that in the pager). D-Bus is a modern inter-process communication (IPC) technology developed to address the shortcomings of other methods. It is not X specific.

Related Question