]> git.mdlowis.com Git - proto/labwc.git/commitdiff
foreign: set parent
authorJohan Malm <jgm323@gmail.com>
Thu, 3 Aug 2023 20:32:58 +0000 (21:32 +0100)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Fri, 11 Aug 2023 05:53:19 +0000 (07:53 +0200)
Tested with wlroots/examples/foreign-toplevel.c

Helped-by: @Consolatis
src/xdg.c
src/xwayland.c

index 93c5112f4891892094783ccdaa0b9d4811eecc7b..20b87b6ad3a4758aed9f898f7bfef206af761499 100644 (file)
--- a/src/xdg.c
+++ b/src/xdg.c
@@ -449,6 +449,22 @@ xdg_toplevel_view_get_string_prop(struct view *view, const char *prop)
        return "";
 }
 
+static void
+init_foreign_toplevel(struct view *view)
+{
+       foreign_toplevel_handle_create(view);
+       struct wlr_xdg_toplevel *toplevel = xdg_toplevel_from_view(view);
+       if (!toplevel->parent) {
+               return;
+       }
+       struct wlr_xdg_surface *surface = toplevel->parent->base;
+       struct view *parent = surface->data;
+       if (!parent->toplevel.handle) {
+               return;
+       }
+       wlr_foreign_toplevel_handle_v1_set_parent(view->toplevel.handle, parent->toplevel.handle);
+}
+
 static void
 xdg_toplevel_view_map(struct view *view)
 {
@@ -465,7 +481,9 @@ xdg_toplevel_view_map(struct view *view)
        if (!view->been_mapped) {
                struct wlr_xdg_toplevel_requested *requested =
                        &xdg_toplevel_from_view(view)->requested;
-               foreign_toplevel_handle_create(view);
+
+               init_foreign_toplevel(view);
+
                view_set_decorations(view, has_ssd(view));
 
                /*
index 456ae65956a85c1abb477b209e5ce27fb974a56a..acbbbc076fed2168733df79be8e3b577d23f35af 100644 (file)
@@ -407,6 +407,22 @@ top_left_edge_boundary_check(struct view *view)
        view->impl->configure(view, view->current);
 }
 
+static void
+init_foreign_toplevel(struct view *view)
+{
+       foreign_toplevel_handle_create(view);
+
+       struct wlr_xwayland_surface *surface = xwayland_surface_from_view(view);
+       if (!surface->parent) {
+               return;
+       }
+       struct view *parent = (struct view *)surface->parent->data;
+       if (!parent->toplevel.handle) {
+               return;
+       }
+       wlr_foreign_toplevel_handle_v1_set_parent(view->toplevel.handle, parent->toplevel.handle);
+}
+
 static void
 xwayland_view_map(struct view *view)
 {
@@ -453,7 +469,7 @@ xwayland_view_map(struct view *view)
        }
 
        if (!view->toplevel.handle) {
-               foreign_toplevel_handle_create(view);
+               init_foreign_toplevel(view);
        }
 
        if (!view->been_mapped) {