From ca573df55941299f4ddca3543f9c4a61045854ab Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 9 Jul 2026 09:52:39 +0000 Subject: [PATCH] wayland: don't send set_buffer_scale on wl_surface below version 3 wl_surface::set_buffer_scale is available since version 3. Sending it on an older surface is a protocol error that terminates the connection. This could happen when setting a custom cursor on a compositor without wp_viewporter. The neighboring damage call already checks the version. --- winit-wayland/src/window/state.rs | 4 +++- winit/src/changelog/unreleased.md | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/winit-wayland/src/window/state.rs b/winit-wayland/src/window/state.rs index dcac4b69d..7fa98f2a8 100644 --- a/winit-wayland/src/window/state.rs +++ b/winit-wayland/src/window/state.rs @@ -814,10 +814,12 @@ impl WindowState { let size = PhysicalSize::new(cursor.w, cursor.h).to_logical(scale); viewport.set_destination(size.width, size.height); scale - } else { + } else if surface.version() >= 3 { let scale = surface.data::().unwrap().surface_data().scale_factor(); surface.set_buffer_scale(scale); scale as f64 + } else { + 1. }; surface.attach(Some(cursor.buffer.wl_buffer()), 0, 0); diff --git a/winit/src/changelog/unreleased.md b/winit/src/changelog/unreleased.md index 1c58b725c..a14ab1fa7 100644 --- a/winit/src/changelog/unreleased.md +++ b/winit/src/changelog/unreleased.md @@ -67,3 +67,4 @@ changelog entry. - On macOS, fix borderless game presentation options not sticking after switching spaces. - On macOS, fix IME being locked on (regardless of requests to disable) after being enabled once. - On macOS, fix a panic and incorrect cursor position in Ime::Preedit when the preedit string contains special characters (ie. emojis) caused by incorrect UTF-16 to UTF-8 offset conversion. +- On Wayland, fix a protocol error when setting a custom cursor on compositors with `wl_surface` version below 3.