aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authorRyan Dwyer <RyanDwyer@users.noreply.github.com>2018-05-28 00:14:22 +1000
committerGitHub <noreply@github.com>2018-05-28 00:14:22 +1000
commit8fda41dab52656c7c4a0db9a835ae57cea994538 (patch)
tree2b0c481616cd738e0f6ca92be9594eec7707799b /sway
parent569f4e0e4c75562c38848ea0bbaeb3b2f230b1a9 (diff)
parentde32b6d52ef8cf7d477fba23f42ca054155add56 (diff)
downloadsway-8fda41dab52656c7c4a0db9a835ae57cea994538.tar.xz
Merge branch 'master' into cmd-swap
Diffstat (limited to 'sway')
-rw-r--r--sway/criteria.c18
-rw-r--r--sway/desktop/xdg_shell.c12
-rw-r--r--sway/sway.5.scd5
-rw-r--r--sway/tree/view.c10
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 @@
bool criteria_is_empty(struct criteria *criteria) {
return !criteria->title
+ && !criteria->shell
&& !criteria->app_id
&& !criteria->class
&& !criteria->instance
@@ -29,6 +30,7 @@ bool criteria_is_empty(struct criteria *criteria) {
void criteria_destroy(struct criteria *criteria) {
pcre_free(criteria->title);
+ pcre_free(criteria->shell);
pcre_free(criteria->app_id);
pcre_free(criteria->class);
pcre_free(criteria->instance);
@@ -53,6 +55,13 @@ static bool criteria_matches_view(struct criteria *criteria,
}
}
+ if (criteria->shell) {
+ const char *shell = view_get_shell(view);
+ if (!shell || regex_cmp(shell, criteria->shell) != 0) {
+ return false;
+ }
+ }
+
if (criteria->app_id) {
const char *app_id = view_get_app_id(view);
if (!app_id || regex_cmp(app_id, criteria->app_id) != 0) {
@@ -206,6 +215,7 @@ enum criteria_token {
T_FLOATING,
T_ID,
T_INSTANCE,
+ T_SHELL,
T_TILING,
T_TITLE,
T_URGENT,
@@ -229,6 +239,8 @@ static enum criteria_token token_from_name(char *name) {
return T_ID;
} else if (strcmp(name, "instance") == 0) {
return T_INSTANCE;
+ } else if (strcmp(name, "shell") == 0) {
+ return T_SHELL;
} else if (strcmp(name, "title") == 0) {
return T_TITLE;
} else if (strcmp(name, "urgent") == 0) {
@@ -271,6 +283,9 @@ static char *get_focused_prop(enum criteria_token token) {
case T_INSTANCE:
value = view_get_instance(view);
break;
+ case T_SHELL:
+ value = view_get_shell(view);
+ break;
case T_TITLE:
value = view_get_class(view);
break;
@@ -332,6 +347,9 @@ static bool parse_token(struct criteria *criteria, char *name, char *value) {
case T_TITLE:
generate_regex(&criteria->title, effective_value);
break;
+ case T_SHELL:
+ generate_regex(&criteria->shell, effective_value);
+ break;
case T_APP_ID:
generate_regex(&criteria->app_id, effective_value);
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 @@
#include <stdlib.h>
#include <wayland-server.h>
#include <wlr/types/wlr_xdg_shell.h>
+#include <wlr/util/edges.h>
+#include "log.h"
+#include "sway/input/input-manager.h"
+#include "sway/input/seat.h"
+#include "sway/server.h"
#include "sway/tree/container.h"
#include "sway/tree/layout.h"
-#include "sway/server.h"
#include "sway/tree/view.h"
-#include "sway/input/seat.h"
-#include "sway/input/input-manager.h"
-#include "log.h"
static const struct sway_view_child_impl popup_impl;
@@ -248,7 +249,8 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
wlr_log(L_DEBUG, "New xdg_shell toplevel title='%s' app_id='%s'",
xdg_surface->toplevel->title, xdg_surface->toplevel->app_id);
wlr_xdg_surface_ping(xdg_surface);
- wlr_xdg_toplevel_set_maximized(xdg_surface, true);
+ wlr_xdg_toplevel_set_tiled(xdg_surface, WLR_EDGE_LEFT | WLR_EDGE_RIGHT |
+ WLR_EDGE_TOP | WLR_EDGE_BOTTOM);
struct sway_xdg_shell_view *xdg_shell_view =
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:
value is \_\_focused\_\_, then the window instance must be the same as that
of the currently focused window.
+*shell*
+ Compare value against the window shell, such as "xdg\_shell" or "xwayland".
+ Can be a regular expression. If value is \_\_focused\_\_, then the shell
+ must be the same as that of the currently focused window.
+
*tiling*
Matches tiling windows.
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) {
return 0;
}
-const char *view_get_type(struct sway_view *view) {
+const char *view_get_shell(struct sway_view *view) {
switch(view->type) {
case SWAY_VIEW_XDG_SHELL_V6:
return "xdg_shell_v6";
@@ -654,10 +654,12 @@ static size_t parse_title_format(struct sway_view *view, char *buffer) {
return title ? strlen(title) : 0;
}
const char *title = view_get_title(view);
+ const char *app_id = view_get_app_id(view);
const char *class = view_get_class(view);
const char *instance = view_get_instance(view);
- const char *shell = view_get_type(view);
+ const char *shell = view_get_shell(view);
size_t title_len = title ? strlen(title) : 0;
+ size_t app_id_len = app_id ? strlen(app_id) : 0;
size_t class_len = class ? strlen(class) : 0;
size_t instance_len = instance ? strlen(instance) : 0;
size_t shell_len = shell ? strlen(shell) : 0;
@@ -675,6 +677,10 @@ static size_t parse_title_format(struct sway_view *view, char *buffer) {
lenient_strcat(buffer, title);
len += title_len;
format += 6;
+ } else if (strncmp(next, "%app_id", 7) == 0) {
+ lenient_strcat(buffer, app_id);
+ len += app_id_len;
+ format += 7;
} else if (strncmp(next, "%class", 6) == 0) {
lenient_strcat(buffer, class);
len += class_len;