]> Dogcows Code - chaz/openbox/commitdiff
allow app rules to match windows by their title when mapping
authorDana Jansens <danakj@orodu.net>
Thu, 14 Jan 2010 22:24:39 +0000 (17:24 -0500)
committerDana Jansens <danakj@orodu.net>
Thu, 14 Jan 2010 23:41:21 +0000 (18:41 -0500)
and save the title in the _OB_APP_TITLE property

data/rc.xml
data/rc.xsd
obt/prop.c
obt/prop.h
openbox/client.c
openbox/config.c
openbox/config.h
openbox/screen.c

index ecc22bb94ae173ee1e49d1a7cc0e7853fcff1672..63470918b72935c2b399e3650fe5b9d4f270e42e 100644 (file)
 <!--
   # this is an example with comments through out. use these to make your
   # own rules, but without the comments of course.
-  # you may use one or more of the name/class/role/type rules to specify
+  # you may use one or more of the name/class/role/title/type rules to specify
   # windows to match
 
   <application name="the window's _OB_APP_NAME property (see obxprop)"
               class="the window's _OB_APP_CLASS property (see obxprop)"
                role="the window's _OB_APP_ROLE property (see obxprop)"
+              title="the window's _OB_APP_TITLE property (see obxprop)"
                type="the window's _OB_APP_TYPE property (see obxprob)..
                       (if unspecified, then it is 'dialog' for child windows)">
-  # you may set only one of name/class/role/type, or you may use more than one
-  # together to restrict your matches.
+  # you may set only one of name/class/role/title/type, or you may use more
+  # than one together to restrict your matches.
 
-  # the name, class, and role use simple wildcard matching such as those
+  # the name, class, role, and title use simple wildcard matching such as those
   # used by a shell. you can use * to match any characters and ? to match
   # any single character.
 
index 6d2ed1dd18264c405b7a3142329c329e823b3e2b..2fed1f489f5318b44cf5d77ca1e2c394f771d1c9 100644 (file)
             <xsd:element minOccurs="0" name="fullscreen" type="ob:bool"/>
             <xsd:element minOccurs="0" name="maximized" type="ob:maximization"/>
         </xsd:all>
+        <!-- at least one of these must be present -->
         <xsd:attribute name="role" type="xsd:string"/>
+        <xsd:attribute name="title" type="xsd:string"/>
         <xsd:attribute name="type" type="ob:clienttype"/>
-        <!-- at least one of these must be present -->
         <xsd:attribute name="name" type="xsd:string"/>
         <xsd:attribute name="class" type="xsd:string"/>
     </xsd:complexType>
index 3af9c7d7483bdc8e6b81d41864cfe0cbcf08ae13..ae229e4295e82ed413394f2eac4f50f761ff0e3e 100644 (file)
@@ -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);
index 0a471cd501cbbe20db9d01bdd934ace8aded590c..cc1fe736024ec662172319b93f4f1b36ef425e0c 100644 (file)
@@ -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,
index fd2afed1be69559ff6c328ccaa226a55b1195436..f91a783db0cf0d9b22117959456f1080241812e0 100644 (file)
@@ -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:
index 6904759ce6e5bb31eb54bb7ab401049b3d26b7db..72d054693562528adf2a58f000d0245821e6b482 100644 (file)
@@ -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);
     }
index 0e4ccb5cf0f0c80717aed2158f9b2e122caed00c..818dcc760ea3e1deee9ef4e2013787a31e8e6833 100644 (file)
@@ -38,6 +38,7 @@ struct _ObAppSettings
     GPatternSpec *class;
     GPatternSpec *name;
     GPatternSpec *role;
+    GPatternSpec *title;
     ObClientType  type;
 
     GravityPoint position;
index 2e69f11e7fb94197b5e805969dd87e26a69fbb2e..cbcaad798604af9eb61d2a119c3459aa6ea9e222 100644 (file)
@@ -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);
This page took 0.030925 seconds and 4 git commands to generate.