add interactive action functions. some other changes to stuff that wasnt going to work

This commit is contained in:
Dana Jansens 2007-06-22 02:01:45 +00:00
parent 314c056637
commit 8becd1f93f
4 changed files with 40 additions and 54 deletions

View file

@ -31,6 +31,8 @@ struct _ObActionsDefinition {
ObActionsDataSetupFunc setup; ObActionsDataSetupFunc setup;
ObActionsDataFreeFunc free; ObActionsDataFreeFunc free;
ObActionsRunFunc run; ObActionsRunFunc run;
ObActionsInteractiveInputFunc i_input;
ObActionsInteractiveCancelFunc i_cancel;
}; };
struct _ObActionsAct { struct _ObActionsAct {
@ -65,7 +67,9 @@ gboolean actions_register(const gchar *name,
ObActionsType type, ObActionsType type,
ObActionsDataSetupFunc setup, ObActionsDataSetupFunc setup,
ObActionsDataFreeFunc free, ObActionsDataFreeFunc free,
ObActionsRunFunc run) ObActionsRunFunc run,
ObActionsInteractiveInputFunc i_input,
ObActionsInteractiveCancelFunc i_cancel)
{ {
GSList *it; GSList *it;
ObActionsDefinition *def; ObActionsDefinition *def;
@ -76,6 +80,8 @@ gboolean actions_register(const gchar *name,
return FALSE; return FALSE;
} }
g_assert((i_input == NULL) == (i_cancel == NULL));
def = g_new(ObActionsDefinition, 1); def = g_new(ObActionsDefinition, 1);
def->ref = 1; def->ref = 1;
def->name = g_strdup(name); def->name = g_strdup(name);
@ -83,6 +89,8 @@ gboolean actions_register(const gchar *name,
def->setup = setup; def->setup = setup;
def->free = free; def->free = free;
def->run = run; def->run = run;
def->i_input = i_input;
def->i_cancel = i_cancel;
return TRUE; return TRUE;
} }
@ -145,6 +153,11 @@ ObActionsAct* actions_parse(ObParseInst *i,
return act; return act;
} }
gboolean actions_act_is_interactive(ObActionsAct *act)
{
return act->def->i_cancel != NULL;
}
void actions_act_ref(ObActionsAct *act) void actions_act_ref(ObActionsAct *act)
{ {
++act->ref; ++act->ref;
@ -165,14 +178,12 @@ static void actions_setup_data(ObActionsData *data,
ObUserAction uact, ObUserAction uact,
Time time, Time time,
guint state, guint state,
guint button,
gint x, gint x,
gint y) gint y)
{ {
data->any.uact = uact; data->any.uact = uact;
data->any.time = time; data->any.time = time;
data->any.state = state; data->any.state = state;
data->any.button = button;
data->any.x = x; data->any.x = x;
data->any.y = y; data->any.y = y;
} }
@ -181,12 +192,10 @@ void actions_run_acts(GSList *acts,
ObUserAction uact, ObUserAction uact,
Time time, Time time,
guint state, guint state,
guint button,
gint x, gint x,
gint y, gint y,
ObFrameContext con, ObFrameContext con,
struct _ObClient *client, struct _ObClient *client)
ObActionsInteractiveState interactive)
{ {
GSList *it; GSList *it;
@ -195,7 +204,7 @@ void actions_run_acts(GSList *acts,
ObActionsAct *act = it->data; ObActionsAct *act = it->data;
data.type = act->def->type; 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) { switch (data.type) {
case OB_ACTION_TYPE_GLOBAL: case OB_ACTION_TYPE_GLOBAL:
break; break;
@ -203,9 +212,6 @@ void actions_run_acts(GSList *acts,
data.client.context = con; data.client.context = con;
data.client.c = client; data.client.c = client;
break; break;
case OB_ACTION_TYPE_SELECTOR:
data.selector.interactive = interactive;
break;
default: default:
g_assert_not_reached(); g_assert_not_reached();
} }

View file

@ -30,31 +30,19 @@ typedef struct _ObActionsGlobalData ObActionsGlobalData;
typedef struct _ObActionsClientData ObActionsClientData; typedef struct _ObActionsClientData ObActionsClientData;
typedef struct _ObActionsSelectorData ObActionsSelectorData; 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, typedef gpointer (*ObActionsDataSetupFunc)(ObParseInst *i,
xmlDocPtr doc, xmlNodePtr node); xmlDocPtr doc, xmlNodePtr node);
typedef void (*ObActionsDataFreeFunc)(gpointer options); typedef void (*ObActionsDataFreeFunc)(gpointer options);
typedef void (*ObActionsRunFunc)(ObActionsData *data, typedef gboolean (*ObActionsRunFunc)(ObActionsData *data,
gpointer options); gpointer options);
typedef gboolean (*ObActionsInteractiveInputFunc)(guint initial_state,
/* XEvent *e,
The theory goes: gpointer options);
typedef void (*ObActionsInteractiveCancelFunc)(gpointer options);
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 enum { typedef enum {
OB_ACTION_TYPE_GLOBAL, OB_ACTION_TYPE_GLOBAL,
OB_ACTION_TYPE_CLIENT, OB_ACTION_TYPE_CLIENT
OB_ACTION_TYPE_SELECTOR
} ObActionsType; } ObActionsType;
/* These structures are all castable as eachother */ /* These structures are all castable as eachother */
@ -63,7 +51,6 @@ struct _ObActionsAnyData {
ObUserAction uact; ObUserAction uact;
Time time; Time time;
guint state; guint state;
guint button;
gint x; gint x;
gint y; gint y;
}; };
@ -81,14 +68,6 @@ struct _ObActionsClientData {
ObFrameContext context; ObFrameContext context;
}; };
struct _ObActionsSelectorData {
ObActionsType type;
ObActionsAnyData any;
ObActionsInteractiveState interactive;
GSList *actions;
};
struct _ObActionsData { struct _ObActionsData {
ObActionsType type; ObActionsType type;
@ -96,35 +75,40 @@ struct _ObActionsData {
ObActionsAnyData any; ObActionsAnyData any;
ObActionsGlobalData global; ObActionsGlobalData global;
ObActionsClientData client; ObActionsClientData client;
ObActionsSelectorData selector;
}; };
}; };
void actions_startup(gboolean reconfigure); void actions_startup(gboolean reconfigure);
void actions_shutdown(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, gboolean actions_register(const gchar *name,
ObActionsType type, ObActionsType type,
ObActionsDataSetupFunc setup, ObActionsDataSetupFunc setup,
ObActionsDataFreeFunc free, ObActionsDataFreeFunc free,
ObActionsRunFunc run); ObActionsRunFunc run,
ObActionsInteractiveInputFunc i_input,
ObActionsInteractiveCancelFunc i_cancel);
ObActionsAct* actions_parse(ObParseInst *i, ObActionsAct* actions_parse(ObParseInst *i,
xmlDocPtr doc, xmlDocPtr doc,
xmlNodePtr node); xmlNodePtr node);
ObActionsAct* actions_parse_string(const gchar *name); ObActionsAct* actions_parse_string(const gchar *name);
gboolean actions_act_is_interactive(ObActionsAct *act);
void actions_act_ref(ObActionsAct *act); void actions_act_ref(ObActionsAct *act);
void actions_act_unref(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, void actions_run_acts(GSList *acts,
ObUserAction uact, ObUserAction uact,
Time time, Time time,
guint state, guint state,
guint button,
gint x, gint x,
gint y, gint y,
ObFrameContext con, ObFrameContext con,
struct _ObClient *client, struct _ObClient *client);
ObActionsInteractiveState interactive);

View file

@ -169,14 +169,6 @@ gboolean keyboard_bind(GList *keylist, ObActionsAct *action)
/* find the bottom node */ /* find the bottom node */
for (; t->first_child; t = t->first_child); 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 */ /* set the action */
t->actions = g_slist_append(t->actions, action); t->actions = g_slist_append(t->actions, action);
/* assimilate this built tree into the main tree. assimilation /* 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, static void keyboard_interactive_end(guint state, gboolean cancel, Time time,
gboolean ungrab) gboolean ungrab)
{ {
#if 0
GSList *alist; GSList *alist;
g_assert(istate.active); g_assert(istate.active);
@ -206,6 +199,7 @@ static void keyboard_interactive_end(guint state, gboolean cancel, Time time,
g_slist_free(alist); g_slist_free(alist);
keyboard_reset_chains(0); keyboard_reset_chains(0);
#endif
} }
static void keyboard_interactive_end_client(ObClient *client, gpointer data) 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, gboolean keyboard_interactive_grab(guint state, ObClient *client,
ObAction *action) ObActionsAct *action)
{ {
#if 0
g_assert(action->data.any.interactive); g_assert(action->data.any.interactive);
if (!istate.active) { if (!istate.active) {
@ -237,6 +232,7 @@ gboolean keyboard_interactive_grab(guint state, ObClient *client,
istate.client = client; istate.client = client;
istate.action = action; istate.action = action;
#endif
return TRUE; return TRUE;
} }
@ -319,7 +315,7 @@ void keyboard_event(ObClient *client, const XEvent *e)
gboolean inter = FALSE; gboolean inter = FALSE;
for (it = p->actions; it && !inter; it = g_slist_next(it)) 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; inter = TRUE;
if (!inter) /* don't reset if the action is interactive */ if (!inter) /* don't reset if the action is interactive */
keyboard_reset_chains(0); keyboard_reset_chains(0);

View file

@ -196,7 +196,7 @@ static gboolean fire_binding(ObMouseAction a, ObFrameContext context,
if (it == NULL) return FALSE; if (it == NULL) return FALSE;
actions_run_acts(b->actions[a], mouse_action_to_user_action(a), 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; return TRUE;
} }