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 ObClient *c = data->client.c;
779 gboolean raise = FALSE;
783 for (it = stacking_list; it; it = g_list_next(it)) {
784 ObClient *cit = it->data;
787 if (client_normal(cit) && cit->layer == c->layer) {
788 if (RECT_INTERSECTS_RECT(cit->frame->area, c->frame->area)) {
796 stacking_raise(CLIENT_AS_WINDOW(c));
798 stacking_lower(CLIENT_AS_WINDOW(c));
801 void action_raise(union ActionData *data)
804 stacking_raise(CLIENT_AS_WINDOW(data->client.c));
807 void action_unshaderaise(union ActionData *data)
809 if (data->client.c) {
810 if (data->client.c->shaded)
811 client_shade(data->client.c, FALSE);
813 stacking_raise(CLIENT_AS_WINDOW(data->client.c));
817 void action_shadelower(union ActionData *data)
819 if (data->client.c) {
820 if (data->client.c->shaded)
821 stacking_lower(CLIENT_AS_WINDOW(data->client.c));
823 client_shade(data->client.c, TRUE);
827 void action_lower(union ActionData *data)
830 stacking_lower(CLIENT_AS_WINDOW(data->client.c));
833 void action_close(union ActionData *data)
836 client_close(data->client.c);
839 void action_kill(union ActionData *data)
842 client_kill(data->client.c);
845 void action_shade(union ActionData *data)
848 client_shade(data->client.c, TRUE);
851 void action_unshade(union ActionData *data)
854 client_shade(data->client.c, FALSE);
857 void action_toggle_shade(union ActionData *data)
860 client_shade(data->client.c, !data->client.c->shaded);
863 void action_toggle_omnipresent(union ActionData *data)
866 client_set_desktop(data->client.c,
867 data->client.c->desktop == DESKTOP_ALL ?
868 screen_desktop : DESKTOP_ALL, FALSE);
871 void action_move_relative_horz(union ActionData *data)
873 ObClient *c = data->relative.c;
875 client_configure(c, OB_CORNER_TOPLEFT,
876 c->area.x + data->relative.delta, c->area.y,
877 c->area.width, c->area.height, TRUE, TRUE);
880 void action_move_relative_vert(union ActionData *data)
882 ObClient *c = data->relative.c;
884 client_configure(c, OB_CORNER_TOPLEFT,
885 c->area.x, c->area.y + data->relative.delta,
886 c->area.width, c->area.height, TRUE, TRUE);
889 void action_resize_relative_horz(union ActionData *data)
891 ObClient *c = data->relative.c;
893 client_configure(c, OB_CORNER_TOPLEFT, c->area.x, c->area.y,
895 data->relative.delta * c->size_inc.width,
896 c->area.height, TRUE, TRUE);
899 void action_resize_relative_vert(union ActionData *data)
901 ObClient *c = data->relative.c;
903 client_configure(c, OB_CORNER_TOPLEFT, c->area.x, c->area.y,
904 c->area.width, c->area.height +
905 data->relative.delta * c->size_inc.height,
909 void action_maximize_full(union ActionData *data)
912 client_maximize(data->client.c, TRUE, 0, TRUE);
915 void action_unmaximize_full(union ActionData *data)
918 client_maximize(data->client.c, FALSE, 0, TRUE);
921 void action_toggle_maximize_full(union ActionData *data)
924 client_maximize(data->client.c,
925 !(data->client.c->max_horz ||
926 data->client.c->max_vert),
930 void action_maximize_horz(union ActionData *data)
933 client_maximize(data->client.c, TRUE, 1, TRUE);
936 void action_unmaximize_horz(union ActionData *data)
939 client_maximize(data->client.c, FALSE, 1, TRUE);
942 void action_toggle_maximize_horz(union ActionData *data)
945 client_maximize(data->client.c, !data->client.c->max_horz, 1, TRUE);
948 void action_maximize_vert(union ActionData *data)
951 client_maximize(data->client.c, TRUE, 2, TRUE);
954 void action_unmaximize_vert(union ActionData *data)
957 client_maximize(data->client.c, FALSE, 2, TRUE);
960 void action_toggle_maximize_vert(union ActionData *data)
963 client_maximize(data->client.c, !data->client.c->max_vert, 2, TRUE);
966 void action_send_to_desktop(union ActionData *data)
968 ObClient *c = data->sendto.c;
970 if (!c || !client_normal(c)) return;
972 if (data->sendto.desk < screen_num_desktops ||
973 data->sendto.desk == DESKTOP_ALL) {
974 client_set_desktop(c, data->sendto.desk, TRUE);
975 screen_set_desktop(data->sendto.desk);
979 void action_desktop(union ActionData *data)
981 if (data->desktop.desk < screen_num_desktops ||
982 data->desktop.desk == DESKTOP_ALL)
983 screen_set_desktop(data->desktop.desk);
986 void action_desktop_dir(union ActionData *data)
990 d = screen_cycle_desktop(data->desktopdir.dir, data->desktopdir.wrap,
991 data->sendtodir.linear,
992 data->desktopdir.final, data->desktopdir.cancel);
993 screen_set_desktop(d);
996 void action_send_to_desktop_dir(union ActionData *data)
998 ObClient *c = data->sendtodir.c;
1001 if (!c || !client_normal(c)) return;
1003 d = screen_cycle_desktop(data->sendtodir.dir, data->sendtodir.wrap,
1004 data->sendtodir.linear,
1005 data->sendtodir.final, data->sendtodir.cancel);
1006 client_set_desktop(c, d, TRUE);
1007 screen_set_desktop(d);
1011 void action_desktop_right(union ActionData *data)
1015 cur_row_col(&r, &c);
1017 if (c >= screen_desktop_layout.columns) {
1018 if (!data->desktopdir.wrap) return;
1021 d = translate_row_col(r, c);
1022 if (d >= screen_num_desktops) {
1023 if (!data->desktopdir.wrap) return;
1026 d = translate_row_col(r, c);
1027 if (d < screen_num_desktops)
1028 screen_cycle_desktop(d, data->desktopdir.final,
1029 data->desktopdir.cancel);
1032 void action_send_to_desktop_right(union ActionData *data)
1034 ObClient *cl = data->sendto.c;
1037 if (!cl || !client_normal(cl)) return;
1039 cur_row_col(&r, &c);
1041 if (c >= screen_desktop_layout.columns) {
1042 if (!data->sendtodir.wrap) return;
1045 d = translate_row_col(r, c);
1046 if (d >= screen_num_desktops) {
1047 if (!data->sendtodir.wrap) return;
1050 d = translate_row_col(r, c);
1051 if (d < screen_num_desktops) {
1052 client_set_desktop(cl, d, data->sendtodir.follow);
1053 if (data->sendtodir.follow)
1054 screen_cycle_desktop(d, data->desktopdir.final,
1055 data->desktopdir.cancel);
1059 void action_desktop_left(union ActionData *data)
1063 cur_row_col(&r, &c);
1065 if (c >= screen_desktop_layout.columns) {
1066 if (!data->desktopdir.wrap) return;
1067 c = screen_desktop_layout.columns - 1;
1069 d = translate_row_col(r, c);
1070 if (d >= screen_num_desktops) {
1071 if (!data->desktopdir.wrap) return;
1074 d = translate_row_col(r, c);
1075 if (d < screen_num_desktops)
1076 screen_cycle_desktop(d, data->desktopdir.final,
1077 data->desktopdir.cancel);
1080 void action_send_to_desktop_left(union ActionData *data)
1082 ObClient *cl = data->sendto.c;
1085 if (!cl || !client_normal(cl)) return;
1087 cur_row_col(&r, &c);
1089 if (c >= screen_desktop_layout.columns) {
1090 if (!data->sendtodir.wrap) return;
1091 c = screen_desktop_layout.columns - 1;
1093 d = translate_row_col(r, c);
1094 if (d >= screen_num_desktops) {
1095 if (!data->sendtodir.wrap) return;
1098 d = translate_row_col(r, c);
1099 if (d < screen_num_desktops) {
1100 client_set_desktop(cl, d, data->sendtodir.follow);
1101 if (data->sendtodir.follow)
1102 screen_cycle_desktop(d, data->desktopdir.final,
1103 data->desktopdir.cancel);
1107 void action_desktop_down(union ActionData *data)
1111 cur_row_col(&r, &c);
1113 if (r >= screen_desktop_layout.rows) {
1114 if (!data->desktopdir.wrap) return;
1117 d = translate_row_col(r, c);
1118 if (d >= screen_num_desktops) {
1119 if (!data->desktopdir.wrap) return;
1122 d = translate_row_col(r, c);
1123 if (d < screen_num_desktops)
1124 screen_cycle_desktop(d, data->desktopdir.final,
1125 data->desktopdir.cancel);
1128 void action_send_to_desktop_down(union ActionData *data)
1132 if (data->sendtodir.c) {
1133 cur_row_col(&r, &c);
1135 if (r >= screen_desktop_layout.rows) {
1136 if (!data->sendtodir.wrap) return;
1139 d = translate_row_col(r, c);
1140 if (d >= screen_num_desktops) {
1141 if (!data->sendtodir.wrap) return;
1144 d = translate_row_col(r, c);
1145 if (d < screen_num_desktops) {
1146 client_set_desktop(data->sendtodir.c, d, data->sendtodir.follow);
1147 if (data->sendtodir.follow)
1148 screen_cycle_desktop(d, data->desktopdir.final,
1149 data->desktopdir.cancel);
1154 void action_desktop_up(union ActionData *data)
1158 cur_row_col(&r, &c);
1160 if (r >= screen_desktop_layout.rows) {
1161 if (!data->desktopdir.wrap) return;
1162 r = screen_desktop_layout.rows - 1;
1164 d = translate_row_col(r, c);
1165 if (d >= screen_num_desktops) {
1166 if (!data->desktopdir.wrap) return;
1169 d = translate_row_col(r, c);
1170 if (d < screen_num_desktops)
1171 screen_cycle_desktop(d, data->desktopdir.final,
1172 data->desktopdir.cancel);
1175 void action_send_to_desktop_up(union ActionData *data)
1179 if (data->sendtodir.c) {
1180 cur_row_col(&r, &c);
1182 if (r >= screen_desktop_layout.rows) {
1183 if (!data->sendtodir.wrap) return;
1184 r = screen_desktop_layout.rows - 1;
1186 d = translate_row_col(r, c);
1187 if (d >= screen_num_desktops) {
1188 if (!data->sendtodir.wrap) return;
1191 d = translate_row_col(r, c);
1192 if (d < screen_num_desktops) {
1193 client_set_desktop(data->sendtodir.c, d, data->sendtodir.follow);
1194 if (data->sendtodir.follow)
1195 screen_cycle_desktop(d, data->desktopdir.final,
1196 data->desktopdir.cancel);
1202 void action_toggle_decorations(union ActionData *data)
1204 ObClient *c = data->client.c;;
1208 c->decorate = !c->decorate;
1209 client_setup_decor_and_functions(c);
1212 void action_moveresize(union ActionData *data)
1214 ObClient *c = data->moveresize.c;
1216 if (!c || !client_normal(c)) return;
1218 moveresize_start(c, data->moveresize.x, data->moveresize.y,
1219 data->moveresize.button, data->moveresize.corner);
1222 void action_restart(union ActionData *data)
1224 ob_restart_other(data->execute.path);
1227 void action_exit(union ActionData *data)
1232 void action_showmenu(union ActionData *data)
1234 if (data->showmenu.name) {
1235 menu_show(data->showmenu.name, data->showmenu.x, data->showmenu.y,
1240 void action_cycle_windows(union ActionData *data)
1244 c = focus_cycle(data->cycle.forward, data->cycle.linear, data->cycle.final,
1245 data->cycle.cancel);
1248 void action_directional_focus(union ActionData *data)
1252 if (!data->diraction.c)
1254 if ((nf = client_find_directional(data->diraction.c,
1255 data->diraction.direction)))
1256 client_activate(nf, FALSE);
1259 void action_movetoedge(union ActionData *data)
1262 ObClient *c = data->diraction.c;
1266 x = c->frame->area.x;
1267 y = c->frame->area.y;
1269 switch(data->diraction.direction) {
1270 case OB_DIRECTION_NORTH:
1271 y = client_directional_edge_search(c, OB_DIRECTION_NORTH);
1273 case OB_DIRECTION_WEST:
1274 x = client_directional_edge_search(c, OB_DIRECTION_WEST);
1276 case OB_DIRECTION_SOUTH:
1277 y = client_directional_edge_search(c, OB_DIRECTION_SOUTH) -
1278 c->frame->area.height;
1280 case OB_DIRECTION_EAST:
1281 x = client_directional_edge_search(c, OB_DIRECTION_EAST) -
1282 c->frame->area.width;
1285 g_assert_not_reached();
1287 frame_frame_gravity(c->frame, &x, &y);
1288 client_configure(c, OB_CORNER_TOPLEFT,
1289 x, y, c->area.width, c->area.height, TRUE, TRUE);
1293 void action_growtoedge(union ActionData *data)
1295 int x, y, width, height, dest;
1296 ObClient *c = data->diraction.c;
1297 Rect *a = screen_area(c->desktop);
1302 x = c->frame->area.x;
1303 y = c->frame->area.y;
1304 width = c->frame->area.width;
1305 height = c->frame->area.height;
1307 switch(data->diraction.direction) {
1308 case OB_DIRECTION_NORTH:
1309 dest = client_directional_edge_search(c, OB_DIRECTION_NORTH);
1311 height = c->frame->area.height / 2;
1313 height = c->frame->area.y + c->frame->area.height - dest;
1317 case OB_DIRECTION_WEST:
1318 dest = client_directional_edge_search(c, OB_DIRECTION_WEST);
1320 width = c->frame->area.width / 2;
1322 width = c->frame->area.x + c->frame->area.width - dest;
1326 case OB_DIRECTION_SOUTH:
1327 dest = client_directional_edge_search(c, OB_DIRECTION_SOUTH);
1328 if (a->y + a->height == y + c->frame->area.height) {
1329 height = c->frame->area.height / 2;
1330 y = a->y + a->height - height;
1332 height = dest - c->frame->area.y;
1333 y += (height - c->frame->area.height) % c->size_inc.height;
1334 height -= (height - c->frame->area.height) % c->size_inc.height;
1336 case OB_DIRECTION_EAST:
1337 dest = client_directional_edge_search(c, OB_DIRECTION_EAST);
1338 if (a->x + a->width == x + c->frame->area.width) {
1339 width = c->frame->area.width / 2;
1340 x = a->x + a->width - width;
1342 width = dest - c->frame->area.x;
1343 x += (width - c->frame->area.width) % c->size_inc.width;
1344 width -= (width - c->frame->area.width) % c->size_inc.width;
1347 g_assert_not_reached();
1349 frame_frame_gravity(c->frame, &x, &y);
1350 width -= c->frame->size.left + c->frame->size.right;
1351 height -= c->frame->size.top + c->frame->size.bottom;
1352 client_configure(c, OB_CORNER_TOPLEFT, x, y, width, height, TRUE, TRUE);
1355 void action_send_to_layer(union ActionData *data)
1358 client_set_layer(data->layer.c, data->layer.layer);
1361 void action_toggle_layer(union ActionData *data)
1363 ObClient *c = data->layer.c;
1366 if (data->layer.layer < 0)
1367 client_set_layer(c, c->below ? 0 : -1);
1368 else if (data->layer.layer > 0)
1369 client_set_layer(c, c->above ? 0 : 1);
1373 void action_toggle_show_desktop(union ActionData *data)
1375 screen_show_desktop(!screen_showing_desktop);
1378 void action_show_desktop(union ActionData *data)
1380 screen_show_desktop(TRUE);
1383 void action_unshow_desktop(union ActionData *data)
1385 screen_show_desktop(FALSE);