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.
This commit is contained in:
parent
197d0ab82f
commit
21d2fdf74c
|
@ -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_seat *seat = input_manager_current_seat();
|
||||||
struct sway_node *node = ws ? seat_get_focus_inactive(seat, &ws->node)
|
struct sway_node *node =
|
||||||
: seat_get_focus_inactive(seat, &root->node);
|
seat_get_focus_inactive(seat, ws ? &ws->node : &root->node);
|
||||||
struct sway_container *target_sibling = node->type == N_CONTAINER ?
|
struct sway_container *target_sibling = NULL;
|
||||||
node->sway_container : 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 =
|
view->foreign_toplevel =
|
||||||
wlr_foreign_toplevel_handle_v1_create(server.foreign_toplevel_manager);
|
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,
|
wl_signal_add(&view->foreign_toplevel->events.destroy,
|
||||||
&view->foreign_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;
|
struct sway_container *container = view->container;
|
||||||
if (target_sibling) {
|
if (target_sibling) {
|
||||||
container_add_sibling(target_sibling, container, 1);
|
container_add_sibling(target_sibling, container, 1);
|
||||||
|
|
Loading…
Reference in a new issue