From: John Lindgren Date: Fri, 3 Feb 2023 19:53:26 +0000 (-0500) Subject: Chase wlroots: convert to try_from X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=b5220a723e93d004ae933532f21e4363cecae667;p=proto%2Flabwc.git Chase wlroots: convert to try_from Chases: 711a1a3ed42150fdbc716e80719d482006075f69 xdg-shell: convert to try_from Chases: f9bd416d4156942ce3951a6c5cf9f81a3cf4a3dd layer-shell-v1: convert to try_from Chases: fbf5982e3838ee28b5345e98832f6956c402b225 xwayland/xwm: introduce wlr_xwayland_surface_try_from_wlr_surface() --- diff --git a/src/decorations/kde-deco.c b/src/decorations/kde-deco.c index f4dd876d..b26f6621 100644 --- a/src/decorations/kde-deco.c +++ b/src/decorations/kde-deco.c @@ -63,7 +63,7 @@ handle_new_server_decoration(struct wl_listener *listener, void *data) struct kde_deco *kde_deco = znew(*kde_deco); kde_deco->wlr_kde_decoration = wlr_deco; - if (wlr_surface_is_xdg_surface(wlr_deco->surface)) { + if (wlr_deco->surface) { /* * Depending on the application event flow, the supplied * wlr_surface may already have been set up as a xdg_surface @@ -72,7 +72,7 @@ handle_new_server_decoration(struct wl_listener *listener, void *data) * kde_server_decoration_set_view(). */ struct wlr_xdg_surface *xdg_surface = - wlr_xdg_surface_from_wlr_surface(wlr_deco->surface); + wlr_xdg_surface_try_from_wlr_surface(wlr_deco->surface); if (xdg_surface && xdg_surface->data) { kde_deco->view = (struct view *)xdg_surface->data; handle_mode(&kde_deco->mode, wlr_deco); diff --git a/src/desktop.c b/src/desktop.c index d442d36c..66b1372b 100644 --- a/src/desktop.c +++ b/src/desktop.c @@ -97,9 +97,9 @@ desktop_focus_view_or_surface(struct seat *seat, struct view *view, if (view) { desktop_focus_view(view, raise); #if HAVE_XWAYLAND - } else if (wlr_surface_is_xwayland_surface(surface)) { + } else { struct wlr_xwayland_surface *xsurface = - wlr_xwayland_surface_from_wlr_surface(surface); + wlr_xwayland_surface_try_from_wlr_surface(surface); if (xsurface && wlr_xwayland_or_surface_wants_focus(xsurface)) { seat_focus_surface(seat, surface); } @@ -432,7 +432,7 @@ get_cursor_context(struct server *server) if (node->type == WLR_SCENE_NODE_BUFFER) { struct wlr_surface *surface = lab_wlr_surface_from_node(node); if (surface) { - if (wlr_surface_is_layer_surface(surface)) { + if (wlr_layer_surface_v1_try_from_wlr_surface(surface)) { ret.type = LAB_SSD_LAYER_SURFACE; } if (is_layer_descendant(node)) { diff --git a/src/input/cursor.c b/src/input/cursor.c index 58f55be1..4764f2ea 100644 --- a/src/input/cursor.c +++ b/src/input/cursor.c @@ -100,11 +100,11 @@ cursor_get_from_ssd(enum ssd_part_type view_area) static struct wlr_surface * get_toplevel(struct wlr_surface *surface) { - while (surface && wlr_surface_is_xdg_surface(surface)) { + while (surface) { struct wlr_xdg_surface *xdg_surface = - wlr_xdg_surface_from_wlr_surface(surface); + wlr_xdg_surface_try_from_wlr_surface(surface); if (!xdg_surface) { - return NULL; + break; } switch (xdg_surface->role) { @@ -117,7 +117,7 @@ get_toplevel(struct wlr_surface *surface) continue; } } - if (surface && wlr_surface_is_layer_surface(surface)) { + if (surface && wlr_layer_surface_v1_try_from_wlr_surface(surface)) { return surface; } return NULL; @@ -329,7 +329,7 @@ process_cursor_motion_out_of_surface(struct server *server, uint32_t time) if (view) { lx = view->current.x; ly = view->current.y; - } else if (node && wlr_surface_is_layer_surface(surface)) { + } else if (node && wlr_layer_surface_v1_try_from_wlr_surface(surface)) { wlr_scene_node_coords(node, &lx, &ly); #if HAVE_XWAYLAND } else if (node && node->parent == server->unmanaged_tree) { @@ -917,7 +917,7 @@ cursor_button_press(struct seat *seat, struct wlr_pointer_button_event *event) */ if (ctx.type == LAB_SSD_LAYER_SURFACE) { struct wlr_layer_surface_v1 *layer = - wlr_layer_surface_v1_from_wlr_surface(ctx.surface); + wlr_layer_surface_v1_try_from_wlr_surface(ctx.surface); if (layer && layer->current.keyboard_interactive) { seat_set_focus_layer(seat, layer); } diff --git a/src/view.c b/src/view.c index 20cbdc74..8c77dcda 100644 --- a/src/view.c +++ b/src/view.c @@ -34,20 +34,16 @@ view_from_wlr_surface(struct wlr_surface *surface) * - find a way to get rid of xdg/xwayland-specific stuff * - look up root/toplevel surface if passed a subsurface? */ - if (wlr_surface_is_xdg_surface(surface)) { - struct wlr_xdg_surface *xdg_surface = - wlr_xdg_surface_from_wlr_surface(surface); - if (xdg_surface) { - return xdg_surface->data; - } + struct wlr_xdg_surface *xdg_surface = + wlr_xdg_surface_try_from_wlr_surface(surface); + if (xdg_surface) { + return xdg_surface->data; } #if HAVE_XWAYLAND - if (wlr_surface_is_xwayland_surface(surface)) { - struct wlr_xwayland_surface *xsurface = - wlr_xwayland_surface_from_wlr_surface(surface); - if (xsurface) { - return xsurface->data; - } + struct wlr_xwayland_surface *xsurface = + wlr_xwayland_surface_try_from_wlr_surface(surface); + if (xsurface) { + return xsurface->data; } #endif return NULL; diff --git a/src/xdg-popup.c b/src/xdg-popup.c index 14cdf560..496c5c0c 100644 --- a/src/xdg-popup.c +++ b/src/xdg-popup.c @@ -63,8 +63,7 @@ void xdg_popup_create(struct view *view, struct wlr_xdg_popup *wlr_popup) { struct wlr_xdg_surface *parent = - wlr_surface_is_xdg_surface(wlr_popup->parent) ? - wlr_xdg_surface_from_wlr_surface(wlr_popup->parent) : NULL; + wlr_xdg_surface_try_from_wlr_surface(wlr_popup->parent); if (!parent) { wlr_log(WLR_ERROR, "parent is not a valid XDG surface"); return; diff --git a/src/xdg.c b/src/xdg.c index f5564976..a02c8aaa 100644 --- a/src/xdg.c +++ b/src/xdg.c @@ -579,12 +579,12 @@ xdg_activation_handle_request(struct wl_listener *listener, void *data) { const struct wlr_xdg_activation_v1_request_activate_event *event = data; - if (!wlr_surface_is_xdg_surface(event->surface)) { + struct wlr_xdg_surface *xdg_surface = + wlr_xdg_surface_try_from_wlr_surface(event->surface); + if (!xdg_surface) { return; } - struct wlr_xdg_surface *xdg_surface = - wlr_xdg_surface_from_wlr_surface(event->surface); - struct view *view = xdg_surface ? xdg_surface->data : NULL; + struct view *view = xdg_surface->data; if (!view) { wlr_log(WLR_INFO, "Not activating surface - no view attached to surface"); diff --git a/src/xwayland-unmanaged.c b/src/xwayland-unmanaged.c index 95e17086..21df12ba 100644 --- a/src/xwayland-unmanaged.c +++ b/src/xwayland-unmanaged.c @@ -168,7 +168,7 @@ handle_request_activate(struct wl_listener *listener, void *data) struct view *view = desktop_topmost_focusable_view(server); if (view && view->type == LAB_XWAYLAND_VIEW) { struct wlr_xwayland_surface *surf = - wlr_xwayland_surface_from_wlr_surface(view->surface); + wlr_xwayland_surface_try_from_wlr_surface(view->surface); if (surf && surf->pid != xsurface->pid) { return; } diff --git a/src/xwayland.c b/src/xwayland.c index 74d9394e..c0888236 100644 --- a/src/xwayland.c +++ b/src/xwayland.c @@ -701,8 +701,7 @@ xwayland_view_is_related(struct view *view, struct wlr_surface *surface) struct wlr_xwayland_surface *xsurface = xwayland_surface_from_view(view); struct wlr_xwayland_surface *xsurface2 = - wlr_surface_is_xwayland_surface(surface) ? - wlr_xwayland_surface_from_wlr_surface(surface) : NULL; + wlr_xwayland_surface_try_from_wlr_surface(surface); return (xsurface2 && xsurface2->pid == xsurface->pid); } diff --git a/subprojects/wlroots.wrap b/subprojects/wlroots.wrap index ad5d1d64..6df36126 100644 --- a/subprojects/wlroots.wrap +++ b/subprojects/wlroots.wrap @@ -1,6 +1,6 @@ [wrap-git] url = https://gitlab.freedesktop.org/wlroots/wlroots.git -revision = 097ea84cda70a71ad8ea5940b3b3d277167424e5 +revision = f9bd416d4156942ce3951a6c5cf9f81a3cf4a3dd [provide] dependency_names = wlroots