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.
This commit is contained in:
Camilla Löwy 2022-06-20 22:20:56 +02:00
parent 83a134a92f
commit 2df0ce07fa
2 changed files with 8 additions and 10 deletions

View File

@ -251,6 +251,7 @@ typedef struct _GLFWwindowWayland
struct xdg_surface* surface; struct xdg_surface* surface;
struct xdg_toplevel* toplevel; struct xdg_toplevel* toplevel;
struct zxdg_toplevel_decoration_v1* decoration; struct zxdg_toplevel_decoration_v1* decoration;
uint32_t decorationMode;
} xdg; } xdg;
_GLFWcursor* currentCursor; _GLFWcursor* currentCursor;
@ -273,7 +274,6 @@ typedef struct _GLFWwindowWayland
struct zwp_idle_inhibitor_v1* idleInhibitor; struct zwp_idle_inhibitor_v1* idleInhibitor;
struct { struct {
GLFWbool serverSide;
struct wl_buffer* buffer; struct wl_buffer* buffer;
_GLFWdecorationWayland top, left, right, bottom; _GLFWdecorationWayland top, left, right, bottom;
int focus; int focus;

View File

@ -220,7 +220,7 @@ static void createFallbackDecorations(_GLFWwindow* window)
unsigned char data[] = { 224, 224, 224, 255 }; unsigned char data[] = { 224, 224, 224, 255 };
const GLFWimage image = { 1, 1, data }; const GLFWimage image = { 1, 1, data };
if (!_glfw.wl.viewporter || !window->decorated || window->wl.decorations.serverSide) if (!_glfw.wl.viewporter || !window->decorated)
return; return;
if (!window->wl.decorations.buffer) if (!window->wl.decorations.buffer)
@ -273,9 +273,9 @@ static void xdgDecorationHandleConfigure(void* userData,
{ {
_GLFWwindow* window = 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); createFallbackDecorations(window);
} }
@ -431,7 +431,7 @@ static void acquireMonitor(_GLFWwindow* window)
setIdleInhibitor(window, GLFW_TRUE); setIdleInhibitor(window, GLFW_TRUE);
if (!window->wl.decorations.serverSide) if (window->wl.decorations.top.surface)
destroyFallbackDecorations(window); destroyFallbackDecorations(window);
} }
@ -444,7 +444,7 @@ static void releaseMonitor(_GLFWwindow* window)
setIdleInhibitor(window, GLFW_FALSE); setIdleInhibitor(window, GLFW_FALSE);
if (!_glfw.wl.decorationManager) if (window->wl.xdg.decorationMode != ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE)
createFallbackDecorations(window); createFallbackDecorations(window);
} }
@ -635,10 +635,7 @@ static GLFWbool createShellObjects(_GLFWwindow* window)
ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
} }
else else
{
window->wl.decorations.serverSide = GLFW_FALSE;
createFallbackDecorations(window); createFallbackDecorations(window);
}
} }
if (window->minwidth != GLFW_DONT_CARE && window->minheight != GLFW_DONT_CARE) 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); xdg_surface_destroy(window->wl.xdg.surface);
window->wl.xdg.decoration = NULL; window->wl.xdg.decoration = NULL;
window->wl.xdg.decorationMode = 0;
window->wl.xdg.toplevel = NULL; window->wl.xdg.toplevel = NULL;
window->wl.xdg.surface = NULL; window->wl.xdg.surface = NULL;
} }
@ -1978,7 +1976,7 @@ void _glfwGetWindowFrameSizeWayland(_GLFWwindow* window,
int* left, int* top, int* left, int* top,
int* right, int* bottom) 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) if (top)
*top = GLFW_CAPTION_HEIGHT; *top = GLFW_CAPTION_HEIGHT;