mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-23 05:15:58 +01:00
rootston: fix multiseat focus
This commit is contained in:
parent
1472dbda74
commit
27a3a810ab
3 changed files with 26 additions and 25 deletions
|
@ -26,4 +26,6 @@ void input_destroy(struct roots_input *input);
|
||||||
struct roots_seat *input_seat_from_wlr_seat(struct roots_input *input,
|
struct roots_seat *input_seat_from_wlr_seat(struct roots_input *input,
|
||||||
struct wlr_seat *seat);
|
struct wlr_seat *seat);
|
||||||
|
|
||||||
|
bool input_view_has_focus(struct roots_input *input, struct roots_view *view);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -108,3 +108,17 @@ struct roots_seat *input_seat_from_wlr_seat(struct roots_input *input,
|
||||||
}
|
}
|
||||||
return seat;
|
return seat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool input_view_has_focus(struct roots_input *input, struct roots_view *view) {
|
||||||
|
if (!view) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
struct roots_seat *seat;
|
||||||
|
wl_list_for_each(seat, &input->seats, link) {
|
||||||
|
if (seat->focus == view) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -503,36 +503,21 @@ void roots_seat_focus_view(struct roots_seat *seat, struct roots_view *view) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// unfocus the old view if it is not focused by some other seat
|
if (view && view->type == ROOTS_XWAYLAND_VIEW &&
|
||||||
// TODO probably should be an input function
|
view->xwayland_surface->override_redirect) {
|
||||||
if (seat->focus) {
|
|
||||||
bool has_other_focus = false;
|
|
||||||
struct roots_seat *iter_seat;
|
|
||||||
wl_list_for_each(iter_seat, &seat->input->seats, link) {
|
|
||||||
if (iter_seat == seat) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (iter_seat->focus == seat->focus) {
|
|
||||||
has_other_focus = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!has_other_focus) {
|
|
||||||
view_activate(seat->focus, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!view) {
|
|
||||||
seat->focus = NULL;
|
|
||||||
seat->cursor->mode = ROOTS_CURSOR_PASSTHROUGH;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct roots_view *prev_focus = seat->focus;
|
||||||
seat->focus = view;
|
seat->focus = view;
|
||||||
|
|
||||||
if (view->type == ROOTS_XWAYLAND_VIEW &&
|
// unfocus the old view if it is not focused by some other seat
|
||||||
view->xwayland_surface->override_redirect) {
|
if (prev_focus && !input_view_has_focus(seat->input, prev_focus)) {
|
||||||
|
view_activate(prev_focus, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!seat->focus) {
|
||||||
|
seat->cursor->mode = ROOTS_CURSOR_PASSTHROUGH;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue