summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Mykyta Holubakha <hilobakho@gmail.com>2017-01-19 03:14:59 +0200
committerLibravatar Mykyta Holubakha <hilobakho@gmail.com>2017-01-19 03:14:59 +0200
commite714fbcbec43fa87e1b969e5fcdc0abf298ade44 (patch)
treecc10e0f32f2e83c3b14180b1fd44b6f0a114bf92
parentMerge pull request #1051 from ametisf/master (diff)
downloadsway-e714fbcbec43fa87e1b969e5fcdc0abf298ade44.tar.gz
sway-e714fbcbec43fa87e1b969e5fcdc0abf298ade44.tar.zst
sway-e714fbcbec43fa87e1b969e5fcdc0abf298ade44.zip
Add window instance support
-rw-r--r--include/sway/container.h1
-rw-r--r--sway/container.c7
-rw-r--r--sway/criteria.c15
-rw-r--r--sway/ipc-json.c2
4 files changed, 22 insertions, 3 deletions
diff --git a/include/sway/container.h b/include/sway/container.h
index ff65628c..46925589 100644
--- a/include/sway/container.h
+++ b/include/sway/container.h
@@ -115,6 +115,7 @@ struct sway_container {
115 // Attributes that mostly views have. 115 // Attributes that mostly views have.
116 char *name; 116 char *name;
117 char *class; 117 char *class;
118 char *instance;
118 char *app_id; 119 char *app_id;
119 120
120 // Used by output containers to keep track of swaybg child processes. 121 // Used by output containers to keep track of swaybg child processes.
diff --git a/sway/container.c b/sway/container.c
index cf7d7dda..11dcdb7f 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -70,6 +70,9 @@ static void free_swayc(swayc_t *cont) {
70 if (cont->class) { 70 if (cont->class) {
71 free(cont->class); 71 free(cont->class);
72 } 72 }
73 if (cont->instance) {
74 free(cont->instance);
75 }
73 if (cont->app_id) { 76 if (cont->app_id) {
74 free(cont->app_id); 77 free(cont->app_id);
75 } 78 }
@@ -295,6 +298,8 @@ swayc_t *new_view(swayc_t *sibling, wlc_handle handle) {
295 view->name = title ? strdup(title) : NULL; 298 view->name = title ? strdup(title) : NULL;
296 const char *class = wlc_view_get_class(handle); 299 const char *class = wlc_view_get_class(handle);
297 view->class = class ? strdup(class) : NULL; 300 view->class = class ? strdup(class) : NULL;
301 const char *instance = wlc_view_get_instance(handle);
302 view->instance = instance ? strdup(instance) : NULL;
298 const char *app_id = wlc_view_get_app_id(handle); 303 const char *app_id = wlc_view_get_app_id(handle);
299 view->app_id = app_id ? strdup(app_id) : NULL; 304 view->app_id = app_id ? strdup(app_id) : NULL;
300 view->visible = true; 305 view->visible = true;
@@ -333,6 +338,8 @@ swayc_t *new_floating_view(wlc_handle handle) {
333 view->name = title ? strdup(title) : NULL; 338 view->name = title ? strdup(title) : NULL;
334 const char *class = wlc_view_get_class(handle); 339 const char *class = wlc_view_get_class(handle);
335 view->class = class ? strdup(class) : NULL; 340 view->class = class ? strdup(class) : NULL;
341 const char *instance = wlc_view_get_instance(handle);
342 view->instance = instance ? strdup(instance) : NULL;
336 const char *app_id = wlc_view_get_app_id(handle); 343 const char *app_id = wlc_view_get_app_id(handle);
337 view->app_id = app_id ? strdup(app_id) : NULL; 344 view->app_id = app_id ? strdup(app_id) : NULL;
338 view->visible = true; 345 view->visible = true;
diff --git a/sway/criteria.c b/sway/criteria.c
index 739a183e..fd1ea64b 100644
--- a/sway/criteria.c
+++ b/sway/criteria.c
@@ -173,9 +173,8 @@ static char *parse_criteria_name(enum criteria_type *type, char *name) {
173 char *error = malloc(len); 173 char *error = malloc(len);
174 snprintf(error, len, fmt, name); 174 snprintf(error, len, fmt, name);
175 return error; 175 return error;
176 } else if (*type == CRIT_INSTANCE || *type == CRIT_URGENT || 176 } else if (*type == CRIT_URGENT || *type == CRIT_WINDOW_ROLE ||
177 *type == CRIT_WINDOW_ROLE || *type == CRIT_WINDOW_TYPE) { 177 *type == CRIT_WINDOW_TYPE) {
178
179 // (we're just being helpful here) 178 // (we're just being helpful here)
180 const char *fmt = "\"%s\" criteria currently unsupported, " 179 const char *fmt = "\"%s\" criteria currently unsupported, "
181 "no window will match this"; 180 "no window will match this";
@@ -267,6 +266,16 @@ static bool criteria_test(swayc_t *cont, list_t *tokens) {
267 } 266 }
268 break; 267 break;
269 case CRIT_INSTANCE: 268 case CRIT_INSTANCE:
269 if (!cont->instance) {
270 // ignore
271 } else if (strcmp(crit->raw, "focused") == 0) {
272 swayc_t *focused = get_focused_view(&root_container);
273 if (focused->instance && strcmp(cont->instance, focused->instance) == 0) {
274 matches++;
275 }
276 } else if (crit->regex && regexec(crit->regex, cont->instance, 0, NULL, 0) == 0) {
277 matches++;
278 }
270 break; 279 break;
271 case CRIT_TITLE: 280 case CRIT_TITLE:
272 if (!cont->name) { 281 if (!cont->name) {
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index 876fc87c..6bd5204c 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -188,6 +188,8 @@ static void ipc_json_describe_view(swayc_t *c, json_object *object) {
188 json_object_object_add(object, "window", json_object_new_int(c->handle)); // for the sake of i3 compat 188 json_object_object_add(object, "window", json_object_new_int(c->handle)); // for the sake of i3 compat
189 json_object_object_add(props, "class", c->class ? json_object_new_string(c->class) : 189 json_object_object_add(props, "class", c->class ? json_object_new_string(c->class) :
190 c->app_id ? json_object_new_string(c->app_id) : NULL); 190 c->app_id ? json_object_new_string(c->app_id) : NULL);
191 json_object_object_add(props, "instance", c->instance ? json_object_new_string(c->instance) :
192 c->app_id ? json_object_new_string(c->app_id) : NULL);
191 json_object_object_add(props, "title", (c->name) ? json_object_new_string(c->name) : NULL); 193 json_object_object_add(props, "title", (c->name) ? json_object_new_string(c->name) : NULL);
192 json_object_object_add(props, "transient_for", parent ? json_object_new_int(parent) : NULL); 194 json_object_object_add(props, "transient_for", parent ? json_object_new_int(parent) : NULL);
193 json_object_object_add(object, "window_properties", props); 195 json_object_object_add(object, "window_properties", props);