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(ObParseInst *i, 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))) {
711 act->data.showmenu.name = parse_string(doc, n);
712 if (parse_attr_string("plugin", n, &plugin))
713 menu_open_plugin(i, act->data.showmenu.name, plugin);
715 } else if (act->func == action_desktop) {
716 if ((n = parse_find_node("desktop", node->xmlChildrenNode)))
717 act->data.desktop.desk = parse_int(doc, n);
718 if (act->data.desktop.desk > 0) act->data.desktop.desk--;
719 } else if (act->func == action_send_to_desktop) {
720 if ((n = parse_find_node("desktop", node->xmlChildrenNode)))
721 act->data.sendto.desk = parse_int(doc, n);
722 if (act->data.sendto.desk > 0) act->data.sendto.desk--;
723 } else if (act->func == action_move_relative_horz ||
724 act->func == action_move_relative_vert ||
725 act->func == action_resize_relative_horz ||
726 act->func == action_resize_relative_vert) {
727 if ((n = parse_find_node("delta", node->xmlChildrenNode)))
728 act->data.relative.delta = parse_int(doc, n);
729 } else if (act->func == action_desktop_dir) {
730 if ((n = parse_find_node("wrap", node->xmlChildrenNode))) {
731 act->data.desktopdir.wrap = parse_bool(doc, n);
733 } else if (act->func == action_send_to_desktop) {
734 if ((n = parse_find_node("follow", node->xmlChildrenNode)))
735 act->data.sendto.follow = parse_bool(doc, n);
736 } else if (act->func == action_send_to_desktop_dir) {
737 if ((n = parse_find_node("wrap", node->xmlChildrenNode)))
738 act->data.sendtodir.wrap = parse_bool(doc, n);
739 if ((n = parse_find_node("follow", node->xmlChildrenNode)))
740 act->data.sendtodir.follow = parse_bool(doc, n);
741 } else if (act->func == action_activate) {
742 if ((n = parse_find_node("here", node->xmlChildrenNode)))
743 act->data.activate.here = parse_bool(doc, n);
751 void action_execute(union ActionData *data)
755 if (data->execute.path) {
756 cmd = g_filename_from_utf8(data->execute.path, -1, NULL, NULL, NULL);
758 if (!g_spawn_command_line_async(cmd, &e)) {
759 g_warning("failed to execute '%s': %s",
763 g_warning("failed to convert '%s' from utf8", data->execute.path);
768 void action_activate(union ActionData *data)
770 if (data->activate.c)
771 client_activate(data->activate.c, data->activate.here);
774 void action_focus(union ActionData *data)
777 client_focus(data->client.c);
780 void action_unfocus (union ActionData *data)
783 client_unfocus(data->client.c);
786 void action_iconify(union ActionData *data)
789 client_iconify(data->client.c, TRUE, TRUE);
792 void action_raiselower(union ActionData *data)
794 ObClient *c = data->client.c;
796 gboolean raise = FALSE;
800 for (it = stacking_list; it; it = g_list_next(it)) {
801 ObClient *cit = it->data;
804 if (client_normal(cit) == client_normal(c) &&
805 cit->layer == c->layer &&
808 if (RECT_INTERSECTS_RECT(cit->frame->area, c->frame->area)) {
816 stacking_raise(CLIENT_AS_WINDOW(c));
818 stacking_lower(CLIENT_AS_WINDOW(c));
821 void action_raise(union ActionData *data)
824 stacking_raise(CLIENT_AS_WINDOW(data->client.c));
827 void action_unshaderaise(union ActionData *data)
829 if (data->client.c) {
830 if (data->client.c->shaded)
831 client_shade(data->client.c, FALSE);
833 stacking_raise(CLIENT_AS_WINDOW(data->client.c));
837 void action_shadelower(union ActionData *data)
839 if (data->client.c) {
840 if (data->client.c->shaded)
841 stacking_lower(CLIENT_AS_WINDOW(data->client.c));
843 client_shade(data->client.c, TRUE);
847 void action_lower(union ActionData *data)
850 stacking_lower(CLIENT_AS_WINDOW(data->client.c));
853 void action_close(union ActionData *data)
856 client_close(data->client.c);
859 void action_kill(union ActionData *data)
862 client_kill(data->client.c);
865 void action_shade(union ActionData *data)
868 client_shade(data->client.c, TRUE);
871 void action_unshade(union ActionData *data)
874 client_shade(data->client.c, FALSE);
877 void action_toggle_shade(union ActionData *data)
880 client_shade(data->client.c, !data->client.c->shaded);
883 void action_toggle_omnipresent(union ActionData *data)
886 client_set_desktop(data->client.c,
887 data->client.c->desktop == DESKTOP_ALL ?
888 screen_desktop : DESKTOP_ALL, FALSE);
891 void action_move_relative_horz(union ActionData *data)
893 ObClient *c = data->relative.c;
895 client_configure(c, OB_CORNER_TOPLEFT,
896 c->area.x + data->relative.delta, c->area.y,
897 c->area.width, c->area.height, TRUE, TRUE);
900 void action_move_relative_vert(union ActionData *data)
902 ObClient *c = data->relative.c;
904 client_configure(c, OB_CORNER_TOPLEFT,
905 c->area.x, c->area.y + data->relative.delta,
906 c->area.width, c->area.height, TRUE, TRUE);
909 void action_resize_relative_horz(union ActionData *data)
911 ObClient *c = data->relative.c;
913 client_configure(c, OB_CORNER_TOPLEFT, c->area.x, c->area.y,
915 data->relative.delta * c->size_inc.width,
916 c->area.height, TRUE, TRUE);
919 void action_resize_relative_vert(union ActionData *data)
921 ObClient *c = data->relative.c;
923 client_configure(c, OB_CORNER_TOPLEFT, c->area.x, c->area.y,
924 c->area.width, c->area.height +
925 data->relative.delta * c->size_inc.height,
929 void action_maximize_full(union ActionData *data)
932 client_maximize(data->client.c, TRUE, 0, TRUE);
935 void action_unmaximize_full(union ActionData *data)
938 client_maximize(data->client.c, FALSE, 0, TRUE);
941 void action_toggle_maximize_full(union ActionData *data)
944 client_maximize(data->client.c,
945 !(data->client.c->max_horz ||
946 data->client.c->max_vert),
950 void action_maximize_horz(union ActionData *data)
953 client_maximize(data->client.c, TRUE, 1, TRUE);
956 void action_unmaximize_horz(union ActionData *data)
959 client_maximize(data->client.c, FALSE, 1, TRUE);
962 void action_toggle_maximize_horz(union ActionData *data)
965 client_maximize(data->client.c, !data->client.c->max_horz, 1, TRUE);
968 void action_maximize_vert(union ActionData *data)
971 client_maximize(data->client.c, TRUE, 2, TRUE);
974 void action_unmaximize_vert(union ActionData *data)
977 client_maximize(data->client.c, FALSE, 2, TRUE);
980 void action_toggle_maximize_vert(union ActionData *data)
983 client_maximize(data->client.c, !data->client.c->max_vert, 2, TRUE);
986 void action_send_to_desktop(union ActionData *data)
988 ObClient *c = data->sendto.c;
990 if (!c || !client_normal(c)) return;
992 if (data->sendto.desk < screen_num_desktops ||
993 data->sendto.desk == DESKTOP_ALL) {
994 client_set_desktop(c, data->sendto.desk, data->sendtodir.follow);
995 if (data->sendto.follow)
996 screen_set_desktop(data->sendto.desk);
1000 void action_desktop(union ActionData *data)
1002 if (data->desktop.desk < screen_num_desktops ||
1003 data->desktop.desk == DESKTOP_ALL)
1004 screen_set_desktop(data->desktop.desk);
1007 void action_desktop_dir(union ActionData *data)
1011 d = screen_cycle_desktop(data->desktopdir.dir, data->desktopdir.wrap,
1012 data->sendtodir.linear,
1013 data->desktopdir.final, data->desktopdir.cancel);
1014 screen_set_desktop(d);
1017 void action_send_to_desktop_dir(union ActionData *data)
1019 ObClient *c = data->sendtodir.c;
1022 if (!c || !client_normal(c)) return;
1024 d = screen_cycle_desktop(data->sendtodir.dir, data->sendtodir.wrap,
1025 data->sendtodir.linear,
1026 data->sendtodir.final, data->sendtodir.cancel);
1027 client_set_desktop(c, d, data->sendtodir.follow);
1028 if (data->sendtodir.follow)
1029 screen_set_desktop(d);
1033 void action_desktop_right(union ActionData *data)
1037 cur_row_col(&r, &c);
1039 if (c >= screen_desktop_layout.columns) {
1040 if (!data->desktopdir.wrap) return;
1043 d = translate_row_col(r, c);
1044 if (d >= screen_num_desktops) {
1045 if (!data->desktopdir.wrap) return;
1048 d = translate_row_col(r, c);
1049 if (d < screen_num_desktops)
1050 screen_cycle_desktop(d, data->desktopdir.final,
1051 data->desktopdir.cancel);
1054 void action_send_to_desktop_right(union ActionData *data)
1056 ObClient *cl = data->sendto.c;
1059 if (!cl || !client_normal(cl)) return;
1061 cur_row_col(&r, &c);
1063 if (c >= screen_desktop_layout.columns) {
1064 if (!data->sendtodir.wrap) return;
1067 d = translate_row_col(r, c);
1068 if (d >= screen_num_desktops) {
1069 if (!data->sendtodir.wrap) return;
1072 d = translate_row_col(r, c);
1073 if (d < screen_num_desktops) {
1074 client_set_desktop(cl, d, data->sendtodir.follow);
1075 if (data->sendtodir.follow)
1076 screen_cycle_desktop(d, data->desktopdir.final,
1077 data->desktopdir.cancel);
1081 void action_desktop_left(union ActionData *data)
1085 cur_row_col(&r, &c);
1087 if (c >= screen_desktop_layout.columns) {
1088 if (!data->desktopdir.wrap) return;
1089 c = screen_desktop_layout.columns - 1;
1091 d = translate_row_col(r, c);
1092 if (d >= screen_num_desktops) {
1093 if (!data->desktopdir.wrap) return;
1096 d = translate_row_col(r, c);
1097 if (d < screen_num_desktops)
1098 screen_cycle_desktop(d, data->desktopdir.final,
1099 data->desktopdir.cancel);
1102 void action_send_to_desktop_left(union ActionData *data)
1104 ObClient *cl = data->sendto.c;
1107 if (!cl || !client_normal(cl)) return;
1109 cur_row_col(&r, &c);
1111 if (c >= screen_desktop_layout.columns) {
1112 if (!data->sendtodir.wrap) return;
1113 c = screen_desktop_layout.columns - 1;
1115 d = translate_row_col(r, c);
1116 if (d >= screen_num_desktops) {
1117 if (!data->sendtodir.wrap) return;
1120 d = translate_row_col(r, c);
1121 if (d < screen_num_desktops) {
1122 client_set_desktop(cl, d, data->sendtodir.follow);
1123 if (data->sendtodir.follow)
1124 screen_cycle_desktop(d, data->desktopdir.final,
1125 data->desktopdir.cancel);
1129 void action_desktop_down(union ActionData *data)
1133 cur_row_col(&r, &c);
1135 if (r >= screen_desktop_layout.rows) {
1136 if (!data->desktopdir.wrap) return;
1139 d = translate_row_col(r, c);
1140 if (d >= screen_num_desktops) {
1141 if (!data->desktopdir.wrap) return;
1144 d = translate_row_col(r, c);
1145 if (d < screen_num_desktops)
1146 screen_cycle_desktop(d, data->desktopdir.final,
1147 data->desktopdir.cancel);
1150 void action_send_to_desktop_down(union ActionData *data)
1154 if (data->sendtodir.c) {
1155 cur_row_col(&r, &c);
1157 if (r >= screen_desktop_layout.rows) {
1158 if (!data->sendtodir.wrap) return;
1161 d = translate_row_col(r, c);
1162 if (d >= screen_num_desktops) {
1163 if (!data->sendtodir.wrap) return;
1166 d = translate_row_col(r, c);
1167 if (d < screen_num_desktops) {
1168 client_set_desktop(data->sendtodir.c, d, data->sendtodir.follow);
1169 if (data->sendtodir.follow)
1170 screen_cycle_desktop(d, data->desktopdir.final,
1171 data->desktopdir.cancel);
1176 void action_desktop_up(union ActionData *data)
1180 cur_row_col(&r, &c);
1182 if (r >= screen_desktop_layout.rows) {
1183 if (!data->desktopdir.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->desktopdir.wrap) return;
1191 d = translate_row_col(r, c);
1192 if (d < screen_num_desktops)
1193 screen_cycle_desktop(d, data->desktopdir.final,
1194 data->desktopdir.cancel);
1197 void action_send_to_desktop_up(union ActionData *data)
1201 if (data->sendtodir.c) {
1202 cur_row_col(&r, &c);
1204 if (r >= screen_desktop_layout.rows) {
1205 if (!data->sendtodir.wrap) return;
1206 r = screen_desktop_layout.rows - 1;
1208 d = translate_row_col(r, c);
1209 if (d >= screen_num_desktops) {
1210 if (!data->sendtodir.wrap) return;
1213 d = translate_row_col(r, c);
1214 if (d < screen_num_desktops) {
1215 client_set_desktop(data->sendtodir.c, d, data->sendtodir.follow);
1216 if (data->sendtodir.follow)
1217 screen_cycle_desktop(d, data->desktopdir.final,
1218 data->desktopdir.cancel);
1224 void action_toggle_decorations(union ActionData *data)
1226 ObClient *c = data->client.c;
1230 c->decorate = !c->decorate;
1231 client_setup_decor_and_functions(c);
1234 void action_moveresize(union ActionData *data)
1236 ObClient *c = data->moveresize.c;
1238 if (!c || !client_normal(c)) return;
1240 moveresize_start(c, data->moveresize.x, data->moveresize.y,
1241 data->moveresize.button, data->moveresize.corner);
1244 void action_restart(union ActionData *data)
1246 ob_restart_other(data->execute.path);
1249 void action_exit(union ActionData *data)
1254 void action_showmenu(union ActionData *data)
1256 if (data->showmenu.name) {
1257 menu_show(data->showmenu.name, data->showmenu.x, data->showmenu.y,
1262 void action_cycle_windows(union ActionData *data)
1266 c = focus_cycle(data->cycle.forward, data->cycle.linear, data->cycle.final,
1267 data->cycle.cancel);
1270 void action_directional_focus(union ActionData *data)
1274 if (!data->diraction.c)
1276 if ((nf = client_find_directional(data->diraction.c,
1277 data->diraction.direction)))
1278 client_activate(nf, FALSE);
1281 void action_movetoedge(union ActionData *data)
1284 ObClient *c = data->diraction.c;
1288 x = c->frame->area.x;
1289 y = c->frame->area.y;
1291 switch(data->diraction.direction) {
1292 case OB_DIRECTION_NORTH:
1293 y = client_directional_edge_search(c, OB_DIRECTION_NORTH);
1295 case OB_DIRECTION_WEST:
1296 x = client_directional_edge_search(c, OB_DIRECTION_WEST);
1298 case OB_DIRECTION_SOUTH:
1299 y = client_directional_edge_search(c, OB_DIRECTION_SOUTH) -
1300 c->frame->area.height;
1302 case OB_DIRECTION_EAST:
1303 x = client_directional_edge_search(c, OB_DIRECTION_EAST) -
1304 c->frame->area.width;
1307 g_assert_not_reached();
1309 frame_frame_gravity(c->frame, &x, &y);
1310 client_configure(c, OB_CORNER_TOPLEFT,
1311 x, y, c->area.width, c->area.height, TRUE, TRUE);
1315 void action_growtoedge(union ActionData *data)
1317 int x, y, width, height, dest;
1318 ObClient *c = data->diraction.c;
1319 Rect *a = screen_area(c->desktop);
1324 x = c->frame->area.x;
1325 y = c->frame->area.y;
1326 width = c->frame->area.width;
1327 height = c->frame->area.height;
1329 switch(data->diraction.direction) {
1330 case OB_DIRECTION_NORTH:
1331 dest = client_directional_edge_search(c, OB_DIRECTION_NORTH);
1333 height = c->frame->area.height / 2;
1335 height = c->frame->area.y + c->frame->area.height - dest;
1339 case OB_DIRECTION_WEST:
1340 dest = client_directional_edge_search(c, OB_DIRECTION_WEST);
1342 width = c->frame->area.width / 2;
1344 width = c->frame->area.x + c->frame->area.width - dest;
1348 case OB_DIRECTION_SOUTH:
1349 dest = client_directional_edge_search(c, OB_DIRECTION_SOUTH);
1350 if (a->y + a->height == y + c->frame->area.height) {
1351 height = c->frame->area.height / 2;
1352 y = a->y + a->height - height;
1354 height = dest - c->frame->area.y;
1355 y += (height - c->frame->area.height) % c->size_inc.height;
1356 height -= (height - c->frame->area.height) % c->size_inc.height;
1358 case OB_DIRECTION_EAST:
1359 dest = client_directional_edge_search(c, OB_DIRECTION_EAST);
1360 if (a->x + a->width == x + c->frame->area.width) {
1361 width = c->frame->area.width / 2;
1362 x = a->x + a->width - width;
1364 width = dest - c->frame->area.x;
1365 x += (width - c->frame->area.width) % c->size_inc.width;
1366 width -= (width - c->frame->area.width) % c->size_inc.width;
1369 g_assert_not_reached();
1371 frame_frame_gravity(c->frame, &x, &y);
1372 width -= c->frame->size.left + c->frame->size.right;
1373 height -= c->frame->size.top + c->frame->size.bottom;
1374 client_configure(c, OB_CORNER_TOPLEFT, x, y, width, height, TRUE, TRUE);
1377 void action_send_to_layer(union ActionData *data)
1380 client_set_layer(data->layer.c, data->layer.layer);
1383 void action_toggle_layer(union ActionData *data)
1385 ObClient *c = data->layer.c;
1388 if (data->layer.layer < 0)
1389 client_set_layer(c, c->below ? 0 : -1);
1390 else if (data->layer.layer > 0)
1391 client_set_layer(c, c->above ? 0 : 1);
1395 void action_toggle_show_desktop(union ActionData *data)
1397 screen_show_desktop(!screen_showing_desktop);
1400 void action_show_desktop(union ActionData *data)
1402 screen_show_desktop(TRUE);
1405 void action_unshow_desktop(union ActionData *data)
1407 screen_show_desktop(FALSE);