+ObAction *action_parse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
+ ObUserAction uact)
+{
+ char *actname;
+ ObAction *act = NULL;
+ xmlNodePtr n;
+
+ if (parse_attr_string("name", node, &actname)) {
+ if ((act = action_from_string(actname, uact))) {
+ if (act->func == action_execute || act->func == action_restart) {
+ if ((n = parse_find_node("execute", node->xmlChildrenNode))) {
+ gchar *s = parse_string(doc, n);
+ act->data.execute.path = parse_expand_tilde(s);
+ g_free(s);
+ }
+ } else if (act->func == action_showmenu) {
+ if ((n = parse_find_node("menu", node->xmlChildrenNode)))
+ act->data.showmenu.name = parse_string(doc, n);
+ } else if (act->func == action_move_relative_horz ||
+ act->func == action_move_relative_vert ||
+ act->func == action_resize_relative_horz ||
+ act->func == action_resize_relative_vert) {
+ if ((n = parse_find_node("delta", node->xmlChildrenNode)))
+ act->data.relative.delta = parse_int(doc, n);
+ } else if (act->func == action_desktop) {
+ if ((n = parse_find_node("desktop", node->xmlChildrenNode)))
+ act->data.desktop.desk = parse_int(doc, n);
+ if (act->data.desktop.desk > 0) act->data.desktop.desk--;
+ } else if (act->func == action_send_to_desktop) {
+ if ((n = parse_find_node("desktop", node->xmlChildrenNode)))
+ act->data.sendto.desk = parse_int(doc, n);
+ if (act->data.sendto.desk > 0) act->data.sendto.desk--;
+ if ((n = parse_find_node("follow", node->xmlChildrenNode)))
+ act->data.sendto.follow = parse_bool(doc, n);
+ } else if (act->func == action_desktop_dir) {
+ if ((n = parse_find_node("wrap", node->xmlChildrenNode)))
+ act->data.desktopdir.wrap = parse_bool(doc, n);
+ } else if (act->func == action_send_to_desktop_dir) {
+ if ((n = parse_find_node("wrap", node->xmlChildrenNode)))
+ act->data.sendtodir.wrap = parse_bool(doc, n);
+ if ((n = parse_find_node("follow", node->xmlChildrenNode)))
+ act->data.sendtodir.follow = parse_bool(doc, n);
+ } else if (act->func == action_activate) {
+ if ((n = parse_find_node("here", node->xmlChildrenNode)))
+ act->data.activate.here = parse_bool(doc, n);
+ } else if (act->func == action_cycle_windows) {
+ if ((n = parse_find_node("linear", node->xmlChildrenNode)))
+ act->data.cycle.linear = parse_bool(doc, n);
+ }
+ }
+ g_free(actname);
+ }
+ return act;
+}
+
+void action_run_list(GSList *acts, ObClient *c, ObFrameContext context,
+ guint state, guint button, gint x, gint y,
+ gboolean cancel, gboolean done)
+{
+ GSList *it;
+ ObAction *a;
+ gboolean inter = FALSE;
+
+ if (!acts)
+ return;
+
+ if (x < 0 && y < 0)
+ screen_pointer_pos(&x, &y);
+
+ if (grab_on_keyboard())
+ inter = TRUE;
+ else
+ for (it = acts; it; it = g_slist_next(it)) {
+ a = it->data;
+ if (a->data.any.interactive) {
+ inter = TRUE;
+ break;
+ }
+ }
+
+ if (!inter) {
+ /* sometimes when we execute another app as an action,
+ it won't work right unless we XUngrabKeyboard first,
+ even though we grabbed the key/button Asychronously.
+ e.g. "gnome-panel-control --main-menu" */
+ XUngrabKeyboard(ob_display, event_lasttime);
+ }
+
+ for (it = acts; it; it = g_slist_next(it)) {
+ a = it->data;
+
+ a->data.any.c = c;
+ a->data.any.context = context;
+ a->data.any.x = x;
+ a->data.any.y = y;
+
+ a->data.any.button = button;
+
+ if (a->data.any.interactive) {
+ a->data.inter.cancel = cancel;
+ a->data.inter.final = done;
+ if (!(cancel || done))
+ keyboard_interactive_grab(state, c, a);
+ }
+
+ a->func(&a->data);
+ }
+}
+