all repos — openbox @ 8becd1f93f9a8a448ca61372e50bd8bf79e7ab9d

openbox fork - make it a bit more like ryudo

add interactive action functions. some other changes to stuff that wasnt going to work
Dana Jansens danakj@orodu.net
commit

8becd1f93f9a8a448ca61372e50bd8bf79e7ab9d

parent

314c0566371d83305d723c883884555a24cc0ad8

4 files changed, 40 insertions(+), 54 deletions(-)

jump to
M openbox/actions.copenbox/actions.c

@@ -31,6 +31,8 @@

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 @@ if (!g_ascii_strcasecmp(name, def->name)) /* already registered */

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 @@ def->type = type;

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 @@

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,16 +204,13 @@ ObActionsData data;

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; case OB_ACTION_TYPE_CLIENT: data.client.context = con; data.client.c = client; - break; - case OB_ACTION_TYPE_SELECTOR: - data.selector.interactive = interactive; break; default: g_assert_not_reached();
M openbox/actions.hopenbox/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 _ObClient *c;

ObFrameContext context; }; -struct _ObActionsSelectorData { - ObActionsType type; - ObActionsAnyData any; - - ObActionsInteractiveState interactive; - GSList *actions; -}; - struct _ObActionsData { ObActionsType type;

@@ -96,35 +75,40 @@ union {

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);
M openbox/keyboard.copenbox/keyboard.c

@@ -169,14 +169,6 @@

/* 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 @@

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 @@ action_run_interactive(alist, istate.client, state, time, cancel, TRUE);

g_slist_free(alist); keyboard_reset_chains(0); +#endif } static void keyboard_interactive_end_client(ObClient *client, gpointer data)

@@ -221,8 +215,9 @@ keyboard_interactive_end(0, TRUE, event_curtime, TRUE);

} 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 @@ istate.state = state;

istate.client = client; istate.action = action; +#endif return TRUE; }

@@ -319,7 +315,7 @@ GSList *it;

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);
M openbox/mouse.copenbox/mouse.c

@@ -196,7 +196,7 @@ /* if not bound, then nothing to do! */

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; }