diff options
author | emersion <contact@emersion.fr> | 2018-04-02 14:35:43 -0400 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2018-04-02 14:35:43 -0400 |
commit | 2f64ce86c47efb2ee4c0e3a3c2b31307d21404d9 (patch) | |
tree | 5342d958ece5bf77338d1b1015763e65073fc4f1 /sway/desktop | |
parent | 61fabede14bb3a8fe9ee5a249352cd405fd1b9bf (diff) |
Xwayland unmanaged views aren't views anymore
Diffstat (limited to 'sway/desktop')
-rw-r--r-- | sway/desktop/output.c | 14 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 47 |
2 files changed, 45 insertions, 16 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 6c97ac37..352f4af3 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -257,15 +257,15 @@ static void render_output(struct sway_output *output, struct timespec *when, container_descendants(workspace, C_VIEW, render_view, &rdata); // render unmanaged views on top - struct sway_view *view; - wl_list_for_each(view, &root_container.sway_root->unmanaged_views, - unmanaged_view_link) { - if (view->type != SWAY_XWAYLAND_VIEW) { + struct wl_list *unmanaged = &root_container.sway_root->xwayland_unmanaged; + struct sway_xwayland_unmanaged *sway_surface; + wl_list_for_each(sway_surface, unmanaged, link) { + struct wlr_xwayland_surface *xsurface = + sway_surface->wlr_xwayland_surface; + if (xsurface->surface == NULL) { continue; } - struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; - const struct wlr_box view_box = { .x = xsurface->x, .y = xsurface->y, @@ -277,7 +277,7 @@ static void render_output(struct sway_output *output, struct timespec *when, continue; } - render_surface(view->surface, wlr_output, &output->last_frame, + render_surface(xsurface->surface, wlr_output, &output->last_frame, view_box.x - output_box->x, view_box.y - output_box->y, 0); } diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 39076fab..bfef68cf 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -14,6 +14,33 @@ #include "sway/input/input-manager.h" #include "log.h" +static void unmanaged_handle_destroy(struct wl_listener *listener, void *data) { + struct sway_xwayland_unmanaged *sway_surface = + wl_container_of(listener, sway_surface, destroy); + wl_list_remove(&sway_surface->destroy.link); + wl_list_remove(&sway_surface->link); + free(sway_surface); +} + +static void create_unmanaged(struct wlr_xwayland_surface *xsurface) { + struct sway_xwayland_unmanaged *sway_surface = + calloc(1, sizeof(struct sway_xwayland_unmanaged)); + if (!sway_assert(sway_surface, "Failed to allocate surface")) { + return; + } + + sway_surface->wlr_xwayland_surface = xsurface; + + wl_signal_add(&xsurface->events.destroy, &sway_surface->destroy); + sway_surface->destroy.notify = unmanaged_handle_destroy; + + wl_list_insert(&root_container.sway_root->xwayland_unmanaged, + &sway_surface->link); + + // TODO: damage tracking +} + + static bool assert_xwayland(struct sway_view *view) { return sway_assert(view->type == SWAY_XWAYLAND_VIEW, "Expected xwayland view!"); @@ -121,13 +148,8 @@ static void handle_map(struct wl_listener *listener, void *data) { struct sway_view *view = sway_surface->view; // put it back into the tree - if (wlr_xwayland_surface_is_unmanaged(xsurface) || - xsurface->override_redirect) { - view_map_unmanaged(view, xsurface->surface); - } else { - wlr_xwayland_surface_set_maximized(xsurface, true); - view_map(view, xsurface->surface); - } + wlr_xwayland_surface_set_maximized(xsurface, true); + view_map(view, xsurface->surface); } static void handle_request_configure(struct wl_listener *listener, void *data) { @@ -147,12 +169,19 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) { listener, server, xwayland_surface); struct wlr_xwayland_surface *xsurface = data; + if (wlr_xwayland_surface_is_unmanaged(xsurface) || + xsurface->override_redirect) { + wlr_log(L_DEBUG, "New xwayland unmanaged surface"); + create_unmanaged(xsurface); + return; + } + wlr_log(L_DEBUG, "New xwayland surface title='%s' class='%s'", - xsurface->title, xsurface->class); + xsurface->title, xsurface->class); struct sway_xwayland_surface *sway_surface = calloc(1, sizeof(struct sway_xwayland_surface)); - if (!sway_assert(sway_surface, "Failed to allocate surface!")) { + if (!sway_assert(sway_surface, "Failed to allocate surface")) { return; } |