WM_CLASS vs WM_INSTANCE?

When I run xprop I get a class string that has two values, one of them i3 calls an instance, the other a class, for example on chromium-browser the xprop utility will return something like this,

WM_CLASS(STRING) = "chromium-browser", "Chromium-browser"

What is the official guidance on a window and these two fields? For this they’re pretty similar. Are they ever different? If so, what should I pick and why? How are GUI-authors supposed to class and instance their names?

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

The actual behavior is defined by the spec entitled the Inter-Client Communication Conventions Manual (ICCM). Basically the class name is specified by the person who makes the app. The instance name can be specified by the user and its specified resources should override the class name specified resources.

Here is what ICCMv2 for X11r6 says on WM_CLASS,

4.1.2.5. 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.

(emphasis in bold added by me)


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