From 2d2495350faf0176de3758a068e67f2e787be759 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 29 Nov 2023 18:44:22 -0800 Subject: [PATCH] core: on mod change, rerun cursor pos callback --- src/Surface.zig | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Surface.zig b/src/Surface.zig index bcd45e895..43556d53c 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -1232,9 +1232,17 @@ pub fn keyCallback( self.hideMouse(); } - // We always update our mouse mods here too because otherwise we only - // get mods when a button is pressed. - self.mouse.mods = event.mods; + // If our mouse modifiers change, we run a cursor position event. + // This handles the scenario where URL highlighting should be + // toggled for example. + if (!self.mouse.mods.equal(event.mods)) mouse_mods: { + // We set this to null to force link reprocessing since + // mod changes can affect link highlighting. + self.mouse.link_point = null; + self.mouse.mods = event.mods; + const pos = self.rt_surface.getCursorPos() catch break :mouse_mods; + self.cursorPosCallback(pos) catch {}; + } // When we are in the middle of a mouse event and we press shift, // we change the mouse to a text shape so that selection appears @@ -2131,6 +2139,10 @@ pub fn cursorPosCallback( try self.mouseReport(button, .motion, self.mouse.mods, pos); + // If we were previously over a link, we need to queue a + // render to undo the link state. + if (over_link) try self.queueRender(); + // If we're doing mouse motion tracking, we do not support text // selection. return;