Wayland: Ensure context is correct when calling wl_egl_window_resize

Fixes #7373 (I hope)
This commit is contained in:
Kovid Goyal 2024-04-22 18:06:03 +05:30
parent fbefd8600f
commit 9755d0d879
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C

10
glfw/wl_window.c vendored
View file

@ -356,6 +356,14 @@ _glfwWaylandWindowScale(_GLFWwindow *window) {
return ans;
}
#define run_with_context(window, expression) { \
const _GLFWwindow *current_context = (_GLFWwindow*)glfwGetCurrentContext(); \
const bool needs_swap = window != current_context; \
if (needs_swap) glfwMakeContextCurrent((GLFWwindow*)window); \
expression; \
if (needs_swap) glfwMakeContextCurrent((GLFWwindow*)current_context); \
}
static void
resizeFramebuffer(_GLFWwindow* window) {
double scale = _glfwWaylandWindowScale(window);
@ -363,7 +371,7 @@ resizeFramebuffer(_GLFWwindow* window) {
int scaled_height = (int)round(window->wl.height * scale);
debug("Resizing framebuffer of window: %llu to: %dx%d window size: %dx%d at scale: %.3f\n",
window->id, scaled_width, scaled_height, window->wl.width, window->wl.height, scale);
wl_egl_window_resize(window->wl.native, scaled_width, scaled_height, 0, 0);
run_with_context(window, wl_egl_window_resize(window->wl.native, scaled_width, scaled_height, 0, 0));
update_regions(window);
window->wl.waiting_for_swap_to_commit = true;
_glfwInputFramebufferSize(window, scaled_width, scaled_height);