From 1e7a11b27833a646a1a54ed4c192a2a60b5f2234 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 10 Sep 2022 10:22:09 +0530 Subject: [PATCH] Wayland: When swapping buffers in response to a configure event ensure the window is the current context otherwise the swap fails The swap failing will mean the buffer is not attached which might cause issues with some compsitors. --- glfw/wl_window.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/glfw/wl_window.c b/glfw/wl_window.c index 773956e80..30cbe88a2 100644 --- a/glfw/wl_window.c +++ b/glfw/wl_window.c @@ -498,7 +498,11 @@ static void xdgSurfaceHandleConfigure(void* data, window->wl.surface_configured_once = true; // this will attach the buffer to the surface, the client is responsible for clearing the buffer to an appropriate blank window->swaps_disallowed = false; + GLFWwindow *current = glfwGetCurrentContext(); + bool context_is_current = ((_GLFWwindow*)current)->id == window->id; + if (!context_is_current) glfwMakeContextCurrent(data); window->context.swapBuffers(window); + if (!context_is_current) glfwMakeContextCurrent(current); if (!width && !height && !new_states && !window->wl.decorations.serverSide && getenv("XAUTHORITY") && strstr(getenv("XAUTHORITY"), "mutter")) { // https://github.com/kovidgoyal/kitty/issues/4802