From dfaa6fdc140ebc60b61723dd395a4df1619f46bf Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 4 Dec 2022 12:03:44 +0100 Subject: [PATCH] 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: --- src/frames/meta-frame.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/frames/meta-frame.c b/src/frames/meta-frame.c index c66d8b660..f17fe982c 100644 --- a/src/frames/meta-frame.c +++ b/src/frames/meta-frame.c @@ -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