try to fix focus-inactive

This commit is contained in:
Tony Crisci 2018-04-04 18:52:38 -04:00
parent 3852a710ca
commit 3e61718053
2 changed files with 17 additions and 15 deletions

View file

@ -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 *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) {
struct sway_seat_container *current = NULL; if (container->type == C_VIEW || container->children->length == 0) {
struct sway_container *parent = NULL; return container;
wl_list_for_each(current, &seat->focus_stack, link) { }
parent = current->container->parent;
if (current->container == container && struct sway_seat_container *current = NULL;
(type == C_TYPES || container->type == type)) { wl_list_for_each(current, &seat->focus_stack, link) {
return current->container; if (type != C_TYPES && container->type != type) {
continue;
} }
while (parent) { if (container_has_child(container, current->container)) {
if (parent == container && (type == C_TYPES || return current->container;
current->container->type == type)) {
return current->container;
}
parent = parent->parent;
} }
} }

View file

@ -51,12 +51,18 @@ const char *container_type_to_str(enum sway_container_type type) {
} }
void container_create_notify(struct sway_container *container) { 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 // TODO send ipc event type based on the container type
wl_signal_emit(&root_container.sway_root->events.new_container, container); wl_signal_emit(&root_container.sway_root->events.new_container, container);
ipc_event_window(container, "new"); ipc_event_window(container, "new");
} }
static void container_close_notify(struct sway_container *container) { static void container_close_notify(struct sway_container *container) {
if (container == NULL) {
return;
}
// TODO send ipc event type based on the container type // TODO send ipc event type based on the container type
ipc_event_window(container, "close"); 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, bool container_has_child(struct sway_container *con,
struct sway_container *child) { struct sway_container *child) {
if (child == NULL || child->type == C_VIEW || if (con == NULL || con->type == C_VIEW ||
child->children->length == 0) { con->children->length == 0) {
return false; return false;
} }
return container_find(con, find_child_func, child); return container_find(con, find_child_func, child);