]> git.mdlowis.com Git - proto/labwc.git/commitdiff
xwayland: split out xwayland_view constructor
authorJohan Malm <jgm323@gmail.com>
Mon, 17 Apr 2023 16:02:11 +0000 (17:02 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Wed, 19 Apr 2023 13:30:54 +0000 (14:30 +0100)
...and make it public in preparation for supporting override-redirect
requests from unmanaged xwayland surfaces.

include/xwayland.h
src/xwayland.c

index 5ac327ad711f4af8617d95b8bd00bc04635cf593..a3493038f98b8a5ff14e665af1adfe108dbd8cb5 100644 (file)
@@ -43,6 +43,9 @@ struct xwayland_view {
 void xwayland_unmanaged_create(struct server *server,
        struct wlr_xwayland_surface *xsurface, bool mapped);
 
+struct xwayland_view *xwayland_view_create(struct server *server,
+       struct wlr_xwayland_surface *xsurface);
+
 struct wlr_xwayland_surface *xwayland_surface_from_view(struct view *view);
 
 bool xwayland_apply_size_hints(struct view *view, int *w, int *h);
index 7029da3cdac53235150ac925188c8afd5136b6f9..7a950310440916f4cd0987ee4a2b7e7a918b27e5 100644 (file)
@@ -595,23 +595,9 @@ static const struct view_impl xwayland_view_impl = {
        .move_to_back = xwayland_view_move_to_back,
 };
 
-static void
-handle_new_surface(struct wl_listener *listener, void *data)
+struct xwayland_view *
+xwayland_view_create(struct server *server, struct wlr_xwayland_surface *xsurface)
 {
-       struct server *server =
-               wl_container_of(listener, server, xwayland_new_surface);
-       struct wlr_xwayland_surface *xsurface = data;
-       wlr_xwayland_surface_ping(xsurface);
-
-       /*
-        * We do not create 'views' for xwayland override_redirect surfaces,
-        * but add them to server.unmanaged_surfaces so that we can render them
-        */
-       if (xsurface->override_redirect) {
-               xwayland_unmanaged_create(server, xsurface, /* mapped */ false);
-               return;
-       }
-
        struct xwayland_view *xwayland_view = znew(*xwayland_view);
        struct view *view = &xwayland_view->base;
 
@@ -620,20 +606,18 @@ handle_new_surface(struct wl_listener *listener, void *data)
        view->impl = &xwayland_view_impl;
 
        /*
-        * Set two-way view <-> xsurface association.  Usually the
-        * association remains until the xsurface is destroyed (which
-        * also destroys the view).  The only exception is caused by
-        * setting override-redirect on the xsurface, which removes it
-        * from the view (destroying the view) and makes it an
-        * "unmanaged" surface.
+        * Set two-way view <-> xsurface association.  Usually the association
+        * remains until the xsurface is destroyed (which also destroys the
+        * view).  The only exception is caused by setting override-redirect on
+        * the xsurface, which removes it from the view (destroying the view)
+        * and makes it an "unmanaged" surface.
         */
        xwayland_view->xwayland_surface = xsurface;
        xsurface->data = view;
 
        view->workspace = server->workspace_current;
        view->scene_tree = wlr_scene_tree_create(view->workspace->tree);
-       node_descriptor_create(&view->scene_tree->node,
-               LAB_NODE_DESC_VIEW, view);
+       node_descriptor_create(&view->scene_tree->node, LAB_NODE_DESC_VIEW, view);
 
        view->map.notify = handle_map;
        wl_signal_add(&xsurface->events.map, &view->map);
@@ -657,25 +641,41 @@ handle_new_surface(struct wl_listener *listener, void *data)
 
        /* Events specific to XWayland views */
        xwayland_view->request_activate.notify = handle_request_activate;
-       wl_signal_add(&xsurface->events.request_activate,
-               &xwayland_view->request_activate);
+       wl_signal_add(&xsurface->events.request_activate, &xwayland_view->request_activate);
 
        xwayland_view->request_configure.notify = handle_request_configure;
-       wl_signal_add(&xsurface->events.request_configure,
-               &xwayland_view->request_configure);
+       wl_signal_add(&xsurface->events.request_configure, &xwayland_view->request_configure);
 
        xwayland_view->set_app_id.notify = handle_set_class;
        wl_signal_add(&xsurface->events.set_class, &xwayland_view->set_app_id);
 
        xwayland_view->set_decorations.notify = handle_set_decorations;
-       wl_signal_add(&xsurface->events.set_decorations,
-               &xwayland_view->set_decorations);
+       wl_signal_add(&xsurface->events.set_decorations, &xwayland_view->set_decorations);
 
        xwayland_view->override_redirect.notify = handle_override_redirect;
-       wl_signal_add(&xsurface->events.set_override_redirect,
-               &xwayland_view->override_redirect);
+       wl_signal_add(&xsurface->events.set_override_redirect, &xwayland_view->override_redirect);
 
        wl_list_insert(&view->server->views, &view->link);
+       return xwayland_view;
+}
+
+static void
+handle_new_surface(struct wl_listener *listener, void *data)
+{
+       struct server *server =
+               wl_container_of(listener, server, xwayland_new_surface);
+       struct wlr_xwayland_surface *xsurface = data;
+       wlr_xwayland_surface_ping(xsurface);
+
+       /*
+        * We do not create 'views' for xwayland override_redirect surfaces,
+        * but add them to server.unmanaged_surfaces so that we can render them
+        */
+       if (xsurface->override_redirect) {
+               xwayland_unmanaged_create(server, xsurface, /* mapped */ false);
+               return;
+       }
+       xwayland_view_create(server, xsurface);
 }
 
 static void