From: Dana Jansens Date: Thu, 14 Feb 2008 01:53:25 +0000 (-0500) Subject: let you match per-app settings based on the window type X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=27177e498b737cc351ce446f0b89010bcf29bfcd;p=chaz%2Fopenbox let you match per-app settings based on the window type --- diff --git a/data/rc.xml b/data/rc.xml index 98daf274..ebe2f310 100644 --- a/data/rc.xml +++ b/data/rc.xml @@ -642,7 +642,9 @@ + 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. @@ -651,6 +653,9 @@ # 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 diff --git a/data/rc.xsd b/data/rc.xsd index 47eeed12..de227ea1 100644 --- a/data/rc.xsd +++ b/data/rc.xsd @@ -189,10 +189,11 @@ + + - @@ -252,6 +253,18 @@ + + + + + + + + + + + + diff --git a/openbox/client.c b/openbox/client.c index 43a2f551..371eb087 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -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); diff --git a/openbox/config.c b/openbox/config.c index e1954a79..c82e3b3a 100644 --- a/openbox/config.c +++ b/openbox/config.c @@ -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); diff --git a/openbox/config.h b/openbox/config.h index 3fd1b879..62b92473 100644 --- a/openbox/config.h +++ b/openbox/config.h @@ -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;