1 #include "openbox/actions.h"
2 #include "openbox/screen.h"
3 #include "openbox/client.h"
29 static gpointer setup_go_last_func(ObParseInst *i, xmlDocPtr doc,
31 static gpointer setup_send_last_func(ObParseInst *i, xmlDocPtr doc,
33 static gpointer setup_go_abs_func(ObParseInst *i, xmlDocPtr doc,
35 static gpointer setup_send_abs_func(ObParseInst *i, xmlDocPtr doc,
37 static gpointer setup_go_next_func(ObParseInst *i, xmlDocPtr doc,
39 static gpointer setup_send_next_func(ObParseInst *i, xmlDocPtr doc,
41 static gpointer setup_go_prev_func(ObParseInst *i, xmlDocPtr doc,
43 static gpointer setup_send_prev_func(ObParseInst *i, xmlDocPtr doc,
45 static gpointer setup_go_left_func(ObParseInst *i, xmlDocPtr doc,
47 static gpointer setup_send_left_func(ObParseInst *i, xmlDocPtr doc,
49 static gpointer setup_go_right_func(ObParseInst *i, xmlDocPtr doc,
51 static gpointer setup_send_right_func(ObParseInst *i, xmlDocPtr doc,
53 static gpointer setup_go_up_func(ObParseInst *i, xmlDocPtr doc,
55 static gpointer setup_send_up_func(ObParseInst *i, xmlDocPtr doc,
57 static gpointer setup_go_down_func(ObParseInst *i, xmlDocPtr doc,
59 static gpointer setup_send_down_func(ObParseInst *i, xmlDocPtr doc,
61 static gboolean run_func(ObActionsData *data, gpointer options);
63 void action_desktop_startup(void)
65 actions_register("DesktopLast", setup_go_last_func, g_free,
66 run_func, NULL, NULL);
67 actions_register("SendToDesktopLast", setup_send_last_func, g_free,
68 run_func, NULL, NULL);
69 actions_register("Desktop", setup_go_abs_func, g_free,
70 run_func, NULL, NULL);
71 actions_register("SendToDesktop", setup_send_abs_func, g_free,
72 run_func, NULL, NULL);
73 actions_register("DesktopNext", setup_go_next_func, g_free,
74 run_func, NULL, NULL);
75 actions_register("SendToDesktopNext", setup_send_next_func, g_free,
76 run_func, NULL, NULL);
77 actions_register("DesktopPrevious", setup_go_prev_func, g_free,
78 run_func, NULL, NULL);
79 actions_register("SendToDesktopPrevious", setup_send_prev_func, g_free,
80 run_func, NULL, NULL);
81 actions_register("DesktopLeft", setup_go_left_func, g_free,
82 run_func, NULL, NULL);
83 actions_register("SendToDesktopLeft", setup_send_left_func, g_free,
84 run_func, NULL, NULL);
85 actions_register("DesktopRight", setup_go_right_func, g_free,
86 run_func, NULL, NULL);
87 actions_register("SendToDesktopRight", setup_send_right_func, g_free,
88 run_func, NULL, NULL);
89 actions_register("DesktopUp", setup_go_up_func, g_free,
90 run_func, NULL, NULL);
91 actions_register("SendToDesktopUp", setup_send_up_func, g_free,
92 run_func, NULL, NULL);
93 actions_register("DesktopDown", setup_go_down_func, g_free,
94 run_func, NULL, NULL);
95 actions_register("SendToDesktopDown", setup_send_down_func, g_free,
96 run_func, NULL, NULL);
99 static gpointer setup_follow(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
102 Options *o = g_new0(Options, 1);
105 if ((n = parse_find_node("follow", node)))
106 o->follow = parse_bool(doc, n);
110 static gpointer setup_go_last_func(ObParseInst *i, xmlDocPtr doc,
113 Options *o = g_new0(Options, 1);
118 static gpointer setup_send_last_func(ObParseInst *i, xmlDocPtr doc,
121 Options *o = setup_follow(i, doc, node);
126 static gpointer setup_go_abs_func(ObParseInst *i, xmlDocPtr doc,
130 Options *o = g_new0(Options, 1);
132 if ((n = parse_find_node("desktop", node)))
133 o->abs.desktop = parse_int(doc, n) - 1;
135 o->abs.desktop = screen_desktop;
139 static gpointer setup_send_abs_func(ObParseInst *i, xmlDocPtr doc,
143 Options *o = setup_follow(i, doc, node);
145 if ((n = parse_find_node("desktop", node)))
146 o->abs.desktop = parse_int(doc, n) - 1;
148 o->abs.desktop = screen_desktop;
152 static void setup_rel(Options *o, ObParseInst *i, xmlDocPtr doc,
153 xmlNodePtr node, gboolean lin, ObDirection dir)
162 if ((n = parse_find_node("wrap", node)))
163 o->rel.wrap = parse_bool(doc, n);
166 static gpointer setup_go_next_func(ObParseInst *i, xmlDocPtr doc,
169 Options *o = g_new0(Options, 1);
170 setup_rel(o, i, doc, node, TRUE, OB_DIRECTION_EAST);
174 static gpointer setup_send_next_func(ObParseInst *i, xmlDocPtr doc,
177 Options *o = setup_follow(i, doc, node);
178 setup_rel(o, i, doc, node, TRUE, OB_DIRECTION_EAST);
182 static gpointer setup_go_prev_func(ObParseInst *i, xmlDocPtr doc,
185 Options *o = g_new0(Options, 1);
186 setup_rel(o, i, doc, node, TRUE, OB_DIRECTION_WEST);
190 static gpointer setup_send_prev_func(ObParseInst *i, xmlDocPtr doc,
193 Options *o = setup_follow(i, doc, node);
194 setup_rel(o, i, doc, node, TRUE, OB_DIRECTION_WEST);
198 static gpointer setup_go_left_func(ObParseInst *i, xmlDocPtr doc,
201 Options *o = g_new0(Options, 1);
202 setup_rel(o, i, doc, node, FALSE, OB_DIRECTION_WEST);
206 static gpointer setup_send_left_func(ObParseInst *i, xmlDocPtr doc,
209 Options *o = setup_follow(i, doc, node);
210 setup_rel(o, i, doc, node, FALSE, OB_DIRECTION_WEST);
214 static gpointer setup_go_right_func(ObParseInst *i, xmlDocPtr doc,
217 Options *o = g_new0(Options, 1);
218 setup_rel(o, i, doc, node, FALSE, OB_DIRECTION_EAST);
222 static gpointer setup_send_right_func(ObParseInst *i, xmlDocPtr doc,
225 Options *o = setup_follow(i, doc, node);
226 setup_rel(o, i, doc, node, FALSE, OB_DIRECTION_EAST);
230 static gpointer setup_go_up_func(ObParseInst *i, xmlDocPtr doc,
233 Options *o = g_new0(Options, 1);
234 setup_rel(o, i, doc, node, FALSE, OB_DIRECTION_NORTH);
238 static gpointer setup_send_up_func(ObParseInst *i, xmlDocPtr doc,
241 Options *o = setup_follow(i, doc, node);
242 setup_rel(o, i, doc, node, FALSE, OB_DIRECTION_NORTH);
246 static gpointer setup_go_down_func(ObParseInst *i, xmlDocPtr doc,
249 Options *o = g_new0(Options, 1);
250 setup_rel(o, i, doc, node, FALSE, OB_DIRECTION_SOUTH);
254 static gpointer setup_send_down_func(ObParseInst *i, xmlDocPtr doc,
257 Options *o = setup_follow(i, doc, node);
258 setup_rel(o, i, doc, node, FALSE, OB_DIRECTION_SOUTH);
262 /* Always return FALSE because its not interactive */
263 static gboolean run_func(ObActionsData *data, gpointer options)
265 Options *o = options;
272 d = screen_last_desktop;
278 d = screen_find_desktop(screen_desktop,
279 o->rel.dir, o->rel.wrap, o->rel.linear);
283 if (d < screen_num_desktops && d != screen_desktop) {
286 if (o->send && data->client && client_normal(data->client)) {
287 client_set_desktop(data->client, d, o->follow, FALSE);
291 if (go) screen_set_desktop(d, TRUE);