14.1.8 Setting and Reading the WM_CLASS Property

Xlib provides functions that you can use to set and get the WM_CLASS property for a given window. These functions use the XClassHint structure, which is defined in the X11/Xutil.h header file.

To allocate an XClassHint structure, use XAllocClassHint().

The XClassHint contains:

typedef struct {
	char *res_name;
	char *res_class;
} XClassHint;

The res_name member contains the application name, and the res_class member contains the application class. Note that the name set in this property may differ from the name set as WM_NAME. That is, WM_NAME specifies what should be displayed in the title bar and, therefore, can contain temporal information (for example, the name of a file currently in an editor's buffer). On the other hand, the name specified as part of WM_CLASS is the formal name of the application that should be used when retrieving the application's resources from the resource database.

To set a window's WM_CLASS property, use XSetClassHint().

To read a window's WM_CLASS property, use XGetClassHint().

Next: Setting and Reading the WM_TRANSIENT_FOR Property

Christophe Tronche, [email protected]