dont run actions immediately. put them in the queue. add action_run_string for niternal use

This commit is contained in:
Dana Jansens 2003-09-26 17:29:33 +00:00
parent 87430acf34
commit eb51015bc3
2 changed files with 42 additions and 5 deletions

View file

@ -30,6 +30,7 @@
#include "keyboard.h" #include "keyboard.h"
#include "event.h" #include "event.h"
#include "config.h" #include "config.h"
#include "mainloop.h"
#include <glib.h> #include <glib.h>
@ -94,6 +95,21 @@ void action_unref(ObAction *a)
g_free(a); g_free(a);
} }
ObAction* action_copy(const ObAction *src)
{
ObAction *a = action_new(src->func);
a->data = src->data;
/* deal with pointers */
if (a->func == action_execute || a->func == action_restart)
a->data.execute.path = g_strdup(a->data.execute.path);
else if (a->func == action_showmenu)
a->data.showmenu.name = g_strdup(a->data.showmenu.name);
return a;
}
void setup_action_directional_focus_north(ObAction **a, ObUserAction uact) void setup_action_directional_focus_north(ObAction **a, ObUserAction uact)
{ {
(*a)->data.interdiraction.inter.any.interactive = TRUE; (*a)->data.interdiraction.inter.any.interactive = TRUE;
@ -346,7 +362,8 @@ void setup_action_move(ObAction **a, ObUserAction uact)
(*a)->data.moveresize.any.client_action = OB_CLIENT_ACTION_ALWAYS; (*a)->data.moveresize.any.client_action = OB_CLIENT_ACTION_ALWAYS;
(*a)->data.moveresize.move = TRUE; (*a)->data.moveresize.move = TRUE;
(*a)->data.moveresize.keyboard = (*a)->data.moveresize.keyboard =
(uact == OB_USER_ACTION_KEYBOARD_KEY || (uact == OB_USER_ACTION_NONE ||
uact == OB_USER_ACTION_KEYBOARD_KEY ||
uact == OB_USER_ACTION_MENU_SELECTION); uact == OB_USER_ACTION_MENU_SELECTION);
} }
@ -355,7 +372,8 @@ void setup_action_resize(ObAction **a, ObUserAction uact)
(*a)->data.moveresize.any.client_action = OB_CLIENT_ACTION_ALWAYS; (*a)->data.moveresize.any.client_action = OB_CLIENT_ACTION_ALWAYS;
(*a)->data.moveresize.move = FALSE; (*a)->data.moveresize.move = FALSE;
(*a)->data.moveresize.keyboard = (*a)->data.moveresize.keyboard =
(uact == OB_USER_ACTION_KEYBOARD_KEY || (uact == OB_USER_ACTION_NONE ||
uact == OB_USER_ACTION_KEYBOARD_KEY ||
uact == OB_USER_ACTION_MENU_SELECTION); uact == OB_USER_ACTION_MENU_SELECTION);
} }
@ -903,11 +921,24 @@ void action_run_list(GSList *acts, ObClient *c, ObFrameContext context,
keyboard_interactive_grab(state, a->data.any.c, a); keyboard_interactive_grab(state, a->data.any.c, a);
} }
a->func(&a->data); ob_main_loop_queue_action(ob_main_loop, a);
} }
} }
} }
void action_run_string(const gchar *name, struct _ObClient *c)
{
ObAction *a;
GSList *l;
a = action_from_string(name, OB_USER_ACTION_NONE);
g_assert(a);
l = g_slist_append(NULL, a);
action_run(l, c, 0);
}
void action_execute(union ActionData *data) void action_execute(union ActionData *data)
{ {
GError *e = NULL; GError *e = NULL;

View file

@ -180,6 +180,8 @@ ObAction *action_parse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
void action_ref(ObAction *a); void action_ref(ObAction *a);
void action_unref(ObAction *a); void action_unref(ObAction *a);
ObAction* action_copy(const ObAction *a);
/*! Executes a list of actions. /*! Executes a list of actions.
@param c The client associated with the action. Can be NULL. @param c The client associated with the action. Can be NULL.
@param state The keyboard modifiers state at the time the user action occured @param state The keyboard modifiers state at the time the user action occured
@ -207,6 +209,10 @@ void action_run_list(GSList *acts, struct _ObClient *c, ObFrameContext context,
#define action_run(a, c, s) \ #define action_run(a, c, s) \
action_run_list(a, c, OB_FRAME_CONTEXT_NONE, s, 0, -1, -1, FALSE, FALSE) action_run_list(a, c, OB_FRAME_CONTEXT_NONE, s, 0, -1, -1, FALSE, FALSE)
/*! This is only for internal usage, i.e. not meant for user bindings and
such! */
void action_run_string(const gchar *name, struct _ObClient *c);
/* Execute */ /* Execute */
void action_execute(union ActionData *data); void action_execute(union ActionData *data);
/* ActivateAction */ /* ActivateAction */