]>
Dogcows Code - chaz/openbox/blob - openbox/actions/desktop.c
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
);
32 /* 3.4-compatibility */
33 static gpointer
setup_go_last_func(xmlNodePtr node
);
34 static gpointer
setup_send_last_func(xmlNodePtr node
);
35 static gpointer
setup_go_abs_func(xmlNodePtr node
);
36 static gpointer
setup_send_abs_func(xmlNodePtr node
);
37 static gpointer
setup_go_next_func(xmlNodePtr node
);
38 static gpointer
setup_send_next_func(xmlNodePtr node
);
39 static gpointer
setup_go_prev_func(xmlNodePtr node
);
40 static gpointer
setup_send_prev_func(xmlNodePtr node
);
41 static gpointer
setup_go_left_func(xmlNodePtr node
);
42 static gpointer
setup_send_left_func(xmlNodePtr node
);
43 static gpointer
setup_go_right_func(xmlNodePtr node
);
44 static gpointer
setup_send_right_func(xmlNodePtr node
);
45 static gpointer
setup_go_up_func(xmlNodePtr node
);
46 static gpointer
setup_send_up_func(xmlNodePtr node
);
47 static gpointer
setup_go_down_func(xmlNodePtr node
);
48 static gpointer
setup_send_down_func(xmlNodePtr node
);
50 void action_desktop_startup(void)
52 actions_register("GoToDesktop", setup_go_func
, g_free
, run_func
,
54 actions_register("SendToDesktop", setup_send_func
, g_free
, run_func
,
56 /* 3.4-compatibility */
57 actions_register("DesktopLast", setup_go_last_func
, g_free
, run_func
,
59 actions_register("SendToDesktopLast", setup_send_last_func
, g_free
, run_func
,
61 actions_register("Desktop", setup_go_abs_func
, g_free
, run_func
,
63 actions_register("SendToDesktop", setup_send_abs_func
, g_free
, run_func
,
65 actions_register("DesktopNext", setup_go_next_func
, g_free
, run_func
,
67 actions_register("SendToDesktopNext", setup_send_next_func
, g_free
, run_func
,
69 actions_register("DesktopPrevious", setup_go_prev_func
, g_free
, run_func
,
71 actions_register("SendToDesktopPrevious", setup_send_prev_func
, g_free
, run_func
,
73 actions_register("DesktopLeft", setup_go_left_func
, g_free
, run_func
,
75 actions_register("SendToDesktopLeft", setup_send_left_func
, g_free
, run_func
,
77 actions_register("DesktopRight", setup_go_right_func
, g_free
, run_func
,
79 actions_register("SendToDesktopRight", setup_send_right_func
, g_free
, run_func
,
81 actions_register("DesktopUp", setup_go_up_func
, g_free
, run_func
,
83 actions_register("SendToDesktopUp", setup_send_up_func
, g_free
, run_func
,
85 actions_register("DesktopDown", setup_go_down_func
, g_free
, run_func
,
87 actions_register("SendToDesktopDown", setup_send_down_func
, g_free
, run_func
,
91 static gpointer
setup_go_func(xmlNodePtr node
)
96 o
= g_new0(Options
, 1);
97 /* don't go anywhere if there are no options given */
99 o
->u
.abs
.desktop
= screen_desktop
;
100 /* wrap by default - it's handy! */
101 o
->u
.rel
.wrap
= TRUE
;
103 if ((n
= obt_parse_find_node(node
, "to"))) {
104 gchar
*s
= obt_parse_node_string(n
);
105 if (!g_ascii_strcasecmp(s
, "last"))
107 else if (!g_ascii_strcasecmp(s
, "next")) {
109 o
->u
.rel
.linear
= TRUE
;
110 o
->u
.rel
.dir
= OB_DIRECTION_EAST
;
112 else if (!g_ascii_strcasecmp(s
, "previous")) {
114 o
->u
.rel
.linear
= TRUE
;
115 o
->u
.rel
.dir
= OB_DIRECTION_WEST
;
117 else if (!g_ascii_strcasecmp(s
, "north") ||
118 !g_ascii_strcasecmp(s
, "up")) {
120 o
->u
.rel
.dir
= OB_DIRECTION_NORTH
;
122 else if (!g_ascii_strcasecmp(s
, "south") ||
123 !g_ascii_strcasecmp(s
, "down")) {
125 o
->u
.rel
.dir
= OB_DIRECTION_SOUTH
;
127 else if (!g_ascii_strcasecmp(s
, "west") ||
128 !g_ascii_strcasecmp(s
, "left")) {
130 o
->u
.rel
.dir
= OB_DIRECTION_WEST
;
132 else if (!g_ascii_strcasecmp(s
, "east") ||
133 !g_ascii_strcasecmp(s
, "right")) {
135 o
->u
.rel
.dir
= OB_DIRECTION_EAST
;
139 o
->u
.abs
.desktop
= atoi(s
) - 1;
144 if ((n
= obt_parse_find_node(node
, "wrap")))
145 o
->u
.rel
.wrap
= obt_parse_node_bool(n
);
150 static gpointer
setup_send_func(xmlNodePtr node
)
155 o
= setup_go_func(node
);
159 if ((n
= obt_parse_find_node(node
, "follow")))
160 o
->follow
= obt_parse_node_bool(n
);
165 /* Always return FALSE because its not interactive */
166 static gboolean
run_func(ObActionsData
*data
, gpointer options
)
168 Options
*o
= options
;
173 d
= screen_last_desktop
;
176 d
= o
->u
.abs
.desktop
;
179 d
= screen_find_desktop(screen_desktop
,
180 o
->u
.rel
.dir
, o
->u
.rel
.wrap
, o
->u
.rel
.linear
);
184 if (d
< screen_num_desktops
&& d
!= screen_desktop
) {
187 actions_client_move(data
, TRUE
);
188 if (o
->send
&& data
->client
&& client_normal(data
->client
)) {
189 client_set_desktop(data
->client
, d
, o
->follow
, FALSE
);
194 screen_set_desktop(d
, TRUE
);
196 client_bring_helper_windows(data
->client
);
199 actions_client_move(data
, FALSE
);
204 /* 3.4-compatilibity */
205 static gpointer
setup_follow(xmlNodePtr node
)
208 Options
*o
= g_new0(Options
, 1);
211 if ((n
= obt_parse_find_node(node
, "follow")))
212 o
->follow
= obt_parse_node_bool(n
);
216 static gpointer
setup_go_last_func(xmlNodePtr node
)
218 Options
*o
= g_new0(Options
, 1);
223 static gpointer
setup_send_last_func(xmlNodePtr node
)
225 Options
*o
= setup_follow(node
);
230 static gpointer
setup_go_abs_func(xmlNodePtr node
)
233 Options
*o
= g_new0(Options
, 1);
235 if ((n
= obt_parse_find_node(node
, "desktop")))
236 o
->u
.abs
.desktop
= obt_parse_node_int(n
) - 1;
238 o
->u
.abs
.desktop
= screen_desktop
;
242 static gpointer
setup_send_abs_func(xmlNodePtr node
)
245 Options
*o
= setup_follow(node
);
247 if ((n
= obt_parse_find_node(node
, "desktop")))
248 o
->u
.abs
.desktop
= obt_parse_node_int(n
) - 1;
250 o
->u
.abs
.desktop
= screen_desktop
;
254 static void setup_rel(Options
*o
, xmlNodePtr node
, gboolean lin
, ObDirection dir
)
259 o
->u
.rel
.linear
= lin
;
261 o
->u
.rel
.wrap
= TRUE
;
263 if ((n
= obt_parse_find_node(node
, "wrap")))
264 o
->u
.rel
.wrap
= obt_parse_node_bool(n
);
267 static gpointer
setup_go_next_func(xmlNodePtr node
)
269 Options
*o
= g_new0(Options
, 1);
270 setup_rel(o
, node
, TRUE
, OB_DIRECTION_EAST
);
274 static gpointer
setup_send_next_func(xmlNodePtr node
)
276 Options
*o
= setup_follow(node
);
277 setup_rel(o
, node
, TRUE
, OB_DIRECTION_EAST
);
281 static gpointer
setup_go_prev_func(xmlNodePtr node
)
283 Options
*o
= g_new0(Options
, 1);
284 setup_rel(o
, node
, TRUE
, OB_DIRECTION_WEST
);
288 static gpointer
setup_send_prev_func(xmlNodePtr node
)
290 Options
*o
= setup_follow(node
);
291 setup_rel(o
, node
, TRUE
, OB_DIRECTION_WEST
);
295 static gpointer
setup_go_left_func(xmlNodePtr node
)
297 Options
*o
= g_new0(Options
, 1);
298 setup_rel(o
, node
, FALSE
, OB_DIRECTION_WEST
);
302 static gpointer
setup_send_left_func(xmlNodePtr node
)
304 Options
*o
= setup_follow(node
);
305 setup_rel(o
, node
, FALSE
, OB_DIRECTION_WEST
);
309 static gpointer
setup_go_right_func(xmlNodePtr node
)
311 Options
*o
= g_new0(Options
, 1);
312 setup_rel(o
, node
, FALSE
, OB_DIRECTION_EAST
);
316 static gpointer
setup_send_right_func(xmlNodePtr node
)
318 Options
*o
= setup_follow(node
);
319 setup_rel(o
, node
, FALSE
, OB_DIRECTION_EAST
);
323 static gpointer
setup_go_up_func(xmlNodePtr node
)
325 Options
*o
= g_new0(Options
, 1);
326 setup_rel(o
, node
, FALSE
, OB_DIRECTION_NORTH
);
330 static gpointer
setup_send_up_func(xmlNodePtr node
)
332 Options
*o
= setup_follow(node
);
333 setup_rel(o
, node
, FALSE
, OB_DIRECTION_NORTH
);
337 static gpointer
setup_go_down_func(xmlNodePtr node
)
339 Options
*o
= g_new0(Options
, 1);
340 setup_rel(o
, node
, FALSE
, OB_DIRECTION_SOUTH
);
344 static gpointer
setup_send_down_func(xmlNodePtr node
)
346 Options
*o
= setup_follow(node
);
347 setup_rel(o
, node
, FALSE
, OB_DIRECTION_SOUTH
);
This page took 0.049297 seconds and 5 git commands to generate.