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
.diraction
.direction
= OB_DIRECTION_NORTH
;
48 void setup_action_directional_focus_east(ObAction
*a
)
50 a
->data
.diraction
.direction
= OB_DIRECTION_EAST
;
53 void setup_action_directional_focus_south(ObAction
*a
)
55 a
->data
.diraction
.direction
= OB_DIRECTION_SOUTH
;
58 void setup_action_directional_focus_west(ObAction
*a
)
60 a
->data
.diraction
.direction
= OB_DIRECTION_WEST
;
63 void setup_action_directional_focus_northeast(ObAction
*a
)
65 a
->data
.diraction
.direction
= OB_DIRECTION_NORTHEAST
;
68 void setup_action_directional_focus_southeast(ObAction
*a
)
70 a
->data
.diraction
.direction
= OB_DIRECTION_SOUTHEAST
;
73 void setup_action_directional_focus_southwest(ObAction
*a
)
75 a
->data
.diraction
.direction
= OB_DIRECTION_SOUTHWEST
;
78 void setup_action_directional_focus_northwest(ObAction
*a
)
80 a
->data
.diraction
.direction
= OB_DIRECTION_NORTHWEST
;
83 void setup_action_send_to_desktop(ObAction
*a
)
85 a
->data
.sendto
.follow
= TRUE
;
88 void setup_action_send_to_desktop_prev(ObAction
*a
)
90 a
->data
.sendtodir
.dir
= OB_DIRECTION_WEST
;
91 a
->data
.sendtodir
.linear
= TRUE
;
92 a
->data
.sendtodir
.wrap
= TRUE
;
93 a
->data
.sendtodir
.follow
= TRUE
;
96 void setup_action_send_to_desktop_next(ObAction
*a
)
98 a
->data
.sendtodir
.dir
= OB_DIRECTION_EAST
;
99 a
->data
.sendtodir
.linear
= TRUE
;
100 a
->data
.sendtodir
.wrap
= TRUE
;
101 a
->data
.sendtodir
.follow
= TRUE
;
104 void setup_action_send_to_desktop_left(ObAction
*a
)
106 a
->data
.sendtodir
.dir
= OB_DIRECTION_WEST
;
107 a
->data
.sendtodir
.linear
= FALSE
;
108 a
->data
.sendtodir
.wrap
= TRUE
;
109 a
->data
.sendtodir
.follow
= TRUE
;
112 void setup_action_send_to_desktop_right(ObAction
*a
)
114 a
->data
.sendtodir
.dir
= OB_DIRECTION_EAST
;
115 a
->data
.sendtodir
.linear
= FALSE
;
116 a
->data
.sendtodir
.wrap
= TRUE
;
117 a
->data
.sendtodir
.follow
= TRUE
;
120 void setup_action_send_to_desktop_up(ObAction
*a
)
122 a
->data
.sendtodir
.dir
= OB_DIRECTION_NORTH
;
123 a
->data
.sendtodir
.linear
= FALSE
;
124 a
->data
.sendtodir
.wrap
= TRUE
;
125 a
->data
.sendtodir
.follow
= TRUE
;
128 void setup_action_send_to_desktop_down(ObAction
*a
)
130 a
->data
.sendtodir
.dir
= OB_DIRECTION_SOUTH
;
131 a
->data
.sendtodir
.linear
= FALSE
;
132 a
->data
.sendtodir
.wrap
= TRUE
;
133 a
->data
.sendtodir
.follow
= TRUE
;
136 void setup_action_desktop_prev(ObAction
*a
)
138 a
->data
.desktopdir
.dir
= OB_DIRECTION_WEST
;
139 a
->data
.desktopdir
.linear
= TRUE
;
140 a
->data
.desktopdir
.wrap
= TRUE
;
143 void setup_action_desktop_next(ObAction
*a
)
145 a
->data
.desktopdir
.dir
= OB_DIRECTION_EAST
;
146 a
->data
.desktopdir
.linear
= TRUE
;
147 a
->data
.desktopdir
.wrap
= TRUE
;
150 void setup_action_desktop_left(ObAction
*a
)
152 a
->data
.desktopdir
.dir
= OB_DIRECTION_WEST
;
153 a
->data
.desktopdir
.linear
= FALSE
;
154 a
->data
.desktopdir
.wrap
= TRUE
;
157 void setup_action_desktop_right(ObAction
*a
)
159 a
->data
.desktopdir
.dir
= OB_DIRECTION_EAST
;
160 a
->data
.desktopdir
.linear
= FALSE
;
161 a
->data
.desktopdir
.wrap
= TRUE
;
164 void setup_action_desktop_up(ObAction
*a
)
166 a
->data
.desktopdir
.dir
= OB_DIRECTION_NORTH
;
167 a
->data
.desktopdir
.linear
= FALSE
;
168 a
->data
.desktopdir
.wrap
= TRUE
;
171 void setup_action_desktop_down(ObAction
*a
)
173 a
->data
.desktopdir
.dir
= OB_DIRECTION_SOUTH
;
174 a
->data
.desktopdir
.linear
= FALSE
;
175 a
->data
.desktopdir
.wrap
= TRUE
;
178 void setup_action_move_keyboard(ObAction
*a
)
180 a
->data
.moveresize
.corner
= prop_atoms
.net_wm_moveresize_move_keyboard
;
183 void setup_action_move(ObAction
*a
)
185 a
->data
.moveresize
.corner
= prop_atoms
.net_wm_moveresize_move
;
188 void setup_action_resize(ObAction
*a
)
190 a
->data
.moveresize
.corner
= prop_atoms
.net_wm_moveresize_size_topleft
;
193 void setup_action_resize_keyboard(ObAction
*a
)
195 a
->data
.moveresize
.corner
= prop_atoms
.net_wm_moveresize_size_keyboard
;
198 void setup_action_cycle_windows_linear_next(ObAction
*a
)
200 a
->data
.cycle
.linear
= TRUE
;
201 a
->data
.cycle
.forward
= TRUE
;
204 void setup_action_cycle_windows_linear_previous(ObAction
*a
)
206 a
->data
.cycle
.linear
= TRUE
;
207 a
->data
.cycle
.forward
= FALSE
;
210 void setup_action_cycle_windows_next(ObAction
*a
)
212 a
->data
.cycle
.linear
= FALSE
;
213 a
->data
.cycle
.forward
= TRUE
;
216 void setup_action_cycle_windows_previous(ObAction
*a
)
218 a
->data
.cycle
.linear
= FALSE
;
219 a
->data
.cycle
.forward
= FALSE
;
222 void setup_action_movetoedge_north(ObAction
*a
)
224 a
->data
.diraction
.direction
= OB_DIRECTION_NORTH
;
227 void setup_action_movetoedge_south(ObAction
*a
)
229 a
->data
.diraction
.direction
= OB_DIRECTION_SOUTH
;
232 void setup_action_movetoedge_east(ObAction
*a
)
234 a
->data
.diraction
.direction
= OB_DIRECTION_EAST
;
237 void setup_action_movetoedge_west(ObAction
*a
)
239 a
->data
.diraction
.direction
= OB_DIRECTION_WEST
;
242 void setup_action_growtoedge_north(ObAction
*a
)
244 a
->data
.diraction
.direction
= OB_DIRECTION_NORTH
;
247 void setup_action_growtoedge_south(ObAction
*a
)
249 a
->data
.diraction
.direction
= OB_DIRECTION_SOUTH
;
252 void setup_action_growtoedge_east(ObAction
*a
)
254 a
->data
.diraction
.direction
= OB_DIRECTION_EAST
;
257 void setup_action_growtoedge_west(ObAction
*a
)
259 a
->data
.diraction
.direction
= OB_DIRECTION_WEST
;
262 void setup_action_top_layer(ObAction
*a
)
264 a
->data
.layer
.layer
= 1;
267 void setup_action_normal_layer(ObAction
*a
)
269 a
->data
.layer
.layer
= 0;
272 void setup_action_bottom_layer(ObAction
*a
)
274 a
->data
.layer
.layer
= -1;
277 ActionString actionstrings
[] =
285 "directionalfocusnorth",
286 action_directional_focus
,
287 setup_action_directional_focus_north
290 "directionalfocuseast",
291 action_directional_focus
,
292 setup_action_directional_focus_east
295 "directionalfocussouth",
296 action_directional_focus
,
297 setup_action_directional_focus_south
300 "directionalfocuswest",
301 action_directional_focus
,
302 setup_action_directional_focus_west
305 "directionalfocusnortheast",
306 action_directional_focus
,
307 setup_action_directional_focus_northeast
310 "directionalfocussoutheast",
311 action_directional_focus
,
312 setup_action_directional_focus_southeast
315 "directionalfocussouthwest",
316 action_directional_focus
,
317 setup_action_directional_focus_southwest
320 "directionalfocusnorthwest",
321 action_directional_focus
,
322 setup_action_directional_focus_northwest
396 action_toggle_omnipresent
,
401 action_move_relative_horz
,
406 action_move_relative_vert
,
410 "resizerelativehorz",
411 action_resize_relative_horz
,
415 "resizerelativevert",
416 action_resize_relative_vert
,
421 action_maximize_full
,
426 action_unmaximize_full
,
430 "togglemaximizefull",
431 action_toggle_maximize_full
,
436 action_maximize_horz
,
441 action_unmaximize_horz
,
445 "togglemaximizehorz",
446 action_toggle_maximize_horz
,
451 action_maximize_vert
,
456 action_unmaximize_vert
,
460 "togglemaximizevert",
461 action_toggle_maximize_vert
,
466 action_send_to_desktop
,
467 setup_action_send_to_desktop
471 action_send_to_desktop_dir
,
472 setup_action_send_to_desktop_next
475 "sendtodesktopprevious",
476 action_send_to_desktop_dir
,
477 setup_action_send_to_desktop_prev
480 "sendtodesktopright",
481 action_send_to_desktop_dir
,
482 setup_action_send_to_desktop_right
486 action_send_to_desktop_dir
,
487 setup_action_send_to_desktop_left
491 action_send_to_desktop_dir
,
492 setup_action_send_to_desktop_up
496 action_send_to_desktop_dir
,
497 setup_action_send_to_desktop_down
507 setup_action_desktop_next
512 setup_action_desktop_prev
517 setup_action_desktop_right
522 setup_action_desktop_left
527 setup_action_desktop_up
532 setup_action_desktop_down
536 action_toggle_decorations
,
542 setup_action_move_keyboard
557 setup_action_resize_keyboard
561 action_toggle_show_desktop
,
571 action_unshow_desktop
,
591 action_send_to_layer
,
592 setup_action_top_layer
597 setup_action_top_layer
601 action_send_to_layer
,
602 setup_action_normal_layer
606 action_send_to_layer
,
607 setup_action_bottom_layer
610 "togglealwaysonbottom",
612 setup_action_bottom_layer
616 action_cycle_windows
,
617 setup_action_cycle_windows_linear_next
620 "previouswindowlinear",
621 action_cycle_windows
,
622 setup_action_cycle_windows_linear_previous
626 action_cycle_windows
,
627 setup_action_cycle_windows_next
631 action_cycle_windows
,
632 setup_action_cycle_windows_previous
637 setup_action_movetoedge_north
642 setup_action_movetoedge_south
647 setup_action_movetoedge_west
652 setup_action_movetoedge_east
657 setup_action_growtoedge_north
662 setup_action_growtoedge_south
667 setup_action_growtoedge_west
672 setup_action_growtoedge_east
681 ObAction
*action_from_string(char *name
)
686 for (i
= 0; actionstrings
[i
].name
; i
++)
687 if (!g_ascii_strcasecmp(name
, actionstrings
[i
].name
)) {
688 a
= action_new(actionstrings
[i
].func
);
689 if (actionstrings
[i
].setup
)
690 actionstrings
[i
].setup(a
);
696 ObAction
*action_parse(xmlDocPtr doc
, xmlNodePtr node
)
699 ObAction
*act
= NULL
;
702 if (parse_attr_string("name", node
, &actname
)) {
703 if ((act
= action_from_string(actname
))) {
704 if (act
->func
== action_execute
|| act
->func
== action_restart
) {
705 if ((n
= parse_find_node("execute", node
->xmlChildrenNode
)))
706 act
->data
.execute
.path
= parse_string(doc
, n
);
707 } else if (act
->func
== action_showmenu
) {
708 if ((n
= parse_find_node("menu", node
->xmlChildrenNode
)))
709 act
->data
.showmenu
.name
= parse_string(doc
, n
);
710 } else if (act
->func
== action_desktop
) {
711 if ((n
= parse_find_node("desktop", node
->xmlChildrenNode
)))
712 act
->data
.desktop
.desk
= parse_int(doc
, n
);
713 if (act
->data
.desktop
.desk
> 0) act
->data
.desktop
.desk
--;
714 } else if (act
->func
== action_send_to_desktop
) {
715 if ((n
= parse_find_node("desktop", node
->xmlChildrenNode
)))
716 act
->data
.sendto
.desk
= parse_int(doc
, n
);
717 if (act
->data
.sendto
.desk
> 0) act
->data
.sendto
.desk
--;
718 } else if (act
->func
== action_move_relative_horz
||
719 act
->func
== action_move_relative_vert
||
720 act
->func
== action_resize_relative_horz
||
721 act
->func
== action_resize_relative_vert
) {
722 if ((n
= parse_find_node("delta", node
->xmlChildrenNode
)))
723 act
->data
.relative
.delta
= parse_int(doc
, n
);
724 } else if (act
->func
== action_desktop_dir
) {
725 if ((n
= parse_find_node("wrap", node
->xmlChildrenNode
))) {
726 act
->data
.desktopdir
.wrap
= parse_bool(doc
, n
);
728 } else if (act
->func
== action_send_to_desktop
) {
729 if ((n
= parse_find_node("follow", node
->xmlChildrenNode
)))
730 act
->data
.sendto
.follow
= parse_bool(doc
, n
);
731 } else if (act
->func
== action_send_to_desktop_dir
) {
732 if ((n
= parse_find_node("wrap", node
->xmlChildrenNode
)))
733 act
->data
.sendtodir
.wrap
= parse_bool(doc
, n
);
734 if ((n
= parse_find_node("follow", node
->xmlChildrenNode
)))
735 act
->data
.sendtodir
.follow
= parse_bool(doc
, n
);
736 } else if (act
->func
== action_activate
) {
737 if ((n
= parse_find_node("here", node
->xmlChildrenNode
)))
738 act
->data
.activate
.here
= parse_bool(doc
, n
);
746 void action_execute(union ActionData
*data
)
750 if (data
->execute
.path
) {
751 cmd
= g_filename_from_utf8(data
->execute
.path
, -1, NULL
, NULL
, NULL
);
753 if (!g_spawn_command_line_async(cmd
, &e
)) {
754 g_warning("failed to execute '%s': %s",
758 g_warning("failed to convert '%s' from utf8", data
->execute
.path
);
763 void action_activate(union ActionData
*data
)
765 if (data
->activate
.c
)
766 client_activate(data
->activate
.c
, data
->activate
.here
);
769 void action_focus(union ActionData
*data
)
772 client_focus(data
->client
.c
);
775 void action_unfocus (union ActionData
*data
)
778 client_unfocus(data
->client
.c
);
781 void action_iconify(union ActionData
*data
)
784 client_iconify(data
->client
.c
, TRUE
, TRUE
);
787 void action_raiselower(union ActionData
*data
)
789 ObClient
*c
= data
->client
.c
;
791 gboolean raise
= FALSE
;
795 for (it
= stacking_list
; it
; it
= g_list_next(it
)) {
796 ObClient
*cit
= it
->data
;
799 if (client_normal(cit
) == client_normal(c
) &&
800 cit
->layer
== c
->layer
&&
803 if (RECT_INTERSECTS_RECT(cit
->frame
->area
, c
->frame
->area
)) {
811 stacking_raise(CLIENT_AS_WINDOW(c
));
813 stacking_lower(CLIENT_AS_WINDOW(c
));
816 void action_raise(union ActionData
*data
)
819 stacking_raise(CLIENT_AS_WINDOW(data
->client
.c
));
822 void action_unshaderaise(union ActionData
*data
)
824 if (data
->client
.c
) {
825 if (data
->client
.c
->shaded
)
826 client_shade(data
->client
.c
, FALSE
);
828 stacking_raise(CLIENT_AS_WINDOW(data
->client
.c
));
832 void action_shadelower(union ActionData
*data
)
834 if (data
->client
.c
) {
835 if (data
->client
.c
->shaded
)
836 stacking_lower(CLIENT_AS_WINDOW(data
->client
.c
));
838 client_shade(data
->client
.c
, TRUE
);
842 void action_lower(union ActionData
*data
)
845 stacking_lower(CLIENT_AS_WINDOW(data
->client
.c
));
848 void action_close(union ActionData
*data
)
851 client_close(data
->client
.c
);
854 void action_kill(union ActionData
*data
)
857 client_kill(data
->client
.c
);
860 void action_shade(union ActionData
*data
)
863 client_shade(data
->client
.c
, TRUE
);
866 void action_unshade(union ActionData
*data
)
869 client_shade(data
->client
.c
, FALSE
);
872 void action_toggle_shade(union ActionData
*data
)
875 client_shade(data
->client
.c
, !data
->client
.c
->shaded
);
878 void action_toggle_omnipresent(union ActionData
*data
)
881 client_set_desktop(data
->client
.c
,
882 data
->client
.c
->desktop
== DESKTOP_ALL
?
883 screen_desktop
: DESKTOP_ALL
, FALSE
);
886 void action_move_relative_horz(union ActionData
*data
)
888 ObClient
*c
= data
->relative
.c
;
890 client_configure(c
, OB_CORNER_TOPLEFT
,
891 c
->area
.x
+ data
->relative
.delta
, c
->area
.y
,
892 c
->area
.width
, c
->area
.height
, TRUE
, TRUE
);
895 void action_move_relative_vert(union ActionData
*data
)
897 ObClient
*c
= data
->relative
.c
;
899 client_configure(c
, OB_CORNER_TOPLEFT
,
900 c
->area
.x
, c
->area
.y
+ data
->relative
.delta
,
901 c
->area
.width
, c
->area
.height
, TRUE
, TRUE
);
904 void action_resize_relative_horz(union ActionData
*data
)
906 ObClient
*c
= data
->relative
.c
;
908 client_configure(c
, OB_CORNER_TOPLEFT
, c
->area
.x
, c
->area
.y
,
910 data
->relative
.delta
* c
->size_inc
.width
,
911 c
->area
.height
, TRUE
, TRUE
);
914 void action_resize_relative_vert(union ActionData
*data
)
916 ObClient
*c
= data
->relative
.c
;
918 client_configure(c
, OB_CORNER_TOPLEFT
, c
->area
.x
, c
->area
.y
,
919 c
->area
.width
, c
->area
.height
+
920 data
->relative
.delta
* c
->size_inc
.height
,
924 void action_maximize_full(union ActionData
*data
)
927 client_maximize(data
->client
.c
, TRUE
, 0, TRUE
);
930 void action_unmaximize_full(union ActionData
*data
)
933 client_maximize(data
->client
.c
, FALSE
, 0, TRUE
);
936 void action_toggle_maximize_full(union ActionData
*data
)
939 client_maximize(data
->client
.c
,
940 !(data
->client
.c
->max_horz
||
941 data
->client
.c
->max_vert
),
945 void action_maximize_horz(union ActionData
*data
)
948 client_maximize(data
->client
.c
, TRUE
, 1, TRUE
);
951 void action_unmaximize_horz(union ActionData
*data
)
954 client_maximize(data
->client
.c
, FALSE
, 1, TRUE
);
957 void action_toggle_maximize_horz(union ActionData
*data
)
960 client_maximize(data
->client
.c
, !data
->client
.c
->max_horz
, 1, TRUE
);
963 void action_maximize_vert(union ActionData
*data
)
966 client_maximize(data
->client
.c
, TRUE
, 2, TRUE
);
969 void action_unmaximize_vert(union ActionData
*data
)
972 client_maximize(data
->client
.c
, FALSE
, 2, TRUE
);
975 void action_toggle_maximize_vert(union ActionData
*data
)
978 client_maximize(data
->client
.c
, !data
->client
.c
->max_vert
, 2, TRUE
);
981 void action_send_to_desktop(union ActionData
*data
)
983 ObClient
*c
= data
->sendto
.c
;
985 if (!c
|| !client_normal(c
)) return;
987 if (data
->sendto
.desk
< screen_num_desktops
||
988 data
->sendto
.desk
== DESKTOP_ALL
) {
989 client_set_desktop(c
, data
->sendto
.desk
, data
->sendtodir
.follow
);
990 if (data
->sendto
.follow
)
991 screen_set_desktop(data
->sendto
.desk
);
995 void action_desktop(union ActionData
*data
)
997 if (data
->desktop
.desk
< screen_num_desktops
||
998 data
->desktop
.desk
== DESKTOP_ALL
)
999 screen_set_desktop(data
->desktop
.desk
);
1002 void action_desktop_dir(union ActionData
*data
)
1006 d
= screen_cycle_desktop(data
->desktopdir
.dir
, data
->desktopdir
.wrap
,
1007 data
->sendtodir
.linear
,
1008 data
->desktopdir
.final
, data
->desktopdir
.cancel
);
1009 screen_set_desktop(d
);
1012 void action_send_to_desktop_dir(union ActionData
*data
)
1014 ObClient
*c
= data
->sendtodir
.c
;
1017 if (!c
|| !client_normal(c
)) return;
1019 d
= screen_cycle_desktop(data
->sendtodir
.dir
, data
->sendtodir
.wrap
,
1020 data
->sendtodir
.linear
,
1021 data
->sendtodir
.final
, data
->sendtodir
.cancel
);
1022 client_set_desktop(c
, d
, data
->sendtodir
.follow
);
1023 if (data
->sendtodir
.follow
)
1024 screen_set_desktop(d
);
1028 void action_desktop_right(union ActionData
*data
)
1032 cur_row_col(&r
, &c
);
1034 if (c
>= screen_desktop_layout
.columns
) {
1035 if (!data
->desktopdir
.wrap
) return;
1038 d
= translate_row_col(r
, c
);
1039 if (d
>= screen_num_desktops
) {
1040 if (!data
->desktopdir
.wrap
) return;
1043 d
= translate_row_col(r
, c
);
1044 if (d
< screen_num_desktops
)
1045 screen_cycle_desktop(d
, data
->desktopdir
.final
,
1046 data
->desktopdir
.cancel
);
1049 void action_send_to_desktop_right(union ActionData
*data
)
1051 ObClient
*cl
= data
->sendto
.c
;
1054 if (!cl
|| !client_normal(cl
)) return;
1056 cur_row_col(&r
, &c
);
1058 if (c
>= screen_desktop_layout
.columns
) {
1059 if (!data
->sendtodir
.wrap
) return;
1062 d
= translate_row_col(r
, c
);
1063 if (d
>= screen_num_desktops
) {
1064 if (!data
->sendtodir
.wrap
) return;
1067 d
= translate_row_col(r
, c
);
1068 if (d
< screen_num_desktops
) {
1069 client_set_desktop(cl
, d
, data
->sendtodir
.follow
);
1070 if (data
->sendtodir
.follow
)
1071 screen_cycle_desktop(d
, data
->desktopdir
.final
,
1072 data
->desktopdir
.cancel
);
1076 void action_desktop_left(union ActionData
*data
)
1080 cur_row_col(&r
, &c
);
1082 if (c
>= screen_desktop_layout
.columns
) {
1083 if (!data
->desktopdir
.wrap
) return;
1084 c
= screen_desktop_layout
.columns
- 1;
1086 d
= translate_row_col(r
, c
);
1087 if (d
>= screen_num_desktops
) {
1088 if (!data
->desktopdir
.wrap
) return;
1091 d
= translate_row_col(r
, c
);
1092 if (d
< screen_num_desktops
)
1093 screen_cycle_desktop(d
, data
->desktopdir
.final
,
1094 data
->desktopdir
.cancel
);
1097 void action_send_to_desktop_left(union ActionData
*data
)
1099 ObClient
*cl
= data
->sendto
.c
;
1102 if (!cl
|| !client_normal(cl
)) return;
1104 cur_row_col(&r
, &c
);
1106 if (c
>= screen_desktop_layout
.columns
) {
1107 if (!data
->sendtodir
.wrap
) return;
1108 c
= screen_desktop_layout
.columns
- 1;
1110 d
= translate_row_col(r
, c
);
1111 if (d
>= screen_num_desktops
) {
1112 if (!data
->sendtodir
.wrap
) return;
1115 d
= translate_row_col(r
, c
);
1116 if (d
< screen_num_desktops
) {
1117 client_set_desktop(cl
, d
, data
->sendtodir
.follow
);
1118 if (data
->sendtodir
.follow
)
1119 screen_cycle_desktop(d
, data
->desktopdir
.final
,
1120 data
->desktopdir
.cancel
);
1124 void action_desktop_down(union ActionData
*data
)
1128 cur_row_col(&r
, &c
);
1130 if (r
>= screen_desktop_layout
.rows
) {
1131 if (!data
->desktopdir
.wrap
) return;
1134 d
= translate_row_col(r
, c
);
1135 if (d
>= screen_num_desktops
) {
1136 if (!data
->desktopdir
.wrap
) return;
1139 d
= translate_row_col(r
, c
);
1140 if (d
< screen_num_desktops
)
1141 screen_cycle_desktop(d
, data
->desktopdir
.final
,
1142 data
->desktopdir
.cancel
);
1145 void action_send_to_desktop_down(union ActionData
*data
)
1149 if (data
->sendtodir
.c
) {
1150 cur_row_col(&r
, &c
);
1152 if (r
>= screen_desktop_layout
.rows
) {
1153 if (!data
->sendtodir
.wrap
) return;
1156 d
= translate_row_col(r
, c
);
1157 if (d
>= screen_num_desktops
) {
1158 if (!data
->sendtodir
.wrap
) return;
1161 d
= translate_row_col(r
, c
);
1162 if (d
< screen_num_desktops
) {
1163 client_set_desktop(data
->sendtodir
.c
, d
, data
->sendtodir
.follow
);
1164 if (data
->sendtodir
.follow
)
1165 screen_cycle_desktop(d
, data
->desktopdir
.final
,
1166 data
->desktopdir
.cancel
);
1171 void action_desktop_up(union ActionData
*data
)
1175 cur_row_col(&r
, &c
);
1177 if (r
>= screen_desktop_layout
.rows
) {
1178 if (!data
->desktopdir
.wrap
) return;
1179 r
= screen_desktop_layout
.rows
- 1;
1181 d
= translate_row_col(r
, c
);
1182 if (d
>= screen_num_desktops
) {
1183 if (!data
->desktopdir
.wrap
) return;
1186 d
= translate_row_col(r
, c
);
1187 if (d
< screen_num_desktops
)
1188 screen_cycle_desktop(d
, data
->desktopdir
.final
,
1189 data
->desktopdir
.cancel
);
1192 void action_send_to_desktop_up(union ActionData
*data
)
1196 if (data
->sendtodir
.c
) {
1197 cur_row_col(&r
, &c
);
1199 if (r
>= screen_desktop_layout
.rows
) {
1200 if (!data
->sendtodir
.wrap
) return;
1201 r
= screen_desktop_layout
.rows
- 1;
1203 d
= translate_row_col(r
, c
);
1204 if (d
>= screen_num_desktops
) {
1205 if (!data
->sendtodir
.wrap
) return;
1208 d
= translate_row_col(r
, c
);
1209 if (d
< screen_num_desktops
) {
1210 client_set_desktop(data
->sendtodir
.c
, d
, data
->sendtodir
.follow
);
1211 if (data
->sendtodir
.follow
)
1212 screen_cycle_desktop(d
, data
->desktopdir
.final
,
1213 data
->desktopdir
.cancel
);
1219 void action_toggle_decorations(union ActionData
*data
)
1221 ObClient
*c
= data
->client
.c
;;
1225 c
->decorate
= !c
->decorate
;
1226 client_setup_decor_and_functions(c
);
1229 void action_moveresize(union ActionData
*data
)
1231 ObClient
*c
= data
->moveresize
.c
;
1233 if (!c
|| !client_normal(c
)) return;
1235 moveresize_start(c
, data
->moveresize
.x
, data
->moveresize
.y
,
1236 data
->moveresize
.button
, data
->moveresize
.corner
);
1239 void action_restart(union ActionData
*data
)
1241 ob_restart_other(data
->execute
.path
);
1244 void action_exit(union ActionData
*data
)
1249 void action_showmenu(union ActionData
*data
)
1251 if (data
->showmenu
.name
) {
1252 menu_show(data
->showmenu
.name
, data
->showmenu
.x
, data
->showmenu
.y
,
1257 void action_cycle_windows(union ActionData
*data
)
1261 c
= focus_cycle(data
->cycle
.forward
, data
->cycle
.linear
, data
->cycle
.final
,
1262 data
->cycle
.cancel
);
1265 void action_directional_focus(union ActionData
*data
)
1269 if (!data
->diraction
.c
)
1271 if ((nf
= client_find_directional(data
->diraction
.c
,
1272 data
->diraction
.direction
)))
1273 client_activate(nf
, FALSE
);
1276 void action_movetoedge(union ActionData
*data
)
1279 ObClient
*c
= data
->diraction
.c
;
1283 x
= c
->frame
->area
.x
;
1284 y
= c
->frame
->area
.y
;
1286 switch(data
->diraction
.direction
) {
1287 case OB_DIRECTION_NORTH
:
1288 y
= client_directional_edge_search(c
, OB_DIRECTION_NORTH
);
1290 case OB_DIRECTION_WEST
:
1291 x
= client_directional_edge_search(c
, OB_DIRECTION_WEST
);
1293 case OB_DIRECTION_SOUTH
:
1294 y
= client_directional_edge_search(c
, OB_DIRECTION_SOUTH
) -
1295 c
->frame
->area
.height
;
1297 case OB_DIRECTION_EAST
:
1298 x
= client_directional_edge_search(c
, OB_DIRECTION_EAST
) -
1299 c
->frame
->area
.width
;
1302 g_assert_not_reached();
1304 frame_frame_gravity(c
->frame
, &x
, &y
);
1305 client_configure(c
, OB_CORNER_TOPLEFT
,
1306 x
, y
, c
->area
.width
, c
->area
.height
, TRUE
, TRUE
);
1310 void action_growtoedge(union ActionData
*data
)
1312 int x
, y
, width
, height
, dest
;
1313 ObClient
*c
= data
->diraction
.c
;
1314 Rect
*a
= screen_area(c
->desktop
);
1319 x
= c
->frame
->area
.x
;
1320 y
= c
->frame
->area
.y
;
1321 width
= c
->frame
->area
.width
;
1322 height
= c
->frame
->area
.height
;
1324 switch(data
->diraction
.direction
) {
1325 case OB_DIRECTION_NORTH
:
1326 dest
= client_directional_edge_search(c
, OB_DIRECTION_NORTH
);
1328 height
= c
->frame
->area
.height
/ 2;
1330 height
= c
->frame
->area
.y
+ c
->frame
->area
.height
- dest
;
1334 case OB_DIRECTION_WEST
:
1335 dest
= client_directional_edge_search(c
, OB_DIRECTION_WEST
);
1337 width
= c
->frame
->area
.width
/ 2;
1339 width
= c
->frame
->area
.x
+ c
->frame
->area
.width
- dest
;
1343 case OB_DIRECTION_SOUTH
:
1344 dest
= client_directional_edge_search(c
, OB_DIRECTION_SOUTH
);
1345 if (a
->y
+ a
->height
== y
+ c
->frame
->area
.height
) {
1346 height
= c
->frame
->area
.height
/ 2;
1347 y
= a
->y
+ a
->height
- height
;
1349 height
= dest
- c
->frame
->area
.y
;
1350 y
+= (height
- c
->frame
->area
.height
) % c
->size_inc
.height
;
1351 height
-= (height
- c
->frame
->area
.height
) % c
->size_inc
.height
;
1353 case OB_DIRECTION_EAST
:
1354 dest
= client_directional_edge_search(c
, OB_DIRECTION_EAST
);
1355 if (a
->x
+ a
->width
== x
+ c
->frame
->area
.width
) {
1356 width
= c
->frame
->area
.width
/ 2;
1357 x
= a
->x
+ a
->width
- width
;
1359 width
= dest
- c
->frame
->area
.x
;
1360 x
+= (width
- c
->frame
->area
.width
) % c
->size_inc
.width
;
1361 width
-= (width
- c
->frame
->area
.width
) % c
->size_inc
.width
;
1364 g_assert_not_reached();
1366 frame_frame_gravity(c
->frame
, &x
, &y
);
1367 width
-= c
->frame
->size
.left
+ c
->frame
->size
.right
;
1368 height
-= c
->frame
->size
.top
+ c
->frame
->size
.bottom
;
1369 client_configure(c
, OB_CORNER_TOPLEFT
, x
, y
, width
, height
, TRUE
, TRUE
);
1372 void action_send_to_layer(union ActionData
*data
)
1375 client_set_layer(data
->layer
.c
, data
->layer
.layer
);
1378 void action_toggle_layer(union ActionData
*data
)
1380 ObClient
*c
= data
->layer
.c
;
1383 if (data
->layer
.layer
< 0)
1384 client_set_layer(c
, c
->below
? 0 : -1);
1385 else if (data
->layer
.layer
> 0)
1386 client_set_layer(c
, c
->above
? 0 : 1);
1390 void action_toggle_show_desktop(union ActionData
*data
)
1392 screen_show_desktop(!screen_showing_desktop
);
1395 void action_show_desktop(union ActionData
*data
)
1397 screen_show_desktop(TRUE
);
1400 void action_unshow_desktop(union ActionData
*data
)
1402 screen_show_desktop(FALSE
);