Improve roots_seat_cycle_focus

This commit is contained in:
emersion 2017-11-19 21:54:11 +01:00
parent 9687950de1
commit 0191f3f711
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48

View file

@ -598,9 +598,25 @@ void roots_seat_cycle_focus(struct roots_seat *seat) {
if (wl_list_empty(&seat->views)) { if (wl_list_empty(&seat->views)) {
return; return;
} }
struct roots_seat_view *last_seat_view = wl_container_of(
seat->views.prev, last_seat_view, link); struct roots_seat_view *first_seat_view = wl_container_of(
roots_seat_set_focus(seat, last_seat_view->view); 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) { void roots_seat_begin_move(struct roots_seat *seat, struct roots_view *view) {