From e21c155bcdc3f6bc8a3acc7c1dc362bcda3f734c Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 10 Apr 2025 18:08:15 +0200 Subject: [PATCH 1/3] seat: destroy keyboard groups on shutdown These are not destroyed automatically because they are entirely managed by the compositor. --- seat.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/seat.c b/seat.c index cdf8798..9acbdd3 100644 --- a/seat.c +++ b/seat.c @@ -380,6 +380,16 @@ cleanup: free(cg_group); } +static void +keyboard_group_destroy(struct cg_keyboard_group *keyboard_group) +{ + wl_list_remove(&keyboard_group->key.link); + wl_list_remove(&keyboard_group->modifiers.link); + wlr_keyboard_group_destroy(keyboard_group->wlr_group); + wl_list_remove(&keyboard_group->link); + free(keyboard_group); +} + static void handle_new_keyboard(struct cg_seat *seat, struct wlr_keyboard *keyboard, bool virtual) { @@ -893,6 +903,11 @@ seat_destroy(struct cg_seat *seat) wl_list_remove(&seat->request_start_drag.link); wl_list_remove(&seat->start_drag.link); + struct cg_keyboard_group *keyboard_group, *keyboard_group_tmp; + wl_list_for_each_safe (keyboard_group, keyboard_group_tmp, &seat->keyboard_groups, link) { + keyboard_group_destroy(keyboard_group); + } + // Destroying the wlr seat will trigger the destroy handler on our seat, // which will in turn free it. wlr_seat_destroy(seat->seat); From 6efb3b50421d9adc8d1220ccae63af45d423f5cf Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 10 Apr 2025 18:09:01 +0200 Subject: [PATCH 2/3] cage: remove global server listeners on shutdown --- cage.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cage.c b/cage.c index 8f14746..40a675d 100644 --- a/cage.c +++ b/cage.c @@ -596,11 +596,25 @@ main(int argc, char *argv[]) wl_display_run(server.wl_display); #if CAGE_HAS_XWAYLAND + if (xwayland) { + wl_list_remove(&server.new_xwayland_surface.link); + } wlr_xwayland_destroy(xwayland); wlr_xcursor_manager_destroy(xcursor_manager); #endif wl_display_destroy_clients(server.wl_display); + wl_list_remove(&server.new_virtual_pointer.link); + wl_list_remove(&server.new_virtual_keyboard.link); + wl_list_remove(&server.output_manager_apply.link); + wl_list_remove(&server.output_manager_test.link); + wl_list_remove(&server.xdg_toplevel_decoration.link); + wl_list_remove(&server.new_xdg_toplevel.link); + wl_list_remove(&server.new_xdg_popup.link); + wl_list_remove(&server.new_idle_inhibitor_v1.link); + wl_list_remove(&server.new_output.link); + wl_list_remove(&server.output_layout_change.link); + end: if (pid != 0) app_ret = cleanup_primary_client(pid); From 6f20285555da30e7b6df5d686a5061c2397a092d Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 10 Apr 2025 17:50:15 +0200 Subject: [PATCH 3/3] Upgrade wlroots to v0.19 --- .github/workflows/main.yml | 9 ++++++--- cage.c | 2 +- meson.build | 2 +- seat.c | 2 +- xdg_shell.c | 7 +++---- xwayland.c | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e82dbf1..e0f8093 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,6 +5,9 @@ on: pull_request: branches: [ master ] +env: + WLROOTS_VERSION: 0.19 + jobs: compile: runs-on: ubuntu-latest @@ -32,7 +35,7 @@ jobs: pacman -Syu --noconfirm xcb-util-wm seatd git clang meson libinput libdrm mesa libxkbcommon wayland wayland-protocols xorg-server-xwayland scdoc - name: Fetch wlroots as a subproject - run: git clone https://gitlab.freedesktop.org/wlroots/wlroots.git subprojects/wlroots -b 0.18 + run: git clone https://gitlab.freedesktop.org/wlroots/wlroots.git subprojects/wlroots -b $WLROOTS_VERSION - name: Compile Cage (XWayland=${{ matrix.xwayland }}) run: | @@ -52,7 +55,7 @@ jobs: pacman-key --init pacman -Syu --noconfirm xcb-util-wm seatd git clang meson libinput libdrm mesa libxkbcommon wayland wayland-protocols xorg-server-xwayland scdoc hwdata - name: Fetch wlroots as a subproject - run: git clone https://gitlab.freedesktop.org/wlroots/wlroots.git subprojects/wlroots -b 0.18 + run: git clone https://gitlab.freedesktop.org/wlroots/wlroots.git subprojects/wlroots -b $WLROOTS_VERSION - name: Check for formatting changes run: | meson build-clang-format -Dwlroots:xwayland=enabled @@ -71,7 +74,7 @@ jobs: pacman-key --init pacman -Syu --noconfirm xcb-util-wm seatd git clang meson libinput libdrm mesa libxkbcommon wayland wayland-protocols xorg-server-xwayland scdoc hwdata - name: Fetch wlroots as a subproject - run: git clone https://gitlab.freedesktop.org/wlroots/wlroots.git subprojects/wlroots -b 0.18 + run: git clone https://gitlab.freedesktop.org/wlroots/wlroots.git subprojects/wlroots -b $WLROOTS_VERSION - name: Run scan-build run: | meson build-scan-build -Dwlroots:xwayland=enabled diff --git a/cage.c b/cage.c index 40a675d..77ebc88 100644 --- a/cage.c +++ b/cage.c @@ -454,7 +454,7 @@ main(int argc, char *argv[]) goto end; } - struct wlr_presentation *presentation = wlr_presentation_create(server.wl_display, server.backend); + struct wlr_presentation *presentation = wlr_presentation_create(server.wl_display, server.backend, 2); if (!presentation) { wlr_log(WLR_ERROR, "Unable to create the presentation interface"); ret = 1; diff --git a/meson.build b/meson.build index 7b58cd8..07ca800 100644 --- a/meson.build +++ b/meson.build @@ -35,7 +35,7 @@ if is_freebsd ) endif -wlroots = dependency('wlroots-0.18', fallback: ['wlroots', 'wlroots']) +wlroots = dependency('wlroots-0.19', fallback: ['wlroots', 'wlroots']) wayland_protos = dependency('wayland-protocols', version: '>=1.14') wayland_server = dependency('wayland-server') xkbcommon = dependency('xkbcommon') diff --git a/seat.c b/seat.c index 9acbdd3..5f659a4 100644 --- a/seat.c +++ b/seat.c @@ -937,7 +937,7 @@ seat_set_focus(struct cg_seat *seat, struct cg_view *view) #if CAGE_HAS_XWAYLAND if (view->type == CAGE_XWAYLAND_VIEW) { struct cg_xwayland_view *xwayland_view = xwayland_view_from_view(view); - if (!wlr_xwayland_or_surface_wants_focus(xwayland_view->xwayland_surface)) { + if (!wlr_xwayland_surface_override_redirect_wants_focus(xwayland_view->xwayland_surface)) { return; } } diff --git a/xdg_shell.c b/xdg_shell.c index cae6c90..10224ae 100644 --- a/xdg_shell.c +++ b/xdg_shell.c @@ -128,11 +128,10 @@ static void get_geometry(struct cg_view *view, int *width_out, int *height_out) { struct cg_xdg_shell_view *xdg_shell_view = xdg_shell_view_from_view(view); - struct wlr_box geom; + struct wlr_xdg_surface *xdg_surface = xdg_shell_view->xdg_toplevel->base; - wlr_xdg_surface_get_geometry(xdg_shell_view->xdg_toplevel->base, &geom); - *width_out = geom.width; - *height_out = geom.height; + *width_out = xdg_surface->geometry.width; + *height_out = xdg_surface->geometry.height; } static bool diff --git a/xwayland.c b/xwayland.c index de81408..3df7a08 100644 --- a/xwayland.c +++ b/xwayland.c @@ -92,7 +92,7 @@ maximize(struct cg_view *view, int output_width, int output_height) struct cg_xwayland_view *xwayland_view = xwayland_view_from_view(view); wlr_xwayland_surface_configure(xwayland_view->xwayland_surface, view->lx, view->ly, output_width, output_height); - wlr_xwayland_surface_set_maximized(xwayland_view->xwayland_surface, true); + wlr_xwayland_surface_set_maximized(xwayland_view->xwayland_surface, true, true); } static void