diff options
author | 2018-05-28 00:14:22 +1000 | |
---|---|---|
committer | 2018-05-28 00:14:22 +1000 | |
commit | 8fda41dab52656c7c4a0db9a835ae57cea994538 (patch) | |
tree | 2b0c481616cd738e0f6ca92be9594eec7707799b /sway | |
parent | Implement swap command (diff) | |
parent | Merge pull request #2043 from emersion/pool-buffer-fixes (diff) | |
download | sway-8fda41dab52656c7c4a0db9a835ae57cea994538.tar.gz sway-8fda41dab52656c7c4a0db9a835ae57cea994538.tar.zst sway-8fda41dab52656c7c4a0db9a835ae57cea994538.zip |
Merge branch 'master' into cmd-swap
Diffstat (limited to 'sway')
-rw-r--r-- | sway/criteria.c | 18 | ||||
-rw-r--r-- | sway/desktop/xdg_shell.c | 12 | ||||
-rw-r--r-- | sway/sway.5.scd | 5 | ||||
-rw-r--r-- | sway/tree/view.c | 10 |
4 files changed, 38 insertions, 7 deletions
diff --git a/sway/criteria.c b/sway/criteria.c index 4295cacc..dec5fed7 100644 --- a/sway/criteria.c +++ b/sway/criteria.c | |||
@@ -13,6 +13,7 @@ | |||
13 | 13 | ||
14 | bool criteria_is_empty(struct criteria *criteria) { | 14 | bool criteria_is_empty(struct criteria *criteria) { |
15 | return !criteria->title | 15 | return !criteria->title |
16 | && !criteria->shell | ||
16 | && !criteria->app_id | 17 | && !criteria->app_id |
17 | && !criteria->class | 18 | && !criteria->class |
18 | && !criteria->instance | 19 | && !criteria->instance |
@@ -29,6 +30,7 @@ bool criteria_is_empty(struct criteria *criteria) { | |||
29 | 30 | ||
30 | void criteria_destroy(struct criteria *criteria) { | 31 | void criteria_destroy(struct criteria *criteria) { |
31 | pcre_free(criteria->title); | 32 | pcre_free(criteria->title); |
33 | pcre_free(criteria->shell); | ||
32 | pcre_free(criteria->app_id); | 34 | pcre_free(criteria->app_id); |
33 | pcre_free(criteria->class); | 35 | pcre_free(criteria->class); |
34 | pcre_free(criteria->instance); | 36 | pcre_free(criteria->instance); |
@@ -53,6 +55,13 @@ static bool criteria_matches_view(struct criteria *criteria, | |||
53 | } | 55 | } |
54 | } | 56 | } |
55 | 57 | ||
58 | if (criteria->shell) { | ||
59 | const char *shell = view_get_shell(view); | ||
60 | if (!shell || regex_cmp(shell, criteria->shell) != 0) { | ||
61 | return false; | ||
62 | } | ||
63 | } | ||
64 | |||
56 | if (criteria->app_id) { | 65 | if (criteria->app_id) { |
57 | const char *app_id = view_get_app_id(view); | 66 | const char *app_id = view_get_app_id(view); |
58 | if (!app_id || regex_cmp(app_id, criteria->app_id) != 0) { | 67 | if (!app_id || regex_cmp(app_id, criteria->app_id) != 0) { |
@@ -206,6 +215,7 @@ enum criteria_token { | |||
206 | T_FLOATING, | 215 | T_FLOATING, |
207 | T_ID, | 216 | T_ID, |
208 | T_INSTANCE, | 217 | T_INSTANCE, |
218 | T_SHELL, | ||
209 | T_TILING, | 219 | T_TILING, |
210 | T_TITLE, | 220 | T_TITLE, |
211 | T_URGENT, | 221 | T_URGENT, |
@@ -229,6 +239,8 @@ static enum criteria_token token_from_name(char *name) { | |||
229 | return T_ID; | 239 | return T_ID; |
230 | } else if (strcmp(name, "instance") == 0) { | 240 | } else if (strcmp(name, "instance") == 0) { |
231 | return T_INSTANCE; | 241 | return T_INSTANCE; |
242 | } else if (strcmp(name, "shell") == 0) { | ||
243 | return T_SHELL; | ||
232 | } else if (strcmp(name, "title") == 0) { | 244 | } else if (strcmp(name, "title") == 0) { |
233 | return T_TITLE; | 245 | return T_TITLE; |
234 | } else if (strcmp(name, "urgent") == 0) { | 246 | } else if (strcmp(name, "urgent") == 0) { |
@@ -271,6 +283,9 @@ static char *get_focused_prop(enum criteria_token token) { | |||
271 | case T_INSTANCE: | 283 | case T_INSTANCE: |
272 | value = view_get_instance(view); | 284 | value = view_get_instance(view); |
273 | break; | 285 | break; |
286 | case T_SHELL: | ||
287 | value = view_get_shell(view); | ||
288 | break; | ||
274 | case T_TITLE: | 289 | case T_TITLE: |
275 | value = view_get_class(view); | 290 | value = view_get_class(view); |
276 | break; | 291 | break; |
@@ -332,6 +347,9 @@ static bool parse_token(struct criteria *criteria, char *name, char *value) { | |||
332 | case T_TITLE: | 347 | case T_TITLE: |
333 | generate_regex(&criteria->title, effective_value); | 348 | generate_regex(&criteria->title, effective_value); |
334 | break; | 349 | break; |
350 | case T_SHELL: | ||
351 | generate_regex(&criteria->shell, effective_value); | ||
352 | break; | ||
335 | case T_APP_ID: | 353 | case T_APP_ID: |
336 | generate_regex(&criteria->app_id, effective_value); | 354 | generate_regex(&criteria->app_id, effective_value); |
337 | break; | 355 | break; |
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 9a0d282b..b2b95fa0 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c | |||
@@ -3,13 +3,14 @@ | |||
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #include <wayland-server.h> | 4 | #include <wayland-server.h> |
5 | #include <wlr/types/wlr_xdg_shell.h> | 5 | #include <wlr/types/wlr_xdg_shell.h> |
6 | #include <wlr/util/edges.h> | ||
7 | #include "log.h" | ||
8 | #include "sway/input/input-manager.h" | ||
9 | #include "sway/input/seat.h" | ||
10 | #include "sway/server.h" | ||
6 | #include "sway/tree/container.h" | 11 | #include "sway/tree/container.h" |
7 | #include "sway/tree/layout.h" | 12 | #include "sway/tree/layout.h" |
8 | #include "sway/server.h" | ||
9 | #include "sway/tree/view.h" | 13 | #include "sway/tree/view.h" |
10 | #include "sway/input/seat.h" | ||
11 | #include "sway/input/input-manager.h" | ||
12 | #include "log.h" | ||
13 | 14 | ||
14 | static const struct sway_view_child_impl popup_impl; | 15 | static const struct sway_view_child_impl popup_impl; |
15 | 16 | ||
@@ -248,7 +249,8 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) { | |||
248 | wlr_log(L_DEBUG, "New xdg_shell toplevel title='%s' app_id='%s'", | 249 | wlr_log(L_DEBUG, "New xdg_shell toplevel title='%s' app_id='%s'", |
249 | xdg_surface->toplevel->title, xdg_surface->toplevel->app_id); | 250 | xdg_surface->toplevel->title, xdg_surface->toplevel->app_id); |
250 | wlr_xdg_surface_ping(xdg_surface); | 251 | wlr_xdg_surface_ping(xdg_surface); |
251 | wlr_xdg_toplevel_set_maximized(xdg_surface, true); | 252 | wlr_xdg_toplevel_set_tiled(xdg_surface, WLR_EDGE_LEFT | WLR_EDGE_RIGHT | |
253 | WLR_EDGE_TOP | WLR_EDGE_BOTTOM); | ||
252 | 254 | ||
253 | struct sway_xdg_shell_view *xdg_shell_view = | 255 | struct sway_xdg_shell_view *xdg_shell_view = |
254 | calloc(1, sizeof(struct sway_xdg_shell_view)); | 256 | calloc(1, sizeof(struct sway_xdg_shell_view)); |
diff --git a/sway/sway.5.scd b/sway/sway.5.scd index 25a5eef5..e6bc5a1e 100644 --- a/sway/sway.5.scd +++ b/sway/sway.5.scd | |||
@@ -560,6 +560,11 @@ The following attributes may be matched with: | |||
560 | value is \_\_focused\_\_, then the window instance must be the same as that | 560 | value is \_\_focused\_\_, then the window instance must be the same as that |
561 | of the currently focused window. | 561 | of the currently focused window. |
562 | 562 | ||
563 | *shell* | ||
564 | Compare value against the window shell, such as "xdg\_shell" or "xwayland". | ||
565 | Can be a regular expression. If value is \_\_focused\_\_, then the shell | ||
566 | must be the same as that of the currently focused window. | ||
567 | |||
563 | *tiling* | 568 | *tiling* |
564 | Matches tiling windows. | 569 | Matches tiling windows. |
565 | 570 | ||
diff --git a/sway/tree/view.c b/sway/tree/view.c index 812d7740..d91182ed 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -107,7 +107,7 @@ uint32_t view_get_window_type(struct sway_view *view) { | |||
107 | return 0; | 107 | return 0; |
108 | } | 108 | } |
109 | 109 | ||
110 | const char *view_get_type(struct sway_view *view) { | 110 | const char *view_get_shell(struct sway_view *view) { |
111 | switch(view->type) { | 111 | switch(view->type) { |
112 | case SWAY_VIEW_XDG_SHELL_V6: | 112 | case SWAY_VIEW_XDG_SHELL_V6: |
113 | return "xdg_shell_v6"; | 113 | return "xdg_shell_v6"; |
@@ -654,10 +654,12 @@ static size_t parse_title_format(struct sway_view *view, char *buffer) { | |||
654 | return title ? strlen(title) : 0; | 654 | return title ? strlen(title) : 0; |
655 | } | 655 | } |
656 | const char *title = view_get_title(view); | 656 | const char *title = view_get_title(view); |
657 | const char *app_id = view_get_app_id(view); | ||
657 | const char *class = view_get_class(view); | 658 | const char *class = view_get_class(view); |
658 | const char *instance = view_get_instance(view); | 659 | const char *instance = view_get_instance(view); |
659 | const char *shell = view_get_type(view); | 660 | const char *shell = view_get_shell(view); |
660 | size_t title_len = title ? strlen(title) : 0; | 661 | size_t title_len = title ? strlen(title) : 0; |
662 | size_t app_id_len = app_id ? strlen(app_id) : 0; | ||
661 | size_t class_len = class ? strlen(class) : 0; | 663 | size_t class_len = class ? strlen(class) : 0; |
662 | size_t instance_len = instance ? strlen(instance) : 0; | 664 | size_t instance_len = instance ? strlen(instance) : 0; |
663 | size_t shell_len = shell ? strlen(shell) : 0; | 665 | size_t shell_len = shell ? strlen(shell) : 0; |
@@ -675,6 +677,10 @@ static size_t parse_title_format(struct sway_view *view, char *buffer) { | |||
675 | lenient_strcat(buffer, title); | 677 | lenient_strcat(buffer, title); |
676 | len += title_len; | 678 | len += title_len; |
677 | format += 6; | 679 | format += 6; |
680 | } else if (strncmp(next, "%app_id", 7) == 0) { | ||
681 | lenient_strcat(buffer, app_id); | ||
682 | len += app_id_len; | ||
683 | format += 7; | ||
678 | } else if (strncmp(next, "%class", 6) == 0) { | 684 | } else if (strncmp(next, "%class", 6) == 0) { |
679 | lenient_strcat(buffer, class); | 685 | lenient_strcat(buffer, class); |
680 | len += class_len; | 686 | len += class_len; |