diff options
Diffstat (limited to 'sway/criteria.c')
-rw-r--r-- | sway/criteria.c | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/sway/criteria.c b/sway/criteria.c index feca904a..e5b308e0 100644 --- a/sway/criteria.c +++ b/sway/criteria.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include "sway/config.h" | 9 | #include "sway/config.h" |
10 | #include "sway/tree/root.h" | 10 | #include "sway/tree/root.h" |
11 | #include "sway/tree/view.h" | 11 | #include "sway/tree/view.h" |
12 | #include "sway/tree/workspace.h" | ||
12 | #include "stringop.h" | 13 | #include "stringop.h" |
13 | #include "list.h" | 14 | #include "list.h" |
14 | #include "log.h" | 15 | #include "log.h" |
@@ -87,12 +88,12 @@ static int cmp_urgent(const void *_a, const void *_b) { | |||
87 | return 0; | 88 | return 0; |
88 | } | 89 | } |
89 | 90 | ||
90 | static void find_urgent_iterator(struct sway_container *swayc, void *data) { | 91 | static void find_urgent_iterator(struct sway_container *con, void *data) { |
91 | if (swayc->type != C_VIEW || !view_is_urgent(swayc->sway_view)) { | 92 | if (!con->view || !view_is_urgent(con->view)) { |
92 | return; | 93 | return; |
93 | } | 94 | } |
94 | list_t *urgent_views = data; | 95 | list_t *urgent_views = data; |
95 | list_add(urgent_views, swayc->sway_view); | 96 | list_add(urgent_views, con->view); |
96 | } | 97 | } |
97 | 98 | ||
98 | static bool criteria_matches_view(struct criteria *criteria, | 99 | static bool criteria_matches_view(struct criteria *criteria, |
@@ -132,7 +133,7 @@ static bool criteria_matches_view(struct criteria *criteria, | |||
132 | } | 133 | } |
133 | 134 | ||
134 | if (criteria->con_id) { // Internal ID | 135 | if (criteria->con_id) { // Internal ID |
135 | if (!view->swayc || view->swayc->id != criteria->con_id) { | 136 | if (!view->container || view->container->node.id != criteria->con_id) { |
136 | return false; | 137 | return false; |
137 | } | 138 | } |
138 | } | 139 | } |
@@ -174,13 +175,13 @@ static bool criteria_matches_view(struct criteria *criteria, | |||
174 | #endif | 175 | #endif |
175 | 176 | ||
176 | if (criteria->floating) { | 177 | if (criteria->floating) { |
177 | if (!container_is_floating(view->swayc)) { | 178 | if (!container_is_floating(view->container)) { |
178 | return false; | 179 | return false; |
179 | } | 180 | } |
180 | } | 181 | } |
181 | 182 | ||
182 | if (criteria->tiling) { | 183 | if (criteria->tiling) { |
183 | if (container_is_floating(view->swayc)) { | 184 | if (container_is_floating(view->container)) { |
184 | return false; | 185 | return false; |
185 | } | 186 | } |
186 | } | 187 | } |
@@ -205,10 +206,7 @@ static bool criteria_matches_view(struct criteria *criteria, | |||
205 | } | 206 | } |
206 | 207 | ||
207 | if (criteria->workspace) { | 208 | if (criteria->workspace) { |
208 | if (!view->swayc) { | 209 | struct sway_workspace *ws = view->container->workspace; |
209 | return false; | ||
210 | } | ||
211 | struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE); | ||
212 | if (!ws || strcmp(ws->name, criteria->workspace) != 0) { | 210 | if (!ws || strcmp(ws->name, criteria->workspace) != 0) { |
213 | return false; | 211 | return false; |
214 | } | 212 | } |
@@ -237,9 +235,9 @@ struct match_data { | |||
237 | static void criteria_get_views_iterator(struct sway_container *container, | 235 | static void criteria_get_views_iterator(struct sway_container *container, |
238 | void *data) { | 236 | void *data) { |
239 | struct match_data *match_data = data; | 237 | struct match_data *match_data = data; |
240 | if (container->type == C_VIEW) { | 238 | if (!container->view) { |
241 | if (criteria_matches_view(match_data->criteria, container->sway_view)) { | 239 | if (criteria_matches_view(match_data->criteria, container->view)) { |
242 | list_add(match_data->matches, container->sway_view); | 240 | list_add(match_data->matches, container->view); |
243 | } | 241 | } |
244 | } | 242 | } |
245 | } | 243 | } |
@@ -355,12 +353,12 @@ static enum criteria_token token_from_name(char *name) { | |||
355 | */ | 353 | */ |
356 | static char *get_focused_prop(enum criteria_token token) { | 354 | static char *get_focused_prop(enum criteria_token token) { |
357 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 355 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
358 | struct sway_container *focus = seat_get_focus(seat); | 356 | struct sway_container *focus = seat_get_focused_container(seat); |
359 | 357 | ||
360 | if (!focus || focus->type != C_VIEW) { | 358 | if (!focus || !focus->view) { |
361 | return NULL; | 359 | return NULL; |
362 | } | 360 | } |
363 | struct sway_view *view = focus->sway_view; | 361 | struct sway_view *view = focus->view; |
364 | const char *value = NULL; | 362 | const char *value = NULL; |
365 | 363 | ||
366 | switch (token) { | 364 | switch (token) { |
@@ -374,18 +372,15 @@ static char *get_focused_prop(enum criteria_token token) { | |||
374 | value = view_get_title(view); | 372 | value = view_get_title(view); |
375 | break; | 373 | break; |
376 | case T_WORKSPACE: | 374 | case T_WORKSPACE: |
377 | { | 375 | if (focus->workspace) { |
378 | struct sway_container *ws = container_parent(focus, C_WORKSPACE); | 376 | value = focus->workspace->name; |
379 | if (ws) { | ||
380 | value = ws->name; | ||
381 | } | ||
382 | } | 377 | } |
383 | break; | 378 | break; |
384 | case T_CON_ID: | 379 | case T_CON_ID: |
385 | if (view->swayc == NULL) { | 380 | if (view->container == NULL) { |
386 | return NULL; | 381 | return NULL; |
387 | } | 382 | } |
388 | size_t id = view->swayc->id; | 383 | size_t id = view->container->node.id; |
389 | size_t id_size = snprintf(NULL, 0, "%zu", id) + 1; | 384 | size_t id_size = snprintf(NULL, 0, "%zu", id) + 1; |
390 | char *id_str = malloc(id_size); | 385 | char *id_str = malloc(id_size); |
391 | snprintf(id_str, id_size, "%zu", id); | 386 | snprintf(id_str, id_size, "%zu", id); |