let you match per-app settings based on the window type
authorDana Jansens <danakj@orodu.net>
Thu, 14 Feb 2008 01:53:25 +0000 (20:53 -0500)
committerMikael Magnusson <mikachu@comhem.se>
Thu, 14 Feb 2008 18:40:03 +0000 (19:40 +0100)
data/rc.xml
data/rc.xsd
openbox/client.c
openbox/config.c
openbox/config.h

index 98daf27..ebe2f31 100644 (file)
 
   <application name="first element of window's WM_CLASS property (see xprop)"
               class="second element of window's WM_CLASS property (see xprop)"
-               role="the window's WM_WINDOW_ROLE property (see xprop)">
+               role="the window's WM_WINDOW_ROLE property (see xprop)"
+               type="the window's _NET_WM_WINDOW_TYPE (if unspecified, then
+                       it is dialog for child windows)">
   # the name or the class can be set, or both. this is used to match
   # windows when they appear. role can optionally be set as well, to
   # further restrict your matches.
   # used by a shell. you can use * to match any characters and ? to match
   # any single character.
 
+  # the type is one of: normal, dialog, splash, utility, menu, toolbar, dock,
+  #    or desktop
+
   # when multiple rules match a window, they will all be applied, in the
   # order that they appear in this list
 
index 47eeed1..de227ea 100644 (file)
         <xsd:element minOccurs="0" name="skip_taskbar" type="ob:bool"/>
         <xsd:element minOccurs="0" name="fullscreen" type="ob:bool"/>
         <xsd:element minOccurs="0" name="maximized" type="ob:maximization"/>
+        <xsd:attribute name="role" 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:attribute name="role" type="xsd:string"/>
     </xsd:complexType>
     <xsd:complexType name="applications">
         <xsd:element minOccurs="0" maxOccurs="unbounded" name="application" type="ob:application"/>
             <xsd:enumeration value="Unshade"/>
         </xsd:restriction>
     </xsd:simpleType>
+    <xsd:simpleType name="clienttype">
+        <xsd:restriction base="xsd:string">
+            <xsd:enumeration value="desktop"/>
+            <xsd:enumeration value="dock"/>
+            <xsd:enumeration value="toolbar"/>
+            <xsd:enumeration value="menu"/>
+            <xsd:enumeration value="splash"/>
+            <xsd:enumeration value="utility"/>
+            <xsd:enumeration value="dialog"/>
+            <xsd:enumeration value="normal"/>
+        </xsd:restriction>
+    </xsd:simpleType>
     <xsd:simpleType name="bool">
         <!-- this is copied to maximization.  Keep that in sync. -->
         <xsd:restriction base="xsd:string">
index 43a2f55..371eb08 100644 (file)
@@ -844,13 +844,15 @@ static ObAppSettings *client_get_settings_state(ObClient *self)
             !g_pattern_match(app->name, strlen(self->name), self->name, NULL))
             match = FALSE;
         else if (app->class &&
-                !g_pattern_match(app->class,
-                                 strlen(self->class), self->class, NULL))
+                 !g_pattern_match(app->class,
+                                  strlen(self->class), self->class, NULL))
             match = FALSE;
         else if (app->role &&
                  !g_pattern_match(app->role,
                                   strlen(self->role), self->role, NULL))
             match = FALSE;
+        else if ((signed)app->type >= 0 && app->type != self->type)
+            match = FALSE;
 
         if (match) {
             ob_debug("Window matching: %s\n", app->name);
index e1954a7..c82e3b3 100644 (file)
@@ -101,6 +101,7 @@ GSList *config_per_app_settings;
 ObAppSettings* config_create_app_settings(void)
 {
     ObAppSettings *settings = g_new0(ObAppSettings, 1);
+    settings->type = -1;
     settings->decor = -1;
     settings->shade = -1;
     settings->monitor = -1;
@@ -124,6 +125,7 @@ void config_app_settings_copy_non_defaults(const ObAppSettings *src,
     g_assert(src != NULL);
     g_assert(dst != NULL);
 
+    copy_if(type, -1);
     copy_if(decor, -1);
     copy_if(shade, -1);
     copy_if(focus, -1);
@@ -193,15 +195,16 @@ static void parse_per_app_settings(ObParseInst *inst, xmlDocPtr doc,
                                    xmlNodePtr node, gpointer data)
 {
     xmlNodePtr app = parse_find_node("application", node->children);
-    gchar *name = NULL, *class = NULL, *role = NULL;
-    gboolean name_set, class_set;
+    gchar *name = NULL, *class = NULL, *role = NULL, *type = NULL;
+    gboolean name_set, class_set, type_set;
     gboolean x_pos_given;
 
     while (app) {
-        name_set = class_set = x_pos_given = FALSE;
+        name_set = class_set = type_set = x_pos_given = FALSE;
 
         class_set = parse_attr_string("class", app, &class);
         name_set = parse_attr_string("name", app, &name);
+        type_set = parse_attr_string("type", app, &type);
         if (class_set || name_set) {
             xmlNodePtr n, c;
             ObAppSettings *settings = config_create_app_settings();;
@@ -212,6 +215,25 @@ static void parse_per_app_settings(ObParseInst *inst, xmlDocPtr doc,
             if (class_set)
                 settings->class = g_pattern_spec_new(class);
 
+            if (type_set) {
+                if (!g_ascii_strcasecmp(type, "normal"))
+                    settings->type = OB_CLIENT_TYPE_NORMAL;
+                else if (!g_ascii_strcasecmp(type, "dialog"))
+                    settings->type = OB_CLIENT_TYPE_DIALOG;
+                else if (!g_ascii_strcasecmp(type, "splash"))
+                    settings->type = OB_CLIENT_TYPE_SPLASH;
+                else if (!g_ascii_strcasecmp(type, "utility"))
+                    settings->type = OB_CLIENT_TYPE_UTILITY;
+                else if (!g_ascii_strcasecmp(type, "menu"))
+                    settings->type = OB_CLIENT_TYPE_MENU;
+                else if (!g_ascii_strcasecmp(type, "toolbar"))
+                    settings->type = OB_CLIENT_TYPE_TOOLBAR;
+                else if (!g_ascii_strcasecmp(type, "dock"))
+                    settings->type = OB_CLIENT_TYPE_DOCK;
+                else if (!g_ascii_strcasecmp(type, "desktop"))
+                    settings->type = OB_CLIENT_TYPE_DESKTOP;
+            }
+
             if (parse_attr_string("role", app, &role))
                 settings->role = g_pattern_spec_new(role);
 
index 3fd1b87..62b9247 100644 (file)
@@ -23,6 +23,7 @@
 #include "misc.h"
 #include "stacking.h"
 #include "place.h"
+#include "client.h"
 #include "geom.h"
 #include "moveresize.h"
 #include "render/render.h"
@@ -38,6 +39,7 @@ struct _ObAppSettings
     GPatternSpec *class;
     GPatternSpec *name;
     GPatternSpec *role;
+    ObClientType  type;
 
     GravityPoint position;
     gboolean pos_given;