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
389 action_toggle_omnipresent
,
394 action_move_relative_horz
,
399 action_move_relative_vert
,
403 "resizerelativehorz",
404 action_resize_relative_horz
,
408 "resizerelativevert",
409 action_resize_relative_vert
,
414 action_maximize_full
,
419 action_unmaximize_full
,
423 "togglemaximizefull",
424 action_toggle_maximize_full
,
429 action_maximize_horz
,
434 action_unmaximize_horz
,
438 "togglemaximizehorz",
439 action_toggle_maximize_horz
,
444 action_maximize_vert
,
449 action_unmaximize_vert
,
453 "togglemaximizevert",
454 action_toggle_maximize_vert
,
459 action_send_to_desktop
,
460 setup_action_send_to_desktop
464 action_send_to_desktop_dir
,
465 setup_action_send_to_desktop_next
468 "sendtodesktopprevious",
469 action_send_to_desktop_dir
,
470 setup_action_send_to_desktop_prev
473 "sendtodesktopright",
474 action_send_to_desktop_dir
,
475 setup_action_send_to_desktop_right
479 action_send_to_desktop_dir
,
480 setup_action_send_to_desktop_left
484 action_send_to_desktop_dir
,
485 setup_action_send_to_desktop_up
489 action_send_to_desktop_dir
,
490 setup_action_send_to_desktop_down
500 setup_action_desktop_next
505 setup_action_desktop_prev
510 setup_action_desktop_right
515 setup_action_desktop_left
520 setup_action_desktop_up
525 setup_action_desktop_down
529 action_toggle_decorations
,
535 setup_action_move_keyboard
550 setup_action_resize_keyboard
554 action_toggle_show_desktop
,
564 action_unshow_desktop
,
584 action_send_to_layer
,
585 setup_action_top_layer
590 setup_action_top_layer
594 action_send_to_layer
,
595 setup_action_normal_layer
599 action_send_to_layer
,
600 setup_action_bottom_layer
603 "togglealwaysonbottom",
605 setup_action_bottom_layer
609 action_cycle_windows
,
610 setup_action_cycle_windows_linear_next
613 "previouswindowlinear",
614 action_cycle_windows
,
615 setup_action_cycle_windows_linear_previous
619 action_cycle_windows
,
620 setup_action_cycle_windows_next
624 action_cycle_windows
,
625 setup_action_cycle_windows_previous
630 setup_action_movetoedge_north
635 setup_action_movetoedge_south
640 setup_action_movetoedge_west
645 setup_action_movetoedge_east
650 setup_action_growtoedge_north
655 setup_action_growtoedge_south
660 setup_action_growtoedge_west
665 setup_action_growtoedge_east
674 ObAction
*action_from_string(char *name
)
679 for (i
= 0; actionstrings
[i
].name
; i
++)
680 if (!g_ascii_strcasecmp(name
, actionstrings
[i
].name
)) {
681 a
= action_new(actionstrings
[i
].func
);
682 if (actionstrings
[i
].setup
)
683 actionstrings
[i
].setup(a
);
689 ObAction
*action_parse(xmlDocPtr doc
, xmlNodePtr node
)
692 ObAction
*act
= NULL
;
695 if (parse_attr_string("name", node
, &actname
)) {
696 if ((act
= action_from_string(actname
))) {
697 if (act
->func
== action_execute
|| act
->func
== action_restart
) {
698 if ((n
= parse_find_node("execute", node
->xmlChildrenNode
)))
699 act
->data
.execute
.path
= parse_string(doc
, n
);
700 } else if (act
->func
== action_showmenu
) {
701 if ((n
= parse_find_node("menu", node
->xmlChildrenNode
)))
702 act
->data
.showmenu
.name
= parse_string(doc
, n
);
703 } else if (act
->func
== action_desktop
) {
704 if ((n
= parse_find_node("desktop", node
->xmlChildrenNode
)))
705 act
->data
.desktop
.desk
= parse_int(doc
, n
);
706 if (act
->data
.desktop
.desk
> 0) act
->data
.desktop
.desk
--;
707 } else if (act
->func
== action_send_to_desktop
) {
708 if ((n
= parse_find_node("desktop", node
->xmlChildrenNode
)))
709 act
->data
.sendto
.desk
= parse_int(doc
, n
);
710 if (act
->data
.sendto
.desk
> 0) act
->data
.sendto
.desk
--;
711 } else if (act
->func
== action_move_relative_horz
||
712 act
->func
== action_move_relative_vert
||
713 act
->func
== action_resize_relative_horz
||
714 act
->func
== action_resize_relative_vert
) {
715 if ((n
= parse_find_node("delta", node
->xmlChildrenNode
)))
716 act
->data
.relative
.delta
= parse_int(doc
, n
);
717 } else if (act
->func
== action_desktop_dir
) {
718 if ((n
= parse_find_node("wrap", node
->xmlChildrenNode
))) {
719 act
->data
.desktopdir
.wrap
= parse_bool(doc
, n
);
721 } else if (act
->func
== action_send_to_desktop_dir
) {
722 if ((n
= parse_find_node("wrap", node
->xmlChildrenNode
)))
723 act
->data
.sendtodir
.wrap
= parse_bool(doc
, n
);
724 } else if (act
->func
== action_activate
) {
725 if ((n
= parse_find_node("here", node
->xmlChildrenNode
)))
726 act
->data
.activate
.here
= parse_bool(doc
, n
);
734 void action_execute(union ActionData
*data
)
738 if (data
->execute
.path
) {
739 cmd
= g_filename_from_utf8(data
->execute
.path
, -1, NULL
, NULL
, NULL
);
741 if (!g_spawn_command_line_async(cmd
, &e
)) {
742 g_warning("failed to execute '%s': %s",
746 g_warning("failed to convert '%s' from utf8", data
->execute
.path
);
751 void action_activate(union ActionData
*data
)
753 if (data
->activate
.c
)
754 client_activate(data
->activate
.c
, data
->activate
.here
);
757 void action_focus(union ActionData
*data
)
760 client_focus(data
->client
.c
);
763 void action_unfocus (union ActionData
*data
)
766 client_unfocus(data
->client
.c
);
769 void action_iconify(union ActionData
*data
)
772 client_iconify(data
->client
.c
, TRUE
, TRUE
);
775 void action_raiselower(union ActionData
*data
)
777 if (data
->client
.c
) {
778 if (data
->client
.c
->frame
->obscured
)
779 stacking_raise(CLIENT_AS_WINDOW(data
->client
.c
));
781 stacking_lower(CLIENT_AS_WINDOW(data
->client
.c
));
785 void action_raise(union ActionData
*data
)
788 stacking_raise(CLIENT_AS_WINDOW(data
->client
.c
));
791 void action_unshaderaise(union ActionData
*data
)
793 if (data
->client
.c
) {
794 if (data
->client
.c
->shaded
)
795 client_shade(data
->client
.c
, FALSE
);
797 stacking_raise(CLIENT_AS_WINDOW(data
->client
.c
));
801 void action_shadelower(union ActionData
*data
)
803 if (data
->client
.c
) {
804 if (data
->client
.c
->shaded
)
805 stacking_lower(CLIENT_AS_WINDOW(data
->client
.c
));
807 client_shade(data
->client
.c
, TRUE
);
811 void action_lower(union ActionData
*data
)
814 stacking_lower(CLIENT_AS_WINDOW(data
->client
.c
));
817 void action_close(union ActionData
*data
)
820 client_close(data
->client
.c
);
823 void action_kill(union ActionData
*data
)
826 client_kill(data
->client
.c
);
829 void action_shade(union ActionData
*data
)
832 client_shade(data
->client
.c
, TRUE
);
835 void action_unshade(union ActionData
*data
)
838 client_shade(data
->client
.c
, FALSE
);
841 void action_toggle_shade(union ActionData
*data
)
844 client_shade(data
->client
.c
, !data
->client
.c
->shaded
);
847 void action_toggle_omnipresent(union ActionData
*data
)
850 client_set_desktop(data
->client
.c
,
851 data
->client
.c
->desktop
== DESKTOP_ALL
?
852 screen_desktop
: DESKTOP_ALL
, FALSE
);
855 void action_move_relative_horz(union ActionData
*data
)
857 ObClient
*c
= data
->relative
.c
;
859 client_configure(c
, OB_CORNER_TOPLEFT
,
860 c
->area
.x
+ data
->relative
.delta
, c
->area
.y
,
861 c
->area
.width
, c
->area
.height
, TRUE
, TRUE
);
864 void action_move_relative_vert(union ActionData
*data
)
866 ObClient
*c
= data
->relative
.c
;
868 client_configure(c
, OB_CORNER_TOPLEFT
,
869 c
->area
.x
, c
->area
.y
+ data
->relative
.delta
,
870 c
->area
.width
, c
->area
.height
, TRUE
, TRUE
);
873 void action_resize_relative_horz(union ActionData
*data
)
875 ObClient
*c
= data
->relative
.c
;
877 client_configure(c
, OB_CORNER_TOPLEFT
, c
->area
.x
, c
->area
.y
,
879 data
->relative
.delta
* c
->size_inc
.width
,
880 c
->area
.height
, TRUE
, TRUE
);
883 void action_resize_relative_vert(union ActionData
*data
)
885 ObClient
*c
= data
->relative
.c
;
887 client_configure(c
, OB_CORNER_TOPLEFT
, c
->area
.x
, c
->area
.y
,
888 c
->area
.width
, c
->area
.height
+
889 data
->relative
.delta
* c
->size_inc
.height
,
893 void action_maximize_full(union ActionData
*data
)
896 client_maximize(data
->client
.c
, TRUE
, 0, TRUE
);
899 void action_unmaximize_full(union ActionData
*data
)
902 client_maximize(data
->client
.c
, FALSE
, 0, TRUE
);
905 void action_toggle_maximize_full(union ActionData
*data
)
908 client_maximize(data
->client
.c
,
909 !(data
->client
.c
->max_horz
||
910 data
->client
.c
->max_vert
),
914 void action_maximize_horz(union ActionData
*data
)
917 client_maximize(data
->client
.c
, TRUE
, 1, TRUE
);
920 void action_unmaximize_horz(union ActionData
*data
)
923 client_maximize(data
->client
.c
, FALSE
, 1, TRUE
);
926 void action_toggle_maximize_horz(union ActionData
*data
)
929 client_maximize(data
->client
.c
, !data
->client
.c
->max_horz
, 1, TRUE
);
932 void action_maximize_vert(union ActionData
*data
)
935 client_maximize(data
->client
.c
, TRUE
, 2, TRUE
);
938 void action_unmaximize_vert(union ActionData
*data
)
941 client_maximize(data
->client
.c
, FALSE
, 2, TRUE
);
944 void action_toggle_maximize_vert(union ActionData
*data
)
947 client_maximize(data
->client
.c
, !data
->client
.c
->max_vert
, 2, TRUE
);
950 void action_send_to_desktop(union ActionData
*data
)
952 ObClient
*c
= data
->sendto
.c
;
954 if (!c
|| !client_normal(c
)) return;
956 if (data
->sendto
.desk
< screen_num_desktops
||
957 data
->sendto
.desk
== DESKTOP_ALL
) {
958 client_set_desktop(c
, data
->sendto
.desk
, TRUE
);
959 screen_set_desktop(data
->sendto
.desk
);
963 void action_desktop(union ActionData
*data
)
965 if (data
->desktop
.desk
< screen_num_desktops
||
966 data
->desktop
.desk
== DESKTOP_ALL
)
967 screen_set_desktop(data
->desktop
.desk
);
970 void action_desktop_dir(union ActionData
*data
)
974 d
= screen_cycle_desktop(data
->desktopdir
.dir
, data
->desktopdir
.wrap
,
975 data
->sendtodir
.linear
,
976 data
->desktopdir
.final
, data
->desktopdir
.cancel
);
977 screen_set_desktop(d
);
980 void action_send_to_desktop_dir(union ActionData
*data
)
982 ObClient
*c
= data
->sendtodir
.c
;
985 if (!c
|| !client_normal(c
)) return;
987 d
= screen_cycle_desktop(data
->sendtodir
.dir
, data
->sendtodir
.wrap
,
988 data
->sendtodir
.linear
,
989 data
->sendtodir
.final
, data
->sendtodir
.cancel
);
990 client_set_desktop(c
, d
, TRUE
);
991 screen_set_desktop(d
);
995 void action_desktop_right(union ActionData
*data
)
1001 if (c
>= screen_desktop_layout
.columns
) {
1002 if (!data
->desktopdir
.wrap
) return;
1005 d
= translate_row_col(r
, c
);
1006 if (d
>= screen_num_desktops
) {
1007 if (!data
->desktopdir
.wrap
) return;
1010 d
= translate_row_col(r
, c
);
1011 if (d
< screen_num_desktops
)
1012 screen_cycle_desktop(d
, data
->desktopdir
.final
,
1013 data
->desktopdir
.cancel
);
1016 void action_send_to_desktop_right(union ActionData
*data
)
1018 ObClient
*cl
= data
->sendto
.c
;
1021 if (!cl
|| !client_normal(cl
)) return;
1023 cur_row_col(&r
, &c
);
1025 if (c
>= screen_desktop_layout
.columns
) {
1026 if (!data
->sendtodir
.wrap
) return;
1029 d
= translate_row_col(r
, c
);
1030 if (d
>= screen_num_desktops
) {
1031 if (!data
->sendtodir
.wrap
) return;
1034 d
= translate_row_col(r
, c
);
1035 if (d
< screen_num_desktops
) {
1036 client_set_desktop(cl
, d
, data
->sendtodir
.follow
);
1037 if (data
->sendtodir
.follow
)
1038 screen_cycle_desktop(d
, data
->desktopdir
.final
,
1039 data
->desktopdir
.cancel
);
1043 void action_desktop_left(union ActionData
*data
)
1047 cur_row_col(&r
, &c
);
1049 if (c
>= screen_desktop_layout
.columns
) {
1050 if (!data
->desktopdir
.wrap
) return;
1051 c
= screen_desktop_layout
.columns
- 1;
1053 d
= translate_row_col(r
, c
);
1054 if (d
>= screen_num_desktops
) {
1055 if (!data
->desktopdir
.wrap
) return;
1058 d
= translate_row_col(r
, c
);
1059 if (d
< screen_num_desktops
)
1060 screen_cycle_desktop(d
, data
->desktopdir
.final
,
1061 data
->desktopdir
.cancel
);
1064 void action_send_to_desktop_left(union ActionData
*data
)
1066 ObClient
*cl
= data
->sendto
.c
;
1069 if (!cl
|| !client_normal(cl
)) return;
1071 cur_row_col(&r
, &c
);
1073 if (c
>= screen_desktop_layout
.columns
) {
1074 if (!data
->sendtodir
.wrap
) return;
1075 c
= screen_desktop_layout
.columns
- 1;
1077 d
= translate_row_col(r
, c
);
1078 if (d
>= screen_num_desktops
) {
1079 if (!data
->sendtodir
.wrap
) return;
1082 d
= translate_row_col(r
, c
);
1083 if (d
< screen_num_desktops
) {
1084 client_set_desktop(cl
, d
, data
->sendtodir
.follow
);
1085 if (data
->sendtodir
.follow
)
1086 screen_cycle_desktop(d
, data
->desktopdir
.final
,
1087 data
->desktopdir
.cancel
);
1091 void action_desktop_down(union ActionData
*data
)
1095 cur_row_col(&r
, &c
);
1097 if (r
>= screen_desktop_layout
.rows
) {
1098 if (!data
->desktopdir
.wrap
) return;
1101 d
= translate_row_col(r
, c
);
1102 if (d
>= screen_num_desktops
) {
1103 if (!data
->desktopdir
.wrap
) return;
1106 d
= translate_row_col(r
, c
);
1107 if (d
< screen_num_desktops
)
1108 screen_cycle_desktop(d
, data
->desktopdir
.final
,
1109 data
->desktopdir
.cancel
);
1112 void action_send_to_desktop_down(union ActionData
*data
)
1116 if (data
->sendtodir
.c
) {
1117 cur_row_col(&r
, &c
);
1119 if (r
>= screen_desktop_layout
.rows
) {
1120 if (!data
->sendtodir
.wrap
) return;
1123 d
= translate_row_col(r
, c
);
1124 if (d
>= screen_num_desktops
) {
1125 if (!data
->sendtodir
.wrap
) return;
1128 d
= translate_row_col(r
, c
);
1129 if (d
< screen_num_desktops
) {
1130 client_set_desktop(data
->sendtodir
.c
, d
, data
->sendtodir
.follow
);
1131 if (data
->sendtodir
.follow
)
1132 screen_cycle_desktop(d
, data
->desktopdir
.final
,
1133 data
->desktopdir
.cancel
);
1138 void action_desktop_up(union ActionData
*data
)
1142 cur_row_col(&r
, &c
);
1144 if (r
>= screen_desktop_layout
.rows
) {
1145 if (!data
->desktopdir
.wrap
) return;
1146 r
= screen_desktop_layout
.rows
- 1;
1148 d
= translate_row_col(r
, c
);
1149 if (d
>= screen_num_desktops
) {
1150 if (!data
->desktopdir
.wrap
) return;
1153 d
= translate_row_col(r
, c
);
1154 if (d
< screen_num_desktops
)
1155 screen_cycle_desktop(d
, data
->desktopdir
.final
,
1156 data
->desktopdir
.cancel
);
1159 void action_send_to_desktop_up(union ActionData
*data
)
1163 if (data
->sendtodir
.c
) {
1164 cur_row_col(&r
, &c
);
1166 if (r
>= screen_desktop_layout
.rows
) {
1167 if (!data
->sendtodir
.wrap
) return;
1168 r
= screen_desktop_layout
.rows
- 1;
1170 d
= translate_row_col(r
, c
);
1171 if (d
>= screen_num_desktops
) {
1172 if (!data
->sendtodir
.wrap
) return;
1175 d
= translate_row_col(r
, c
);
1176 if (d
< screen_num_desktops
) {
1177 client_set_desktop(data
->sendtodir
.c
, d
, data
->sendtodir
.follow
);
1178 if (data
->sendtodir
.follow
)
1179 screen_cycle_desktop(d
, data
->desktopdir
.final
,
1180 data
->desktopdir
.cancel
);
1186 void action_toggle_decorations(union ActionData
*data
)
1188 ObClient
*c
= data
->client
.c
;;
1192 c
->decorate
= !c
->decorate
;
1193 client_setup_decor_and_functions(c
);
1196 void action_moveresize(union ActionData
*data
)
1198 ObClient
*c
= data
->moveresize
.c
;
1200 if (!c
|| !client_normal(c
)) return;
1202 moveresize_start(c
, data
->moveresize
.x
, data
->moveresize
.y
,
1203 data
->moveresize
.button
, data
->moveresize
.corner
);
1206 void action_restart(union ActionData
*data
)
1208 ob_restart_other(data
->execute
.path
);
1211 void action_exit(union ActionData
*data
)
1216 void action_showmenu(union ActionData
*data
)
1218 if (data
->showmenu
.name
) {
1219 menu_show(data
->showmenu
.name
, data
->showmenu
.x
, data
->showmenu
.y
,
1224 void action_cycle_windows(union ActionData
*data
)
1228 c
= focus_cycle(data
->cycle
.forward
, data
->cycle
.linear
, data
->cycle
.final
,
1229 data
->cycle
.cancel
);
1232 void action_directional_focus(union ActionData
*data
)
1236 if (!data
->diraction
.c
)
1238 if ((nf
= client_find_directional(data
->diraction
.c
,
1239 data
->diraction
.direction
)))
1240 client_activate(nf
, FALSE
);
1243 void action_movetoedge(union ActionData
*data
)
1246 ObClient
*c
= data
->diraction
.c
;
1250 x
= c
->frame
->area
.x
;
1251 y
= c
->frame
->area
.y
;
1253 switch(data
->diraction
.direction
) {
1254 case OB_DIRECTION_NORTH
:
1255 y
= client_directional_edge_search(c
, OB_DIRECTION_NORTH
);
1257 case OB_DIRECTION_WEST
:
1258 x
= client_directional_edge_search(c
, OB_DIRECTION_WEST
);
1260 case OB_DIRECTION_SOUTH
:
1261 y
= client_directional_edge_search(c
, OB_DIRECTION_SOUTH
) -
1262 c
->frame
->area
.height
;
1264 case OB_DIRECTION_EAST
:
1265 x
= client_directional_edge_search(c
, OB_DIRECTION_EAST
) -
1266 c
->frame
->area
.width
;
1269 g_assert_not_reached();
1271 frame_frame_gravity(c
->frame
, &x
, &y
);
1272 client_configure(c
, OB_CORNER_TOPLEFT
,
1273 x
, y
, c
->area
.width
, c
->area
.height
, TRUE
, TRUE
);
1277 void action_growtoedge(union ActionData
*data
)
1279 int x
, y
, width
, height
, dest
;
1280 ObClient
*c
= data
->diraction
.c
;
1281 Rect
*a
= screen_area(c
->desktop
);
1286 x
= c
->frame
->area
.x
;
1287 y
= c
->frame
->area
.y
;
1288 width
= c
->frame
->area
.width
;
1289 height
= c
->frame
->area
.height
;
1291 switch(data
->diraction
.direction
) {
1292 case OB_DIRECTION_NORTH
:
1293 dest
= client_directional_edge_search(c
, OB_DIRECTION_NORTH
);
1295 height
= c
->frame
->area
.height
/ 2;
1297 height
= c
->frame
->area
.y
+ c
->frame
->area
.height
- dest
;
1301 case OB_DIRECTION_WEST
:
1302 dest
= client_directional_edge_search(c
, OB_DIRECTION_WEST
);
1304 width
= c
->frame
->area
.width
/ 2;
1306 width
= c
->frame
->area
.x
+ c
->frame
->area
.width
- dest
;
1310 case OB_DIRECTION_SOUTH
:
1311 dest
= client_directional_edge_search(c
, OB_DIRECTION_SOUTH
);
1312 if (a
->y
+ a
->height
== y
+ c
->frame
->area
.height
) {
1313 height
= c
->frame
->area
.height
/ 2;
1314 y
= a
->y
+ a
->height
- height
;
1316 height
= dest
- c
->frame
->area
.y
;
1317 y
+= (height
- c
->frame
->area
.height
) % c
->size_inc
.height
;
1318 height
-= (height
- c
->frame
->area
.height
) % c
->size_inc
.height
;
1320 case OB_DIRECTION_EAST
:
1321 dest
= client_directional_edge_search(c
, OB_DIRECTION_EAST
);
1322 if (a
->x
+ a
->width
== x
+ c
->frame
->area
.width
) {
1323 width
= c
->frame
->area
.width
/ 2;
1324 x
= a
->x
+ a
->width
- width
;
1326 width
= dest
- c
->frame
->area
.x
;
1327 x
+= (width
- c
->frame
->area
.width
) % c
->size_inc
.width
;
1328 width
-= (width
- c
->frame
->area
.width
) % c
->size_inc
.width
;
1331 g_assert_not_reached();
1333 frame_frame_gravity(c
->frame
, &x
, &y
);
1334 width
-= c
->frame
->size
.left
+ c
->frame
->size
.right
;
1335 height
-= c
->frame
->size
.top
+ c
->frame
->size
.bottom
;
1336 client_configure(c
, OB_CORNER_TOPLEFT
, x
, y
, width
, height
, TRUE
, TRUE
);
1339 void action_send_to_layer(union ActionData
*data
)
1342 client_set_layer(data
->layer
.c
, data
->layer
.layer
);
1345 void action_toggle_layer(union ActionData
*data
)
1347 ObClient
*c
= data
->layer
.c
;
1350 if (data
->layer
.layer
< 0)
1351 client_set_layer(c
, c
->below
? 0 : -1);
1352 else if (data
->layer
.layer
> 0)
1353 client_set_layer(c
, c
->above
? 0 : 1);
1357 void action_toggle_show_desktop(union ActionData
*data
)
1359 screen_show_desktop(!screen_showing_desktop
);
1362 void action_show_desktop(union ActionData
*data
)
1364 screen_show_desktop(TRUE
);
1367 void action_unshow_desktop(union ActionData
*data
)
1369 screen_show_desktop(FALSE
);