From 0594033b31d3e3aa3b6268ff79938072602344a7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 26 Aug 2024 15:28:47 +0530 Subject: [PATCH] Wayland: Move creation of OpenGL context to end of window creation function Apparently with explicit sync it is now not possible to attach a temporary buffer to a surface that also has an OpenGL context. So we first attach the temporary buffer, and only after we are done waiting for window creation do we attach the OpenGL context to the window surface. Fixes #7767 (maybe, not installing sway-git to check) --- docs/changelog.rst | 2 ++ glfw/wl_window.c | 44 ++++++++++++++++++++------------------------ 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 6da059bd4..d7bb970e6 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -81,6 +81,8 @@ Detailed list of changes - :ac:`goto_tab`: Allow numbers less than ``-1`` to go to the Nth previously active tab +- Wayland: Fix for upcoming explicit sync changes in Wayland compositors breaking kitty (:iss:`7767`) + 0.36.1 [2024-08-24] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/glfw/wl_window.c b/glfw/wl_window.c index 0b1566d0f..92301f484 100644 --- a/glfw/wl_window.c +++ b/glfw/wl_window.c @@ -1320,30 +1320,8 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, window->swaps_disallowed = true; if (!createSurface(window, wndconfig)) return false; - - if (ctxconfig->client != GLFW_NO_API) - { - if (ctxconfig->source == GLFW_EGL_CONTEXT_API || - ctxconfig->source == GLFW_NATIVE_CONTEXT_API) - { - if (!_glfwInitEGL()) - return false; - if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig)) - return false; - } - else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API) - { - if (!_glfwInitOSMesa()) - return false; - if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig)) - return false; - } - } - - if (wndconfig->title) - window->wl.title = _glfw_strdup(wndconfig->title); - if (wndconfig->maximized) - window->wl.maximize_on_first_show = true; + if (wndconfig->title) window->wl.title = _glfw_strdup(wndconfig->title); + if (wndconfig->maximized) window->wl.maximize_on_first_show = true; if (wndconfig->visible) { @@ -1367,6 +1345,24 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, window->wl.monitorsCount = 0; window->wl.monitorsSize = 1; if (window->wl.visible) loop_till_window_fully_created(window); + if (ctxconfig->client != GLFW_NO_API) + { + if (ctxconfig->source == GLFW_EGL_CONTEXT_API || + ctxconfig->source == GLFW_NATIVE_CONTEXT_API) + { + if (!_glfwInitEGL()) + return false; + if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig)) + return false; + } + else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API) + { + if (!_glfwInitOSMesa()) + return false; + if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig)) + return false; + } + } return true; }