mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
apprt/gtk: ignore mouse movement if no actual movement occurs
Fixes #2022 See comment
This commit is contained in:
@ -1394,11 +1394,21 @@ fn gtkMouseMotion(
|
|||||||
const self = userdataSelf(ud.?);
|
const self = userdataSelf(ud.?);
|
||||||
const scaled = self.scaledCoordinates(x, y);
|
const scaled = self.scaledCoordinates(x, y);
|
||||||
|
|
||||||
self.cursor_pos = .{
|
const pos: apprt.CursorPos = .{
|
||||||
.x = @floatCast(@max(0, scaled.x)),
|
.x = @floatCast(@max(0, scaled.x)),
|
||||||
.y = @floatCast(scaled.y),
|
.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.
|
// If we don't have focus, and we want it, grab it.
|
||||||
const gl_widget = @as(*c.GtkWidget, @ptrCast(self.gl_area));
|
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 (c.gtk_widget_has_focus(gl_widget) == 0 and self.app.config.@"focus-follows-mouse") {
|
||||||
|
Reference in New Issue
Block a user