From: Dana Jansens Date: Tue, 2 Aug 2011 19:55:44 +0000 (-0400) Subject: Add action_list_run.c/h with action_list_run() and struct ObActionListRun. X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=8d324820cc8774106cadf6e345b79cbb441996ca;p=dana%2Fopenbox.git Add action_list_run.c/h with action_list_run() and struct ObActionListRun. This function runs an action list, taking over from the function that used to live in action.c. Now the action.c function will simply run a single action. The actions and filters now take a const ObActionListRun* which describes the user event which triggered the actions/filters to run. The action_list_run() function can also run filters, yay. However... TODO: 1. the filters' client sets are not passed to actions yet. do this. 2. make action(s) to change config options includes key and mouse binding 3. rm -rf *xml* --- diff --git a/Makefile.am b/Makefile.am index a80a98a5..ad173a93 100644 --- a/Makefile.am +++ b/Makefile.am @@ -244,6 +244,8 @@ openbox_openbox_SOURCES = \ openbox/action_filter.h \ openbox/action_list.c \ openbox/action_list.h \ + openbox/action_list_run.c \ + openbox/action_list_run.h \ openbox/action_parser.c \ openbox/action_parser.h \ openbox/action_value.c \ diff --git a/openbox/action.c b/openbox/action.c index e962fe60..5810c07c 100644 --- a/openbox/action.c +++ b/openbox/action.c @@ -18,6 +18,7 @@ #include "action.h" #include "action_list.h" +#include "action_list_run.h" #include "action_filter.h" #include "gettext.h" #include "grab.h" @@ -25,6 +26,7 @@ #include "event.h" #include "config.h" #include "client.h" +#include "client_set.h" #include "focus.h" #include "openbox.h" #include "debug.h" @@ -37,8 +39,8 @@ static gboolean action_interactive_begin_act(ObAction *act, guint state); static void action_interactive_end_act(); static ObAction* action_find_by_name(const gchar *name); -static ObAction *interactive_act = NULL; -static guint interactive_initial_state = 0; +static ObAction *current_i_act = NULL; +static guint current_i_initial_state = 0; struct _ObActionDefinition { guint ref; @@ -255,113 +257,79 @@ void action_unref(ObAction *act) } } -static void action_setup_data(ObActionData *data, - ObUserAction uact, - guint state, - gint x, - gint y, - gint button, - ObFrameContext con, - struct _ObClient *client) -{ - data->uact = uact; - data->state = state; - data->x = x; - data->y = y; - data->button = button; - data->context = con; - data->client = client; -} - -gboolean action_run_acts(ObActionList *acts, - ObUserAction uact, - guint state, - gint x, - gint y, - gint button, - ObFrameContext con, - struct _ObClient *client) +gboolean action_run(ObAction *act, const ObActionListRun *data, + struct _ObClientSet *set) { gboolean ran_interactive; gboolean update_user_time; - - /* Don't allow saving the initial state when running things from the - menu */ - if (uact == OB_USER_ACTION_MENU_SELECTION) - state = 0; - /* If x and y are < 0 then use the current pointer position */ - if (x < 0 && y < 0) - screen_pointer_pos(&x, &y); + gboolean run, run_i; ran_interactive = FALSE; update_user_time = FALSE; - while (acts) { - ObAction *act; - ObActionData data; - gboolean ok = TRUE; - - if (acts->isfilter) { - g_warning("filters not implemented!"); - acts = acts->next; - continue; - } - else { - act = acts->u.action; - } - action_setup_data(&data, uact, state, x, y, button, con, client); - - /* if they have the same run function, then we'll assume they are - cooperating and not cancel eachother out */ - if (!interactive_act || interactive_act->def->run != act->def->run) { - if (action_is_interactive(act)) { - /* cancel the old one */ - if (interactive_act) - action_interactive_cancel_act(); - if (act->i_pre) - if (!act->i_pre(state, act->options)) - act->i_input = NULL; /* remove the interactivity */ - ran_interactive = TRUE; - } - /* check again cuz it might have been cancelled */ - if (action_is_interactive(act)) { - ok = action_interactive_begin_act(act, state); - ran_interactive = TRUE; - } - } + /* If we're starting an interactive action: + - if the current interactive action is the same, do nothing and + just use the run function. + - otherwise... + - cancel the current interactive action (if any) + - run the pre function. if it returns false then the action will + not be treated as interactive. + - set up for a new interactive action with action_interactive_begin_act. + this may fail in which case we don't run the action at all. + Then execute the action's run function. + If the action is doing something to the currently focused window, + then we want to update its user_time to indicate it was used by a + human now. + */ + + run_i = FALSE; + if (action_is_interactive(act)) { + ObActionRunFunc this_run = act->def->run; + ObActionRunFunc i_run = (current_i_act ? + current_i_act->def->run : NULL); + + if (i_run && i_run != this_run) + action_interactive_cancel_act(); + run_i = TRUE; + if (i_run != this_run && act->i_pre) + run_i = act->i_pre(data->state, act->options); + } - /* fire the action's run function with this data */ - if (ok) { - if (!act->def->run(&data, act->options)) { - if (action_is_interactive(act)) - action_interactive_end_act(); - if (client && client == focus_client) - update_user_time = TRUE; - } else { - /* make sure its interactive if it returned TRUE */ - g_assert(act->i_input); - - /* no actions are run after the interactive one */ - break; - } + run = TRUE; + if (run_i) { + run = action_interactive_begin_act(act, data->state); + ran_interactive = TRUE; + } + + if (run) { + gboolean end; + + /* XXX pass the set here */ + end = !act->def->run(data, act->options); + g_assert(end || action_is_interactive(act)); + + if (end) { + if (action_is_interactive(act)) + action_interactive_end_act(); + /* XXX else if (client_set_contains(focus_client)) */ + else if (data->client && data->client == focus_client) + event_update_user_time(); } - acts = acts->next; } - if (update_user_time) - event_update_user_time(); + return ran_interactive; } gboolean action_interactive_act_running(void) { - return interactive_act != NULL; + return current_i_act != NULL; } void action_interactive_cancel_act(void) { - if (interactive_act) { - if (interactive_act->i_cancel) - interactive_act->i_cancel(interactive_act->options); + if (current_i_act) { + if (current_i_act->i_cancel) + current_i_act->i_cancel(current_i_act->options); action_interactive_end_act(); } } @@ -369,10 +337,10 @@ void action_interactive_cancel_act(void) static gboolean action_interactive_begin_act(ObAction *act, guint state) { if (grab_keyboard()) { - interactive_act = act; - action_ref(interactive_act); + current_i_act = act; + action_ref(current_i_act); - interactive_initial_state = obt_keyboard_only_modmasks(state); + current_i_initial_state = obt_keyboard_only_modmasks(state); /* if using focus_delay, stop the timer now so that focus doesn't go moving on us, which would kill the action */ @@ -386,13 +354,13 @@ static gboolean action_interactive_begin_act(ObAction *act, guint state) static void action_interactive_end_act(void) { - if (interactive_act) { - ObAction *ia = interactive_act; + if (current_i_act) { + ObAction *ia = current_i_act; /* set this to NULL first so the i_post() function can't cause this to get called again (if it decides it wants to cancel any ongoing interactive action). */ - interactive_act = NULL; + current_i_act = NULL; ungrab_keyboard(); @@ -406,10 +374,10 @@ static void action_interactive_end_act(void) gboolean action_interactive_input_event(XEvent *e) { gboolean used = FALSE; - if (interactive_act) { - if (!interactive_act->i_input(interactive_initial_state, e, - grab_input_context(), - interactive_act->options, &used)) + if (current_i_act) { + if (!current_i_act->i_input(current_i_initial_state, e, + grab_input_context(), + current_i_act->options, &used)) { used = TRUE; /* if it cancelled the action then it has to of been used */ @@ -419,7 +387,7 @@ gboolean action_interactive_input_event(XEvent *e) return used; } -void action_client_move(ObActionData *data, gboolean start) +void action_client_move(const ObActionListRun *data, gboolean start) { static gulong ignore_start = 0; if (start) @@ -458,3 +426,8 @@ void action_client_move(ObActionData *data, gboolean start) event_end_ignore_all_enters(ignore_start); } } + +ObActionDefaultFilter action_default_filter(ObAction *act) +{ + return act->def->def_filter; +} diff --git a/openbox/action.h b/openbox/action.h index 2163154d..e6ec7de5 100644 --- a/openbox/action.h +++ b/openbox/action.h @@ -25,22 +25,25 @@ #include struct _ObActionList; +struct _ObActionListRun; +struct _ObClientSet; typedef struct _ObActionDefinition ObActionDefinition; typedef struct _ObAction ObAction; typedef struct _ObActionData ObActionData; typedef void (*ObActionDataFreeFunc)(gpointer options); -typedef gboolean (*ObActionRunFunc)(ObActionData *data, +typedef gboolean (*ObActionRunFunc)(const struct _ObActionListRun *data, gpointer options); typedef gpointer (*ObActionDataSetupFunc)(GHashTable *config); typedef void (*ObActionShutdownFunc)(void); /* functions for interactive actions */ -/* return TRUE if the action is going to be interactive, or false to change - your mind and make it not */ +/*! Returns TRUE if the action is going to be interactive, or FALSE to change + your mind and make it not. */ typedef gboolean (*ObActionIPreFunc)(guint initial_state, gpointer options); typedef void (*ObActionIPostFunc)(gpointer options); +/*! Returns TRUE to continue the interactive action, and FALSE to end it. */ typedef gboolean (*ObActionIInputFunc)(guint initial_state, XEvent *e, ObtIC *ic, @@ -62,17 +65,6 @@ typedef enum { OB_NUM_ACTION_DEFAULT_FILTERS } ObActionDefaultFilter; -struct _ObActionData { - ObUserAction uact; - guint state; - gint x; - gint y; - gint button; - - struct _ObClient *client; - ObFrameContext context; -}; - void action_startup(gboolean reconfigure); void action_shutdown(gboolean reconfigure); @@ -105,17 +97,13 @@ ObAction* action_new(const gchar *name, GHashTable *config); void action_ref(ObAction *act); void action_unref(ObAction *act); -/*! Runs a list of actions. - @return TRUE if an interactive action was started, FALSE otherwise. +ObActionDefaultFilter action_default_filter(ObAction *act); + +/*! Runs an action. + @return TRUE if an interactive action was started, FALSE otherwise. */ -gboolean action_run_acts(struct _ObActionList *acts, - ObUserAction uact, - guint state, - gint x, - gint y, - gint button, - ObFrameContext con, - struct _ObClient *client); +gboolean action_run(ObAction *act, const struct _ObActionListRun *data, + struct _ObClientSet *set); gboolean action_interactive_act_running(void); void action_interactive_cancel_act(void); @@ -123,4 +111,5 @@ void action_interactive_cancel_act(void); gboolean action_interactive_input_event(XEvent *e); /*! Function for actions to call when they are moving a client around */ -void action_client_move(ObActionData *data, gboolean start); +void action_client_move(const struct _ObActionListRun *data, + gboolean start); diff --git a/openbox/action_filter.c b/openbox/action_filter.c index 0d6c08de..9401fe93 100644 --- a/openbox/action_filter.c +++ b/openbox/action_filter.c @@ -17,6 +17,8 @@ */ #include "action_filter.h" +#include "action_list_run.h" +#include "client_set.h" #include "gettext.h" #include "filters/_all.h" @@ -27,14 +29,14 @@ struct _ObActionFilterDefinition { gchar *name; ObActionFilterSetupFunc setup; ObActionFilterDestroyFunc destroy; - ObClientSetReduceFunc reduce; - ObClientSetExpandFunc expand; + ObActionFilterFunc set; }; struct _ObActionFilter { gint ref; ObActionFilterDefinition *def; + gboolean invert; gpointer data; }; @@ -60,15 +62,13 @@ void action_filter_shutdown(gboolean reconfig) gboolean action_filter_register(const gchar *name, ObActionFilterSetupFunc setup, ObActionFilterDestroyFunc destroy, - ObClientSetReduceFunc reduce, - ObClientSetExpandFunc expand) + ObActionFilterFunc set) { ObActionFilterDefinition *def; GSList *it; g_return_val_if_fail(name != NULL, FALSE); - g_return_val_if_fail(reduce != NULL, FALSE); - g_return_val_if_fail(expand != NULL, FALSE); + g_return_val_if_fail(set != NULL, FALSE); for (it = registered; it; it = it->next) { def = it->data; @@ -80,8 +80,7 @@ gboolean action_filter_register(const gchar *name, def->name = g_strdup(name); def->setup = setup; def->destroy = destroy; - def->reduce = reduce; - def->expand = expand; + def->set = set; registered = g_slist_prepend(registered, def); return TRUE; @@ -123,6 +122,7 @@ ObActionFilter* action_filter_new(const gchar *key, struct _ObActionValue *v) filter = g_slice_new(ObActionFilter); filter->ref = 1; filter->def = def; + filter->invert = invert; filter->data = def->setup ? def->setup(invert, v) : NULL; return filter; } @@ -140,14 +140,8 @@ void action_filter_unref(ObActionFilter *f) } } -void action_filter_expand(ObActionFilter *f, struct _ObClientSet *set) -{ - g_return_if_fail(f != NULL); - client_set_expand(set, f->def->expand, f->data); -} - -void action_filter_reduce(ObActionFilter *f, struct _ObClientSet *set) +struct _ObClientSet* action_filter_set(ObActionFilter *f, + const ObActionListRun *run) { - g_return_if_fail(f != NULL); - client_set_reduce(set, f->def->reduce, f->data); + return f->def->set(f->invert, run, f->data); } diff --git a/openbox/action_filter.h b/openbox/action_filter.h index 4060878b..71375e31 100644 --- a/openbox/action_filter.h +++ b/openbox/action_filter.h @@ -16,12 +16,12 @@ See the COPYING file for a copy of the GNU General Public License. */ -#include "client_set.h" - #include +struct _ObActionListRun; struct _ObActionValue; struct _ObClient; +struct _ObClientSet; typedef struct _ObActionFilter ObActionFilter; typedef struct _ObActionFilterFuncs ObActionFilterFuncs; @@ -30,19 +30,35 @@ typedef enum _ObActionFilterDefault ObActionFilterDefault; typedef gpointer (*ObActionFilterSetupFunc)(gboolean invert, struct _ObActionValue *v); typedef void (*ObActionFilterDestroyFunc)(gpointer data); +typedef struct _ObClientSet* (*ObActionFilterFunc)( + gboolean invert, const struct _ObActionListRun *run, gpointer data); void action_filter_startup(gboolean reconfig); void action_filter_shutdown(gboolean reconfig); +/*! Registers a filter test in the system. + @name The name of the key for the filter. [foo] or [foo=bar] would register + "foo" as its name. + @setup A setup function which takes the parameter given to the filter. + This would receive the bar in [foo=bar]. This returns a pointer to data + used by the filter. + @destroy Destroys the data returned from @setup. + @filter A function that returns an ObClientSet* of clients that this filter + includes. + @return TRUE if the registration was successful. +*/ gboolean action_filter_register(const gchar *name, ObActionFilterSetupFunc setup, ObActionFilterDestroyFunc destroy, - ObClientSetReduceFunc reduce, - ObClientSetExpandFunc expand); + ObActionFilterFunc set); 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, ObClientSet *set); -void action_filter_reduce(ObActionFilter *f, ObClientSet *set); +/*! Returns a set of clients for a filter. + @f The filter. + @run Data for the user event which caused this filter to be run. +*/ +struct _ObClientSet* action_filter_set(ObActionFilter *f, + const struct _ObActionListRun *run); diff --git a/openbox/action_list.c b/openbox/action_list.c index c6c50608..30b46fed 100644 --- a/openbox/action_list.c +++ b/openbox/action_list.c @@ -18,6 +18,7 @@ #include "action_list.h" #include "action.h" +#include "action_filter.h" #include "action_value.h" #include @@ -32,7 +33,7 @@ void action_list_unref(ObActionList *l) while (l && --l->ref < 1) { ObActionList *n = l->next; - if (l->isfilter) { + if (l->isfilterset) { action_list_test_destroy(l->u.f.test); action_list_unref(l->u.f.thendo); action_list_unref(l->u.f.elsedo); @@ -50,8 +51,7 @@ void action_list_test_destroy(ObActionListTest *t) while (t) { ObActionListTest *n = t->next; - g_free(t->key); - action_value_unref(t->value); + action_filter_unref(t->filter); g_slice_free(ObActionListTest, t); t = n; } diff --git a/openbox/action_list.h b/openbox/action_list.h index 4e2dcb2e..b3ead24a 100644 --- a/openbox/action_list.h +++ b/openbox/action_list.h @@ -19,6 +19,7 @@ #include struct _ObActionAct; +struct _ObActionFilter; struct _ObActionValue; typedef struct _ObActionList ObActionList; @@ -28,9 +29,9 @@ typedef struct _ObActionListTest ObActionListTest; an action). */ struct _ObActionList { gint ref; - gboolean isfilter; + gboolean isfilterset; union { - struct _ObActionListFilter { + struct _ObActionListFilterSet { ObActionListTest *test; /* can be null */ ObActionList *thendo; /* can be null */ ObActionList *elsedo; /* can be null */ @@ -41,8 +42,7 @@ struct _ObActionList { }; struct _ObActionListTest { - gchar *key; - struct _ObActionValue *value; /* can be null */ + struct _ObActionFilter *filter; gboolean and; ObActionListTest *next; }; diff --git a/openbox/action_list_run.c b/openbox/action_list_run.c new file mode 100644 index 00000000..5e2af95d --- /dev/null +++ b/openbox/action_list_run.c @@ -0,0 +1,168 @@ +/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- + + action_list_run.c for the Openbox window manager + Copyright (c) 2011 Dana Jansens + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + See the COPYING file for a copy of the GNU General Public License. +*/ + +#include "action_list_run.h" +#include "action.h" +#include "action_filter.h" +#include "action_list.h" +#include "client.h" +#include "client_set.h" +#include "event.h" +#include "screen.h" + +static gboolean run_list(ObActionList *acts, const ObActionListRun *data, + ObClientSet *set); +static gboolean run_filter(ObActionList *acts, const ObActionListRun *data, + ObClientSet *set); + +gboolean action_list_run(ObActionList *acts, + ObUserAction uact, + guint state, + gint x, + gint y, + gint button, + ObFrameContext con, + struct _ObClient *client) +{ + ObActionListRun action_data; + + g_return_val_if_fail(acts != NULL, FALSE); + if (acts == NULL) return FALSE; + + /* Don't save the initial mod state when running things from the menu */ + if (uact == OB_USER_ACTION_MENU_SELECTION) + state = 0; + /* If x and y are < 0 then use the current pointer position */ + if (x < 0 && y < 0) + screen_pointer_pos(&x, &y); + + action_data.uact = uact; + action_data.state = state; + action_data.x = x; + action_data.y = y; + action_data.button = button; + action_data.context = con; + action_data.client = client; + /* if a pointer started the event clicking on a window, it must be under + the pointer */ + action_data.pointer_over = client ? client : client_under_pointer(); + + return run_list(acts, &action_data, NULL); +} + +static gboolean run_list(ObActionList *acts, const ObActionListRun *data, + ObClientSet *set) +{ + gboolean interactive; + ObClientSet *myset; + + if (!acts) return FALSE; + if (acts->isfilterset) return run_filter(acts, data, set); + + /* if we're not given a filter, then make a default filter set, + but don't pass it on to our siblings in the list. */ + myset = set; + if (!myset) { + switch (action_default_filter(acts->u.action)) { + case OB_ACTION_DEFAULT_FILTER_SINGLE: + myset = client_set_single(data->client); break; + case OB_ACTION_DEFAULT_FILTER_EMPTY: + myset = client_set_empty(); break; + case OB_ACTION_DEFAULT_FILTER_ALL: + myset = client_set_all(); break; + case OB_NUM_ACTION_DEFAULT_FILTERS: + default: g_assert_not_reached(); + } + } + + interactive = action_run(acts->u.action, data, myset); + if (set != myset) client_set_destroy(myset); + + if (interactive) return TRUE; + return run_list(acts->next, data, set); +} + +static gboolean run_filter(ObActionList *acts, const ObActionListRun *data, + ObClientSet *incoming_set) +{ + ObActionListTest *test = acts->u.f.test; + ObClientSet *set, *and_set; + gboolean prev_and; + gboolean interactive; + + /* (a ^ b) | c | (d ^ e ^ f) | (g ^ h) + + - for each test in the filter: + 1) when we are at the first test, we make the test's set our current + set + 2) when we are between two ORs, we add the test's set to our current + set + 3) when we are to the left of an OR (or at the last test), we + intersect our test's set to the and_set, and then add the add_set + to our current set + 4) otherwise, we are to the left of an AND + a) if we are to the right of an OR, we make and_set our test's set + b) else we are between two ANDs, so we intersect and_set with + the test's set + - finally, we take the intersection of our created set with the + incoming set. + */ + + g_assert(test != NULL); + + and_set = NULL; + + set = action_filter_set(test->filter, data); + prev_and = test->and; + test = test->next; + while (test) { + ObClientSet *const test_set = action_filter_set(test->filter, data); + + if (!prev_and && test->next && !test->and) + set = client_set_union(set, test_set); + else if (!test->and || !test->next) { + if (and_set) + and_set = client_set_intersection(and_set, test_set); + else + and_set = test_set; + set = client_set_union(set, and_set); + and_set = NULL; + } + else { + if (and_set) + and_set = client_set_intersection(and_set, test_set); + else + and_set = test_set; + } + test = test->next; + } + + if (incoming_set) { + /* we don't want to destroy the incoming set so make a copy of it */ + set = client_set_intersection(set, client_set_clone(incoming_set)); + } + + if (client_set_test_boolean(set)) + interactive = run_list(acts->u.f.thendo, data, set); + else + interactive = run_list(acts->u.f.elsedo, data, set); + client_set_destroy(set); + + if (interactive) return TRUE; + return run_list(acts->next, data, incoming_set); +} diff --git a/openbox/action_list_run.h b/openbox/action_list_run.h new file mode 100644 index 00000000..044af78d --- /dev/null +++ b/openbox/action_list_run.h @@ -0,0 +1,65 @@ +/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- + + action_list_run.h for the Openbox window manager + Copyright (c) 2011 Dana Jansens + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + See the COPYING file for a copy of the GNU General Public License. +*/ + +#include "misc.h" +#include "frame.h" + +#include + +typedef struct _ObActionListRun ObActionListRun; + +struct _ObActionList; + +/*! This structure holds data about the user event which triggers running an + action list and the filters/actions within it. + All action list executions must come from some user event, and this describes + it. +*/ +struct _ObActionListRun { + ObUserAction uact; + guint state; + + gint x; + gint y; + gint button; + ObFrameContext context; + struct _ObClient *client; + struct _ObClient *pointer_over; +}; + +/*! Run an action list. + @acts The list of actions to run. + @state The current state of the keyboard modifiers. + @x The x coordinate of the pointer. + @y The y coordinate of the pointer. + @button The button used to initiate the action list (if a pointer + initiated it). + @con The frame context on which the pointer button was used to initiate the + action list. + @client The client on which the pointer button was used to initiate the + action list. + @return TRUE if an interactive action was started, or FALSE otherwise. +*/ +gboolean action_list_run(struct _ObActionList *acts, + ObUserAction uact, + guint state, + gint x, + gint y, + gint button, + ObFrameContext con, + struct _ObClient *client); diff --git a/openbox/action_parser.c b/openbox/action_parser.c index 0424bdbd..2b328cd1 100644 --- a/openbox/action_parser.c +++ b/openbox/action_parser.c @@ -18,6 +18,7 @@ #include "action_parser.h" #include "action.h" +#include "action_filter.h" #include "action_list.h" #include "action_value.h" #include "gettext.h" @@ -263,7 +264,7 @@ ObActionList* parse_action(ObActionParser *p, gboolean *e) al = g_slice_new(ObActionList); al->ref = 1; - al->isfilter = FALSE; + al->isfilterset = FALSE; al->u.action = action_new(name, config); al->next = NULL; g_free(name); @@ -301,7 +302,7 @@ ObActionList* parse_filter(ObActionParser *p, gboolean *e) al = g_slice_new(ObActionList); al->ref = 1; - al->isfilter = TRUE; + al->isfilterset = TRUE; al->u.f.test = test; al->u.f.thendo = thendo; al->u.f.elsedo = elsedo; @@ -315,6 +316,7 @@ ObActionListTest* parse_filter_test(ObActionParser *p, gboolean *e) gchar *key; ObActionValue *value; gboolean and; + ObActionFilter *filter; ObActionListTest *next; t = g_scanner_get_next_token(p->scan); @@ -345,6 +347,19 @@ ObActionListTest* parse_filter_test(ObActionParser *p, gboolean *e) return NULL; } + filter = action_filter_new(key, value); + if (!filter) { + gchar *m; + m = g_strdup_printf(_("Unable to create filter: %s"), key); + parse_error(p, G_TOKEN_NONE, m, e); + g_free(m); + } + + g_free(key); + action_value_unref(value); + if (!filter) + return NULL; + /* check if there is another test and how we're connected */ t = g_scanner_get_next_token(p->scan); if (t == ',') { /* and */ @@ -362,8 +377,7 @@ ObActionListTest* parse_filter_test(ObActionParser *p, gboolean *e) /* don't allow any errors */ if (*e) { - g_free(key); - action_value_unref(value); + action_filter_unref(filter); action_list_test_destroy(next); return NULL; } @@ -371,8 +385,7 @@ ObActionListTest* parse_filter_test(ObActionParser *p, gboolean *e) ObActionListTest *test; test = g_slice_new(ObActionListTest); - test->key = key; - test->value = value; + test->filter = filter; test->and = and; test->next = next; return test; diff --git a/openbox/actions/addremovedesktop.c b/openbox/actions/addremovedesktop.c index 6c4593a9..22158daf 100644 --- a/openbox/actions/addremovedesktop.c +++ b/openbox/actions/addremovedesktop.c @@ -1,4 +1,5 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/action_value.h" #include "openbox/screen.h" #include @@ -12,7 +13,7 @@ static gpointer setup_func(GHashTable *config); static gpointer setup_add_func(GHashTable *config); static gpointer setup_remove_func(GHashTable *config); static void free_func(gpointer o); -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); void action_addremovedesktop_startup(void) { @@ -61,7 +62,7 @@ static void free_func(gpointer o) } /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { Options *o = options; diff --git a/openbox/actions/breakchroot.c b/openbox/actions/breakchroot.c index 56e90a46..de2da715 100644 --- a/openbox/actions/breakchroot.c +++ b/openbox/actions/breakchroot.c @@ -1,7 +1,8 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/keyboard.h" -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); void action_breakchroot_startup(void) { @@ -12,7 +13,7 @@ void action_breakchroot_startup(void) } /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { /* break out of one chroot */ keyboard_reset_chains(1); diff --git a/openbox/actions/close.c b/openbox/actions/close.c index d3e5770c..250bd1f2 100644 --- a/openbox/actions/close.c +++ b/openbox/actions/close.c @@ -1,7 +1,8 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/client.h" -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); void action_close_startup(void) { @@ -10,7 +11,7 @@ void action_close_startup(void) } /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { if (data->client) client_close(data->client); diff --git a/openbox/actions/cyclewindows.c b/openbox/actions/cyclewindows.c index 9ce5f5fe..0087f8d5 100644 --- a/openbox/actions/cyclewindows.c +++ b/openbox/actions/cyclewindows.c @@ -1,5 +1,6 @@ #include "openbox/action.h" #include "openbox/action_list.h" +#include "openbox/action_list_run.h" #include "openbox/action_parser.h" #include "openbox/action_value.h" #include "openbox/stacking.h" @@ -44,7 +45,7 @@ static gpointer setup_backward_func(GHashTable *config, ObActionICancelFunc *c, ObActionIPostFunc *post); static void free_func(gpointer options); -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); static gboolean i_input_func(guint initial_state, XEvent *e, ObtIC *ic, @@ -156,7 +157,7 @@ static void free_func(gpointer options) g_slice_free(Options, o); } -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { Options *o = options; struct _ObClient *ft; @@ -246,7 +247,7 @@ static void i_post_func(gpointer options) TRUE, o->cancel); if (ft) - action_run_acts(o->actions, OB_USER_ACTION_KEYBOARD_KEY, + action_list_run(o->actions, OB_USER_ACTION_KEYBOARD_KEY, o->state, -1, -1, 0, OB_FRAME_CONTEXT_NONE, ft); stacking_restore(); diff --git a/openbox/actions/debug.c b/openbox/actions/debug.c index c575a022..74e47232 100644 --- a/openbox/actions/debug.c +++ b/openbox/actions/debug.c @@ -1,4 +1,5 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/action_value.h" #include @@ -8,7 +9,7 @@ typedef struct { static gpointer setup_func(GHashTable *config); static void free_func(gpointer options); -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); void action_debug_startup(void) { @@ -37,7 +38,7 @@ static void free_func(gpointer options) } /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { Options *o = options; diff --git a/openbox/actions/decorations.c b/openbox/actions/decorations.c index c75ca11b..5e1f956b 100644 --- a/openbox/actions/decorations.c +++ b/openbox/actions/decorations.c @@ -1,9 +1,10 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/client.h" -static gboolean run_func_on(ObActionData *data, gpointer options); -static gboolean run_func_off(ObActionData *data, gpointer options); -static gboolean run_func_toggle(ObActionData *data, gpointer options); +static gboolean run_func_on(const ObActionListRun *data, gpointer options); +static gboolean run_func_off(const ObActionListRun *data, gpointer options); +static gboolean run_func_toggle(const ObActionListRun *data, gpointer options); void action_decorations_startup(void) { @@ -16,7 +17,7 @@ void action_decorations_startup(void) } /* Always return FALSE because its not interactive */ -static gboolean run_func_on(ObActionData *data, gpointer options) +static gboolean run_func_on(const ObActionListRun *data, gpointer options) { if (data->client) { action_client_move(data, TRUE); @@ -27,7 +28,7 @@ static gboolean run_func_on(ObActionData *data, gpointer options) } /* Always return FALSE because its not interactive */ -static gboolean run_func_off(ObActionData *data, gpointer options) +static gboolean run_func_off(const ObActionListRun *data, gpointer options) { if (data->client) { action_client_move(data, TRUE); @@ -38,7 +39,7 @@ static gboolean run_func_off(ObActionData *data, gpointer options) } /* Always return FALSE because its not interactive */ -static gboolean run_func_toggle(ObActionData *data, gpointer options) +static gboolean run_func_toggle(const ObActionListRun *data, gpointer options) { if (data->client) { action_client_move(data, TRUE); diff --git a/openbox/actions/desktop.c b/openbox/actions/desktop.c index 3f926e64..e86b7378 100644 --- a/openbox/actions/desktop.c +++ b/openbox/actions/desktop.c @@ -1,4 +1,5 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/action_value.h" #include "openbox/screen.h" #include "openbox/client.h" @@ -41,7 +42,7 @@ static gpointer setup_send_func(GHashTable *config, ObActionICancelFunc *cancel, ObActionIPostFunc *post); static void free_func(gpointer o); -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); static gboolean i_pre_func(guint state, gpointer options); static gboolean i_input_func(guint initial_state, @@ -178,7 +179,7 @@ static void free_func(gpointer o) g_slice_free(Options, o); } -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { Options *o = options; guint d; diff --git a/openbox/actions/directionalwindows.c b/openbox/actions/directionalwindows.c index 102594d1..05777d4e 100644 --- a/openbox/actions/directionalwindows.c +++ b/openbox/actions/directionalwindows.c @@ -1,5 +1,6 @@ #include "openbox/action.h" #include "openbox/action_list.h" +#include "openbox/action_list_run.h" #include "openbox/action_parser.h" #include "openbox/action_value.h" #include "openbox/event.h" @@ -32,7 +33,7 @@ static gpointer setup_cycle_func(GHashTable *config, ObActionIPostFunc *post); static gpointer setup_target_func(GHashTable *config); static void free_func(gpointer options); -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); static gboolean i_input_func(guint initial_state, XEvent *e, ObtIC *ic, @@ -144,7 +145,7 @@ static void free_func(gpointer options) g_slice_free(Options, o); } -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { Options *o = options; @@ -231,7 +232,7 @@ static void end_cycle(gboolean cancel, guint state, Options *o) cycling = FALSE; if (ft) - action_run_acts(o->actions, OB_USER_ACTION_KEYBOARD_KEY, + action_list_run(o->actions, OB_USER_ACTION_KEYBOARD_KEY, state, -1, -1, 0, OB_FRAME_CONTEXT_NONE, ft); stacking_restore(); diff --git a/openbox/actions/dock.c b/openbox/actions/dock.c index b20dd7e5..d3aa2258 100644 --- a/openbox/actions/dock.c +++ b/openbox/actions/dock.c @@ -1,10 +1,11 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/stacking.h" #include "openbox/window.h" #include "openbox/dock.h" -static gboolean raise_func(ObActionData *data, gpointer options); -static gboolean lower_func(ObActionData *data, gpointer options); +static gboolean raise_func(const ObActionListRun *data, gpointer options); +static gboolean lower_func(const ObActionListRun *data, gpointer options); void action_dock_startup(void) { @@ -15,7 +16,7 @@ void action_dock_startup(void) } /* Always return FALSE because its not interactive */ -static gboolean raise_func(ObActionData *data, gpointer options) +static gboolean raise_func(const ObActionListRun *data, gpointer options) { action_client_move(data, TRUE); dock_raise_dock(); @@ -25,7 +26,7 @@ static gboolean raise_func(ObActionData *data, gpointer options) } /* Always return FALSE because its not interactive */ -static gboolean lower_func(ObActionData *data, gpointer options) +static gboolean lower_func(const ObActionListRun *data, gpointer options) { action_client_move(data, TRUE); dock_lower_dock(); diff --git a/openbox/actions/dockautohide.c b/openbox/actions/dockautohide.c index 163cd948..6b31d873 100644 --- a/openbox/actions/dockautohide.c +++ b/openbox/actions/dockautohide.c @@ -1,8 +1,9 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/dock.h" #include "openbox/config.h" -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); void action_dockautohide_startup(void) { @@ -11,7 +12,7 @@ void action_dockautohide_startup(void) } /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { config_dock_hide = !config_dock_hide; dock_configure(); diff --git a/openbox/actions/execute.c b/openbox/actions/execute.c index 43463d52..f7825fb1 100644 --- a/openbox/actions/execute.c +++ b/openbox/actions/execute.c @@ -1,4 +1,5 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/action_value.h" #include "openbox/event.h" #include "openbox/startupnotify.h" @@ -19,12 +20,12 @@ typedef struct { gchar *sn_icon; gchar *sn_wmclass; gchar *prompt; - ObActionData *data; + ObActionListRun *data; } Options; static gpointer setup_func(GHashTable *config); static void free_func(gpointer options); -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); static void shutdown_func(void); static void client_dest(ObClient *client, gpointer data); @@ -98,12 +99,12 @@ static void free_func(gpointer options) g_free(o->sn_icon); g_free(o->sn_wmclass); g_free(o->prompt); - if (o->data) g_slice_free(ObActionData, o->data); + if (o->data) g_slice_free(ObActionListRun, o->data); g_slice_free(Options, o); } } -static Options* dup_options(Options *in, ObActionData *data) +static Options* dup_options(Options *in, const ObActionListRun *data) { Options *o = g_slice_new(Options); o->cmd = g_strdup(in->cmd); @@ -112,8 +113,8 @@ static Options* dup_options(Options *in, ObActionData *data) o->sn_icon = g_strdup(in->sn_icon); o->sn_wmclass = g_strdup(in->sn_wmclass); o->prompt = NULL; - o->data = g_slice_new(ObActionData); - memcpy(o->data, data, sizeof(ObActionData)); + o->data = g_slice_new(ObActionListRun); + memcpy(o->data, data, sizeof(ObActionListRun)); return o; } @@ -132,7 +133,7 @@ static void prompt_cleanup(ObPrompt *p, gpointer options) } /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { GError *e; gchar **argv = NULL; diff --git a/openbox/actions/exit.c b/openbox/actions/exit.c index 8c9636b1..5be209e3 100644 --- a/openbox/actions/exit.c +++ b/openbox/actions/exit.c @@ -1,4 +1,5 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/action_value.h" #include "openbox/openbox.h" #include "openbox/prompt.h" @@ -11,7 +12,7 @@ typedef struct { static gpointer setup_func(GHashTable *config); static void free_func(gpointer o); -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); void action_exit_startup(void) { @@ -61,7 +62,7 @@ static void prompt_cleanup(ObPrompt *p, gpointer data) /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { Options *o = options; diff --git a/openbox/actions/focus.c b/openbox/actions/focus.c index ebf55c8d..9bc5c09c 100644 --- a/openbox/actions/focus.c +++ b/openbox/actions/focus.c @@ -1,4 +1,5 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/action_value.h" #include "openbox/event.h" #include "openbox/client.h" @@ -12,7 +13,7 @@ typedef struct { static gpointer setup_func(GHashTable *config); static void free_func(gpointer o); -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); void action_focus_startup(void) { @@ -43,7 +44,7 @@ static void free_func(gpointer o) } /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { Options *o = options; diff --git a/openbox/actions/focustobottom.c b/openbox/actions/focustobottom.c index 4e0af5e1..afaa80ef 100644 --- a/openbox/actions/focustobottom.c +++ b/openbox/actions/focustobottom.c @@ -1,7 +1,8 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/focus.h" -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); void action_focustobottom_startup(void) { @@ -10,7 +11,7 @@ void action_focustobottom_startup(void) } /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { if (data->client) focus_order_to_bottom(data->client); diff --git a/openbox/actions/fullscreen.c b/openbox/actions/fullscreen.c index f87a1d89..25a94fa8 100644 --- a/openbox/actions/fullscreen.c +++ b/openbox/actions/fullscreen.c @@ -1,7 +1,8 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/client.h" -static gboolean run_func_toggle(ObActionData *data, gpointer options); +static gboolean run_func_toggle(const ObActionListRun *data, gpointer options); void action_fullscreen_startup(void) { @@ -10,7 +11,7 @@ void action_fullscreen_startup(void) } /* Always return FALSE because its not interactive */ -static gboolean run_func_toggle(ObActionData *data, gpointer options) +static gboolean run_func_toggle(const ObActionListRun *data, gpointer options) { if (data->client) { action_client_move(data, TRUE); diff --git a/openbox/actions/growtoedge.c b/openbox/actions/growtoedge.c index 8ddc2cad..c254474b 100644 --- a/openbox/actions/growtoedge.c +++ b/openbox/actions/growtoedge.c @@ -1,4 +1,5 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/action_value.h" #include "openbox/misc.h" #include "openbox/client.h" @@ -14,7 +15,7 @@ typedef struct { static gpointer setup_func(GHashTable *config); static gpointer setup_shrink_func(GHashTable *config); static void free_func(gpointer o); -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); void action_growtoedge_startup(void) { @@ -63,7 +64,7 @@ static gpointer setup_shrink_func(GHashTable *config) return o; } -static gboolean do_grow(ObActionData *data, gint x, gint y, gint w, gint h) +static gboolean do_grow(const ObActionListRun *data, gint x, gint y, gint w, gint h) { gint realw, realh, lw, lh; @@ -94,7 +95,7 @@ static void free_func(gpointer o) } /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { Options *o = options; gint x, y, w, h; diff --git a/openbox/actions/iconify.c b/openbox/actions/iconify.c index 9b467200..1bfc9cc8 100644 --- a/openbox/actions/iconify.c +++ b/openbox/actions/iconify.c @@ -1,7 +1,8 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/client.h" -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); void action_iconify_startup(void) { @@ -10,7 +11,7 @@ void action_iconify_startup(void) } /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { if (data->client) { action_client_move(data, TRUE); diff --git a/openbox/actions/kill.c b/openbox/actions/kill.c index 925f02f9..b2d56cc7 100644 --- a/openbox/actions/kill.c +++ b/openbox/actions/kill.c @@ -1,7 +1,8 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/client.h" -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); void action_kill_startup(void) { @@ -10,7 +11,7 @@ void action_kill_startup(void) } /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { if (data->client) client_kill(data->client); diff --git a/openbox/actions/layer.c b/openbox/actions/layer.c index 21e7b4cc..33d89612 100644 --- a/openbox/actions/layer.c +++ b/openbox/actions/layer.c @@ -1,4 +1,5 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/action_value.h" #include "openbox/client.h" @@ -11,7 +12,7 @@ static gpointer setup_func_top(GHashTable *config); static gpointer setup_func_bottom(GHashTable *config); static gpointer setup_func_send(GHashTable *config); static void free_func(gpointer o); -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); void action_layer_startup(void) { @@ -69,7 +70,7 @@ static void free_func(gpointer o) } /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { Options *o = options; diff --git a/openbox/actions/lower.c b/openbox/actions/lower.c index b468cb29..06896c55 100644 --- a/openbox/actions/lower.c +++ b/openbox/actions/lower.c @@ -1,8 +1,9 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/stacking.h" #include "openbox/window.h" -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); void action_lower_startup(void) { @@ -11,7 +12,7 @@ void action_lower_startup(void) } /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { if (data->client) { action_client_move(data, TRUE); diff --git a/openbox/actions/maximize.c b/openbox/actions/maximize.c index b2f95872..b8543a1b 100644 --- a/openbox/actions/maximize.c +++ b/openbox/actions/maximize.c @@ -1,4 +1,5 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/action_value.h" #include "openbox/client.h" @@ -15,9 +16,9 @@ typedef struct { static gpointer setup_func(GHashTable *config); static void free_func(gpointer o); -static gboolean run_func_on(ObActionData *data, gpointer options); -static gboolean run_func_off(ObActionData *data, gpointer options); -static gboolean run_func_toggle(ObActionData *data, gpointer options); +static gboolean run_func_on(const ObActionListRun *data, gpointer options); +static gboolean run_func_off(const ObActionListRun *data, gpointer options); +static gboolean run_func_toggle(const ObActionListRun *data, gpointer options); void action_maximize_startup(void) { @@ -57,7 +58,7 @@ static void free_func(gpointer o) } /* Always return FALSE because its not interactive */ -static gboolean run_func_on(ObActionData *data, gpointer options) +static gboolean run_func_on(const ObActionListRun *data, gpointer options) { Options *o = options; if (data->client) { @@ -69,7 +70,7 @@ static gboolean run_func_on(ObActionData *data, gpointer options) } /* Always return FALSE because its not interactive */ -static gboolean run_func_off(ObActionData *data, gpointer options) +static gboolean run_func_off(const ObActionListRun *data, gpointer options) { Options *o = options; if (data->client) { @@ -81,7 +82,7 @@ static gboolean run_func_off(ObActionData *data, gpointer options) } /* Always return FALSE because its not interactive */ -static gboolean run_func_toggle(ObActionData *data, gpointer options) +static gboolean run_func_toggle(const ObActionListRun *data, gpointer options) { Options *o = options; if (data->client) { diff --git a/openbox/actions/move.c b/openbox/actions/move.c index 4707de35..7ec72739 100644 --- a/openbox/actions/move.c +++ b/openbox/actions/move.c @@ -1,8 +1,9 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/moveresize.h" #include "obt/prop.h" -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); void action_move_startup(void) { @@ -11,7 +12,7 @@ void action_move_startup(void) } /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { if (data->client) { guint32 corner; diff --git a/openbox/actions/moverelative.c b/openbox/actions/moverelative.c index e1125abd..47d5a8a0 100644 --- a/openbox/actions/moverelative.c +++ b/openbox/actions/moverelative.c @@ -1,4 +1,5 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/action_value.h" #include "openbox/client.h" #include "openbox/screen.h" @@ -14,7 +15,7 @@ typedef struct { static gpointer setup_func(GHashTable *config); static void free_func(gpointer o); -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); void action_moverelative_startup(void) { @@ -45,7 +46,7 @@ static void free_func(gpointer o) } /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { Options *o = options; diff --git a/openbox/actions/moveresizeto.c b/openbox/actions/moveresizeto.c index af3202dc..da300e62 100644 --- a/openbox/actions/moveresizeto.c +++ b/openbox/actions/moveresizeto.c @@ -1,4 +1,5 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/action_value.h" #include "openbox/client.h" #include "openbox/screen.h" @@ -24,7 +25,7 @@ typedef struct { static gpointer setup_func(GHashTable *config); static void free_func(gpointer o); -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); void action_moveresizeto_startup(void) { @@ -84,7 +85,7 @@ static void free_func(gpointer o) } /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { Options *o = options; diff --git a/openbox/actions/movetoedge.c b/openbox/actions/movetoedge.c index cd99d1b8..018a075c 100644 --- a/openbox/actions/movetoedge.c +++ b/openbox/actions/movetoedge.c @@ -1,4 +1,5 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/action_value.h" #include "openbox/misc.h" #include "openbox/client.h" @@ -12,7 +13,7 @@ typedef struct { static gpointer setup_func(GHashTable *config); static void free_func(gpointer o); -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); void action_movetoedge_startup(void) { @@ -54,7 +55,7 @@ static void free_func(gpointer o) } /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { Options *o = options; diff --git a/openbox/actions/omnipresent.c b/openbox/actions/omnipresent.c index 3121fac3..1a6c91d5 100644 --- a/openbox/actions/omnipresent.c +++ b/openbox/actions/omnipresent.c @@ -1,8 +1,9 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/client.h" #include "openbox/screen.h" -static gboolean run_func_toggle(ObActionData *data, gpointer options); +static gboolean run_func_toggle(const ObActionListRun *data, gpointer options); void action_omnipresent_startup(void) { @@ -11,7 +12,7 @@ void action_omnipresent_startup(void) } /* Always return FALSE because its not interactive */ -static gboolean run_func_toggle(ObActionData *data, gpointer options) +static gboolean run_func_toggle(const ObActionListRun *data, gpointer options) { if (data->client) { action_client_move(data, TRUE); diff --git a/openbox/actions/raise.c b/openbox/actions/raise.c index 283b07be..da5389be 100644 --- a/openbox/actions/raise.c +++ b/openbox/actions/raise.c @@ -1,8 +1,9 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/stacking.h" #include "openbox/window.h" -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); void action_raise_startup(void) { @@ -11,7 +12,7 @@ void action_raise_startup(void) } /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { if (data->client) { action_client_move(data, TRUE); diff --git a/openbox/actions/raiselower.c b/openbox/actions/raiselower.c index 9231b608..63f471a6 100644 --- a/openbox/actions/raiselower.c +++ b/openbox/actions/raiselower.c @@ -1,7 +1,8 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/stacking.h" -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); void action_raiselower_startup(void) { @@ -10,7 +11,7 @@ void action_raiselower_startup(void) } /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { if (data->client) { action_client_move(data, TRUE); diff --git a/openbox/actions/reconfigure.c b/openbox/actions/reconfigure.c index 66f4a80b..13966c4d 100644 --- a/openbox/actions/reconfigure.c +++ b/openbox/actions/reconfigure.c @@ -1,7 +1,8 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/openbox.h" -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); void action_reconfigure_startup(void) { @@ -10,7 +11,7 @@ void action_reconfigure_startup(void) } /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { ob_reconfigure(); diff --git a/openbox/actions/resize.c b/openbox/actions/resize.c index b193864f..c479f755 100644 --- a/openbox/actions/resize.c +++ b/openbox/actions/resize.c @@ -1,4 +1,5 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/action_value.h" #include "openbox/moveresize.h" #include "openbox/client.h" @@ -12,7 +13,7 @@ typedef struct { static gpointer setup_func(GHashTable *config); static void free_func(gpointer o); -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); static guint32 pick_corner(gint x, gint y, gint cx, gint cy, gint cw, gint ch, gboolean shaded); @@ -63,7 +64,7 @@ static void free_func(gpointer o) } /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { Options *o = options; diff --git a/openbox/actions/resizerelative.c b/openbox/actions/resizerelative.c index 50741fa0..b6bd1ff2 100644 --- a/openbox/actions/resizerelative.c +++ b/openbox/actions/resizerelative.c @@ -1,4 +1,5 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/action_value.h" #include "openbox/client.h" #include "openbox/screen.h" @@ -18,7 +19,7 @@ typedef struct { static gpointer setup_func(GHashTable *config); static void free_func(gpointer options); -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); void action_resizerelative_startup(void) { @@ -55,7 +56,7 @@ static void free_func(gpointer o) } /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { Options *o = options; diff --git a/openbox/actions/restart.c b/openbox/actions/restart.c index 33369211..9521e814 100644 --- a/openbox/actions/restart.c +++ b/openbox/actions/restart.c @@ -1,4 +1,5 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/action_value.h" #include "openbox/openbox.h" #include "obt/paths.h" @@ -9,7 +10,7 @@ typedef struct { static gpointer setup_func(GHashTable *config); static void free_func(gpointer options); -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); void action_restart_startup(void) { @@ -38,7 +39,7 @@ static void free_func(gpointer options) } /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { Options *o = options; diff --git a/openbox/actions/shade.c b/openbox/actions/shade.c index 6e1b61a5..752220f4 100644 --- a/openbox/actions/shade.c +++ b/openbox/actions/shade.c @@ -1,9 +1,10 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/client.h" -static gboolean run_func_on(ObActionData *data, gpointer options); -static gboolean run_func_off(ObActionData *data, gpointer options); -static gboolean run_func_toggle(ObActionData *data, gpointer options); +static gboolean run_func_on(const ObActionListRun *data, gpointer options); +static gboolean run_func_off(const ObActionListRun *data, gpointer options); +static gboolean run_func_toggle(const ObActionListRun *data, gpointer options); void action_shade_startup(void) { @@ -16,7 +17,7 @@ void action_shade_startup(void) } /* Always return FALSE because its not interactive */ -static gboolean run_func_on(ObActionData *data, gpointer options) +static gboolean run_func_on(const ObActionListRun *data, gpointer options) { if (data->client) { action_client_move(data, TRUE); @@ -27,7 +28,7 @@ static gboolean run_func_on(ObActionData *data, gpointer options) } /* Always return FALSE because its not interactive */ -static gboolean run_func_off(ObActionData *data, gpointer options) +static gboolean run_func_off(const ObActionListRun *data, gpointer options) { if (data->client) { action_client_move(data, TRUE); @@ -38,7 +39,7 @@ static gboolean run_func_off(ObActionData *data, gpointer options) } /* Always return FALSE because its not interactive */ -static gboolean run_func_toggle(ObActionData *data, gpointer options) +static gboolean run_func_toggle(const ObActionListRun *data, gpointer options) { if (data->client) { action_client_move(data, TRUE); diff --git a/openbox/actions/showdesktop.c b/openbox/actions/showdesktop.c index 647fa648..3b31a955 100644 --- a/openbox/actions/showdesktop.c +++ b/openbox/actions/showdesktop.c @@ -1,7 +1,8 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/screen.h" -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); void action_showdesktop_startup(void) { @@ -10,7 +11,7 @@ void action_showdesktop_startup(void) } /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { screen_show_desktop(!screen_showing_desktop, NULL); diff --git a/openbox/actions/showmenu.c b/openbox/actions/showmenu.c index ca1464c8..a7ef2985 100644 --- a/openbox/actions/showmenu.c +++ b/openbox/actions/showmenu.c @@ -1,4 +1,5 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/action_value.h" #include "openbox/menu.h" #include @@ -9,7 +10,7 @@ typedef struct { static gpointer setup_func(GHashTable *config); static void free_func(gpointer options); -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); void action_showmenu_startup(void) { @@ -38,7 +39,7 @@ static void free_func(gpointer options) } /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { Options *o = options; diff --git a/openbox/actions/unfocus.c b/openbox/actions/unfocus.c index 26c1b3cd..bc26dfef 100644 --- a/openbox/actions/unfocus.c +++ b/openbox/actions/unfocus.c @@ -1,7 +1,8 @@ #include "openbox/action.h" +#include "openbox/action_list_run.h" #include "openbox/focus.h" -static gboolean run_func(ObActionData *data, gpointer options); +static gboolean run_func(const ObActionListRun *data, gpointer options); void action_unfocus_startup(void) { @@ -10,7 +11,7 @@ void action_unfocus_startup(void) } /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionData *data, gpointer options) +static gboolean run_func(const ObActionListRun *data, gpointer options) { if (data->client && data->client == focus_client) focus_fallback(FALSE, FALSE, TRUE, FALSE); diff --git a/openbox/client_set.c b/openbox/client_set.c index f2970939..5388d153 100644 --- a/openbox/client_set.c +++ b/openbox/client_set.c @@ -61,11 +61,11 @@ ObClientSet* client_set_single(ObClient *c) { ObClientSet *set; - if (!c) return NULL; - set = g_slice_new(ObClientSet); - set->all = FALSE; - client_set_create_hash(set); - g_hash_table_insert(set->h, &c->window, c); + set = client_set_empty(); + if (c) { + client_set_create_hash(set); + g_hash_table_insert(set->h, &c->window, c); + } return set; } diff --git a/openbox/filters/all.c b/openbox/filters/all.c index dd0f4d7d..c35e0953 100644 --- a/openbox/filters/all.c +++ b/openbox/filters/all.c @@ -17,17 +17,16 @@ */ #include "openbox/action_filter.h" +#include "openbox/action_list_run.h" +#include "openbox/client_set.h" -static gboolean reduce(struct _ObClient *c, gpointer data) +static ObClientSet* filter(gboolean invert, const ObActionListRun *data, + gpointer setup_data) { - return FALSE; /* remove nothing */ -} -static gboolean expand(struct _ObClient *c, gpointer data) -{ - return TRUE; /* add everything */ + return invert ? client_set_empty() : client_set_all(); } void filter_all_startup(void) { - action_filter_register("all", NULL, NULL, reduce, expand); + action_filter_register("all", NULL, NULL, filter); } diff --git a/openbox/filters/target.c b/openbox/filters/target.c index cb6b33a9..49059975 100644 --- a/openbox/filters/target.c +++ b/openbox/filters/target.c @@ -17,18 +17,18 @@ */ #include "openbox/action_filter.h" -#include "openbox/event.h" +#include "openbox/action_list_run.h" +#include "openbox/client_set.h" -static gboolean reduce(struct _ObClient *c, gpointer data) +static ObClientSet* filter(gboolean invert, const ObActionListRun *data, + gpointer setup_data) { - return c != event_current_target(); /* remove anything not the target */ -} -static gboolean expand(struct _ObClient *c, gpointer data) -{ - return c == event_current_target(); /* add only the target */ + ObClientSet *set = client_set_single(data->client); + if (invert) set = client_set_minus(client_set_all(), set); + return set; } void filter_target_startup(void) { - action_filter_register("target", NULL, NULL, reduce, expand); + action_filter_register("target", NULL, NULL, filter); } diff --git a/openbox/keyboard.c b/openbox/keyboard.c index 8515ff64..b3ec2ad5 100644 --- a/openbox/keyboard.c +++ b/openbox/keyboard.c @@ -26,6 +26,7 @@ #include "client.h" #include "action.h" #include "action_list.h" +#include "action_list_run.h" #include "menuframe.h" #include "config.h" #include "keytree.h" @@ -266,7 +267,7 @@ gboolean keyboard_event(ObClient *client, const XEvent *e) else { gboolean i; - i = action_run_acts(p->actions, OB_USER_ACTION_KEYBOARD_KEY, + i = action_list_run(p->actions, OB_USER_ACTION_KEYBOARD_KEY, e->xkey.state, e->xkey.x_root, e->xkey.y_root, 0, OB_FRAME_CONTEXT_NONE, client); diff --git a/openbox/menuframe.c b/openbox/menuframe.c index 3aa0dfee..9c5e54b2 100644 --- a/openbox/menuframe.c +++ b/openbox/menuframe.c @@ -23,6 +23,7 @@ #include "screen.h" #include "action.h" #include "action_list.h" +#include "action_list_run.h" #include "event.h" #include "grab.h" #include "openbox.h" @@ -1304,7 +1305,7 @@ void menu_entry_frame_execute(ObMenuEntryFrame *self, guint state) if (func) func(entry, frame, client, state, data); else - action_run_acts(acts, OB_USER_ACTION_MENU_SELECTION, + action_list_run(acts, OB_USER_ACTION_MENU_SELECTION, state, -1, -1, 0, OB_FRAME_CONTEXT_NONE, client); } } diff --git a/openbox/mouse.c b/openbox/mouse.c index f0b869c1..df34184b 100644 --- a/openbox/mouse.c +++ b/openbox/mouse.c @@ -21,6 +21,7 @@ #include "config.h" #include "action.h" #include "action_list.h" +#include "action_list_run.h" #include "event.h" #include "client.h" #include "grab.h" @@ -188,7 +189,7 @@ static gboolean fire_binding(ObMouseAction a, ObFrameContext context, /* if not bound, then nothing to do! */ if (it == NULL) return FALSE; - action_run_acts(b->actions[a], mouse_action_to_user_action(a), + action_list_run(b->actions[a], mouse_action_to_user_action(a), state, x, y, button, context, c); return TRUE; }