view: decouple always-on-top windows from the omnipresent state

Before this commit, always-on-{top,bottom} windows were always visible
on all workspaces (omnipresent) because the they were not in
per-workspace trees like normal windows.

This commit fixes this by introducing per-layer trees in
`struct workspace`.

I also added `enum view_layer` and `view->layer` for simplicity.
This commit is contained in:
tokyo4j 2026-02-03 19:18:53 +09:00
parent 55a256f2fa
commit b21daabf77
11 changed files with 75 additions and 90 deletions

View file

@ -62,10 +62,7 @@ enum lab_view_criteria {
/* No filter -> all focusable views */
LAB_VIEW_CRITERIA_NONE = 0,
/*
* Includes always-on-top views, e.g.
* what is visible on the current workspace
*/
/* Includes omnipresent (visible on all desktops) views */
LAB_VIEW_CRITERIA_CURRENT_WORKSPACE = 1 << 0,
/* Positive criteria */

View file

@ -231,10 +231,6 @@ struct server {
* them to this dedicated tree
*/
struct wlr_scene_tree *xdg_popup_tree;
/* Tree for all non-layer xdg/xwayland-shell surfaces with always-on-top/below */
struct wlr_scene_tree *view_tree_always_on_top;
struct wlr_scene_tree *view_tree_always_on_bottom;
#if HAVE_XWAYLAND
/* Tree for unmanaged xsurfaces without initialized view (usually popups) */
struct wlr_scene_tree *unmanaged_tree;

View file

@ -82,6 +82,12 @@ enum view_wants_focus {
VIEW_WANTS_FOCUS_UNLIKELY,
};
enum view_layer {
VIEW_LAYER_NORMAL = 0,
VIEW_LAYER_ALWAYS_ON_TOP,
VIEW_LAYER_ALWAYS_ON_BOTTOM,
};
struct view;
struct wlr_surface;
struct foreign_toplevel;
@ -183,6 +189,7 @@ struct view {
bool fullscreen;
bool tearing_hint;
enum lab_tristate force_tearing;
enum view_layer layer;
bool visible_on_all_workspaces;
enum lab_edge tiled;
enum lab_edge edges_visible;
@ -527,9 +534,6 @@ void view_toggle_maximize(struct view *view, enum view_axis axis);
bool view_wants_decorations(struct view *view);
void view_toggle_decorations(struct view *view);
bool view_is_always_on_top(struct view *view);
bool view_is_always_on_bottom(struct view *view);
bool view_is_omnipresent(struct view *view);
void view_toggle_always_on_top(struct view *view);
void view_toggle_always_on_bottom(struct view *view);
void view_toggle_visible_on_all_workspaces(struct view *view);

View file

@ -16,6 +16,7 @@ struct workspace {
char *name;
struct wlr_scene_tree *tree;
struct wlr_scene_tree *view_trees[3];
struct lab_cosmic_workspace *cosmic_workspace;
struct {