focus-follow-cursor: Change output focus when needed

This commit is contained in:
Marten Ringwelski 2020-12-07 13:51:06 +01:00 committed by GitHub
parent 0fecdf60cb
commit 49bf0e679f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 19 deletions

View file

@ -136,10 +136,13 @@ that tag 1 through 9 are visible.
*focus-follows-cursor* *disabled*|*normal*|*strict*
When _disabled_ moving the cursor will not influence the focus. This is the default setting.
If set to _normal_ moving the cursor over a window will focus that window.
The focus still can be changed and moving the cursor within the (now unfocused) window will not change the focus to that window
but let the currently focused window in focus.
The focus still can be changed and moving the cursor within the (now unfocused) window will
not change the focus to that window but let the currently focused window in focus.
When set to _strict_ this is not the case. The focus will be updated on every cursor movement.
When the to be focused view is on another output than the currently focused output the view's
output is focused.
*map* [-release] _mode_ _modifiers_ _key_ _command_
_mode_ is either "normal" (the default mode), "locked" (the mode entered when
an input inhibitor such as a lock screen is active) or a mode created with *declare-mode*.

View file

@ -584,25 +584,15 @@ fn passthrough(self: *Self, time: u32) void {
c.wlr_seat_pointer_notify_enter(self.seat.wlr_seat, wlr_surface, sx, sy);
c.wlr_seat_pointer_notify_motion(self.seat.wlr_seat, time, sx, sy);
if (View.fromWlrSurface(wlr_surface)) |view| {
// Change focus according to config
switch (config.focus_follows_cursor) {
.disabled => {},
.normal => {
// Only refocus when the cursor entered a new surface
if (focus_change) {
self.seat.focus(view);
root.startTransaction();
}
},
.strict => {
self.seat.focus(view);
root.startTransaction();
},
const follow_mode = config.focus_follows_cursor;
if (follow_mode == .strict or (follow_mode == .normal and focus_change)) {
if (View.fromWlrSurface(wlr_surface)) |view| {
self.seat.focus(view);
self.seat.focusOutput(view.output);
root.startTransaction();
}
}
return;
}
} else {
// There is either no surface under the cursor or input is disallowed

View file

@ -242,6 +242,8 @@ pub fn setFocusRaw(self: *Self, new_focus: FocusTarget) void {
/// Focus the given output, notifying any listening clients of the change.
pub fn focusOutput(self: *Self, output: *Output) void {
if (self.focused_output == output) return;
const root = &self.input_manager.server.root;
var it = self.status_trackers.first;