diff options
Diffstat (limited to 'sway/criteria.c')
-rw-r--r-- | sway/criteria.c | 100 |
1 files changed, 50 insertions, 50 deletions
diff --git a/sway/criteria.c b/sway/criteria.c index 51779590..53435d29 100644 --- a/sway/criteria.c +++ b/sway/criteria.c | |||
@@ -247,62 +247,62 @@ static bool criteria_test(swayc_t *cont, list_t *tokens) { | |||
247 | for (int i = 0; i < tokens->length; i++) { | 247 | for (int i = 0; i < tokens->length; i++) { |
248 | struct crit_token *crit = tokens->items[i]; | 248 | struct crit_token *crit = tokens->items[i]; |
249 | switch (crit->type) { | 249 | switch (crit->type) { |
250 | case CRIT_CLASS: | 250 | case CRIT_CLASS: |
251 | if (!cont->class) { | 251 | if (!cont->class) { |
252 | // ignore | 252 | // ignore |
253 | } else if (strcmp(crit->raw, "focused") == 0) { | 253 | } else if (strcmp(crit->raw, "focused") == 0) { |
254 | swayc_t *focused = get_focused_view(&root_container); | 254 | swayc_t *focused = get_focused_view(&root_container); |
255 | if (focused->class && strcmp(cont->class, focused->class) == 0) { | 255 | if (focused->class && strcmp(cont->class, focused->class) == 0) { |
256 | matches++; | ||
257 | } | ||
258 | } else if (crit->regex && regexec(crit->regex, cont->class, 0, NULL, 0) == 0) { | ||
259 | matches++; | 256 | matches++; |
260 | } | 257 | } |
261 | break; | 258 | } else if (crit->regex && regexec(crit->regex, cont->class, 0, NULL, 0) == 0) { |
262 | case CRIT_ID: | 259 | matches++; |
263 | if (!cont->app_id) { | 260 | } |
264 | // ignore | 261 | break; |
265 | } else if (crit->regex && regexec(crit->regex, cont->app_id, 0, NULL, 0) == 0) { | 262 | case CRIT_ID: |
266 | matches++; | 263 | if (!cont->app_id) { |
267 | } | 264 | // ignore |
268 | break; | 265 | } else if (crit->regex && regexec(crit->regex, cont->app_id, 0, NULL, 0) == 0) { |
269 | case CRIT_INSTANCE: | 266 | matches++; |
270 | break; | 267 | } |
271 | case CRIT_TITLE: | 268 | break; |
272 | if (!cont->name) { | 269 | case CRIT_INSTANCE: |
273 | // ignore | 270 | break; |
274 | } else if (strcmp(crit->raw, "focused") == 0) { | 271 | case CRIT_TITLE: |
275 | swayc_t *focused = get_focused_view(&root_container); | 272 | if (!cont->name) { |
276 | if (focused->name && strcmp(cont->name, focused->name) == 0) { | 273 | // ignore |
277 | matches++; | 274 | } else if (strcmp(crit->raw, "focused") == 0) { |
278 | } | 275 | swayc_t *focused = get_focused_view(&root_container); |
279 | } else if (crit->regex && regexec(crit->regex, cont->name, 0, NULL, 0) == 0) { | 276 | if (focused->name && strcmp(cont->name, focused->name) == 0) { |
280 | matches++; | 277 | matches++; |
281 | } | 278 | } |
282 | break; | 279 | } else if (crit->regex && regexec(crit->regex, cont->name, 0, NULL, 0) == 0) { |
283 | case CRIT_URGENT: // "latest" or "oldest" | 280 | matches++; |
284 | break; | 281 | } |
285 | case CRIT_WINDOW_ROLE: | 282 | break; |
286 | break; | 283 | case CRIT_URGENT: // "latest" or "oldest" |
287 | case CRIT_WINDOW_TYPE: | 284 | break; |
288 | // TODO wlc indeed exposes this information | 285 | case CRIT_WINDOW_ROLE: |
289 | break; | 286 | break; |
290 | case CRIT_WORKSPACE: ; | 287 | case CRIT_WINDOW_TYPE: |
291 | swayc_t *cont_ws = swayc_parent_by_type(cont, C_WORKSPACE); | 288 | // TODO wlc indeed exposes this information |
292 | if (!cont_ws || !cont_ws->name) { | 289 | break; |
293 | // ignore | 290 | case CRIT_WORKSPACE: ; |
294 | } else if (strcmp(crit->raw, "focused") == 0) { | 291 | swayc_t *cont_ws = swayc_parent_by_type(cont, C_WORKSPACE); |
295 | swayc_t *focused_ws = swayc_active_workspace(); | 292 | if (!cont_ws || !cont_ws->name) { |
296 | if (focused_ws->name && strcmp(cont_ws->name, focused_ws->name) == 0) { | 293 | // ignore |
297 | matches++; | 294 | } else if (strcmp(crit->raw, "focused") == 0) { |
298 | } | 295 | swayc_t *focused_ws = swayc_active_workspace(); |
299 | } else if (crit->regex && regexec(crit->regex, cont_ws->name, 0, NULL, 0) == 0) { | 296 | if (focused_ws->name && strcmp(cont_ws->name, focused_ws->name) == 0) { |
300 | matches++; | 297 | matches++; |
301 | } | 298 | } |
302 | break; | 299 | } else if (crit->regex && regexec(crit->regex, cont_ws->name, 0, NULL, 0) == 0) { |
303 | default: | 300 | matches++; |
304 | sway_abort("Invalid criteria type (%i)", crit->type); | 301 | } |
305 | break; | 302 | break; |
303 | default: | ||
304 | sway_abort("Invalid criteria type (%i)", crit->type); | ||
305 | break; | ||
306 | } | 306 | } |
307 | } | 307 | } |
308 | return matches == tokens->length; | 308 | return matches == tokens->length; |