4 #include "moveresize.h"
15 typedef struct ActionString {
17 void (*func)(union ActionData *);
18 void (*setup)(ObAction *);
21 ObAction *action_new(void (*func)(union ActionData *data))
23 ObAction *a = g_new0(ObAction, 1);
29 void action_free(ObAction *a)
31 if (a == NULL) return;
33 /* deal with pointers */
34 if (a->func == action_execute || a->func == action_restart)
35 g_free(a->data.execute.path);
36 else if (a->func == action_showmenu)
37 g_free(a->data.showmenu.name);
42 void setup_action_directional_focus_north(ObAction *a)
44 a->data.diraction.direction = OB_DIRECTION_NORTH;
47 void setup_action_directional_focus_east(ObAction *a)
49 a->data.diraction.direction = OB_DIRECTION_EAST;
52 void setup_action_directional_focus_south(ObAction *a)
54 a->data.diraction.direction = OB_DIRECTION_SOUTH;
57 void setup_action_directional_focus_west(ObAction *a)
59 a->data.diraction.direction = OB_DIRECTION_WEST;
62 void setup_action_directional_focus_northeast(ObAction *a)
64 a->data.diraction.direction = OB_DIRECTION_NORTHEAST;
67 void setup_action_directional_focus_southeast(ObAction *a)
69 a->data.diraction.direction = OB_DIRECTION_SOUTHEAST;
72 void setup_action_directional_focus_southwest(ObAction *a)
74 a->data.diraction.direction = OB_DIRECTION_SOUTHWEST;
77 void setup_action_directional_focus_northwest(ObAction *a)
79 a->data.diraction.direction = OB_DIRECTION_NORTHWEST;
82 void setup_action_send_to_desktop(ObAction *a)
84 a->data.sendto.follow = TRUE;
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;
92 a->data.sendtodir.follow = TRUE;
95 void setup_action_send_to_desktop_next(ObAction *a)
97 a->data.sendtodir.dir = OB_DIRECTION_EAST;
98 a->data.sendtodir.linear = TRUE;
99 a->data.sendtodir.wrap = TRUE;
100 a->data.sendtodir.follow = TRUE;
103 void setup_action_send_to_desktop_left(ObAction *a)
105 a->data.sendtodir.dir = OB_DIRECTION_WEST;
106 a->data.sendtodir.linear = FALSE;
107 a->data.sendtodir.wrap = TRUE;
108 a->data.sendtodir.follow = TRUE;
111 void setup_action_send_to_desktop_right(ObAction *a)
113 a->data.sendtodir.dir = OB_DIRECTION_EAST;
114 a->data.sendtodir.linear = FALSE;
115 a->data.sendtodir.wrap = TRUE;
116 a->data.sendtodir.follow = TRUE;
119 void setup_action_send_to_desktop_up(ObAction *a)
121 a->data.sendtodir.dir = OB_DIRECTION_NORTH;
122 a->data.sendtodir.linear = FALSE;
123 a->data.sendtodir.wrap = TRUE;
124 a->data.sendtodir.follow = TRUE;
127 void setup_action_send_to_desktop_down(ObAction *a)
129 a->data.sendtodir.dir = OB_DIRECTION_SOUTH;
130 a->data.sendtodir.linear = FALSE;
131 a->data.sendtodir.wrap = TRUE;
132 a->data.sendtodir.follow = TRUE;
135 void setup_action_desktop_prev(ObAction *a)
137 a->data.desktopdir.dir = OB_DIRECTION_WEST;
138 a->data.desktopdir.linear = TRUE;
139 a->data.desktopdir.wrap = TRUE;
142 void setup_action_desktop_next(ObAction *a)
144 a->data.desktopdir.dir = OB_DIRECTION_EAST;
145 a->data.desktopdir.linear = TRUE;
146 a->data.desktopdir.wrap = TRUE;
149 void setup_action_desktop_left(ObAction *a)
151 a->data.desktopdir.dir = OB_DIRECTION_WEST;
152 a->data.desktopdir.linear = FALSE;
153 a->data.desktopdir.wrap = TRUE;
156 void setup_action_desktop_right(ObAction *a)
158 a->data.desktopdir.dir = OB_DIRECTION_EAST;
159 a->data.desktopdir.linear = FALSE;
160 a->data.desktopdir.wrap = TRUE;
163 void setup_action_desktop_up(ObAction *a)
165 a->data.desktopdir.dir = OB_DIRECTION_NORTH;
166 a->data.desktopdir.linear = FALSE;
167 a->data.desktopdir.wrap = TRUE;
170 void setup_action_desktop_down(ObAction *a)
172 a->data.desktopdir.dir = OB_DIRECTION_SOUTH;
173 a->data.desktopdir.linear = FALSE;
174 a->data.desktopdir.wrap = TRUE;
177 void setup_action_move_keyboard(ObAction *a)
179 a->data.moveresize.corner = prop_atoms.net_wm_moveresize_move_keyboard;
182 void setup_action_move(ObAction *a)
184 a->data.moveresize.corner = prop_atoms.net_wm_moveresize_move;
187 void setup_action_resize(ObAction *a)
189 a->data.moveresize.corner = prop_atoms.net_wm_moveresize_size_topleft;
192 void setup_action_resize_keyboard(ObAction *a)
194 a->data.moveresize.corner = prop_atoms.net_wm_moveresize_size_keyboard;
197 void setup_action_cycle_windows_linear_next(ObAction *a)
199 a->data.cycle.linear = TRUE;
200 a->data.cycle.forward = TRUE;
203 void setup_action_cycle_windows_linear_previous(ObAction *a)
205 a->data.cycle.linear = TRUE;
206 a->data.cycle.forward = FALSE;
209 void setup_action_cycle_windows_next(ObAction *a)
211 a->data.cycle.linear = FALSE;
212 a->data.cycle.forward = TRUE;
215 void setup_action_cycle_windows_previous(ObAction *a)
217 a->data.cycle.linear = FALSE;
218 a->data.cycle.forward = FALSE;
221 void setup_action_movetoedge_north(ObAction *a)
223 a->data.diraction.direction = OB_DIRECTION_NORTH;
226 void setup_action_movetoedge_south(ObAction *a)
228 a->data.diraction.direction = OB_DIRECTION_SOUTH;
231 void setup_action_movetoedge_east(ObAction *a)
233 a->data.diraction.direction = OB_DIRECTION_EAST;
236 void setup_action_movetoedge_west(ObAction *a)
238 a->data.diraction.direction = OB_DIRECTION_WEST;
241 void setup_action_growtoedge_north(ObAction *a)
243 a->data.diraction.direction = OB_DIRECTION_NORTH;
246 void setup_action_growtoedge_south(ObAction *a)
248 a->data.diraction.direction = OB_DIRECTION_SOUTH;
251 void setup_action_growtoedge_east(ObAction *a)
253 a->data.diraction.direction = OB_DIRECTION_EAST;
256 void setup_action_growtoedge_west(ObAction *a)
258 a->data.diraction.direction = OB_DIRECTION_WEST;
261 void setup_action_top_layer(ObAction *a)
263 a->data.layer.layer = 1;
266 void setup_action_normal_layer(ObAction *a)
268 a->data.layer.layer = 0;
271 void setup_action_bottom_layer(ObAction *a)
273 a->data.layer.layer = -1;
276 ActionString actionstrings[] =
284 "directionalfocusnorth",
285 action_directional_focus,
286 setup_action_directional_focus_north
289 "directionalfocuseast",
290 action_directional_focus,
291 setup_action_directional_focus_east
294 "directionalfocussouth",
295 action_directional_focus,
296 setup_action_directional_focus_south
299 "directionalfocuswest",
300 action_directional_focus,
301 setup_action_directional_focus_west
304 "directionalfocusnortheast",
305 action_directional_focus,
306 setup_action_directional_focus_northeast
309 "directionalfocussoutheast",
310 action_directional_focus,
311 setup_action_directional_focus_southeast
314 "directionalfocussouthwest",
315 action_directional_focus,
316 setup_action_directional_focus_southwest
319 "directionalfocusnorthwest",
320 action_directional_focus,
321 setup_action_directional_focus_northwest
395 action_toggle_omnipresent,
400 action_move_relative_horz,
405 action_move_relative_vert,
409 "resizerelativehorz",
410 action_resize_relative_horz,
414 "resizerelativevert",
415 action_resize_relative_vert,
420 action_maximize_full,
425 action_unmaximize_full,
429 "togglemaximizefull",
430 action_toggle_maximize_full,
435 action_maximize_horz,
440 action_unmaximize_horz,
444 "togglemaximizehorz",
445 action_toggle_maximize_horz,
450 action_maximize_vert,
455 action_unmaximize_vert,
459 "togglemaximizevert",
460 action_toggle_maximize_vert,
465 action_send_to_desktop,
466 setup_action_send_to_desktop
470 action_send_to_desktop_dir,
471 setup_action_send_to_desktop_next
474 "sendtodesktopprevious",
475 action_send_to_desktop_dir,
476 setup_action_send_to_desktop_prev
479 "sendtodesktopright",
480 action_send_to_desktop_dir,
481 setup_action_send_to_desktop_right
485 action_send_to_desktop_dir,
486 setup_action_send_to_desktop_left
490 action_send_to_desktop_dir,
491 setup_action_send_to_desktop_up
495 action_send_to_desktop_dir,
496 setup_action_send_to_desktop_down
506 setup_action_desktop_next
511 setup_action_desktop_prev
516 setup_action_desktop_right
521 setup_action_desktop_left
526 setup_action_desktop_up
531 setup_action_desktop_down
535 action_toggle_decorations,
541 setup_action_move_keyboard
556 setup_action_resize_keyboard
560 action_toggle_show_desktop,
570 action_unshow_desktop,
590 action_send_to_layer,
591 setup_action_top_layer
596 setup_action_top_layer
600 action_send_to_layer,
601 setup_action_normal_layer
605 action_send_to_layer,
606 setup_action_bottom_layer
609 "togglealwaysonbottom",
611 setup_action_bottom_layer
615 action_cycle_windows,
616 setup_action_cycle_windows_linear_next
619 "previouswindowlinear",
620 action_cycle_windows,
621 setup_action_cycle_windows_linear_previous
625 action_cycle_windows,
626 setup_action_cycle_windows_next
630 action_cycle_windows,
631 setup_action_cycle_windows_previous
636 setup_action_movetoedge_north
641 setup_action_movetoedge_south
646 setup_action_movetoedge_west
651 setup_action_movetoedge_east
656 setup_action_growtoedge_north
661 setup_action_growtoedge_south
666 setup_action_growtoedge_west
671 setup_action_growtoedge_east
680 ObAction *action_from_string(char *name)
685 for (i = 0; actionstrings[i].name; i++)
686 if (!g_ascii_strcasecmp(name, actionstrings[i].name)) {
687 a = action_new(actionstrings[i].func);
688 if (actionstrings[i].setup)
689 actionstrings[i].setup(a);
695 ObAction *action_parse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
698 ObAction *act = NULL;
701 if (parse_attr_string("name", node, &actname)) {
702 if ((act = action_from_string(actname))) {
703 if (act->func == action_execute || act->func == action_restart) {
704 if ((n = parse_find_node("execute", node->xmlChildrenNode)))
705 act->data.execute.path = parse_string(doc, n);
706 } else if (act->func == action_showmenu) {
707 if ((n = parse_find_node("menu", node->xmlChildrenNode)))
708 act->data.showmenu.name = parse_string(doc, n);
709 } else if (act->func == action_desktop) {
710 if ((n = parse_find_node("desktop", node->xmlChildrenNode)))
711 act->data.desktop.desk = parse_int(doc, n);
712 if (act->data.desktop.desk > 0) act->data.desktop.desk--;
713 } else if (act->func == action_send_to_desktop) {
714 if ((n = parse_find_node("desktop", node->xmlChildrenNode)))
715 act->data.sendto.desk = parse_int(doc, n);
716 if (act->data.sendto.desk > 0) act->data.sendto.desk--;
717 } else if (act->func == action_move_relative_horz ||
718 act->func == action_move_relative_vert ||
719 act->func == action_resize_relative_horz ||
720 act->func == action_resize_relative_vert) {
721 if ((n = parse_find_node("delta", node->xmlChildrenNode)))
722 act->data.relative.delta = parse_int(doc, n);
723 } else if (act->func == action_desktop_dir) {
724 if ((n = parse_find_node("wrap", node->xmlChildrenNode))) {
725 act->data.desktopdir.wrap = parse_bool(doc, n);
727 } else if (act->func == action_send_to_desktop) {
728 if ((n = parse_find_node("follow", node->xmlChildrenNode)))
729 act->data.sendto.follow = parse_bool(doc, n);
730 } else if (act->func == action_send_to_desktop_dir) {
731 if ((n = parse_find_node("wrap", node->xmlChildrenNode)))
732 act->data.sendtodir.wrap = parse_bool(doc, n);
733 if ((n = parse_find_node("follow", node->xmlChildrenNode)))
734 act->data.sendtodir.follow = parse_bool(doc, n);
735 } else if (act->func == action_activate) {
736 if ((n = parse_find_node("here", node->xmlChildrenNode)))
737 act->data.activate.here = parse_bool(doc, n);
745 void action_execute(union ActionData *data)
749 if (data->execute.path) {
750 cmd = g_filename_from_utf8(data->execute.path, -1, NULL, NULL, NULL);
752 if (!g_spawn_command_line_async(cmd, &e)) {
753 g_warning("failed to execute '%s': %s",
757 g_warning("failed to convert '%s' from utf8", data->execute.path);
762 void action_activate(union ActionData *data)
764 if (data->activate.c)
765 client_activate(data->activate.c, data->activate.here);
768 void action_focus(union ActionData *data)
771 client_focus(data->client.c);
774 void action_unfocus (union ActionData *data)
777 client_unfocus(data->client.c);
780 void action_iconify(union ActionData *data)
783 client_iconify(data->client.c, TRUE, TRUE);
786 void action_raiselower(union ActionData *data)
788 ObClient *c = data->client.c;
790 gboolean raise = FALSE;
794 for (it = stacking_list; it; it = g_list_next(it)) {
795 ObClient *cit = it->data;
798 if (client_normal(cit) == client_normal(c) &&
799 cit->layer == c->layer &&
802 if (RECT_INTERSECTS_RECT(cit->frame->area, c->frame->area)) {
810 stacking_raise(CLIENT_AS_WINDOW(c));
812 stacking_lower(CLIENT_AS_WINDOW(c));
815 void action_raise(union ActionData *data)
818 stacking_raise(CLIENT_AS_WINDOW(data->client.c));
821 void action_unshaderaise(union ActionData *data)
823 if (data->client.c) {
824 if (data->client.c->shaded)
825 client_shade(data->client.c, FALSE);
827 stacking_raise(CLIENT_AS_WINDOW(data->client.c));
831 void action_shadelower(union ActionData *data)
833 if (data->client.c) {
834 if (data->client.c->shaded)
835 stacking_lower(CLIENT_AS_WINDOW(data->client.c));
837 client_shade(data->client.c, TRUE);
841 void action_lower(union ActionData *data)
844 stacking_lower(CLIENT_AS_WINDOW(data->client.c));
847 void action_close(union ActionData *data)
850 client_close(data->client.c);
853 void action_kill(union ActionData *data)
856 client_kill(data->client.c);
859 void action_shade(union ActionData *data)
862 client_shade(data->client.c, TRUE);
865 void action_unshade(union ActionData *data)
868 client_shade(data->client.c, FALSE);
871 void action_toggle_shade(union ActionData *data)
874 client_shade(data->client.c, !data->client.c->shaded);
877 void action_toggle_omnipresent(union ActionData *data)
880 client_set_desktop(data->client.c,
881 data->client.c->desktop == DESKTOP_ALL ?
882 screen_desktop : DESKTOP_ALL, FALSE);
885 void action_move_relative_horz(union ActionData *data)
887 ObClient *c = data->relative.c;
889 client_configure(c, OB_CORNER_TOPLEFT,
890 c->area.x + data->relative.delta, c->area.y,
891 c->area.width, c->area.height, TRUE, TRUE);
894 void action_move_relative_vert(union ActionData *data)
896 ObClient *c = data->relative.c;
898 client_configure(c, OB_CORNER_TOPLEFT,
899 c->area.x, c->area.y + data->relative.delta,
900 c->area.width, c->area.height, TRUE, TRUE);
903 void action_resize_relative_horz(union ActionData *data)
905 ObClient *c = data->relative.c;
907 client_configure(c, OB_CORNER_TOPLEFT, c->area.x, c->area.y,
909 data->relative.delta * c->size_inc.width,
910 c->area.height, TRUE, TRUE);
913 void action_resize_relative_vert(union ActionData *data)
915 ObClient *c = data->relative.c;
917 client_configure(c, OB_CORNER_TOPLEFT, c->area.x, c->area.y,
918 c->area.width, c->area.height +
919 data->relative.delta * c->size_inc.height,
923 void action_maximize_full(union ActionData *data)
926 client_maximize(data->client.c, TRUE, 0, TRUE);
929 void action_unmaximize_full(union ActionData *data)
932 client_maximize(data->client.c, FALSE, 0, TRUE);
935 void action_toggle_maximize_full(union ActionData *data)
938 client_maximize(data->client.c,
939 !(data->client.c->max_horz ||
940 data->client.c->max_vert),
944 void action_maximize_horz(union ActionData *data)
947 client_maximize(data->client.c, TRUE, 1, TRUE);
950 void action_unmaximize_horz(union ActionData *data)
953 client_maximize(data->client.c, FALSE, 1, TRUE);
956 void action_toggle_maximize_horz(union ActionData *data)
959 client_maximize(data->client.c, !data->client.c->max_horz, 1, TRUE);
962 void action_maximize_vert(union ActionData *data)
965 client_maximize(data->client.c, TRUE, 2, TRUE);
968 void action_unmaximize_vert(union ActionData *data)
971 client_maximize(data->client.c, FALSE, 2, TRUE);
974 void action_toggle_maximize_vert(union ActionData *data)
977 client_maximize(data->client.c, !data->client.c->max_vert, 2, TRUE);
980 void action_send_to_desktop(union ActionData *data)
982 ObClient *c = data->sendto.c;
984 if (!c || !client_normal(c)) return;
986 if (data->sendto.desk < screen_num_desktops ||
987 data->sendto.desk == DESKTOP_ALL) {
988 client_set_desktop(c, data->sendto.desk, data->sendto.follow);
989 if (data->sendto.follow)
990 screen_set_desktop(data->sendto.desk);
994 void action_desktop(union ActionData *data)
996 if (data->desktop.desk < screen_num_desktops ||
997 data->desktop.desk == DESKTOP_ALL)
998 screen_set_desktop(data->desktop.desk);
1001 void action_desktop_dir(union ActionData *data)
1005 d = screen_cycle_desktop(data->desktopdir.dir, data->desktopdir.wrap,
1006 data->sendtodir.linear,
1007 data->desktopdir.final, data->desktopdir.cancel);
1008 screen_set_desktop(d);
1011 void action_send_to_desktop_dir(union ActionData *data)
1013 ObClient *c = data->sendtodir.c;
1016 if (!c || !client_normal(c)) return;
1018 d = screen_cycle_desktop(data->sendtodir.dir, data->sendtodir.wrap,
1019 data->sendtodir.linear,
1020 data->sendtodir.final, data->sendtodir.cancel);
1021 client_set_desktop(c, d, data->sendtodir.follow);
1022 if (data->sendtodir.follow)
1023 screen_set_desktop(d);
1027 void action_desktop_right(union ActionData *data)
1031 cur_row_col(&r, &c);
1033 if (c >= screen_desktop_layout.columns) {
1034 if (!data->desktopdir.wrap) return;
1037 d = translate_row_col(r, c);
1038 if (d >= screen_num_desktops) {
1039 if (!data->desktopdir.wrap) return;
1042 d = translate_row_col(r, c);
1043 if (d < screen_num_desktops)
1044 screen_cycle_desktop(d, data->desktopdir.final,
1045 data->desktopdir.cancel);
1048 void action_send_to_desktop_right(union ActionData *data)
1050 ObClient *cl = data->sendto.c;
1053 if (!cl || !client_normal(cl)) return;
1055 cur_row_col(&r, &c);
1057 if (c >= screen_desktop_layout.columns) {
1058 if (!data->sendtodir.wrap) return;
1061 d = translate_row_col(r, c);
1062 if (d >= screen_num_desktops) {
1063 if (!data->sendtodir.wrap) return;
1066 d = translate_row_col(r, c);
1067 if (d < screen_num_desktops) {
1068 client_set_desktop(cl, d, data->sendtodir.follow);
1069 if (data->sendtodir.follow)
1070 screen_cycle_desktop(d, data->desktopdir.final,
1071 data->desktopdir.cancel);
1075 void action_desktop_left(union ActionData *data)
1079 cur_row_col(&r, &c);
1081 if (c >= screen_desktop_layout.columns) {
1082 if (!data->desktopdir.wrap) return;
1083 c = screen_desktop_layout.columns - 1;
1085 d = translate_row_col(r, c);
1086 if (d >= screen_num_desktops) {
1087 if (!data->desktopdir.wrap) return;
1090 d = translate_row_col(r, c);
1091 if (d < screen_num_desktops)
1092 screen_cycle_desktop(d, data->desktopdir.final,
1093 data->desktopdir.cancel);
1096 void action_send_to_desktop_left(union ActionData *data)
1098 ObClient *cl = data->sendto.c;
1101 if (!cl || !client_normal(cl)) return;
1103 cur_row_col(&r, &c);
1105 if (c >= screen_desktop_layout.columns) {
1106 if (!data->sendtodir.wrap) return;
1107 c = screen_desktop_layout.columns - 1;
1109 d = translate_row_col(r, c);
1110 if (d >= screen_num_desktops) {
1111 if (!data->sendtodir.wrap) return;
1114 d = translate_row_col(r, c);
1115 if (d < screen_num_desktops) {
1116 client_set_desktop(cl, d, data->sendtodir.follow);
1117 if (data->sendtodir.follow)
1118 screen_cycle_desktop(d, data->desktopdir.final,
1119 data->desktopdir.cancel);
1123 void action_desktop_down(union ActionData *data)
1127 cur_row_col(&r, &c);
1129 if (r >= screen_desktop_layout.rows) {
1130 if (!data->desktopdir.wrap) return;
1133 d = translate_row_col(r, c);
1134 if (d >= screen_num_desktops) {
1135 if (!data->desktopdir.wrap) return;
1138 d = translate_row_col(r, c);
1139 if (d < screen_num_desktops)
1140 screen_cycle_desktop(d, data->desktopdir.final,
1141 data->desktopdir.cancel);
1144 void action_send_to_desktop_down(union ActionData *data)
1148 if (data->sendtodir.c) {
1149 cur_row_col(&r, &c);
1151 if (r >= screen_desktop_layout.rows) {
1152 if (!data->sendtodir.wrap) return;
1155 d = translate_row_col(r, c);
1156 if (d >= screen_num_desktops) {
1157 if (!data->sendtodir.wrap) return;
1160 d = translate_row_col(r, c);
1161 if (d < screen_num_desktops) {
1162 client_set_desktop(data->sendtodir.c, d, data->sendtodir.follow);
1163 if (data->sendtodir.follow)
1164 screen_cycle_desktop(d, data->desktopdir.final,
1165 data->desktopdir.cancel);
1170 void action_desktop_up(union ActionData *data)
1174 cur_row_col(&r, &c);
1176 if (r >= screen_desktop_layout.rows) {
1177 if (!data->desktopdir.wrap) return;
1178 r = screen_desktop_layout.rows - 1;
1180 d = translate_row_col(r, c);
1181 if (d >= screen_num_desktops) {
1182 if (!data->desktopdir.wrap) return;
1185 d = translate_row_col(r, c);
1186 if (d < screen_num_desktops)
1187 screen_cycle_desktop(d, data->desktopdir.final,
1188 data->desktopdir.cancel);
1191 void action_send_to_desktop_up(union ActionData *data)
1195 if (data->sendtodir.c) {
1196 cur_row_col(&r, &c);
1198 if (r >= screen_desktop_layout.rows) {
1199 if (!data->sendtodir.wrap) return;
1200 r = screen_desktop_layout.rows - 1;
1202 d = translate_row_col(r, c);
1203 if (d >= screen_num_desktops) {
1204 if (!data->sendtodir.wrap) return;
1207 d = translate_row_col(r, c);
1208 if (d < screen_num_desktops) {
1209 client_set_desktop(data->sendtodir.c, d, data->sendtodir.follow);
1210 if (data->sendtodir.follow)
1211 screen_cycle_desktop(d, data->desktopdir.final,
1212 data->desktopdir.cancel);
1218 void action_toggle_decorations(union ActionData *data)
1220 ObClient *c = data->client.c;
1224 c->decorate = !c->decorate;
1225 client_setup_decor_and_functions(c);
1228 void action_moveresize(union ActionData *data)
1230 ObClient *c = data->moveresize.c;
1232 if (!c || !client_normal(c)) return;
1234 moveresize_start(c, data->moveresize.x, data->moveresize.y,
1235 data->moveresize.button, data->moveresize.corner);
1238 void action_restart(union ActionData *data)
1240 ob_restart_other(data->execute.path);
1243 void action_exit(union ActionData *data)
1248 void action_showmenu(union ActionData *data)
1250 if (data->showmenu.name) {
1251 menu_show(data->showmenu.name, data->showmenu.x, data->showmenu.y,
1256 void action_cycle_windows(union ActionData *data)
1260 c = focus_cycle(data->cycle.forward, data->cycle.linear, data->cycle.final,
1261 data->cycle.cancel);
1264 void action_directional_focus(union ActionData *data)
1268 if (!data->diraction.c)
1270 if ((nf = client_find_directional(data->diraction.c,
1271 data->diraction.direction)))
1272 client_activate(nf, FALSE);
1275 void action_movetoedge(union ActionData *data)
1278 ObClient *c = data->diraction.c;
1282 x = c->frame->area.x;
1283 y = c->frame->area.y;
1285 switch(data->diraction.direction) {
1286 case OB_DIRECTION_NORTH:
1287 y = client_directional_edge_search(c, OB_DIRECTION_NORTH);
1289 case OB_DIRECTION_WEST:
1290 x = client_directional_edge_search(c, OB_DIRECTION_WEST);
1292 case OB_DIRECTION_SOUTH:
1293 y = client_directional_edge_search(c, OB_DIRECTION_SOUTH) -
1294 c->frame->area.height;
1296 case OB_DIRECTION_EAST:
1297 x = client_directional_edge_search(c, OB_DIRECTION_EAST) -
1298 c->frame->area.width;
1301 g_assert_not_reached();
1303 frame_frame_gravity(c->frame, &x, &y);
1304 client_configure(c, OB_CORNER_TOPLEFT,
1305 x, y, c->area.width, c->area.height, TRUE, TRUE);
1309 void action_growtoedge(union ActionData *data)
1311 int x, y, width, height, dest;
1312 ObClient *c = data->diraction.c;
1313 Rect *a = screen_area(c->desktop);
1318 x = c->frame->area.x;
1319 y = c->frame->area.y;
1320 width = c->frame->area.width;
1321 height = c->frame->area.height;
1323 switch(data->diraction.direction) {
1324 case OB_DIRECTION_NORTH:
1325 dest = client_directional_edge_search(c, OB_DIRECTION_NORTH);
1327 height = c->frame->area.height / 2;
1329 height = c->frame->area.y + c->frame->area.height - dest;
1333 case OB_DIRECTION_WEST:
1334 dest = client_directional_edge_search(c, OB_DIRECTION_WEST);
1336 width = c->frame->area.width / 2;
1338 width = c->frame->area.x + c->frame->area.width - dest;
1342 case OB_DIRECTION_SOUTH:
1343 dest = client_directional_edge_search(c, OB_DIRECTION_SOUTH);
1344 if (a->y + a->height == y + c->frame->area.height) {
1345 height = c->frame->area.height / 2;
1346 y = a->y + a->height - height;
1348 height = dest - c->frame->area.y;
1349 y += (height - c->frame->area.height) % c->size_inc.height;
1350 height -= (height - c->frame->area.height) % c->size_inc.height;
1352 case OB_DIRECTION_EAST:
1353 dest = client_directional_edge_search(c, OB_DIRECTION_EAST);
1354 if (a->x + a->width == x + c->frame->area.width) {
1355 width = c->frame->area.width / 2;
1356 x = a->x + a->width - width;
1358 width = dest - c->frame->area.x;
1359 x += (width - c->frame->area.width) % c->size_inc.width;
1360 width -= (width - c->frame->area.width) % c->size_inc.width;
1363 g_assert_not_reached();
1365 frame_frame_gravity(c->frame, &x, &y);
1366 width -= c->frame->size.left + c->frame->size.right;
1367 height -= c->frame->size.top + c->frame->size.bottom;
1368 client_configure(c, OB_CORNER_TOPLEFT, x, y, width, height, TRUE, TRUE);
1371 void action_send_to_layer(union ActionData *data)
1374 client_set_layer(data->layer.c, data->layer.layer);
1377 void action_toggle_layer(union ActionData *data)
1379 ObClient *c = data->layer.c;
1382 if (data->layer.layer < 0)
1383 client_set_layer(c, c->below ? 0 : -1);
1384 else if (data->layer.layer > 0)
1385 client_set_layer(c, c->above ? 0 : 1);
1389 void action_toggle_show_desktop(union ActionData *data)
1391 screen_show_desktop(!screen_showing_desktop);
1394 void action_show_desktop(union ActionData *data)
1396 screen_show_desktop(TRUE);
1399 void action_unshow_desktop(union ActionData *data)
1401 screen_show_desktop(FALSE);