]> icculus.org git repositories - mikachu/openbox.git/blob - openbox/action.c
dont queue up interative end actions
[mikachu/openbox.git] / 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         "resizerelativehorz",
541         action_resize_relative_horz,
542         setup_client_action
543     },
544     {
545         "resizerelativevert",
546         action_resize_relative_vert,
547         setup_client_action
548     },
549     {
550         "maximizefull",
551         action_maximize_full,
552         setup_client_action
553     },
554     {
555         "unmaximizefull",
556         action_unmaximize_full,
557         setup_client_action
558     },
559     {
560         "togglemaximizefull",
561         action_toggle_maximize_full,
562         setup_client_action
563     },
564     {
565         "maximizehorz",
566         action_maximize_horz,
567         setup_client_action
568     },
569     {
570         "unmaximizehorz",
571         action_unmaximize_horz,
572         setup_client_action
573     },
574     {
575         "togglemaximizehorz",
576         action_toggle_maximize_horz,
577         setup_client_action
578     },
579     {
580         "maximizevert",
581         action_maximize_vert,
582         setup_client_action
583     },
584     {
585         "unmaximizevert",
586         action_unmaximize_vert,
587         setup_client_action
588     },
589     {
590         "togglemaximizevert",
591         action_toggle_maximize_vert,
592         setup_client_action
593     },
594     {
595         "sendtodesktop",
596         action_send_to_desktop,
597         setup_action_send_to_desktop
598     },
599     {
600         "sendtodesktopnext",
601         action_send_to_desktop_dir,
602         setup_action_send_to_desktop_next
603     },
604     {
605         "sendtodesktopprevious",
606         action_send_to_desktop_dir,
607         setup_action_send_to_desktop_prev
608     },
609     {
610         "sendtodesktopright",
611         action_send_to_desktop_dir,
612         setup_action_send_to_desktop_right
613     },
614     {
615         "sendtodesktopleft",
616         action_send_to_desktop_dir,
617         setup_action_send_to_desktop_left
618     },
619     {
620         "sendtodesktopup",
621         action_send_to_desktop_dir,
622         setup_action_send_to_desktop_up
623     },
624     {
625         "sendtodesktopdown",
626         action_send_to_desktop_dir,
627         setup_action_send_to_desktop_down
628     },
629     {
630         "desktop",
631         action_desktop,
632         setup_action_desktop
633     },
634     {
635         "desktopnext",
636         action_desktop_dir,
637         setup_action_desktop_next
638     },
639     {
640         "desktopprevious",
641         action_desktop_dir,
642         setup_action_desktop_prev
643     },
644     {
645         "desktopright",
646         action_desktop_dir,
647         setup_action_desktop_right
648     },
649     {
650         "desktopleft",
651         action_desktop_dir,
652         setup_action_desktop_left
653     },
654     {
655         "desktopup",
656         action_desktop_dir,
657         setup_action_desktop_up
658     },
659     {
660         "desktopdown",
661         action_desktop_dir,
662         setup_action_desktop_down
663     },
664     {
665         "toggledecorations",
666         action_toggle_decorations,
667         setup_client_action
668     },
669     {
670         "move",
671         action_moveresize,
672         setup_action_move
673     },
674     {
675         "resize",
676         action_moveresize,
677         setup_action_resize
678     },
679     {
680         "toggleshowdesktop",
681         action_toggle_show_desktop,
682         NULL
683     },
684     {
685         "showdesktop",
686         action_show_desktop,
687         NULL
688     },
689     {
690         "unshowdesktop",
691         action_unshow_desktop,
692         NULL
693     },
694     {
695         "desktoplast",
696         action_desktop_last,
697         NULL
698     },
699     {
700         "reconfigure",
701         action_reconfigure,
702         NULL
703     },
704     {
705         "restart",
706         action_restart,
707         NULL
708     },
709     {
710         "exit",
711         action_exit,
712         NULL
713     },
714     {
715         "showmenu",
716         action_showmenu,
717         setup_action_showmenu
718     },
719     {
720         "sendtotoplayer",
721         action_send_to_layer,
722         setup_action_top_layer
723     },
724     {
725         "togglealwaysontop",
726         action_toggle_layer,
727         setup_action_top_layer
728     },
729     {
730         "sendtonormallayer",
731         action_send_to_layer,
732         setup_action_normal_layer
733     },
734     {
735         "sendtobottomlayer",
736         action_send_to_layer,
737         setup_action_bottom_layer
738     },
739     {
740         "togglealwaysonbottom",
741         action_toggle_layer,
742         setup_action_bottom_layer
743     },
744     {
745         "nextwindow",
746         action_cycle_windows,
747         setup_action_cycle_windows_next
748     },
749     {
750         "previouswindow",
751         action_cycle_windows,
752         setup_action_cycle_windows_previous
753     },
754     {
755         "movetoedgenorth",
756         action_movetoedge,
757         setup_action_movetoedge_north
758     },
759     {
760         "movetoedgesouth",
761         action_movetoedge,
762         setup_action_movetoedge_south
763     },
764     {
765         "movetoedgewest",
766         action_movetoedge,
767         setup_action_movetoedge_west
768     },
769     {
770         "movetoedgeeast",
771         action_movetoedge,
772         setup_action_movetoedge_east
773     },
774     {
775         "growtoedgenorth",
776         action_growtoedge,
777         setup_action_growtoedge_north
778     },
779     {
780         "growtoedgesouth",
781         action_growtoedge,
782         setup_action_growtoedge_south
783     },
784     {
785         "growtoedgewest",
786         action_growtoedge,
787         setup_action_growtoedge_west
788     },
789     {
790         "growtoedgeeast",
791         action_growtoedge,
792         setup_action_growtoedge_east
793     },
794     {
795         NULL,
796         NULL,
797         NULL
798     }
799 };
800
801 /* only key bindings can be interactive. thus saith the xor.
802    because of how the mouse is grabbed, mouse events dont even get
803    read during interactive events, so no dice! >:) */
804 #define INTERACTIVE_LIMIT(a, uact) \
805     if (uact != OB_USER_ACTION_KEYBOARD_KEY) \
806         a->data.any.interactive = FALSE;
807
808 ObAction *action_from_string(const gchar *name, ObUserAction uact)
809 {
810     ObAction *a = NULL;
811     gboolean exist = FALSE;
812     int i;
813
814     for (i = 0; actionstrings[i].name; i++)
815         if (!g_ascii_strcasecmp(name, actionstrings[i].name)) {
816             exist = TRUE;
817             a = action_new(actionstrings[i].func);
818             if (actionstrings[i].setup)
819                 actionstrings[i].setup(&a, uact);
820             INTERACTIVE_LIMIT(a, uact);
821             break;
822         }
823     if (!exist)
824         g_warning("Invalid action '%s' requested. No such action exists.",
825                   name);
826     if (!a)
827         g_warning("Invalid use of action '%s'. Action will be ignored.", name);
828     return a;
829 }
830
831 ObAction *action_parse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
832                        ObUserAction uact)
833 {
834     char *actname;
835     ObAction *act = NULL;
836     xmlNodePtr n;
837
838     if (parse_attr_string("name", node, &actname)) {
839         if ((act = action_from_string(actname, uact))) {
840             if (act->func == action_execute || act->func == action_restart) {
841                 if ((n = parse_find_node("execute", node->xmlChildrenNode))) {
842                     gchar *s = parse_string(doc, n);
843                     act->data.execute.path = parse_expand_tilde(s);
844                     g_free(s);
845                 }
846             } else if (act->func == action_showmenu) {
847                 if ((n = parse_find_node("menu", node->xmlChildrenNode)))
848                     act->data.showmenu.name = parse_string(doc, n);
849             } else if (act->func == action_move_relative_horz ||
850                        act->func == action_move_relative_vert ||
851                        act->func == action_resize_relative_horz ||
852                        act->func == action_resize_relative_vert) {
853                 if ((n = parse_find_node("delta", node->xmlChildrenNode)))
854                     act->data.relative.delta = parse_int(doc, n);
855             } else if (act->func == action_desktop) {
856                 if ((n = parse_find_node("desktop", node->xmlChildrenNode)))
857                     act->data.desktop.desk = parse_int(doc, n);
858                 if (act->data.desktop.desk > 0) act->data.desktop.desk--;
859                 if ((n = parse_find_node("dialog", node->xmlChildrenNode)))
860                     act->data.desktop.inter.any.interactive =
861                         parse_bool(doc, n);
862            } else if (act->func == action_send_to_desktop) {
863                 if ((n = parse_find_node("desktop", node->xmlChildrenNode)))
864                     act->data.sendto.desk = parse_int(doc, n);
865                 if (act->data.sendto.desk > 0) act->data.sendto.desk--;
866                 if ((n = parse_find_node("follow", node->xmlChildrenNode)))
867                     act->data.sendto.follow = parse_bool(doc, n);
868             } else if (act->func == action_desktop_dir) {
869                 if ((n = parse_find_node("wrap", node->xmlChildrenNode)))
870                     act->data.desktopdir.wrap = parse_bool(doc, n); 
871                 if ((n = parse_find_node("dialog", node->xmlChildrenNode)))
872                     act->data.desktopdir.inter.any.interactive =
873                         parse_bool(doc, n);
874             } else if (act->func == action_send_to_desktop_dir) {
875                 if ((n = parse_find_node("wrap", node->xmlChildrenNode)))
876                     act->data.sendtodir.wrap = parse_bool(doc, n);
877                 if ((n = parse_find_node("follow", node->xmlChildrenNode)))
878                     act->data.sendtodir.follow = parse_bool(doc, n);
879                 if ((n = parse_find_node("dialog", node->xmlChildrenNode)))
880                     act->data.sendtodir.inter.any.interactive =
881                         parse_bool(doc, n);
882             } else if (act->func == action_activate) {
883                 if ((n = parse_find_node("here", node->xmlChildrenNode)))
884                     act->data.activate.here = parse_bool(doc, n);
885             } else if (act->func == action_cycle_windows) {
886                 if ((n = parse_find_node("linear", node->xmlChildrenNode)))
887                     act->data.cycle.linear = parse_bool(doc, n);
888                 if ((n = parse_find_node("dialog", node->xmlChildrenNode)))
889                     act->data.cycle.dialog = parse_bool(doc, n);
890             } else if (act->func == action_directional_focus) {
891                 if ((n = parse_find_node("dialog", node->xmlChildrenNode)))
892                     act->data.cycle.dialog = parse_bool(doc, n);
893             }
894         }
895         INTERACTIVE_LIMIT(act, uact);
896         g_free(actname);
897     }
898     return act;
899 }
900
901 void action_run_list(GSList *acts, ObClient *c, ObFrameContext context,
902                      guint state, guint button, gint x, gint y,
903                      gboolean cancel, gboolean done)
904 {
905     GSList *it;
906     ObAction *a;
907     gboolean inter = FALSE;
908
909     if (!acts)
910         return;
911
912     if (x < 0 && y < 0)
913         screen_pointer_pos(&x, &y);
914
915     if (grab_on_keyboard())
916         inter = TRUE;
917     else
918         for (it = acts; it; it = g_slist_next(it)) {
919             a = it->data;
920             if (a->data.any.interactive) {
921                 inter = TRUE;
922                 break;
923             }
924         }
925
926     if (!inter) {
927         /* sometimes when we execute another app as an action,
928            it won't work right unless we XUngrabKeyboard first,
929            even though we grabbed the key/button Asychronously.
930            e.g. "gnome-panel-control --main-menu" */
931         XUngrabKeyboard(ob_display, event_lasttime);
932     }
933
934     for (it = acts; it; it = g_slist_next(it)) {
935         a = it->data;
936
937         if (!(a->data.any.client_action == OB_CLIENT_ACTION_ALWAYS && !c)) {
938             a->data.any.c = a->data.any.client_action ? c : NULL;
939             a->data.any.context = context;
940             a->data.any.x = x;
941             a->data.any.y = y;
942
943             a->data.any.button = button;
944
945             if (a->data.any.interactive) {
946                 a->data.inter.cancel = cancel;
947                 a->data.inter.final = done;
948                 if (!(cancel || done))
949                     keyboard_interactive_grab(state, a->data.any.c, a);
950             }
951
952             /* closing interactive actions are not queued */
953             if (!done)
954                 ob_main_loop_queue_action(ob_main_loop, a);
955             else
956                 a->func(&a->data);
957         }
958     }
959 }
960
961 void action_run_string(const gchar *name, struct _ObClient *c)
962 {
963     ObAction *a;
964     GSList *l;
965
966     a = action_from_string(name, OB_USER_ACTION_NONE);
967     g_assert(a);
968
969     l = g_slist_append(NULL, a);
970
971     action_run(l, c, 0);
972 }
973
974 void action_execute(union ActionData *data)
975 {
976     GError *e = NULL;
977     char *cmd;
978     if (data->execute.path) {
979         cmd = g_filename_from_utf8(data->execute.path, -1, NULL, NULL, NULL);
980         if (cmd) {
981             if (!g_spawn_command_line_async(cmd, &e)) {
982                 g_warning("failed to execute '%s': %s",
983                           cmd, e->message);
984             }
985             g_free(cmd);
986         } else {
987             g_warning("failed to convert '%s' from utf8", data->execute.path);
988         }
989     }
990 }
991
992 void action_activate(union ActionData *data)
993 {
994     client_activate(data->activate.any.c, data->activate.here);
995 }
996
997 void action_focus(union ActionData *data)
998 {
999     client_focus(data->client.any.c);
1000 }
1001
1002 void action_unfocus (union ActionData *data)
1003 {
1004     client_unfocus(data->client.any.c);
1005 }
1006
1007 void action_iconify(union ActionData *data)
1008 {
1009     client_iconify(data->client.any.c, TRUE, TRUE);
1010 }
1011
1012 void action_raiselower(union ActionData *data)
1013 {
1014     ObClient *c = data->client.any.c;
1015     GList *it;
1016     gboolean raise = FALSE;
1017
1018     for (it = stacking_list; it; it = g_list_next(it)) {
1019         ObClient *cit = it->data;
1020
1021         if (cit == c) break;
1022         if (client_normal(cit) == client_normal(c) &&
1023             cit->layer == c->layer &&
1024             cit->frame->visible &&
1025             !client_search_transient(c, cit))
1026         {
1027             if (RECT_INTERSECTS_RECT(cit->frame->area, c->frame->area)) {
1028                 raise = TRUE;
1029                 break;
1030             }
1031         }
1032     }
1033
1034     action_run_string((raise ? "Raise" : "Lower"), c);
1035 }
1036
1037 void action_raise(union ActionData *data)
1038 {
1039     client_action_start(data);
1040     stacking_raise(CLIENT_AS_WINDOW(data->client.any.c));
1041     client_action_end(data);
1042 }
1043
1044 void action_unshaderaise(union ActionData *data)
1045 {
1046     if (data->client.any.c->shaded)
1047         action_run_string("Unshade", data->client.any.c);
1048     else
1049         action_run_string("Raise", data->client.any.c);
1050 }
1051
1052 void action_shadelower(union ActionData *data)
1053 {
1054     if (data->client.any.c->shaded)
1055         action_run_string("Lower", data->client.any.c);
1056     else
1057         action_run_string("Shade", data->client.any.c);
1058 }
1059
1060 void action_lower(union ActionData *data)
1061 {
1062     client_action_start(data);
1063     stacking_lower(CLIENT_AS_WINDOW(data->client.any.c));
1064     client_action_end(data);
1065
1066     focus_order_to_bottom(data->client.any.c);
1067 }
1068
1069 void action_close(union ActionData *data)
1070 {
1071     client_close(data->client.any.c);
1072 }
1073
1074 void action_kill(union ActionData *data)
1075 {
1076     client_kill(data->client.any.c);
1077 }
1078
1079 void action_shade(union ActionData *data)
1080 {
1081     client_action_start(data);
1082     client_shade(data->client.any.c, TRUE);
1083     client_action_end(data);
1084 }
1085
1086 void action_unshade(union ActionData *data)
1087 {
1088     client_action_start(data);
1089     client_shade(data->client.any.c, FALSE);
1090     client_action_end(data);
1091 }
1092
1093 void action_toggle_shade(union ActionData *data)
1094 {
1095     client_action_start(data);
1096     client_shade(data->client.any.c, !data->client.any.c->shaded);
1097     client_action_end(data);
1098 }
1099
1100 void action_toggle_omnipresent(union ActionData *data)
1101
1102     client_set_desktop(data->client.any.c,
1103                        data->client.any.c->desktop == DESKTOP_ALL ?
1104                        screen_desktop : DESKTOP_ALL, FALSE);
1105 }
1106
1107 void action_move_relative_horz(union ActionData *data)
1108 {
1109     ObClient *c = data->relative.any.c;
1110     client_action_start(data);
1111     client_move(c, c->area.x + data->relative.delta, c->area.y);
1112     client_action_end(data);
1113 }
1114
1115 void action_move_relative_vert(union ActionData *data)
1116 {
1117     ObClient *c = data->relative.any.c;
1118     client_action_start(data);
1119     client_move(c, c->area.x, c->area.y + data->relative.delta);
1120     client_action_end(data);
1121 }
1122
1123 void action_resize_relative_horz(union ActionData *data)
1124 {
1125     ObClient *c = data->relative.any.c;
1126     client_action_start(data);
1127     client_resize(c,
1128                   c->area.width + data->relative.delta * c->size_inc.width,
1129                   c->area.height);
1130     client_action_end(data);
1131 }
1132
1133 void action_resize_relative_vert(union ActionData *data)
1134 {
1135     ObClient *c = data->relative.any.c;
1136     if (!c->shaded) {
1137         client_action_start(data);
1138         client_resize(c, c->area.width, c->area.height +
1139                       data->relative.delta * c->size_inc.height);
1140         client_action_end(data);
1141     }
1142 }
1143
1144 void action_maximize_full(union ActionData *data)
1145 {
1146     client_action_start(data);
1147     client_maximize(data->client.any.c, TRUE, 0, TRUE);
1148     client_action_end(data);
1149 }
1150
1151 void action_unmaximize_full(union ActionData *data)
1152 {
1153     client_action_start(data);
1154     client_maximize(data->client.any.c, FALSE, 0, TRUE);
1155     client_action_end(data);
1156 }
1157
1158 void action_toggle_maximize_full(union ActionData *data)
1159 {
1160     client_action_start(data);
1161     client_maximize(data->client.any.c,
1162                     !(data->client.any.c->max_horz ||
1163                       data->client.any.c->max_vert),
1164                     0, TRUE);
1165     client_action_end(data);
1166 }
1167
1168 void action_maximize_horz(union ActionData *data)
1169 {
1170     client_action_start(data);
1171     client_maximize(data->client.any.c, TRUE, 1, TRUE);
1172     client_action_end(data);
1173 }
1174
1175 void action_unmaximize_horz(union ActionData *data)
1176 {
1177     client_action_start(data);
1178     client_maximize(data->client.any.c, FALSE, 1, TRUE);
1179     client_action_end(data);
1180 }
1181
1182 void action_toggle_maximize_horz(union ActionData *data)
1183 {
1184     client_action_start(data);
1185     client_maximize(data->client.any.c,
1186                     !data->client.any.c->max_horz, 1, TRUE);
1187     client_action_end(data);
1188 }
1189
1190 void action_maximize_vert(union ActionData *data)
1191 {
1192     client_action_start(data);
1193     client_maximize(data->client.any.c, TRUE, 2, TRUE);
1194     client_action_end(data);
1195 }
1196
1197 void action_unmaximize_vert(union ActionData *data)
1198 {
1199     client_action_start(data);
1200     client_maximize(data->client.any.c, FALSE, 2, TRUE);
1201     client_action_end(data);
1202 }
1203
1204 void action_toggle_maximize_vert(union ActionData *data)
1205 {
1206     client_action_start(data);
1207     client_maximize(data->client.any.c,
1208                     !data->client.any.c->max_vert, 2, TRUE);
1209     client_action_end(data);
1210 }
1211
1212 void action_send_to_desktop(union ActionData *data)
1213 {
1214     ObClient *c = data->sendto.any.c;
1215
1216     if (!client_normal(c)) return;
1217
1218     if (data->sendto.desk < screen_num_desktops ||
1219         data->sendto.desk == DESKTOP_ALL) {
1220         client_set_desktop(c, data->sendto.desk, data->sendto.follow);
1221         if (data->sendto.follow)
1222             screen_set_desktop(data->sendto.desk);
1223     }
1224 }
1225
1226 void action_desktop(union ActionData *data)
1227 {
1228     static guint first = (unsigned) -1;
1229
1230     if (data->inter.any.interactive && first == (unsigned) -1)
1231         first = screen_desktop;
1232
1233     if (!data->inter.any.interactive ||
1234         (!data->inter.cancel && !data->inter.final))
1235     {
1236         if (data->desktop.desk < screen_num_desktops ||
1237             data->desktop.desk == DESKTOP_ALL)
1238         {
1239             screen_set_desktop(data->desktop.desk);
1240             if (data->inter.any.interactive)
1241                 screen_desktop_popup(data->desktop.desk, TRUE);
1242         }
1243     } else if (data->inter.cancel) {
1244         screen_set_desktop(first);
1245     }
1246
1247     if (!data->inter.any.interactive || data->inter.final) {
1248         screen_desktop_popup(0, FALSE);
1249         first = (unsigned) -1;
1250     }
1251 }
1252
1253 void action_desktop_dir(union ActionData *data)
1254 {
1255     guint d;
1256
1257     d = screen_cycle_desktop(data->desktopdir.dir,
1258                              data->desktopdir.wrap,
1259                              data->desktopdir.linear,
1260                              data->desktopdir.inter.any.interactive,
1261                              data->desktopdir.inter.final,
1262                              data->desktopdir.inter.cancel);
1263     if (!data->sendtodir.inter.any.interactive ||
1264         !data->sendtodir.inter.final ||
1265         data->sendtodir.inter.cancel)
1266     {
1267         screen_set_desktop(d);
1268     }
1269 }
1270
1271 void action_send_to_desktop_dir(union ActionData *data)
1272 {
1273     ObClient *c = data->sendtodir.inter.any.c;
1274     guint d;
1275
1276     if (!client_normal(c)) return;
1277
1278     d = screen_cycle_desktop(data->sendtodir.dir, data->sendtodir.wrap,
1279                              data->sendtodir.linear,
1280                              data->sendtodir.inter.any.interactive,
1281                              data->sendtodir.inter.final,
1282                              data->sendtodir.inter.cancel);
1283     if (!data->sendtodir.inter.any.interactive ||
1284         !data->sendtodir.inter.final ||
1285         data->sendtodir.inter.cancel)
1286     {
1287         client_set_desktop(c, d, data->sendtodir.follow);
1288         if (data->sendtodir.follow)
1289             screen_set_desktop(d);
1290     }
1291 }
1292
1293 void action_desktop_last(union ActionData *data)
1294 {
1295     screen_set_desktop(screen_last_desktop);
1296 }
1297
1298 void action_toggle_decorations(union ActionData *data)
1299 {
1300     ObClient *c = data->client.any.c;
1301
1302     client_action_start(data);
1303     client_set_undecorated(c, !c->undecorated);
1304     client_action_end(data);
1305 }
1306
1307 static guint32 pick_corner(int x, int y, int cx, int cy, int cw, int ch)
1308 {
1309     if (x - cx > cw / 2) {
1310         if (y - cy > ch / 2)
1311             return prop_atoms.net_wm_moveresize_size_bottomright;
1312         else
1313             return prop_atoms.net_wm_moveresize_size_topright;
1314     } else {
1315         if (y - cy > ch / 2)
1316             return prop_atoms.net_wm_moveresize_size_bottomleft;
1317         else
1318             return prop_atoms.net_wm_moveresize_size_topleft;
1319     }
1320 }
1321
1322 void action_moveresize(union ActionData *data)
1323 {
1324     ObClient *c = data->moveresize.any.c;
1325     guint32 corner;
1326
1327     if (!client_normal(c)) return;
1328
1329     if (data->moveresize.keyboard) {
1330         corner = (data->moveresize.move ?
1331                   prop_atoms.net_wm_moveresize_move_keyboard :
1332                   prop_atoms.net_wm_moveresize_size_keyboard);
1333     } else {
1334         corner = (data->moveresize.move ?
1335                   prop_atoms.net_wm_moveresize_move :
1336                   pick_corner(data->any.x, data->any.y,
1337                               c->frame->area.x, c->frame->area.y,
1338                               /* use the client size because the frame
1339                                  can be differently sized (shaded
1340                                  windows) and we want this based on the
1341                                  clients size */
1342                               c->area.width + c->frame->size.left +
1343                               c->frame->size.right,
1344                               c->area.height + c->frame->size.top +
1345                               c->frame->size.bottom));
1346     }
1347
1348     moveresize_start(c, data->any.x, data->any.y, data->any.button, corner);
1349 }
1350
1351 void action_reconfigure(union ActionData *data)
1352 {
1353     ob_reconfigure();
1354 }
1355
1356 void action_restart(union ActionData *data)
1357 {
1358     ob_restart_other(data->execute.path);
1359 }
1360
1361 void action_exit(union ActionData *data)
1362 {
1363     ob_exit(0);
1364 }
1365
1366 void action_showmenu(union ActionData *data)
1367 {
1368     if (data->showmenu.name) {
1369         menu_show(data->showmenu.name, data->any.x, data->any.y,
1370                   data->showmenu.any.c);
1371     }
1372 }
1373
1374 void action_cycle_windows(union ActionData *data)
1375 {
1376     focus_cycle(data->cycle.forward, data->cycle.linear,
1377                 data->cycle.dialog,
1378                 data->cycle.inter.final, data->cycle.inter.cancel);
1379 }
1380
1381 void action_directional_focus(union ActionData *data)
1382 {
1383     focus_directional_cycle(data->interdiraction.direction,
1384                             data->interdiraction.dialog,
1385                             data->interdiraction.inter.final,
1386                             data->interdiraction.inter.cancel);
1387 }
1388
1389 void action_movetoedge(union ActionData *data)
1390 {
1391     int x, y;
1392     ObClient *c = data->diraction.any.c;
1393
1394     x = c->frame->area.x;
1395     y = c->frame->area.y;
1396     
1397     switch(data->diraction.direction) {
1398     case OB_DIRECTION_NORTH:
1399         y = client_directional_edge_search(c, OB_DIRECTION_NORTH);
1400         break;
1401     case OB_DIRECTION_WEST:
1402         x = client_directional_edge_search(c, OB_DIRECTION_WEST);
1403         break;
1404     case OB_DIRECTION_SOUTH:
1405         y = client_directional_edge_search(c, OB_DIRECTION_SOUTH) -
1406             c->frame->area.height;
1407         break;
1408     case OB_DIRECTION_EAST:
1409         x = client_directional_edge_search(c, OB_DIRECTION_EAST) -
1410             c->frame->area.width;
1411         break;
1412     default:
1413         g_assert_not_reached();
1414     }
1415     frame_frame_gravity(c->frame, &x, &y);
1416     client_action_start(data);
1417     client_move(c, x, y);
1418     client_action_end(data);
1419 }
1420
1421 void action_growtoedge(union ActionData *data)
1422 {
1423     int x, y, width, height, dest;
1424     ObClient *c = data->diraction.any.c;
1425     Rect *a;
1426
1427     a = screen_area(c->desktop);
1428     x = c->frame->area.x;
1429     y = c->frame->area.y;
1430     width = c->frame->area.width;
1431     height = c->frame->area.height;
1432
1433     switch(data->diraction.direction) {
1434     case OB_DIRECTION_NORTH:
1435         dest = client_directional_edge_search(c, OB_DIRECTION_NORTH);
1436         if (a->y == y)
1437             height = c->frame->area.height / 2;
1438         else {
1439             height = c->frame->area.y + c->frame->area.height - dest;
1440             y = dest;
1441         }
1442         break;
1443     case OB_DIRECTION_WEST:
1444         dest = client_directional_edge_search(c, OB_DIRECTION_WEST);
1445         if (a->x == x)
1446             width = c->frame->area.width / 2;
1447         else {
1448             width = c->frame->area.x + c->frame->area.width - dest;
1449             x = dest;
1450         }
1451         break;
1452     case OB_DIRECTION_SOUTH:
1453         dest = client_directional_edge_search(c, OB_DIRECTION_SOUTH);
1454         if (a->y + a->height == y + c->frame->area.height) {
1455             height = c->frame->area.height / 2;
1456             y = a->y + a->height - height;
1457         } else
1458             height = dest - c->frame->area.y;
1459         y += (height - c->frame->area.height) % c->size_inc.height;
1460         height -= (height - c->frame->area.height) % c->size_inc.height;
1461         break;
1462     case OB_DIRECTION_EAST:
1463         dest = client_directional_edge_search(c, OB_DIRECTION_EAST);
1464         if (a->x + a->width == x + c->frame->area.width) {
1465             width = c->frame->area.width / 2;
1466             x = a->x + a->width - width;
1467         } else
1468             width = dest - c->frame->area.x;
1469         x += (width - c->frame->area.width) % c->size_inc.width;
1470         width -= (width - c->frame->area.width) % c->size_inc.width;
1471         break;
1472     default:
1473         g_assert_not_reached();
1474     }
1475     frame_frame_gravity(c->frame, &x, &y);
1476     width -= c->frame->size.left + c->frame->size.right;
1477     height -= c->frame->size.top + c->frame->size.bottom;
1478     client_action_start(data);
1479     client_move_resize(c, x, y, width, height);
1480     client_action_end(data);
1481 }
1482
1483 void action_send_to_layer(union ActionData *data)
1484 {
1485     client_set_layer(data->layer.any.c, data->layer.layer);
1486 }
1487
1488 void action_toggle_layer(union ActionData *data)
1489 {
1490     ObClient *c = data->layer.any.c;
1491
1492     client_action_start(data);
1493     if (data->layer.layer < 0)
1494         client_set_layer(c, c->below ? 0 : -1);
1495     else if (data->layer.layer > 0)
1496         client_set_layer(c, c->above ? 0 : 1);
1497     client_action_end(data);
1498 }
1499
1500 void action_toggle_show_desktop(union ActionData *data)
1501 {
1502     screen_show_desktop(!screen_showing_desktop);
1503 }
1504
1505 void action_show_desktop(union ActionData *data)
1506 {
1507     screen_show_desktop(TRUE);
1508 }
1509
1510 void action_unshow_desktop(union ActionData *data)
1511 {
1512     screen_show_desktop(FALSE);
1513 }