commit 703957e

dalem  ·  2026-02-22 19:23:31 +0000 UTC
parent 2183a8a
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
3 files changed,  +32, -1
+24, -1
 1@@ -1011,7 +1011,7 @@ window_view(struct compositor_view *view)
 2 	return (view && view->window) ? view : NULL;
 3 }
 4 
 5-static void
 6+void
 7 raise_window(struct compositor_view *view)
 8 {
 9 	struct compositor_view *other, *top_window;
10@@ -1027,9 +1027,18 @@ raise_window(struct compositor_view *view)
11 	insert_after = &compositor.views;
12 	wl_list_for_each(other, &compositor.views, link)
13 	{
14+		if (other == view) {
15+			continue;
16+		}
17+
18 		if (!other->visible) {
19 			continue;
20 		}
21+		
22+		if (other->always_top) {
23+			insert_after = &other->link;
24+			continue;
25+		}
26 
27 		if (other->window) {
28 			top_window = other;
29@@ -1055,6 +1064,15 @@ raise_window(struct compositor_view *view)
30 	schedule_updates(screens);
31 }
32 
33+void
34+raise_window_top(struct compositor_view *view)
35+{
36+	wl_list_remove(&view->link);
37+	wl_list_insert(&compositor.views, &view->link);
38+	damage_view(view);
39+	schedule_updates(view->base.screens);
40+}
41+
42 EXPORT struct swc_window *
43 swc_window_at(int32_t x, int32_t y)
44 {
45@@ -1182,6 +1200,7 @@ compositor_create_view(struct surface *surface)
46 	view->buffer_offset_x = 0;
47 	view->buffer_offset_y = 0;
48 	view->visible = false;
49+	view->always_top = false;
50 	view->extents.x1 = 0;
51 	view->extents.y1 = 0;
52 	view->extents.x2 = 0;
53@@ -1275,6 +1294,10 @@ compositor_view_show(struct compositor_view *view)
54 
55 	view->visible = true;
56 	view_update_screens(&view->base);
57+	
58+	if (view->window) {
59+		raise_window(view);
60+	}
61 
62 	/* Assume worst-case no clipping until we draw the next frame (in case the
63 	 * surface gets moved before that. */
+6, -0
 1@@ -64,6 +64,9 @@ struct compositor_view {
 2 
 3 	/* Whether or not the view is visible (mapped). */
 4 	bool visible;
 5+	
 6+	/* Whether or not to make it always be on top of other windows */
 7+	bool always_top;
 8 
 9 	/* The box that the surface covers (including it's border). */
10 	pixman_box32_t extents;
11@@ -134,4 +137,7 @@ compositor_get_buffer(struct screen *screen);
12 struct wld_buffer *
13 compositor_render_to_shm(struct screen *screen);
14 
15+void raise_window(struct compositor_view *view);
16+void raise_window_top(struct compositor_view *view);
17+
18 #endif
+2, -0
 1@@ -119,6 +119,7 @@ dock(struct wl_client *client, struct wl_resource *resource, uint32_t edge,
 2 
 3 	update_position(panel);
 4 	compositor_view_show(panel->view);
 5+	raise_window_top(panel->view);
 6 	wl_list_insert(&screen->modifiers, &panel->modifier.link);
 7 
 8 	if (focus) {
 9@@ -268,6 +269,7 @@ panel_new(struct wl_client *client, uint32_t version, uint32_t id,
10 	                               &destroy_panel);
11 	panel->surface_destroy_listener.notify = &handle_surface_destroy;
12 	panel->view_handler.impl = &view_handler_impl;
13+	panel->view->always_top = true;
14 	panel->modifier.modify = &modify;
15 	panel->screen = NULL;
16 	panel->offset = 0;