ObActionsDataSetupFunc setup;
ObActionsDataFreeFunc free;
ObActionsRunFunc run;
+ ObActionsInteractiveInputFunc i_input;
+ ObActionsInteractiveCancelFunc i_cancel;
};
struct _ObActionsAct {
ObActionsType type,
ObActionsDataSetupFunc setup,
ObActionsDataFreeFunc free,
- ObActionsRunFunc run)
+ ObActionsRunFunc run,
+ ObActionsInteractiveInputFunc i_input,
+ ObActionsInteractiveCancelFunc i_cancel)
{
GSList *it;
ObActionsDefinition *def;
return FALSE;
}
+ g_assert((i_input == NULL) == (i_cancel == NULL));
+
def = g_new(ObActionsDefinition, 1);
def->ref = 1;
def->name = g_strdup(name);
def->setup = setup;
def->free = free;
def->run = run;
+ def->i_input = i_input;
+ def->i_cancel = i_cancel;
return TRUE;
}
return act;
}
+gboolean actions_act_is_interactive(ObActionsAct *act)
+{
+ return act->def->i_cancel != NULL;
+}
+
void actions_act_ref(ObActionsAct *act)
{
++act->ref;
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;
}
ObUserAction uact,
Time time,
guint state,
- guint button,
gint x,
gint y,
ObFrameContext con,
- struct _ObClient *client,
- ObActionsInteractiveState interactive)
+ struct _ObClient *client)
{
GSList *it;
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;
data.client.context = con;
data.client.c = client;
break;
- case OB_ACTION_TYPE_SELECTOR:
- data.selector.interactive = interactive;
- break;
default:
g_assert_not_reached();
}
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 */
ObUserAction uact;
Time time;
guint state;
- guint button;
gint x;
gint y;
};
ObFrameContext context;
};
-struct _ObActionsSelectorData {
- ObActionsType type;
- ObActionsAnyData any;
-
- ObActionsInteractiveState interactive;
- GSList *actions;
-};
-
struct _ObActionsData {
ObActionsType type;
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);
/* 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
static void keyboard_interactive_end(guint state, gboolean cancel, Time time,
gboolean ungrab)
{
+#if 0
GSList *alist;
g_assert(istate.active);
g_slist_free(alist);
keyboard_reset_chains(0);
+#endif
}
static void keyboard_interactive_end_client(ObClient *client, gpointer data)
}
gboolean keyboard_interactive_grab(guint state, ObClient *client,
- ObAction *action)
+ ObActionsAct *action)
{
+#if 0
g_assert(action->data.any.interactive);
if (!istate.active) {
istate.client = client;
istate.action = action;
+#endif
return TRUE;
}
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);
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;
}