neuswc

patched neuswc library (tracked)
git clone https://git.daat.foo/neuswc.git
Log | Files | Refs | README | LICENSE

commit 703957e6c9e49e2ef11485de05a3dba3972afb01
parent 2183a8aa6d40def23c9bbed75a8c28b524afabd4
Author: dalem <lain@dalem.foo>
Date:   Sun, 22 Feb 2026 20:23:31 +0100

Implement raising windows to the top of Z axis

This:

- adds a new internal function "raise_window_top" which makes it be reinsterted at the top of the list.
- automatically raises visible windows
- adds a always_top toggle to "compositor_view" struct, which signifies the window should be on the top of the Z axis
- makes panels always appear on top of windows

Diffstat:
Mlibswc/compositor.c | 25++++++++++++++++++++++++-
Mlibswc/compositor.h | 6++++++
Mlibswc/panel.c | 2++
3 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/libswc/compositor.c b/libswc/compositor.c @@ -1011,7 +1011,7 @@ window_view(struct compositor_view *view) return (view && view->window) ? view : NULL; } -static void +void raise_window(struct compositor_view *view) { struct compositor_view *other, *top_window; @@ -1027,9 +1027,18 @@ raise_window(struct compositor_view *view) insert_after = &compositor.views; wl_list_for_each(other, &compositor.views, link) { + if (other == view) { + continue; + } + if (!other->visible) { continue; } + + if (other->always_top) { + insert_after = &other->link; + continue; + } if (other->window) { top_window = other; @@ -1055,6 +1064,15 @@ raise_window(struct compositor_view *view) schedule_updates(screens); } +void +raise_window_top(struct compositor_view *view) +{ + wl_list_remove(&view->link); + wl_list_insert(&compositor.views, &view->link); + damage_view(view); + schedule_updates(view->base.screens); +} + EXPORT struct swc_window * swc_window_at(int32_t x, int32_t y) { @@ -1182,6 +1200,7 @@ compositor_create_view(struct surface *surface) view->buffer_offset_x = 0; view->buffer_offset_y = 0; view->visible = false; + view->always_top = false; view->extents.x1 = 0; view->extents.y1 = 0; view->extents.x2 = 0; @@ -1275,6 +1294,10 @@ compositor_view_show(struct compositor_view *view) view->visible = true; view_update_screens(&view->base); + + if (view->window) { + raise_window(view); + } /* Assume worst-case no clipping until we draw the next frame (in case the * surface gets moved before that. */ diff --git a/libswc/compositor.h b/libswc/compositor.h @@ -64,6 +64,9 @@ struct compositor_view { /* Whether or not the view is visible (mapped). */ bool visible; + + /* Whether or not to make it always be on top of other windows */ + bool always_top; /* The box that the surface covers (including it's border). */ pixman_box32_t extents; @@ -134,4 +137,7 @@ compositor_get_buffer(struct screen *screen); struct wld_buffer * compositor_render_to_shm(struct screen *screen); +void raise_window(struct compositor_view *view); +void raise_window_top(struct compositor_view *view); + #endif diff --git a/libswc/panel.c b/libswc/panel.c @@ -119,6 +119,7 @@ dock(struct wl_client *client, struct wl_resource *resource, uint32_t edge, update_position(panel); compositor_view_show(panel->view); + raise_window_top(panel->view); wl_list_insert(&screen->modifiers, &panel->modifier.link); if (focus) { @@ -268,6 +269,7 @@ panel_new(struct wl_client *client, uint32_t version, uint32_t id, &destroy_panel); panel->surface_destroy_listener.notify = &handle_surface_destroy; panel->view_handler.impl = &view_handler_impl; + panel->view->always_top = true; panel->modifier.modify = &modify; panel->screen = NULL; panel->offset = 0;