diff --git a/src/apprt/gtk/Surface.zig b/src/apprt/gtk/Surface.zig index ee6c6869e..e356b6342 100644 --- a/src/apprt/gtk/Surface.zig +++ b/src/apprt/gtk/Surface.zig @@ -1394,11 +1394,21 @@ fn gtkMouseMotion( const self = userdataSelf(ud.?); const scaled = self.scaledCoordinates(x, y); - self.cursor_pos = .{ + const pos: apprt.CursorPos = .{ .x = @floatCast(@max(0, scaled.x)), .y = @floatCast(scaled.y), }; + // GTK can send spurious mouse movement events. Ignore them + // because this can cause actual issues: + // https://github.com/ghostty-org/ghostty/issues/2022 + if (pos.x == self.cursor_pos.x and pos.y == self.cursor_pos.y) { + return; + } + + // Our pos changed, update + self.cursor_pos = pos; + // If we don't have focus, and we want it, grab it. const gl_widget = @as(*c.GtkWidget, @ptrCast(self.gl_area)); if (c.gtk_widget_has_focus(gl_widget) == 0 and self.app.config.@"focus-follows-mouse") {