aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rootston/seat.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/rootston/seat.c b/rootston/seat.c
index 3a009a51..9a725dfa 100644
--- a/rootston/seat.c
+++ b/rootston/seat.c
@@ -430,12 +430,35 @@ void roots_seat_focus_view(struct roots_seat *seat, struct roots_view *view) {
if (seat->focus == view) {
return;
}
- seat->focus = view;
- seat->cursor->mode = ROOTS_CURSOR_PASSTHROUGH;
+
+ // 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;
return;
}
+ seat->focus = view;
+
if (view->type == ROOTS_XWAYLAND_VIEW &&
view->xwayland_surface->override_redirect) {
return;
@@ -444,12 +467,12 @@ void roots_seat_focus_view(struct roots_seat *seat, struct roots_view *view) {
size_t index = 0;
for (size_t i = 0; i < desktop->views->length; ++i) {
struct roots_view *_view = desktop->views->items[i];
- if (_view != view) {
- view_activate(_view, false);
- } else {
+ if (_view == view) {
index = i;
+ break;
}
}
+
view_activate(view, true);
// TODO: list_swap
wlr_list_del(desktop->views, index);