From: Dana Jansens Date: Thu, 14 Jan 2010 22:24:39 +0000 (-0500) Subject: allow app rules to match windows by their title when mapping X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fopenbox;a=commitdiff_plain;h=6cf3357036561134383198cc8b853abb3fe5a982 allow app rules to match windows by their title when mapping and save the title in the _OB_APP_TITLE property --- diff --git a/data/rc.xml b/data/rc.xml index ecc22bb9..63470918 100644 --- a/data/rc.xml +++ b/data/rc.xml @@ -693,18 +693,19 @@ + - diff --git a/obt/prop.c b/obt/prop.c index 3af9c7d7..ae229e42 100644 --- a/obt/prop.c +++ b/obt/prop.c @@ -192,6 +192,7 @@ void obt_prop_startup(void) CREATE_(OB_CONTROL); CREATE_(OB_VERSION); CREATE_(OB_APP_ROLE); + CREATE_(OB_APP_TITLE); CREATE_(OB_APP_NAME); CREATE_(OB_APP_CLASS); CREATE_(OB_APP_TYPE); diff --git a/obt/prop.h b/obt/prop.h index 0a471cd5..cc1fe736 100644 --- a/obt/prop.h +++ b/obt/prop.h @@ -213,6 +213,7 @@ typedef enum { OBT_PROP_OB_CONTROL, OBT_PROP_OB_VERSION, OBT_PROP_OB_APP_ROLE, + OBT_PROP_OB_APP_TITLE, OBT_PROP_OB_APP_NAME, OBT_PROP_OB_APP_CLASS, OBT_PROP_OB_APP_TYPE, diff --git a/openbox/client.c b/openbox/client.c index fd2afed1..f91a783d 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -236,7 +236,8 @@ void client_manage(Window window, ObPrompt *prompt) ob_debug("Window type: %d", self->type); ob_debug("Window group: 0x%x", self->group?self->group->leader:0); - ob_debug("Window name: %s class: %s role: %s", self->name, self->class, self->role); + ob_debug("Window name: %s class: %s role: %s title: %s", + self->name, self->class, self->role, self->title); /* per-app settings override stuff from client_get_all, and return the settings for other uses too. the returned settings is a shallow copy, @@ -796,7 +797,8 @@ static ObAppSettings *client_get_settings_state(ObClient *self) gboolean match = TRUE; g_assert(app->name != NULL || app->class != NULL || - app->role != NULL || (signed)app->type >= 0); + app->role != NULL || app->title != NULL || + (signed)app->type >= 0); if (app->name && !g_pattern_match(app->name, strlen(self->name), self->name, NULL)) @@ -809,6 +811,10 @@ static ObAppSettings *client_get_settings_state(ObClient *self) !g_pattern_match(app->role, strlen(self->role), self->role, NULL)) match = FALSE; + else if (app->title && + !g_pattern_match(app->title, + strlen(self->title), self->title, NULL)) + match = FALSE; else if ((signed)app->type >= 0 && app->type != self->type) { match = FALSE; } @@ -1083,9 +1089,6 @@ static void client_get_all(ObClient *self, gboolean real) from per-app settings */ client_get_session_ids(self); - /* save the values of the variables used for app rule matching */ - client_save_app_rule_values(self); - /* now we got everything that can affect the decorations */ if (!real) return; @@ -1093,6 +1096,9 @@ static void client_get_all(ObClient *self, gboolean real) /* get this early so we have it for debugging */ client_update_title(self); + /* save the values of the variables used for app rule matching */ + client_save_app_rule_values(self); + client_update_protocols(self); client_update_wmhints(self); @@ -2310,6 +2316,7 @@ static void client_save_app_rule_values(ObClient *self) OBT_PROP_SETS(self->window, OB_APP_ROLE, utf8, self->role); OBT_PROP_SETS(self->window, OB_APP_NAME, utf8, self->name); OBT_PROP_SETS(self->window, OB_APP_CLASS, utf8, self->class); + OBT_PROP_SETS(self->window, OB_APP_TITLE, utf8, self->original_title); switch (self->type) { case OB_CLIENT_TYPE_NORMAL: diff --git a/openbox/config.c b/openbox/config.c index 6904759c..72d05469 100644 --- a/openbox/config.c +++ b/openbox/config.c @@ -200,8 +200,9 @@ static void config_parse_gravity_coord(xmlNodePtr node, GravityCoord *c) static void parse_per_app_settings(xmlNodePtr node, gpointer d) { xmlNodePtr app = obt_xml_find_node(node->children, "application"); - gchar *name = NULL, *class = NULL, *role = NULL, *type_str = NULL; - gboolean name_set, class_set, type_set, role_set; + gchar *name = NULL, *class = NULL, *role = NULL, *title = NULL, + *type_str = NULL; + gboolean name_set, class_set, type_set, role_set, title_set; ObClientType type; gboolean x_pos_given; @@ -212,6 +213,7 @@ static void parse_per_app_settings(xmlNodePtr node, gpointer d) name_set = obt_xml_attr_string(app, "name", &name); type_set = obt_xml_attr_string(app, "type", &type_str); role_set = obt_xml_attr_string(app, "role", &role); + title_set = obt_xml_attr_string(app, "title", &title); /* validate the type tho */ if (type_set) { @@ -235,7 +237,7 @@ static void parse_per_app_settings(xmlNodePtr node, gpointer d) type_set = FALSE; /* not valid! */ } - if (class_set || name_set || role_set || type_set) { + if (class_set || name_set || role_set || title_set || type_set) { xmlNodePtr n, c; ObAppSettings *settings = config_create_app_settings();; @@ -248,6 +250,9 @@ static void parse_per_app_settings(xmlNodePtr node, gpointer d) if (role_set) settings->role = g_pattern_spec_new(role); + if (title_set) + settings->title = g_pattern_spec_new(title); + if (type_set) settings->type = type; @@ -352,7 +357,8 @@ static void parse_per_app_settings(xmlNodePtr node, gpointer d) g_free(name); g_free(class); g_free(role); - name = class = role = NULL; + g_free(title); + name = class = role = title = NULL; } app = obt_xml_find_node(app->next, "application"); @@ -1074,6 +1080,7 @@ void config_shutdown(void) ObAppSettings *itd = (ObAppSettings *)it->data; if (itd->name) g_pattern_spec_free(itd->name); if (itd->role) g_pattern_spec_free(itd->role); + if (itd->title) g_pattern_spec_free(itd->title); if (itd->class) g_pattern_spec_free(itd->class); g_free(it->data); } diff --git a/openbox/config.h b/openbox/config.h index 0e4ccb5c..818dcc76 100644 --- a/openbox/config.h +++ b/openbox/config.h @@ -38,6 +38,7 @@ struct _ObAppSettings GPatternSpec *class; GPatternSpec *name; GPatternSpec *role; + GPatternSpec *title; ObClientType type; GravityPoint position; diff --git a/openbox/screen.c b/openbox/screen.c index 2e69f11e..cbcaad79 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -297,6 +297,7 @@ gboolean screen_annex(void) supported[i++] = OBT_PROP_ATOM(OB_CONTROL); supported[i++] = OBT_PROP_ATOM(OB_VERSION); supported[i++] = OBT_PROP_ATOM(OB_APP_ROLE); + supported[i++] = OBT_PROP_ATOM(OB_APP_TITLE); supported[i++] = OBT_PROP_ATOM(OB_APP_NAME); supported[i++] = OBT_PROP_ATOM(OB_APP_CLASS); supported[i++] = OBT_PROP_ATOM(OB_APP_TYPE);