diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-01-18 20:50:30 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-18 20:50:30 -0500 |
commit | fa19960d1e700c9999117c9bd4b1ad0fbc16a028 (patch) | |
tree | 99225cbb7e76e869ba96ce87bbf28ca47f299fa2 | |
parent | Merge pull request #1051 from ametisf/master (diff) | |
parent | Display instance (if present) in nested layouts (diff) | |
download | sway-fa19960d1e700c9999117c9bd4b1ad0fbc16a028.tar.gz sway-fa19960d1e700c9999117c9bd4b1ad0fbc16a028.tar.zst sway-fa19960d1e700c9999117c9bd4b1ad0fbc16a028.zip |
Merge pull request #1052 from Hummer12007/instance
Add window instance support
-rw-r--r-- | include/sway/container.h | 1 | ||||
-rw-r--r-- | sway/border.c | 4 | ||||
-rw-r--r-- | sway/container.c | 7 | ||||
-rw-r--r-- | sway/criteria.c | 15 | ||||
-rw-r--r-- | sway/ipc-json.c | 2 |
5 files changed, 25 insertions, 4 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/border.c b/sway/border.c index 5ae32d24..d79029a9 100644 --- a/sway/border.c +++ b/sway/border.c | |||
@@ -254,7 +254,9 @@ static char *generate_container_title(swayc_t *container) { | |||
254 | swayc_t* child = container->children->items[i]; | 254 | swayc_t* child = container->children->items[i]; |
255 | const char *title = NULL; | 255 | const char *title = NULL; |
256 | if (child->type == C_VIEW) { | 256 | if (child->type == C_VIEW) { |
257 | title = child->app_id ? child->app_id : (child->class ? child->class : "(null)"); | 257 | title = child->app_id ? child->app_id : |
258 | (child->instance ? child->instance : | ||
259 | (child->class ? child->class :"(null)")); | ||
258 | } else { //child->type == C_CONTAINER | 260 | } else { //child->type == C_CONTAINER |
259 | title = generate_container_title(child); | 261 | title = generate_container_title(child); |
260 | } | 262 | } |
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); |