Skip to content

Commit

Permalink
Don't steal focus on mouse events that are within 1 px
Browse files Browse the repository at this point in the history
  • Loading branch information
mjrochford committed Dec 29, 2024
1 parent b3925b8 commit 8dd61b6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/apprt/gtk/Surface.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1426,12 +1426,15 @@ fn gtkMouseMotion(
.y = @floatCast(scaled.y),
};

const is_cursor_still = @abs(self.cursor_pos.x - pos.x) < 1 and
@abs(self.cursor_pos.y - pos.y) < 1;

// 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") {
if (!is_cursor_still and c.gtk_widget_has_focus(gl_widget) == 0 and self.app.config.@"focus-follows-mouse") {
self.grabFocus();
}

Expand Down

0 comments on commit 8dd61b6

Please sign in to comment.