From 32126eb87bdb98ffe3f792039467bb93a64693ca Mon Sep 17 00:00:00 2001 From: Zuki Air Date: Tue, 5 Aug 2025 08:28:10 +0100 Subject: [PATCH] fix xwayland screenshare --- dwl.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/dwl.c b/dwl.c index d8fa192..e8c6179 100644 --- a/dwl.c +++ b/dwl.c @@ -136,6 +136,7 @@ typedef struct { struct wl_listener set_decoration_mode; struct wl_listener destroy_decoration; #ifdef XWAYLAND + struct wlr_scene_surface *image_capture_scene_surface; struct wl_listener activate; struct wl_listener associate; struct wl_listener dissociate; @@ -1773,7 +1774,13 @@ mapnotify(struct wl_listener *listener, void *data) c->image_capture_scene = wlr_scene_create(); c->ext_foreign_toplevel = wlr_ext_foreign_toplevel_handle_v1_create(foreign_toplevel_list,&foreign_toplevel_state); c->ext_foreign_toplevel->data = c; - c->image_capture_tree = wlr_scene_xdg_surface_create(&c->image_capture_scene->tree, c->surface.xdg); + if (c->type == XDGShell) { + c->image_capture_tree = wlr_scene_xdg_surface_create(&c->image_capture_scene->tree, c->surface.xdg); +#ifdef XWAYLAND + } else { /* xwayland */ + c->image_capture_scene_surface = wlr_scene_surface_create(&c->image_capture_scene->tree, c->surface.xwayland->surface); +#endif + } client_get_geometry(c, &c->geom); @@ -2878,6 +2885,12 @@ unmapnotify(struct wl_listener *listener, void *data) if (c->ext_foreign_toplevel) { wlr_ext_foreign_toplevel_handle_v1_destroy(c->ext_foreign_toplevel); } +#ifdef XWAYLAND + if (c->image_capture_scene_surface) { + wlr_scene_node_destroy(&c->image_capture_scene_surface->buffer->node); + c->image_capture_scene_surface = NULL; + } +#endif wlr_scene_node_destroy(&c->image_capture_scene->tree.node); wlr_scene_node_destroy(&c->scene->node);