summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Tony Crisci <tony@dubstepdish.com>2018-04-04 18:52:38 -0400
committerLibravatar Tony Crisci <tony@dubstepdish.com>2018-04-04 18:52:38 -0400
commit3e61718053a7e2cdd94c64f5613c6bdf28e35c8e (patch)
tree4cceb8836dbc34317c8e530aec373fd6241db466
parentMerge pull request #1731 from acrisci/ipc-window-events (diff)
downloadsway-3e61718053a7e2cdd94c64f5613c6bdf28e35c8e.tar.gz
sway-3e61718053a7e2cdd94c64f5613c6bdf28e35c8e.tar.zst
sway-3e61718053a7e2cdd94c64f5613c6bdf28e35c8e.zip
try to fix focus-inactive
-rw-r--r--sway/input/seat.c20
-rw-r--r--sway/tree/container.c10
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) {
467 467
468struct sway_container *seat_get_focus_by_type(struct sway_seat *seat, 468struct sway_container *seat_get_focus_by_type(struct sway_seat *seat,
469 struct sway_container *container, enum sway_container_type type) { 469 struct sway_container *container, enum sway_container_type type) {
470 if (container->type == C_VIEW || container->children->length == 0) {
471 return container;
472 }
473
470 struct sway_seat_container *current = NULL; 474 struct sway_seat_container *current = NULL;
471 struct sway_container *parent = NULL;
472 wl_list_for_each(current, &seat->focus_stack, link) { 475 wl_list_for_each(current, &seat->focus_stack, link) {
473 parent = current->container->parent; 476 if (type != C_TYPES && container->type != type) {
474 477 continue;
475 if (current->container == container &&
476 (type == C_TYPES || container->type == type)) {
477 return current->container;
478 } 478 }
479 479
480 while (parent) { 480 if (container_has_child(container, current->container)) {
481 if (parent == container && (type == C_TYPES || 481 return current->container;
482 current->container->type == type)) {
483 return current->container;
484 }
485 parent = parent->parent;
486 } 482 }
487 } 483 }
488 484
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) {
51} 51}
52 52
53void container_create_notify(struct sway_container *container) { 53void container_create_notify(struct sway_container *container) {
54 if (container->type != C_VIEW || container->type != C_CONTAINER) {
55 return;
56 }
54 // TODO send ipc event type based on the container type 57 // TODO send ipc event type based on the container type
55 wl_signal_emit(&root_container.sway_root->events.new_container, container); 58 wl_signal_emit(&root_container.sway_root->events.new_container, container);
56 ipc_event_window(container, "new"); 59 ipc_event_window(container, "new");
57} 60}
58 61
59static void container_close_notify(struct sway_container *container) { 62static void container_close_notify(struct sway_container *container) {
63 if (container == NULL) {
64 return;
65 }
60 // TODO send ipc event type based on the container type 66 // TODO send ipc event type based on the container type
61 ipc_event_window(container, "close"); 67 ipc_event_window(container, "close");
62} 68}
@@ -522,8 +528,8 @@ static bool find_child_func(struct sway_container *con, void *data) {
522 528
523bool container_has_child(struct sway_container *con, 529bool container_has_child(struct sway_container *con,
524 struct sway_container *child) { 530 struct sway_container *child) {
525 if (child == NULL || child->type == C_VIEW || 531 if (con == NULL || con->type == C_VIEW ||
526 child->children->length == 0) { 532 con->children->length == 0) {
527 return false; 533 return false;
528 } 534 }
529 return container_find(con, find_child_func, child); 535 return container_find(con, find_child_func, child);