+ if (ok) {
+ if (!act->def->run(&data, act->options))
+ actions_interactive_end_act();
+ else
+ break; /* no actions are run after the interactive one */
+ }
+ }
+}
+
+gboolean actions_interactive_act_running()
+{
+ return interactive_act != NULL;
+}
+
+void actions_interactive_cancel_act()
+{
+ if (interactive_act) {
+ interactive_act->def->i_cancel(interactive_act->options);
+ actions_interactive_end_act();
+ }
+}
+
+static gboolean actions_interactive_begin_act(ObActionsAct *act, guint state)
+{
+ /* cancel the old one */
+ if (interactive_act)
+ actions_interactive_cancel_act();
+
+ if (grab_keyboard()) {
+ interactive_act = act;
+ actions_act_ref(interactive_act);
+
+ interactive_initial_state = state;
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+static void actions_interactive_end_act()
+{
+ if (interactive_act) {
+ ungrab_keyboard();
+
+ actions_act_unref(interactive_act);
+ interactive_act = NULL;
+ }
+}
+
+gboolean actions_interactive_input_event(XEvent *e)
+{
+ gboolean used = FALSE;
+ if (interactive_act) {
+ if (!interactive_act->def->i_input(interactive_initial_state, e,
+ interactive_act->options, &used))
+ {
+ used = TRUE; /* if it cancelled the action then it has to of
+ been used */
+ actions_interactive_end_act();
+ }