react to wlroots changes

This commit is contained in:
Keith Bowes 2023-02-07 13:47:56 -05:00
parent 8fa589a132
commit 4eb4536b28
5 changed files with 48 additions and 8 deletions

View file

@ -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

View file

@ -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()

View file

@ -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) {
/*

View file

@ -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
}

View file

@ -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);