]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Chase wlroots: convert to try_from
authorJohn Lindgren <john@jlindgren.net>
Fri, 3 Feb 2023 19:53:26 +0000 (14:53 -0500)
committerJohan Malm <johanmalm@users.noreply.github.com>
Mon, 27 Nov 2023 21:01:53 +0000 (21:01 +0000)
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()

src/decorations/kde-deco.c
src/desktop.c
src/input/cursor.c
src/view.c
src/xdg-popup.c
src/xdg.c
src/xwayland-unmanaged.c
src/xwayland.c
subprojects/wlroots.wrap

index f4dd876d1e14e8a51e0941826cef85bbd9d46785..b26f66213a8f2dc8e0ba66d9225fb9ec647a59ba 100644 (file)
@@ -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);
index d442d36cf1aff47f1d617338febc009956715681..66b1372bbbfb92d1b0aafb776399960aa1ea13f6 100644 (file)
@@ -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)) {
index 58f55be1e87fb21b64184c918b59cfbce3c18147..4764f2ea62c514c60d4cb0cd447fc24b337e38ba 100644 (file)
@@ -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);
                }
index 20cbdc74dacf043eb13193d608d80311fd93d322..8c77dcdaefc9d1014b3e57766742bbef733976ad 100644 (file)
@@ -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;
index 14cdf560ea9444950006027991aa66ba55d4796d..496c5c0c170146126f9998c789376d9f9149342b 100644 (file)
@@ -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;
index f55649761a7c00a2124ef1b97d6a369702ce3bd8..a02c8aaa963094a59ca0c3fef6e7382d231962d7 100644 (file)
--- 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");
index 95e17086364fa8805e64bc2073adf6ab1889d906..21df12ba3ad9394ea40f8882ea150ff41e6637fc 100644 (file)
@@ -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;
                }
index 74d9394e02d24738dfcdec27aa7d26aeb3eda7ed..c0888236f873a5fee25d2695088b0c4c63ef7f62 100644 (file)
@@ -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);
 }
index ad5d1d64ab47d7c3afcd2fc8a1feee503aa8f0f9..6df361268deeee735879deca490bcbb3004c314c 100644 (file)
@@ -1,6 +1,6 @@
 [wrap-git]
 url = https://gitlab.freedesktop.org/wlroots/wlroots.git
-revision = 097ea84cda70a71ad8ea5940b3b3d277167424e5
+revision = f9bd416d4156942ce3951a6c5cf9f81a3cf4a3dd
 
 [provide]
 dependency_names = wlroots