From 3e61718053a7e2cdd94c64f5613c6bdf28e35c8e Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Wed, 4 Apr 2018 18:52:38 -0400 Subject: try to fix focus-inactive --- sway/input/seat.c | 20 ++++++++------------ sway/tree/container.c | 10 ++++++++-- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/sway/input/seat.c b/sway/input/seat.c index 4a99e9eb..078cb8b8 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -467,22 +467,18 @@ struct sway_container *sway_seat_get_focus(struct sway_seat *seat) { struct sway_container *seat_get_focus_by_type(struct sway_seat *seat, struct sway_container *container, enum sway_container_type type) { + if (container->type == C_VIEW || container->children->length == 0) { + return container; + } + struct sway_seat_container *current = NULL; - struct sway_container *parent = NULL; wl_list_for_each(current, &seat->focus_stack, link) { - parent = current->container->parent; - - if (current->container == container && - (type == C_TYPES || container->type == type)) { - return current->container; + if (type != C_TYPES && container->type != type) { + continue; } - while (parent) { - if (parent == container && (type == C_TYPES || - current->container->type == type)) { - return current->container; - } - parent = parent->parent; + if (container_has_child(container, current->container)) { + return current->container; } } diff --git a/sway/tree/container.c b/sway/tree/container.c index 753f333c..b47a8364 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -51,12 +51,18 @@ const char *container_type_to_str(enum sway_container_type type) { } void container_create_notify(struct sway_container *container) { + if (container->type != C_VIEW || container->type != C_CONTAINER) { + return; + } // TODO send ipc event type based on the container type wl_signal_emit(&root_container.sway_root->events.new_container, container); ipc_event_window(container, "new"); } static void container_close_notify(struct sway_container *container) { + if (container == NULL) { + return; + } // TODO send ipc event type based on the container type ipc_event_window(container, "close"); } @@ -522,8 +528,8 @@ static bool find_child_func(struct sway_container *con, void *data) { bool container_has_child(struct sway_container *con, struct sway_container *child) { - if (child == NULL || child->type == C_VIEW || - child->children->length == 0) { + if (con == NULL || con->type == C_VIEW || + con->children->length == 0) { return false; } return container_find(con, find_child_func, child); -- cgit v1.2.3-54-g00ecf From cfd806577b9ba6049cc3dec3cd78168bfb7ca4db Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Wed, 4 Apr 2018 19:37:01 -0400 Subject: fix sending window new event --- sway/tree/container.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sway/tree/container.c b/sway/tree/container.c index b47a8364..92c00f83 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -51,12 +51,12 @@ const char *container_type_to_str(enum sway_container_type type) { } void container_create_notify(struct sway_container *container) { - if (container->type != C_VIEW || container->type != C_CONTAINER) { - return; - } // TODO send ipc event type based on the container type wl_signal_emit(&root_container.sway_root->events.new_container, container); - ipc_event_window(container, "new"); + + if (container->type == C_VIEW || container->type == C_CONTAINER) { + ipc_event_window(container, "new"); + } } static void container_close_notify(struct sway_container *container) { -- cgit v1.2.3-54-g00ecf From deda37469ad4e21ad86b7c83c7c8a966301b9d5e Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Wed, 4 Apr 2018 22:31:10 -0400 Subject: fix focus child --- sway/input/seat.c | 4 ++-- sway/tree/layout.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sway/input/seat.c b/sway/input/seat.c index 078cb8b8..50134aae 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -123,7 +123,7 @@ static void handle_seat_container_destroy(struct wl_listener *listener, static struct sway_seat_container *seat_container_from_container( struct sway_seat *seat, struct sway_container *con) { - if (con->type < C_WORKSPACE) { + if (con->type == C_ROOT || con->type == C_OUTPUT) { // these don't get seat containers ever return NULL; } @@ -473,7 +473,7 @@ struct sway_container *seat_get_focus_by_type(struct sway_seat *seat, struct sway_seat_container *current = NULL; wl_list_for_each(current, &seat->focus_stack, link) { - if (type != C_TYPES && container->type != type) { + if (current->container->type != type && type != C_TYPES) { continue; } diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 5abdbc32..1769609b 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c @@ -638,16 +638,16 @@ struct sway_container *container_get_in_direction( wrap_candidate = parent->children->items[0]; } if (config->force_focus_wrapping) { - return seat_get_focus_by_type(seat, - wrap_candidate, C_VIEW); + return wrap_candidate; } } } else { + struct sway_container *desired_con = parent->children->items[desired]; wlr_log(L_DEBUG, "cont %d-%p dir %i sibling %d: %p", idx, - container, dir, desired, parent->children->items[desired]); - return seat_get_focus_by_type(seat, - parent->children->items[desired], C_VIEW); + container, dir, desired, desired_con); + struct sway_container *next = seat_get_focus_by_type(seat, desired_con, C_VIEW); + return next; } } -- cgit v1.2.3-54-g00ecf