]> Dogcows Code - chaz/openbox/blob - openbox/action.c
<group> option for raise/lower related actions. hi floam.
[chaz/openbox] / openbox / action.c
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3 action.c for the Openbox window manager
4 Copyright (c) 2003 Ben Jansens
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 See the COPYING file for a copy of the GNU General Public License.
17 */
18
19 #include "debug.h"
20 #include "client.h"
21 #include "focus.h"
22 #include "moveresize.h"
23 #include "menu.h"
24 #include "prop.h"
25 #include "stacking.h"
26 #include "screen.h"
27 #include "action.h"
28 #include "openbox.h"
29 #include "grab.h"
30 #include "keyboard.h"
31 #include "event.h"
32 #include "config.h"
33 #include "mainloop.h"
34
35 #include <glib.h>
36
37 inline void client_action_start(union ActionData *data)
38 {
39 if (config_focus_follow)
40 if (data->any.context != OB_FRAME_CONTEXT_CLIENT && !data->any.button)
41 grab_pointer(TRUE, OB_CURSOR_NONE);
42 }
43
44 inline void client_action_end(union ActionData *data)
45 {
46 if (config_focus_follow)
47 if (data->any.context != OB_FRAME_CONTEXT_CLIENT) {
48 if (!data->any.button) {
49 grab_pointer(FALSE, OB_CURSOR_NONE);
50 } else {
51 ObClient *c;
52
53 /* usually this is sorta redundant, but with a press action
54 the enter event will come as a GrabNotify which is
55 ignored, so this will handle that case */
56 if ((c = client_under_pointer()))
57 event_enter_client(c);
58 }
59 }
60 }
61
62 typedef struct
63 {
64 const gchar *name;
65 void (*func)(union ActionData *);
66 void (*setup)(ObAction **, ObUserAction uact);
67 } ActionString;
68
69 static ObAction *action_new(void (*func)(union ActionData *data))
70 {
71 ObAction *a = g_new0(ObAction, 1);
72 a->ref = 1;
73 a->func = func;
74
75 return a;
76 }
77
78 void action_ref(ObAction *a)
79 {
80 ++a->ref;
81 }
82
83 void action_unref(ObAction *a)
84 {
85 if (a == NULL) return;
86
87 if (--a->ref > 0) return;
88
89 /* deal with pointers */
90 if (a->func == action_execute || a->func == action_restart)
91 g_free(a->data.execute.path);
92 else if (a->func == action_showmenu)
93 g_free(a->data.showmenu.name);
94
95 g_free(a);
96 }
97
98 ObAction* action_copy(const ObAction *src)
99 {
100 ObAction *a = action_new(src->func);
101
102 a->data = src->data;
103
104 /* deal with pointers */
105 if (a->func == action_execute || a->func == action_restart)
106 a->data.execute.path = g_strdup(a->data.execute.path);
107 else if (a->func == action_showmenu)
108 a->data.showmenu.name = g_strdup(a->data.showmenu.name);
109
110 return a;
111 }
112
113 void setup_action_directional_focus_north(ObAction **a, ObUserAction uact)
114 {
115 (*a)->data.interdiraction.inter.any.interactive = TRUE;
116 (*a)->data.interdiraction.direction = OB_DIRECTION_NORTH;
117 (*a)->data.interdiraction.dialog = TRUE;
118 }
119
120 void setup_action_directional_focus_east(ObAction **a, ObUserAction uact)
121 {
122 (*a)->data.interdiraction.inter.any.interactive = TRUE;
123 (*a)->data.interdiraction.direction = OB_DIRECTION_EAST;
124 (*a)->data.interdiraction.dialog = TRUE;
125 }
126
127 void setup_action_directional_focus_south(ObAction **a, ObUserAction uact)
128 {
129 (*a)->data.interdiraction.inter.any.interactive = TRUE;
130 (*a)->data.interdiraction.direction = OB_DIRECTION_SOUTH;
131 (*a)->data.interdiraction.dialog = TRUE;
132 }
133
134 void setup_action_directional_focus_west(ObAction **a, ObUserAction uact)
135 {
136 (*a)->data.interdiraction.inter.any.interactive = TRUE;
137 (*a)->data.interdiraction.direction = OB_DIRECTION_WEST;
138 (*a)->data.interdiraction.dialog = TRUE;
139 }
140
141 void setup_action_directional_focus_northeast(ObAction **a, ObUserAction uact)
142 {
143 (*a)->data.interdiraction.inter.any.interactive = TRUE;
144 (*a)->data.interdiraction.direction = OB_DIRECTION_NORTHEAST;
145 (*a)->data.interdiraction.dialog = TRUE;
146 }
147
148 void setup_action_directional_focus_southeast(ObAction **a, ObUserAction uact)
149 {
150 (*a)->data.interdiraction.inter.any.interactive = TRUE;
151 (*a)->data.interdiraction.direction = OB_DIRECTION_SOUTHEAST;
152 (*a)->data.interdiraction.dialog = TRUE;
153 }
154
155 void setup_action_directional_focus_southwest(ObAction **a, ObUserAction uact)
156 {
157 (*a)->data.interdiraction.inter.any.interactive = TRUE;
158 (*a)->data.interdiraction.direction = OB_DIRECTION_SOUTHWEST;
159 (*a)->data.interdiraction.dialog = TRUE;
160 }
161
162 void setup_action_directional_focus_northwest(ObAction **a, ObUserAction uact)
163 {
164 (*a)->data.interdiraction.inter.any.interactive = TRUE;
165 (*a)->data.interdiraction.direction = OB_DIRECTION_NORTHWEST;
166 (*a)->data.interdiraction.dialog = TRUE;
167 }
168
169 void setup_action_send_to_desktop(ObAction **a, ObUserAction uact)
170 {
171 (*a)->data.sendto.any.client_action = OB_CLIENT_ACTION_ALWAYS;
172 (*a)->data.sendto.follow = TRUE;
173 }
174
175 void setup_action_send_to_desktop_prev(ObAction **a, ObUserAction uact)
176 {
177 (*a)->data.sendtodir.inter.any.client_action = OB_CLIENT_ACTION_ALWAYS;
178 (*a)->data.sendtodir.inter.any.interactive = TRUE;
179 (*a)->data.sendtodir.dir = OB_DIRECTION_WEST;
180 (*a)->data.sendtodir.linear = TRUE;
181 (*a)->data.sendtodir.wrap = TRUE;
182 (*a)->data.sendtodir.follow = TRUE;
183 }
184
185 void setup_action_send_to_desktop_next(ObAction **a, ObUserAction uact)
186 {
187 (*a)->data.sendtodir.inter.any.client_action = OB_CLIENT_ACTION_ALWAYS;
188 (*a)->data.sendtodir.inter.any.interactive = TRUE;
189 (*a)->data.sendtodir.dir = OB_DIRECTION_EAST;
190 (*a)->data.sendtodir.linear = TRUE;
191 (*a)->data.sendtodir.wrap = TRUE;
192 (*a)->data.sendtodir.follow = TRUE;
193 }
194
195 void setup_action_send_to_desktop_left(ObAction **a, ObUserAction uact)
196 {
197 (*a)->data.sendtodir.inter.any.client_action = OB_CLIENT_ACTION_ALWAYS;
198 (*a)->data.sendtodir.inter.any.interactive = TRUE;
199 (*a)->data.sendtodir.dir = OB_DIRECTION_WEST;
200 (*a)->data.sendtodir.linear = FALSE;
201 (*a)->data.sendtodir.wrap = TRUE;
202 (*a)->data.sendtodir.follow = TRUE;
203 }
204
205 void setup_action_send_to_desktop_right(ObAction **a, ObUserAction uact)
206 {
207 (*a)->data.sendtodir.inter.any.client_action = OB_CLIENT_ACTION_ALWAYS;
208 (*a)->data.sendtodir.inter.any.interactive = TRUE;
209 (*a)->data.sendtodir.dir = OB_DIRECTION_EAST;
210 (*a)->data.sendtodir.linear = FALSE;
211 (*a)->data.sendtodir.wrap = TRUE;
212 (*a)->data.sendtodir.follow = TRUE;
213 }
214
215 void setup_action_send_to_desktop_up(ObAction **a, ObUserAction uact)
216 {
217 (*a)->data.sendtodir.inter.any.client_action = OB_CLIENT_ACTION_ALWAYS;
218 (*a)->data.sendtodir.inter.any.interactive = TRUE;
219 (*a)->data.sendtodir.dir = OB_DIRECTION_NORTH;
220 (*a)->data.sendtodir.linear = FALSE;
221 (*a)->data.sendtodir.wrap = TRUE;
222 (*a)->data.sendtodir.follow = TRUE;
223 }
224
225 void setup_action_send_to_desktop_down(ObAction **a, ObUserAction uact)
226 {
227 (*a)->data.sendtodir.inter.any.client_action = OB_CLIENT_ACTION_ALWAYS;
228 (*a)->data.sendtodir.inter.any.interactive = TRUE;
229 (*a)->data.sendtodir.dir = OB_DIRECTION_SOUTH;
230 (*a)->data.sendtodir.linear = FALSE;
231 (*a)->data.sendtodir.wrap = TRUE;
232 (*a)->data.sendtodir.follow = TRUE;
233 }
234
235 void setup_action_desktop(ObAction **a, ObUserAction uact)
236 {
237 (*a)->data.desktop.inter.any.interactive = FALSE;
238 }
239
240 void setup_action_desktop_prev(ObAction **a, ObUserAction uact)
241 {
242 (*a)->data.desktopdir.inter.any.interactive = TRUE;
243 (*a)->data.desktopdir.dir = OB_DIRECTION_WEST;
244 (*a)->data.desktopdir.linear = TRUE;
245 (*a)->data.desktopdir.wrap = TRUE;
246 }
247
248 void setup_action_desktop_next(ObAction **a, ObUserAction uact)
249 {
250 (*a)->data.desktopdir.inter.any.interactive = TRUE;
251 (*a)->data.desktopdir.dir = OB_DIRECTION_EAST;
252 (*a)->data.desktopdir.linear = TRUE;
253 (*a)->data.desktopdir.wrap = TRUE;
254 }
255
256 void setup_action_desktop_left(ObAction **a, ObUserAction uact)
257 {
258 (*a)->data.desktopdir.inter.any.interactive = TRUE;
259 (*a)->data.desktopdir.dir = OB_DIRECTION_WEST;
260 (*a)->data.desktopdir.linear = FALSE;
261 (*a)->data.desktopdir.wrap = TRUE;
262 }
263
264 void setup_action_desktop_right(ObAction **a, ObUserAction uact)
265 {
266 (*a)->data.desktopdir.inter.any.interactive = TRUE;
267 (*a)->data.desktopdir.dir = OB_DIRECTION_EAST;
268 (*a)->data.desktopdir.linear = FALSE;
269 (*a)->data.desktopdir.wrap = TRUE;
270 }
271
272 void setup_action_desktop_up(ObAction **a, ObUserAction uact)
273 {
274 (*a)->data.desktopdir.inter.any.interactive = TRUE;
275 (*a)->data.desktopdir.dir = OB_DIRECTION_NORTH;
276 (*a)->data.desktopdir.linear = FALSE;
277 (*a)->data.desktopdir.wrap = TRUE;
278 }
279
280 void setup_action_desktop_down(ObAction **a, ObUserAction uact)
281 {
282 (*a)->data.desktopdir.inter.any.interactive = TRUE;
283 (*a)->data.desktopdir.dir = OB_DIRECTION_SOUTH;
284 (*a)->data.desktopdir.linear = FALSE;
285 (*a)->data.desktopdir.wrap = TRUE;
286 }
287
288 void setup_action_cycle_windows_next(ObAction **a, ObUserAction uact)
289 {
290 (*a)->data.cycle.inter.any.interactive = TRUE;
291 (*a)->data.cycle.linear = FALSE;
292 (*a)->data.cycle.forward = TRUE;
293 (*a)->data.cycle.dialog = TRUE;
294 }
295
296 void setup_action_cycle_windows_previous(ObAction **a, ObUserAction uact)
297 {
298 (*a)->data.cycle.inter.any.interactive = TRUE;
299 (*a)->data.cycle.linear = FALSE;
300 (*a)->data.cycle.forward = FALSE;
301 (*a)->data.cycle.dialog = TRUE;
302 }
303
304 void setup_action_movetoedge_north(ObAction **a, ObUserAction uact)
305 {
306 (*a)->data.diraction.any.client_action = OB_CLIENT_ACTION_ALWAYS;
307 (*a)->data.diraction.direction = OB_DIRECTION_NORTH;
308 }
309
310 void setup_action_movetoedge_south(ObAction **a, ObUserAction uact)
311 {
312 (*a)->data.diraction.any.client_action = OB_CLIENT_ACTION_ALWAYS;
313 (*a)->data.diraction.direction = OB_DIRECTION_SOUTH;
314 }
315
316 void setup_action_movetoedge_east(ObAction **a, ObUserAction uact)
317 {
318 (*a)->data.diraction.any.client_action = OB_CLIENT_ACTION_ALWAYS;
319 (*a)->data.diraction.direction = OB_DIRECTION_EAST;
320 }
321
322 void setup_action_movetoedge_west(ObAction **a, ObUserAction uact)
323 {
324 (*a)->data.diraction.any.client_action = OB_CLIENT_ACTION_ALWAYS;
325 (*a)->data.diraction.direction = OB_DIRECTION_WEST;
326 }
327
328 void setup_action_growtoedge_north(ObAction **a, ObUserAction uact)
329 {
330 (*a)->data.diraction.any.client_action = OB_CLIENT_ACTION_ALWAYS;
331 (*a)->data.diraction.direction = OB_DIRECTION_NORTH;
332 }
333
334 void setup_action_growtoedge_south(ObAction **a, ObUserAction uact)
335 {
336 (*a)->data.diraction.any.client_action = OB_CLIENT_ACTION_ALWAYS;
337 (*a)->data.diraction.direction = OB_DIRECTION_SOUTH;
338 }
339
340 void setup_action_growtoedge_east(ObAction **a, ObUserAction uact)
341 {
342 (*a)->data.diraction.any.client_action = OB_CLIENT_ACTION_ALWAYS;
343 (*a)->data.diraction.direction = OB_DIRECTION_EAST;
344 }
345
346 void setup_action_growtoedge_west(ObAction **a, ObUserAction uact)
347 {
348 (*a)->data.diraction.any.client_action = OB_CLIENT_ACTION_ALWAYS;
349 (*a)->data.diraction.direction = OB_DIRECTION_WEST;
350 }
351
352 void setup_action_top_layer(ObAction **a, ObUserAction uact)
353 {
354 (*a)->data.layer.any.client_action = OB_CLIENT_ACTION_ALWAYS;
355 (*a)->data.layer.layer = 1;
356 }
357
358 void setup_action_normal_layer(ObAction **a, ObUserAction uact)
359 {
360 (*a)->data.layer.any.client_action = OB_CLIENT_ACTION_ALWAYS;
361 (*a)->data.layer.layer = 0;
362 }
363
364 void setup_action_bottom_layer(ObAction **a, ObUserAction uact)
365 {
366 (*a)->data.layer.any.client_action = OB_CLIENT_ACTION_ALWAYS;
367 (*a)->data.layer.layer = -1;
368 }
369
370 void setup_action_move(ObAction **a, ObUserAction uact)
371 {
372 (*a)->data.moveresize.any.client_action = OB_CLIENT_ACTION_ALWAYS;
373 (*a)->data.moveresize.move = TRUE;
374 (*a)->data.moveresize.keyboard =
375 (uact == OB_USER_ACTION_NONE ||
376 uact == OB_USER_ACTION_KEYBOARD_KEY ||
377 uact == OB_USER_ACTION_MENU_SELECTION);
378 }
379
380 void setup_action_resize(ObAction **a, ObUserAction uact)
381 {
382 (*a)->data.moveresize.any.client_action = OB_CLIENT_ACTION_ALWAYS;
383 (*a)->data.moveresize.move = FALSE;
384 (*a)->data.moveresize.keyboard =
385 (uact == OB_USER_ACTION_NONE ||
386 uact == OB_USER_ACTION_KEYBOARD_KEY ||
387 uact == OB_USER_ACTION_MENU_SELECTION);
388 }
389
390 void setup_action_showmenu(ObAction **a, ObUserAction uact)
391 {
392 (*a)->data.showmenu.any.client_action = OB_CLIENT_ACTION_OPTIONAL;
393 /* you cannot call ShowMenu from inside a menu, cuz the menu code makes
394 assumptions that there is only one menu (and submenus) open at
395 a time! */
396 if (uact == OB_USER_ACTION_MENU_SELECTION) {
397 action_unref(*a);
398 *a = NULL;
399 }
400 }
401
402 void setup_client_action(ObAction **a, ObUserAction uact)
403 {
404 (*a)->data.any.client_action = OB_CLIENT_ACTION_ALWAYS;
405 }
406
407 ActionString actionstrings[] =
408 {
409 {
410 "execute",
411 action_execute,
412 NULL
413 },
414 {
415 "directionalfocusnorth",
416 action_directional_focus,
417 setup_action_directional_focus_north
418 },
419 {
420 "directionalfocuseast",
421 action_directional_focus,
422 setup_action_directional_focus_east
423 },
424 {
425 "directionalfocussouth",
426 action_directional_focus,
427 setup_action_directional_focus_south
428 },
429 {
430 "directionalfocuswest",
431 action_directional_focus,
432 setup_action_directional_focus_west
433 },
434 {
435 "directionalfocusnortheast",
436 action_directional_focus,
437 setup_action_directional_focus_northeast
438 },
439 {
440 "directionalfocussoutheast",
441 action_directional_focus,
442 setup_action_directional_focus_southeast
443 },
444 {
445 "directionalfocussouthwest",
446 action_directional_focus,
447 setup_action_directional_focus_southwest
448 },
449 {
450 "directionalfocusnorthwest",
451 action_directional_focus,
452 setup_action_directional_focus_northwest
453 },
454 {
455 "activate",
456 action_activate,
457 setup_client_action
458 },
459 {
460 "focus",
461 action_focus,
462 setup_client_action
463 },
464 {
465 "unfocus",
466 action_unfocus,
467 setup_client_action
468 },
469 {
470 "iconify",
471 action_iconify,
472 setup_client_action
473 },
474 {
475 "raiselower",
476 action_raiselower,
477 setup_client_action
478 },
479 {
480 "raise",
481 action_raise,
482 setup_client_action
483 },
484 {
485 "lower",
486 action_lower,
487 setup_client_action
488 },
489 {
490 "close",
491 action_close,
492 setup_client_action
493 },
494 {
495 "kill",
496 action_kill,
497 setup_client_action
498 },
499 {
500 "shadelower",
501 action_shadelower,
502 setup_client_action
503 },
504 {
505 "unshaderaise",
506 action_unshaderaise,
507 setup_client_action
508 },
509 {
510 "shade",
511 action_shade,
512 setup_client_action
513 },
514 {
515 "unshade",
516 action_unshade,
517 setup_client_action
518 },
519 {
520 "toggleshade",
521 action_toggle_shade,
522 setup_client_action
523 },
524 {
525 "toggleomnipresent",
526 action_toggle_omnipresent,
527 setup_client_action
528 },
529 {
530 "moverelativehorz",
531 action_move_relative_horz,
532 setup_client_action
533 },
534 {
535 "moverelativevert",
536 action_move_relative_vert,
537 setup_client_action
538 },
539 {
540 "movetocenter",
541 action_move_to_center,
542 setup_client_action
543 },
544 {
545 "resizerelativehorz",
546 action_resize_relative_horz,
547 setup_client_action
548 },
549 {
550 "resizerelativevert",
551 action_resize_relative_vert,
552 setup_client_action
553 },
554 {
555 "maximizefull",
556 action_maximize_full,
557 setup_client_action
558 },
559 {
560 "unmaximizefull",
561 action_unmaximize_full,
562 setup_client_action
563 },
564 {
565 "togglemaximizefull",
566 action_toggle_maximize_full,
567 setup_client_action
568 },
569 {
570 "maximizehorz",
571 action_maximize_horz,
572 setup_client_action
573 },
574 {
575 "unmaximizehorz",
576 action_unmaximize_horz,
577 setup_client_action
578 },
579 {
580 "togglemaximizehorz",
581 action_toggle_maximize_horz,
582 setup_client_action
583 },
584 {
585 "maximizevert",
586 action_maximize_vert,
587 setup_client_action
588 },
589 {
590 "unmaximizevert",
591 action_unmaximize_vert,
592 setup_client_action
593 },
594 {
595 "togglemaximizevert",
596 action_toggle_maximize_vert,
597 setup_client_action
598 },
599 {
600 "togglefullscreen",
601 action_toggle_fullscreen,
602 setup_client_action
603 },
604 {
605 "sendtodesktop",
606 action_send_to_desktop,
607 setup_action_send_to_desktop
608 },
609 {
610 "sendtodesktopnext",
611 action_send_to_desktop_dir,
612 setup_action_send_to_desktop_next
613 },
614 {
615 "sendtodesktopprevious",
616 action_send_to_desktop_dir,
617 setup_action_send_to_desktop_prev
618 },
619 {
620 "sendtodesktopright",
621 action_send_to_desktop_dir,
622 setup_action_send_to_desktop_right
623 },
624 {
625 "sendtodesktopleft",
626 action_send_to_desktop_dir,
627 setup_action_send_to_desktop_left
628 },
629 {
630 "sendtodesktopup",
631 action_send_to_desktop_dir,
632 setup_action_send_to_desktop_up
633 },
634 {
635 "sendtodesktopdown",
636 action_send_to_desktop_dir,
637 setup_action_send_to_desktop_down
638 },
639 {
640 "desktop",
641 action_desktop,
642 setup_action_desktop
643 },
644 {
645 "desktopnext",
646 action_desktop_dir,
647 setup_action_desktop_next
648 },
649 {
650 "desktopprevious",
651 action_desktop_dir,
652 setup_action_desktop_prev
653 },
654 {
655 "desktopright",
656 action_desktop_dir,
657 setup_action_desktop_right
658 },
659 {
660 "desktopleft",
661 action_desktop_dir,
662 setup_action_desktop_left
663 },
664 {
665 "desktopup",
666 action_desktop_dir,
667 setup_action_desktop_up
668 },
669 {
670 "desktopdown",
671 action_desktop_dir,
672 setup_action_desktop_down
673 },
674 {
675 "toggledecorations",
676 action_toggle_decorations,
677 setup_client_action
678 },
679 {
680 "move",
681 action_moveresize,
682 setup_action_move
683 },
684 {
685 "resize",
686 action_moveresize,
687 setup_action_resize
688 },
689 {
690 "toggledockautohide",
691 action_toggle_dockautohide,
692 NULL
693 },
694 {
695 "toggleshowdesktop",
696 action_toggle_show_desktop,
697 NULL
698 },
699 {
700 "showdesktop",
701 action_show_desktop,
702 NULL
703 },
704 {
705 "unshowdesktop",
706 action_unshow_desktop,
707 NULL
708 },
709 {
710 "desktoplast",
711 action_desktop_last,
712 NULL
713 },
714 {
715 "reconfigure",
716 action_reconfigure,
717 NULL
718 },
719 {
720 "restart",
721 action_restart,
722 NULL
723 },
724 {
725 "exit",
726 action_exit,
727 NULL
728 },
729 {
730 "showmenu",
731 action_showmenu,
732 setup_action_showmenu
733 },
734 {
735 "sendtotoplayer",
736 action_send_to_layer,
737 setup_action_top_layer
738 },
739 {
740 "togglealwaysontop",
741 action_toggle_layer,
742 setup_action_top_layer
743 },
744 {
745 "sendtonormallayer",
746 action_send_to_layer,
747 setup_action_normal_layer
748 },
749 {
750 "sendtobottomlayer",
751 action_send_to_layer,
752 setup_action_bottom_layer
753 },
754 {
755 "togglealwaysonbottom",
756 action_toggle_layer,
757 setup_action_bottom_layer
758 },
759 {
760 "nextwindow",
761 action_cycle_windows,
762 setup_action_cycle_windows_next
763 },
764 {
765 "previouswindow",
766 action_cycle_windows,
767 setup_action_cycle_windows_previous
768 },
769 {
770 "movetoedgenorth",
771 action_movetoedge,
772 setup_action_movetoedge_north
773 },
774 {
775 "movetoedgesouth",
776 action_movetoedge,
777 setup_action_movetoedge_south
778 },
779 {
780 "movetoedgewest",
781 action_movetoedge,
782 setup_action_movetoedge_west
783 },
784 {
785 "movetoedgeeast",
786 action_movetoedge,
787 setup_action_movetoedge_east
788 },
789 {
790 "growtoedgenorth",
791 action_growtoedge,
792 setup_action_growtoedge_north
793 },
794 {
795 "growtoedgesouth",
796 action_growtoedge,
797 setup_action_growtoedge_south
798 },
799 {
800 "growtoedgewest",
801 action_growtoedge,
802 setup_action_growtoedge_west
803 },
804 {
805 "growtoedgeeast",
806 action_growtoedge,
807 setup_action_growtoedge_east
808 },
809 {
810 NULL,
811 NULL,
812 NULL
813 }
814 };
815
816 /* only key bindings can be interactive. thus saith the xor.
817 because of how the mouse is grabbed, mouse events dont even get
818 read during interactive events, so no dice! >:) */
819 #define INTERACTIVE_LIMIT(a, uact) \
820 if (uact != OB_USER_ACTION_KEYBOARD_KEY) \
821 a->data.any.interactive = FALSE;
822
823 ObAction *action_from_string(const gchar *name, ObUserAction uact)
824 {
825 ObAction *a = NULL;
826 gboolean exist = FALSE;
827 gint i;
828
829 for (i = 0; actionstrings[i].name; i++)
830 if (!g_ascii_strcasecmp(name, actionstrings[i].name)) {
831 exist = TRUE;
832 a = action_new(actionstrings[i].func);
833 if (actionstrings[i].setup)
834 actionstrings[i].setup(&a, uact);
835 if (a)
836 INTERACTIVE_LIMIT(a, uact);
837 break;
838 }
839 if (!exist)
840 g_warning("Invalid action '%s' requested. No such action exists.",
841 name);
842 if (!a)
843 g_warning("Invalid use of action '%s'. Action will be ignored.", name);
844 return a;
845 }
846
847 ObAction *action_parse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
848 ObUserAction uact)
849 {
850 gchar *actname;
851 ObAction *act = NULL;
852 xmlNodePtr n;
853
854 if (parse_attr_string("name", node, &actname)) {
855 if ((act = action_from_string(actname, uact))) {
856 if (act->func == action_execute || act->func == action_restart) {
857 if ((n = parse_find_node("execute", node->xmlChildrenNode))) {
858 gchar *s = parse_string(doc, n);
859 act->data.execute.path = parse_expand_tilde(s);
860 g_free(s);
861 }
862 } else if (act->func == action_showmenu) {
863 if ((n = parse_find_node("menu", node->xmlChildrenNode)))
864 act->data.showmenu.name = parse_string(doc, n);
865 } else if (act->func == action_move_relative_horz ||
866 act->func == action_move_relative_vert ||
867 act->func == action_resize_relative_horz ||
868 act->func == action_resize_relative_vert) {
869 if ((n = parse_find_node("delta", node->xmlChildrenNode)))
870 act->data.relative.delta = parse_int(doc, n);
871 } else if (act->func == action_desktop) {
872 if ((n = parse_find_node("desktop", node->xmlChildrenNode)))
873 act->data.desktop.desk = parse_int(doc, n);
874 if (act->data.desktop.desk > 0) act->data.desktop.desk--;
875 if ((n = parse_find_node("dialog", node->xmlChildrenNode)))
876 act->data.desktop.inter.any.interactive =
877 parse_bool(doc, n);
878 } else if (act->func == action_send_to_desktop) {
879 if ((n = parse_find_node("desktop", node->xmlChildrenNode)))
880 act->data.sendto.desk = parse_int(doc, n);
881 if (act->data.sendto.desk > 0) act->data.sendto.desk--;
882 if ((n = parse_find_node("follow", node->xmlChildrenNode)))
883 act->data.sendto.follow = parse_bool(doc, n);
884 } else if (act->func == action_desktop_dir) {
885 if ((n = parse_find_node("wrap", node->xmlChildrenNode)))
886 act->data.desktopdir.wrap = parse_bool(doc, n);
887 if ((n = parse_find_node("dialog", node->xmlChildrenNode)))
888 act->data.desktopdir.inter.any.interactive =
889 parse_bool(doc, n);
890 } else if (act->func == action_send_to_desktop_dir) {
891 if ((n = parse_find_node("wrap", node->xmlChildrenNode)))
892 act->data.sendtodir.wrap = parse_bool(doc, n);
893 if ((n = parse_find_node("follow", node->xmlChildrenNode)))
894 act->data.sendtodir.follow = parse_bool(doc, n);
895 if ((n = parse_find_node("dialog", node->xmlChildrenNode)))
896 act->data.sendtodir.inter.any.interactive =
897 parse_bool(doc, n);
898 } else if (act->func == action_activate) {
899 if ((n = parse_find_node("here", node->xmlChildrenNode)))
900 act->data.activate.here = parse_bool(doc, n);
901 } else if (act->func == action_cycle_windows) {
902 if ((n = parse_find_node("linear", node->xmlChildrenNode)))
903 act->data.cycle.linear = parse_bool(doc, n);
904 if ((n = parse_find_node("dialog", node->xmlChildrenNode)))
905 act->data.cycle.dialog = parse_bool(doc, n);
906 } else if (act->func == action_directional_focus) {
907 if ((n = parse_find_node("dialog", node->xmlChildrenNode)))
908 act->data.cycle.dialog = parse_bool(doc, n);
909 } else if (act->func == action_raise ||
910 act->func == action_lower ||
911 act->func == action_raiselower ||
912 act->func == action_shadelower ||
913 act->func == action_unshaderaise) {
914 if ((n = parse_find_node("group", node->xmlChildrenNode)))
915 act->data.stacking.group = parse_bool(doc, n);
916 }
917 INTERACTIVE_LIMIT(act, uact);
918 }
919 g_free(actname);
920 }
921 return act;
922 }
923
924 void action_run_list(GSList *acts, ObClient *c, ObFrameContext context,
925 guint state, guint button, gint x, gint y,
926 gboolean cancel, gboolean done)
927 {
928 GSList *it;
929 ObAction *a;
930 gboolean inter = FALSE;
931
932 if (!acts)
933 return;
934
935 if (x < 0 && y < 0)
936 screen_pointer_pos(&x, &y);
937
938 if (grab_on_keyboard())
939 inter = TRUE;
940 else
941 for (it = acts; it; it = g_slist_next(it)) {
942 a = it->data;
943 if (a->data.any.interactive) {
944 inter = TRUE;
945 break;
946 }
947 }
948
949 if (!inter) {
950 /* sometimes when we execute another app as an action,
951 it won't work right unless we XUngrabKeyboard first,
952 even though we grabbed the key/button Asychronously.
953 e.g. "gnome-panel-control --main-menu" */
954 XUngrabKeyboard(ob_display, event_lasttime);
955 }
956
957 for (it = acts; it; it = g_slist_next(it)) {
958 a = it->data;
959
960 if (!(a->data.any.client_action == OB_CLIENT_ACTION_ALWAYS && !c)) {
961 a->data.any.c = a->data.any.client_action ? c : NULL;
962 a->data.any.context = context;
963 a->data.any.x = x;
964 a->data.any.y = y;
965
966 a->data.any.button = button;
967
968 if (a->data.any.interactive) {
969 a->data.inter.cancel = cancel;
970 a->data.inter.final = done;
971 if (!(cancel || done))
972 if (!keyboard_interactive_grab(state, a->data.any.c, a))
973 continue;
974 }
975
976 /* XXX UGLY HACK race with motion event starting a move and the
977 button release gettnig processed first. answer: don't queue
978 moveresize starts. UGLY HACK XXX */
979 if (a->data.any.interactive || a->func == action_moveresize) {
980 /* interactive actions are not queued */
981 a->func(&a->data);
982 } else
983 ob_main_loop_queue_action(ob_main_loop, a);
984 }
985 }
986 }
987
988 void action_run_string(const gchar *name, struct _ObClient *c)
989 {
990 ObAction *a;
991 GSList *l;
992
993 a = action_from_string(name, OB_USER_ACTION_NONE);
994 g_assert(a);
995
996 l = g_slist_append(NULL, a);
997
998 action_run(l, c, 0);
999 }
1000
1001 void action_execute(union ActionData *data)
1002 {
1003 GError *e = NULL;
1004 gchar *cmd, **argv = 0;
1005 if (data->execute.path) {
1006 cmd = g_filename_from_utf8(data->execute.path, -1, NULL, NULL, NULL);
1007 if (cmd) {
1008 if (!g_shell_parse_argv (cmd, NULL, &argv, &e)) {
1009 g_warning("failed to execute '%s': %s",
1010 cmd, e->message);
1011 g_error_free(e);
1012 } else {
1013 if (!g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH |
1014 G_SPAWN_DO_NOT_REAP_CHILD,
1015 NULL, NULL, NULL, &e)) {
1016 g_warning("failed to execute '%s': %s",
1017 cmd, e->message);
1018 g_error_free(e);
1019 }
1020 g_strfreev(argv);
1021 }
1022 g_free(cmd);
1023 } else {
1024 g_warning("failed to convert '%s' from utf8", data->execute.path);
1025 }
1026 }
1027 }
1028
1029 void action_activate(union ActionData *data)
1030 {
1031 client_activate(data->activate.any.c, data->activate.here);
1032 }
1033
1034 void action_focus(union ActionData *data)
1035 {
1036 /* if using focus_delay, stop the timer now so that focus doesn't go moving
1037 on us */
1038 event_halt_focus_delay();
1039
1040 client_focus(data->client.any.c);
1041 }
1042
1043 void action_unfocus (union ActionData *data)
1044 {
1045 client_unfocus(data->client.any.c);
1046 }
1047
1048 void action_iconify(union ActionData *data)
1049 {
1050 client_action_start(data);
1051 client_iconify(data->client.any.c, TRUE, TRUE);
1052 client_action_end(data);
1053 }
1054
1055 void action_raiselower(union ActionData *data)
1056 {
1057 ObClient *c = data->client.any.c;
1058 GList *it;
1059 gboolean raise = FALSE;
1060
1061 for (it = stacking_list; it; it = g_list_next(it)) {
1062 ObClient *cit = it->data;
1063
1064 if (cit == c) break;
1065 if (client_normal(cit) == client_normal(c) &&
1066 cit->layer == c->layer &&
1067 cit->frame->visible &&
1068 !client_search_transient(c, cit))
1069 {
1070 if (RECT_INTERSECTS_RECT(cit->frame->area, c->frame->area)) {
1071 raise = TRUE;
1072 break;
1073 }
1074 }
1075 }
1076
1077 if (raise)
1078 action_raise(data);
1079 else
1080 action_lower(data);
1081 }
1082
1083 void action_raise(union ActionData *data)
1084 {
1085 client_action_start(data);
1086 stacking_raise(CLIENT_AS_WINDOW(data->client.any.c), data->stacking.group);
1087 client_action_end(data);
1088 }
1089
1090 void action_unshaderaise(union ActionData *data)
1091 {
1092 if (data->client.any.c->shaded)
1093 action_unshade(data);
1094 else
1095 action_raise(data);
1096 }
1097
1098 void action_shadelower(union ActionData *data)
1099 {
1100 if (data->client.any.c->shaded)
1101 action_lower(data);
1102 else
1103 action_shade(data);
1104 }
1105
1106 void action_lower(union ActionData *data)
1107 {
1108 client_action_start(data);
1109 stacking_lower(CLIENT_AS_WINDOW(data->client.any.c), data->stacking.group);
1110 client_action_end(data);
1111 }
1112
1113 void action_close(union ActionData *data)
1114 {
1115 client_close(data->client.any.c);
1116 }
1117
1118 void action_kill(union ActionData *data)
1119 {
1120 client_kill(data->client.any.c);
1121 }
1122
1123 void action_shade(union ActionData *data)
1124 {
1125 client_action_start(data);
1126 client_shade(data->client.any.c, TRUE);
1127 client_action_end(data);
1128 }
1129
1130 void action_unshade(union ActionData *data)
1131 {
1132 client_action_start(data);
1133 client_shade(data->client.any.c, FALSE);
1134 client_action_end(data);
1135 }
1136
1137 void action_toggle_shade(union ActionData *data)
1138 {
1139 client_action_start(data);
1140 client_shade(data->client.any.c, !data->client.any.c->shaded);
1141 client_action_end(data);
1142 }
1143
1144 void action_toggle_omnipresent(union ActionData *data)
1145 {
1146 client_set_desktop(data->client.any.c,
1147 data->client.any.c->desktop == DESKTOP_ALL ?
1148 screen_desktop : DESKTOP_ALL, FALSE);
1149 }
1150
1151 void action_move_relative_horz(union ActionData *data)
1152 {
1153 ObClient *c = data->relative.any.c;
1154 client_action_start(data);
1155 client_move(c, c->area.x + data->relative.delta, c->area.y);
1156 client_action_end(data);
1157 }
1158
1159 void action_move_relative_vert(union ActionData *data)
1160 {
1161 ObClient *c = data->relative.any.c;
1162 client_action_start(data);
1163 client_move(c, c->area.x, c->area.y + data->relative.delta);
1164 client_action_end(data);
1165 }
1166
1167 void action_move_to_center(union ActionData *data)
1168 {
1169 ObClient *c = data->client.any.c;
1170 Rect *area;
1171 area = screen_area_monitor(c->desktop, 0);
1172 client_action_start(data);
1173 client_move(c, area->width / 2 - c->area.width / 2,
1174 area->height / 2 - c->area.height / 2);
1175 client_action_end(data);
1176 }
1177
1178 void action_resize_relative_horz(union ActionData *data)
1179 {
1180 ObClient *c = data->relative.any.c;
1181 client_action_start(data);
1182 client_resize(c,
1183 c->area.width + data->relative.delta * c->size_inc.width,
1184 c->area.height);
1185 client_action_end(data);
1186 }
1187
1188 void action_resize_relative_vert(union ActionData *data)
1189 {
1190 ObClient *c = data->relative.any.c;
1191 if (!c->shaded) {
1192 client_action_start(data);
1193 client_resize(c, c->area.width, c->area.height +
1194 data->relative.delta * c->size_inc.height);
1195 client_action_end(data);
1196 }
1197 }
1198
1199 void action_maximize_full(union ActionData *data)
1200 {
1201 client_action_start(data);
1202 client_maximize(data->client.any.c, TRUE, 0, TRUE);
1203 client_action_end(data);
1204 }
1205
1206 void action_unmaximize_full(union ActionData *data)
1207 {
1208 client_action_start(data);
1209 client_maximize(data->client.any.c, FALSE, 0, TRUE);
1210 client_action_end(data);
1211 }
1212
1213 void action_toggle_maximize_full(union ActionData *data)
1214 {
1215 client_action_start(data);
1216 client_maximize(data->client.any.c,
1217 !(data->client.any.c->max_horz ||
1218 data->client.any.c->max_vert),
1219 0, TRUE);
1220 client_action_end(data);
1221 }
1222
1223 void action_maximize_horz(union ActionData *data)
1224 {
1225 client_action_start(data);
1226 client_maximize(data->client.any.c, TRUE, 1, TRUE);
1227 client_action_end(data);
1228 }
1229
1230 void action_unmaximize_horz(union ActionData *data)
1231 {
1232 client_action_start(data);
1233 client_maximize(data->client.any.c, FALSE, 1, TRUE);
1234 client_action_end(data);
1235 }
1236
1237 void action_toggle_maximize_horz(union ActionData *data)
1238 {
1239 client_action_start(data);
1240 client_maximize(data->client.any.c,
1241 !data->client.any.c->max_horz, 1, TRUE);
1242 client_action_end(data);
1243 }
1244
1245 void action_maximize_vert(union ActionData *data)
1246 {
1247 client_action_start(data);
1248 client_maximize(data->client.any.c, TRUE, 2, TRUE);
1249 client_action_end(data);
1250 }
1251
1252 void action_unmaximize_vert(union ActionData *data)
1253 {
1254 client_action_start(data);
1255 client_maximize(data->client.any.c, FALSE, 2, TRUE);
1256 client_action_end(data);
1257 }
1258
1259 void action_toggle_maximize_vert(union ActionData *data)
1260 {
1261 client_action_start(data);
1262 client_maximize(data->client.any.c,
1263 !data->client.any.c->max_vert, 2, TRUE);
1264 client_action_end(data);
1265 }
1266
1267 void action_toggle_fullscreen(union ActionData *data)
1268 {
1269 client_action_start(data);
1270 client_fullscreen(data->client.any.c,
1271 !(data->client.any.c->fullscreen), TRUE);
1272 client_action_end(data);
1273 }
1274
1275 void action_send_to_desktop(union ActionData *data)
1276 {
1277 ObClient *c = data->sendto.any.c;
1278
1279 if (!client_normal(c)) return;
1280
1281 if (data->sendto.desk < screen_num_desktops ||
1282 data->sendto.desk == DESKTOP_ALL) {
1283 client_set_desktop(c, data->sendto.desk, data->sendto.follow);
1284 if (data->sendto.follow)
1285 screen_set_desktop(data->sendto.desk);
1286 }
1287 }
1288
1289 void action_desktop(union ActionData *data)
1290 {
1291 static guint first = (unsigned) -1;
1292
1293 if (data->inter.any.interactive && first == (unsigned) -1)
1294 first = screen_desktop;
1295
1296 if (!data->inter.any.interactive ||
1297 (!data->inter.cancel && !data->inter.final))
1298 {
1299 if (data->desktop.desk < screen_num_desktops ||
1300 data->desktop.desk == DESKTOP_ALL)
1301 {
1302 screen_set_desktop(data->desktop.desk);
1303 if (data->inter.any.interactive)
1304 screen_desktop_popup(data->desktop.desk, TRUE);
1305 }
1306 } else if (data->inter.cancel) {
1307 screen_set_desktop(first);
1308 }
1309
1310 if (!data->inter.any.interactive || data->inter.final) {
1311 screen_desktop_popup(0, FALSE);
1312 first = (unsigned) -1;
1313 }
1314 }
1315
1316 void action_desktop_dir(union ActionData *data)
1317 {
1318 guint d;
1319
1320 d = screen_cycle_desktop(data->desktopdir.dir,
1321 data->desktopdir.wrap,
1322 data->desktopdir.linear,
1323 data->desktopdir.inter.any.interactive,
1324 data->desktopdir.inter.final,
1325 data->desktopdir.inter.cancel);
1326 if (!data->sendtodir.inter.any.interactive ||
1327 !data->sendtodir.inter.final ||
1328 data->sendtodir.inter.cancel)
1329 {
1330 screen_set_desktop(d);
1331 }
1332 }
1333
1334 void action_send_to_desktop_dir(union ActionData *data)
1335 {
1336 ObClient *c = data->sendtodir.inter.any.c;
1337 guint d;
1338
1339 if (!client_normal(c)) return;
1340
1341 d = screen_cycle_desktop(data->sendtodir.dir, data->sendtodir.wrap,
1342 data->sendtodir.linear,
1343 data->sendtodir.inter.any.interactive,
1344 data->sendtodir.inter.final,
1345 data->sendtodir.inter.cancel);
1346 if (!data->sendtodir.inter.any.interactive ||
1347 !data->sendtodir.inter.final ||
1348 data->sendtodir.inter.cancel)
1349 {
1350 client_set_desktop(c, d, data->sendtodir.follow);
1351 if (data->sendtodir.follow)
1352 screen_set_desktop(d);
1353 }
1354 }
1355
1356 void action_desktop_last(union ActionData *data)
1357 {
1358 screen_set_desktop(screen_last_desktop);
1359 }
1360
1361 void action_toggle_decorations(union ActionData *data)
1362 {
1363 ObClient *c = data->client.any.c;
1364
1365 client_action_start(data);
1366 client_set_undecorated(c, !c->undecorated);
1367 client_action_end(data);
1368 }
1369
1370 static guint32 pick_corner(gint x, gint y, gint cx, gint cy, gint cw, gint ch)
1371 {
1372 if (config_resize_four_corners) {
1373 if (x - cx > cw / 2) {
1374 if (y - cy > ch / 2)
1375 return prop_atoms.net_wm_moveresize_size_bottomright;
1376 else
1377 return prop_atoms.net_wm_moveresize_size_topright;
1378 } else {
1379 if (y - cy > ch / 2)
1380 return prop_atoms.net_wm_moveresize_size_bottomleft;
1381 else
1382 return prop_atoms.net_wm_moveresize_size_topleft;
1383 }
1384 } else {
1385 if (x - cx > cw * 2 / 3) {
1386 if (y - cy > ch * 2 / 3)
1387 return prop_atoms.net_wm_moveresize_size_bottomright;
1388 else if (y - cy < ch / 3)
1389 return prop_atoms.net_wm_moveresize_size_topright;
1390 else
1391 return prop_atoms.net_wm_moveresize_size_right;
1392 } else if (x - cx < cw / 3) {
1393 if (y - cy > ch * 2 / 3)
1394 return prop_atoms.net_wm_moveresize_size_bottomleft;
1395 else if (y - cy < ch / 3)
1396 return prop_atoms.net_wm_moveresize_size_topleft;
1397 else
1398 return prop_atoms.net_wm_moveresize_size_left;
1399 } else
1400 if (y - cy > ch * 2 / 3)
1401 return prop_atoms.net_wm_moveresize_size_bottom;
1402 else if (y - cy < ch / 3)
1403 return prop_atoms.net_wm_moveresize_size_top;
1404 else
1405 return prop_atoms.net_wm_moveresize_move;
1406 }
1407 }
1408
1409 void action_moveresize(union ActionData *data)
1410 {
1411 ObClient *c = data->moveresize.any.c;
1412 guint32 corner;
1413
1414 if (!client_normal(c)) return;
1415
1416 if (data->moveresize.keyboard) {
1417 corner = (data->moveresize.move ?
1418 prop_atoms.net_wm_moveresize_move_keyboard :
1419 prop_atoms.net_wm_moveresize_size_keyboard);
1420 } else {
1421 corner = (data->moveresize.move ?
1422 prop_atoms.net_wm_moveresize_move :
1423 pick_corner(data->any.x, data->any.y,
1424 c->frame->area.x, c->frame->area.y,
1425 /* use the client size because the frame
1426 can be differently sized (shaded
1427 windows) and we want this based on the
1428 clients size */
1429 c->area.width + c->frame->size.left +
1430 c->frame->size.right,
1431 c->area.height + c->frame->size.top +
1432 c->frame->size.bottom));
1433 }
1434
1435 moveresize_start(c, data->any.x, data->any.y, data->any.button, corner);
1436 }
1437
1438 void action_reconfigure(union ActionData *data)
1439 {
1440 ob_reconfigure();
1441 }
1442
1443 void action_restart(union ActionData *data)
1444 {
1445 ob_restart_other(data->execute.path);
1446 }
1447
1448 void action_exit(union ActionData *data)
1449 {
1450 ob_exit(0);
1451 }
1452
1453 void action_showmenu(union ActionData *data)
1454 {
1455 if (data->showmenu.name) {
1456 menu_show(data->showmenu.name, data->any.x, data->any.y,
1457 data->showmenu.any.c);
1458 }
1459 }
1460
1461 void action_cycle_windows(union ActionData *data)
1462 {
1463 /* if using focus_delay, stop the timer now so that focus doesn't go moving
1464 on us */
1465 event_halt_focus_delay();
1466
1467 focus_cycle(data->cycle.forward, data->cycle.linear, data->any.interactive,
1468 data->cycle.dialog,
1469 data->cycle.inter.final, data->cycle.inter.cancel);
1470 }
1471
1472 void action_directional_focus(union ActionData *data)
1473 {
1474 /* if using focus_delay, stop the timer now so that focus doesn't go moving
1475 on us */
1476 event_halt_focus_delay();
1477
1478 focus_directional_cycle(data->interdiraction.direction,
1479 data->any.interactive,
1480 data->interdiraction.dialog,
1481 data->interdiraction.inter.final,
1482 data->interdiraction.inter.cancel);
1483 }
1484
1485 void action_movetoedge(union ActionData *data)
1486 {
1487 gint x, y;
1488 ObClient *c = data->diraction.any.c;
1489
1490 x = c->frame->area.x;
1491 y = c->frame->area.y;
1492
1493 switch(data->diraction.direction) {
1494 case OB_DIRECTION_NORTH:
1495 y = client_directional_edge_search(c, OB_DIRECTION_NORTH);
1496 break;
1497 case OB_DIRECTION_WEST:
1498 x = client_directional_edge_search(c, OB_DIRECTION_WEST);
1499 break;
1500 case OB_DIRECTION_SOUTH:
1501 y = client_directional_edge_search(c, OB_DIRECTION_SOUTH) -
1502 c->frame->area.height;
1503 break;
1504 case OB_DIRECTION_EAST:
1505 x = client_directional_edge_search(c, OB_DIRECTION_EAST) -
1506 c->frame->area.width;
1507 break;
1508 default:
1509 g_assert_not_reached();
1510 }
1511 frame_frame_gravity(c->frame, &x, &y);
1512 client_action_start(data);
1513 client_move(c, x, y);
1514 client_action_end(data);
1515 }
1516
1517 void action_growtoedge(union ActionData *data)
1518 {
1519 gint x, y, width, height, dest;
1520 ObClient *c = data->diraction.any.c;
1521 Rect *a;
1522
1523 //FIXME growtoedge resizes shaded windows to 0 height
1524 if (c->shaded)
1525 return;
1526
1527 a = screen_area(c->desktop);
1528 x = c->frame->area.x;
1529 y = c->frame->area.y;
1530 width = c->frame->area.width;
1531 height = c->frame->area.height;
1532
1533 switch(data->diraction.direction) {
1534 case OB_DIRECTION_NORTH:
1535 dest = client_directional_edge_search(c, OB_DIRECTION_NORTH);
1536 if (a->y == y)
1537 height = c->frame->area.height / 2;
1538 else {
1539 height = c->frame->area.y + c->frame->area.height - dest;
1540 y = dest;
1541 }
1542 break;
1543 case OB_DIRECTION_WEST:
1544 dest = client_directional_edge_search(c, OB_DIRECTION_WEST);
1545 if (a->x == x)
1546 width = c->frame->area.width / 2;
1547 else {
1548 width = c->frame->area.x + c->frame->area.width - dest;
1549 x = dest;
1550 }
1551 break;
1552 case OB_DIRECTION_SOUTH:
1553 dest = client_directional_edge_search(c, OB_DIRECTION_SOUTH);
1554 if (a->y + a->height == y + c->frame->area.height) {
1555 height = c->frame->area.height / 2;
1556 y = a->y + a->height - height;
1557 } else
1558 height = dest - c->frame->area.y;
1559 y += (height - c->frame->area.height) % c->size_inc.height;
1560 height -= (height - c->frame->area.height) % c->size_inc.height;
1561 break;
1562 case OB_DIRECTION_EAST:
1563 dest = client_directional_edge_search(c, OB_DIRECTION_EAST);
1564 if (a->x + a->width == x + c->frame->area.width) {
1565 width = c->frame->area.width / 2;
1566 x = a->x + a->width - width;
1567 } else
1568 width = dest - c->frame->area.x;
1569 x += (width - c->frame->area.width) % c->size_inc.width;
1570 width -= (width - c->frame->area.width) % c->size_inc.width;
1571 break;
1572 default:
1573 g_assert_not_reached();
1574 }
1575 frame_frame_gravity(c->frame, &x, &y);
1576 width -= c->frame->size.left + c->frame->size.right;
1577 height -= c->frame->size.top + c->frame->size.bottom;
1578 client_action_start(data);
1579 client_move_resize(c, x, y, width, height);
1580 client_action_end(data);
1581 }
1582
1583 void action_send_to_layer(union ActionData *data)
1584 {
1585 client_set_layer(data->layer.any.c, data->layer.layer);
1586 }
1587
1588 void action_toggle_layer(union ActionData *data)
1589 {
1590 ObClient *c = data->layer.any.c;
1591
1592 client_action_start(data);
1593 if (data->layer.layer < 0)
1594 client_set_layer(c, c->below ? 0 : -1);
1595 else if (data->layer.layer > 0)
1596 client_set_layer(c, c->above ? 0 : 1);
1597 client_action_end(data);
1598 }
1599
1600 void action_toggle_dockautohide(union ActionData *data)
1601 {
1602 config_dock_hide = !config_dock_hide;
1603 dock_configure();
1604 }
1605
1606 void action_toggle_show_desktop(union ActionData *data)
1607 {
1608 screen_show_desktop(!screen_showing_desktop);
1609 }
1610
1611 void action_show_desktop(union ActionData *data)
1612 {
1613 screen_show_desktop(TRUE);
1614 }
1615
1616 void action_unshow_desktop(union ActionData *data)
1617 {
1618 screen_show_desktop(FALSE);
1619 }
This page took 0.105965 seconds and 4 git commands to generate.