Fix some compiler warnings
[mikachu/openbox.git] / openbox / actions / if.c
index 7087d6a..411e95c 100644 (file)
@@ -29,9 +29,10 @@ typedef struct {
     gboolean desktop_other;
     guint    desktop_number;
     guint    screendesktop_number;
+    guint    client_monitor;
     GPatternSpec *matchtitle;
     GRegex *regextitle;
-    gchar  *plaintitle;
+    gchar  *exacttitle;
     GSList *thenacts;
     GSList *elseacts;
 } Options;
@@ -45,10 +46,10 @@ void action_if_startup(void)
     actions_register("If", setup_func, free_func, run_func);
 }
 
-static inline set_bool(xmlNodePtr node,
-                       const char *name,
-                       gboolean *on,
-                       gboolean *off)
+static inline void set_bool(xmlNodePtr node,
+                            const char *name,
+                            gboolean *on,
+                            gboolean *off)
 {
     xmlNodePtr n;
 
@@ -101,12 +102,15 @@ static gpointer setup_func(xmlNodePtr node)
                 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, "plain")) {
-                o->plaintitle = g_strdup(s);
+            } 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;
@@ -148,8 +152,8 @@ static void free_func(gpointer options)
         g_pattern_spec_free(o->matchtitle);
     if (o->regextitle)
         g_regex_unref(o->regextitle);
-    if (o->plaintitle)
-        g_free(o->plaintitle);
+    if (o->exacttitle)
+        g_free(o->exacttitle);
 
     g_slice_free(Options, o);
 }
@@ -191,8 +195,10 @@ static gboolean run_func(ObActionsData *data, gpointer options)
          (g_pattern_match_string(o->matchtitle, c->original_title))) &&
         (!o->regextitle ||
          (g_regex_match(o->regextitle, c->original_title, 0, NULL))) &&
-        (!o->plaintitle ||
-         (!strcmp(o->plaintitle, c->original_title))))
+        (!o->exacttitle ||
+         (!strcmp(o->exacttitle, c->original_title))) &&
+        (!o->client_monitor ||
+         (o->client_monitor == client_monitor(c) + 1)))
     {
         acts = o->thenacts;
     }