1 #include "openbox/actions.h"
2 #include "openbox/screen.h"
3 #include "openbox/client.h"
29 static gpointer setup_go_func(xmlNodePtr node);
30 static gpointer setup_send_func(xmlNodePtr node);
31 static gboolean run_func(ObActionsData *data, gpointer options);
33 void action_desktop_startup(void)
35 actions_register("GoToDesktop", setup_go_func, g_free, run_func,
37 actions_register("SendToDesktop", setup_send_func, g_free, run_func,
41 static gpointer setup_go_func(xmlNodePtr node)
46 o = g_new0(Options, 1);
47 /* don't go anywhere if theres no options given */
49 o->abs.desktop = screen_desktop;
50 /* wrap by default - it's handy! */
53 if ((n = obt_parse_find_node(node, "to"))) {
54 gchar *s = obt_parse_node_string(n);
55 if (!g_ascii_strcasecmp(s, "last"))
57 else if (!g_ascii_strcasecmp(s, "next")) {
60 o->rel.dir = OB_DIRECTION_EAST;
62 else if (!g_ascii_strcasecmp(s, "previous")) {
65 o->rel.dir = OB_DIRECTION_WEST;
67 else if (!g_ascii_strcasecmp(s, "north") ||
68 !g_ascii_strcasecmp(s, "up")) {
70 o->rel.dir = OB_DIRECTION_NORTH;
72 else if (!g_ascii_strcasecmp(s, "south") ||
73 !g_ascii_strcasecmp(s, "down")) {
75 o->rel.dir = OB_DIRECTION_SOUTH;
77 else if (!g_ascii_strcasecmp(s, "west") ||
78 !g_ascii_strcasecmp(s, "left")) {
80 o->rel.dir = OB_DIRECTION_WEST;
82 else if (!g_ascii_strcasecmp(s, "east") ||
83 !g_ascii_strcasecmp(s, "right")) {
85 o->rel.dir = OB_DIRECTION_EAST;
89 o->abs.desktop = obt_parse_node_int(n) - 1;
94 if ((n = obt_parse_find_node(node, "wrap")))
95 o->rel.wrap = obt_parse_node_bool(n);
100 static gpointer setup_send_func(xmlNodePtr node)
105 o = setup_go_func(node);
109 if ((n = obt_parse_find_node(node, "follow")))
110 o->follow = obt_parse_node_bool(n);
115 /* Always return FALSE because its not interactive */
116 static gboolean run_func(ObActionsData *data, gpointer options)
118 Options *o = options;
125 d = screen_last_desktop;
131 d = screen_find_desktop(screen_desktop,
132 o->rel.dir, o->rel.wrap, o->rel.linear);
136 if (d < screen_num_desktops && d != screen_desktop) {
139 if (o->send && data->client && client_normal(data->client)) {
140 client_set_desktop(data->client, d, o->follow, FALSE);
144 if (go) screen_set_desktop(d, TRUE);