layer shell

This commit is contained in:
2026-05-18 23:25:05 +07:00
parent 1ee715cbe3
commit 73295c26fc
19 changed files with 213 additions and 409 deletions
+21 -42
View File
@@ -33,8 +33,7 @@ static int setup(absn_server *server)
return 1;
}
server->backend = wlr_backend_autocreate(
wl_display_get_event_loop(server->display), NULL);
server->backend = wlr_backend_autocreate(wl_display_get_event_loop(server->display), NULL);
if (!server->backend) {
wlr_log(WLR_ERROR, "Failed to create wlr_backend");
return 1;
@@ -49,25 +48,20 @@ static int setup(absn_server *server)
wlr_renderer_init_wl_shm(server->renderer, server->display);
server->scene = wlr_scene_create();
if (wlr_renderer_get_texture_formats(server->renderer,
WLR_BUFFER_CAP_DMABUF)) {
if (wlr_renderer_get_texture_formats(server->renderer, WLR_BUFFER_CAP_DMABUF)) {
wlr_drm_create(server->display, server->renderer);
wlr_scene_set_linux_dmabuf_v1(
server->scene, wlr_linux_dmabuf_v1_create_with_renderer(
server->display, 5, server->renderer));
wlr_scene_set_linux_dmabuf_v1(server->scene, wlr_linux_dmabuf_v1_create_with_renderer(server->display, 5, server->renderer));
}
server->bg = wlr_scene_rect_create(&server->scene->tree, 0, 0, bgcolor);
server->allocator =
wlr_allocator_autocreate(server->backend, server->renderer);
server->allocator = wlr_allocator_autocreate(server->backend, server->renderer);
if (!server->allocator) {
wlr_log(WLR_ERROR, "Failed to create wlr_allocator");
return 1;
}
/* wlroots managers */
server->compositor =
wlr_compositor_create(server->display, 6, server->renderer);
server->compositor = wlr_compositor_create(server->display, 6, server->renderer);
wlr_subcompositor_create(server->display);
wlr_data_device_manager_create(server->display);
wlr_screencopy_manager_v1_create(server->display);
@@ -80,13 +74,9 @@ static int setup(absn_server *server)
wlr_export_dmabuf_manager_v1_create(server->display);
wlr_ext_foreign_toplevel_list_v1_create(server->display, 1);
wlr_server_decoration_manager_set_default_mode(
wlr_server_decoration_manager_create(server->display),
WLR_SERVER_DECORATION_MANAGER_MODE_SERVER);
server->xdg_deco_mgr =
wlr_xdg_decoration_manager_v1_create(server->display);
LISTEN(server->new_xdg_deco, new_xdg_decoration,
server->xdg_deco_mgr->events.new_toplevel_decoration);
wlr_server_decoration_manager_set_default_mode(wlr_server_decoration_manager_create(server->display), WLR_SERVER_DECORATION_MANAGER_MODE_SERVER);
server->xdg_deco_mgr = wlr_xdg_decoration_manager_v1_create(server->display);
LISTEN(server->new_xdg_deco, new_xdg_decoration, server->xdg_deco_mgr->events.new_toplevel_decoration);
/* toplevels lists */
wl_list_init(&server->toplevels);
@@ -97,22 +87,18 @@ static int setup(absn_server *server)
LISTEN(server->new_output, new_output, server->backend->events.new_output);
server->output_layout = wlr_output_layout_create(server->display);
LISTEN(server->layout_change, output_layout_change,
server->output_layout->events.change);
LISTEN(server->layout_change, output_layout_change, server->output_layout->events.change);
server->output_mgr = wlr_output_manager_v1_create(server->display);
wlr_xdg_output_manager_v1_create(server->display, server->output_layout);
server->scene_layout =
wlr_scene_attach_output_layout(server->scene, server->output_layout);
server->scene_layout = wlr_scene_attach_output_layout(server->scene, server->output_layout);
/* xdg_shell */
server->xdg_shell = wlr_xdg_shell_create(server->display, 6);
LISTEN(server->new_xdg_toplevel, new_xdg_toplevel,
server->xdg_shell->events.new_toplevel);
LISTEN(server->new_xdg_popup, new_xdg_popup,
server->xdg_shell->events.new_popup);
LISTEN(server->new_xdg_toplevel, new_xdg_toplevel, server->xdg_shell->events.new_toplevel);
LISTEN(server->new_xdg_popup, new_xdg_popup, server->xdg_shell->events.new_popup);
/* cursor */
server->cursor = wlr_cursor_create();
@@ -122,8 +108,7 @@ static int setup(absn_server *server)
server->cursor_mode = CURSOR_PASSTHROUGH;
LISTEN(server->cursor_motion, cursor_motion, server->cursor->events.motion);
LISTEN(server->cursor_motion_abs, cursor_motion_abs,
server->cursor->events.motion_absolute);
LISTEN(server->cursor_motion_abs, cursor_motion_abs, server->cursor->events.motion_absolute);
LISTEN(server->cursor_button, cursor_button, server->cursor->events.button);
LISTEN(server->cursor_axis, cursor_axis, server->cursor->events.axis);
LISTEN(server->cursor_frame, cursor_frame, server->cursor->events.frame);
@@ -132,18 +117,16 @@ static int setup(absn_server *server)
wl_list_init(&server->keyboards);
server->seat = wlr_seat_create(server->display, "seat0");
LISTEN(server->new_input, new_input, server->backend->events.new_input);
LISTEN(server->request_cursor, request_cursor,
server->seat->events.request_set_cursor);
LISTEN(server->pointer_focus_change, pointer_focus_change,
server->seat->pointer_state.events.focus_change);
LISTEN(server->request_set_selection, request_cursor,
server->seat->events.request_set_selection);
LISTEN(server->request_cursor, request_cursor, server->seat->events.request_set_cursor);
LISTEN(server->pointer_focus_change, pointer_focus_change, server->seat->pointer_state.events.focus_change);
LISTEN(server->request_set_selection, request_cursor, server->seat->events.request_set_selection);
/* layer shell */
server->layer_shell = wlr_layer_shell_v1_create(server->display, 5);
for (int i = 0; i < LAYERS_COUNT; ++i) {
server->layers[i] = wlr_scene_tree_create(&server->scene->tree);
}
LISTEN(server->new_layer_surface, new_layer_surface, server->layer_shell->events.new_surface);
/* workspaces */
int workspaces_count = sizeof(workspaces) / sizeof(workspaces[0]);
@@ -159,16 +142,12 @@ static int setup(absn_server *server)
unsetenv("DISPLAY");
#ifdef XWAYLAND
if ((server->xwayland =
wlr_xwayland_create(server->display, server->compositor, 1))) {
LISTEN(server->xw_ready, xwayland_ready,
server->xwayland->events.ready);
LISTEN(server->xw_new_surface, xwayland_new_surface,
server->xwayland->events.new_surface);
if ((server->xwayland = wlr_xwayland_create(server->display, server->compositor, 1))) {
LISTEN(server->xw_ready, xwayland_ready, server->xwayland->events.ready);
LISTEN(server->xw_new_surface, xwayland_new_surface, server->xwayland->events.new_surface);
setenv("DISPLAY", server->xwayland->display_name, 1);
wlr_log(WLR_INFO, "Running XWayland, DISPLAY=%s",
server->xwayland->display_name);
wlr_log(WLR_INFO, "Running XWayland, DISPLAY=%s", server->xwayland->display_name);
} else {
wlr_log(WLR_ERROR, "Failed to setup XWayland, continuing without it");
}