aboutsummaryrefslogtreecommitdiff
path: root/rootston
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2017-11-10 08:27:45 -0500
committerTony Crisci <tony@dubstepdish.com>2017-11-10 08:27:45 -0500
commit27a3a810ab372ca699bb9da1ce506816432b39f6 (patch)
tree6b98049b07725e8e777aa232983dbcaebe0f15ff /rootston
parent1472dbda74dea5387a4d0e531b641734131dc705 (diff)
rootston: fix multiseat focus
Diffstat (limited to 'rootston')
-rw-r--r--rootston/input.c14
-rw-r--r--rootston/seat.c35
2 files changed, 24 insertions, 25 deletions
diff --git a/rootston/input.c b/rootston/input.c
index 92148b65..e96565e0 100644
--- a/rootston/input.c
+++ b/rootston/input.c
@@ -108,3 +108,17 @@ struct roots_seat *input_seat_from_wlr_seat(struct roots_input *input,
}
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;
+}
diff --git a/rootston/seat.c b/rootston/seat.c
index 72e94aec..3dcd7f2f 100644
--- a/rootston/seat.c
+++ b/rootston/seat.c
@@ -503,36 +503,21 @@ void roots_seat_focus_view(struct roots_seat *seat, struct roots_view *view) {
return;
}
- // unfocus the old view if it is not focused by some other seat
- // TODO probably should be an input function
- 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;
+ if (view && view->type == ROOTS_XWAYLAND_VIEW &&
+ view->xwayland_surface->override_redirect) {
return;
}
+ struct roots_view *prev_focus = seat->focus;
seat->focus = view;
- if (view->type == ROOTS_XWAYLAND_VIEW &&
- view->xwayland_surface->override_redirect) {
+ // unfocus the old view if it is not focused by some other seat
+ 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;
}