]>
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_switch_func(ObParseInst
*i
, xmlDocPtr doc
,
31 static gpointer
setup_send_func(ObParseInst
*i
, xmlDocPtr doc
,
33 static gboolean
run_func(ObActionsData
*data
, gpointer options
);
35 void action_desktop_startup()
37 actions_register("SwitchToDesktop", setup_switch_func
, g_free
, run_func
,
39 actions_register("SendToDesktop", setup_send_func
, g_free
, run_func
,
43 static gpointer
setup_switch_func(ObParseInst
*i
, xmlDocPtr doc
,
49 o
= g_new0(Options
, 1);
50 /* don't go anywhere if theres no options given */
52 o
->abs
.desktop
= screen_desktop
;
53 /* wrap by default - it's handy! */
56 if ((n
= parse_find_node("to", node
))) {
57 gchar
*s
= parse_string(doc
, n
);
58 if (!g_ascii_strcasecmp(s
, "last") ||
59 !g_ascii_strcasecmp(s
, "previous"))
61 else if (!g_ascii_strcasecmp(s
, "next")) {
64 o
->rel
.dir
= OB_DIRECTION_EAST
;
66 else if (!g_ascii_strcasecmp(s
, "previous")) {
69 o
->rel
.dir
= OB_DIRECTION_WEST
;
71 else if (!g_ascii_strcasecmp(s
, "north") ||
72 !g_ascii_strcasecmp(s
, "up")) {
74 o
->rel
.dir
= OB_DIRECTION_NORTH
;
76 else if (!g_ascii_strcasecmp(s
, "south") ||
77 !g_ascii_strcasecmp(s
, "down")) {
79 o
->rel
.dir
= OB_DIRECTION_SOUTH
;
81 else if (!g_ascii_strcasecmp(s
, "west") ||
82 !g_ascii_strcasecmp(s
, "left")) {
84 o
->rel
.dir
= OB_DIRECTION_WEST
;
86 else if (!g_ascii_strcasecmp(s
, "east") ||
87 !g_ascii_strcasecmp(s
, "right")) {
89 o
->rel
.dir
= OB_DIRECTION_EAST
;
93 o
->abs
.desktop
= parse_int(doc
, n
) - 1;
98 if ((n
= parse_find_node("wrap", node
)))
99 o
->rel
.wrap
= parse_bool(doc
, n
);
104 static gpointer
setup_send_func(ObParseInst
*i
, xmlDocPtr doc
,
107 Options
*o
= setup_switch_func(i
, doc
, node
);
111 if ((n
= parse_find_node("follow", node
)))
112 o
->follow
= parse_bool(doc
, n
);
117 /* Always return FALSE because its not interactive */
118 static gboolean
run_func(ObActionsData
*data
, gpointer options
)
120 Options
*o
= options
;
127 d
= screen_last_desktop
;
133 d
= screen_cycle_desktop(o
->abs
.dir
,
140 if (d
< screen_num_desktops
&& d
!= screen_desktop
) {
143 if (o
->send
&& data
->client
&& client_normal(data
->client
)) {
144 client_set_desktop(data
->client
, d
, o
->follow
, FALSE
);
148 if (go
) screen_set_desktop(d
, TRUE
);
This page took 0.03991 seconds and 5 git commands to generate.