From ac554c74ff72dc6b17d00f6b40e314bcbc7d7731 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 3 Jun 2024 14:55:21 -0700 Subject: [PATCH] core: do not toggle mouse hidden on keyCallback with mods If the mouse was hidden, we just keep it hidden. --- src/Surface.zig | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Surface.zig b/src/Surface.zig index 2839f908c..e40c0a06f 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -1319,9 +1319,12 @@ pub fn keyCallback( // This handles the scenario where URL highlighting should be // toggled for example. if (!self.mouse.mods.equal(event.mods)) mouse_mods: { - // Usually moving the cursor unhides the mouse so we need - // to hide it again if it was hidden. + // This is a hacky way to prevent cursorPosCallback from + // showing our hidden mouse: we just pretend the mouse isn't hidden. + // We used to re-call `self.hideMouse()` but this causes flickering + // in some cases in GTK. const rehide = self.mouse.hidden; + self.mouse.hidden = false; // Update our modifiers, this will update mouse mods too self.modsChanged(event.mods); @@ -1331,7 +1334,7 @@ pub fn keyCallback( self.mouse.link_point = null; const pos = self.rt_surface.getCursorPos() catch break :mouse_mods; self.cursorPosCallback(pos) catch {}; - if (rehide) self.hideMouse(); + if (rehide) self.mouse.hidden = true; } // Process the cursor state logic. This will update the cursor shape if