aboutsummaryrefslogtreecommitdiff
path: root/sway/input
diff options
context:
space:
mode:
authorRyan Dwyer <ryandwyer1@gmail.com>2018-07-26 22:58:42 +1000
committerRyan Dwyer <ryandwyer1@gmail.com>2018-07-28 22:41:04 +1000
commitda2a87f6c71bfe90a4d77542bfc7ed22899f67be (patch)
tree76cb0dcdd9006bbec11321645e096ea47cd79e82 /sway/input
parent936168e740067a8658c7097ff76588b070faa71f (diff)
downloadsway-da2a87f6c71bfe90a4d77542bfc7ed22899f67be.tar.xz
When unfloating, return container to previously focused tiled container
This introduces seat_get_focus_inactive_tiling and updates `focus mode_toggle` to use it instead, because the previous method wasn't guaranteed to return a tiling view.
Diffstat (limited to 'sway/input')
-rw-r--r--sway/input/seat.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 877a93c6..18d5591d 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -124,12 +124,14 @@ static void seat_send_focus(struct sway_container *con,
}
static struct sway_container *seat_get_focus_by_type(struct sway_seat *seat,
- struct sway_container *container, enum sway_container_type type) {
+ struct sway_container *container, enum sway_container_type type,
+ bool only_tiling) {
if (container->type == C_VIEW) {
return container;
}
- struct sway_container *floating = container->type == C_WORKSPACE ?
+ struct sway_container *floating =
+ container->type == C_WORKSPACE && !only_tiling ?
container->sway_workspace->floating : NULL;
if (container->children->length == 0 &&
(!floating || floating->children->length == 0)) {
@@ -143,6 +145,10 @@ static struct sway_container *seat_get_focus_by_type(struct sway_seat *seat,
}
if (container_has_child(container, current->container)) {
+ if (only_tiling &&
+ container_is_floating_or_child(current->container)) {
+ continue;
+ }
return current->container;
}
if (floating && container_has_child(floating, current->container)) {
@@ -169,7 +175,7 @@ void seat_focus_inactive_children_for_each(struct sway_seat *seat,
struct sway_container *seat_get_focus_inactive_view(struct sway_seat *seat,
struct sway_container *container) {
- return seat_get_focus_by_type(seat, container, C_VIEW);
+ return seat_get_focus_by_type(seat, container, C_VIEW, false);
}
static void handle_seat_container_destroy(struct wl_listener *listener,
@@ -191,7 +197,7 @@ static void handle_seat_container_destroy(struct wl_listener *listener,
if (set_focus) {
struct sway_container *next_focus = NULL;
while (next_focus == NULL) {
- next_focus = seat_get_focus_by_type(seat, parent, C_VIEW);
+ next_focus = seat_get_focus_by_type(seat, parent, C_VIEW, false);
if (next_focus == NULL && parent->type == C_WORKSPACE) {
next_focus = parent;
@@ -648,7 +654,7 @@ void seat_set_focus_warp(struct sway_seat *seat,
struct sway_container *new_output_last_ws = NULL;
if (last_output && new_output && last_output != new_output) {
new_output_last_ws =
- seat_get_focus_by_type(seat, new_output, C_WORKSPACE);
+ seat_get_focus_by_type(seat, new_output, C_WORKSPACE, false);
}
if (container && container->parent) {
@@ -853,7 +859,12 @@ void seat_set_exclusive_client(struct sway_seat *seat,
struct sway_container *seat_get_focus_inactive(struct sway_seat *seat,
struct sway_container *container) {
- return seat_get_focus_by_type(seat, container, C_TYPES);
+ return seat_get_focus_by_type(seat, container, C_TYPES, false);
+}
+
+struct sway_container *seat_get_focus_inactive_tiling(struct sway_seat *seat,
+ struct sway_container *container) {
+ return seat_get_focus_by_type(seat, container, C_TYPES, true);
}
struct sway_container *seat_get_active_child(struct sway_seat *seat,