diff options
| author | siikamiika <siikamiika@users.noreply.github.com> | 2021-10-10 17:27:43 +0300 | 
|---|---|---|
| committer | Ronan Pigott <rpigott@berkeley.edu> | 2021-10-21 13:16:36 -0700 | 
| commit | 21d2fdf74c93a4d1df5dd2dc0d6bf24c611dd752 (patch) | |
| tree | c4da2870530786e99635b8fbc354b073097ab470 | |
| parent | 197d0ab82f64ea9a96786e55e375c930389aa85b (diff) | |
| download | sway-21d2fdf74c93a4d1df5dd2dc0d6bf24c611dd752.tar.xz | |
view: add new container as a sibling of tiled view
If the focused container is floating by itself, create a new container
in tiling mode as a sibling of the inactive focused container instead of
creating it as a sibling of everything that is in tiling mode in that
workspace. This is the i3 behavior.
| -rw-r--r-- | sway/tree/view.c | 34 | 
1 files changed, 23 insertions, 11 deletions
| diff --git a/sway/tree/view.c b/sway/tree/view.c index b2f70d70..bd53a5c8 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -729,10 +729,29 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,  	}  	struct sway_seat *seat = input_manager_current_seat(); -	struct sway_node *node = ws ? seat_get_focus_inactive(seat, &ws->node) -		: seat_get_focus_inactive(seat, &root->node); -	struct sway_container *target_sibling = node->type == N_CONTAINER ? -		node->sway_container : NULL; +	struct sway_node *node = +		seat_get_focus_inactive(seat, ws ? &ws->node : &root->node); +	struct sway_container *target_sibling = NULL; +	if (node && node->type == N_CONTAINER) { +		if (container_is_floating(node->sway_container)) { +			// If we're about to launch the view into the floating container, then +			// launch it as a tiled view instead. +			if (ws) { +				target_sibling = seat_get_focus_inactive_tiling(seat, ws); +				if (target_sibling) { +					struct sway_container *con = +						seat_get_focus_inactive_view(seat, &target_sibling->node); +					if (con)  { +						target_sibling = con; +					} +				} +			} else { +				ws = seat_get_last_known_workspace(seat); +			} +		} else { +			target_sibling = node->sway_container; +		} +	}  	view->foreign_toplevel =  		wlr_foreign_toplevel_handle_v1_create(server.foreign_toplevel_manager); @@ -749,13 +768,6 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,  	wl_signal_add(&view->foreign_toplevel->events.destroy,  			&view->foreign_destroy); -	// If we're about to launch the view into the floating container, then -	// launch it as a tiled view in the root of the workspace instead. -	if (target_sibling && container_is_floating(target_sibling)) { -		target_sibling = NULL; -		ws = seat_get_last_known_workspace(seat); -	} -  	struct sway_container *container = view->container;  	if (target_sibling) {  		container_add_sibling(target_sibling, container, 1); | 
