Re: WM_CLASS purpose?

Thomas Lübking thomas.luebking at gmail.com
Wed Oct 31 13:14:32 PDT 2012


On Mittwoch, 31. Oktober 2012 20:43:39 CEST, Vladimir A. Pavlov wrote:

> I'm just searching a way to distinguish between taskbar and menu. AFAIU I
> should set WM_CLASS to somebox/SomeBox 

"somebox", "SomeBox"

> If I set WM_CLIENT_LEADER for a window I _must_ set SM_CLIENT_ID
> for it. But must I set anything for a window I set WM_WINDOW_ROLE for?
No. And given this is all WM or even Client internal, you don't actually *have* to set anything in this regard. You also rely on eg _SB_ROLE on a "proprietary" integer or an Atom to identify the type - or just identify it by matching the WId with an internal pointer.

> IOW is it an allowable situation when a window only have
> WM_WINDOW_ROLE property and nothing else?
Yes, http://tronche.com/gui/x/icccm/sec-5.html

"It is necessary that other clients be able to uniquely identify a window (across sessions) among all windows related to the same client-ID. For example, a window manager can require this unique ID to restore geometry information from a previous session, or a workspace manager could use it to restore information about which windows are in which workspace. A client may optionally provide a WM_WINDOW_ROLE property to uniquely identify a window within the scope specified above. The combination of SM_CLIENT_ID and WM_WINDOW_ROLE can be used by other clients to uniquely identify a window across sessions.

If the WM_WINDOW_ROLE property is not specified on a top level window, a client that needs to uniquely identify that window will try to use instead the values of WM_CLASS and WM_NAME. If a client has multiple windows with identical WM_CLASS and WM_NAME properties, then it should provide a WM_WINDOW_ROLE property.

The client must set the WM_WINDOW_ROLE property to a string that uniquely identifies that window among all windows that have the same client leader window. The property must:

* be of type STRING;
* be of format 8; and
* contain a string restricted to the XPCS characters, encoded in ISO 8859-1."

The property is provided to sharpen WM_CLASS & WM_NAME.

> My goal is to allow other applications to distinguish between windows
> created by somebox by as little code as possible.

Specify "other applications".
If you're talking about a generic approach, you rather should provide WM_CLASS, since that is what most apps will look for first. You should definitly also provide info like _NET_WM_WINDOW_TYPE (for docks and menus, since otherwise the window will be considered "normal") - since no regular application will ever do a string matching whether the role contains "panel" and by this guess of a dock.

If it's "just" about some side-arm processes of you WM, consider tagging the window by a proprietary _SB_ROLE property, this will not break any standard possibly.

> what do the standards say about this?

The standard is mostly for interaction between the WM, Pagers and clients.
If you don't worry about such (since the windows are effectively part of the WM and targeted pagers / taskbars etc. are as well, though maybe in differen X11 Clients) you don't have to worry about the standards at all.

Otherwise rather stick ICCCM and NETWM.
That is, provide WM_CLASS, WM_WINDOW_ROLE and _NET_WM_WINDOW_TYPE, likely WM_PROTOCOLS(ATOM): WM_TAKE_FOCUS

Cheers,
Thomas


More information about the xorg mailing list