From 4eb4536b284db87aa3d6ea74e43323444f68b397 Mon Sep 17 00:00:00 2001 From: Keith Bowes Date: Tue, 7 Feb 2023 13:47:56 -0500 Subject: [PATCH] react to wlroots changes --- .github/workflows/build.yml | 2 +- meson.build | 4 ++-- waybox/cursor.c | 4 ++++ waybox/output.c | 7 +++++++ waybox/xdg_shell.c | 39 ++++++++++++++++++++++++++++++++----- 5 files changed, 48 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 670cee8..a8f3ad5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: steps: - name: packages run: | - apk add gcc git libevdev-dev libinput-dev libxkbcommon-dev libxml2-dev meson musl-dev wayland-dev wayland-protocols wlroots-dev xwayland + apk add gcc libevdev-dev libinput-dev libxkbcommon-dev libxml2-dev meson musl-dev wayland-dev wayland-protocols wlroots-dev xwayland # actions/checkout@v3 clones the repository - uses: actions/checkout@v3 - name: setup diff --git a/meson.build b/meson.build index 544bac8..824ede3 100644 --- a/meson.build +++ b/meson.build @@ -30,8 +30,8 @@ libinput = dependency('libinput', version: '>=1.21.0') libxml2 = dependency('libxml-2.0') wlroots = dependency('wlroots', version: '>=0.16.0') wayland_server = dependency('wayland-server', version: '>=1.15') -wayland_protos = dependency('wayland-protocols', version: '>=1.27') -xkbcommon = dependency('xkbcommon') +wayland_protos = dependency('wayland-protocols', version: '>=1.27') +xkbcommon = dependency('xkbcommon') msgfmt = find_program('msgfmt', required: false) if msgfmt.found() diff --git a/waybox/cursor.c b/waybox/cursor.c index 4a1fff6..f44c259 100644 --- a/waybox/cursor.c +++ b/waybox/cursor.c @@ -83,7 +83,11 @@ static void process_cursor_motion(struct wb_server *server, uint32_t time) { * default. This is what makes the cursor image appear when you move it * around the screen, not over any views. */ wlr_xcursor_manager_set_cursor_image( +#if WLR_CHECK_VERSION(0, 16, 2) + server->cursor->xcursor_manager, "default", server->cursor->cursor); +#else server->cursor->xcursor_manager, "left_ptr", server->cursor->cursor); +#endif } if (surface) { /* diff --git a/waybox/output.c b/waybox/output.c index e69edec..67ed3e7 100644 --- a/waybox/output.c +++ b/waybox/output.c @@ -116,5 +116,12 @@ void new_output_notify(struct wl_listener *listener, void *data) { * display, which Wayland clients can see to find out information about the * output (such as DPI, scale factor, manufacturer, etc). */ +#if WLR_CHECK_VERSION(0, 17, 0) + if (!wlr_output_layout_add_auto(server->output_layout, wlr_output)) { + wlr_log(WLR_ERROR, "%s", _("Could not add an output layout.")); + return; + } +#else wlr_output_layout_add_auto(server->output_layout, wlr_output); +#endif } diff --git a/waybox/xdg_shell.c b/waybox/xdg_shell.c index 1cf6402..73932bf 100644 --- a/waybox/xdg_shell.c +++ b/waybox/xdg_shell.c @@ -13,7 +13,11 @@ struct wb_view *get_view_at( } struct wlr_scene_buffer *scene_buffer = wlr_scene_buffer_from_node(node); struct wlr_scene_surface *scene_surface = +#if WLR_CHECK_VERSION(0, 17, 0) + wlr_scene_surface_try_from_buffer(scene_buffer); +#else wlr_scene_surface_from_buffer(scene_buffer); +#endif if (!scene_surface) { return NULL; } @@ -30,11 +34,18 @@ struct wb_view *get_view_at( void focus_view(struct wb_view *view, struct wlr_surface *surface) { /* Note: this function only deals with keyboard focus. */ - if (view == NULL || surface == NULL || !wlr_surface_is_xdg_surface(surface)) { + if (view == NULL) { return; } +#if WLR_CHECK_VERSION(0, 17, 0) + struct wlr_xdg_surface *xdg_surface = wlr_xdg_surface_try_from_wlr_surface(surface); +#else + if (surface == NULL || !wlr_surface_is_xdg_surface(surface)) + return; + struct wlr_xdg_surface *xdg_surface = wlr_xdg_surface_from_wlr_surface(surface); +#endif if (xdg_surface) wlr_log(WLR_INFO, "%s: %s", _("Keyboard focus is now on surface"), xdg_surface->toplevel->app_id); @@ -46,15 +57,24 @@ void focus_view(struct wb_view *view, struct wlr_surface *surface) { /* Don't re-focus an already focused surface. */ return; } - if (prev_surface && wlr_surface_is_xdg_surface(prev_surface)) { + if (prev_surface) { /* * Deactivate the previously focused surface. This lets the client know * it no longer has focus and the client will repaint accordingly, e.g. * stop displaying a caret. */ +#if WLR_CHECK_VERSION(0, 17, 0) struct wlr_xdg_surface *previous = - wlr_xdg_surface_from_wlr_surface(prev_surface); - wlr_xdg_toplevel_set_activated(previous->toplevel, false); + wlr_xdg_surface_try_from_wlr_surface(prev_surface); +#else + struct wlr_xdg_surface *previous; + if (wlr_surface_is_xdg_surface(prev_surface)) { + previous = wlr_xdg_surface_from_wlr_surface(prev_surface); + } +#endif + if (previous != NULL && previous->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) { + wlr_xdg_toplevel_set_activated(previous->toplevel, false); + } } /* Move the view to the front */ if (!server->seat->focused_layer) { @@ -293,7 +313,9 @@ static void handle_new_popup(struct wl_listener *listener, void *data) { view->geometry.x + popup->current.geometry.x, view->geometry.y + popup->current.geometry.y); - if (!wlr_output) return; + if (!wlr_output) { + return; + } struct wb_output *output = wlr_output->data; int top_margin = (view->server->config) ? @@ -320,9 +342,16 @@ static void handle_new_xdg_surface(struct wl_listener *listener, void *data) { * we always set the user data field of xdg_surfaces to the corresponding * scene node. */ if (xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP) { +#if WLR_CHECK_VERSION(0, 17, 0) + struct wlr_xdg_surface *parent = wlr_xdg_surface_try_from_wlr_surface( + xdg_surface->popup->parent); + if (parent != NULL) { +#else if (wlr_surface_is_xdg_surface(xdg_surface->popup->parent)) { struct wlr_xdg_surface *parent = wlr_xdg_surface_from_wlr_surface( xdg_surface->popup->parent); +#endif + struct wlr_scene_tree *parent_tree = parent->data; xdg_surface->data = wlr_scene_xdg_surface_create( parent_tree, xdg_surface);