diff options
| author | Isaac Freund <mail@isaacfreund.com> | 2021-10-20 13:22:24 +0200 |
|---|---|---|
| committer | Isaac Freund <mail@isaacfreund.com> | 2021-10-20 13:22:24 +0200 |
| commit | 5bf7d22972d50e3ab2b63da82ca7c2161139a0e3 (patch) | |
| tree | 0cf2bd8280cd00db55cd2741f41cdd8097468fcc | |
| parent | 4b94b9c0839eb75e5a8d3eeaf26e85e516a89015 (diff) | |
| download | river-5bf7d22972d50e3ab2b63da82ca7c2161139a0e3.tar.gz river-5bf7d22972d50e3ab2b63da82ca7c2161139a0e3.tar.xz | |
Cursor: only trigger focus-follow-cursor on motion
This greatly improves the UX of this feature, as views moving under a
stationary cursor (as happens during the zoom command for example) will
no longer trigger focus change.
| -rw-r--r-- | river/Cursor.zig | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/river/Cursor.zig b/river/Cursor.zig index 2692fd8..af36711 100644 --- a/river/Cursor.zig +++ b/river/Cursor.zig @@ -738,6 +738,24 @@ fn processMotion(self: *Self, device: *wlr.InputDevice, time: u32, delta_x: f64, switch (self.mode) { .passthrough => { self.wlr_cursor.move(device, dx, dy); + + if (self.surfaceAt()) |result| { + const focus_change = self.seat.wlr_seat.pointer_state.focused_surface != result.surface; + if (server.config.focus_follows_cursor == .normal and focus_change) { + switch (result.parent) { + .view => |view| { + if (self.seat.focused != .view or self.seat.focused.view != view) { + self.seat.focusOutput(view.output); + self.seat.focus(view); + server.root.startTransaction(); + } + }, + .layer_surface => {}, + .xwayland_unmanaged => assert(build_options.xwayland), + } + } + } + self.passthrough(time); }, .down => |view| { @@ -830,25 +848,8 @@ fn passthrough(self: *Self, time: u32) void { // events. Note that wlroots won't actually send an enter event if // the surface has already been entered. if (server.input_manager.inputAllowed(result.surface)) { - // The focus change must be checked before sending enter events - const focus_change = self.seat.wlr_seat.pointer_state.focused_surface != result.surface; - self.seat.wlr_seat.pointerNotifyEnter(result.surface, result.sx, result.sy); self.seat.wlr_seat.pointerNotifyMotion(time, result.sx, result.sy); - - if (server.config.focus_follows_cursor == .normal and focus_change) { - switch (result.parent) { - .view => |view| { - if (self.seat.focused != .view or self.seat.focused.view != view) { - self.seat.focusOutput(view.output); - self.seat.focus(view); - server.root.startTransaction(); - } - }, - .layer_surface => {}, - .xwayland_unmanaged => assert(build_options.xwayland), - } - } } } else { // There is either no surface under the cursor or input is disallowed |
