]>
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
);
183 g_assert_not_reached();
186 if (d
< screen_num_desktops
&& d
!= screen_desktop
) {
189 actions_client_move(data
, TRUE
);
190 if (o
->send
&& data
->client
&& client_normal(data
->client
)) {
191 client_set_desktop(data
->client
, d
, o
->follow
, FALSE
);
196 screen_set_desktop(d
, TRUE
);
198 client_bring_helper_windows(data
->client
);
201 actions_client_move(data
, FALSE
);
206 /* 3.4-compatilibity */
207 static gpointer
setup_follow(xmlNodePtr node
)
210 Options
*o
= g_new0(Options
, 1);
213 if ((n
= obt_parse_find_node(node
, "follow")))
214 o
->follow
= obt_parse_node_bool(n
);
218 static gpointer
setup_go_last_func(xmlNodePtr node
)
220 Options
*o
= g_new0(Options
, 1);
225 static gpointer
setup_send_last_func(xmlNodePtr node
)
227 Options
*o
= setup_follow(node
);
232 static gpointer
setup_go_abs_func(xmlNodePtr node
)
235 Options
*o
= g_new0(Options
, 1);
237 if ((n
= obt_parse_find_node(node
, "desktop")))
238 o
->u
.abs
.desktop
= obt_parse_node_int(n
) - 1;
240 o
->u
.abs
.desktop
= screen_desktop
;
244 static gpointer
setup_send_abs_func(xmlNodePtr node
)
247 Options
*o
= setup_follow(node
);
249 if ((n
= obt_parse_find_node(node
, "desktop")))
250 o
->u
.abs
.desktop
= obt_parse_node_int(n
) - 1;
252 o
->u
.abs
.desktop
= screen_desktop
;
256 static void setup_rel(Options
*o
, xmlNodePtr node
, gboolean lin
, ObDirection dir
)
261 o
->u
.rel
.linear
= lin
;
263 o
->u
.rel
.wrap
= TRUE
;
265 if ((n
= obt_parse_find_node(node
, "wrap")))
266 o
->u
.rel
.wrap
= obt_parse_node_bool(n
);
269 static gpointer
setup_go_next_func(xmlNodePtr node
)
271 Options
*o
= g_new0(Options
, 1);
272 setup_rel(o
, node
, TRUE
, OB_DIRECTION_EAST
);
276 static gpointer
setup_send_next_func(xmlNodePtr node
)
278 Options
*o
= setup_follow(node
);
279 setup_rel(o
, node
, TRUE
, OB_DIRECTION_EAST
);
283 static gpointer
setup_go_prev_func(xmlNodePtr node
)
285 Options
*o
= g_new0(Options
, 1);
286 setup_rel(o
, node
, TRUE
, OB_DIRECTION_WEST
);
290 static gpointer
setup_send_prev_func(xmlNodePtr node
)
292 Options
*o
= setup_follow(node
);
293 setup_rel(o
, node
, TRUE
, OB_DIRECTION_WEST
);
297 static gpointer
setup_go_left_func(xmlNodePtr node
)
299 Options
*o
= g_new0(Options
, 1);
300 setup_rel(o
, node
, FALSE
, OB_DIRECTION_WEST
);
304 static gpointer
setup_send_left_func(xmlNodePtr node
)
306 Options
*o
= setup_follow(node
);
307 setup_rel(o
, node
, FALSE
, OB_DIRECTION_WEST
);
311 static gpointer
setup_go_right_func(xmlNodePtr node
)
313 Options
*o
= g_new0(Options
, 1);
314 setup_rel(o
, node
, FALSE
, OB_DIRECTION_EAST
);
318 static gpointer
setup_send_right_func(xmlNodePtr node
)
320 Options
*o
= setup_follow(node
);
321 setup_rel(o
, node
, FALSE
, OB_DIRECTION_EAST
);
325 static gpointer
setup_go_up_func(xmlNodePtr node
)
327 Options
*o
= g_new0(Options
, 1);
328 setup_rel(o
, node
, FALSE
, OB_DIRECTION_NORTH
);
332 static gpointer
setup_send_up_func(xmlNodePtr node
)
334 Options
*o
= setup_follow(node
);
335 setup_rel(o
, node
, FALSE
, OB_DIRECTION_NORTH
);
339 static gpointer
setup_go_down_func(xmlNodePtr node
)
341 Options
*o
= g_new0(Options
, 1);
342 setup_rel(o
, node
, FALSE
, OB_DIRECTION_SOUTH
);
346 static gpointer
setup_send_down_func(xmlNodePtr node
)
348 Options
*o
= setup_follow(node
);
349 setup_rel(o
, node
, FALSE
, OB_DIRECTION_SOUTH
);
This page took 0.048552 seconds and 5 git commands to generate.