aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-04-04 23:06:42 -0400
committerLibravatar GitHub <noreply@github.com>2018-04-04 23:06:42 -0400
commit891e1148bee2575522312078f96eb4c41af49c6c (patch)
tree3044fb62120ca23499d31275076af50db09a9850
parentMerge pull request #1732 from emersion/view-children (diff)
parentMerge branch 'wlroots' into fix-focus-inactive (diff)
downloadsway-891e1148bee2575522312078f96eb4c41af49c6c.tar.gz
sway-891e1148bee2575522312078f96eb4c41af49c6c.tar.zst
sway-891e1148bee2575522312078f96eb4c41af49c6c.zip
Merge pull request #1733 from acrisci/fix-focus-inactive
try to fix focus-inactive
-rw-r--r--sway/input/seat.c22
-rw-r--r--sway/tree/container.c12
-rw-r--r--sway/tree/layout.c10
3 files changed, 23 insertions, 21 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 87dbd870..e3df6955 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -126,7 +126,7 @@ static void handle_seat_container_destroy(struct wl_listener *listener,
126 126
127static struct sway_seat_container *seat_container_from_container( 127static struct sway_seat_container *seat_container_from_container(
128 struct sway_seat *seat, struct sway_container *con) { 128 struct sway_seat *seat, struct sway_container *con) {
129 if (con->type < C_WORKSPACE) { 129 if (con->type == C_ROOT || con->type == C_OUTPUT) {
130 // these don't get seat containers ever 130 // these don't get seat containers ever
131 return NULL; 131 return NULL;
132 } 132 }
@@ -534,22 +534,18 @@ struct sway_container *sway_seat_get_focus(struct sway_seat *seat) {
534 534
535struct sway_container *seat_get_focus_by_type(struct sway_seat *seat, 535struct sway_container *seat_get_focus_by_type(struct sway_seat *seat,
536 struct sway_container *container, enum sway_container_type type) { 536 struct sway_container *container, enum sway_container_type type) {
537 if (container->type == C_VIEW || container->children->length == 0) {
538 return container;
539 }
540
537 struct sway_seat_container *current = NULL; 541 struct sway_seat_container *current = NULL;
538 struct sway_container *parent = NULL;
539 wl_list_for_each(current, &seat->focus_stack, link) { 542 wl_list_for_each(current, &seat->focus_stack, link) {
540 parent = current->container->parent; 543 if (current->container->type != type && type != C_TYPES) {
541 544 continue;
542 if (current->container == container &&
543 (type == C_TYPES || container->type == type)) {
544 return current->container;
545 } 545 }
546 546
547 while (parent) { 547 if (container_has_child(container, current->container)) {
548 if (parent == container && (type == C_TYPES || 548 return current->container;
549 current->container->type == type)) {
550 return current->container;
551 }
552 parent = parent->parent;
553 } 549 }
554 } 550 }
555 551
diff --git a/sway/tree/container.c b/sway/tree/container.c
index bd9f1edf..8fc9e3e8 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -53,10 +53,16 @@ const char *container_type_to_str(enum sway_container_type type) {
53void container_create_notify(struct sway_container *container) { 53void container_create_notify(struct sway_container *container) {
54 // TODO send ipc event type based on the container type 54 // TODO send ipc event type based on the container type
55 wl_signal_emit(&root_container.sway_root->events.new_container, container); 55 wl_signal_emit(&root_container.sway_root->events.new_container, container);
56 ipc_event_window(container, "new"); 56
57 if (container->type == C_VIEW || container->type == C_CONTAINER) {
58 ipc_event_window(container, "new");
59 }
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}
@@ -506,8 +512,8 @@ static bool find_child_func(struct sway_container *con, void *data) {
506 512
507bool container_has_child(struct sway_container *con, 513bool container_has_child(struct sway_container *con,
508 struct sway_container *child) { 514 struct sway_container *child) {
509 if (child == NULL || child->type == C_VIEW || 515 if (con == NULL || con->type == C_VIEW ||
510 child->children->length == 0) { 516 con->children->length == 0) {
511 return false; 517 return false;
512 } 518 }
513 return container_find(con, find_child_func, child); 519 return container_find(con, find_child_func, child);
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(
638 wrap_candidate = parent->children->items[0]; 638 wrap_candidate = parent->children->items[0];
639 } 639 }
640 if (config->force_focus_wrapping) { 640 if (config->force_focus_wrapping) {
641 return seat_get_focus_by_type(seat, 641 return wrap_candidate;
642 wrap_candidate, C_VIEW);
643 } 642 }
644 } 643 }
645 } else { 644 } else {
645 struct sway_container *desired_con = parent->children->items[desired];
646 wlr_log(L_DEBUG, 646 wlr_log(L_DEBUG,
647 "cont %d-%p dir %i sibling %d: %p", idx, 647 "cont %d-%p dir %i sibling %d: %p", idx,
648 container, dir, desired, parent->children->items[desired]); 648 container, dir, desired, desired_con);
649 return seat_get_focus_by_type(seat, 649 struct sway_container *next = seat_get_focus_by_type(seat, desired_con, C_VIEW);
650 parent->children->items[desired], C_VIEW); 650 return next;
651 } 651 }
652 } 652 }
653 653