From c746edd931a0d8cd9cfa094b0581977fc325636d Mon Sep 17 00:00:00 2001 From: TheRedDeveloper Date: Mon, 16 Feb 2026 21:52:27 +0100 Subject: [PATCH] Fix lost mouse release events on Linux/X11 --- src/lib.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 23b6ae8b..3c31670d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -199,6 +199,7 @@ struct Context { quit_requested: bool, cursor_grabbed: bool, + previous_cursor_grabbed: bool, input_events: Vec>, @@ -339,6 +340,7 @@ impl Context { quit_requested: false, cursor_grabbed: false, + previous_cursor_grabbed: false, input_events: Vec::new(), @@ -705,8 +707,13 @@ impl EventHandler for Stage { fn update(&mut self) { let _z = telemetry::ZoneGuard::new("Event::update"); - // Unless called every frame, cursor will not remain grabbed - miniquad::window::set_cursor_grab(get_context().cursor_grabbed); + // Keep the cursor grabbed by calling every frame. + // But only ungrab once to preserve implicit mouse grabs. + let context = get_context(); + if context.cursor_grabbed || context.cursor_grabbed != context.previous_cursor_grabbed { + miniquad::window::set_cursor_grab(context.cursor_grabbed); + } + context.previous_cursor_grabbed = context.cursor_grabbed; #[cfg(not(target_arch = "wasm32"))] {