Cursor: fix pointer drags with focus-follows-cursor

This commit is contained in:
Isaac Freund
2021-11-19 11:33:27 +01:00
parent 0cbe2b9fc3
commit 9212ac89fa
2 changed files with 50 additions and 23 deletions

View File

@ -750,24 +750,7 @@ 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.checkFocusFollowsCursor();
self.passthrough(time);
},
.down => |view| {
@ -826,6 +809,27 @@ fn processMotion(self: *Self, device: *wlr.InputDevice, time: u32, delta_x: f64,
}
}
pub fn checkFocusFollowsCursor(self: *Self) void {
// Don't do focus-follows-cursor if a drag is in progress as focus change can't occur
if (self.seat.pointer_drag) return;
if (server.config.focus_follows_cursor == .disabled) return;
if (self.surfaceAt()) |result| {
if (self.seat.wlr_seat.pointer_state.focused_surface != result.surface) {
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),
}
}
}
}
/// Handle potential change in location of views on the output, as well as
/// the target view of a cursor operation potentially being moved to a non-visible tag,
/// becoming fullscreen, etc.