aboutsummaryrefslogtreecommitdiff
path: root/rootston
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2017-11-19 21:54:11 +0100
committeremersion <contact@emersion.fr>2017-11-19 21:54:11 +0100
commit0191f3f711b642aa496204e770eaa0dc1914f26d (patch)
treeef9d81a74d567729bddebd7dfcd2fea471328b2c /rootston
parent9687950de158d39904c8bec7e41d397baefd541a (diff)
Improve roots_seat_cycle_focus
Diffstat (limited to 'rootston')
-rw-r--r--rootston/seat.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/rootston/seat.c b/rootston/seat.c
index 70ecec7e..737bbd67 100644
--- a/rootston/seat.c
+++ b/rootston/seat.c
@@ -598,9 +598,25 @@ void roots_seat_cycle_focus(struct roots_seat *seat) {
if (wl_list_empty(&seat->views)) {
return;
}
- struct roots_seat_view *last_seat_view = wl_container_of(
- seat->views.prev, last_seat_view, link);
- roots_seat_set_focus(seat, last_seat_view->view);
+
+ struct roots_seat_view *first_seat_view = wl_container_of(
+ seat->views.next, first_seat_view, link);
+ if (!seat->has_focus) {
+ roots_seat_set_focus(seat, first_seat_view->view);
+ return;
+ }
+ if (wl_list_length(&seat->views) < 2) {
+ return;
+ }
+
+ // Focus the next view
+ struct roots_seat_view *next_seat_view = wl_container_of(
+ first_seat_view->link.next, next_seat_view, link);
+ roots_seat_set_focus(seat, next_seat_view->view);
+
+ // Move the first view to the end of the list
+ wl_list_remove(&first_seat_view->link);
+ wl_list_insert(seat->views.prev, &first_seat_view->link);
}
void roots_seat_begin_move(struct roots_seat *seat, struct roots_view *view) {