mirror of
https://github.com/swaywm/sway.git
synced 2024-12-30 17:06:40 +01:00
Make mouse drag in tiled mode swap containers if no edge is selected
Now the highlighted center area of containers triggers a swap action instead of moving around the containers.
This commit is contained in:
parent
c9cb5ced7f
commit
538b36c0e2
3 changed files with 18 additions and 9 deletions
|
@ -326,6 +326,8 @@ void container_detach(struct sway_container *child);
|
||||||
void container_replace(struct sway_container *container,
|
void container_replace(struct sway_container *container,
|
||||||
struct sway_container *replacement);
|
struct sway_container *replacement);
|
||||||
|
|
||||||
|
void container_swap(struct sway_container *con1, struct sway_container *con2);
|
||||||
|
|
||||||
struct sway_container *container_split(struct sway_container *child,
|
struct sway_container *container_split(struct sway_container *child,
|
||||||
enum sway_container_layout layout);
|
enum sway_container_layout layout);
|
||||||
|
|
||||||
|
|
|
@ -84,8 +84,7 @@ static void swap_focus(struct sway_container *con1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void container_swap(struct sway_container *con1,
|
void container_swap(struct sway_container *con1, struct sway_container *con2) {
|
||||||
struct sway_container *con2) {
|
|
||||||
if (!sway_assert(con1 && con2, "Cannot swap with nothing")) {
|
if (!sway_assert(con1 && con2, "Cannot swap with nothing")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,8 +245,12 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
|
||||||
target_node->sway_workspace : target_node->sway_container->workspace;
|
target_node->sway_workspace : target_node->sway_container->workspace;
|
||||||
enum wlr_edges edge = e->target_edge;
|
enum wlr_edges edge = e->target_edge;
|
||||||
int after = edge != WLR_EDGE_TOP && edge != WLR_EDGE_LEFT;
|
int after = edge != WLR_EDGE_TOP && edge != WLR_EDGE_LEFT;
|
||||||
|
bool swap = edge == WLR_EDGE_NONE && target_node->type == N_CONTAINER;
|
||||||
|
|
||||||
|
if (!swap) {
|
||||||
container_detach(con);
|
container_detach(con);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 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) {
|
||||||
|
@ -254,6 +258,9 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
|
||||||
} 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;
|
||||||
|
if (swap) {
|
||||||
|
container_swap(target_node->sway_container, con);
|
||||||
|
} else {
|
||||||
enum sway_container_layout layout = container_parent_layout(target);
|
enum sway_container_layout layout = container_parent_layout(target);
|
||||||
if (edge && !is_parallel(layout, edge)) {
|
if (edge && !is_parallel(layout, edge)) {
|
||||||
enum sway_container_layout new_layout = edge == WLR_EDGE_TOP ||
|
enum sway_container_layout new_layout = edge == WLR_EDGE_TOP ||
|
||||||
|
@ -261,6 +268,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
|
||||||
container_split(target, new_layout);
|
container_split(target, new_layout);
|
||||||
}
|
}
|
||||||
container_add_sibling(target, con, after);
|
container_add_sibling(target, con, after);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Target is a workspace which requires splitting
|
// Target is a workspace which requires splitting
|
||||||
enum sway_container_layout new_layout = edge == WLR_EDGE_TOP ||
|
enum sway_container_layout new_layout = edge == WLR_EDGE_TOP ||
|
||||||
|
|
Loading…
Reference in a new issue