Cloudef / wlc

High-level Wayland compositor library
MIT License
330 stars 58 forks source link

return second string of WM_CLASS #218

Closed ljrk0 closed 7 years ago

ljrk0 commented 7 years ago

The function wlc_view_get_class() returns the first part of the WM_CLASS property while it's more likely that the second one is expected. Eg. i3wm uses the second string of WM_CLASS when using for_window [class="my_application"] for matching:

class The X11 window class (second part of WM_CLASS)

(http://i3wm.org/docs/userguide.html#command_criteria)

This is the property as specified by the X.org foundation:

WM_CLASS Property

The WM_CLASS property (of type STRING without control characters) contains two consecutive null-terminated strings. These specify the Instance and Class names to be used by both the client and the window manager for looking up resources for the application or as identifying information. This property must be present when the window leaves the Withdrawn state and may be changed only while the window is in the Withdrawn state. Window managers may examine the property only when they start up and when the window leaves the Withdrawn state, but there should be no need for a client to change its state dynamically.

The two strings, respectively, are:

  • A string that names the particular instance of the application to which the client that owns this window belongs. Resources that are specified by instance name override any resources that are specified by class name. Instance names can be specified by the user in an operating-system specific manner. On POSIX-conformant systems, the following conventions are used:

    • If "-name NAME" is given on the command line, NAME is used as the instance name.

    • Otherwise, if the environment variable RESOURCE_NAME is set, its value will be used as the instance name.

    • Otherwise, the trailing part of the name used to invoke the program (argv[0] stripped of any directory names) is used as the instance name.

  • A string that names the general class of applications to which the client that owns this window belongs. Resources that are specified by class apply to all applications that have the same class name. Class names are specified by the application writer. Examples of commonly used class names include: "Emacs", "XTerm", "XClock", "XLoad", and so on.

Note that WM_CLASS strings are null-terminated and, thus, differ from the general conventions that STRING properties are null-separated. This inconsistency is necessary for backwards compatibility.

https://www.x.org/releases/X11R7.7/doc/xorg-docs/icccm/icccm.html#WM_CLASS_Property

See also: https://github.com/SirCmpwn/sway/issues/1020

Cloudef commented 7 years ago

Can you do patch / PR fo this?

ljrk0 commented 7 years ago

Done.