Skip to content

backend/x11: Implement a few useful window properties

Tasos Sahanidis requested to merge tatokis/wlroots:x11-props into master

It is currently impossible to tell if an X11 window is created by wlroots, or what process / client it belongs to.

The following properties are now added to the window:

  • WM_CLASS
  • WM_CLIENT_MACHINE
  • _NET_WM_PID

Sample xprop output:

WM_CLASS(STRING) = "X11-1", "wlroots"
WM_CLIENT_MACHINE(STRING) = "My-Desktop"
_NET_WM_PID(CARDINAL) = 3629306

Unfortunately, generating the WM_CLASS string requires manual length calculations so that only the first string gets truncated due to lack of space, and not the second one.

Something along the lines of

snprintf(wm_class, sizeof(wm_class), "%s%c%s", wlr_output->name, '\0', X11_OUT_WM_CLASS_WLR);

would not work, even if we detected that the string was truncated by checking the return value, as we'd then still have to manually calculate the length to truncate wlr_output->name at.

Suggestions to improve it are welcome, as I was unable to come up with anything better.

Merge request reports

Loading