diff options
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r-- | sway/input/seat.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c index d2ffca64..ab751b54 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -70,6 +70,20 @@ static void handle_new_container(struct wl_listener *listener, void *data) { | |||
70 | seat_container_from_container(seat, con); | 70 | seat_container_from_container(seat, con); |
71 | } | 71 | } |
72 | 72 | ||
73 | static void collect_focus_iter(swayc_t *con, void *data) { | ||
74 | struct sway_seat *seat = data; | ||
75 | if (con->type > C_WORKSPACE) { | ||
76 | return; | ||
77 | } | ||
78 | struct sway_seat_container *seat_con = | ||
79 | seat_container_from_container(seat, con); | ||
80 | if (!seat_con) { | ||
81 | return; | ||
82 | } | ||
83 | wl_list_remove(&seat_con->link); | ||
84 | wl_list_insert(&seat->focus_stack, &seat_con->link); | ||
85 | } | ||
86 | |||
73 | struct sway_seat *sway_seat_create(struct sway_input_manager *input, | 87 | struct sway_seat *sway_seat_create(struct sway_input_manager *input, |
74 | const char *seat_name) { | 88 | const char *seat_name) { |
75 | struct sway_seat *seat = calloc(1, sizeof(struct sway_seat)); | 89 | struct sway_seat *seat = calloc(1, sizeof(struct sway_seat)); |
@@ -92,17 +106,8 @@ struct sway_seat *sway_seat_create(struct sway_input_manager *input, | |||
92 | 106 | ||
93 | // init the focus stack | 107 | // init the focus stack |
94 | wl_list_init(&seat->focus_stack); | 108 | wl_list_init(&seat->focus_stack); |
95 | list_t *containers = container_list_children(&root_container); | 109 | |
96 | if (containers == NULL) { | 110 | container_for_each_bfs(&root_container, collect_focus_iter, seat); |
97 | wlr_seat_destroy(seat->wlr_seat); | ||
98 | free(seat); | ||
99 | return NULL; | ||
100 | } | ||
101 | for (int i = containers->length - 1; i >= 0; --i) { | ||
102 | swayc_t *con = containers->items[i]; | ||
103 | seat_container_from_container(seat, con); | ||
104 | } | ||
105 | free(containers); | ||
106 | 111 | ||
107 | wl_signal_add(&root_container.sway_root->events.new_container, | 112 | wl_signal_add(&root_container.sway_root->events.new_container, |
108 | &seat->new_container); | 113 | &seat->new_container); |