From 20d459d113346dd6f7d18322b29281c50afa773c Mon Sep 17 00:00:00 2001 From: Quantum Date: Sun, 29 May 2022 00:34:37 -0400 Subject: [PATCH] [client] wayland: deal getting scale before size Certain window managers give us a scale before it gives us a size. This commit makes the Wayland backend avoid passing a zero size to wp_viewport_set_source, which is a protocol error. --- client/displayservers/Wayland/gl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/client/displayservers/Wayland/gl.c b/client/displayservers/Wayland/gl.c index b632b989..200ccd9f 100644 --- a/client/displayservers/Wayland/gl.c +++ b/client/displayservers/Wayland/gl.c @@ -88,10 +88,13 @@ void waylandEGLSwapBuffers(EGLDisplay display, EGLSurface surface, const struct if (wlWm.needsResize) { + bool skipResize = false; wl_egl_window_resize(wlWm.eglWindow, wl_fixed_to_int(wlWm.width * wlWm.scale), wl_fixed_to_int(wlWm.height * wlWm.scale), 0, 0); - if (wlWm.fractionalScale) + if (wlWm.width == 0 || wlWm.height == 0) + skipResize = true; + else if (wlWm.fractionalScale) { wl_surface_set_buffer_scale(wlWm.surface, 1); if (!wlWm.viewport) @@ -125,7 +128,7 @@ void waylandEGLSwapBuffers(EGLDisplay display, EGLSurface surface, const struct (struct Border) {0, 0, 0, 0}); app_invalidateWindow(true); waylandStopWaitFrame(); - wlWm.needsResize = false; + wlWm.needsResize = !skipResize; } waylandShellAckConfigureIfNeeded();