From f127523ae9d505eb7ba359feee918a3dc15a45a0 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 31 Oct 2022 22:33:14 +0530 Subject: [PATCH] Get rid of the unneccessary swap on first configure Instead use the new flag to indicate the surface should not be committed till the next swap. --- glfw/wl_window.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/glfw/wl_window.c b/glfw/wl_window.c index df1e81bc3..ab21f43a7 100644 --- a/glfw/wl_window.c +++ b/glfw/wl_window.c @@ -275,18 +275,6 @@ static void setOpaqueRegion(_GLFWwindow* window, bool commit_surface) wl_region_destroy(region); } -static void -swap_buffers(_GLFWwindow *window) { - // 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((GLFWwindow*)window); - window->context.swapBuffers(window); - if (!context_is_current) glfwMakeContextCurrent(current); -} - static void resizeFramebuffer(_GLFWwindow* window) { @@ -604,8 +592,9 @@ static void xdgSurfaceHandleConfigure(void* data, int width = window->wl.pending.width; int height = window->wl.pending.height; if (!window->wl.surface_configured_once) { + window->swaps_disallowed = false; + window->wl.waiting_for_swap_to_commit = true; window->wl.surface_configured_once = true; - swap_buffers(window); } if (new_states != window->wl.current.toplevel_states || @@ -628,11 +617,10 @@ static void xdgSurfaceHandleConfigure(void* data, window->wl.current.decoration_mode = mode; } - bool resized = false; if (window->wl.pending_state) { int width = window->wl.pending.width, height = window->wl.pending.height; set_csd_window_geometry(window, &width, &height); - resized = dispatchChangesAfterConfigure(window, width, height); + bool resized = dispatchChangesAfterConfigure(window, width, height); if (window->wl.decorations.serverSide) { free_csd_surfaces(window); } else {