summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-03-23 03:49:29 -0400
committerLibravatar emersion <contact@emersion.fr>2019-03-23 09:53:23 +0200
commit7d2076cbff2b363061d52362927d0da2f3c4865b (patch)
treea3bb021770ee61b77fb65a0eedb53725a0b200da /include
parentcmd_mode: allow cmd_set to be a subcommand (diff)
downloadsway-7d2076cbff2b363061d52362927d0da2f3c4865b.tar.gz
sway-7d2076cbff2b363061d52362927d0da2f3c4865b.tar.zst
sway-7d2076cbff2b363061d52362927d0da2f3c4865b.zip
criteria: fix __focused__ when no focus or unset
This fixes the behavior of `__focused__` when there is no focused view to match i3's behavior of successfully matching no views instead of returning an error of a missing value. It also applies the same logic when a token is not applicable (or unset) for a view such as `app_id` for a focused xwayland view or `class` for a focused xdg-shell view. This adds an `autofail` boolean to `struct criteria`. If it is set to `true`, then `criteria_matches_view` will immediately bail out as a no match. If `autofail` is set, the criteria will also not be considered empty by `criteria_is_empty`. To set this new `autofail` property, `get_focused_prop` will now take in a boolean pointer of the same name. If `__focused__` is supported for the token and there is no focused view or the focused view does not have a value for the token, then the boolean will be set to true. In `parse_token`, the boolean value will be checked and if set to true, then `criteria->autofail` will be set to true and `parse_token` will bail successfully. Tokens will still be parsed to make sure the whole criteria is syntactically valid, which is also why `&criteria->autofail` is not passed to `get_focused_prop` and a local boolean is declared in `parse_token`.
Diffstat (limited to 'include')
-rw-r--r--include/sway/criteria.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/include/sway/criteria.h b/include/sway/criteria.h
index f7e788c8..8a1d9e5e 100644
--- a/include/sway/criteria.h
+++ b/include/sway/criteria.h
@@ -20,6 +20,7 @@ struct criteria {
20 char *cmdlist; 20 char *cmdlist;
21 char *target; // workspace or output name for `assign` criteria 21 char *target; // workspace or output name for `assign` criteria
22 22
23 bool autofail; // __focused__ while no focus or n/a for focused view
23 pcre *title; 24 pcre *title;
24 pcre *shell; 25 pcre *shell;
25 pcre *app_id; 26 pcre *app_id;