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.
master
Jonas Ådahl ago%!(EXTRA string=9 years)
parent 06479ba535
commit cf6c11cfaa
  1. 3
      src/wl_init.c
  2. 2
      src/wl_platform.h
  3. 5
      src/wl_window.c

@ -385,9 +385,10 @@ static void registryHandleGlobal(void* data,
{ {
if (strcmp(interface, "wl_compositor") == 0) if (strcmp(interface, "wl_compositor") == 0)
{ {
_glfw.wl.wl_compositor_version = min(3, version);
_glfw.wl.compositor = _glfw.wl.compositor =
wl_registry_bind(registry, name, &wl_compositor_interface, wl_registry_bind(registry, name, &wl_compositor_interface,
min(3, version)); _glfw.wl.wl_compositor_version);
} }
else if (strcmp(interface, "wl_shm") == 0) else if (strcmp(interface, "wl_shm") == 0)
{ {

@ -91,6 +91,8 @@ typedef struct _GLFWlibraryWayland
struct wl_pointer* pointer; struct wl_pointer* pointer;
struct wl_keyboard* keyboard; struct wl_keyboard* keyboard;
int wl_compositor_version;
struct wl_cursor_theme* cursorTheme; struct wl_cursor_theme* cursorTheme;
struct wl_surface* cursorSurface; struct wl_surface* cursorSurface;
uint32_t pointerSerial; uint32_t pointerSerial;

@ -79,6 +79,11 @@ static void checkScaleChange(_GLFWwindow* window)
int i; int i;
int monitorScale; 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. // Get the scale factor from the highest scale monitor.
for (i = 0; i < window->wl.monitorsCount; ++i) for (i = 0; i < window->wl.monitorsCount; ++i)
{ {

Loading…
Cancel
Save