Actually use focus_follows_pointer and pointer_warp_on_focus_change
This commit is contained in:
parent
c4d2c40f1a
commit
676ca40891
5 changed files with 37 additions and 26 deletions
29
src/Seat.zig
29
src/Seat.zig
|
|
@ -53,7 +53,9 @@ fn seatListener(river_seat_v1: *river.SeatV1, event: river.SeatV1.Event, seat: *
|
|||
.wl_seat => |ev| {
|
||||
log.debug("initializing new river_seat_v1 corresponding to wl_seat: {d}", .{ev.name});
|
||||
},
|
||||
.pointer_enter => |ev| seat.setWindowFocus(ev.window),
|
||||
.pointer_enter => |ev| if (seat.context.config.focus_follows_pointer) {
|
||||
seat.setWindowFocus(ev.window);
|
||||
},
|
||||
.window_interaction => |ev| seat.setWindowFocus(ev.window),
|
||||
else => |ev| {
|
||||
log.debug("unhandled event: {s}", .{@tagName(ev)});
|
||||
|
|
@ -95,18 +97,19 @@ pub fn manage(seat: *Seat) void {
|
|||
}
|
||||
}
|
||||
|
||||
if (seat.pending_manage.should_warp_pointer) {
|
||||
const window = seat.focused orelse {
|
||||
log.err("Trying to warp-on-focus-change without a focused window.", .{});
|
||||
return;
|
||||
};
|
||||
// TODO - CONFIG: Allow disabling this behaviour
|
||||
// Warp pointer to center of focused window;
|
||||
// because the x and y coords are set during render, we need to check if
|
||||
// there are new coordinates in window.pending_render.
|
||||
const pointer_x: i32 = (window.pending_render.x orelse window.x) + @divTrunc(window.width, 2);
|
||||
const pointer_y: i32 = (window.pending_render.y orelse window.y) + @divTrunc(window.height, 2);
|
||||
seat.river_seat_v1.pointerWarp(pointer_x, pointer_y);
|
||||
if (seat.pending_manage.should_warp_pointer) blk: {
|
||||
if (seat.context.config.pointer_warp_on_focus_change) {
|
||||
const window = seat.focused orelse {
|
||||
log.err("Trying to warp-on-focus-change without a focused window.", .{});
|
||||
break :blk;
|
||||
};
|
||||
// Warp pointer to center of focused window;
|
||||
// because the x and y coords are set during render, we need to check if
|
||||
// there are new coordinates in window.pending_render.
|
||||
const pointer_x: i32 = (window.pending_render.x orelse window.x) + @divTrunc(window.width, 2);
|
||||
const pointer_y: i32 = (window.pending_render.y orelse window.y) + @divTrunc(window.height, 2);
|
||||
seat.river_seat_v1.pointerWarp(pointer_x, pointer_y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue