cycle: remember cycled window list in server->cycle.views

This allows changing the cycled order in the future, e.g. focused order vs
created order.

Functionally, this commit also changes the initially selected window;
before this commit, the previous/next of the topmost window was always
selected, but now the previous/next of the active window is selected first
if it is in the cycled list. This won't change behaviors for most users,
but this ensures that the user can go back to the focused window with
Alt-Tab + Alt-Shift-Tab even when it is not the topmost window.

This commit fixes the TODO in the previous commit by trying to preserve
the selected view when a view is destroyed during window cycling.
This commit is contained in:
tokyo4j 2025-11-30 17:47:40 +09:00 committed by Johan Malm
parent b6c1a9ea59
commit 9f5ff391cc
8 changed files with 92 additions and 110 deletions

View file

@ -134,6 +134,9 @@ struct view {
const struct view_impl *impl;
struct wl_list link;
/* This is cleared when the view is not in the cycle list */
struct wl_list cycle_link;
/*
* The primary output that the view is displayed on. Specifically:
*
@ -384,15 +387,6 @@ struct view *view_next(struct wl_list *head, struct view *view,
struct view *view_prev(struct wl_list *head, struct view *view,
enum lab_view_criteria criteria);
/*
* Same as `view_next()` except that they iterate one whole cycle rather than
* stopping at the list-head
*/
struct view *view_next_no_head_stop(struct wl_list *head, struct view *from,
enum lab_view_criteria criteria);
struct view *view_prev_no_head_stop(struct wl_list *head, struct view *from,
enum lab_view_criteria criteria);
/**
* view_array_append() - Append views that match criteria to array
* @server: server context