4

I'm writing a program that needs to detect the name of the running Window Manager (for example, Compiz) on a Linux host running X11.

I'm currently relying on the Extended Window Manager Hints specification, which allows me to query _NET_SUPPORTING_WM_CHECK through XGetWindowProperty to get the ID of a Window which I can then query (through another call to XGetWindowProperty) for the _NET_WM_NAME property:

if ((disp = XOpenDisplay(NULL)))
{
    if (!(XGetWindowProperty(disp, DefaultRootWindow(disp), XInternAtom(disp, "_NET_SUPPORTING_WM_CHECK", True),
        0, 1024, False, XA_WINDOW, &actual_type, &actual_format, &nitems, &bytes, (unsigned char **) &wm_check_window)))
    {
        if (!(XGetWindowProperty(disp, *wm_check_window, XInternAtom(disp, "_NET_WM_NAME", True),
            0, 1024, False, XInternAtom(disp, "UTF8_STRING", True), &actual_type,
            &actual_format, &nitems, &bytes, (unsigned char **) &wm_name)))
        {
            strncpy(str, (char *) wm_name, MAX_STRLEN);
            XFree(wm_name);
        }
    }
}

This works surprisingly nicely for EWMH-compliant Window Managers, but it doesn't work at all for non-compliant ones. I've tried grabbing the WM_NAME property on those, but that only contains the title (or something related to the title) of the active window.

Is there any way to get the actual name of the Window Manager through X11 without EWMH?

yossarian
  • 1,537
  • 14
  • 21
  • 2
    If there was a pre-EWMH way, way, why would we need the EWMH way? – n. m. could be an AI Nov 08 '14 at 09:05
  • 1
    Because standards overlap all the time. I was just wondering if a previous, more common, standard provided the same properties. – yossarian Nov 08 '14 at 23:40
  • 1
    All the time? Well, not this time. The X philosophy once was that a program shouldn't care whether a WM is running or not. Then Motif was invented, it provided `XmIsMotifWMRunning` (check its source) and it all went downhill from there. Note, many window managers which are definitely not Motif will fool `XmIsMotifWMRunning` into reporting TRUE. – n. m. could be an AI Nov 09 '14 at 04:14

0 Answers0