mirror of
https://github.com/swaywm/sway.git
synced 2024-11-05 16:03:11 +00:00
Add window instance support
This commit is contained in:
parent
dd41ce45f7
commit
e714fbcbec
|
@ -115,6 +115,7 @@ struct sway_container {
|
||||||
// Attributes that mostly views have.
|
// Attributes that mostly views have.
|
||||||
char *name;
|
char *name;
|
||||||
char *class;
|
char *class;
|
||||||
|
char *instance;
|
||||||
char *app_id;
|
char *app_id;
|
||||||
|
|
||||||
// Used by output containers to keep track of swaybg child processes.
|
// Used by output containers to keep track of swaybg child processes.
|
||||||
|
|
|
@ -70,6 +70,9 @@ static void free_swayc(swayc_t *cont) {
|
||||||
if (cont->class) {
|
if (cont->class) {
|
||||||
free(cont->class);
|
free(cont->class);
|
||||||
}
|
}
|
||||||
|
if (cont->instance) {
|
||||||
|
free(cont->instance);
|
||||||
|
}
|
||||||
if (cont->app_id) {
|
if (cont->app_id) {
|
||||||
free(cont->app_id);
|
free(cont->app_id);
|
||||||
}
|
}
|
||||||
|
@ -295,6 +298,8 @@ swayc_t *new_view(swayc_t *sibling, wlc_handle handle) {
|
||||||
view->name = title ? strdup(title) : NULL;
|
view->name = title ? strdup(title) : NULL;
|
||||||
const char *class = wlc_view_get_class(handle);
|
const char *class = wlc_view_get_class(handle);
|
||||||
view->class = class ? strdup(class) : NULL;
|
view->class = class ? strdup(class) : NULL;
|
||||||
|
const char *instance = wlc_view_get_instance(handle);
|
||||||
|
view->instance = instance ? strdup(instance) : NULL;
|
||||||
const char *app_id = wlc_view_get_app_id(handle);
|
const char *app_id = wlc_view_get_app_id(handle);
|
||||||
view->app_id = app_id ? strdup(app_id) : NULL;
|
view->app_id = app_id ? strdup(app_id) : NULL;
|
||||||
view->visible = true;
|
view->visible = true;
|
||||||
|
@ -333,6 +338,8 @@ swayc_t *new_floating_view(wlc_handle handle) {
|
||||||
view->name = title ? strdup(title) : NULL;
|
view->name = title ? strdup(title) : NULL;
|
||||||
const char *class = wlc_view_get_class(handle);
|
const char *class = wlc_view_get_class(handle);
|
||||||
view->class = class ? strdup(class) : NULL;
|
view->class = class ? strdup(class) : NULL;
|
||||||
|
const char *instance = wlc_view_get_instance(handle);
|
||||||
|
view->instance = instance ? strdup(instance) : NULL;
|
||||||
const char *app_id = wlc_view_get_app_id(handle);
|
const char *app_id = wlc_view_get_app_id(handle);
|
||||||
view->app_id = app_id ? strdup(app_id) : NULL;
|
view->app_id = app_id ? strdup(app_id) : NULL;
|
||||||
view->visible = true;
|
view->visible = true;
|
||||||
|
|
|
@ -173,9 +173,8 @@ static char *parse_criteria_name(enum criteria_type *type, char *name) {
|
||||||
char *error = malloc(len);
|
char *error = malloc(len);
|
||||||
snprintf(error, len, fmt, name);
|
snprintf(error, len, fmt, name);
|
||||||
return error;
|
return error;
|
||||||
} else if (*type == CRIT_INSTANCE || *type == CRIT_URGENT ||
|
} else if (*type == CRIT_URGENT || *type == CRIT_WINDOW_ROLE ||
|
||||||
*type == CRIT_WINDOW_ROLE || *type == CRIT_WINDOW_TYPE) {
|
*type == CRIT_WINDOW_TYPE) {
|
||||||
|
|
||||||
// (we're just being helpful here)
|
// (we're just being helpful here)
|
||||||
const char *fmt = "\"%s\" criteria currently unsupported, "
|
const char *fmt = "\"%s\" criteria currently unsupported, "
|
||||||
"no window will match this";
|
"no window will match this";
|
||||||
|
@ -267,6 +266,16 @@ static bool criteria_test(swayc_t *cont, list_t *tokens) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CRIT_INSTANCE:
|
case CRIT_INSTANCE:
|
||||||
|
if (!cont->instance) {
|
||||||
|
// ignore
|
||||||
|
} else if (strcmp(crit->raw, "focused") == 0) {
|
||||||
|
swayc_t *focused = get_focused_view(&root_container);
|
||||||
|
if (focused->instance && strcmp(cont->instance, focused->instance) == 0) {
|
||||||
|
matches++;
|
||||||
|
}
|
||||||
|
} else if (crit->regex && regexec(crit->regex, cont->instance, 0, NULL, 0) == 0) {
|
||||||
|
matches++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CRIT_TITLE:
|
case CRIT_TITLE:
|
||||||
if (!cont->name) {
|
if (!cont->name) {
|
||||||
|
|
|
@ -188,6 +188,8 @@ static void ipc_json_describe_view(swayc_t *c, json_object *object) {
|
||||||
json_object_object_add(object, "window", json_object_new_int(c->handle)); // for the sake of i3 compat
|
json_object_object_add(object, "window", json_object_new_int(c->handle)); // for the sake of i3 compat
|
||||||
json_object_object_add(props, "class", c->class ? json_object_new_string(c->class) :
|
json_object_object_add(props, "class", c->class ? json_object_new_string(c->class) :
|
||||||
c->app_id ? json_object_new_string(c->app_id) : NULL);
|
c->app_id ? json_object_new_string(c->app_id) : NULL);
|
||||||
|
json_object_object_add(props, "instance", c->instance ? json_object_new_string(c->instance) :
|
||||||
|
c->app_id ? json_object_new_string(c->app_id) : NULL);
|
||||||
json_object_object_add(props, "title", (c->name) ? json_object_new_string(c->name) : NULL);
|
json_object_object_add(props, "title", (c->name) ? json_object_new_string(c->name) : NULL);
|
||||||
json_object_object_add(props, "transient_for", parent ? json_object_new_int(parent) : NULL);
|
json_object_object_add(props, "transient_for", parent ? json_object_new_int(parent) : NULL);
|
||||||
json_object_object_add(object, "window_properties", props);
|
json_object_object_add(object, "window_properties", props);
|
||||||
|
|
Loading…
Reference in a new issue