From 8becd1f93f9a8a448ca61372e50bd8bf79e7ab9d Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Fri, 22 Jun 2007 02:01:45 +0000 Subject: [PATCH] add interactive action functions. some other changes to stuff that wasnt going to work --- openbox/actions.c | 26 ++++++++++++++---------- openbox/actions.h | 50 ++++++++++++++++------------------------------ openbox/keyboard.c | 16 ++++++--------- openbox/mouse.c | 2 +- 4 files changed, 40 insertions(+), 54 deletions(-) diff --git a/openbox/actions.c b/openbox/actions.c index dff78f50..c516969e 100644 --- a/openbox/actions.c +++ b/openbox/actions.c @@ -31,6 +31,8 @@ struct _ObActionsDefinition { ObActionsDataSetupFunc setup; ObActionsDataFreeFunc free; ObActionsRunFunc run; + ObActionsInteractiveInputFunc i_input; + ObActionsInteractiveCancelFunc i_cancel; }; struct _ObActionsAct { @@ -65,7 +67,9 @@ gboolean actions_register(const gchar *name, ObActionsType type, ObActionsDataSetupFunc setup, ObActionsDataFreeFunc free, - ObActionsRunFunc run) + ObActionsRunFunc run, + ObActionsInteractiveInputFunc i_input, + ObActionsInteractiveCancelFunc i_cancel) { GSList *it; ObActionsDefinition *def; @@ -76,6 +80,8 @@ gboolean actions_register(const gchar *name, return FALSE; } + g_assert((i_input == NULL) == (i_cancel == NULL)); + def = g_new(ObActionsDefinition, 1); def->ref = 1; def->name = g_strdup(name); @@ -83,6 +89,8 @@ gboolean actions_register(const gchar *name, def->setup = setup; def->free = free; def->run = run; + def->i_input = i_input; + def->i_cancel = i_cancel; return TRUE; } @@ -145,6 +153,11 @@ ObActionsAct* actions_parse(ObParseInst *i, return act; } +gboolean actions_act_is_interactive(ObActionsAct *act) +{ + return act->def->i_cancel != NULL; +} + void actions_act_ref(ObActionsAct *act) { ++act->ref; @@ -165,14 +178,12 @@ static void actions_setup_data(ObActionsData *data, ObUserAction uact, Time time, guint state, - guint button, gint x, gint y) { data->any.uact = uact; data->any.time = time; data->any.state = state; - data->any.button = button; data->any.x = x; data->any.y = y; } @@ -181,12 +192,10 @@ void actions_run_acts(GSList *acts, ObUserAction uact, Time time, guint state, - guint button, gint x, gint y, ObFrameContext con, - struct _ObClient *client, - ObActionsInteractiveState interactive) + struct _ObClient *client) { GSList *it; @@ -195,7 +204,7 @@ void actions_run_acts(GSList *acts, ObActionsAct *act = it->data; data.type = act->def->type; - actions_setup_data(&data, uact, time, state, button, x, y); + actions_setup_data(&data, uact, time, state, x, y); switch (data.type) { case OB_ACTION_TYPE_GLOBAL: break; @@ -203,9 +212,6 @@ void actions_run_acts(GSList *acts, data.client.context = con; data.client.c = client; break; - case OB_ACTION_TYPE_SELECTOR: - data.selector.interactive = interactive; - break; default: g_assert_not_reached(); } diff --git a/openbox/actions.h b/openbox/actions.h index 2cafa306..b55a7f07 100644 --- a/openbox/actions.h +++ b/openbox/actions.h @@ -30,31 +30,19 @@ typedef struct _ObActionsGlobalData ObActionsGlobalData; typedef struct _ObActionsClientData ObActionsClientData; typedef struct _ObActionsSelectorData ObActionsSelectorData; -typedef enum { - OB_ACTION_DONE, - OB_ACTION_CANCELLED, - OB_ACTION_INTERACTING, - OB_NUM_ACTIONS_INTERACTIVE_STATES -} ObActionsInteractiveState; - typedef gpointer (*ObActionsDataSetupFunc)(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); typedef void (*ObActionsDataFreeFunc)(gpointer options); -typedef void (*ObActionsRunFunc)(ObActionsData *data, +typedef gboolean (*ObActionsRunFunc)(ObActionsData *data, gpointer options); - -/* - The theory goes: - - 06:10 (@dana) hm i think there are 3 types of actions - 06:10 (@dana) global actions, window actions, and selector actions - 06:11 (@dana) eg show menu/exit, raise/focus, and cycling/directional/expose -*/ +typedef gboolean (*ObActionsInteractiveInputFunc)(guint initial_state, + XEvent *e, + gpointer options); +typedef void (*ObActionsInteractiveCancelFunc)(gpointer options); typedef enum { OB_ACTION_TYPE_GLOBAL, - OB_ACTION_TYPE_CLIENT, - OB_ACTION_TYPE_SELECTOR + OB_ACTION_TYPE_CLIENT } ObActionsType; /* These structures are all castable as eachother */ @@ -63,7 +51,6 @@ struct _ObActionsAnyData { ObUserAction uact; Time time; guint state; - guint button; gint x; gint y; }; @@ -81,14 +68,6 @@ struct _ObActionsClientData { ObFrameContext context; }; -struct _ObActionsSelectorData { - ObActionsType type; - ObActionsAnyData any; - - ObActionsInteractiveState interactive; - GSList *actions; -}; - struct _ObActionsData { ObActionsType type; @@ -96,35 +75,40 @@ struct _ObActionsData { ObActionsAnyData any; ObActionsGlobalData global; ObActionsClientData client; - ObActionsSelectorData selector; }; }; void actions_startup(gboolean reconfigure); void actions_shutdown(gboolean reconfigure); +/*! If the action is interactive, then i_input and i_cancel are not NULL. + Otherwise, they should both be NULL. */ gboolean actions_register(const gchar *name, ObActionsType type, ObActionsDataSetupFunc setup, ObActionsDataFreeFunc free, - ObActionsRunFunc run); + ObActionsRunFunc run, + ObActionsInteractiveInputFunc i_input, + ObActionsInteractiveCancelFunc i_cancel); ObActionsAct* actions_parse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); ObActionsAct* actions_parse_string(const gchar *name); +gboolean actions_act_is_interactive(ObActionsAct *act); + void actions_act_ref(ObActionsAct *act); void actions_act_unref(ObActionsAct *act); -/*! Pass in a GSList of ObActionsAct's to be run */ +/*! Pass in a GSList of ObActionsAct's to be run. + @return TRUE if an action is in interactive state, FALSE is none are +*/ void actions_run_acts(GSList *acts, ObUserAction uact, Time time, guint state, - guint button, gint x, gint y, ObFrameContext con, - struct _ObClient *client, - ObActionsInteractiveState interactive); + struct _ObClient *client); diff --git a/openbox/keyboard.c b/openbox/keyboard.c index d9ec4f88..18884991 100644 --- a/openbox/keyboard.c +++ b/openbox/keyboard.c @@ -169,14 +169,6 @@ gboolean keyboard_bind(GList *keylist, ObActionsAct *action) /* find the bottom node */ for (; t->first_child; t = t->first_child); - /* when there are no modifiers in the binding, then the action cannot - be interactive */ - if (!t->state && action->data.any.interactive) { - g_print("not interactive\n"); - action->data.any.interactive = FALSE; - action->data.inter.final = TRUE; - } - /* set the action */ t->actions = g_slist_append(t->actions, action); /* assimilate this built tree into the main tree. assimilation @@ -189,6 +181,7 @@ gboolean keyboard_bind(GList *keylist, ObActionsAct *action) static void keyboard_interactive_end(guint state, gboolean cancel, Time time, gboolean ungrab) { +#if 0 GSList *alist; g_assert(istate.active); @@ -206,6 +199,7 @@ static void keyboard_interactive_end(guint state, gboolean cancel, Time time, g_slist_free(alist); keyboard_reset_chains(0); +#endif } static void keyboard_interactive_end_client(ObClient *client, gpointer data) @@ -221,8 +215,9 @@ void keyboard_interactive_cancel() } gboolean keyboard_interactive_grab(guint state, ObClient *client, - ObAction *action) + ObActionsAct *action) { +#if 0 g_assert(action->data.any.interactive); if (!istate.active) { @@ -237,6 +232,7 @@ gboolean keyboard_interactive_grab(guint state, ObClient *client, istate.client = client; istate.action = action; +#endif return TRUE; } @@ -319,7 +315,7 @@ void keyboard_event(ObClient *client, const XEvent *e) gboolean inter = FALSE; for (it = p->actions; it && !inter; it = g_slist_next(it)) - if (((ObAction*)it->data)->data.any.interactive) + if (((ObActionsAct*)it->data)->data.any.interactive) inter = TRUE; if (!inter) /* don't reset if the action is interactive */ keyboard_reset_chains(0); diff --git a/openbox/mouse.c b/openbox/mouse.c index f0403b97..d8813162 100644 --- a/openbox/mouse.c +++ b/openbox/mouse.c @@ -196,7 +196,7 @@ static gboolean fire_binding(ObMouseAction a, ObFrameContext context, if (it == NULL) return FALSE; actions_run_acts(b->actions[a], mouse_action_to_user_action(a), - time, state, button, x, y, context, c, OB_ACTION_DONE); + time, state, x, y, context, c); return TRUE; } -- 2.45.2