Clarifying the semantics of `get_wm_class` and `get_wm_class_instance`

I am using the meta_window_get_wm_class and meta_window_get_wm_class_instance calls via approximately global.get_window_actors().map(w => w.meta_window['get_wm_class']?.() and the equivalent for …_instance.

The documentation for these methods here and here refer to the X WM_CLASS property. Similar information is available from the GNOME Shell source (which Discourse won’t let me link, but at gnome-shell 481657f src/shell-window-tracker.c#L163-L220). In these the documentation refers to name and instance

The X documentation does not have any reference to instance (the WM_CLASS property struct is defined as struct { char *res_name; char *res_class; }), so I would like to understand what the actual relationship is.

It looks to me like the wm_class_instance is equivalent to X’s res_name and XClassHint.wm_class is equivalent to X’s XClassHint.res_class. Is this correct?

That is correct. The labels Instance and Class come from the definition of WM_CLASS in the ICCCM.

For Wayland, they’re both set to the app ID.

1 Like