+ObAction *action_parse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
+ ObUserAction uact)
+{
+ gchar *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);
+ }
+ if ((n = parse_find_node("startupnotify", node->xmlChildrenNode))) {
+ xmlNodePtr m;
+ if ((m = parse_find_node("enabled", n->xmlChildrenNode)))
+ act->data.execute.startupnotify = parse_bool(doc, m);
+ if ((m = parse_find_node("name", n->xmlChildrenNode)))
+ act->data.execute.name = parse_string(doc, m);
+ if ((m = parse_find_node("icon", n->xmlChildrenNode)))
+ act->data.execute.icon_name = parse_string(doc, m);
+ }
+ } else if (act->func == action_debug) {
+ if ((n = parse_find_node("string", node->xmlChildrenNode)))
+ act->data.debug.string = parse_string(doc, n);
+ } 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.deltax = parse_int(doc, n);
+ } else if (act->func == action_move_relative) {
+ if ((n = parse_find_node("x", node->xmlChildrenNode)))
+ act->data.relative.deltax = parse_int(doc, n);
+ if ((n = parse_find_node("y", node->xmlChildrenNode)))
+ act->data.relative.deltay = parse_int(doc, n);
+ } else if (act->func == action_resize_relative) {
+ if ((n = parse_find_node("left", node->xmlChildrenNode)))
+ act->data.relative.deltaxl = parse_int(doc, n);
+ if ((n = parse_find_node("up", node->xmlChildrenNode)))
+ act->data.relative.deltayu = parse_int(doc, n);
+ if ((n = parse_find_node("right", node->xmlChildrenNode)))
+ act->data.relative.deltax = parse_int(doc, n);
+ if ((n = parse_find_node("down", node->xmlChildrenNode)))
+ act->data.relative.deltay = 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--;
+/*
+ if ((n = parse_find_node("dialog", node->xmlChildrenNode)))
+ act->data.desktop.inter.any.interactive =
+ parse_bool(doc, n);
+*/
+ } 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);
+ if ((n = parse_find_node("dialog", node->xmlChildrenNode)))
+ act->data.desktopdir.inter.any.interactive =
+ 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);
+ if ((n = parse_find_node("dialog", node->xmlChildrenNode)))
+ act->data.sendtodir.inter.any.interactive =
+ 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);
+ if ((n = parse_find_node("dialog", node->xmlChildrenNode)))
+ act->data.cycle.dialog = parse_bool(doc, n);
+ if ((n = parse_find_node("panels", node->xmlChildrenNode)))
+ act->data.cycle.dock_windows = parse_bool(doc, n);
+ if ((n = parse_find_node("desktop", node->xmlChildrenNode)))
+ act->data.cycle.desktop_windows = parse_bool(doc, n);
+ if ((n = parse_find_node("allDesktops",
+ node->xmlChildrenNode)))
+ act->data.cycle.all_desktops = parse_bool(doc, n);
+ } else if (act->func == action_directional_focus) {
+ if ((n = parse_find_node("dialog", node->xmlChildrenNode)))
+ act->data.interdiraction.dialog = parse_bool(doc, n);
+ if ((n = parse_find_node("panels", node->xmlChildrenNode)))
+ act->data.interdiraction.dock_windows = parse_bool(doc, n);
+ if ((n = parse_find_node("desktop", node->xmlChildrenNode)))
+ act->data.interdiraction.desktop_windows =
+ parse_bool(doc, n);
+ } else if (act->func == action_resize) {
+ if ((n = parse_find_node("edge", node->xmlChildrenNode))) {
+ gchar *s = parse_string(doc, n);
+ if (!g_ascii_strcasecmp(s, "top"))
+ act->data.moveresize.corner =
+ prop_atoms.net_wm_moveresize_size_top;
+ else if (!g_ascii_strcasecmp(s, "bottom"))
+ act->data.moveresize.corner =
+ prop_atoms.net_wm_moveresize_size_bottom;
+ else if (!g_ascii_strcasecmp(s, "left"))
+ act->data.moveresize.corner =
+ prop_atoms.net_wm_moveresize_size_left;
+ else if (!g_ascii_strcasecmp(s, "right"))
+ act->data.moveresize.corner =
+ prop_atoms.net_wm_moveresize_size_right;
+ else if (!g_ascii_strcasecmp(s, "topleft"))
+ act->data.moveresize.corner =
+ prop_atoms.net_wm_moveresize_size_topleft;
+ else if (!g_ascii_strcasecmp(s, "topright"))
+ act->data.moveresize.corner =
+ prop_atoms.net_wm_moveresize_size_topright;
+ else if (!g_ascii_strcasecmp(s, "bottomleft"))
+ act->data.moveresize.corner =
+ prop_atoms.net_wm_moveresize_size_bottomleft;
+ else if (!g_ascii_strcasecmp(s, "bottomright"))
+ act->data.moveresize.corner =
+ prop_atoms.net_wm_moveresize_size_bottomright;
+ g_free(s);
+ }
+ } else if (act->func == action_raise ||
+ act->func == action_lower ||
+ act->func == action_raiselower ||
+ act->func == action_shadelower ||
+ act->func == action_unshaderaise) {
+ }
+ INTERACTIVE_LIMIT(act, uact);
+ }
+ g_free(actname);
+ }
+ return act;
+}
+
+void action_run_list(GSList *acts, ObClient *c, ObFrameContext context,
+ guint state, guint button, gint x, gint y, Time time,
+ gboolean cancel, gboolean done)
+{
+ GSList *it;
+ ObAction *a;
+
+ if (!acts)
+ return;
+
+ if (x < 0 && y < 0)
+ screen_pointer_pos(&x, &y);
+
+ for (it = acts; it; it = g_slist_next(it)) {
+ a = it->data;
+
+ if (!(a->data.any.client_action == OB_CLIENT_ACTION_ALWAYS && !c)) {
+ a->data.any.c = a->data.any.client_action ? c : NULL;
+ a->data.any.context = context;
+ a->data.any.x = x;
+ a->data.any.y = y;
+
+ a->data.any.button = button;
+
+ a->data.any.time = time;
+
+ if (a->data.any.interactive) {
+ a->data.inter.cancel = cancel;
+ a->data.inter.final = done;
+ if (!(cancel || done))
+ if (!keyboard_interactive_grab(state, a->data.any.c, a))
+ continue;
+ }
+
+ /* XXX UGLY HACK race with motion event starting a move and the
+ button release gettnig processed first. answer: don't queue
+ moveresize starts. UGLY HACK XXX
+
+ XXX ALSO don't queue showmenu events, because on button press
+ events we need to know if a mouse grab is going to take place,
+ and set the button to 0, so that later motion events don't think
+ that a drag is going on. since showmenu grabs the pointer..
+ */
+ if (a->data.any.interactive || a->func == action_move ||
+ a->func == action_resize || a->func == action_showmenu)
+ {
+ /* interactive actions are not queued */
+ a->func(&a->data);
+ } else if (c &&
+ (context == OB_FRAME_CONTEXT_CLIENT ||
+ (c->type == OB_CLIENT_TYPE_DESKTOP &&
+ context == OB_FRAME_CONTEXT_DESKTOP)) &&
+ (a->func == action_focus ||
+ a->func == action_activate ||
+ a->func == action_showmenu))
+ {
+ /* XXX MORE UGLY HACK
+ actions from clicks on client windows are NOT queued.
+ this solves the mysterious click-and-drag-doesnt-work
+ problem. it was because the window gets focused and stuff
+ after the button event has already been passed through. i
+ dont really know why it should care but it does and it makes
+ a difference.
+
+ however this very bogus ! !
+ we want to send the button press to the window BEFORE
+ we do the action because the action might move the windows
+ (eg change desktops) and then the button press ends up on
+ the completely wrong window !
+ so, this is just for that bug, and it will only NOT queue it
+ if it is a focusing action that can be used with the mouse
+ pointer. ugh.
+
+ also with the menus, there is a race going on. if the
+ desktop wants to pop up a menu, and we do to, we send them
+ the button before we pop up the menu, so they pop up their
+ menu first. but not always. if we pop up our menu before
+ sending them the button press, then the result is
+ deterministic. yay.
+ */
+ a->func(&a->data);
+ } else
+ ob_main_loop_queue_action(ob_main_loop, a);
+ }
+ }
+}
+
+void action_run_string(const gchar *name, struct _ObClient *c, Time time)
+{
+ 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, time);
+}
+
+void action_debug(union ActionData *data)
+{
+ if (data->debug.string)
+ g_print("%s\n", data->debug.string);
+}
+