mirror of
https://github.com/swaywm/sway.git
synced 2024-12-29 16:36:26 +01:00
Change workspace_layout to match i3 behavior
In i3, the workspace_layout command does not affect the workspace layout. Instead, new workspace level containers are wrapped in the desired layout and the workspace layout always defaults to the output orientation.
This commit is contained in:
parent
b4850876dc
commit
ece6a1d408
8 changed files with 51 additions and 35 deletions
|
@ -110,13 +110,13 @@ void workspace_unwrap_children(struct sway_workspace *ws,
|
||||||
|
|
||||||
void workspace_detach(struct sway_workspace *workspace);
|
void workspace_detach(struct sway_workspace *workspace);
|
||||||
|
|
||||||
void workspace_add_tiling(struct sway_workspace *workspace,
|
struct sway_container *workspace_add_tiling(struct sway_workspace *workspace,
|
||||||
struct sway_container *con);
|
struct sway_container *con);
|
||||||
|
|
||||||
void workspace_add_floating(struct sway_workspace *workspace,
|
void workspace_add_floating(struct sway_workspace *workspace,
|
||||||
struct sway_container *con);
|
struct sway_container *con);
|
||||||
|
|
||||||
void workspace_insert_tiling(struct sway_workspace *workspace,
|
struct sway_container *workspace_insert_tiling(struct sway_workspace *workspace,
|
||||||
struct sway_container *con, int index);
|
struct sway_container *con, int index);
|
||||||
|
|
||||||
void workspace_remove_gaps(struct sway_workspace *ws);
|
void workspace_remove_gaps(struct sway_workspace *ws);
|
||||||
|
|
|
@ -349,19 +349,20 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct sway_container *container = view->container;
|
||||||
if (e->fullscreen && e->output && e->output->data) {
|
if (e->fullscreen && e->output && e->output->data) {
|
||||||
struct sway_output *output = e->output->data;
|
struct sway_output *output = e->output->data;
|
||||||
struct sway_workspace *ws = output_get_active_workspace(output);
|
struct sway_workspace *ws = output_get_active_workspace(output);
|
||||||
if (ws && !container_is_scratchpad_hidden(view->container)) {
|
if (ws && !container_is_scratchpad_hidden(container)) {
|
||||||
if (container_is_floating(view->container)) {
|
if (container_is_floating(container)) {
|
||||||
workspace_add_floating(ws, view->container);
|
workspace_add_floating(ws, container);
|
||||||
} else {
|
} else {
|
||||||
workspace_add_tiling(ws, view->container);
|
container = workspace_add_tiling(ws, container);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
container_set_fullscreen(view->container, e->fullscreen);
|
container_set_fullscreen(container, e->fullscreen);
|
||||||
|
|
||||||
arrange_root();
|
arrange_root();
|
||||||
transaction_commit_dirty();
|
transaction_commit_dirty();
|
||||||
|
|
|
@ -247,7 +247,7 @@ static void finalize_move(struct sway_seat *seat) {
|
||||||
|
|
||||||
// Moving container into empty workspace
|
// Moving container into empty workspace
|
||||||
if (target_node->type == N_WORKSPACE && edge == WLR_EDGE_NONE) {
|
if (target_node->type == N_WORKSPACE && edge == WLR_EDGE_NONE) {
|
||||||
workspace_add_tiling(new_ws, con);
|
con = workspace_add_tiling(new_ws, con);
|
||||||
} else if (target_node->type == N_CONTAINER) {
|
} else if (target_node->type == N_CONTAINER) {
|
||||||
// Moving container before/after another
|
// Moving container before/after another
|
||||||
struct sway_container *target = target_node->sway_container;
|
struct sway_container *target = target_node->sway_container;
|
||||||
|
|
|
@ -89,7 +89,7 @@ The following commands may only be used in the configuration file.
|
||||||
_swaynag\_command -_
|
_swaynag\_command -_
|
||||||
|
|
||||||
*workspace_layout* default|stacking|tabbed
|
*workspace_layout* default|stacking|tabbed
|
||||||
Specifies the initial layout for new workspaces.
|
Specifies the initial layout for new containers in an empty workspace.
|
||||||
|
|
||||||
*xwayland* enable|disable|force
|
*xwayland* enable|disable|force
|
||||||
Enables or disables Xwayland support, which allows X11 applications to be
|
Enables or disables Xwayland support, which allows X11 applications to be
|
||||||
|
|
|
@ -804,9 +804,10 @@ void container_set_floating(struct sway_container *container, bool enable) {
|
||||||
container->width = reference->width;
|
container->width = reference->width;
|
||||||
container->height = reference->height;
|
container->height = reference->height;
|
||||||
} else {
|
} else {
|
||||||
|
struct sway_container *other =
|
||||||
workspace_add_tiling(workspace, container);
|
workspace_add_tiling(workspace, container);
|
||||||
container->width = workspace->width;
|
other->width = workspace->width;
|
||||||
container->height = workspace->height;
|
other->height = workspace->height;
|
||||||
}
|
}
|
||||||
if (container->view) {
|
if (container->view) {
|
||||||
view_set_tiled(container->view, true);
|
view_set_tiled(container->view, true);
|
||||||
|
|
|
@ -395,9 +395,6 @@ void output_get_box(struct sway_output *output, struct wlr_box *box) {
|
||||||
|
|
||||||
enum sway_container_layout output_get_default_layout(
|
enum sway_container_layout output_get_default_layout(
|
||||||
struct sway_output *output) {
|
struct sway_output *output) {
|
||||||
if (config->default_layout != L_NONE) {
|
|
||||||
return config->default_layout;
|
|
||||||
}
|
|
||||||
if (config->default_orientation != L_NONE) {
|
if (config->default_orientation != L_NONE) {
|
||||||
return config->default_orientation;
|
return config->default_orientation;
|
||||||
}
|
}
|
||||||
|
|
|
@ -732,10 +732,11 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
|
||||||
ws = seat_get_last_known_workspace(seat);
|
ws = seat_get_last_known_workspace(seat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct sway_container *container = view->container;
|
||||||
if (target_sibling) {
|
if (target_sibling) {
|
||||||
container_add_sibling(target_sibling, view->container, 1);
|
container_add_sibling(target_sibling, container, 1);
|
||||||
} else if (ws) {
|
} else if (ws) {
|
||||||
workspace_add_tiling(ws, view->container);
|
container = workspace_add_tiling(ws, container);
|
||||||
}
|
}
|
||||||
ipc_event_window(view->container, "new");
|
ipc_event_window(view->container, "new");
|
||||||
|
|
||||||
|
@ -759,26 +760,26 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config->popup_during_fullscreen == POPUP_LEAVE &&
|
if (config->popup_during_fullscreen == POPUP_LEAVE &&
|
||||||
view->container->workspace &&
|
container->workspace &&
|
||||||
view->container->workspace->fullscreen &&
|
container->workspace->fullscreen &&
|
||||||
view->container->workspace->fullscreen->view) {
|
container->workspace->fullscreen->view) {
|
||||||
struct sway_container *fs = view->container->workspace->fullscreen;
|
struct sway_container *fs = container->workspace->fullscreen;
|
||||||
if (view_is_transient_for(view, fs->view)) {
|
if (view_is_transient_for(view, fs->view)) {
|
||||||
container_set_fullscreen(fs, false);
|
container_set_fullscreen(fs, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
view_update_title(view, false);
|
view_update_title(view, false);
|
||||||
container_update_representation(view->container);
|
container_update_representation(container);
|
||||||
|
|
||||||
if (fullscreen) {
|
if (fullscreen) {
|
||||||
container_set_fullscreen(view->container, true);
|
container_set_fullscreen(view->container, true);
|
||||||
arrange_workspace(view->container->workspace);
|
arrange_workspace(view->container->workspace);
|
||||||
} else {
|
} else {
|
||||||
if (view->container->parent) {
|
if (container->parent) {
|
||||||
arrange_container(view->container->parent);
|
arrange_container(container->parent);
|
||||||
} else if (view->container->workspace) {
|
} else if (container->workspace) {
|
||||||
arrange_workspace(view->container->workspace);
|
arrange_workspace(container->workspace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -627,6 +627,21 @@ struct sway_container *workspace_find_container(struct sway_workspace *ws,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void set_workspace(struct sway_container *container, void *data) {
|
||||||
|
container->workspace = container->parent->workspace;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void workspace_attach_tiling(struct sway_workspace *ws,
|
||||||
|
struct sway_container *con) {
|
||||||
|
list_add(ws->tiling, con);
|
||||||
|
con->workspace = ws;
|
||||||
|
container_for_each_child(con, set_workspace, NULL);
|
||||||
|
container_handle_fullscreen_reparent(con);
|
||||||
|
workspace_update_representation(ws);
|
||||||
|
node_set_dirty(&ws->node);
|
||||||
|
node_set_dirty(&con->node);
|
||||||
|
}
|
||||||
|
|
||||||
struct sway_container *workspace_wrap_children(struct sway_workspace *ws) {
|
struct sway_container *workspace_wrap_children(struct sway_workspace *ws) {
|
||||||
struct sway_container *fs = ws->fullscreen;
|
struct sway_container *fs = ws->fullscreen;
|
||||||
struct sway_container *middle = container_create(NULL);
|
struct sway_container *middle = container_create(NULL);
|
||||||
|
@ -636,7 +651,7 @@ struct sway_container *workspace_wrap_children(struct sway_workspace *ws) {
|
||||||
container_detach(child);
|
container_detach(child);
|
||||||
container_add_child(middle, child);
|
container_add_child(middle, child);
|
||||||
}
|
}
|
||||||
workspace_add_tiling(ws, middle);
|
workspace_attach_tiling(ws, middle);
|
||||||
ws->fullscreen = fs;
|
ws->fullscreen = fs;
|
||||||
return middle;
|
return middle;
|
||||||
}
|
}
|
||||||
|
@ -668,15 +683,14 @@ void workspace_detach(struct sway_workspace *workspace) {
|
||||||
node_set_dirty(&output->node);
|
node_set_dirty(&output->node);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_workspace(struct sway_container *container, void *data) {
|
struct sway_container *workspace_add_tiling(struct sway_workspace *workspace,
|
||||||
container->workspace = container->parent->workspace;
|
|
||||||
}
|
|
||||||
|
|
||||||
void workspace_add_tiling(struct sway_workspace *workspace,
|
|
||||||
struct sway_container *con) {
|
struct sway_container *con) {
|
||||||
if (con->workspace) {
|
if (con->workspace) {
|
||||||
container_detach(con);
|
container_detach(con);
|
||||||
}
|
}
|
||||||
|
if (config->default_layout != L_NONE) {
|
||||||
|
con = container_split(con, config->default_layout);
|
||||||
|
}
|
||||||
list_add(workspace->tiling, con);
|
list_add(workspace->tiling, con);
|
||||||
con->workspace = workspace;
|
con->workspace = workspace;
|
||||||
container_for_each_child(con, set_workspace, NULL);
|
container_for_each_child(con, set_workspace, NULL);
|
||||||
|
@ -684,6 +698,7 @@ void workspace_add_tiling(struct sway_workspace *workspace,
|
||||||
workspace_update_representation(workspace);
|
workspace_update_representation(workspace);
|
||||||
node_set_dirty(&workspace->node);
|
node_set_dirty(&workspace->node);
|
||||||
node_set_dirty(&con->node);
|
node_set_dirty(&con->node);
|
||||||
|
return con;
|
||||||
}
|
}
|
||||||
|
|
||||||
void workspace_add_floating(struct sway_workspace *workspace,
|
void workspace_add_floating(struct sway_workspace *workspace,
|
||||||
|
@ -699,13 +714,13 @@ void workspace_add_floating(struct sway_workspace *workspace,
|
||||||
node_set_dirty(&con->node);
|
node_set_dirty(&con->node);
|
||||||
}
|
}
|
||||||
|
|
||||||
void workspace_insert_tiling(struct sway_workspace *workspace,
|
struct sway_container *workspace_insert_tiling(struct sway_workspace *workspace,
|
||||||
struct sway_container *con, int index) {
|
struct sway_container *con, int index) {
|
||||||
if (con->workspace) {
|
if (con->workspace) {
|
||||||
container_detach(con);
|
container_detach(con);
|
||||||
}
|
}
|
||||||
if (workspace->layout == L_STACKED || workspace->layout == L_TABBED) {
|
if (config->default_layout != L_NONE) {
|
||||||
con = container_split(con, workspace->layout);
|
con = container_split(con, config->default_layout);
|
||||||
}
|
}
|
||||||
list_insert(workspace->tiling, index, con);
|
list_insert(workspace->tiling, index, con);
|
||||||
con->workspace = workspace;
|
con->workspace = workspace;
|
||||||
|
@ -714,6 +729,7 @@ void workspace_insert_tiling(struct sway_workspace *workspace,
|
||||||
workspace_update_representation(workspace);
|
workspace_update_representation(workspace);
|
||||||
node_set_dirty(&workspace->node);
|
node_set_dirty(&workspace->node);
|
||||||
node_set_dirty(&con->node);
|
node_set_dirty(&con->node);
|
||||||
|
return con;
|
||||||
}
|
}
|
||||||
|
|
||||||
void workspace_add_gaps(struct sway_workspace *ws) {
|
void workspace_add_gaps(struct sway_workspace *ws) {
|
||||||
|
|
Loading…
Reference in a new issue