1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 action.c for the Openbox window manager
4 Copyright (c) 2006 Mikael Magnusson
5 Copyright (c) 2003 Ben Jansens
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 See the COPYING file for a copy of the GNU General Public License.
23 #include "moveresize.h"
36 #include "startupnotify.h"
40 inline void client_action_start(union ActionData
*data
)
42 if (config_focus_follow
)
43 if (data
->any
.context
!= OB_FRAME_CONTEXT_CLIENT
&& !data
->any
.button
)
44 grab_pointer(TRUE
, OB_CURSOR_NONE
);
47 inline void client_action_end(union ActionData
*data
)
49 if (config_focus_follow
)
50 if (data
->any
.context
!= OB_FRAME_CONTEXT_CLIENT
) {
51 if (!data
->any
.button
) {
52 grab_pointer(FALSE
, OB_CURSOR_NONE
);
56 /* usually this is sorta redundant, but with a press action
57 the enter event will come as a GrabNotify which is
58 ignored, so this will handle that case */
59 if ((c
= client_under_pointer()))
60 event_enter_client(c
);
68 void (*func
)(union ActionData
*);
69 void (*setup
)(ObAction
**, ObUserAction uact
);
72 static ObAction
*action_new(void (*func
)(union ActionData
*data
))
74 ObAction
*a
= g_new0(ObAction
, 1);
81 void action_ref(ObAction
*a
)
86 void action_unref(ObAction
*a
)
88 if (a
== NULL
) return;
90 if (--a
->ref
> 0) return;
92 /* deal with pointers */
93 if (a
->func
== action_execute
|| a
->func
== action_restart
)
94 g_free(a
->data
.execute
.path
);
95 else if (a
->func
== action_showmenu
)
96 g_free(a
->data
.showmenu
.name
);
101 ObAction
* action_copy(const ObAction
*src
)
103 ObAction
*a
= action_new(src
->func
);
107 /* deal with pointers */
108 if (a
->func
== action_execute
|| a
->func
== action_restart
)
109 a
->data
.execute
.path
= g_strdup(a
->data
.execute
.path
);
110 else if (a
->func
== action_showmenu
)
111 a
->data
.showmenu
.name
= g_strdup(a
->data
.showmenu
.name
);
116 void setup_action_directional_focus_north(ObAction
**a
, ObUserAction uact
)
118 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
119 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_NORTH
;
120 (*a
)->data
.interdiraction
.dialog
= TRUE
;
123 void setup_action_directional_focus_east(ObAction
**a
, ObUserAction uact
)
125 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
126 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_EAST
;
127 (*a
)->data
.interdiraction
.dialog
= TRUE
;
130 void setup_action_directional_focus_south(ObAction
**a
, ObUserAction uact
)
132 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
133 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_SOUTH
;
134 (*a
)->data
.interdiraction
.dialog
= TRUE
;
137 void setup_action_directional_focus_west(ObAction
**a
, ObUserAction uact
)
139 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
140 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_WEST
;
141 (*a
)->data
.interdiraction
.dialog
= TRUE
;
144 void setup_action_directional_focus_northeast(ObAction
**a
, ObUserAction uact
)
146 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
147 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_NORTHEAST
;
148 (*a
)->data
.interdiraction
.dialog
= TRUE
;
151 void setup_action_directional_focus_southeast(ObAction
**a
, ObUserAction uact
)
153 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
154 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_SOUTHEAST
;
155 (*a
)->data
.interdiraction
.dialog
= TRUE
;
158 void setup_action_directional_focus_southwest(ObAction
**a
, ObUserAction uact
)
160 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
161 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_SOUTHWEST
;
162 (*a
)->data
.interdiraction
.dialog
= TRUE
;
165 void setup_action_directional_focus_northwest(ObAction
**a
, ObUserAction uact
)
167 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
168 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_NORTHWEST
;
169 (*a
)->data
.interdiraction
.dialog
= TRUE
;
172 void setup_action_send_to_desktop(ObAction
**a
, ObUserAction uact
)
174 (*a
)->data
.sendto
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
175 (*a
)->data
.sendto
.follow
= TRUE
;
178 void setup_action_send_to_desktop_prev(ObAction
**a
, ObUserAction uact
)
180 (*a
)->data
.sendtodir
.inter
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
181 (*a
)->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
182 (*a
)->data
.sendtodir
.dir
= OB_DIRECTION_WEST
;
183 (*a
)->data
.sendtodir
.linear
= TRUE
;
184 (*a
)->data
.sendtodir
.wrap
= TRUE
;
185 (*a
)->data
.sendtodir
.follow
= TRUE
;
188 void setup_action_send_to_desktop_next(ObAction
**a
, ObUserAction uact
)
190 (*a
)->data
.sendtodir
.inter
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
191 (*a
)->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
192 (*a
)->data
.sendtodir
.dir
= OB_DIRECTION_EAST
;
193 (*a
)->data
.sendtodir
.linear
= TRUE
;
194 (*a
)->data
.sendtodir
.wrap
= TRUE
;
195 (*a
)->data
.sendtodir
.follow
= TRUE
;
198 void setup_action_send_to_desktop_left(ObAction
**a
, ObUserAction uact
)
200 (*a
)->data
.sendtodir
.inter
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
201 (*a
)->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
202 (*a
)->data
.sendtodir
.dir
= OB_DIRECTION_WEST
;
203 (*a
)->data
.sendtodir
.linear
= FALSE
;
204 (*a
)->data
.sendtodir
.wrap
= TRUE
;
205 (*a
)->data
.sendtodir
.follow
= TRUE
;
208 void setup_action_send_to_desktop_right(ObAction
**a
, ObUserAction uact
)
210 (*a
)->data
.sendtodir
.inter
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
211 (*a
)->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
212 (*a
)->data
.sendtodir
.dir
= OB_DIRECTION_EAST
;
213 (*a
)->data
.sendtodir
.linear
= FALSE
;
214 (*a
)->data
.sendtodir
.wrap
= TRUE
;
215 (*a
)->data
.sendtodir
.follow
= TRUE
;
218 void setup_action_send_to_desktop_up(ObAction
**a
, ObUserAction uact
)
220 (*a
)->data
.sendtodir
.inter
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
221 (*a
)->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
222 (*a
)->data
.sendtodir
.dir
= OB_DIRECTION_NORTH
;
223 (*a
)->data
.sendtodir
.linear
= FALSE
;
224 (*a
)->data
.sendtodir
.wrap
= TRUE
;
225 (*a
)->data
.sendtodir
.follow
= TRUE
;
228 void setup_action_send_to_desktop_down(ObAction
**a
, ObUserAction uact
)
230 (*a
)->data
.sendtodir
.inter
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
231 (*a
)->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
232 (*a
)->data
.sendtodir
.dir
= OB_DIRECTION_SOUTH
;
233 (*a
)->data
.sendtodir
.linear
= FALSE
;
234 (*a
)->data
.sendtodir
.wrap
= TRUE
;
235 (*a
)->data
.sendtodir
.follow
= TRUE
;
238 void setup_action_desktop(ObAction
**a
, ObUserAction uact
)
240 (*a
)->data
.desktop
.inter
.any
.interactive
= FALSE
;
243 void setup_action_desktop_prev(ObAction
**a
, ObUserAction uact
)
245 (*a
)->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
246 (*a
)->data
.desktopdir
.dir
= OB_DIRECTION_WEST
;
247 (*a
)->data
.desktopdir
.linear
= TRUE
;
248 (*a
)->data
.desktopdir
.wrap
= TRUE
;
251 void setup_action_desktop_next(ObAction
**a
, ObUserAction uact
)
253 (*a
)->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
254 (*a
)->data
.desktopdir
.dir
= OB_DIRECTION_EAST
;
255 (*a
)->data
.desktopdir
.linear
= TRUE
;
256 (*a
)->data
.desktopdir
.wrap
= TRUE
;
259 void setup_action_desktop_left(ObAction
**a
, ObUserAction uact
)
261 (*a
)->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
262 (*a
)->data
.desktopdir
.dir
= OB_DIRECTION_WEST
;
263 (*a
)->data
.desktopdir
.linear
= FALSE
;
264 (*a
)->data
.desktopdir
.wrap
= TRUE
;
267 void setup_action_desktop_right(ObAction
**a
, ObUserAction uact
)
269 (*a
)->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
270 (*a
)->data
.desktopdir
.dir
= OB_DIRECTION_EAST
;
271 (*a
)->data
.desktopdir
.linear
= FALSE
;
272 (*a
)->data
.desktopdir
.wrap
= TRUE
;
275 void setup_action_desktop_up(ObAction
**a
, ObUserAction uact
)
277 (*a
)->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
278 (*a
)->data
.desktopdir
.dir
= OB_DIRECTION_NORTH
;
279 (*a
)->data
.desktopdir
.linear
= FALSE
;
280 (*a
)->data
.desktopdir
.wrap
= TRUE
;
283 void setup_action_desktop_down(ObAction
**a
, ObUserAction uact
)
285 (*a
)->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
286 (*a
)->data
.desktopdir
.dir
= OB_DIRECTION_SOUTH
;
287 (*a
)->data
.desktopdir
.linear
= FALSE
;
288 (*a
)->data
.desktopdir
.wrap
= TRUE
;
291 void setup_action_cycle_windows_next(ObAction
**a
, ObUserAction uact
)
293 (*a
)->data
.cycle
.inter
.any
.interactive
= TRUE
;
294 (*a
)->data
.cycle
.linear
= FALSE
;
295 (*a
)->data
.cycle
.forward
= TRUE
;
296 (*a
)->data
.cycle
.dialog
= TRUE
;
299 void setup_action_cycle_windows_previous(ObAction
**a
, ObUserAction uact
)
301 (*a
)->data
.cycle
.inter
.any
.interactive
= TRUE
;
302 (*a
)->data
.cycle
.linear
= FALSE
;
303 (*a
)->data
.cycle
.forward
= FALSE
;
304 (*a
)->data
.cycle
.dialog
= TRUE
;
307 void setup_action_movefromedge_north(ObAction
**a
, ObUserAction uact
)
309 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
310 (*a
)->data
.diraction
.direction
= OB_DIRECTION_NORTH
;
311 (*a
)->data
.diraction
.hang
= TRUE
;
314 void setup_action_movefromedge_south(ObAction
**a
, ObUserAction uact
)
316 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
317 (*a
)->data
.diraction
.direction
= OB_DIRECTION_SOUTH
;
318 (*a
)->data
.diraction
.hang
= TRUE
;
321 void setup_action_movefromedge_east(ObAction
**a
, ObUserAction uact
)
323 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
324 (*a
)->data
.diraction
.direction
= OB_DIRECTION_EAST
;
325 (*a
)->data
.diraction
.hang
= TRUE
;
328 void setup_action_movefromedge_west(ObAction
**a
, ObUserAction uact
)
330 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
331 (*a
)->data
.diraction
.direction
= OB_DIRECTION_WEST
;
332 (*a
)->data
.diraction
.hang
= TRUE
;
335 void setup_action_movetoedge_north(ObAction
**a
, ObUserAction uact
)
337 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
338 (*a
)->data
.diraction
.direction
= OB_DIRECTION_NORTH
;
339 (*a
)->data
.diraction
.hang
= FALSE
;
342 void setup_action_movetoedge_south(ObAction
**a
, ObUserAction uact
)
344 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
345 (*a
)->data
.diraction
.direction
= OB_DIRECTION_SOUTH
;
346 (*a
)->data
.diraction
.hang
= FALSE
;
349 void setup_action_movetoedge_east(ObAction
**a
, ObUserAction uact
)
351 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
352 (*a
)->data
.diraction
.direction
= OB_DIRECTION_EAST
;
353 (*a
)->data
.diraction
.hang
= FALSE
;
356 void setup_action_movetoedge_west(ObAction
**a
, ObUserAction uact
)
358 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
359 (*a
)->data
.diraction
.direction
= OB_DIRECTION_WEST
;
360 (*a
)->data
.diraction
.hang
= FALSE
;
363 void setup_action_growtoedge_north(ObAction
**a
, ObUserAction uact
)
365 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
366 (*a
)->data
.diraction
.direction
= OB_DIRECTION_NORTH
;
369 void setup_action_growtoedge_south(ObAction
**a
, ObUserAction uact
)
371 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
372 (*a
)->data
.diraction
.direction
= OB_DIRECTION_SOUTH
;
375 void setup_action_growtoedge_east(ObAction
**a
, ObUserAction uact
)
377 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
378 (*a
)->data
.diraction
.direction
= OB_DIRECTION_EAST
;
381 void setup_action_growtoedge_west(ObAction
**a
, ObUserAction uact
)
383 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
384 (*a
)->data
.diraction
.direction
= OB_DIRECTION_WEST
;
387 void setup_action_top_layer(ObAction
**a
, ObUserAction uact
)
389 (*a
)->data
.layer
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
390 (*a
)->data
.layer
.layer
= 1;
393 void setup_action_normal_layer(ObAction
**a
, ObUserAction uact
)
395 (*a
)->data
.layer
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
396 (*a
)->data
.layer
.layer
= 0;
399 void setup_action_bottom_layer(ObAction
**a
, ObUserAction uact
)
401 (*a
)->data
.layer
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
402 (*a
)->data
.layer
.layer
= -1;
405 void setup_action_move(ObAction
**a
, ObUserAction uact
)
407 (*a
)->data
.moveresize
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
408 (*a
)->data
.moveresize
.move
= TRUE
;
409 (*a
)->data
.moveresize
.keyboard
=
410 (uact
== OB_USER_ACTION_NONE
||
411 uact
== OB_USER_ACTION_KEYBOARD_KEY
||
412 uact
== OB_USER_ACTION_MENU_SELECTION
);
415 void setup_action_resize(ObAction
**a
, ObUserAction uact
)
417 (*a
)->data
.moveresize
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
418 (*a
)->data
.moveresize
.move
= FALSE
;
419 (*a
)->data
.moveresize
.keyboard
=
420 (uact
== OB_USER_ACTION_NONE
||
421 uact
== OB_USER_ACTION_KEYBOARD_KEY
||
422 uact
== OB_USER_ACTION_MENU_SELECTION
);
425 void setup_action_showmenu(ObAction
**a
, ObUserAction uact
)
427 (*a
)->data
.showmenu
.any
.client_action
= OB_CLIENT_ACTION_OPTIONAL
;
428 /* you cannot call ShowMenu from inside a menu, cuz the menu code makes
429 assumptions that there is only one menu (and submenus) open at
431 if (uact
== OB_USER_ACTION_MENU_SELECTION
) {
437 void setup_client_action(ObAction
**a
, ObUserAction uact
)
439 (*a
)->data
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
442 ActionString actionstrings
[] =
450 "directionalfocusnorth",
451 action_directional_focus
,
452 setup_action_directional_focus_north
455 "directionalfocuseast",
456 action_directional_focus
,
457 setup_action_directional_focus_east
460 "directionalfocussouth",
461 action_directional_focus
,
462 setup_action_directional_focus_south
465 "directionalfocuswest",
466 action_directional_focus
,
467 setup_action_directional_focus_west
470 "directionalfocusnortheast",
471 action_directional_focus
,
472 setup_action_directional_focus_northeast
475 "directionalfocussoutheast",
476 action_directional_focus
,
477 setup_action_directional_focus_southeast
480 "directionalfocussouthwest",
481 action_directional_focus
,
482 setup_action_directional_focus_southwest
485 "directionalfocusnorthwest",
486 action_directional_focus
,
487 setup_action_directional_focus_northwest
511 action_focus_order_to_bottom
,
566 action_toggle_omnipresent
,
571 action_move_relative_horz
,
576 action_move_relative_vert
,
581 action_move_to_center
,
585 "resizerelativehorz",
586 action_resize_relative_horz
,
590 "resizerelativevert",
591 action_resize_relative_vert
,
596 action_move_relative
,
601 action_resize_relative
,
606 action_maximize_full
,
611 action_unmaximize_full
,
615 "togglemaximizefull",
616 action_toggle_maximize_full
,
621 action_maximize_horz
,
626 action_unmaximize_horz
,
630 "togglemaximizehorz",
631 action_toggle_maximize_horz
,
636 action_maximize_vert
,
641 action_unmaximize_vert
,
645 "togglemaximizevert",
646 action_toggle_maximize_vert
,
651 action_toggle_fullscreen
,
656 action_send_to_desktop
,
657 setup_action_send_to_desktop
661 action_send_to_desktop_dir
,
662 setup_action_send_to_desktop_next
665 "sendtodesktopprevious",
666 action_send_to_desktop_dir
,
667 setup_action_send_to_desktop_prev
670 "sendtodesktopright",
671 action_send_to_desktop_dir
,
672 setup_action_send_to_desktop_right
676 action_send_to_desktop_dir
,
677 setup_action_send_to_desktop_left
681 action_send_to_desktop_dir
,
682 setup_action_send_to_desktop_up
686 action_send_to_desktop_dir
,
687 setup_action_send_to_desktop_down
697 setup_action_desktop_next
702 setup_action_desktop_prev
707 setup_action_desktop_right
712 setup_action_desktop_left
717 setup_action_desktop_up
722 setup_action_desktop_down
726 action_toggle_decorations
,
740 "toggledockautohide",
741 action_toggle_dockautohide
,
746 action_toggle_show_desktop
,
756 action_unshow_desktop
,
782 setup_action_showmenu
786 action_send_to_layer
,
787 setup_action_top_layer
792 setup_action_top_layer
796 action_send_to_layer
,
797 setup_action_normal_layer
801 action_send_to_layer
,
802 setup_action_bottom_layer
805 "togglealwaysonbottom",
807 setup_action_bottom_layer
811 action_cycle_windows
,
812 setup_action_cycle_windows_next
816 action_cycle_windows
,
817 setup_action_cycle_windows_previous
822 setup_action_movefromedge_north
827 setup_action_movefromedge_south
832 setup_action_movefromedge_west
837 setup_action_movefromedge_east
842 setup_action_movetoedge_north
847 setup_action_movetoedge_south
852 setup_action_movetoedge_west
857 setup_action_movetoedge_east
862 setup_action_growtoedge_north
867 setup_action_growtoedge_south
872 setup_action_growtoedge_west
877 setup_action_growtoedge_east
886 /* only key bindings can be interactive. thus saith the xor.
887 because of how the mouse is grabbed, mouse events dont even get
888 read during interactive events, so no dice! >:) */
889 #define INTERACTIVE_LIMIT(a, uact) \
890 if (uact != OB_USER_ACTION_KEYBOARD_KEY) \
891 a->data.any.interactive = FALSE;
893 ObAction
*action_from_string(const gchar
*name
, ObUserAction uact
)
896 gboolean exist
= FALSE
;
899 for (i
= 0; actionstrings
[i
].name
; i
++)
900 if (!g_ascii_strcasecmp(name
, actionstrings
[i
].name
)) {
902 a
= action_new(actionstrings
[i
].func
);
903 if (actionstrings
[i
].setup
)
904 actionstrings
[i
].setup(&a
, uact
);
906 INTERACTIVE_LIMIT(a
, uact
);
910 g_warning("Invalid action '%s' requested. No such action exists.",
913 g_warning("Invalid use of action '%s'. Action will be ignored.", name
);
917 ObAction
*action_parse(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
921 ObAction
*act
= NULL
;
924 if (parse_attr_string("name", node
, &actname
)) {
925 if ((act
= action_from_string(actname
, uact
))) {
926 if (act
->func
== action_execute
|| act
->func
== action_restart
) {
927 if ((n
= parse_find_node("execute", node
->xmlChildrenNode
))) {
928 gchar
*s
= parse_string(doc
, n
);
929 act
->data
.execute
.path
= parse_expand_tilde(s
);
932 if ((n
= parse_find_node("startupnotify", node
->xmlChildrenNode
))) {
934 if ((m
= parse_find_node("enabled", n
->xmlChildrenNode
)))
935 act
->data
.execute
.startupnotify
= parse_bool(doc
, m
);
936 if ((m
= parse_find_node("name", n
->xmlChildrenNode
)))
937 act
->data
.execute
.name
= parse_string(doc
, m
);
938 if ((m
= parse_find_node("icon", n
->xmlChildrenNode
)))
939 act
->data
.execute
.icon_name
= parse_string(doc
, m
);
941 } else if (act
->func
== action_showmenu
) {
942 if ((n
= parse_find_node("menu", node
->xmlChildrenNode
)))
943 act
->data
.showmenu
.name
= parse_string(doc
, n
);
944 } else if (act
->func
== action_move_relative_horz
||
945 act
->func
== action_move_relative_vert
||
946 act
->func
== action_resize_relative_horz
||
947 act
->func
== action_resize_relative_vert
) {
948 if ((n
= parse_find_node("delta", node
->xmlChildrenNode
)))
949 act
->data
.relative
.deltax
= parse_int(doc
, n
);
950 } else if (act
->func
== action_move_relative
) {
951 if ((n
= parse_find_node("x", node
->xmlChildrenNode
)))
952 act
->data
.relative
.deltax
= parse_int(doc
, n
);
953 if ((n
= parse_find_node("y", node
->xmlChildrenNode
)))
954 act
->data
.relative
.deltay
= parse_int(doc
, n
);
955 } else if (act
->func
== action_resize_relative
) {
956 if ((n
= parse_find_node("left", node
->xmlChildrenNode
)))
957 act
->data
.relative
.deltaxl
= parse_int(doc
, n
);
958 if ((n
= parse_find_node("up", node
->xmlChildrenNode
)))
959 act
->data
.relative
.deltayu
= parse_int(doc
, n
);
960 if ((n
= parse_find_node("right", node
->xmlChildrenNode
)))
961 act
->data
.relative
.deltax
= parse_int(doc
, n
);
962 if ((n
= parse_find_node("down", node
->xmlChildrenNode
)))
963 act
->data
.relative
.deltay
= parse_int(doc
, n
);
964 } else if (act
->func
== action_desktop
) {
965 if ((n
= parse_find_node("desktop", node
->xmlChildrenNode
)))
966 act
->data
.desktop
.desk
= parse_int(doc
, n
);
967 if (act
->data
.desktop
.desk
> 0) act
->data
.desktop
.desk
--;
968 if ((n
= parse_find_node("dialog", node
->xmlChildrenNode
)))
969 act
->data
.desktop
.inter
.any
.interactive
=
971 } else if (act
->func
== action_send_to_desktop
) {
972 if ((n
= parse_find_node("desktop", node
->xmlChildrenNode
)))
973 act
->data
.sendto
.desk
= parse_int(doc
, n
);
974 if (act
->data
.sendto
.desk
> 0) act
->data
.sendto
.desk
--;
975 if ((n
= parse_find_node("follow", node
->xmlChildrenNode
)))
976 act
->data
.sendto
.follow
= parse_bool(doc
, n
);
977 } else if (act
->func
== action_desktop_dir
) {
978 if ((n
= parse_find_node("wrap", node
->xmlChildrenNode
)))
979 act
->data
.desktopdir
.wrap
= parse_bool(doc
, n
);
980 if ((n
= parse_find_node("dialog", node
->xmlChildrenNode
)))
981 act
->data
.desktopdir
.inter
.any
.interactive
=
983 } else if (act
->func
== action_send_to_desktop_dir
) {
984 if ((n
= parse_find_node("wrap", node
->xmlChildrenNode
)))
985 act
->data
.sendtodir
.wrap
= parse_bool(doc
, n
);
986 if ((n
= parse_find_node("follow", node
->xmlChildrenNode
)))
987 act
->data
.sendtodir
.follow
= parse_bool(doc
, n
);
988 if ((n
= parse_find_node("dialog", node
->xmlChildrenNode
)))
989 act
->data
.sendtodir
.inter
.any
.interactive
=
991 } else if (act
->func
== action_activate
) {
992 if ((n
= parse_find_node("here", node
->xmlChildrenNode
)))
993 act
->data
.activate
.here
= parse_bool(doc
, n
);
994 } else if (act
->func
== action_cycle_windows
) {
995 if ((n
= parse_find_node("linear", node
->xmlChildrenNode
)))
996 act
->data
.cycle
.linear
= parse_bool(doc
, n
);
997 if ((n
= parse_find_node("dialog", node
->xmlChildrenNode
)))
998 act
->data
.cycle
.dialog
= parse_bool(doc
, n
);
999 } else if (act
->func
== action_directional_focus
) {
1000 if ((n
= parse_find_node("dialog", node
->xmlChildrenNode
)))
1001 act
->data
.cycle
.dialog
= parse_bool(doc
, n
);
1002 } else if (act
->func
== action_raise
||
1003 act
->func
== action_lower
||
1004 act
->func
== action_raiselower
||
1005 act
->func
== action_shadelower
||
1006 act
->func
== action_unshaderaise
) {
1007 if ((n
= parse_find_node("group", node
->xmlChildrenNode
)))
1008 act
->data
.stacking
.group
= parse_bool(doc
, n
);
1010 INTERACTIVE_LIMIT(act
, uact
);
1017 void action_run_list(GSList
*acts
, ObClient
*c
, ObFrameContext context
,
1018 guint state
, guint button
, gint x
, gint y
, Time time
,
1019 gboolean cancel
, gboolean done
)
1023 gboolean inter
= FALSE
;
1029 screen_pointer_pos(&x
, &y
);
1031 if (grab_on_keyboard())
1034 for (it
= acts
; it
; it
= g_slist_next(it
)) {
1036 if (a
->data
.any
.interactive
) {
1043 /* sometimes when we execute another app as an action,
1044 it won't work right unless we XUngrabKeyboard first,
1045 even though we grabbed the key/button Asychronously.
1046 e.g. "gnome-panel-control --main-menu" */
1047 XUngrabKeyboard(ob_display
, event_curtime
);
1050 for (it
= acts
; it
; it
= g_slist_next(it
)) {
1053 if (!(a
->data
.any
.client_action
== OB_CLIENT_ACTION_ALWAYS
&& !c
)) {
1054 a
->data
.any
.c
= a
->data
.any
.client_action
? c
: NULL
;
1055 a
->data
.any
.context
= context
;
1059 a
->data
.any
.button
= button
;
1061 a
->data
.any
.time
= time
;
1063 if (a
->data
.any
.interactive
) {
1064 a
->data
.inter
.cancel
= cancel
;
1065 a
->data
.inter
.final
= done
;
1066 if (!(cancel
|| done
))
1067 if (!keyboard_interactive_grab(state
, a
->data
.any
.c
, a
))
1071 /* XXX UGLY HACK race with motion event starting a move and the
1072 button release gettnig processed first. answer: don't queue
1073 moveresize starts. UGLY HACK XXX */
1074 if (a
->data
.any
.interactive
|| a
->func
== action_moveresize
) {
1075 /* interactive actions are not queued */
1078 ob_main_loop_queue_action(ob_main_loop
, a
);
1083 void action_run_string(const gchar
*name
, struct _ObClient
*c
, Time time
)
1088 a
= action_from_string(name
, OB_USER_ACTION_NONE
);
1091 l
= g_slist_append(NULL
, a
);
1093 action_run(l
, c
, 0, time
);
1096 void action_execute(union ActionData
*data
)
1099 gchar
*cmd
, **argv
= 0;
1100 if (data
->execute
.path
) {
1101 cmd
= g_filename_from_utf8(data
->execute
.path
, -1, NULL
, NULL
, NULL
);
1103 if (!g_shell_parse_argv (cmd
, NULL
, &argv
, &e
)) {
1104 g_warning("failed to execute '%s': %s",
1107 } else if (data
->execute
.startupnotify
) {
1108 gchar
**env
, *program
;
1110 program
= g_path_get_basename(argv
[0]);
1111 env
= sn_get_spawn_environment(program
,
1113 data
->execute
.icon_name
,
1114 data
->execute
.any
.time
);
1115 if (!g_spawn_async(NULL
, argv
, env
, G_SPAWN_SEARCH_PATH
|
1116 G_SPAWN_DO_NOT_REAP_CHILD
,
1117 NULL
, NULL
, NULL
, &e
)) {
1118 g_warning("failed to execute '%s': %s",
1127 if (!g_spawn_async(NULL
, argv
, NULL
, G_SPAWN_SEARCH_PATH
|
1128 G_SPAWN_DO_NOT_REAP_CHILD
,
1129 NULL
, NULL
, NULL
, &e
))
1131 g_warning("failed to execute '%s': %s",
1139 g_warning("failed to convert '%s' from utf8", data
->execute
.path
);
1144 void action_activate(union ActionData
*data
)
1146 /* similar to the openbox dock for dockapps, don't let user actions give
1147 focus to 3rd-party docks (panels) either (unless they ask for it
1149 if (data
->client
.any
.c
->type
!= OB_CLIENT_TYPE_DOCK
) {
1150 /* if using focus_delay, stop the timer now so that focus doesn't go
1152 event_halt_focus_delay();
1154 client_activate(data
->activate
.any
.c
, data
->activate
.here
, TRUE
,
1155 data
->activate
.any
.time
);
1159 void action_focus(union ActionData
*data
)
1161 /* similar to the openbox dock for dockapps, don't let user actions give
1162 focus to 3rd-party docks (panels) either (unless they ask for it
1164 if (data
->client
.any
.c
->type
!= OB_CLIENT_TYPE_DOCK
) {
1165 /* if using focus_delay, stop the timer now so that focus doesn't go
1167 event_halt_focus_delay();
1169 client_focus(data
->client
.any
.c
);
1173 void action_unfocus (union ActionData
*data
)
1175 if (data
->client
.any
.c
== focus_client
)
1176 focus_fallback(OB_FOCUS_FALLBACK_UNFOCUSING
);
1179 void action_iconify(union ActionData
*data
)
1181 client_action_start(data
);
1182 client_iconify(data
->client
.any
.c
, TRUE
, TRUE
);
1183 client_action_end(data
);
1186 void action_focus_order_to_bottom(union ActionData
*data
)
1188 focus_order_to_bottom(data
->client
.any
.c
);
1191 void action_raiselower(union ActionData
*data
)
1193 ObClient
*c
= data
->client
.any
.c
;
1195 gboolean raise
= FALSE
;
1197 for (it
= stacking_list
; it
; it
= g_list_next(it
)) {
1198 if (WINDOW_IS_CLIENT(it
->data
)) {
1199 ObClient
*cit
= it
->data
;
1201 if (cit
== c
) break;
1202 if (client_normal(cit
) == client_normal(c
) &&
1203 cit
->layer
== c
->layer
&&
1204 cit
->frame
->visible
&&
1205 !client_search_transient(c
, cit
))
1207 if (RECT_INTERSECTS_RECT(cit
->frame
->area
, c
->frame
->area
)) {
1221 void action_raise(union ActionData
*data
)
1223 client_action_start(data
);
1224 stacking_raise(CLIENT_AS_WINDOW(data
->client
.any
.c
), data
->stacking
.group
);
1225 client_action_end(data
);
1228 void action_unshaderaise(union ActionData
*data
)
1230 if (data
->client
.any
.c
->shaded
)
1231 action_unshade(data
);
1236 void action_shadelower(union ActionData
*data
)
1238 if (data
->client
.any
.c
->shaded
)
1244 void action_lower(union ActionData
*data
)
1246 client_action_start(data
);
1247 stacking_lower(CLIENT_AS_WINDOW(data
->client
.any
.c
), data
->stacking
.group
);
1248 client_action_end(data
);
1251 void action_close(union ActionData
*data
)
1253 client_close(data
->client
.any
.c
);
1256 void action_kill(union ActionData
*data
)
1258 client_kill(data
->client
.any
.c
);
1261 void action_shade(union ActionData
*data
)
1263 client_action_start(data
);
1264 client_shade(data
->client
.any
.c
, TRUE
);
1265 client_action_end(data
);
1268 void action_unshade(union ActionData
*data
)
1270 client_action_start(data
);
1271 client_shade(data
->client
.any
.c
, FALSE
);
1272 client_action_end(data
);
1275 void action_toggle_shade(union ActionData
*data
)
1277 client_action_start(data
);
1278 client_shade(data
->client
.any
.c
, !data
->client
.any
.c
->shaded
);
1279 client_action_end(data
);
1282 void action_toggle_omnipresent(union ActionData
*data
)
1284 client_set_desktop(data
->client
.any
.c
,
1285 data
->client
.any
.c
->desktop
== DESKTOP_ALL
?
1286 screen_desktop
: DESKTOP_ALL
, FALSE
);
1289 void action_move_relative_horz(union ActionData
*data
)
1291 ObClient
*c
= data
->relative
.any
.c
;
1292 client_action_start(data
);
1293 client_move(c
, c
->area
.x
+ data
->relative
.deltax
, c
->area
.y
);
1294 client_action_end(data
);
1297 void action_move_relative_vert(union ActionData
*data
)
1299 ObClient
*c
= data
->relative
.any
.c
;
1300 client_action_start(data
);
1301 client_move(c
, c
->area
.x
, c
->area
.y
+ data
->relative
.deltax
);
1302 client_action_end(data
);
1305 void action_move_to_center(union ActionData
*data
)
1307 ObClient
*c
= data
->client
.any
.c
;
1309 area
= screen_area_monitor(c
->desktop
, 0);
1310 client_action_start(data
);
1311 client_move(c
, area
->width
/ 2 - c
->area
.width
/ 2,
1312 area
->height
/ 2 - c
->area
.height
/ 2);
1313 client_action_end(data
);
1316 void action_resize_relative_horz(union ActionData
*data
)
1318 ObClient
*c
= data
->relative
.any
.c
;
1319 client_action_start(data
);
1321 c
->area
.width
+ data
->relative
.deltax
* c
->size_inc
.width
,
1323 client_action_end(data
);
1326 void action_resize_relative_vert(union ActionData
*data
)
1328 ObClient
*c
= data
->relative
.any
.c
;
1330 client_action_start(data
);
1331 client_resize(c
, c
->area
.width
, c
->area
.height
+
1332 data
->relative
.deltax
* c
->size_inc
.height
);
1333 client_action_end(data
);
1337 void action_move_relative(union ActionData
*data
)
1339 ObClient
*c
= data
->relative
.any
.c
;
1340 client_action_start(data
);
1341 client_move(c
, c
->area
.x
+ data
->relative
.deltax
, c
->area
.y
+
1342 data
->relative
.deltay
);
1343 client_action_end(data
);
1346 void action_resize_relative(union ActionData
*data
)
1348 ObClient
*c
= data
->relative
.any
.c
;
1349 client_action_start(data
);
1350 client_move_resize(c
,
1351 c
->area
.x
- data
->relative
.deltaxl
* c
->size_inc
.width
,
1352 c
->area
.y
- data
->relative
.deltayu
* c
->size_inc
.height
,
1353 c
->area
.width
+ data
->relative
.deltax
* c
->size_inc
.width
1354 + data
->relative
.deltaxl
* c
->size_inc
.width
,
1355 c
->area
.height
+ data
->relative
.deltay
* c
->size_inc
.height
1356 + data
->relative
.deltayu
* c
->size_inc
.height
);
1357 client_action_end(data
);
1360 void action_maximize_full(union ActionData
*data
)
1362 client_action_start(data
);
1363 client_maximize(data
->client
.any
.c
, TRUE
, 0, TRUE
);
1364 client_action_end(data
);
1367 void action_unmaximize_full(union ActionData
*data
)
1369 client_action_start(data
);
1370 client_maximize(data
->client
.any
.c
, FALSE
, 0, TRUE
);
1371 client_action_end(data
);
1374 void action_toggle_maximize_full(union ActionData
*data
)
1376 client_action_start(data
);
1377 client_maximize(data
->client
.any
.c
,
1378 !(data
->client
.any
.c
->max_horz
||
1379 data
->client
.any
.c
->max_vert
),
1381 client_action_end(data
);
1384 void action_maximize_horz(union ActionData
*data
)
1386 client_action_start(data
);
1387 client_maximize(data
->client
.any
.c
, TRUE
, 1, TRUE
);
1388 client_action_end(data
);
1391 void action_unmaximize_horz(union ActionData
*data
)
1393 client_action_start(data
);
1394 client_maximize(data
->client
.any
.c
, FALSE
, 1, TRUE
);
1395 client_action_end(data
);
1398 void action_toggle_maximize_horz(union ActionData
*data
)
1400 client_action_start(data
);
1401 client_maximize(data
->client
.any
.c
,
1402 !data
->client
.any
.c
->max_horz
, 1, TRUE
);
1403 client_action_end(data
);
1406 void action_maximize_vert(union ActionData
*data
)
1408 client_action_start(data
);
1409 client_maximize(data
->client
.any
.c
, TRUE
, 2, TRUE
);
1410 client_action_end(data
);
1413 void action_unmaximize_vert(union ActionData
*data
)
1415 client_action_start(data
);
1416 client_maximize(data
->client
.any
.c
, FALSE
, 2, TRUE
);
1417 client_action_end(data
);
1420 void action_toggle_maximize_vert(union ActionData
*data
)
1422 client_action_start(data
);
1423 client_maximize(data
->client
.any
.c
,
1424 !data
->client
.any
.c
->max_vert
, 2, TRUE
);
1425 client_action_end(data
);
1428 void action_toggle_fullscreen(union ActionData
*data
)
1430 client_action_start(data
);
1431 client_fullscreen(data
->client
.any
.c
,
1432 !(data
->client
.any
.c
->fullscreen
), TRUE
);
1433 client_action_end(data
);
1436 void action_send_to_desktop(union ActionData
*data
)
1438 ObClient
*c
= data
->sendto
.any
.c
;
1440 if (!client_normal(c
)) return;
1442 if (data
->sendto
.desk
< screen_num_desktops
||
1443 data
->sendto
.desk
== DESKTOP_ALL
) {
1444 client_set_desktop(c
, data
->sendto
.desk
, data
->sendto
.follow
);
1445 if (data
->sendto
.follow
)
1446 screen_set_desktop(data
->sendto
.desk
);
1450 void action_desktop(union ActionData
*data
)
1452 static guint first
= (unsigned) -1;
1454 if (data
->inter
.any
.interactive
&& first
== (unsigned) -1)
1455 first
= screen_desktop
;
1457 if (!data
->inter
.any
.interactive
||
1458 (!data
->inter
.cancel
&& !data
->inter
.final
))
1460 if (data
->desktop
.desk
< screen_num_desktops
||
1461 data
->desktop
.desk
== DESKTOP_ALL
)
1463 screen_set_desktop(data
->desktop
.desk
);
1464 if (data
->inter
.any
.interactive
)
1465 screen_desktop_popup(data
->desktop
.desk
, TRUE
);
1467 } else if (data
->inter
.cancel
) {
1468 screen_set_desktop(first
);
1471 if (!data
->inter
.any
.interactive
|| data
->inter
.final
) {
1472 screen_desktop_popup(0, FALSE
);
1473 first
= (unsigned) -1;
1477 void action_desktop_dir(union ActionData
*data
)
1481 d
= screen_cycle_desktop(data
->desktopdir
.dir
,
1482 data
->desktopdir
.wrap
,
1483 data
->desktopdir
.linear
,
1484 data
->desktopdir
.inter
.any
.interactive
,
1485 data
->desktopdir
.inter
.final
,
1486 data
->desktopdir
.inter
.cancel
);
1487 if (!data
->sendtodir
.inter
.any
.interactive
||
1488 !data
->sendtodir
.inter
.final
||
1489 data
->sendtodir
.inter
.cancel
)
1491 screen_set_desktop(d
);
1495 void action_send_to_desktop_dir(union ActionData
*data
)
1497 ObClient
*c
= data
->sendtodir
.inter
.any
.c
;
1500 if (!client_normal(c
)) return;
1502 d
= screen_cycle_desktop(data
->sendtodir
.dir
, data
->sendtodir
.wrap
,
1503 data
->sendtodir
.linear
,
1504 data
->sendtodir
.inter
.any
.interactive
,
1505 data
->sendtodir
.inter
.final
,
1506 data
->sendtodir
.inter
.cancel
);
1507 if (!data
->sendtodir
.inter
.any
.interactive
||
1508 !data
->sendtodir
.inter
.final
||
1509 data
->sendtodir
.inter
.cancel
)
1511 client_set_desktop(c
, d
, data
->sendtodir
.follow
);
1512 if (data
->sendtodir
.follow
)
1513 screen_set_desktop(d
);
1517 void action_desktop_last(union ActionData
*data
)
1519 screen_set_desktop(screen_last_desktop
);
1522 void action_toggle_decorations(union ActionData
*data
)
1524 ObClient
*c
= data
->client
.any
.c
;
1526 client_action_start(data
);
1527 client_set_undecorated(c
, !c
->undecorated
);
1528 client_action_end(data
);
1531 static guint32
pick_corner(gint x
, gint y
, gint cx
, gint cy
, gint cw
, gint ch
)
1533 if (config_resize_four_corners
) {
1534 if (x
- cx
> cw
/ 2) {
1535 if (y
- cy
> ch
/ 2)
1536 return prop_atoms
.net_wm_moveresize_size_bottomright
;
1538 return prop_atoms
.net_wm_moveresize_size_topright
;
1540 if (y
- cy
> ch
/ 2)
1541 return prop_atoms
.net_wm_moveresize_size_bottomleft
;
1543 return prop_atoms
.net_wm_moveresize_size_topleft
;
1546 if (x
- cx
> cw
* 2 / 3) {
1547 if (y
- cy
> ch
* 2 / 3)
1548 return prop_atoms
.net_wm_moveresize_size_bottomright
;
1549 else if (y
- cy
< ch
/ 3)
1550 return prop_atoms
.net_wm_moveresize_size_topright
;
1552 return prop_atoms
.net_wm_moveresize_size_right
;
1553 } else if (x
- cx
< cw
/ 3) {
1554 if (y
- cy
> ch
* 2 / 3)
1555 return prop_atoms
.net_wm_moveresize_size_bottomleft
;
1556 else if (y
- cy
< ch
/ 3)
1557 return prop_atoms
.net_wm_moveresize_size_topleft
;
1559 return prop_atoms
.net_wm_moveresize_size_left
;
1561 if (y
- cy
> ch
* 2 / 3)
1562 return prop_atoms
.net_wm_moveresize_size_bottom
;
1563 else if (y
- cy
< ch
/ 3)
1564 return prop_atoms
.net_wm_moveresize_size_top
;
1566 return prop_atoms
.net_wm_moveresize_move
;
1570 void action_moveresize(union ActionData
*data
)
1572 ObClient
*c
= data
->moveresize
.any
.c
;
1575 if (!client_normal(c
)) return;
1577 if (data
->moveresize
.keyboard
) {
1578 corner
= (data
->moveresize
.move
?
1579 prop_atoms
.net_wm_moveresize_move_keyboard
:
1580 prop_atoms
.net_wm_moveresize_size_keyboard
);
1582 corner
= (data
->moveresize
.move
?
1583 prop_atoms
.net_wm_moveresize_move
:
1584 pick_corner(data
->any
.x
, data
->any
.y
,
1585 c
->frame
->area
.x
, c
->frame
->area
.y
,
1586 /* use the client size because the frame
1587 can be differently sized (shaded
1588 windows) and we want this based on the
1590 c
->area
.width
+ c
->frame
->size
.left
+
1591 c
->frame
->size
.right
,
1592 c
->area
.height
+ c
->frame
->size
.top
+
1593 c
->frame
->size
.bottom
));
1596 moveresize_start(c
, data
->any
.x
, data
->any
.y
, data
->any
.button
, corner
);
1599 void action_reconfigure(union ActionData
*data
)
1604 void action_restart(union ActionData
*data
)
1606 ob_restart_other(data
->execute
.path
);
1609 void action_exit(union ActionData
*data
)
1614 void action_showmenu(union ActionData
*data
)
1616 if (data
->showmenu
.name
) {
1617 menu_show(data
->showmenu
.name
, data
->any
.x
, data
->any
.y
,
1618 data
->showmenu
.any
.c
);
1622 void action_cycle_windows(union ActionData
*data
)
1624 /* if using focus_delay, stop the timer now so that focus doesn't go moving
1626 event_halt_focus_delay();
1628 focus_cycle(data
->cycle
.forward
, data
->cycle
.linear
, data
->any
.interactive
,
1630 data
->cycle
.inter
.final
, data
->cycle
.inter
.cancel
,
1631 data
->cycle
.inter
.any
.time
);
1634 void action_directional_focus(union ActionData
*data
)
1636 /* if using focus_delay, stop the timer now so that focus doesn't go moving
1638 event_halt_focus_delay();
1640 focus_directional_cycle(data
->interdiraction
.direction
,
1641 data
->any
.interactive
,
1642 data
->interdiraction
.dialog
,
1643 data
->interdiraction
.inter
.final
,
1644 data
->interdiraction
.inter
.cancel
,
1645 data
->interdiraction
.inter
.any
.time
);
1648 void action_movetoedge(union ActionData
*data
)
1651 ObClient
*c
= data
->diraction
.any
.c
;
1653 x
= c
->frame
->area
.x
;
1654 y
= c
->frame
->area
.y
;
1656 switch(data
->diraction
.direction
) {
1657 case OB_DIRECTION_NORTH
:
1658 y
= client_directional_edge_search(c
, OB_DIRECTION_NORTH
,
1659 data
->diraction
.hang
)
1660 - (data
->diraction
.hang
? c
->frame
->area
.height
: 0);
1662 case OB_DIRECTION_WEST
:
1663 x
= client_directional_edge_search(c
, OB_DIRECTION_WEST
,
1664 data
->diraction
.hang
)
1665 - (data
->diraction
.hang
? c
->frame
->area
.width
: 0);
1667 case OB_DIRECTION_SOUTH
:
1668 y
= client_directional_edge_search(c
, OB_DIRECTION_SOUTH
,
1669 data
->diraction
.hang
)
1670 - (data
->diraction
.hang
? 0 : c
->frame
->area
.height
);
1672 case OB_DIRECTION_EAST
:
1673 x
= client_directional_edge_search(c
, OB_DIRECTION_EAST
,
1674 data
->diraction
.hang
)
1675 - (data
->diraction
.hang
? 0 : c
->frame
->area
.width
);
1678 g_assert_not_reached();
1680 frame_frame_gravity(c
->frame
, &x
, &y
);
1681 client_action_start(data
);
1682 client_move(c
, x
, y
);
1683 client_action_end(data
);
1686 void action_growtoedge(union ActionData
*data
)
1688 gint x
, y
, width
, height
, dest
;
1689 ObClient
*c
= data
->diraction
.any
.c
;
1692 //FIXME growtoedge resizes shaded windows to 0 height
1696 a
= screen_area(c
->desktop
);
1697 x
= c
->frame
->area
.x
;
1698 y
= c
->frame
->area
.y
;
1699 width
= c
->frame
->area
.width
;
1700 height
= c
->frame
->area
.height
;
1702 switch(data
->diraction
.direction
) {
1703 case OB_DIRECTION_NORTH
:
1704 dest
= client_directional_edge_search(c
, OB_DIRECTION_NORTH
, FALSE
);
1706 height
= c
->frame
->area
.height
/ 2;
1708 height
= c
->frame
->area
.y
+ c
->frame
->area
.height
- dest
;
1712 case OB_DIRECTION_WEST
:
1713 dest
= client_directional_edge_search(c
, OB_DIRECTION_WEST
, FALSE
);
1715 width
= c
->frame
->area
.width
/ 2;
1717 width
= c
->frame
->area
.x
+ c
->frame
->area
.width
- dest
;
1721 case OB_DIRECTION_SOUTH
:
1722 dest
= client_directional_edge_search(c
, OB_DIRECTION_SOUTH
, FALSE
);
1723 if (a
->y
+ a
->height
== y
+ c
->frame
->area
.height
) {
1724 height
= c
->frame
->area
.height
/ 2;
1725 y
= a
->y
+ a
->height
- height
;
1727 height
= dest
- c
->frame
->area
.y
;
1728 y
+= (height
- c
->frame
->area
.height
) % c
->size_inc
.height
;
1729 height
-= (height
- c
->frame
->area
.height
) % c
->size_inc
.height
;
1731 case OB_DIRECTION_EAST
:
1732 dest
= client_directional_edge_search(c
, OB_DIRECTION_EAST
, FALSE
);
1733 if (a
->x
+ a
->width
== x
+ c
->frame
->area
.width
) {
1734 width
= c
->frame
->area
.width
/ 2;
1735 x
= a
->x
+ a
->width
- width
;
1737 width
= dest
- c
->frame
->area
.x
;
1738 x
+= (width
- c
->frame
->area
.width
) % c
->size_inc
.width
;
1739 width
-= (width
- c
->frame
->area
.width
) % c
->size_inc
.width
;
1742 g_assert_not_reached();
1744 frame_frame_gravity(c
->frame
, &x
, &y
);
1745 width
-= c
->frame
->size
.left
+ c
->frame
->size
.right
;
1746 height
-= c
->frame
->size
.top
+ c
->frame
->size
.bottom
;
1747 client_action_start(data
);
1748 client_move_resize(c
, x
, y
, width
, height
);
1749 client_action_end(data
);
1752 void action_send_to_layer(union ActionData
*data
)
1754 client_set_layer(data
->layer
.any
.c
, data
->layer
.layer
);
1757 void action_toggle_layer(union ActionData
*data
)
1759 ObClient
*c
= data
->layer
.any
.c
;
1761 client_action_start(data
);
1762 if (data
->layer
.layer
< 0)
1763 client_set_layer(c
, c
->below
? 0 : -1);
1764 else if (data
->layer
.layer
> 0)
1765 client_set_layer(c
, c
->above
? 0 : 1);
1766 client_action_end(data
);
1769 void action_toggle_dockautohide(union ActionData
*data
)
1771 config_dock_hide
= !config_dock_hide
;
1775 void action_toggle_show_desktop(union ActionData
*data
)
1777 screen_show_desktop(!screen_showing_desktop
);
1780 void action_show_desktop(union ActionData
*data
)
1782 screen_show_desktop(TRUE
);
1785 void action_unshow_desktop(union ActionData
*data
)
1787 screen_show_desktop(FALSE
);