WM_CLASS purpose?

Glynn Clements glynn at gclements.plus.com
Mon Oct 29 10:14:29 PDT 2012


Vladimir A. Pavlov wrote:

> I'm working on a window manager and I got a few
> questions concerning WM_CLASS property.
> 
> The questions are:
> 
> 1. What is WM_CLASS's purpose? I thought it's to find
>    X resources set by xrdb but Xrm* functions doesn't
>    seem to depend on it. Is there any specific purpose,
>    or does WM_CLASS have no specific purpose and just
>    stores the info that other apps/users decide on how to use it?

The application class is more general than the name. E.g. a user may
run multiple instances of an application with different names, but
they will normally all have the same class.

The class is used for locating resource files (and other files located
via via XtResolvePathname), and for specifying most resources in e.g. 
~/.Xdefaults. You can provide custom resource settings for specific
instances by using the name in the resource setting instead of the
class.

The WM_NAME and WM_CLASS properties make this information available to
other clients, e.g. the window manager and editres. The application
will set these properties to the same values which it passes to Xt.

> 2. Are there rules (recommendation) that an application should
>    follow when setting res_name and res_class?

Normally, the class is hard-coded while the name will be set to the
base name of the executable (determined from argv[0]). These can
normally be overridden with the -class and -name switches.

>    For example, let's suppose I have a window manager
>    somebox that has taskbar, dock, menus for starting
>    applications/switching workspaces and configuration dialogs.
>    What should be res_name/res_class for each of them?

An X client should have a single name and class. You shouldn't use
different values for different windows within a single client
(however, it's possible for a single process to contain multiple
clients by calling XtOpenApplication() multiple times; each "client"
has a separate X connection and XtAppContext).

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the xorg mailing list