diff options
Diffstat (limited to 'sway/desktop/xwayland.c')
-rw-r--r-- | sway/desktop/xwayland.c | 92 |
1 files changed, 33 insertions, 59 deletions
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 38ee4656..01c993b3 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -14,10 +14,10 @@ #include "sway/input/input-manager.h" #include "log.h" - static bool assert_xwayland(struct sway_view *view) { - return sway_assert(view->type == SWAY_XWAYLAND_VIEW && view->wlr_xwayland_surface, - "Expected xwayland view!"); - } +static bool assert_xwayland(struct sway_view *view) { + return sway_assert(view->type == SWAY_XWAYLAND_VIEW, + "Expected xwayland view!"); +} static const char *get_prop(struct sway_view *view, enum sway_view_prop prop) { if (!assert_xwayland(view)) { @@ -99,73 +99,59 @@ static void handle_commit(struct wl_listener *listener, void *data) { // TODO: Let floating views do whatever view->width = sway_surface->pending_width; view->height = sway_surface->pending_height; + view_damage_from(view); } static void handle_destroy(struct wl_listener *listener, void *data) { struct sway_xwayland_surface *sway_surface = wl_container_of(listener, sway_surface, destroy); - struct wlr_xwayland_surface *xsurface = data; + wl_list_remove(&sway_surface->commit.link); wl_list_remove(&sway_surface->destroy.link); wl_list_remove(&sway_surface->request_configure.link); - if (xsurface->override_redirect && xsurface->mapped) { - wl_list_remove(&sway_surface->view->unmanaged_view_link); - wl_list_init(&sway_surface->view->unmanaged_view_link); - } - - struct sway_container *parent = container_view_destroy(sway_surface->view->swayc); - if (parent) { - arrange_windows(parent, -1, -1); - } - - free(sway_surface->view); - free(sway_surface); + wl_list_remove(&sway_surface->view->unmanaged_view_link); + container_view_destroy(sway_surface->view->swayc); + sway_surface->view->swayc = NULL; + sway_surface->view->surface = NULL; } -static void handle_unmap_notify(struct wl_listener *listener, void *data) { +static void handle_unmap(struct wl_listener *listener, void *data) { struct sway_xwayland_surface *sway_surface = - wl_container_of(listener, sway_surface, unmap_notify); - struct wlr_xwayland_surface *xsurface = data; - if (xsurface->override_redirect && xsurface->mapped) { - wl_list_remove(&sway_surface->view->unmanaged_view_link); - wl_list_init(&sway_surface->view->unmanaged_view_link); - } - - // take it out of the tree - struct sway_container *parent = container_view_destroy(sway_surface->view->swayc); - if (parent) { - arrange_windows(parent, -1, -1); - } - + wl_container_of(listener, sway_surface, unmap); + view_damage_whole(sway_surface->view); + wl_list_remove(&sway_surface->view->unmanaged_view_link); + wl_list_init(&sway_surface->view->unmanaged_view_link); + container_view_destroy(sway_surface->view->swayc); sway_surface->view->swayc = NULL; sway_surface->view->surface = NULL; } -static void handle_map_notify(struct wl_listener *listener, void *data) { - // TODO put the view back into the tree +static void handle_map(struct wl_listener *listener, void *data) { struct sway_xwayland_surface *sway_surface = - wl_container_of(listener, sway_surface, map_notify); + wl_container_of(listener, sway_surface, map); struct wlr_xwayland_surface *xsurface = data; sway_surface->view->surface = xsurface->surface; // put it back into the tree - if (xsurface->override_redirect) { + if (wlr_xwayland_surface_is_unmanaged(xsurface) || + xsurface->override_redirect) { + wl_list_remove(&sway_surface->view->unmanaged_view_link); wl_list_insert(&root_container.sway_root->unmanaged_views, &sway_surface->view->unmanaged_view_link); } else { struct sway_view *view = sway_surface->view; container_view_destroy(view->swayc); - struct sway_container *parent = root_container.children->items[0]; - parent = parent->children->items[0]; // workspace - - struct sway_container *cont = container_view_create(parent, view); + struct sway_seat *seat = input_manager_current_seat(input_manager); + struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container); + struct sway_container *cont = container_view_create(focus, view); view->swayc = cont; - arrange_windows(cont->parent, -1, -1); sway_input_manager_set_focus(input_manager, cont); } + + view_damage_whole(sway_surface->view); } static void handle_configure_request(struct wl_listener *listener, void *data) { @@ -206,9 +192,10 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) { sway_view->iface.close = close_view; sway_view->wlr_xwayland_surface = xsurface; sway_view->sway_xwayland_surface = sway_surface; - sway_view->surface = xsurface->surface; sway_surface->view = sway_view; + wl_list_init(&sway_view->unmanaged_view_link); + // TODO: // - Look up pid and open on appropriate workspace // - Set new view to maximized so it behaves nicely @@ -224,24 +211,11 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) { &sway_surface->request_configure); sway_surface->request_configure.notify = handle_configure_request; - wl_signal_add(&xsurface->events.unmap_notify, &sway_surface->unmap_notify); - sway_surface->unmap_notify.notify = handle_unmap_notify; - - wl_signal_add(&xsurface->events.map_notify, &sway_surface->map_notify); - sway_surface->map_notify.notify = handle_map_notify; - - if (wlr_xwayland_surface_is_unmanaged(xsurface)) { - // these don't get a container in the tree - wl_list_insert(&root_container.sway_root->unmanaged_views, - &sway_view->unmanaged_view_link); - return; - } + wl_signal_add(&xsurface->events.unmap, &sway_surface->unmap); + sway_surface->unmap.notify = handle_unmap; - struct sway_seat *seat = input_manager_current_seat(input_manager); - struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container); - struct sway_container *cont = container_view_create(focus, sway_view); - sway_view->swayc = cont; + wl_signal_add(&xsurface->events.map, &sway_surface->map); + sway_surface->map.notify = handle_map; - arrange_windows(cont->parent, -1, -1); - sway_input_manager_set_focus(input_manager, cont); + handle_map(&sway_surface->map, xsurface); } |