#include "action.h"
#include "action_list.h"
+#include "action_filter.h"
#include "gettext.h"
#include "grab.h"
#include "screen.h"
gchar *name;
gboolean canbeinteractive;
+ ObActionDefaultFilter def_filter;
union {
ObActionIDataSetupFunc i;
ObActionDataSetupFunc n;
}
ObActionDefinition* do_register(const gchar *name,
+ ObActionDefaultFilter def_filter,
ObActionDataFreeFunc free,
ObActionRunFunc run)
{
GSList *it;
ObActionDefinition *def;
- g_assert(run != NULL);
+ g_return_val_if_fail(def_filter < OB_NUM_ACTION_DEFAULT_FILTERS, NULL);
+ g_return_val_if_fail(run != NULL, NULL);
for (it = registered; it; it = g_slist_next(it)) {
def = it->data;
def = g_slice_new(ObActionDefinition);
def->ref = 1;
def->name = g_strdup(name);
+ def->def_filter = def_filter;
def->free = free;
def->run = run;
def->shutdown = NULL;
}
gboolean action_register_i(const gchar *name,
+ ObActionDefaultFilter def_filter,
ObActionIDataSetupFunc setup,
ObActionDataFreeFunc free,
ObActionRunFunc run)
{
- ObActionDefinition *def = do_register(name, free, run);
+ ObActionDefinition *def = do_register(name, def_filter, free, run);
if (def) {
def->canbeinteractive = TRUE;
def->setup.i = setup;
}
gboolean action_register(const gchar *name,
+ ObActionDefaultFilter def_filter,
ObActionDataSetupFunc setup,
ObActionDataFreeFunc free,
ObActionRunFunc run)
{
- ObActionDefinition *def = do_register(name, free, run);
+ ObActionDefinition *def = do_register(name, def_filter, free, run);
if (def) {
def->canbeinteractive = FALSE;
def->setup.n = setup;
ObActionICancelFunc *cancel,
ObActionIPostFunc *post);
+/*! The default filter an action would like if no filter is provided by the
+ user */
+typedef enum {
+ OB_ACTION_DEFAULT_FILTER_EMPTY,
+ OB_ACTION_DEFAULT_FILTER_SINGLE,
+ OB_ACTION_DEFAULT_FILTER_ALL,
+ OB_NUM_ACTION_DEFAULT_FILTERS
+} ObActionDefaultFilter;
+
struct _ObActionData {
ObUserAction uact;
guint state;
/*! Use this if the actions created from this name may be interactive */
gboolean action_register_i(const gchar *name,
+ ObActionDefaultFilter def_filter,
ObActionIDataSetupFunc setup,
ObActionDataFreeFunc free,
ObActionRunFunc run);
gboolean action_register(const gchar *name,
+ ObActionDefaultFilter def_filter,
ObActionDataSetupFunc setup,
ObActionDataFreeFunc free,
ObActionRunFunc run);
typedef struct _ObActionFilter ObActionFilter;
typedef struct _ObActionFilterFuncs ObActionFilterFuncs;
+typedef enum _ObActionFilterDefault ObActionFilterDefault;
typedef gpointer (*ObActionFilterSetupFunc)(gboolean invert,
struct _ObActionValue *v);
static gpointer setup_remove_func(GHashTable *config);
static void free_func(gpointer o);
static gboolean run_func(ObActionData *data, gpointer options);
-/* 3.4-compatibility */
-static gpointer setup_addcurrent_func(GHashTable *config);
-static gpointer setup_addlast_func(GHashTable *config);
-static gpointer setup_removecurrent_func(GHashTable *config);
-static gpointer setup_removelast_func(GHashTable *config);
void action_addremovedesktop_startup(void)
{
- action_register("AddDesktop", setup_add_func, free_func, run_func);
- action_register("RemoveDesktop", setup_remove_func, free_func, run_func);
-
- /* 3.4-compatibility */
- action_register("AddDesktopLast", setup_addlast_func,
- free_func, run_func);
- action_register("RemoveDesktopLast", setup_removelast_func,
- free_func, run_func);
- action_register("AddDesktopCurrent", setup_addcurrent_func,
- free_func, run_func);
- action_register("RemoveDesktopCurrent", setup_removecurrent_func,
- free_func, run_func);
+ action_register("AddDesktop", OB_ACTION_DEFAULT_FILTER_EMPTY,
+ setup_add_func, free_func, run_func);
+ action_register("RemoveDesktop", OB_ACTION_DEFAULT_FILTER_EMPTY,
+ setup_remove_func, free_func, run_func);
}
static gpointer setup_func(GHashTable *config)
return FALSE;
}
-
-/* 3.4-compatibility */
-static gpointer setup_addcurrent_func(GHashTable *config)
-{
- Options *o = setup_add_func(config);
- o->current = TRUE;
- return o;
-}
-
-static gpointer setup_addlast_func(GHashTable *config)
-{
- Options *o = setup_add_func(config);
- o->current = FALSE;
- return o;
-}
-
-static gpointer setup_removecurrent_func(GHashTable *config)
-{
- Options *o = setup_remove_func(config);
- o->current = TRUE;
- return o;
-}
-
-static gpointer setup_removelast_func(GHashTable *config)
-{
- Options *o = setup_remove_func(config);
- o->current = FALSE;
- return o;
-}
void action_breakchroot_startup(void)
{
action_register("BreakChroot",
+ OB_ACTION_DEFAULT_FILTER_EMPTY,
NULL, NULL,
run_func);
}
void action_close_startup(void)
{
- action_register("Close", NULL, NULL, run_func);
+ action_register("Close", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ NULL, NULL, run_func);
}
/* Always return FALSE because its not interactive */
void action_cyclewindows_startup(void)
{
- action_register_i("NextWindow", setup_forward_func, free_func, run_func);
- action_register_i("PreviousWindow", setup_backward_func, free_func,
- run_func);
+ action_register_i("NextWindow", OB_ACTION_DEFAULT_FILTER_ALL,
+ setup_forward_func, free_func, run_func);
+ action_register_i("PreviousWindow", OB_ACTION_DEFAULT_FILTER_ALL,
+ setup_backward_func, free_func, run_func);
}
static gpointer setup_func(GHashTable *config,
void action_debug_startup(void)
{
- action_register("Debug", setup_func, free_func, run_func);
+ action_register("Debug", OB_ACTION_DEFAULT_FILTER_EMPTY,
+ setup_func, free_func, run_func);
}
static gpointer setup_func(GHashTable *config)
void action_decorations_startup(void)
{
- action_register("Decorate", NULL, NULL, run_func_on);
- action_register("Undecorate", NULL, NULL, run_func_off);
- action_register("ToggleDecorations", NULL, NULL, run_func_toggle);
+ action_register("Decorate", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ NULL, NULL, run_func_on);
+ action_register("Undecorate", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ NULL, NULL, run_func_off);
+ action_register("ToggleDecorations", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ NULL, NULL, run_func_toggle);
}
/* Always return FALSE because its not interactive */
void action_desktop_startup(void)
{
- action_register_i("GoToDesktop", setup_go_func, free_func, run_func);
- action_register_i("SendToDesktop", setup_send_func, free_func, run_func);
+ action_register_i("GoToDesktop", OB_ACTION_DEFAULT_FILTER_EMPTY,
+ setup_go_func, free_func, run_func);
+ action_register_i("SendToDesktop", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ setup_send_func, free_func, run_func);
}
static gpointer setup_func(GHashTable *config,
void action_directionalwindows_startup(void)
{
- action_register_i("DirectionalCycleWindows", setup_cycle_func, free_func,
- run_func);
- action_register("DirectionalTargetWindow", setup_target_func, free_func,
- run_func);
+ action_register_i("DirectionalCycleWindows", OB_ACTION_DEFAULT_FILTER_ALL,
+ setup_cycle_func, free_func, run_func);
+ action_register("DirectionalTargetWindow", OB_ACTION_DEFAULT_FILTER_ALL,
+ setup_target_func, free_func, run_func);
}
static gpointer setup_func(GHashTable *config)
void action_dock_startup(void)
{
- action_register("RaiseDock", NULL, NULL, raise_func);
- action_register("LowerDock", NULL, NULL, lower_func);
+ action_register("RaiseDock", OB_ACTION_DEFAULT_FILTER_EMPTY,
+ NULL, NULL, raise_func);
+ action_register("LowerDock", OB_ACTION_DEFAULT_FILTER_EMPTY,
+ NULL, NULL, lower_func);
}
/* Always return FALSE because its not interactive */
void action_dockautohide_startup(void)
{
- action_register("ToggleDockAutoHide", NULL, NULL, run_func);
+ action_register("ToggleDockAutoHide", OB_ACTION_DEFAULT_FILTER_EMPTY,
+ NULL, NULL, run_func);
}
/* Always return FALSE because its not interactive */
void action_execute_startup(void)
{
- action_register("Execute", setup_func, free_func, run_func);
+ action_register("Execute", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ setup_func, free_func, run_func);
action_set_shutdown("Execute", shutdown_func);
client_add_destroy_notify(client_dest, NULL);
void action_exit_startup(void)
{
- action_register("Exit", setup_func, free_func, run_func);
+ action_register("Exit", OB_ACTION_DEFAULT_FILTER_EMPTY,
+ setup_func, free_func, run_func);
}
static gpointer setup_func(GHashTable *config)
void action_focus_startup(void)
{
- action_register("Focus", setup_func, free_func, run_func);
+ action_register("Focus", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ setup_func, free_func, run_func);
}
static gpointer setup_func(GHashTable *config)
void action_focustobottom_startup(void)
{
- action_register("FocusToBottom", NULL, NULL, run_func);
+ action_register("FocusToBottom", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ NULL, NULL, run_func);
}
/* Always return FALSE because its not interactive */
void action_fullscreen_startup(void)
{
- action_register("ToggleFullscreen", NULL, NULL, run_func_toggle);
+ action_register("ToggleFullscreen", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ NULL, NULL, run_func_toggle);
}
/* Always return FALSE because its not interactive */
void action_growtoedge_startup(void)
{
- action_register("GrowToEdge", setup_func, free_func, run_func);
- action_register("ShrinkToEdge", setup_shrink_func, free_func, run_func);
+ action_register("GrowToEdge", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ setup_func, free_func, run_func);
+ action_register("ShrinkToEdge", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ setup_shrink_func, free_func, run_func);
}
static gpointer setup_func(GHashTable *config)
void action_iconify_startup(void)
{
- action_register("Iconify", NULL, NULL, run_func);
+ action_register("Iconify", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ NULL, NULL, run_func);
}
/* Always return FALSE because its not interactive */
void action_kill_startup(void)
{
- action_register("Kill", NULL, NULL, run_func);
+ action_register("Kill", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ NULL, NULL, run_func);
}
/* Always return FALSE because its not interactive */
void action_layer_startup(void)
{
- action_register("ToggleAlwaysOnTop", setup_func_top, free_func,
- run_func);
- action_register("ToggleAlwaysOnBottom", setup_func_bottom, free_func,
- run_func);
- action_register("SendToLayer", setup_func_send, free_func,
- run_func);
+ action_register("ToggleAlwaysOnTop", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ setup_func_top, free_func, run_func);
+ action_register("ToggleAlwaysOnBottom", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ setup_func_bottom, free_func, run_func);
+ action_register("SendToLayer", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ setup_func_send, free_func, run_func);
}
static gpointer setup_func_top(GHashTable *config)
void action_lower_startup(void)
{
- action_register("Lower", NULL, NULL, run_func);
+ action_register("Lower", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ NULL, NULL, run_func);
}
/* Always return FALSE because its not interactive */
void action_maximize_startup(void)
{
- action_register("Maximize", setup_func, free_func, run_func_on);
- action_register("Unmaximize", setup_func, free_func, run_func_off);
- action_register("ToggleMaximize", setup_func, free_func, run_func_toggle);
+ action_register("Maximize", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ setup_func, free_func, run_func_on);
+ action_register("Unmaximize", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ setup_func, free_func, run_func_off);
+ action_register("ToggleMaximize", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ setup_func, free_func, run_func_toggle);
}
static gpointer setup_func(GHashTable *config)
void action_move_startup(void)
{
- action_register("Move", NULL, NULL, run_func);
+ action_register("Move", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ NULL, NULL, run_func);
}
/* Always return FALSE because its not interactive */
void action_moverelative_startup(void)
{
- action_register("MoveRelative", setup_func, free_func, run_func);
+ action_register("MoveRelative", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ setup_func, free_func, run_func);
}
static gpointer setup_func(GHashTable *config)
void action_moveresizeto_startup(void)
{
- action_register("MoveResizeTo", setup_func, free_func, run_func);
+ action_register("MoveResizeTo", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ setup_func, free_func, run_func);
}
static gpointer setup_func(GHashTable *config)
void action_movetoedge_startup(void)
{
- action_register("MoveToEdge", setup_func, free_func, run_func);
+ action_register("MoveToEdge", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ setup_func, free_func, run_func);
}
static gpointer setup_func(GHashTable *config)
void action_omnipresent_startup(void)
{
- action_register("ToggleOmnipresent", NULL, NULL, run_func_toggle);
+ action_register("ToggleOmnipresent", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ NULL, NULL, run_func_toggle);
}
/* Always return FALSE because its not interactive */
void action_raise_startup(void)
{
- action_register("Raise", NULL, NULL, run_func);
+ action_register("Raise", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ NULL, NULL, run_func);
}
/* Always return FALSE because its not interactive */
void action_raiselower_startup(void)
{
- action_register("RaiseLower", NULL, NULL, run_func);
+ action_register("RaiseLower", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ NULL, NULL, run_func);
}
/* Always return FALSE because its not interactive */
void action_reconfigure_startup(void)
{
- action_register("Reconfigure", NULL, NULL, run_func);
+ action_register("Reconfigure", OB_ACTION_DEFAULT_FILTER_EMPTY,
+ NULL, NULL, run_func);
}
/* Always return FALSE because its not interactive */
void action_resize_startup(void)
{
- action_register("Resize", setup_func, free_func, run_func);
+ action_register("Resize", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ setup_func, free_func, run_func);
}
static gpointer setup_func(GHashTable *config)
void action_resizerelative_startup(void)
{
- action_register("ResizeRelative", setup_func, free_func, run_func);
+ action_register("ResizeRelative", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ setup_func, free_func, run_func);
}
static gpointer setup_func(GHashTable *config)
void action_restart_startup(void)
{
- action_register("Restart", setup_func, free_func, run_func);
+ action_register("Restart", OB_ACTION_DEFAULT_FILTER_EMPTY,
+ setup_func, free_func, run_func);
}
static gpointer setup_func(GHashTable *config)
void action_shade_startup(void)
{
- action_register("Shade", NULL, NULL, run_func_on);
- action_register("Unshade", NULL, NULL, run_func_off);
- action_register("ToggleShade", NULL, NULL, run_func_toggle);
+ action_register("Shade", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ NULL, NULL, run_func_on);
+ action_register("Unshade", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ NULL, NULL, run_func_off);
+ action_register("ToggleShade", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ NULL, NULL, run_func_toggle);
}
/* Always return FALSE because its not interactive */
void action_showdesktop_startup(void)
{
- action_register("ToggleShowDesktop", NULL, NULL, run_func);
+ action_register("ToggleShowDesktop", OB_ACTION_DEFAULT_FILTER_EMPTY,
+ NULL, NULL, run_func);
}
/* Always return FALSE because its not interactive */
void action_showmenu_startup(void)
{
- action_register("ShowMenu", setup_func, free_func, run_func);
+ action_register("ShowMenu", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ setup_func, free_func, run_func);
}
static gpointer setup_func(GHashTable *config)
void action_unfocus_startup(void)
{
- action_register("Unfocus", NULL, NULL, run_func);
+ action_register("Unfocus", OB_ACTION_DEFAULT_FILTER_SINGLE,
+ NULL, NULL, run_func);
}
/* Always return FALSE because its not interactive */