Terminal Emulator – Server-Client Relationship Between Terminal Emulator, Window Manager, and X Server

lxterminalnetstatterminal-emulator

  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

Best Answer

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.

Related Question