What is the server-client relationship between a terminal emulator, a window manager and a X server processes?

  1. In APUE (see the figure below), how do a terminal emulator process and a window manager
    (e.g. openbox) process communicate? Is a temrinal emulator process
    a client of a window manager process, based on Unix domain socket?
  2. What is the relation of X server process to a terminal emulator process and a window manager process? Specifically:

    xlsclients output contains lxterminal. Does that means that a
    terminal emulator process is a client of X server?

    $ xlsclients -a |  grep -i lxterminal
    ocean  lxterminal

    xlsclients output doesn’t contain a window manager process. Does that means that a window manager process is not a client of X server?

    $ xlsclients -a |  grep -i openbox
    $

enter image description here

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

xlsclients is a simple application which is listing the WM_CLIENT_MACHINE and WM_COMMAND properties set on top windows (ie. windows which are children of the root window or have a WM_STATE property).

That’s about everything that it does. There’s no magic.

For instance, I’m using my own window manager which has opened an InputOnly (invisible) window as child of the root window, to use it for ewmh‘s wm check. If I set those two properties on it, the expected thing will happen 😉

$ xprop -id 0x400001 -f WM_CLIENT_MACHINE 8s -set WM_CLIENT_MACHINE kgbvax
$ xprop -id 0x400001 -set WM_COMMAND /sbin/reboot
$ $ xlsclients
kgbvax  /sbin/reboot
...

But to answer your question:

how do a terminal emulator process and a window manager (e.g. openbox) process communicate? Is a terminal emulator process a client of a window manager process, based on Unix domain socket?

They’re both clients of the X11 server, and they usually communicate by sending client messages with XSendEvent(3) and setting properties on windows. The protocol is described in icccm and ewmh. Notice that a client does not “have” a window; any client can do any operation on any window, including but not limited to setting and getting any property off it.

Method 2

I don’t know what APUE is supposed to mean, and googling turns up nothing useful, but I can explain it for terminal emulators like xterm. While xterm just uses a single shell plus the PTYs (e.g. the left part of the picture), nothing stops terminal emulators from doing this multiple times e.g. in tabbed subwindows, so possibly APUE is such a program.

1) The terminal emulator is just a normal X application, and as such communicates with the X window manager in the same way every other X application does: indirectly via the X server. The details of this are complicated, and involve X properties, X events and other stuff. They don’t involve any kind of client-server relationship (because the connection is indirect), or a Unix domain socket.

2) Any X application, including a terminal emulator, is a client of the X server, via a Unix domain socket if they run on the same machine, or via the network if they don’t. And yes, xlsclients lists all client applications of the X server it connects to, like the name implies.

3) An X window manager like openbox is just an X application which executes a few special commands when connecting to the X server. So an X window manager is a client of the X server (unless you insist of a funny definition of “client”), and communicates in the same way as above. If xlsclients doesn’t list it under “clients”, it’s because the X server treats it in a special way. I am actually not sure about the mechanics of that (the xlsclients might filter it out, or the X server itself might filter it out).

Edit

An X client is (at least according to my view) anything that opens a connection to an X server, even if it doesn’t display a window. So xlsclients is an X client (as long as it runs), as are other commands that query the X server.

“Controlling terminal” is a notion that is completely independent. You may start X applications that (at least initially) have a controlling terminal: That’s the usual case if you start them via the command line. But X applications may also be started without a controlling terminal, e.g. from the X display manager, or from other X clients like the window manager that were started without controlling terminal.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x