]> Dogcows Code - chaz/openbox/blob - openbox/action.c
9aeeff5800fd2713de32f0124ae2a6a748029ffa
[chaz/openbox] / openbox / action.c
1 #include "client.h"
2 #include "focus.h"
3 #include "moveresize.h"
4 #include "menu.h"
5 #include "prop.h"
6 #include "stacking.h"
7 #include "frame.h"
8 #include "screen.h"
9 #include "action.h"
10 #include "dispatch.h"
11 #include "openbox.h"
12
13 #include <glib.h>
14
15 typedef struct ActionString {
16 char *name;
17 void (*func)(union ActionData *);
18 void (*setup)(Action *);
19 } ActionString;
20
21 Action *action_new(void (*func)(union ActionData *data))
22 {
23 Action *a = g_new0(Action, 1);
24 a->func = func;
25
26 return a;
27 }
28
29 void action_free(Action *a)
30 {
31 if (a == NULL) return;
32
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);
38
39 g_free(a);
40 }
41
42 void setup_action_directional_focus_north(Action *a)
43 {
44 a->data.dfocus.direction = Direction_North;
45 }
46
47 void setup_action_directional_focus_east(Action *a)
48 {
49 a->data.dfocus.direction = Direction_East;
50 }
51
52 void setup_action_directional_focus_south(Action *a)
53 {
54 a->data.dfocus.direction = Direction_South;
55 }
56
57 void setup_action_directional_focus_west(Action *a)
58 {
59 a->data.dfocus.direction = Direction_West;
60 }
61
62 void setup_action_directional_focus_northeast(Action *a)
63 {
64 a->data.dfocus.direction = Direction_NorthEast;
65 }
66
67 void setup_action_directional_focus_southeast(Action *a)
68 {
69 a->data.dfocus.direction = Direction_SouthEast;
70 }
71
72 void setup_action_directional_focus_southwest(Action *a)
73 {
74 a->data.dfocus.direction = Direction_SouthWest;
75 }
76
77 void setup_action_directional_focus_northwest(Action *a)
78 {
79 a->data.dfocus.direction = Direction_NorthWest;
80 }
81
82 void setup_action_send_to_desktop(Action *a)
83 {
84 a->data.sendto.follow = TRUE;
85 }
86
87 void setup_action_send_to_np_desktop(Action *a)
88 {
89 a->data.sendtonextprev.wrap = FALSE;
90 a->data.sendtonextprev.follow = TRUE;
91 }
92
93 void setup_action_send_to_np_desktop_wrap(Action *a)
94 {
95 a->data.sendtonextprev.wrap = TRUE;
96 a->data.sendtonextprev.follow = TRUE;
97 }
98
99 void setup_action_np_desktop(Action *a)
100 {
101 a->data.nextprevdesktop.wrap = FALSE;
102 }
103
104 void setup_action_np_desktop_wrap(Action *a)
105 {
106 a->data.nextprevdesktop.wrap = TRUE;
107 }
108
109 void setup_action_move_keyboard(Action *a)
110 {
111 a->data.moveresize.corner = prop_atoms.net_wm_moveresize_move_keyboard;
112 }
113
114 void setup_action_move(Action *a)
115 {
116 a->data.moveresize.corner = prop_atoms.net_wm_moveresize_move;
117 }
118
119 void setup_action_resize(Action *a)
120 {
121 a->data.moveresize.corner = prop_atoms.net_wm_moveresize_size_topleft;
122 }
123
124 void setup_action_resize_keyboard(Action *a)
125 {
126 a->data.moveresize.corner = prop_atoms.net_wm_moveresize_size_keyboard;
127 }
128
129 void setup_action_cycle_windows_linear_next(Action *a)
130 {
131 a->data.cycle.linear = TRUE;
132 a->data.cycle.forward = TRUE;
133 }
134
135 void setup_action_cycle_windows_linear_previous(Action *a)
136 {
137 a->data.cycle.linear = TRUE;
138 a->data.cycle.forward = FALSE;
139 }
140
141 void setup_action_cycle_windows_next(Action *a)
142 {
143 a->data.cycle.linear = FALSE;
144 a->data.cycle.forward = TRUE;
145 }
146
147 void setup_action_cycle_windows_previous(Action *a)
148 {
149 a->data.cycle.linear = FALSE;
150 a->data.cycle.forward = FALSE;
151 }
152
153 ActionString actionstrings[] =
154 {
155 {
156 "execute",
157 action_execute,
158 NULL
159 },
160 {
161 "directionalfocusnorth",
162 action_directional_focus,
163 setup_action_directional_focus_north
164 },
165 {
166 "directionalfocuseast",
167 action_directional_focus,
168 setup_action_directional_focus_east
169 },
170 {
171 "directionalfocussouth",
172 action_directional_focus,
173 setup_action_directional_focus_south
174 },
175 {
176 "directionalfocuswest",
177 action_directional_focus,
178 setup_action_directional_focus_west
179 },
180 {
181 "directionalfocusnortheast",
182 action_directional_focus,
183 setup_action_directional_focus_northeast
184 },
185 {
186 "directionalfocussoutheast",
187 action_directional_focus,
188 setup_action_directional_focus_southeast
189 },
190 {
191 "directionalfocussouthwest",
192 action_directional_focus,
193 setup_action_directional_focus_southwest
194 },
195 {
196 "directionalfocusnorthwest",
197 action_directional_focus,
198 setup_action_directional_focus_northwest
199 },
200 {
201 "focus",
202 action_focus,
203 NULL,
204 },
205 {
206 "unfocus",
207 action_unfocus,
208 NULL
209 },
210 {
211 "iconify",
212 action_iconify,
213 NULL
214 },
215 {
216 "raise",
217 action_raise,
218 NULL
219 },
220 {
221 "lower",
222 action_lower,
223 NULL
224 },
225 {
226 "focusraise",
227 action_focusraise,
228 NULL
229 },
230 {
231 "close",
232 action_close,
233 NULL
234 },
235 {
236 "kill",
237 action_kill,
238 NULL
239 },
240 {
241 "shadelower",
242 action_shadelower,
243 NULL
244 },
245 {
246 "unshaderaise",
247 action_unshaderaise,
248 NULL
249 },
250 {
251 "shade",
252 action_shade,
253 NULL
254 },
255 {
256 "unshade",
257 action_unshade,
258 NULL
259 },
260 {
261 "toggleshade",
262 action_toggle_shade,
263 NULL
264 },
265 {
266 "toggleomnipresent",
267 action_toggle_omnipresent,
268 NULL
269 },
270 {
271 "moverelativehorz",
272 action_move_relative_horz,
273 NULL
274 },
275 {
276 "moverelativevert",
277 action_move_relative_vert,
278 NULL
279 },
280 {
281 "resizerelativehorz",
282 action_resize_relative_horz,
283 NULL
284 },
285 {
286 "resizerelativevert",
287 action_resize_relative_vert,
288 NULL
289 },
290 {
291 "maximizefull",
292 action_maximize_full,
293 NULL
294 },
295 {
296 "unmaximizefull",
297 action_unmaximize_full,
298 NULL
299 },
300 {
301 "togglemaximizefull",
302 action_toggle_maximize_full,
303 NULL
304 },
305 {
306 "maximizehorz",
307 action_maximize_horz,
308 NULL
309 },
310 {
311 "unmaximizehorz",
312 action_unmaximize_horz,
313 NULL
314 },
315 {
316 "togglemaximizehorz",
317 action_toggle_maximize_horz,
318 NULL
319 },
320 {
321 "maximizevert",
322 action_maximize_vert,
323 NULL
324 },
325 {
326 "unmaximizevert",
327 action_unmaximize_vert,
328 NULL
329 },
330 {
331 "togglemaximizevert",
332 action_toggle_maximize_vert,
333 NULL
334 },
335 {
336 "sendtodesktop",
337 action_send_to_desktop,
338 setup_action_send_to_desktop
339 },
340 {
341 "sendtonextdesktop",
342 action_send_to_next_desktop,
343 setup_action_send_to_np_desktop
344 },
345 {
346 "sendtonextdesktopwrap",
347 action_send_to_next_desktop,
348 setup_action_send_to_np_desktop_wrap
349 },
350 {
351 "sendtopreviousdesktop",
352 action_send_to_previous_desktop,
353 setup_action_send_to_np_desktop
354 },
355 {
356 "sendtopreviousdesktopwrap",
357 action_send_to_previous_desktop,
358 setup_action_send_to_np_desktop_wrap
359 },
360 {
361 "desktop",
362 action_desktop,
363 NULL
364 },
365 {
366 "nextdesktop",
367 action_next_desktop,
368 setup_action_np_desktop
369 },
370 {
371 "nextdesktopwrap",
372 action_next_desktop,
373 setup_action_np_desktop_wrap
374 },
375 {
376 "previousdesktop",
377 action_previous_desktop,
378 setup_action_np_desktop
379 },
380 {
381 "previousdesktopwrap",
382 action_previous_desktop,
383 setup_action_np_desktop_wrap
384 },
385 {
386 "nextdesktopcolumn",
387 action_next_desktop_column,
388 setup_action_np_desktop
389 },
390 {
391 "nextdesktopcolumnwrap",
392 action_next_desktop_column,
393 setup_action_np_desktop_wrap
394 },
395 {
396 "previousdesktopcolumn",
397 action_previous_desktop_column,
398 setup_action_np_desktop
399 },
400 {
401 "previousdesktopcolumnwrap",
402 action_previous_desktop_column,
403 setup_action_np_desktop_wrap
404 },
405 {
406 "nextdesktoprow",
407 action_next_desktop_row,
408 setup_action_np_desktop
409 },
410 {
411 "nextdesktoprowwrap",
412 action_next_desktop_row,
413 setup_action_np_desktop_wrap
414 },
415 {
416 "previousdesktoprow",
417 action_previous_desktop_row,
418 setup_action_np_desktop
419 },
420 {
421 "previousdesktoprowwrap",
422 action_previous_desktop_row,
423 setup_action_np_desktop_wrap
424 },
425 {
426 "toggledecorations",
427 action_toggle_decorations,
428 NULL
429 },
430 {
431 "keyboardmove",
432 action_moveresize,
433 setup_action_move_keyboard
434 },
435 {
436 "move",
437 action_moveresize,
438 setup_action_move
439 },
440 {
441 "resize",
442 action_moveresize,
443 setup_action_resize
444 },
445 {
446 "keyboardresize",
447 action_moveresize,
448 setup_action_resize_keyboard
449 },
450 {
451 "restart",
452 action_restart,
453 NULL
454 },
455 {
456 "exit",
457 action_exit,
458 NULL
459 },
460 {
461 "showmenu",
462 action_showmenu,
463 NULL
464 },
465 {
466 "nextwindowlinear",
467 action_cycle_windows,
468 setup_action_cycle_windows_linear_next
469 },
470 {
471 "previouswindowlinear",
472 action_cycle_windows,
473 setup_action_cycle_windows_linear_previous
474 },
475 {
476 "nextwindow",
477 action_cycle_windows,
478 setup_action_cycle_windows_next
479 },
480 {
481 "previouswindow",
482 action_cycle_windows,
483 setup_action_cycle_windows_previous
484 },
485 {
486 NULL,
487 NULL,
488 NULL
489 }
490 };
491
492 Action *action_from_string(char *name)
493 {
494 Action *a = NULL;
495 int i;
496
497 for (i = 0; actionstrings[i].name; i++)
498 if (!g_ascii_strcasecmp(name, actionstrings[i].name)) {
499 a = action_new(actionstrings[i].func);
500 if (actionstrings[i].setup)
501 actionstrings[i].setup(a);
502 break;
503 }
504 return a;
505 }
506
507 void action_execute(union ActionData *data)
508 {
509 GError *e = NULL;
510 if (data->execute.path)
511 if (!g_spawn_command_line_async(data->execute.path, &e)) {
512 g_warning("failed to execute '%s': %s",
513 data->execute.path, e->message);
514 }
515 }
516
517 void action_focus(union ActionData *data)
518 {
519 if (data->client.c)
520 client_focus(data->client.c);
521 }
522
523 void action_unfocus (union ActionData *data)
524 {
525 if (data->client.c)
526 client_unfocus(data->client.c);
527 }
528
529 void action_iconify(union ActionData *data)
530 {
531 if (data->client.c)
532 client_iconify(data->client.c, TRUE, TRUE);
533 }
534
535 void action_focusraise(union ActionData *data)
536 {
537 if (data->client.c) {
538 client_focus(data->client.c);
539 stacking_raise(CLIENT_AS_WINDOW(data->client.c));
540 }
541 }
542
543 void action_raise(union ActionData *data)
544 {
545 if (data->client.c)
546 stacking_raise(CLIENT_AS_WINDOW(data->client.c));
547 }
548
549 void action_unshaderaise(union ActionData *data)
550 {
551 if (data->client.c) {
552 if (data->client.c->shaded)
553 client_shade(data->client.c, FALSE);
554 else
555 stacking_raise(CLIENT_AS_WINDOW(data->client.c));
556 }
557 }
558
559 void action_shadelower(union ActionData *data)
560 {
561 if (data->client.c) {
562 if (data->client.c->shaded)
563 stacking_lower(CLIENT_AS_WINDOW(data->client.c));
564 else
565 client_shade(data->client.c, TRUE);
566 }
567 }
568
569 void action_lower(union ActionData *data)
570 {
571 if (data->client.c)
572 stacking_lower(CLIENT_AS_WINDOW(data->client.c));
573 }
574
575 void action_close(union ActionData *data)
576 {
577 if (data->client.c)
578 client_close(data->client.c);
579 }
580
581 void action_kill(union ActionData *data)
582 {
583 if (data->client.c)
584 client_kill(data->client.c);
585 }
586
587 void action_shade(union ActionData *data)
588 {
589 if (data->client.c)
590 client_shade(data->client.c, TRUE);
591 }
592
593 void action_unshade(union ActionData *data)
594 {
595 if (data->client.c)
596 client_shade(data->client.c, FALSE);
597 }
598
599 void action_toggle_shade(union ActionData *data)
600 {
601 if (data->client.c)
602 client_shade(data->client.c, !data->client.c->shaded);
603 }
604
605 void action_toggle_omnipresent(union ActionData *data)
606 {
607 if (data->client.c)
608 client_set_desktop(data->client.c,
609 data->client.c->desktop == DESKTOP_ALL ?
610 screen_desktop : DESKTOP_ALL, FALSE);
611 }
612
613 void action_move_relative_horz(union ActionData *data)
614 {
615 Client *c = data->relative.c;
616 if (c)
617 client_configure(c, Corner_TopLeft,
618 c->area.x + data->relative.delta, c->area.y,
619 c->area.width, c->area.height, TRUE, TRUE);
620 }
621
622 void action_move_relative_vert(union ActionData *data)
623 {
624 Client *c = data->relative.c;
625 if (c)
626 client_configure(c, Corner_TopLeft,
627 c->area.x, c->area.y + data->relative.delta,
628 c->area.width, c->area.height, TRUE, TRUE);
629 }
630
631 void action_resize_relative_horz(union ActionData *data)
632 {
633 Client *c = data->relative.c;
634 if (c)
635 client_configure(c, Corner_TopLeft, c->area.x, c->area.y,
636 c->area.width + data->relative.delta,
637 c->area.height, TRUE, TRUE);
638 }
639
640 void action_resize_relative_vert(union ActionData *data)
641 {
642 Client *c = data->relative.c;
643 if (c && !c->shaded)
644 client_configure(c, Corner_TopLeft, c->area.x, c->area.y,
645 c->area.width, c->area.height + data->relative.delta,
646 TRUE, TRUE);
647 }
648
649 void action_maximize_full(union ActionData *data)
650 {
651 if (data->client.c)
652 client_maximize(data->client.c, TRUE, 0, TRUE);
653 }
654
655 void action_unmaximize_full(union ActionData *data)
656 {
657 if (data->client.c)
658 client_maximize(data->client.c, FALSE, 0, TRUE);
659 }
660
661 void action_toggle_maximize_full(union ActionData *data)
662 {
663 if (data->client.c)
664 client_maximize(data->client.c,
665 !(data->client.c->max_horz ||
666 data->client.c->max_vert),
667 0, TRUE);
668 }
669
670 void action_maximize_horz(union ActionData *data)
671 {
672 if (data->client.c)
673 client_maximize(data->client.c, TRUE, 1, TRUE);
674 }
675
676 void action_unmaximize_horz(union ActionData *data)
677 {
678 if (data->client.c)
679 client_maximize(data->client.c, FALSE, 1, TRUE);
680 }
681
682 void action_toggle_maximize_horz(union ActionData *data)
683 {
684 if (data->client.c)
685 client_maximize(data->client.c, !data->client.c->max_horz, 1, TRUE);
686 }
687
688 void action_maximize_vert(union ActionData *data)
689 {
690 if (data->client.c)
691 client_maximize(data->client.c, TRUE, 2, TRUE);
692 }
693
694 void action_unmaximize_vert(union ActionData *data)
695 {
696 if (data->client.c)
697 client_maximize(data->client.c, FALSE, 2, TRUE);
698 }
699
700 void action_toggle_maximize_vert(union ActionData *data)
701 {
702 if (data->client.c)
703 client_maximize(data->client.c, !data->client.c->max_vert, 2, TRUE);
704 }
705
706 void action_send_to_desktop(union ActionData *data)
707 {
708 if (data->sendto.c) {
709 if (data->sendto.desk < screen_num_desktops ||
710 data->sendto.desk == DESKTOP_ALL) {
711 client_set_desktop(data->desktop.c,
712 data->sendto.desk, data->sendto.follow);
713 if (data->sendto.follow) screen_set_desktop(data->sendto.desk);
714 }
715 }
716 }
717
718 void action_send_to_next_desktop(union ActionData *data)
719 {
720 guint d;
721
722 if (!data->sendtonextprev.c) return;
723
724 d = screen_desktop + 1;
725 if (d >= screen_num_desktops) {
726 if (!data->sendtonextprev.wrap) return;
727 d = 0;
728 }
729 client_set_desktop(data->sendtonextprev.c, d, data->sendtonextprev.follow);
730 if (data->sendtonextprev.follow) screen_set_desktop(d);
731 }
732
733 void action_send_to_previous_desktop(union ActionData *data)
734 {
735 guint d;
736
737 if (!data->sendtonextprev.c) return;
738
739 d = screen_desktop - 1;
740 if (d >= screen_num_desktops) {
741 if (!data->sendtonextprev.wrap) return;
742 d = screen_num_desktops - 1;
743 }
744 client_set_desktop(data->sendtonextprev.c, d, data->sendtonextprev.follow);
745 if (data->sendtonextprev.follow) screen_set_desktop(d);
746 }
747
748 void action_desktop(union ActionData *data)
749 {
750 if (data->desktop.desk < screen_num_desktops ||
751 data->desktop.desk == DESKTOP_ALL)
752 screen_set_desktop(data->desktop.desk);
753 }
754
755 void action_next_desktop(union ActionData *data)
756 {
757 guint d;
758
759 d = screen_desktop + 1;
760 if (d >= screen_num_desktops) {
761 if (!data->nextprevdesktop.wrap) return;
762 d = 0;
763 }
764 screen_set_desktop(d);
765 }
766
767 void action_previous_desktop(union ActionData *data)
768 {
769 guint d;
770
771 d = screen_desktop - 1;
772 if (d >= screen_num_desktops) {
773 if (!data->nextprevdesktop.wrap) return;
774 d = screen_num_desktops - 1;
775 }
776 screen_set_desktop(d);
777 }
778
779 static void cur_row_col(guint *r, guint *c)
780 {
781 switch (screen_desktop_layout.orientation) {
782 case Orientation_Horz:
783 switch (screen_desktop_layout.start_corner) {
784 case Corner_TopLeft:
785 *r = screen_desktop / screen_desktop_layout.columns;
786 *c = screen_desktop % screen_desktop_layout.columns;
787 break;
788 case Corner_BottomLeft:
789 *r = screen_desktop_layout.rows - 1 -
790 screen_desktop / screen_desktop_layout.columns;
791 *c = screen_desktop % screen_desktop_layout.columns;
792 break;
793 case Corner_TopRight:
794 *r = screen_desktop / screen_desktop_layout.columns;
795 *c = screen_desktop_layout.columns - 1 -
796 screen_desktop % screen_desktop_layout.columns;
797 break;
798 case Corner_BottomRight:
799 *r = screen_desktop_layout.rows - 1 -
800 screen_desktop / screen_desktop_layout.columns;
801 *c = screen_desktop_layout.columns - 1 -
802 screen_desktop % screen_desktop_layout.columns;
803 break;
804 }
805 break;
806 case Orientation_Vert:
807 switch (screen_desktop_layout.start_corner) {
808 case Corner_TopLeft:
809 *r = screen_desktop % screen_desktop_layout.rows;
810 *c = screen_desktop / screen_desktop_layout.rows;
811 break;
812 case Corner_BottomLeft:
813 *r = screen_desktop_layout.rows - 1 -
814 screen_desktop % screen_desktop_layout.rows;
815 *c = screen_desktop / screen_desktop_layout.rows;
816 break;
817 case Corner_TopRight:
818 *r = screen_desktop % screen_desktop_layout.rows;
819 *c = screen_desktop_layout.columns - 1 -
820 screen_desktop / screen_desktop_layout.rows;
821 break;
822 case Corner_BottomRight:
823 *r = screen_desktop_layout.rows - 1 -
824 screen_desktop % screen_desktop_layout.rows;
825 *c = screen_desktop_layout.columns - 1 -
826 screen_desktop / screen_desktop_layout.rows;
827 break;
828 }
829 break;
830 }
831 }
832
833 static guint translate_row_col(guint r, guint c)
834 {
835 switch (screen_desktop_layout.orientation) {
836 case Orientation_Horz:
837 switch (screen_desktop_layout.start_corner) {
838 case Corner_TopLeft:
839 return r % screen_desktop_layout.rows *
840 screen_desktop_layout.columns +
841 c % screen_desktop_layout.columns;
842 case Corner_BottomLeft:
843 return (screen_desktop_layout.rows - 1 -
844 r % screen_desktop_layout.rows) *
845 screen_desktop_layout.columns +
846 c % screen_desktop_layout.columns;
847 case Corner_TopRight:
848 return r % screen_desktop_layout.rows *
849 screen_desktop_layout.columns +
850 (screen_desktop_layout.columns - 1 -
851 c % screen_desktop_layout.columns);
852 case Corner_BottomRight:
853 return (screen_desktop_layout.rows - 1 -
854 r % screen_desktop_layout.rows) *
855 screen_desktop_layout.columns +
856 (screen_desktop_layout.columns - 1 -
857 c % screen_desktop_layout.columns);
858 }
859 case Orientation_Vert:
860 switch (screen_desktop_layout.start_corner) {
861 case Corner_TopLeft:
862 return c % screen_desktop_layout.columns *
863 screen_desktop_layout.rows +
864 r % screen_desktop_layout.rows;
865 case Corner_BottomLeft:
866 return c % screen_desktop_layout.columns *
867 screen_desktop_layout.rows +
868 (screen_desktop_layout.rows - 1 -
869 r % screen_desktop_layout.rows);
870 case Corner_TopRight:
871 return (screen_desktop_layout.columns - 1 -
872 c % screen_desktop_layout.columns) *
873 screen_desktop_layout.rows +
874 r % screen_desktop_layout.rows;
875 case Corner_BottomRight:
876 return (screen_desktop_layout.columns - 1 -
877 c % screen_desktop_layout.columns) *
878 screen_desktop_layout.rows +
879 (screen_desktop_layout.rows - 1 -
880 r % screen_desktop_layout.rows);
881 }
882 }
883 g_assert_not_reached();
884 return 0;
885 }
886
887 void action_next_desktop_column(union ActionData *data)
888 {
889 guint r, c, d;
890
891 cur_row_col(&r, &c);
892 ++c;
893 if (c >= screen_desktop_layout.columns)
894 c = 0;
895 d = translate_row_col(r, c);
896 if (d >= screen_num_desktops) {
897 if (!data->nextprevdesktop.wrap) return;
898 ++c;
899 }
900 d = translate_row_col(r, c);
901 if (d < screen_num_desktops)
902 screen_set_desktop(d);
903 }
904
905 void action_previous_desktop_column(union ActionData *data)
906 {
907 guint r, c, d;
908
909 cur_row_col(&r, &c);
910 --c;
911 if (c >= screen_desktop_layout.columns)
912 c = screen_desktop_layout.columns - 1;
913 d = translate_row_col(r, c);
914 if (d >= screen_num_desktops) {
915 if (!data->nextprevdesktop.wrap) return;
916 --c;
917 }
918 d = translate_row_col(r, c);
919 if (d < screen_num_desktops)
920 screen_set_desktop(d);
921 }
922
923 void action_next_desktop_row(union ActionData *data)
924 {
925 guint r, c, d;
926
927 cur_row_col(&r, &c);
928 ++r;
929 if (r >= screen_desktop_layout.rows)
930 r = 0;
931 d = translate_row_col(r, c);
932 if (d >= screen_num_desktops) {
933 if (!data->nextprevdesktop.wrap) return;
934 ++r;
935 }
936 d = translate_row_col(r, c);
937 if (d < screen_num_desktops)
938 screen_set_desktop(d);
939 }
940
941 void action_previous_desktop_row(union ActionData *data)
942 {
943 guint r, c, d;
944
945 cur_row_col(&r, &c);
946 --r;
947 if (r >= screen_desktop_layout.rows)
948 r = screen_desktop_layout.rows - 1;
949 d = translate_row_col(r, c);
950 if (d >= screen_num_desktops) {
951 if (!data->nextprevdesktop.wrap) return;
952 --r;
953 }
954 d = translate_row_col(r, c);
955 if (d < screen_num_desktops)
956 screen_set_desktop(d);
957 }
958
959 void action_toggle_decorations(union ActionData *data)
960 {
961 Client *c = data->client.c;;
962
963 if (!c) return;
964
965 c->disabled_decorations = c->disabled_decorations ? 0 : ~0;
966 client_setup_decor_and_functions(c);
967 }
968
969 void action_moveresize(union ActionData *data)
970 {
971 Client *c = data->moveresize.c;
972
973 if (!c || !client_normal(c)) return;
974
975 moveresize_start(c, data->moveresize.x, data->moveresize.y,
976 data->moveresize.button, data->moveresize.corner);
977 }
978
979 void action_restart(union ActionData *data)
980 {
981 ob_restart_path = data->execute.path;
982 ob_shutdown = ob_restart = TRUE;
983 }
984
985 void action_exit(union ActionData *data)
986 {
987 ob_shutdown = TRUE;
988 }
989
990 void action_showmenu(union ActionData *data)
991 {
992 if (data->showmenu.name) {
993 menu_show(data->showmenu.name, data->showmenu.x, data->showmenu.y,
994 data->showmenu.c);
995 }
996 }
997
998 void action_cycle_windows(union ActionData *data)
999 {
1000 Client *c;
1001
1002 c = focus_cycle(data->cycle.forward, data->cycle.linear, data->cycle.final,
1003 data->cycle.cancel);
1004 }
1005
1006 void action_directional_focus(union ActionData *data)
1007 {
1008 Client *nf;
1009
1010 if (!data->dfocus.c)
1011 return;
1012 if ((nf = client_find_directional(data->dfocus.c, data->dfocus.direction)))
1013 client_activate(nf);
1014 }
This page took 0.081031 seconds and 4 git commands to generate.