Stick an ObClientSetReduce/ExpandFunc directly in the filter definition.
authorDana Jansens <danakj@orodu.net>
Fri, 29 Jul 2011 20:52:59 +0000 (16:52 -0400)
committerDana Jansens <danakj@orodu.net>
Sun, 16 Oct 2011 22:55:15 +0000 (18:55 -0400)
Saves a redirection to the filter just to go to the client_set_reduce/expand
  function.

openbox/action_filter.c
openbox/action_filter.h

index 1c23f6be855fc81bd7dc359fa78ad169d84963cc..e5e9b9baf16a6c4f24cf31149b4afe1984579d6f 100644 (file)
@@ -27,8 +27,8 @@ struct _ObActionFilterDefinition {
     gchar *name;
     ObActionFilterSetupFunc setup;
     ObActionFilterDestroyFunc destroy;
-    ObActionFilterReduceFunc reduce;
-    ObActionFilterExpandFunc expand;
+    ObClientSetReduceFunc reduce;
+    ObClientSetExpandFunc expand;
 };
 
 struct _ObActionFilter {
@@ -60,14 +60,13 @@ void action_filter_shutdown(gboolean reconfig)
 gboolean action_filter_register(const gchar *name,
                                 ObActionFilterSetupFunc setup,
                                 ObActionFilterDestroyFunc destroy,
-                                ObActionFilterReduceFunc reduce,
-                                ObActionFilterExpandFunc expand)
+                                ObClientSetReduceFunc reduce,
+                                ObClientSetExpandFunc expand)
 {
     ObActionFilterDefinition *def;
     GSList *it;
 
     g_return_val_if_fail(name != NULL, FALSE);
-    g_return_val_if_fail(setup != NULL, FALSE);
     g_return_val_if_fail(reduce != NULL, FALSE);
     g_return_val_if_fail(expand != NULL, FALSE);
 
@@ -124,7 +123,7 @@ ObActionFilter* action_filter_new(const gchar *key, struct _ObActionValue *v)
     filter = g_slice_new(ObActionFilter);
     filter->ref = 1;
     filter->def = def;
-    filter->data = def->setup(invert, v);
+    filter->data = def->setup ? def->setup(invert, v) : NULL;
     return filter;
 }
 
@@ -144,11 +143,11 @@ void action_filter_unref(ObActionFilter *f)
 void action_filter_expand(ObActionFilter *f, struct _ObClientSet *set)
 {
     g_return_if_fail(f != NULL);
-    return f->def->expand(set);
+    client_set_expand(set, f->def->expand);
 }
 
 void action_filter_reduce(ObActionFilter *f, struct _ObClientSet *set)
 {
     g_return_if_fail(f != NULL);
-    return f->def->reduce(set);
+    client_set_reduce(set, f->def->reduce);
 }
index d9bf28e13e29f2dcee1d2d17aa239961bc4410e4..4060878bc70b3713eadef6e7156af6f2f2e9e0c7 100644 (file)
    See the COPYING file for a copy of the GNU General Public License.
 */
 
+#include "client_set.h"
+
 #include <glib.h>
 
 struct _ObActionValue;
 struct _ObClient;
-struct _ObClientSet;
 
 typedef struct _ObActionFilter ObActionFilter;
 typedef struct _ObActionFilterFuncs ObActionFilterFuncs;
@@ -29,14 +30,6 @@ typedef enum _ObActionFilterDefault ObActionFilterDefault;
 typedef gpointer (*ObActionFilterSetupFunc)(gboolean invert,
                                             struct _ObActionValue *v);
 typedef void (*ObActionFilterDestroyFunc)(gpointer data);
-/*! Runs the filter and modifies the client set as appropriate.  This function
-  is given a set of clients and may simply remove clients that do not
-  match its criteria. */
-typedef void (*ObActionFilterReduceFunc)(struct _ObClientSet *set);
-/*! Runs the filter and creates a new client set as appropriate.  This function
-  is given a set of clients and must add all unlisted clients possible that
-  match its criteria. */
-typedef void (*ObActionFilterExpandFunc)(struct _ObClientSet *set);
 
 void action_filter_startup(gboolean reconfig);
 void action_filter_shutdown(gboolean reconfig);
@@ -44,12 +37,12 @@ void action_filter_shutdown(gboolean reconfig);
 gboolean action_filter_register(const gchar *name,
                                 ObActionFilterSetupFunc setup,
                                 ObActionFilterDestroyFunc destroy,
-                                ObActionFilterReduceFunc reduce,
-                                ObActionFilterExpandFunc expand);
+                                ObClientSetReduceFunc reduce,
+                                ObClientSetExpandFunc expand);
 
 ObActionFilter* action_filter_new(const gchar *key, struct _ObActionValue *v);
 void action_filter_ref(ObActionFilter *f);
 void action_filter_unref(ObActionFilter *f);
 
-void action_filter_expand(ObActionFilter *f, struct _ObClientSet *set);
-void action_filter_reduce(ObActionFilter *f, struct _ObClientSet *set);
+void action_filter_expand(ObActionFilter *f, ObClientSet *set);
+void action_filter_reduce(ObActionFilter *f, ObClientSet *set);