From 2df0ce07faead09b1d305d30cf68d95c1145c37c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 20 Jun 2022 22:20:56 +0200 Subject: [PATCH] Wayland: Store and act on XDG decoration mode Refer to the XDG decoration mode (or the lack of one) directly instead of setting a boolean in a struct meant for the fallback decorations. This makes things a bit more verbose but is in preparation for a refactoring of all decoration paths. --- src/wl_platform.h | 2 +- src/wl_window.c | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/wl_platform.h b/src/wl_platform.h index d8d94822..b3d23da0 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -251,6 +251,7 @@ typedef struct _GLFWwindowWayland struct xdg_surface* surface; struct xdg_toplevel* toplevel; struct zxdg_toplevel_decoration_v1* decoration; + uint32_t decorationMode; } xdg; _GLFWcursor* currentCursor; @@ -273,7 +274,6 @@ typedef struct _GLFWwindowWayland struct zwp_idle_inhibitor_v1* idleInhibitor; struct { - GLFWbool serverSide; struct wl_buffer* buffer; _GLFWdecorationWayland top, left, right, bottom; int focus; diff --git a/src/wl_window.c b/src/wl_window.c index 8e61a70b..44f1df7b 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -220,7 +220,7 @@ static void createFallbackDecorations(_GLFWwindow* window) unsigned char data[] = { 224, 224, 224, 255 }; const GLFWimage image = { 1, 1, data }; - if (!_glfw.wl.viewporter || !window->decorated || window->wl.decorations.serverSide) + if (!_glfw.wl.viewporter || !window->decorated) return; if (!window->wl.decorations.buffer) @@ -273,9 +273,9 @@ static void xdgDecorationHandleConfigure(void* userData, { _GLFWwindow* window = userData; - window->wl.decorations.serverSide = (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); + window->wl.xdg.decorationMode = mode; - if (!window->wl.decorations.serverSide) + if (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE) createFallbackDecorations(window); } @@ -431,7 +431,7 @@ static void acquireMonitor(_GLFWwindow* window) setIdleInhibitor(window, GLFW_TRUE); - if (!window->wl.decorations.serverSide) + if (window->wl.decorations.top.surface) destroyFallbackDecorations(window); } @@ -444,7 +444,7 @@ static void releaseMonitor(_GLFWwindow* window) setIdleInhibitor(window, GLFW_FALSE); - if (!_glfw.wl.decorationManager) + if (window->wl.xdg.decorationMode != ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE) createFallbackDecorations(window); } @@ -635,10 +635,7 @@ static GLFWbool createShellObjects(_GLFWwindow* window) ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); } else - { - window->wl.decorations.serverSide = GLFW_FALSE; createFallbackDecorations(window); - } } if (window->minwidth != GLFW_DONT_CARE && window->minheight != GLFW_DONT_CARE) @@ -689,6 +686,7 @@ static void destroyShellObjects(_GLFWwindow* window) xdg_surface_destroy(window->wl.xdg.surface); window->wl.xdg.decoration = NULL; + window->wl.xdg.decorationMode = 0; window->wl.xdg.toplevel = NULL; window->wl.xdg.surface = NULL; } @@ -1978,7 +1976,7 @@ void _glfwGetWindowFrameSizeWayland(_GLFWwindow* window, int* left, int* top, int* right, int* bottom) { - if (window->decorated && !window->monitor && !window->wl.decorations.serverSide) + if (window->decorated && !window->monitor && window->wl.decorations.top.surface) { if (top) *top = GLFW_CAPTION_HEIGHT;