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: steps:
- name: packages - name: packages
run: | 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 # actions/checkout@v3 clones the repository
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: setup - name: setup

View file

@ -30,8 +30,8 @@ libinput = dependency('libinput', version: '>=1.21.0')
libxml2 = dependency('libxml-2.0') libxml2 = dependency('libxml-2.0')
wlroots = dependency('wlroots', version: '>=0.16.0') wlroots = dependency('wlroots', version: '>=0.16.0')
wayland_server = dependency('wayland-server', version: '>=1.15') wayland_server = dependency('wayland-server', version: '>=1.15')
wayland_protos = dependency('wayland-protocols', version: '>=1.27') wayland_protos = dependency('wayland-protocols', version: '>=1.27')
xkbcommon = dependency('xkbcommon') xkbcommon = dependency('xkbcommon')
msgfmt = find_program('msgfmt', required: false) msgfmt = find_program('msgfmt', required: false)
if msgfmt.found() 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 * default. This is what makes the cursor image appear when you move it
* around the screen, not over any views. */ * around the screen, not over any views. */
wlr_xcursor_manager_set_cursor_image( 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); server->cursor->xcursor_manager, "left_ptr", server->cursor->cursor);
#endif
} }
if (surface) { 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 * display, which Wayland clients can see to find out information about the
* output (such as DPI, scale factor, manufacturer, etc). * 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); 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_buffer *scene_buffer = wlr_scene_buffer_from_node(node);
struct wlr_scene_surface *scene_surface = 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); wlr_scene_surface_from_buffer(scene_buffer);
#endif
if (!scene_surface) { if (!scene_surface) {
return NULL; return NULL;
} }
@ -30,11 +34,18 @@ struct wb_view *get_view_at(
void focus_view(struct wb_view *view, struct wlr_surface *surface) { void focus_view(struct wb_view *view, struct wlr_surface *surface) {
/* Note: this function only deals with keyboard focus. */ /* Note: this function only deals with keyboard focus. */
if (view == NULL || surface == NULL || !wlr_surface_is_xdg_surface(surface)) { if (view == NULL) {
return; 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); struct wlr_xdg_surface *xdg_surface = wlr_xdg_surface_from_wlr_surface(surface);
#endif
if (xdg_surface) if (xdg_surface)
wlr_log(WLR_INFO, "%s: %s", _("Keyboard focus is now on surface"), wlr_log(WLR_INFO, "%s: %s", _("Keyboard focus is now on surface"),
xdg_surface->toplevel->app_id); 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. */ /* Don't re-focus an already focused surface. */
return; return;
} }
if (prev_surface && wlr_surface_is_xdg_surface(prev_surface)) { if (prev_surface) {
/* /*
* Deactivate the previously focused surface. This lets the client know * Deactivate the previously focused surface. This lets the client know
* it no longer has focus and the client will repaint accordingly, e.g. * it no longer has focus and the client will repaint accordingly, e.g.
* stop displaying a caret. * stop displaying a caret.
*/ */
#if WLR_CHECK_VERSION(0, 17, 0)
struct wlr_xdg_surface *previous = struct wlr_xdg_surface *previous =
wlr_xdg_surface_from_wlr_surface(prev_surface); wlr_xdg_surface_try_from_wlr_surface(prev_surface);
wlr_xdg_toplevel_set_activated(previous->toplevel, false); #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 */ /* Move the view to the front */
if (!server->seat->focused_layer) { 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.x + popup->current.geometry.x,
view->geometry.y + popup->current.geometry.y); view->geometry.y + popup->current.geometry.y);
if (!wlr_output) return; if (!wlr_output) {
return;
}
struct wb_output *output = wlr_output->data; struct wb_output *output = wlr_output->data;
int top_margin = (view->server->config) ? 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 * we always set the user data field of xdg_surfaces to the corresponding
* scene node. */ * scene node. */
if (xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP) { 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)) { if (wlr_surface_is_xdg_surface(xdg_surface->popup->parent)) {
struct wlr_xdg_surface *parent = wlr_xdg_surface_from_wlr_surface( struct wlr_xdg_surface *parent = wlr_xdg_surface_from_wlr_surface(
xdg_surface->popup->parent); xdg_surface->popup->parent);
#endif
struct wlr_scene_tree *parent_tree = parent->data; struct wlr_scene_tree *parent_tree = parent->data;
xdg_surface->data = wlr_scene_xdg_surface_create( xdg_surface->data = wlr_scene_xdg_surface_create(
parent_tree, xdg_surface); parent_tree, xdg_surface);