From 82e88b54c7f995c370596a1ee85a15e0037ce616 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 31 Oct 2019 09:04:45 +0530 Subject: [PATCH] X11: Fix decoration enabling after window creation From upstream: https://github.com/glfw/glfw/commit/5fc4c01302b0729fd9f39e8c504e28cf7347153c --- glfw/x11_window.c | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/glfw/x11_window.c b/glfw/x11_window.c index f5e426a48..8e189a220 100644 --- a/glfw/x11_window.c +++ b/glfw/x11_window.c @@ -52,6 +52,10 @@ #define Button6 6 #define Button7 7 +// Motif WM hints flags +#define MWM_HINTS_DECORATIONS 2 +#define MWM_DECOR_ALL 1 + #define _GLFW_XDND_VERSION 5 @@ -2351,33 +2355,24 @@ void _glfwPlatformSetWindowResizable(_GLFWwindow* window, bool enabled UNUSED) void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, bool enabled) { - if (enabled) + struct { - XDeleteProperty(_glfw.x11.display, - window->x11.handle, - _glfw.x11.MOTIF_WM_HINTS); - } - else - { - struct - { - unsigned long flags; - unsigned long functions; - unsigned long decorations; - long input_mode; - unsigned long status; - } hints; + unsigned long flags; + unsigned long functions; + unsigned long decorations; + long input_mode; + unsigned long status; + } hints = {0}; - hints.flags = 2; // Set decorations - hints.decorations = 0; // No decorations + hints.flags = MWM_HINTS_DECORATIONS; + hints.decorations = enabled ? MWM_DECOR_ALL : 0; - XChangeProperty(_glfw.x11.display, window->x11.handle, - _glfw.x11.MOTIF_WM_HINTS, - _glfw.x11.MOTIF_WM_HINTS, 32, - PropModeReplace, - (unsigned char*) &hints, - sizeof(hints) / sizeof(long)); - } + XChangeProperty(_glfw.x11.display, window->x11.handle, + _glfw.x11.MOTIF_WM_HINTS, + _glfw.x11.MOTIF_WM_HINTS, 32, + PropModeReplace, + (unsigned char*) &hints, + sizeof(hints) / sizeof(long)); } void _glfwPlatformSetWindowFloating(_GLFWwindow* window, bool enabled)