From 5fc4c01302b0729fd9f39e8c504e28cf7347153c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 26 Sep 2019 18:29:37 +0200 Subject: [PATCH] X11: Fix decoration enabling after window creation This fixes the enabling of window decorations after creation. Instead of removing the _MOTIF_WM_HINTS property, we now set or unset the MWM_DECOR_ALL bit of the decorations field. Fixes #1566. --- README.md | 1 + src/x11_window.c | 43 +++++++++++++++++++------------------------ 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 1d209ba8..068a8f66 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,7 @@ information on what to include when reporting a bug. - [X11] Bugfix: The CMake files did not check for the XInput headers (#1480) - [X11] Bugfix: Key names were not updated when the keyboard layout changed (#1462,#1528) + - [X11] Bugfix: Decorations could not be enabled after window creation (#1566) - [NSGL] Removed enforcement of forward-compatible flag for core contexts diff --git a/src/x11_window.c b/src/x11_window.c index d8355ae8..56379a3c 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -50,6 +50,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 @@ -2536,33 +2540,24 @@ void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled) void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool 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, GLFWbool enabled)