From c1393a13664f14f9847ef7e1808ae0e71bfc77ba Mon Sep 17 00:00:00 2001 From: DanyLE Date: Wed, 2 Jul 2025 22:54:16 +0200 Subject: [PATCH] fix: update to wlroot 0.18 --- cursor.c | 2 +- diyac.c | 11 +++++----- diyac.h | 5 +++-- xdg.c | 65 +++++++++++++++++++++++++++----------------------------- xdg.h | 2 +- 5 files changed, 42 insertions(+), 43 deletions(-) diff --git a/cursor.c b/cursor.c index e05f844..82d1f58 100644 --- a/cursor.c +++ b/cursor.c @@ -273,7 +273,7 @@ static void server_cursor_axis(struct wl_listener *listener, void *data) /* Notify the client with pointer focus of the axis event. */ wlr_seat_pointer_notify_axis(seat->wlr_seat, event->time_msec, event->orientation, event->delta, - event->delta_discrete, event->source); + event->delta_discrete, event->source, event->delta); } static void server_cursor_frame(struct wl_listener *listener, void *data) diff --git a/diyac.c b/diyac.c index 64b46d6..46af10a 100644 --- a/diyac.c +++ b/diyac.c @@ -95,7 +95,7 @@ int main(int argc, char *argv[]) * output hardware. The autocreate option will choose the most suitable * backend based on the current environment, such as opening an X11 window * if an X11 server is running. */ - server.backend = wlr_backend_autocreate(server.wl_display, NULL); + server.backend = wlr_backend_autocreate(server.wl_event_loop, NULL); if (server.backend == NULL) { wlr_log(WLR_ERROR, "failed to create wlr_backend"); @@ -151,7 +151,7 @@ int main(int argc, char *argv[]) /* Creates an output layout, which a wlroots utility for working with an * arrangement of screens in a physical layout. */ - server.output_layout = wlr_output_layout_create(); + server.output_layout = wlr_output_layout_create(server.wl_display); /* Configure a listener to be notified when new outputs are available on the * backend. */ @@ -180,9 +180,9 @@ int main(int argc, char *argv[]) server.xdg_popup_tree = wlr_scene_tree_create(&server.scene->tree); server.xdg_shell = wlr_xdg_shell_create(server.wl_display, 6); - server.new_xdg_surface.notify = diyac_new_xdg_surface; - wl_signal_add(&server.xdg_shell->events.new_surface, - &server.new_xdg_surface); + server.new_xdg_toplevel.notify = diyac_new_xdg_toplevel; + wl_signal_add(&server.xdg_shell->events.new_toplevel, + &server.new_xdg_toplevel); server.layer_shell = wlr_layer_shell_v1_create(server.wl_display, 4); server.new_layer_surface.notify = diyac_new_layer_surface; @@ -263,6 +263,7 @@ int main(int argc, char *argv[]) { wl_event_source_remove(server.proc_mon); } + // TODO remove all event listeners wl_display_destroy_clients(server.wl_display); // wlr_scene_node_destroy(&server.scene->tree.node); wlr_xcursor_manager_destroy(server.seat.cursor_mgr); diff --git a/diyac.h b/diyac.h index cf4d594..011b9fe 100644 --- a/diyac.h +++ b/diyac.h @@ -131,7 +131,9 @@ struct diyac_server struct wlr_xdg_shell *xdg_shell; struct wlr_layer_shell_v1 *layer_shell; - struct wl_listener new_xdg_surface; + + struct wl_listener new_xdg_toplevel; + struct wl_listener new_layer_surface; struct wl_list views; struct diyac_view * active_view; @@ -244,7 +246,6 @@ struct diyac_view struct wl_listener request_minimize; struct wl_listener request_maximize; struct wl_listener request_fullscreen; - struct wl_listener set_app_id; struct wl_listener new_popup; struct wl_listener set_title; diff --git a/xdg.c b/xdg.c index 0736591..b68afe1 100644 --- a/xdg.c +++ b/xdg.c @@ -55,20 +55,32 @@ static void begin_interactive(struct diyac_view *toplevel, } static void xdg_toplevel_commit(struct wl_listener *listener, void *data) { - struct diyac_view *view = wl_container_of(listener, view, commit); - uint32_t serial = view->configuration_serial; - if (serial > 0 && serial == view->xdg_surface->current.configure_serial) + struct diyac_view *toplevel = wl_container_of(listener, toplevel, commit); + uint32_t serial = toplevel->configuration_serial; + + struct wlr_xdg_surface *xdg_surface = toplevel->xdg_surface; + if (xdg_surface->initial_commit) { - wl_event_source_remove(view->configuration_timeout); - view->configuration_serial = 0; - view->configuration_timeout = NULL; + uint32_t serial = + wlr_xdg_surface_schedule_configure(xdg_surface); + uint32_t wm_caps = WLR_XDG_TOPLEVEL_WM_CAPABILITIES_MAXIMIZE | WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN | WLR_XDG_TOPLEVEL_WM_CAPABILITIES_MINIMIZE; + wlr_xdg_toplevel_set_wm_capabilities(toplevel->xdg_toplevel, wm_caps); + return; + } + + if (serial > 0 && serial == toplevel->xdg_surface->current.configure_serial) + { + wlr_log(WLR_INFO, "xdg_toplevel_commit: wl_event_source_remove"); + wl_event_source_remove(toplevel->configuration_timeout); + toplevel->configuration_serial = 0; + toplevel->configuration_timeout = NULL; // TODO move view } - diyac_view_sync_geo(view); + diyac_view_sync_geo(toplevel); } static void xdg_toplevel_map(struct wl_listener *listener, void *data) { - + wlr_log(WLR_INFO, "xdg_toplevel_map: %p", listener); /* Called when the surface is mapped, or ready to display on-screen. */ struct diyac_view *toplevel = wl_container_of(listener, toplevel, map); if (toplevel->mapped) @@ -84,9 +96,6 @@ static void xdg_toplevel_map(struct wl_listener *listener, void *data) wlr_xdg_surface_get_geometry(toplevel->xdg_toplevel->base, &toplevel->pending_size); wlr_scene_node_set_enabled(&toplevel->scene_tree->node, true); toplevel->mapped = true; - wl_list_insert(&toplevel->server->views, &toplevel->link); - toplevel->commit.notify = xdg_toplevel_commit; - wl_signal_add(&toplevel->xdg_surface->surface->events.commit, &toplevel->commit); diyac_view_update_app_id(toplevel); diyac_view_update_title(toplevel); @@ -208,7 +217,7 @@ static void xdg_toplevel_destroy(struct wl_listener *listener, void *data) wl_event_source_remove(toplevel->configuration_timeout); toplevel->configuration_timeout = NULL; } - if(toplevel->mapped) + if (toplevel->mapped) { wl_list_remove(&toplevel->commit.link); } @@ -244,7 +253,7 @@ static void handle_xdg_popup_destroy(struct wl_listener *listener, void *data) static void popup_unconstrain(struct diyac_popup *popup) { struct diyac_view *view = popup->parent; - if(!view->output) + if (!view->output) { return; } @@ -370,31 +379,15 @@ static void xdg_new_popup_notify(struct wl_listener *listener, void *data) xdg_popup_create(view, wlr_popup); } -void diyac_new_xdg_surface(struct wl_listener *listener, void *data) +void diyac_new_xdg_toplevel(struct wl_listener *listener, void *data) { /* This event is raised when wlr_xdg_shell receives a new xdg surface from a * client, either a toplevel (application window) or popup. */ struct diyac_server *server = - wl_container_of(listener, server, new_xdg_surface); - struct wlr_xdg_surface *xdg_surface = data; + wl_container_of(listener, server, new_xdg_toplevel); + struct wlr_xdg_toplevel *xdg_toplevel = data; + struct wlr_xdg_surface *xdg_surface = xdg_toplevel->base; - /* We must add xdg popups to the scene graph so they get rendered. The - * wlroots scene graph provides a helper for this, but to use it we must - * provide the proper parent scene node of the xdg popup. To enable this, - * we always set the user data field of xdg_surfaces to the corresponding - * scene node. */ - if (xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP) - { - /*struct wlr_xdg_surface *parent = - wlr_xdg_surface_try_from_wlr_surface(xdg_surface->popup->parent); - assert(parent != NULL); - struct wlr_scene_tree *parent_tree = parent->data; - xdg_surface->data = wlr_scene_xdg_surface_create( - parent_tree, xdg_surface); - return;*/ - wlr_log(WLR_INFO, "diyac_new_xdg_surface: Creating new dialog using view popup"); - return; - } assert(xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL); wlr_log(WLR_INFO, "diyac_new_xdg_surface: Creating new application windows"); wlr_xdg_surface_ping(xdg_surface); @@ -432,7 +425,6 @@ void diyac_new_xdg_surface(struct wl_listener *listener, void *data) wl_signal_add(&xdg_surface->events.destroy, &toplevel->destroy); /* cotd */ - struct wlr_xdg_toplevel *xdg_toplevel = xdg_surface->toplevel; toplevel->request_move.notify = xdg_toplevel_request_move; wl_signal_add(&xdg_toplevel->events.request_move, &toplevel->request_move); toplevel->request_resize.notify = xdg_toplevel_request_resize; @@ -453,4 +445,9 @@ void diyac_new_xdg_surface(struct wl_listener *listener, void *data) toplevel->set_title.notify = xdg_set_title_notify; wl_signal_add(&xdg_toplevel->events.set_title, &toplevel->set_title); + + toplevel->commit.notify = xdg_toplevel_commit; + wl_signal_add(&toplevel->xdg_surface->surface->events.commit, &toplevel->commit); + + wl_list_insert(&toplevel->server->views, &toplevel->link); } \ No newline at end of file diff --git a/xdg.h b/xdg.h index d423931..279720d 100644 --- a/xdg.h +++ b/xdg.h @@ -2,5 +2,5 @@ #define DIYAC_XDG_H #include "diyac.h" -void diyac_new_xdg_surface(struct wl_listener *listener, void *data); +void diyac_new_xdg_toplevel(struct wl_listener *listener, void *data); #endif \ No newline at end of file