X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Factions%2Fif.c;h=3f4c4d64f72c15d5f1df8fcb9baa10045d772ab5;hb=7c4fae0312dc7af7578e0fe345cec0a92ea87c9f;hp=35bda4619416cde2a44637f32da5a54200978f69;hpb=5a1da743ca6f8889e9c58aca84a3481c59c6a246;p=chaz%2Fopenbox diff --git a/openbox/actions/if.c b/openbox/actions/if.c index 35bda461..3f4c4d64 100644 --- a/openbox/actions/if.c +++ b/openbox/actions/if.c @@ -29,7 +29,10 @@ typedef struct { gboolean desktop_other; guint desktop_number; guint screendesktop_number; + guint client_monitor; GPatternSpec *matchtitle; + GRegex *regextitle; + gchar *exacttitle; GSList *thenacts; GSList *elseacts; } Options; @@ -91,12 +94,23 @@ static gpointer setup_func(xmlNodePtr node) o->screendesktop_number = obt_xml_node_int(n); } if ((n = obt_xml_find_node(node, "title"))) { - gchar *s; + gchar *s, *type = NULL; if ((s = obt_xml_node_string(n))) { - o->matchtitle = g_pattern_spec_new(s); + if (!obt_xml_attr_string(n, "type", &type) || + !g_ascii_strcasecmp(type, "pattern")) + { + o->matchtitle = g_pattern_spec_new(s); + } else if (type && !g_ascii_strcasecmp(type, "regex")) { + o->regextitle = g_regex_new(s, 0, 0, NULL); + } else if (type && !g_ascii_strcasecmp(type, "exact")) { + o->exacttitle = g_strdup(s); + } g_free(s); } } + if ((n = obt_xml_find_node(node, "monitor"))) { + o->client_monitor = obt_xml_node_int(n); + } if ((n = obt_xml_find_node(node, "then"))) { xmlNodePtr m; @@ -136,6 +150,10 @@ static void free_func(gpointer options) } if (o->matchtitle) g_pattern_spec_free(o->matchtitle); + if (o->regextitle) + g_regex_unref(o->regextitle); + if (o->exacttitle) + g_free(o->exacttitle); g_slice_free(Options, o); } @@ -174,7 +192,13 @@ static gboolean run_func(ObActionsData *data, gpointer options) (c->desktop == DESKTOP_ALL))) && (!o->screendesktop_number || screen_desktop == o->screendesktop_number - 1) && (!o->matchtitle || - (g_pattern_match_string(o->matchtitle, c->original_title)))) + (g_pattern_match_string(o->matchtitle, c->original_title))) && + (!o->regextitle || + (g_regex_match(o->regextitle, c->original_title, 0, NULL))) && + (!o->exacttitle || + (!strcmp(o->exacttitle, c->original_title))) && + (!o->client_monitor || + (o->client_monitor == client_monitor(c) + 1))) { acts = o->thenacts; }