aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar lbonn <bonnans.l@gmail.com>2017-10-08 00:24:42 +0200
committerLibravatar lbonn <bonnans.l@gmail.com>2017-10-08 11:51:03 +0200
commitd879e5b15d146a04ed7585b6c78653c4ac56b6dd (patch)
tree61d6d08633f8b34372a2e56b8ba42f4af53b82bb
parentipc/tree: populate `focus` fields (diff)
downloadsway-d879e5b15d146a04ed7585b6c78653c4ac56b6dd.tar.gz
sway-d879e5b15d146a04ed7585b6c78653c4ac56b6dd.tar.zst
sway-d879e5b15d146a04ed7585b6c78653c4ac56b6dd.zip
commands: implement 3 missing criteria from i3
* con_id * floating * tiling
-rw-r--r--sway/criteria.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/sway/criteria.c b/sway/criteria.c
index 04683f66..9a04b48e 100644
--- a/sway/criteria.c
+++ b/sway/criteria.c
@@ -12,9 +12,12 @@
12 12
13enum criteria_type { // *must* keep in sync with criteria_strings[] 13enum criteria_type { // *must* keep in sync with criteria_strings[]
14 CRIT_CLASS, 14 CRIT_CLASS,
15 CRIT_CON_ID,
15 CRIT_CON_MARK, 16 CRIT_CON_MARK,
17 CRIT_FLOATING,
16 CRIT_ID, 18 CRIT_ID,
17 CRIT_INSTANCE, 19 CRIT_INSTANCE,
20 CRIT_TILING,
18 CRIT_TITLE, 21 CRIT_TITLE,
19 CRIT_URGENT, 22 CRIT_URGENT,
20 CRIT_WINDOW_ROLE, 23 CRIT_WINDOW_ROLE,
@@ -25,9 +28,12 @@ enum criteria_type { // *must* keep in sync with criteria_strings[]
25 28
26static const char * const criteria_strings[CRIT_LAST] = { 29static const char * const criteria_strings[CRIT_LAST] = {
27 [CRIT_CLASS] = "class", 30 [CRIT_CLASS] = "class",
31 [CRIT_CON_ID] = "con_id",
28 [CRIT_CON_MARK] = "con_mark", 32 [CRIT_CON_MARK] = "con_mark",
33 [CRIT_FLOATING] = "floating",
29 [CRIT_ID] = "id", 34 [CRIT_ID] = "id",
30 [CRIT_INSTANCE] = "instance", 35 [CRIT_INSTANCE] = "instance",
36 [CRIT_TILING] = "tiling",
31 [CRIT_TITLE] = "title", 37 [CRIT_TITLE] = "title",
32 [CRIT_URGENT] = "urgent", // either "latest" or "oldest" ... 38 [CRIT_URGENT] = "urgent", // either "latest" or "oldest" ...
33 [CRIT_WINDOW_ROLE] = "window_role", 39 [CRIT_WINDOW_ROLE] = "window_role",
@@ -263,6 +269,15 @@ static bool criteria_test(swayc_t *cont, list_t *tokens) {
263 matches++; 269 matches++;
264 } 270 }
265 break; 271 break;
272 case CRIT_CON_ID: {
273 char *endptr;
274 size_t crit_id = strtoul(crit->raw, &endptr, 10);
275
276 if (*endptr == 0 && cont->id == crit_id) {
277 ++matches;
278 }
279 break;
280 }
266 case CRIT_CON_MARK: 281 case CRIT_CON_MARK:
267 if (crit->regex && cont->marks && (list_seq_find(cont->marks, (int (*)(const void *, const void *))regex_cmp, crit->regex) != -1)) { 282 if (crit->regex && cont->marks && (list_seq_find(cont->marks, (int (*)(const void *, const void *))regex_cmp, crit->regex) != -1)) {
268 // Make sure it isn't matching the NUL string 283 // Make sure it isn't matching the NUL string
@@ -271,6 +286,11 @@ static bool criteria_test(swayc_t *cont, list_t *tokens) {
271 } 286 }
272 } 287 }
273 break; 288 break;
289 case CRIT_FLOATING:
290 if (cont->is_floating) {
291 matches++;
292 }
293 break;
274 case CRIT_ID: 294 case CRIT_ID:
275 if (!cont->app_id) { 295 if (!cont->app_id) {
276 // ignore 296 // ignore
@@ -290,6 +310,11 @@ static bool criteria_test(swayc_t *cont, list_t *tokens) {
290 matches++; 310 matches++;
291 } 311 }
292 break; 312 break;
313 case CRIT_TILING:
314 if (!cont->is_floating) {
315 matches++;
316 }
317 break;
293 case CRIT_TITLE: 318 case CRIT_TITLE:
294 if (!cont->name) { 319 if (!cont->name) {
295 // ignore 320 // ignore