1
  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

2

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.

  • Thanks. "sending client messages with XSendEvent(3)", does XSendEvent allow an xclient seemly directly send a message to another xclient, but in fact it is implemented indirectly via X server in between the two clients? Is XSendEvent implemented based on sockets? – Tim Dec 5 '18 at 22:21
  • XSendEvent goes through the X server common to both clients; notice that X11 is network-transparent; the clients can be on completely different machines, different OSes. X_SendEvent is a simple X11 request, just like X_DestroyWindow, X_MapWindow, etc. – mosvy Dec 5 '18 at 22:28
1

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.

  • Thanks. May I ask if a X client means exactly a GUI application process, which means it always has GUI window(s)? Does a X client always have no controlling terminal? – Tim Dec 5 '18 at 12:31
  • @StephenKitt thanks for clarifying for me. Appreciate if you could also consider my questions. – Tim Dec 5 '18 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.