4 #include "moveresize.h"
16 typedef struct ActionString
{
18 void (*func
)(union ActionData
*);
19 void (*setup
)(ObAction
*);
22 ObAction
*action_new(void (*func
)(union ActionData
*data
))
24 ObAction
*a
= g_new0(ObAction
, 1);
30 void action_free(ObAction
*a
)
32 if (a
== NULL
) return;
34 /* deal with pointers */
35 if (a
->func
== action_execute
|| a
->func
== action_restart
)
36 g_free(a
->data
.execute
.path
);
37 else if (a
->func
== action_showmenu
)
38 g_free(a
->data
.showmenu
.name
);
43 void setup_action_directional_focus_north(ObAction
*a
)
45 a
->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
46 a
->data
.interdiraction
.direction
= OB_DIRECTION_NORTH
;
49 void setup_action_directional_focus_east(ObAction
*a
)
51 a
->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
52 a
->data
.interdiraction
.direction
= OB_DIRECTION_EAST
;
55 void setup_action_directional_focus_south(ObAction
*a
)
57 a
->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
58 a
->data
.interdiraction
.direction
= OB_DIRECTION_SOUTH
;
61 void setup_action_directional_focus_west(ObAction
*a
)
63 a
->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
64 a
->data
.interdiraction
.direction
= OB_DIRECTION_WEST
;
67 void setup_action_directional_focus_northeast(ObAction
*a
)
69 a
->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
70 a
->data
.interdiraction
.direction
= OB_DIRECTION_NORTHEAST
;
73 void setup_action_directional_focus_southeast(ObAction
*a
)
75 a
->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
76 a
->data
.interdiraction
.direction
= OB_DIRECTION_SOUTHEAST
;
79 void setup_action_directional_focus_southwest(ObAction
*a
)
81 a
->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
82 a
->data
.interdiraction
.direction
= OB_DIRECTION_SOUTHWEST
;
85 void setup_action_directional_focus_northwest(ObAction
*a
)
87 a
->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
88 a
->data
.interdiraction
.direction
= OB_DIRECTION_NORTHWEST
;
91 void setup_action_send_to_desktop(ObAction
*a
)
93 a
->data
.sendto
.follow
= TRUE
;
96 void setup_action_send_to_desktop_prev(ObAction
*a
)
98 a
->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
99 a
->data
.sendtodir
.dir
= OB_DIRECTION_WEST
;
100 a
->data
.sendtodir
.linear
= TRUE
;
101 a
->data
.sendtodir
.wrap
= TRUE
;
102 a
->data
.sendtodir
.follow
= TRUE
;
105 void setup_action_send_to_desktop_next(ObAction
*a
)
107 a
->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
108 a
->data
.sendtodir
.dir
= OB_DIRECTION_EAST
;
109 a
->data
.sendtodir
.linear
= TRUE
;
110 a
->data
.sendtodir
.wrap
= TRUE
;
111 a
->data
.sendtodir
.follow
= TRUE
;
114 void setup_action_send_to_desktop_left(ObAction
*a
)
116 a
->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
117 a
->data
.sendtodir
.dir
= OB_DIRECTION_WEST
;
118 a
->data
.sendtodir
.linear
= FALSE
;
119 a
->data
.sendtodir
.wrap
= TRUE
;
120 a
->data
.sendtodir
.follow
= TRUE
;
123 void setup_action_send_to_desktop_right(ObAction
*a
)
125 a
->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
126 a
->data
.sendtodir
.dir
= OB_DIRECTION_EAST
;
127 a
->data
.sendtodir
.linear
= FALSE
;
128 a
->data
.sendtodir
.wrap
= TRUE
;
129 a
->data
.sendtodir
.follow
= TRUE
;
132 void setup_action_send_to_desktop_up(ObAction
*a
)
134 a
->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
135 a
->data
.sendtodir
.dir
= OB_DIRECTION_NORTH
;
136 a
->data
.sendtodir
.linear
= FALSE
;
137 a
->data
.sendtodir
.wrap
= TRUE
;
138 a
->data
.sendtodir
.follow
= TRUE
;
141 void setup_action_send_to_desktop_down(ObAction
*a
)
143 a
->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
144 a
->data
.sendtodir
.dir
= OB_DIRECTION_SOUTH
;
145 a
->data
.sendtodir
.linear
= FALSE
;
146 a
->data
.sendtodir
.wrap
= TRUE
;
147 a
->data
.sendtodir
.follow
= TRUE
;
150 void setup_action_desktop_prev(ObAction
*a
)
152 a
->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
153 a
->data
.desktopdir
.dir
= OB_DIRECTION_WEST
;
154 a
->data
.desktopdir
.linear
= TRUE
;
155 a
->data
.desktopdir
.wrap
= TRUE
;
158 void setup_action_desktop_next(ObAction
*a
)
160 a
->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
161 a
->data
.desktopdir
.dir
= OB_DIRECTION_EAST
;
162 a
->data
.desktopdir
.linear
= TRUE
;
163 a
->data
.desktopdir
.wrap
= TRUE
;
166 void setup_action_desktop_left(ObAction
*a
)
168 a
->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
169 a
->data
.desktopdir
.dir
= OB_DIRECTION_WEST
;
170 a
->data
.desktopdir
.linear
= FALSE
;
171 a
->data
.desktopdir
.wrap
= TRUE
;
174 void setup_action_desktop_right(ObAction
*a
)
176 a
->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
177 a
->data
.desktopdir
.dir
= OB_DIRECTION_EAST
;
178 a
->data
.desktopdir
.linear
= FALSE
;
179 a
->data
.desktopdir
.wrap
= TRUE
;
182 void setup_action_desktop_up(ObAction
*a
)
184 a
->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
185 a
->data
.desktopdir
.dir
= OB_DIRECTION_NORTH
;
186 a
->data
.desktopdir
.linear
= FALSE
;
187 a
->data
.desktopdir
.wrap
= TRUE
;
190 void setup_action_desktop_down(ObAction
*a
)
192 a
->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
193 a
->data
.desktopdir
.dir
= OB_DIRECTION_SOUTH
;
194 a
->data
.desktopdir
.linear
= FALSE
;
195 a
->data
.desktopdir
.wrap
= TRUE
;
198 void setup_action_move_keyboard(ObAction
*a
)
200 a
->data
.moveresize
.corner
= prop_atoms
.net_wm_moveresize_move_keyboard
;
203 void setup_action_move(ObAction
*a
)
205 a
->data
.moveresize
.corner
= prop_atoms
.net_wm_moveresize_move
;
208 void setup_action_resize(ObAction
*a
)
210 a
->data
.moveresize
.corner
= prop_atoms
.net_wm_moveresize_size_topleft
;
213 void setup_action_resize_keyboard(ObAction
*a
)
215 a
->data
.moveresize
.corner
= prop_atoms
.net_wm_moveresize_size_keyboard
;
218 void setup_action_cycle_windows_linear_next(ObAction
*a
)
220 a
->data
.cycle
.inter
.any
.interactive
= TRUE
;
221 a
->data
.cycle
.linear
= TRUE
;
222 a
->data
.cycle
.forward
= TRUE
;
225 void setup_action_cycle_windows_linear_previous(ObAction
*a
)
227 a
->data
.cycle
.inter
.any
.interactive
= TRUE
;
228 a
->data
.cycle
.linear
= TRUE
;
229 a
->data
.cycle
.forward
= FALSE
;
232 void setup_action_cycle_windows_next(ObAction
*a
)
234 a
->data
.cycle
.inter
.any
.interactive
= TRUE
;
235 a
->data
.cycle
.linear
= FALSE
;
236 a
->data
.cycle
.forward
= TRUE
;
239 void setup_action_cycle_windows_previous(ObAction
*a
)
241 a
->data
.cycle
.inter
.any
.interactive
= TRUE
;
242 a
->data
.cycle
.linear
= FALSE
;
243 a
->data
.cycle
.forward
= FALSE
;
246 void setup_action_movetoedge_north(ObAction
*a
)
248 a
->data
.diraction
.direction
= OB_DIRECTION_NORTH
;
251 void setup_action_movetoedge_south(ObAction
*a
)
253 a
->data
.diraction
.direction
= OB_DIRECTION_SOUTH
;
256 void setup_action_movetoedge_east(ObAction
*a
)
258 a
->data
.diraction
.direction
= OB_DIRECTION_EAST
;
261 void setup_action_movetoedge_west(ObAction
*a
)
263 a
->data
.diraction
.direction
= OB_DIRECTION_WEST
;
266 void setup_action_growtoedge_north(ObAction
*a
)
268 a
->data
.diraction
.direction
= OB_DIRECTION_NORTH
;
271 void setup_action_growtoedge_south(ObAction
*a
)
273 a
->data
.diraction
.direction
= OB_DIRECTION_SOUTH
;
276 void setup_action_growtoedge_east(ObAction
*a
)
278 a
->data
.diraction
.direction
= OB_DIRECTION_EAST
;
281 void setup_action_growtoedge_west(ObAction
*a
)
283 a
->data
.diraction
.direction
= OB_DIRECTION_WEST
;
286 void setup_action_top_layer(ObAction
*a
)
288 a
->data
.layer
.layer
= 1;
291 void setup_action_normal_layer(ObAction
*a
)
293 a
->data
.layer
.layer
= 0;
296 void setup_action_bottom_layer(ObAction
*a
)
298 a
->data
.layer
.layer
= -1;
301 ActionString actionstrings
[] =
309 "directionalfocusnorth",
310 action_directional_focus
,
311 setup_action_directional_focus_north
314 "directionalfocuseast",
315 action_directional_focus
,
316 setup_action_directional_focus_east
319 "directionalfocussouth",
320 action_directional_focus
,
321 setup_action_directional_focus_south
324 "directionalfocuswest",
325 action_directional_focus
,
326 setup_action_directional_focus_west
329 "directionalfocusnortheast",
330 action_directional_focus
,
331 setup_action_directional_focus_northeast
334 "directionalfocussoutheast",
335 action_directional_focus
,
336 setup_action_directional_focus_southeast
339 "directionalfocussouthwest",
340 action_directional_focus
,
341 setup_action_directional_focus_southwest
344 "directionalfocusnorthwest",
345 action_directional_focus
,
346 setup_action_directional_focus_northwest
420 action_toggle_omnipresent
,
425 action_move_relative_horz
,
430 action_move_relative_vert
,
434 "resizerelativehorz",
435 action_resize_relative_horz
,
439 "resizerelativevert",
440 action_resize_relative_vert
,
445 action_maximize_full
,
450 action_unmaximize_full
,
454 "togglemaximizefull",
455 action_toggle_maximize_full
,
460 action_maximize_horz
,
465 action_unmaximize_horz
,
469 "togglemaximizehorz",
470 action_toggle_maximize_horz
,
475 action_maximize_vert
,
480 action_unmaximize_vert
,
484 "togglemaximizevert",
485 action_toggle_maximize_vert
,
490 action_send_to_desktop
,
491 setup_action_send_to_desktop
495 action_send_to_desktop_dir
,
496 setup_action_send_to_desktop_next
499 "sendtodesktopprevious",
500 action_send_to_desktop_dir
,
501 setup_action_send_to_desktop_prev
504 "sendtodesktopright",
505 action_send_to_desktop_dir
,
506 setup_action_send_to_desktop_right
510 action_send_to_desktop_dir
,
511 setup_action_send_to_desktop_left
515 action_send_to_desktop_dir
,
516 setup_action_send_to_desktop_up
520 action_send_to_desktop_dir
,
521 setup_action_send_to_desktop_down
531 setup_action_desktop_next
536 setup_action_desktop_prev
541 setup_action_desktop_right
546 setup_action_desktop_left
551 setup_action_desktop_up
556 setup_action_desktop_down
560 action_toggle_decorations
,
566 setup_action_move_keyboard
581 setup_action_resize_keyboard
585 action_toggle_show_desktop
,
595 action_unshow_desktop
,
625 action_send_to_layer
,
626 setup_action_top_layer
631 setup_action_top_layer
635 action_send_to_layer
,
636 setup_action_normal_layer
640 action_send_to_layer
,
641 setup_action_bottom_layer
644 "togglealwaysonbottom",
646 setup_action_bottom_layer
650 action_cycle_windows
,
651 setup_action_cycle_windows_linear_next
654 "previouswindowlinear",
655 action_cycle_windows
,
656 setup_action_cycle_windows_linear_previous
660 action_cycle_windows
,
661 setup_action_cycle_windows_next
665 action_cycle_windows
,
666 setup_action_cycle_windows_previous
671 setup_action_movetoedge_north
676 setup_action_movetoedge_south
681 setup_action_movetoedge_west
686 setup_action_movetoedge_east
691 setup_action_growtoedge_north
696 setup_action_growtoedge_south
701 setup_action_growtoedge_west
706 setup_action_growtoedge_east
715 ObAction
*action_from_string(char *name
)
720 for (i
= 0; actionstrings
[i
].name
; i
++)
721 if (!g_ascii_strcasecmp(name
, actionstrings
[i
].name
)) {
722 a
= action_new(actionstrings
[i
].func
);
723 if (actionstrings
[i
].setup
)
724 actionstrings
[i
].setup(a
);
728 g_warning("Invalid action '%s' requested. No such action exists.",
733 ObAction
*action_parse(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
)
736 ObAction
*act
= NULL
;
739 if (parse_attr_string("name", node
, &actname
)) {
740 if ((act
= action_from_string(actname
))) {
741 if (act
->func
== action_execute
|| act
->func
== action_restart
) {
742 if ((n
= parse_find_node("execute", node
->xmlChildrenNode
))) {
743 gchar
*s
= parse_string(doc
, n
);
744 act
->data
.execute
.path
= ob_expand_tilde(s
);
747 } else if (act
->func
== action_showmenu
) {
748 if ((n
= parse_find_node("menu", node
->xmlChildrenNode
)))
749 act
->data
.showmenu
.name
= parse_string(doc
, n
);
750 } else if (act
->func
== action_desktop
) {
751 if ((n
= parse_find_node("desktop", node
->xmlChildrenNode
)))
752 act
->data
.desktop
.desk
= parse_int(doc
, n
);
753 if (act
->data
.desktop
.desk
> 0) act
->data
.desktop
.desk
--;
754 } else if (act
->func
== action_send_to_desktop
) {
755 if ((n
= parse_find_node("desktop", node
->xmlChildrenNode
)))
756 act
->data
.sendto
.desk
= parse_int(doc
, n
);
757 if (act
->data
.sendto
.desk
> 0) act
->data
.sendto
.desk
--;
758 } else if (act
->func
== action_move_relative_horz
||
759 act
->func
== action_move_relative_vert
||
760 act
->func
== action_resize_relative_horz
||
761 act
->func
== action_resize_relative_vert
) {
762 if ((n
= parse_find_node("delta", node
->xmlChildrenNode
)))
763 act
->data
.relative
.delta
= parse_int(doc
, n
);
764 } else if (act
->func
== action_desktop_dir
) {
765 if ((n
= parse_find_node("wrap", node
->xmlChildrenNode
)))
766 act
->data
.desktopdir
.wrap
= parse_bool(doc
, n
);
767 } else if (act
->func
== action_send_to_desktop
) {
768 if ((n
= parse_find_node("follow", node
->xmlChildrenNode
)))
769 act
->data
.sendto
.follow
= parse_bool(doc
, n
);
770 } else if (act
->func
== action_send_to_desktop_dir
) {
771 if ((n
= parse_find_node("wrap", node
->xmlChildrenNode
)))
772 act
->data
.sendtodir
.wrap
= parse_bool(doc
, n
);
773 if ((n
= parse_find_node("follow", node
->xmlChildrenNode
)))
774 act
->data
.sendtodir
.follow
= parse_bool(doc
, n
);
775 } else if (act
->func
== action_activate
) {
776 if ((n
= parse_find_node("here", node
->xmlChildrenNode
)))
777 act
->data
.activate
.here
= parse_bool(doc
, n
);
785 void action_execute(union ActionData
*data
)
789 if (data
->execute
.path
) {
790 cmd
= g_filename_from_utf8(data
->execute
.path
, -1, NULL
, NULL
, NULL
);
792 if (!g_spawn_command_line_async(cmd
, &e
)) {
793 g_warning("failed to execute '%s': %s",
797 g_warning("failed to convert '%s' from utf8", data
->execute
.path
);
802 void action_activate(union ActionData
*data
)
804 if (data
->activate
.any
.c
)
805 client_activate(data
->activate
.any
.c
, data
->activate
.here
);
808 void action_focus(union ActionData
*data
)
810 if (data
->client
.any
.c
)
811 client_focus(data
->client
.any
.c
);
814 void action_unfocus (union ActionData
*data
)
816 if (data
->client
.any
.c
)
817 client_unfocus(data
->client
.any
.c
);
820 void action_iconify(union ActionData
*data
)
822 if (data
->client
.any
.c
)
823 client_iconify(data
->client
.any
.c
, TRUE
, TRUE
);
826 void action_raiselower(union ActionData
*data
)
828 ObClient
*c
= data
->client
.any
.c
;
830 gboolean raise
= FALSE
;
834 for (it
= stacking_list
; it
; it
= g_list_next(it
)) {
835 ObClient
*cit
= it
->data
;
838 if (client_normal(cit
) == client_normal(c
) &&
839 cit
->layer
== c
->layer
&&
842 if (RECT_INTERSECTS_RECT(cit
->frame
->area
, c
->frame
->area
)) {
850 stacking_raise(CLIENT_AS_WINDOW(c
));
852 stacking_lower(CLIENT_AS_WINDOW(c
));
855 void action_raise(union ActionData
*data
)
857 if (data
->client
.any
.c
)
858 stacking_raise(CLIENT_AS_WINDOW(data
->client
.any
.c
));
861 void action_unshaderaise(union ActionData
*data
)
863 if (data
->client
.any
.c
) {
864 if (data
->client
.any
.c
->shaded
)
865 client_shade(data
->client
.any
.c
, FALSE
);
867 stacking_raise(CLIENT_AS_WINDOW(data
->client
.any
.c
));
871 void action_shadelower(union ActionData
*data
)
873 if (data
->client
.any
.c
) {
874 if (data
->client
.any
.c
->shaded
)
875 stacking_lower(CLIENT_AS_WINDOW(data
->client
.any
.c
));
877 client_shade(data
->client
.any
.c
, TRUE
);
881 void action_lower(union ActionData
*data
)
883 if (data
->client
.any
.c
)
884 stacking_lower(CLIENT_AS_WINDOW(data
->client
.any
.c
));
887 void action_close(union ActionData
*data
)
889 if (data
->client
.any
.c
)
890 client_close(data
->client
.any
.c
);
893 void action_kill(union ActionData
*data
)
895 if (data
->client
.any
.c
)
896 client_kill(data
->client
.any
.c
);
899 void action_shade(union ActionData
*data
)
901 if (data
->client
.any
.c
)
902 client_shade(data
->client
.any
.c
, TRUE
);
905 void action_unshade(union ActionData
*data
)
907 if (data
->client
.any
.c
)
908 client_shade(data
->client
.any
.c
, FALSE
);
911 void action_toggle_shade(union ActionData
*data
)
913 if (data
->client
.any
.c
)
914 client_shade(data
->client
.any
.c
, !data
->client
.any
.c
->shaded
);
917 void action_toggle_omnipresent(union ActionData
*data
)
919 if (data
->client
.any
.c
)
920 client_set_desktop(data
->client
.any
.c
,
921 data
->client
.any
.c
->desktop
== DESKTOP_ALL
?
922 screen_desktop
: DESKTOP_ALL
, FALSE
);
925 void action_move_relative_horz(union ActionData
*data
)
927 ObClient
*c
= data
->relative
.any
.c
;
929 grab_pointer(TRUE
, OB_CURSOR_NONE
);
930 client_move(c
, c
->area
.x
+ data
->relative
.delta
, c
->area
.y
);
931 grab_pointer(FALSE
, OB_CURSOR_NONE
);
935 void action_move_relative_vert(union ActionData
*data
)
937 ObClient
*c
= data
->relative
.any
.c
;
939 grab_pointer(TRUE
, OB_CURSOR_NONE
);
940 client_move(c
, c
->area
.x
, c
->area
.y
+ data
->relative
.delta
);
941 grab_pointer(FALSE
, OB_CURSOR_NONE
);
945 void action_resize_relative_horz(union ActionData
*data
)
947 ObClient
*c
= data
->relative
.any
.c
;
949 grab_pointer(TRUE
, OB_CURSOR_NONE
);
951 c
->area
.width
+ data
->relative
.delta
* c
->size_inc
.width
,
953 grab_pointer(FALSE
, OB_CURSOR_NONE
);
957 void action_resize_relative_vert(union ActionData
*data
)
959 ObClient
*c
= data
->relative
.any
.c
;
960 if (c
&& !c
->shaded
) {
961 grab_pointer(TRUE
, OB_CURSOR_NONE
);
962 client_resize(c
, c
->area
.width
, c
->area
.height
+
963 data
->relative
.delta
* c
->size_inc
.height
);
964 grab_pointer(FALSE
, OB_CURSOR_NONE
);
968 void action_maximize_full(union ActionData
*data
)
970 if (data
->client
.any
.c
)
971 client_maximize(data
->client
.any
.c
, TRUE
, 0, TRUE
);
974 void action_unmaximize_full(union ActionData
*data
)
976 if (data
->client
.any
.c
)
977 client_maximize(data
->client
.any
.c
, FALSE
, 0, TRUE
);
980 void action_toggle_maximize_full(union ActionData
*data
)
982 if (data
->client
.any
.c
)
983 client_maximize(data
->client
.any
.c
,
984 !(data
->client
.any
.c
->max_horz
||
985 data
->client
.any
.c
->max_vert
),
989 void action_maximize_horz(union ActionData
*data
)
991 if (data
->client
.any
.c
)
992 client_maximize(data
->client
.any
.c
, TRUE
, 1, TRUE
);
995 void action_unmaximize_horz(union ActionData
*data
)
997 if (data
->client
.any
.c
)
998 client_maximize(data
->client
.any
.c
, FALSE
, 1, TRUE
);
1001 void action_toggle_maximize_horz(union ActionData
*data
)
1003 if (data
->client
.any
.c
)
1004 client_maximize(data
->client
.any
.c
,
1005 !data
->client
.any
.c
->max_horz
, 1, TRUE
);
1008 void action_maximize_vert(union ActionData
*data
)
1010 if (data
->client
.any
.c
)
1011 client_maximize(data
->client
.any
.c
, TRUE
, 2, TRUE
);
1014 void action_unmaximize_vert(union ActionData
*data
)
1016 if (data
->client
.any
.c
)
1017 client_maximize(data
->client
.any
.c
, FALSE
, 2, TRUE
);
1020 void action_toggle_maximize_vert(union ActionData
*data
)
1022 if (data
->client
.any
.c
)
1023 client_maximize(data
->client
.any
.c
, !data
->client
.any
.c
->max_vert
, 2, TRUE
);
1026 void action_send_to_desktop(union ActionData
*data
)
1028 ObClient
*c
= data
->sendto
.any
.c
;
1030 if (!c
|| !client_normal(c
)) return;
1032 if (data
->sendto
.desk
< screen_num_desktops
||
1033 data
->sendto
.desk
== DESKTOP_ALL
) {
1034 client_set_desktop(c
, data
->sendto
.desk
, data
->sendto
.follow
);
1035 if (data
->sendto
.follow
)
1036 screen_set_desktop(data
->sendto
.desk
);
1040 void action_desktop(union ActionData
*data
)
1042 if (data
->desktop
.desk
< screen_num_desktops
||
1043 data
->desktop
.desk
== DESKTOP_ALL
)
1044 screen_set_desktop(data
->desktop
.desk
);
1047 void action_desktop_dir(union ActionData
*data
)
1051 d
= screen_cycle_desktop(data
->desktopdir
.dir
,
1052 data
->desktopdir
.wrap
,
1053 data
->sendtodir
.linear
,
1054 data
->desktopdir
.inter
.any
.interactive
,
1055 data
->desktopdir
.inter
.final
,
1056 data
->desktopdir
.inter
.cancel
);
1057 screen_set_desktop(d
);
1060 void action_send_to_desktop_dir(union ActionData
*data
)
1062 ObClient
*c
= data
->sendtodir
.inter
.any
.c
;
1065 if (!c
|| !client_normal(c
)) return;
1067 d
= screen_cycle_desktop(data
->sendtodir
.dir
, data
->sendtodir
.wrap
,
1068 data
->sendtodir
.linear
,
1069 data
->sendtodir
.inter
.any
.interactive
,
1070 data
->sendtodir
.inter
.final
,
1071 data
->sendtodir
.inter
.cancel
);
1072 client_set_desktop(c
, d
, data
->sendtodir
.follow
);
1073 if (data
->sendtodir
.follow
)
1074 screen_set_desktop(d
);
1077 void action_desktop_last(union ActionData
*data
)
1079 screen_set_desktop(screen_last_desktop
);
1082 void action_toggle_decorations(union ActionData
*data
)
1084 ObClient
*c
= data
->client
.any
.c
;
1088 c
->decorate
= !c
->decorate
;
1089 client_setup_decor_and_functions(c
);
1092 void action_moveresize(union ActionData
*data
)
1094 ObClient
*c
= data
->moveresize
.any
.c
;
1096 if (!c
|| !client_normal(c
)) return;
1098 moveresize_start(c
, data
->moveresize
.x
, data
->moveresize
.y
,
1099 data
->moveresize
.button
, data
->moveresize
.corner
);
1102 void action_reconfigure(union ActionData
*data
)
1107 void action_restart(union ActionData
*data
)
1109 ob_restart_other(data
->execute
.path
);
1112 void action_exit(union ActionData
*data
)
1117 void action_showmenu(union ActionData
*data
)
1119 if (data
->showmenu
.name
) {
1120 menu_show(data
->showmenu
.name
, data
->showmenu
.x
, data
->showmenu
.y
,
1121 data
->showmenu
.any
.c
);
1125 void action_cycle_windows(union ActionData
*data
)
1127 focus_cycle(data
->cycle
.forward
, data
->cycle
.linear
,
1128 data
->cycle
.inter
.any
.interactive
,
1129 data
->cycle
.inter
.final
, data
->cycle
.inter
.cancel
);
1132 void action_directional_focus(union ActionData
*data
)
1134 focus_directional_cycle(data
->interdiraction
.direction
,
1135 data
->interdiraction
.inter
.any
.interactive
,
1136 data
->interdiraction
.inter
.final
,
1137 data
->interdiraction
.inter
.cancel
);
1140 void action_movetoedge(union ActionData
*data
)
1143 ObClient
*c
= data
->diraction
.any
.c
;
1147 x
= c
->frame
->area
.x
;
1148 y
= c
->frame
->area
.y
;
1150 switch(data
->diraction
.direction
) {
1151 case OB_DIRECTION_NORTH
:
1152 y
= client_directional_edge_search(c
, OB_DIRECTION_NORTH
);
1154 case OB_DIRECTION_WEST
:
1155 x
= client_directional_edge_search(c
, OB_DIRECTION_WEST
);
1157 case OB_DIRECTION_SOUTH
:
1158 y
= client_directional_edge_search(c
, OB_DIRECTION_SOUTH
) -
1159 c
->frame
->area
.height
;
1161 case OB_DIRECTION_EAST
:
1162 x
= client_directional_edge_search(c
, OB_DIRECTION_EAST
) -
1163 c
->frame
->area
.width
;
1166 g_assert_not_reached();
1168 frame_frame_gravity(c
->frame
, &x
, &y
);
1169 grab_pointer(TRUE
, OB_CURSOR_NONE
);
1170 client_move(c
, x
, y
);
1171 grab_pointer(FALSE
, OB_CURSOR_NONE
);
1175 void action_growtoedge(union ActionData
*data
)
1177 int x
, y
, width
, height
, dest
;
1178 ObClient
*c
= data
->diraction
.any
.c
;
1179 Rect
*a
= screen_area(c
->desktop
);
1184 x
= c
->frame
->area
.x
;
1185 y
= c
->frame
->area
.y
;
1186 width
= c
->frame
->area
.width
;
1187 height
= c
->frame
->area
.height
;
1189 switch(data
->diraction
.direction
) {
1190 case OB_DIRECTION_NORTH
:
1191 dest
= client_directional_edge_search(c
, OB_DIRECTION_NORTH
);
1193 height
= c
->frame
->area
.height
/ 2;
1195 height
= c
->frame
->area
.y
+ c
->frame
->area
.height
- dest
;
1199 case OB_DIRECTION_WEST
:
1200 dest
= client_directional_edge_search(c
, OB_DIRECTION_WEST
);
1202 width
= c
->frame
->area
.width
/ 2;
1204 width
= c
->frame
->area
.x
+ c
->frame
->area
.width
- dest
;
1208 case OB_DIRECTION_SOUTH
:
1209 dest
= client_directional_edge_search(c
, OB_DIRECTION_SOUTH
);
1210 if (a
->y
+ a
->height
== y
+ c
->frame
->area
.height
) {
1211 height
= c
->frame
->area
.height
/ 2;
1212 y
= a
->y
+ a
->height
- height
;
1214 height
= dest
- c
->frame
->area
.y
;
1215 y
+= (height
- c
->frame
->area
.height
) % c
->size_inc
.height
;
1216 height
-= (height
- c
->frame
->area
.height
) % c
->size_inc
.height
;
1218 case OB_DIRECTION_EAST
:
1219 dest
= client_directional_edge_search(c
, OB_DIRECTION_EAST
);
1220 if (a
->x
+ a
->width
== x
+ c
->frame
->area
.width
) {
1221 width
= c
->frame
->area
.width
/ 2;
1222 x
= a
->x
+ a
->width
- width
;
1224 width
= dest
- c
->frame
->area
.x
;
1225 x
+= (width
- c
->frame
->area
.width
) % c
->size_inc
.width
;
1226 width
-= (width
- c
->frame
->area
.width
) % c
->size_inc
.width
;
1229 g_assert_not_reached();
1231 frame_frame_gravity(c
->frame
, &x
, &y
);
1232 width
-= c
->frame
->size
.left
+ c
->frame
->size
.right
;
1233 height
-= c
->frame
->size
.top
+ c
->frame
->size
.bottom
;
1234 grab_pointer(TRUE
, OB_CURSOR_NONE
);
1235 client_move_resize(c
, x
, y
, width
, height
);
1236 grab_pointer(FALSE
, OB_CURSOR_NONE
);
1239 void action_send_to_layer(union ActionData
*data
)
1241 if (data
->layer
.any
.c
)
1242 client_set_layer(data
->layer
.any
.c
, data
->layer
.layer
);
1245 void action_toggle_layer(union ActionData
*data
)
1247 ObClient
*c
= data
->layer
.any
.c
;
1250 if (data
->layer
.layer
< 0)
1251 client_set_layer(c
, c
->below
? 0 : -1);
1252 else if (data
->layer
.layer
> 0)
1253 client_set_layer(c
, c
->above
? 0 : 1);
1257 void action_toggle_show_desktop(union ActionData
*data
)
1259 screen_show_desktop(!screen_showing_desktop
);
1262 void action_show_desktop(union ActionData
*data
)
1264 screen_show_desktop(TRUE
);
1267 void action_unshow_desktop(union ActionData
*data
)
1269 screen_show_desktop(FALSE
);