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
)
87 void setup_action_send_to_desktop_prev(ObAction
*a
)
89 a
->data
.sendtodir
.dir
= OB_DIRECTION_WEST
;
90 a
->data
.sendtodir
.linear
= TRUE
;
91 a
->data
.sendtodir
.wrap
= TRUE
;
94 void setup_action_send_to_desktop_next(ObAction
*a
)
96 a
->data
.sendtodir
.dir
= OB_DIRECTION_EAST
;
97 a
->data
.sendtodir
.linear
= TRUE
;
98 a
->data
.sendtodir
.wrap
= TRUE
;
101 void setup_action_send_to_desktop_left(ObAction
*a
)
103 a
->data
.sendtodir
.dir
= OB_DIRECTION_WEST
;
104 a
->data
.sendtodir
.linear
= FALSE
;
105 a
->data
.sendtodir
.wrap
= TRUE
;
108 void setup_action_send_to_desktop_right(ObAction
*a
)
110 a
->data
.sendtodir
.dir
= OB_DIRECTION_EAST
;
111 a
->data
.sendtodir
.linear
= FALSE
;
112 a
->data
.sendtodir
.wrap
= TRUE
;
115 void setup_action_send_to_desktop_up(ObAction
*a
)
117 a
->data
.sendtodir
.dir
= OB_DIRECTION_NORTH
;
118 a
->data
.sendtodir
.linear
= FALSE
;
119 a
->data
.sendtodir
.wrap
= TRUE
;
122 void setup_action_send_to_desktop_down(ObAction
*a
)
124 a
->data
.sendtodir
.dir
= OB_DIRECTION_SOUTH
;
125 a
->data
.sendtodir
.linear
= FALSE
;
126 a
->data
.sendtodir
.wrap
= TRUE
;
129 void setup_action_desktop_prev(ObAction
*a
)
131 a
->data
.desktopdir
.dir
= OB_DIRECTION_WEST
;
132 a
->data
.desktopdir
.linear
= TRUE
;
133 a
->data
.desktopdir
.wrap
= TRUE
;
136 void setup_action_desktop_next(ObAction
*a
)
138 a
->data
.desktopdir
.dir
= OB_DIRECTION_EAST
;
139 a
->data
.desktopdir
.linear
= TRUE
;
140 a
->data
.desktopdir
.wrap
= TRUE
;
143 void setup_action_desktop_left(ObAction
*a
)
145 a
->data
.desktopdir
.dir
= OB_DIRECTION_WEST
;
146 a
->data
.desktopdir
.linear
= FALSE
;
147 a
->data
.desktopdir
.wrap
= TRUE
;
150 void setup_action_desktop_right(ObAction
*a
)
152 a
->data
.desktopdir
.dir
= OB_DIRECTION_EAST
;
153 a
->data
.desktopdir
.linear
= FALSE
;
154 a
->data
.desktopdir
.wrap
= TRUE
;
157 void setup_action_desktop_up(ObAction
*a
)
159 a
->data
.desktopdir
.dir
= OB_DIRECTION_NORTH
;
160 a
->data
.desktopdir
.linear
= FALSE
;
161 a
->data
.desktopdir
.wrap
= TRUE
;
164 void setup_action_desktop_down(ObAction
*a
)
166 a
->data
.desktopdir
.dir
= OB_DIRECTION_SOUTH
;
167 a
->data
.desktopdir
.linear
= FALSE
;
168 a
->data
.desktopdir
.wrap
= TRUE
;
171 void setup_action_move_keyboard(ObAction
*a
)
173 a
->data
.moveresize
.corner
= prop_atoms
.net_wm_moveresize_move_keyboard
;
176 void setup_action_move(ObAction
*a
)
178 a
->data
.moveresize
.corner
= prop_atoms
.net_wm_moveresize_move
;
181 void setup_action_resize(ObAction
*a
)
183 a
->data
.moveresize
.corner
= prop_atoms
.net_wm_moveresize_size_topleft
;
186 void setup_action_resize_keyboard(ObAction
*a
)
188 a
->data
.moveresize
.corner
= prop_atoms
.net_wm_moveresize_size_keyboard
;
191 void setup_action_cycle_windows_linear_next(ObAction
*a
)
193 a
->data
.cycle
.linear
= TRUE
;
194 a
->data
.cycle
.forward
= TRUE
;
197 void setup_action_cycle_windows_linear_previous(ObAction
*a
)
199 a
->data
.cycle
.linear
= TRUE
;
200 a
->data
.cycle
.forward
= FALSE
;
203 void setup_action_cycle_windows_next(ObAction
*a
)
205 a
->data
.cycle
.linear
= FALSE
;
206 a
->data
.cycle
.forward
= TRUE
;
209 void setup_action_cycle_windows_previous(ObAction
*a
)
211 a
->data
.cycle
.linear
= FALSE
;
212 a
->data
.cycle
.forward
= FALSE
;
215 void setup_action_movetoedge_north(ObAction
*a
)
217 a
->data
.diraction
.direction
= OB_DIRECTION_NORTH
;
220 void setup_action_movetoedge_south(ObAction
*a
)
222 a
->data
.diraction
.direction
= OB_DIRECTION_SOUTH
;
225 void setup_action_movetoedge_east(ObAction
*a
)
227 a
->data
.diraction
.direction
= OB_DIRECTION_EAST
;
230 void setup_action_movetoedge_west(ObAction
*a
)
232 a
->data
.diraction
.direction
= OB_DIRECTION_WEST
;
235 void setup_action_growtoedge_north(ObAction
*a
)
237 a
->data
.diraction
.direction
= OB_DIRECTION_NORTH
;
240 void setup_action_growtoedge_south(ObAction
*a
)
242 a
->data
.diraction
.direction
= OB_DIRECTION_SOUTH
;
245 void setup_action_growtoedge_east(ObAction
*a
)
247 a
->data
.diraction
.direction
= OB_DIRECTION_EAST
;
250 void setup_action_growtoedge_west(ObAction
*a
)
252 a
->data
.diraction
.direction
= OB_DIRECTION_WEST
;
255 void setup_action_top_layer(ObAction
*a
)
257 a
->data
.layer
.layer
= 1;
260 void setup_action_normal_layer(ObAction
*a
)
262 a
->data
.layer
.layer
= 0;
265 void setup_action_bottom_layer(ObAction
*a
)
267 a
->data
.layer
.layer
= -1;
270 ActionString actionstrings
[] =
278 "directionalfocusnorth",
279 action_directional_focus
,
280 setup_action_directional_focus_north
283 "directionalfocuseast",
284 action_directional_focus
,
285 setup_action_directional_focus_east
288 "directionalfocussouth",
289 action_directional_focus
,
290 setup_action_directional_focus_south
293 "directionalfocuswest",
294 action_directional_focus
,
295 setup_action_directional_focus_west
298 "directionalfocusnortheast",
299 action_directional_focus
,
300 setup_action_directional_focus_northeast
303 "directionalfocussoutheast",
304 action_directional_focus
,
305 setup_action_directional_focus_southeast
308 "directionalfocussouthwest",
309 action_directional_focus
,
310 setup_action_directional_focus_southwest
313 "directionalfocusnorthwest",
314 action_directional_focus
,
315 setup_action_directional_focus_northwest
384 action_toggle_omnipresent
,
389 action_move_relative_horz
,
394 action_move_relative_vert
,
398 "resizerelativehorz",
399 action_resize_relative_horz
,
403 "resizerelativevert",
404 action_resize_relative_vert
,
409 action_maximize_full
,
414 action_unmaximize_full
,
418 "togglemaximizefull",
419 action_toggle_maximize_full
,
424 action_maximize_horz
,
429 action_unmaximize_horz
,
433 "togglemaximizehorz",
434 action_toggle_maximize_horz
,
439 action_maximize_vert
,
444 action_unmaximize_vert
,
448 "togglemaximizevert",
449 action_toggle_maximize_vert
,
454 action_send_to_desktop
,
455 setup_action_send_to_desktop
459 action_send_to_desktop_dir
,
460 setup_action_send_to_desktop_next
463 "sendtodesktopprevious",
464 action_send_to_desktop_dir
,
465 setup_action_send_to_desktop_prev
468 "sendtodesktopright",
469 action_send_to_desktop_dir
,
470 setup_action_send_to_desktop_right
474 action_send_to_desktop_dir
,
475 setup_action_send_to_desktop_left
479 action_send_to_desktop_dir
,
480 setup_action_send_to_desktop_up
484 action_send_to_desktop_dir
,
485 setup_action_send_to_desktop_down
495 setup_action_desktop_next
500 setup_action_desktop_prev
505 setup_action_desktop_right
510 setup_action_desktop_left
515 setup_action_desktop_up
520 setup_action_desktop_down
524 action_toggle_decorations
,
530 setup_action_move_keyboard
545 setup_action_resize_keyboard
549 action_toggle_show_desktop
,
559 action_unshow_desktop
,
579 action_send_to_layer
,
580 setup_action_top_layer
585 setup_action_top_layer
589 action_send_to_layer
,
590 setup_action_normal_layer
594 action_send_to_layer
,
595 setup_action_bottom_layer
598 "togglealwaysonbottom",
600 setup_action_bottom_layer
604 action_cycle_windows
,
605 setup_action_cycle_windows_linear_next
608 "previouswindowlinear",
609 action_cycle_windows
,
610 setup_action_cycle_windows_linear_previous
614 action_cycle_windows
,
615 setup_action_cycle_windows_next
619 action_cycle_windows
,
620 setup_action_cycle_windows_previous
625 setup_action_movetoedge_north
630 setup_action_movetoedge_south
635 setup_action_movetoedge_west
640 setup_action_movetoedge_east
645 setup_action_growtoedge_north
650 setup_action_growtoedge_south
655 setup_action_growtoedge_west
660 setup_action_growtoedge_east
669 ObAction
*action_from_string(char *name
)
674 for (i
= 0; actionstrings
[i
].name
; i
++)
675 if (!g_ascii_strcasecmp(name
, actionstrings
[i
].name
)) {
676 a
= action_new(actionstrings
[i
].func
);
677 if (actionstrings
[i
].setup
)
678 actionstrings
[i
].setup(a
);
684 ObAction
*action_parse(xmlDocPtr doc
, xmlNodePtr node
)
687 ObAction
*act
= NULL
;
690 if (parse_attr_string("name", node
, &actname
)) {
691 if ((act
= action_from_string(actname
))) {
692 if (act
->func
== action_execute
|| act
->func
== action_restart
) {
693 if ((n
= parse_find_node("execute", node
->xmlChildrenNode
)))
694 act
->data
.execute
.path
= parse_string(doc
, n
);
695 } else if (act
->func
== action_showmenu
) {
696 if ((n
= parse_find_node("menu", node
->xmlChildrenNode
)))
697 act
->data
.showmenu
.name
= parse_string(doc
, n
);
698 } else if (act
->func
== action_desktop
) {
699 if ((n
= parse_find_node("desktop", node
->xmlChildrenNode
)))
700 act
->data
.desktop
.desk
= parse_int(doc
, n
);
701 if (act
->data
.desktop
.desk
> 0) act
->data
.desktop
.desk
--;
702 } else if (act
->func
== action_send_to_desktop
) {
703 if ((n
= parse_find_node("desktop", node
->xmlChildrenNode
)))
704 act
->data
.sendto
.desk
= parse_int(doc
, n
);
705 if (act
->data
.sendto
.desk
> 0) act
->data
.sendto
.desk
--;
706 } else if (act
->func
== action_move_relative_horz
||
707 act
->func
== action_move_relative_vert
||
708 act
->func
== action_resize_relative_horz
||
709 act
->func
== action_resize_relative_vert
) {
710 if ((n
= parse_find_node("delta", node
->xmlChildrenNode
)))
711 act
->data
.relative
.delta
= parse_int(doc
, n
);
712 } else if (act
->func
== action_desktop_dir
) {
713 if ((n
= parse_find_node("wrap", node
->xmlChildrenNode
))) {
714 act
->data
.desktopdir
.wrap
= parse_bool(doc
, n
);
716 } else if (act
->func
== action_send_to_desktop_dir
) {
717 if ((n
= parse_find_node("wrap", node
->xmlChildrenNode
)))
718 act
->data
.sendtodir
.wrap
= parse_bool(doc
, n
);
726 void action_execute(union ActionData
*data
)
730 if (data
->execute
.path
) {
731 cmd
= g_filename_from_utf8(data
->execute
.path
, -1, NULL
, NULL
, NULL
);
733 if (!g_spawn_command_line_async(cmd
, &e
)) {
734 g_warning("failed to execute '%s': %s",
738 g_warning("failed to convert '%s' from utf8", data
->execute
.path
);
743 void action_activate(union ActionData
*data
)
745 if (data
->activate
.c
)
746 client_activate(data
->activate
.c
, data
->activate
.here
);
749 void action_focus(union ActionData
*data
)
752 client_focus(data
->client
.c
);
755 void action_unfocus (union ActionData
*data
)
758 client_unfocus(data
->client
.c
);
761 void action_iconify(union ActionData
*data
)
764 client_iconify(data
->client
.c
, TRUE
, TRUE
);
767 void action_raise(union ActionData
*data
)
770 stacking_raise(CLIENT_AS_WINDOW(data
->client
.c
));
773 void action_unshaderaise(union ActionData
*data
)
775 if (data
->client
.c
) {
776 if (data
->client
.c
->shaded
)
777 client_shade(data
->client
.c
, FALSE
);
779 stacking_raise(CLIENT_AS_WINDOW(data
->client
.c
));
783 void action_shadelower(union ActionData
*data
)
785 if (data
->client
.c
) {
786 if (data
->client
.c
->shaded
)
787 stacking_lower(CLIENT_AS_WINDOW(data
->client
.c
));
789 client_shade(data
->client
.c
, TRUE
);
793 void action_lower(union ActionData
*data
)
796 stacking_lower(CLIENT_AS_WINDOW(data
->client
.c
));
799 void action_close(union ActionData
*data
)
802 client_close(data
->client
.c
);
805 void action_kill(union ActionData
*data
)
808 client_kill(data
->client
.c
);
811 void action_shade(union ActionData
*data
)
814 client_shade(data
->client
.c
, TRUE
);
817 void action_unshade(union ActionData
*data
)
820 client_shade(data
->client
.c
, FALSE
);
823 void action_toggle_shade(union ActionData
*data
)
826 client_shade(data
->client
.c
, !data
->client
.c
->shaded
);
829 void action_toggle_omnipresent(union ActionData
*data
)
832 client_set_desktop(data
->client
.c
,
833 data
->client
.c
->desktop
== DESKTOP_ALL
?
834 screen_desktop
: DESKTOP_ALL
, FALSE
);
837 void action_move_relative_horz(union ActionData
*data
)
839 ObClient
*c
= data
->relative
.c
;
841 client_configure(c
, OB_CORNER_TOPLEFT
,
842 c
->area
.x
+ data
->relative
.delta
, c
->area
.y
,
843 c
->area
.width
, c
->area
.height
, TRUE
, TRUE
);
846 void action_move_relative_vert(union ActionData
*data
)
848 ObClient
*c
= data
->relative
.c
;
850 client_configure(c
, OB_CORNER_TOPLEFT
,
851 c
->area
.x
, c
->area
.y
+ data
->relative
.delta
,
852 c
->area
.width
, c
->area
.height
, TRUE
, TRUE
);
855 void action_resize_relative_horz(union ActionData
*data
)
857 ObClient
*c
= data
->relative
.c
;
859 client_configure(c
, OB_CORNER_TOPLEFT
, c
->area
.x
, c
->area
.y
,
861 data
->relative
.delta
* c
->size_inc
.width
,
862 c
->area
.height
, TRUE
, TRUE
);
865 void action_resize_relative_vert(union ActionData
*data
)
867 ObClient
*c
= data
->relative
.c
;
869 client_configure(c
, OB_CORNER_TOPLEFT
, c
->area
.x
, c
->area
.y
,
870 c
->area
.width
, c
->area
.height
+
871 data
->relative
.delta
* c
->size_inc
.height
,
875 void action_maximize_full(union ActionData
*data
)
878 client_maximize(data
->client
.c
, TRUE
, 0, TRUE
);
881 void action_unmaximize_full(union ActionData
*data
)
884 client_maximize(data
->client
.c
, FALSE
, 0, TRUE
);
887 void action_toggle_maximize_full(union ActionData
*data
)
890 client_maximize(data
->client
.c
,
891 !(data
->client
.c
->max_horz
||
892 data
->client
.c
->max_vert
),
896 void action_maximize_horz(union ActionData
*data
)
899 client_maximize(data
->client
.c
, TRUE
, 1, TRUE
);
902 void action_unmaximize_horz(union ActionData
*data
)
905 client_maximize(data
->client
.c
, FALSE
, 1, TRUE
);
908 void action_toggle_maximize_horz(union ActionData
*data
)
911 client_maximize(data
->client
.c
, !data
->client
.c
->max_horz
, 1, TRUE
);
914 void action_maximize_vert(union ActionData
*data
)
917 client_maximize(data
->client
.c
, TRUE
, 2, TRUE
);
920 void action_unmaximize_vert(union ActionData
*data
)
923 client_maximize(data
->client
.c
, FALSE
, 2, TRUE
);
926 void action_toggle_maximize_vert(union ActionData
*data
)
929 client_maximize(data
->client
.c
, !data
->client
.c
->max_vert
, 2, TRUE
);
932 void action_send_to_desktop(union ActionData
*data
)
934 ObClient
*c
= data
->sendto
.c
;
936 if (!c
|| !client_normal(c
)) return;
938 if (data
->sendto
.desk
< screen_num_desktops
||
939 data
->sendto
.desk
== DESKTOP_ALL
) {
940 client_set_desktop(c
, data
->sendto
.desk
, TRUE
);
941 screen_set_desktop(data
->sendto
.desk
);
945 void action_desktop(union ActionData
*data
)
947 if (data
->desktop
.desk
< screen_num_desktops
||
948 data
->desktop
.desk
== DESKTOP_ALL
)
949 screen_set_desktop(data
->desktop
.desk
);
952 void action_desktop_dir(union ActionData
*data
)
956 d
= screen_cycle_desktop(data
->desktopdir
.dir
, data
->desktopdir
.wrap
,
957 data
->sendtodir
.linear
,
958 data
->desktopdir
.final
, data
->desktopdir
.cancel
);
959 screen_set_desktop(d
);
962 void action_send_to_desktop_dir(union ActionData
*data
)
964 ObClient
*c
= data
->sendtodir
.c
;
967 if (!c
|| !client_normal(c
)) return;
969 d
= screen_cycle_desktop(data
->sendtodir
.dir
, data
->sendtodir
.wrap
,
970 data
->sendtodir
.linear
,
971 data
->sendtodir
.final
, data
->sendtodir
.cancel
);
972 client_set_desktop(c
, d
, TRUE
);
973 screen_set_desktop(d
);
977 void action_desktop_right(union ActionData
*data
)
983 if (c
>= screen_desktop_layout
.columns
) {
984 if (!data
->desktopdir
.wrap
) return;
987 d
= translate_row_col(r
, c
);
988 if (d
>= screen_num_desktops
) {
989 if (!data
->desktopdir
.wrap
) return;
992 d
= translate_row_col(r
, c
);
993 if (d
< screen_num_desktops
)
994 screen_cycle_desktop(d
, data
->desktopdir
.final
,
995 data
->desktopdir
.cancel
);
998 void action_send_to_desktop_right(union ActionData
*data
)
1000 ObClient
*cl
= data
->sendto
.c
;
1003 if (!cl
|| !client_normal(cl
)) return;
1005 cur_row_col(&r
, &c
);
1007 if (c
>= screen_desktop_layout
.columns
) {
1008 if (!data
->sendtodir
.wrap
) return;
1011 d
= translate_row_col(r
, c
);
1012 if (d
>= screen_num_desktops
) {
1013 if (!data
->sendtodir
.wrap
) return;
1016 d
= translate_row_col(r
, c
);
1017 if (d
< screen_num_desktops
) {
1018 client_set_desktop(cl
, d
, data
->sendtodir
.follow
);
1019 if (data
->sendtodir
.follow
)
1020 screen_cycle_desktop(d
, data
->desktopdir
.final
,
1021 data
->desktopdir
.cancel
);
1025 void action_desktop_left(union ActionData
*data
)
1029 cur_row_col(&r
, &c
);
1031 if (c
>= screen_desktop_layout
.columns
) {
1032 if (!data
->desktopdir
.wrap
) return;
1033 c
= screen_desktop_layout
.columns
- 1;
1035 d
= translate_row_col(r
, c
);
1036 if (d
>= screen_num_desktops
) {
1037 if (!data
->desktopdir
.wrap
) return;
1040 d
= translate_row_col(r
, c
);
1041 if (d
< screen_num_desktops
)
1042 screen_cycle_desktop(d
, data
->desktopdir
.final
,
1043 data
->desktopdir
.cancel
);
1046 void action_send_to_desktop_left(union ActionData
*data
)
1048 ObClient
*cl
= data
->sendto
.c
;
1051 if (!cl
|| !client_normal(cl
)) return;
1053 cur_row_col(&r
, &c
);
1055 if (c
>= screen_desktop_layout
.columns
) {
1056 if (!data
->sendtodir
.wrap
) return;
1057 c
= screen_desktop_layout
.columns
- 1;
1059 d
= translate_row_col(r
, c
);
1060 if (d
>= screen_num_desktops
) {
1061 if (!data
->sendtodir
.wrap
) return;
1064 d
= translate_row_col(r
, c
);
1065 if (d
< screen_num_desktops
) {
1066 client_set_desktop(cl
, d
, data
->sendtodir
.follow
);
1067 if (data
->sendtodir
.follow
)
1068 screen_cycle_desktop(d
, data
->desktopdir
.final
,
1069 data
->desktopdir
.cancel
);
1073 void action_desktop_down(union ActionData
*data
)
1077 cur_row_col(&r
, &c
);
1079 if (r
>= screen_desktop_layout
.rows
) {
1080 if (!data
->desktopdir
.wrap
) return;
1083 d
= translate_row_col(r
, c
);
1084 if (d
>= screen_num_desktops
) {
1085 if (!data
->desktopdir
.wrap
) return;
1088 d
= translate_row_col(r
, c
);
1089 if (d
< screen_num_desktops
)
1090 screen_cycle_desktop(d
, data
->desktopdir
.final
,
1091 data
->desktopdir
.cancel
);
1094 void action_send_to_desktop_down(union ActionData
*data
)
1098 if (data
->sendtodir
.c
) {
1099 cur_row_col(&r
, &c
);
1101 if (r
>= screen_desktop_layout
.rows
) {
1102 if (!data
->sendtodir
.wrap
) return;
1105 d
= translate_row_col(r
, c
);
1106 if (d
>= screen_num_desktops
) {
1107 if (!data
->sendtodir
.wrap
) return;
1110 d
= translate_row_col(r
, c
);
1111 if (d
< screen_num_desktops
) {
1112 client_set_desktop(data
->sendtodir
.c
, d
, data
->sendtodir
.follow
);
1113 if (data
->sendtodir
.follow
)
1114 screen_cycle_desktop(d
, data
->desktopdir
.final
,
1115 data
->desktopdir
.cancel
);
1120 void action_desktop_up(union ActionData
*data
)
1124 cur_row_col(&r
, &c
);
1126 if (r
>= screen_desktop_layout
.rows
) {
1127 if (!data
->desktopdir
.wrap
) return;
1128 r
= screen_desktop_layout
.rows
- 1;
1130 d
= translate_row_col(r
, c
);
1131 if (d
>= screen_num_desktops
) {
1132 if (!data
->desktopdir
.wrap
) return;
1135 d
= translate_row_col(r
, c
);
1136 if (d
< screen_num_desktops
)
1137 screen_cycle_desktop(d
, data
->desktopdir
.final
,
1138 data
->desktopdir
.cancel
);
1141 void action_send_to_desktop_up(union ActionData
*data
)
1145 if (data
->sendtodir
.c
) {
1146 cur_row_col(&r
, &c
);
1148 if (r
>= screen_desktop_layout
.rows
) {
1149 if (!data
->sendtodir
.wrap
) return;
1150 r
= screen_desktop_layout
.rows
- 1;
1152 d
= translate_row_col(r
, c
);
1153 if (d
>= screen_num_desktops
) {
1154 if (!data
->sendtodir
.wrap
) return;
1157 d
= translate_row_col(r
, c
);
1158 if (d
< screen_num_desktops
) {
1159 client_set_desktop(data
->sendtodir
.c
, d
, data
->sendtodir
.follow
);
1160 if (data
->sendtodir
.follow
)
1161 screen_cycle_desktop(d
, data
->desktopdir
.final
,
1162 data
->desktopdir
.cancel
);
1168 void action_toggle_decorations(union ActionData
*data
)
1170 ObClient
*c
= data
->client
.c
;;
1174 c
->decorate
= !c
->decorate
;
1175 client_setup_decor_and_functions(c
);
1178 void action_moveresize(union ActionData
*data
)
1180 ObClient
*c
= data
->moveresize
.c
;
1182 if (!c
|| !client_normal(c
)) return;
1184 moveresize_start(c
, data
->moveresize
.x
, data
->moveresize
.y
,
1185 data
->moveresize
.button
, data
->moveresize
.corner
);
1188 void action_restart(union ActionData
*data
)
1190 ob_restart_other(data
->execute
.path
);
1193 void action_exit(union ActionData
*data
)
1198 void action_showmenu(union ActionData
*data
)
1200 if (data
->showmenu
.name
) {
1201 menu_show(data
->showmenu
.name
, data
->showmenu
.x
, data
->showmenu
.y
,
1206 void action_cycle_windows(union ActionData
*data
)
1210 c
= focus_cycle(data
->cycle
.forward
, data
->cycle
.linear
, data
->cycle
.final
,
1211 data
->cycle
.cancel
);
1214 void action_directional_focus(union ActionData
*data
)
1218 if (!data
->diraction
.c
)
1220 if ((nf
= client_find_directional(data
->diraction
.c
,
1221 data
->diraction
.direction
)))
1222 client_activate(nf
, FALSE
);
1225 void action_movetoedge(union ActionData
*data
)
1228 ObClient
*c
= data
->diraction
.c
;
1232 x
= c
->frame
->area
.x
;
1233 y
= c
->frame
->area
.y
;
1235 switch(data
->diraction
.direction
) {
1236 case OB_DIRECTION_NORTH
:
1237 y
= client_directional_edge_search(c
, OB_DIRECTION_NORTH
);
1239 case OB_DIRECTION_WEST
:
1240 x
= client_directional_edge_search(c
, OB_DIRECTION_WEST
);
1242 case OB_DIRECTION_SOUTH
:
1243 y
= client_directional_edge_search(c
, OB_DIRECTION_SOUTH
) -
1244 c
->frame
->area
.height
;
1246 case OB_DIRECTION_EAST
:
1247 x
= client_directional_edge_search(c
, OB_DIRECTION_EAST
) -
1248 c
->frame
->area
.width
;
1251 g_assert_not_reached();
1253 frame_frame_gravity(c
->frame
, &x
, &y
);
1254 client_configure(c
, OB_CORNER_TOPLEFT
,
1255 x
, y
, c
->area
.width
, c
->area
.height
, TRUE
, TRUE
);
1259 void action_growtoedge(union ActionData
*data
)
1261 int x
, y
, width
, height
, dest
;
1262 ObClient
*c
= data
->diraction
.c
;
1263 Rect
*a
= screen_area(c
->desktop
);
1268 x
= c
->frame
->area
.x
;
1269 y
= c
->frame
->area
.y
;
1270 width
= c
->frame
->area
.width
;
1271 height
= c
->frame
->area
.height
;
1273 switch(data
->diraction
.direction
) {
1274 case OB_DIRECTION_NORTH
:
1275 dest
= client_directional_edge_search(c
, OB_DIRECTION_NORTH
);
1277 height
= c
->frame
->area
.height
/ 2;
1279 height
= c
->frame
->area
.y
+ c
->frame
->area
.height
- dest
;
1283 case OB_DIRECTION_WEST
:
1284 dest
= client_directional_edge_search(c
, OB_DIRECTION_WEST
);
1286 width
= c
->frame
->area
.width
/ 2;
1288 width
= c
->frame
->area
.x
+ c
->frame
->area
.width
- dest
;
1292 case OB_DIRECTION_SOUTH
:
1293 dest
= client_directional_edge_search(c
, OB_DIRECTION_SOUTH
);
1294 if (a
->y
+ a
->height
== y
+ c
->frame
->area
.height
) {
1295 height
= c
->frame
->area
.height
/ 2;
1296 y
= a
->y
+ a
->height
- height
;
1298 height
= dest
- c
->frame
->area
.y
;
1299 y
+= (height
- c
->frame
->area
.height
) % c
->size_inc
.height
;
1300 height
-= (height
- c
->frame
->area
.height
) % c
->size_inc
.height
;
1302 case OB_DIRECTION_EAST
:
1303 dest
= client_directional_edge_search(c
, OB_DIRECTION_EAST
);
1304 if (a
->x
+ a
->width
== x
+ c
->frame
->area
.width
) {
1305 width
= c
->frame
->area
.width
/ 2;
1306 x
= a
->x
+ a
->width
- width
;
1308 width
= dest
- c
->frame
->area
.x
;
1309 x
+= (width
- c
->frame
->area
.width
) % c
->size_inc
.width
;
1310 width
-= (width
- c
->frame
->area
.width
) % c
->size_inc
.width
;
1313 g_assert_not_reached();
1315 frame_frame_gravity(c
->frame
, &x
, &y
);
1316 width
-= c
->frame
->size
.left
+ c
->frame
->size
.right
;
1317 height
-= c
->frame
->size
.top
+ c
->frame
->size
.bottom
;
1318 client_configure(c
, OB_CORNER_TOPLEFT
, x
, y
, width
, height
, TRUE
, TRUE
);
1321 void action_send_to_layer(union ActionData
*data
)
1324 client_set_layer(data
->layer
.c
, data
->layer
.layer
);
1327 void action_toggle_layer(union ActionData
*data
)
1329 ObClient
*c
= data
->layer
.c
;
1332 if (data
->layer
.layer
< 0)
1333 client_set_layer(c
, c
->below
? 0 : -1);
1334 else if (data
->layer
.layer
> 0)
1335 client_set_layer(c
, c
->above
? 0 : 1);
1339 void action_toggle_show_desktop(union ActionData
*data
)
1341 screen_show_desktop(!screen_showing_desktop
);
1344 void action_show_desktop(union ActionData
*data
)
1346 screen_show_desktop(TRUE
);
1349 void action_unshow_desktop(union ActionData
*data
)
1351 screen_show_desktop(FALSE
);