frames: Fix check of Motif WM hints

We use this for tracking the deletable state of the client window,
but forgot to check that the MWM_HINT_FUNCTIONS hint is set in
hints.flags before checking hints.functions.

This resulted in windows that do not specify this flag (and thus
should go with the defaults) in being mistakenly removed the close
button, as the functions flags would be typically 0 in that case.

Fixes issues with Chromium and Electron applications missing the
close button, since Chromium does this on X11.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2735>
This commit is contained in:
Carlos Garnacho 2022-12-04 12:03:44 +01:00
parent 6c0254bf02
commit dfaa6fdc14

View File

@ -42,6 +42,8 @@ typedef struct
unsigned long status;
} MotifWmHints;
#define MWM_HINTS_FUNCTIONS (1L << 0)
#define MWM_FUNC_ALL (1L << 0)
#define MWM_FUNC_RESIZE (1L << 1)
#define MWM_FUNC_MINIMIZE (1L << 3)
@ -188,17 +190,17 @@ frame_sync_motif_wm_hints (GtkWindow *frame,
&nitems, &bytes_after,
(unsigned char **) &mwm_hints);
if (mwm_hints)
if (mwm_hints &&
(mwm_hints->flags & MWM_HINTS_FUNCTIONS) != 0)
{
if ((mwm_hints->functions & MWM_FUNC_ALL) == 0)
deletable = (mwm_hints->functions & MWM_FUNC_CLOSE) != 0;
else
deletable = (mwm_hints->functions & MWM_FUNC_CLOSE) == 0;
g_free (mwm_hints);
}
gtk_window_set_deletable (frame, deletable);
g_free (mwm_hints);
}
static void