From 28cb412b0d083355507875459e6c5f412e81ce43 Mon Sep 17 00:00:00 2001
From: emersion <contact@emersion.fr>
Date: Fri, 30 Mar 2018 10:09:56 -0400
Subject: [PATCH] Unify initial xwayland view mapping with map handler

---
 sway/desktop/xwayland.c | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 38ee4656..c3697b4c 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -150,7 +150,8 @@ static void handle_map_notify(struct wl_listener *listener, void *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_insert(&root_container.sway_root->unmanaged_views,
 			&sway_surface->view->unmanaged_view_link);
 	} else {
@@ -230,18 +231,5 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
 	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;
-	}
-
-	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;
-
-	arrange_windows(cont->parent, -1, -1);
-	sway_input_manager_set_focus(input_manager, cont);
+	handle_map_notify(&sway_surface->map_notify, xsurface);
 }