From cf6c11cfaa6be44a2ba69f814dc1a022e84e37c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Sun, 27 Dec 2015 10:42:45 +0800 Subject: [PATCH] wayland: Only set surface buffer scale when supported Although very unlikely, the wl_compositor version might not support wl_surface.set_buffer_scale while the wl_output emits a wl_output.scale that is larger than 1. So for correctness, bail on changing the buffer scale if we won't be able to set it later. --- src/wl_init.c | 3 ++- src/wl_platform.h | 2 ++ src/wl_window.c | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/wl_init.c b/src/wl_init.c index cceef16b..90dc507b 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -385,9 +385,10 @@ static void registryHandleGlobal(void* data, { if (strcmp(interface, "wl_compositor") == 0) { + _glfw.wl.wl_compositor_version = min(3, version); _glfw.wl.compositor = wl_registry_bind(registry, name, &wl_compositor_interface, - min(3, version)); + _glfw.wl.wl_compositor_version); } else if (strcmp(interface, "wl_shm") == 0) { diff --git a/src/wl_platform.h b/src/wl_platform.h index a734ec1e..2bfdbb4c 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -91,6 +91,8 @@ typedef struct _GLFWlibraryWayland struct wl_pointer* pointer; struct wl_keyboard* keyboard; + int wl_compositor_version; + struct wl_cursor_theme* cursorTheme; struct wl_surface* cursorSurface; uint32_t pointerSerial; diff --git a/src/wl_window.c b/src/wl_window.c index 00ce7135..3a75daa4 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -79,6 +79,11 @@ static void checkScaleChange(_GLFWwindow* window) int i; int monitorScale; + // Check if we will be able to set the buffer scale or not. + if (_glfw.wl.wl_compositor_version < + WL_SURFACE_SET_BUFFER_SCALE_SINCE_VERSION) + return; + // Get the scale factor from the highest scale monitor. for (i = 0; i < window->wl.monitorsCount; ++i) {