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-2007 Dana 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"
41 inline void client_action_start(union ActionData
*data
)
43 if (config_focus_follow
)
44 if (data
->any
.context
!= OB_FRAME_CONTEXT_CLIENT
&& !data
->any
.button
)
45 grab_pointer(FALSE
, FALSE
, OB_CURSOR_NONE
);
48 inline void client_action_end(union ActionData
*data
)
50 if (config_focus_follow
)
51 if (data
->any
.context
!= OB_FRAME_CONTEXT_CLIENT
) {
52 if (!data
->any
.button
) {
57 /* usually this is sorta redundant, but with a press action
58 that moves windows our from under the cursor, the enter
59 event will come as a GrabNotify which is ignored, so this
60 makes a fake enter event
62 if ((c
= client_under_pointer()))
63 event_enter_client(c
);
71 void (*func
)(union ActionData
*);
72 void (*setup
)(ObAction
**, ObUserAction uact
);
75 static ObAction
*action_new(void (*func
)(union ActionData
*data
))
77 ObAction
*a
= g_new0(ObAction
, 1);
84 void action_ref(ObAction
*a
)
89 void action_unref(ObAction
*a
)
91 if (a
== NULL
) return;
93 if (--a
->ref
> 0) return;
95 /* deal with pointers */
96 if (a
->func
== action_execute
|| a
->func
== action_restart
)
97 g_free(a
->data
.execute
.path
);
98 else if (a
->func
== action_debug
)
99 g_free(a
->data
.debug
.string
);
100 else if (a
->func
== action_showmenu
)
101 g_free(a
->data
.showmenu
.name
);
106 ObAction
* action_copy(const ObAction
*src
)
108 ObAction
*a
= action_new(src
->func
);
112 /* deal with pointers */
113 if (a
->func
== action_execute
|| a
->func
== action_restart
)
114 a
->data
.execute
.path
= g_strdup(a
->data
.execute
.path
);
115 else if (a
->func
== action_debug
)
116 a
->data
.debug
.string
= g_strdup(a
->data
.debug
.string
);
117 else if (a
->func
== action_showmenu
)
118 a
->data
.showmenu
.name
= g_strdup(a
->data
.showmenu
.name
);
123 void setup_action_directional_focus_north(ObAction
**a
, ObUserAction uact
)
125 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
126 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_NORTH
;
127 (*a
)->data
.interdiraction
.dialog
= TRUE
;
128 (*a
)->data
.interdiraction
.dock_windows
= FALSE
;
129 (*a
)->data
.interdiraction
.desktop_windows
= FALSE
;
132 void setup_action_directional_focus_east(ObAction
**a
, ObUserAction uact
)
134 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
135 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_EAST
;
136 (*a
)->data
.interdiraction
.dialog
= TRUE
;
137 (*a
)->data
.interdiraction
.dock_windows
= FALSE
;
138 (*a
)->data
.interdiraction
.desktop_windows
= FALSE
;
141 void setup_action_directional_focus_south(ObAction
**a
, ObUserAction uact
)
143 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
144 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_SOUTH
;
145 (*a
)->data
.interdiraction
.dialog
= TRUE
;
146 (*a
)->data
.interdiraction
.dock_windows
= FALSE
;
147 (*a
)->data
.interdiraction
.desktop_windows
= FALSE
;
150 void setup_action_directional_focus_west(ObAction
**a
, ObUserAction uact
)
152 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
153 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_WEST
;
154 (*a
)->data
.interdiraction
.dialog
= TRUE
;
155 (*a
)->data
.interdiraction
.dock_windows
= FALSE
;
156 (*a
)->data
.interdiraction
.desktop_windows
= FALSE
;
159 void setup_action_directional_focus_northeast(ObAction
**a
, ObUserAction uact
)
161 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
162 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_NORTHEAST
;
163 (*a
)->data
.interdiraction
.dialog
= TRUE
;
164 (*a
)->data
.interdiraction
.dock_windows
= FALSE
;
165 (*a
)->data
.interdiraction
.desktop_windows
= FALSE
;
168 void setup_action_directional_focus_southeast(ObAction
**a
, ObUserAction uact
)
170 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
171 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_SOUTHEAST
;
172 (*a
)->data
.interdiraction
.dialog
= TRUE
;
173 (*a
)->data
.interdiraction
.dock_windows
= FALSE
;
174 (*a
)->data
.interdiraction
.desktop_windows
= FALSE
;
177 void setup_action_directional_focus_southwest(ObAction
**a
, ObUserAction uact
)
179 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
180 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_SOUTHWEST
;
181 (*a
)->data
.interdiraction
.dialog
= TRUE
;
182 (*a
)->data
.interdiraction
.dock_windows
= FALSE
;
183 (*a
)->data
.interdiraction
.desktop_windows
= FALSE
;
186 void setup_action_directional_focus_northwest(ObAction
**a
, ObUserAction uact
)
188 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
189 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_NORTHWEST
;
190 (*a
)->data
.interdiraction
.dialog
= TRUE
;
191 (*a
)->data
.interdiraction
.dock_windows
= FALSE
;
192 (*a
)->data
.interdiraction
.desktop_windows
= FALSE
;
195 void setup_action_send_to_desktop(ObAction
**a
, ObUserAction uact
)
197 (*a
)->data
.sendto
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
198 (*a
)->data
.sendto
.follow
= TRUE
;
201 void setup_action_send_to_desktop_prev(ObAction
**a
, ObUserAction uact
)
203 (*a
)->data
.sendtodir
.inter
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
204 (*a
)->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
205 (*a
)->data
.sendtodir
.dir
= OB_DIRECTION_WEST
;
206 (*a
)->data
.sendtodir
.linear
= TRUE
;
207 (*a
)->data
.sendtodir
.wrap
= TRUE
;
208 (*a
)->data
.sendtodir
.follow
= TRUE
;
211 void setup_action_send_to_desktop_next(ObAction
**a
, ObUserAction uact
)
213 (*a
)->data
.sendtodir
.inter
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
214 (*a
)->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
215 (*a
)->data
.sendtodir
.dir
= OB_DIRECTION_EAST
;
216 (*a
)->data
.sendtodir
.linear
= TRUE
;
217 (*a
)->data
.sendtodir
.wrap
= TRUE
;
218 (*a
)->data
.sendtodir
.follow
= TRUE
;
221 void setup_action_send_to_desktop_left(ObAction
**a
, ObUserAction uact
)
223 (*a
)->data
.sendtodir
.inter
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
224 (*a
)->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
225 (*a
)->data
.sendtodir
.dir
= OB_DIRECTION_WEST
;
226 (*a
)->data
.sendtodir
.linear
= FALSE
;
227 (*a
)->data
.sendtodir
.wrap
= TRUE
;
228 (*a
)->data
.sendtodir
.follow
= TRUE
;
231 void setup_action_send_to_desktop_right(ObAction
**a
, ObUserAction uact
)
233 (*a
)->data
.sendtodir
.inter
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
234 (*a
)->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
235 (*a
)->data
.sendtodir
.dir
= OB_DIRECTION_EAST
;
236 (*a
)->data
.sendtodir
.linear
= FALSE
;
237 (*a
)->data
.sendtodir
.wrap
= TRUE
;
238 (*a
)->data
.sendtodir
.follow
= TRUE
;
241 void setup_action_send_to_desktop_up(ObAction
**a
, ObUserAction uact
)
243 (*a
)->data
.sendtodir
.inter
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
244 (*a
)->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
245 (*a
)->data
.sendtodir
.dir
= OB_DIRECTION_NORTH
;
246 (*a
)->data
.sendtodir
.linear
= FALSE
;
247 (*a
)->data
.sendtodir
.wrap
= TRUE
;
248 (*a
)->data
.sendtodir
.follow
= TRUE
;
251 void setup_action_send_to_desktop_down(ObAction
**a
, ObUserAction uact
)
253 (*a
)->data
.sendtodir
.inter
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
254 (*a
)->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
255 (*a
)->data
.sendtodir
.dir
= OB_DIRECTION_SOUTH
;
256 (*a
)->data
.sendtodir
.linear
= FALSE
;
257 (*a
)->data
.sendtodir
.wrap
= TRUE
;
258 (*a
)->data
.sendtodir
.follow
= TRUE
;
261 void setup_action_desktop(ObAction
**a
, ObUserAction uact
)
264 (*a)->data.desktop.inter.any.interactive = FALSE;
268 void setup_action_desktop_prev(ObAction
**a
, ObUserAction uact
)
270 (*a
)->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
271 (*a
)->data
.desktopdir
.dir
= OB_DIRECTION_WEST
;
272 (*a
)->data
.desktopdir
.linear
= TRUE
;
273 (*a
)->data
.desktopdir
.wrap
= TRUE
;
276 void setup_action_desktop_next(ObAction
**a
, ObUserAction uact
)
278 (*a
)->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
279 (*a
)->data
.desktopdir
.dir
= OB_DIRECTION_EAST
;
280 (*a
)->data
.desktopdir
.linear
= TRUE
;
281 (*a
)->data
.desktopdir
.wrap
= TRUE
;
284 void setup_action_desktop_left(ObAction
**a
, ObUserAction uact
)
286 (*a
)->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
287 (*a
)->data
.desktopdir
.dir
= OB_DIRECTION_WEST
;
288 (*a
)->data
.desktopdir
.linear
= FALSE
;
289 (*a
)->data
.desktopdir
.wrap
= TRUE
;
292 void setup_action_desktop_right(ObAction
**a
, ObUserAction uact
)
294 (*a
)->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
295 (*a
)->data
.desktopdir
.dir
= OB_DIRECTION_EAST
;
296 (*a
)->data
.desktopdir
.linear
= FALSE
;
297 (*a
)->data
.desktopdir
.wrap
= TRUE
;
300 void setup_action_desktop_up(ObAction
**a
, ObUserAction uact
)
302 (*a
)->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
303 (*a
)->data
.desktopdir
.dir
= OB_DIRECTION_NORTH
;
304 (*a
)->data
.desktopdir
.linear
= FALSE
;
305 (*a
)->data
.desktopdir
.wrap
= TRUE
;
308 void setup_action_desktop_down(ObAction
**a
, ObUserAction uact
)
310 (*a
)->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
311 (*a
)->data
.desktopdir
.dir
= OB_DIRECTION_SOUTH
;
312 (*a
)->data
.desktopdir
.linear
= FALSE
;
313 (*a
)->data
.desktopdir
.wrap
= TRUE
;
316 void setup_action_cycle_windows_next(ObAction
**a
, ObUserAction uact
)
318 (*a
)->data
.cycle
.inter
.any
.interactive
= TRUE
;
319 (*a
)->data
.cycle
.linear
= FALSE
;
320 (*a
)->data
.cycle
.forward
= TRUE
;
321 (*a
)->data
.cycle
.dialog
= TRUE
;
322 (*a
)->data
.cycle
.dock_windows
= FALSE
;
323 (*a
)->data
.cycle
.desktop_windows
= FALSE
;
324 (*a
)->data
.cycle
.all_desktops
= FALSE
;
327 void setup_action_cycle_windows_previous(ObAction
**a
, ObUserAction uact
)
329 (*a
)->data
.cycle
.inter
.any
.interactive
= TRUE
;
330 (*a
)->data
.cycle
.linear
= FALSE
;
331 (*a
)->data
.cycle
.forward
= FALSE
;
332 (*a
)->data
.cycle
.dialog
= TRUE
;
333 (*a
)->data
.cycle
.dock_windows
= FALSE
;
334 (*a
)->data
.cycle
.desktop_windows
= FALSE
;
335 (*a
)->data
.cycle
.all_desktops
= FALSE
;
338 void setup_action_movefromedge_north(ObAction
**a
, ObUserAction uact
)
340 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
341 (*a
)->data
.diraction
.direction
= OB_DIRECTION_NORTH
;
342 (*a
)->data
.diraction
.hang
= TRUE
;
345 void setup_action_movefromedge_south(ObAction
**a
, ObUserAction uact
)
347 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
348 (*a
)->data
.diraction
.direction
= OB_DIRECTION_SOUTH
;
349 (*a
)->data
.diraction
.hang
= TRUE
;
352 void setup_action_movefromedge_east(ObAction
**a
, ObUserAction uact
)
354 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
355 (*a
)->data
.diraction
.direction
= OB_DIRECTION_EAST
;
356 (*a
)->data
.diraction
.hang
= TRUE
;
359 void setup_action_movefromedge_west(ObAction
**a
, ObUserAction uact
)
361 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
362 (*a
)->data
.diraction
.direction
= OB_DIRECTION_WEST
;
363 (*a
)->data
.diraction
.hang
= TRUE
;
366 void setup_action_movetoedge_north(ObAction
**a
, ObUserAction uact
)
368 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
369 (*a
)->data
.diraction
.direction
= OB_DIRECTION_NORTH
;
370 (*a
)->data
.diraction
.hang
= FALSE
;
373 void setup_action_movetoedge_south(ObAction
**a
, ObUserAction uact
)
375 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
376 (*a
)->data
.diraction
.direction
= OB_DIRECTION_SOUTH
;
377 (*a
)->data
.diraction
.hang
= FALSE
;
380 void setup_action_movetoedge_east(ObAction
**a
, ObUserAction uact
)
382 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
383 (*a
)->data
.diraction
.direction
= OB_DIRECTION_EAST
;
384 (*a
)->data
.diraction
.hang
= FALSE
;
387 void setup_action_movetoedge_west(ObAction
**a
, ObUserAction uact
)
389 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
390 (*a
)->data
.diraction
.direction
= OB_DIRECTION_WEST
;
391 (*a
)->data
.diraction
.hang
= FALSE
;
394 void setup_action_growtoedge_north(ObAction
**a
, ObUserAction uact
)
396 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
397 (*a
)->data
.diraction
.direction
= OB_DIRECTION_NORTH
;
400 void setup_action_growtoedge_south(ObAction
**a
, ObUserAction uact
)
402 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
403 (*a
)->data
.diraction
.direction
= OB_DIRECTION_SOUTH
;
406 void setup_action_growtoedge_east(ObAction
**a
, ObUserAction uact
)
408 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
409 (*a
)->data
.diraction
.direction
= OB_DIRECTION_EAST
;
412 void setup_action_growtoedge_west(ObAction
**a
, ObUserAction uact
)
414 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
415 (*a
)->data
.diraction
.direction
= OB_DIRECTION_WEST
;
418 void setup_action_top_layer(ObAction
**a
, ObUserAction uact
)
420 (*a
)->data
.layer
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
421 (*a
)->data
.layer
.layer
= 1;
424 void setup_action_normal_layer(ObAction
**a
, ObUserAction uact
)
426 (*a
)->data
.layer
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
427 (*a
)->data
.layer
.layer
= 0;
430 void setup_action_bottom_layer(ObAction
**a
, ObUserAction uact
)
432 (*a
)->data
.layer
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
433 (*a
)->data
.layer
.layer
= -1;
436 void setup_action_move(ObAction
**a
, ObUserAction uact
)
438 (*a
)->data
.moveresize
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
439 (*a
)->data
.moveresize
.keyboard
=
440 (uact
== OB_USER_ACTION_NONE
||
441 uact
== OB_USER_ACTION_KEYBOARD_KEY
||
442 uact
== OB_USER_ACTION_MENU_SELECTION
);
443 (*a
)->data
.moveresize
.corner
= 0;
446 void setup_action_resize(ObAction
**a
, ObUserAction uact
)
448 (*a
)->data
.moveresize
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
449 (*a
)->data
.moveresize
.keyboard
=
450 (uact
== OB_USER_ACTION_NONE
||
451 uact
== OB_USER_ACTION_KEYBOARD_KEY
||
452 uact
== OB_USER_ACTION_MENU_SELECTION
);
453 (*a
)->data
.moveresize
.corner
= 0;
456 void setup_action_showmenu(ObAction
**a
, ObUserAction uact
)
458 (*a
)->data
.showmenu
.any
.client_action
= OB_CLIENT_ACTION_OPTIONAL
;
459 /* you cannot call ShowMenu from inside a menu, cuz the menu code makes
460 assumptions that there is only one menu (and submenus) open at
462 if (uact
== OB_USER_ACTION_MENU_SELECTION
) {
468 void setup_action_focus(ObAction
**a
, ObUserAction uact
)
470 (*a
)->data
.any
.client_action
= OB_CLIENT_ACTION_OPTIONAL
;
473 void setup_client_action(ObAction
**a
, ObUserAction uact
)
475 (*a
)->data
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
478 ActionString actionstrings
[] =
491 "directionalfocusnorth",
492 action_directional_focus
,
493 setup_action_directional_focus_north
496 "directionalfocuseast",
497 action_directional_focus
,
498 setup_action_directional_focus_east
501 "directionalfocussouth",
502 action_directional_focus
,
503 setup_action_directional_focus_south
506 "directionalfocuswest",
507 action_directional_focus
,
508 setup_action_directional_focus_west
511 "directionalfocusnortheast",
512 action_directional_focus
,
513 setup_action_directional_focus_northeast
516 "directionalfocussoutheast",
517 action_directional_focus
,
518 setup_action_directional_focus_southeast
521 "directionalfocussouthwest",
522 action_directional_focus
,
523 setup_action_directional_focus_southwest
526 "directionalfocusnorthwest",
527 action_directional_focus
,
528 setup_action_directional_focus_northwest
552 action_focus_order_to_bottom
,
607 action_toggle_omnipresent
,
612 action_move_relative_horz
,
617 action_move_relative_vert
,
622 action_move_to_center
,
626 "resizerelativehorz",
627 action_resize_relative_horz
,
631 "resizerelativevert",
632 action_resize_relative_vert
,
637 action_move_relative
,
642 action_resize_relative
,
647 action_maximize_full
,
652 action_unmaximize_full
,
656 "togglemaximizefull",
657 action_toggle_maximize_full
,
662 action_maximize_horz
,
667 action_unmaximize_horz
,
671 "togglemaximizehorz",
672 action_toggle_maximize_horz
,
677 action_maximize_vert
,
682 action_unmaximize_vert
,
686 "togglemaximizevert",
687 action_toggle_maximize_vert
,
692 action_toggle_fullscreen
,
697 action_send_to_desktop
,
698 setup_action_send_to_desktop
702 action_send_to_desktop_dir
,
703 setup_action_send_to_desktop_next
706 "sendtodesktopprevious",
707 action_send_to_desktop_dir
,
708 setup_action_send_to_desktop_prev
711 "sendtodesktopright",
712 action_send_to_desktop_dir
,
713 setup_action_send_to_desktop_right
717 action_send_to_desktop_dir
,
718 setup_action_send_to_desktop_left
722 action_send_to_desktop_dir
,
723 setup_action_send_to_desktop_up
727 action_send_to_desktop_dir
,
728 setup_action_send_to_desktop_down
738 setup_action_desktop_next
743 setup_action_desktop_prev
748 setup_action_desktop_right
753 setup_action_desktop_left
758 setup_action_desktop_up
763 setup_action_desktop_down
767 action_toggle_decorations
,
781 "toggledockautohide",
782 action_toggle_dockautohide
,
787 action_toggle_show_desktop
,
797 action_unshow_desktop
,
823 setup_action_showmenu
827 action_send_to_layer
,
828 setup_action_top_layer
833 setup_action_top_layer
837 action_send_to_layer
,
838 setup_action_normal_layer
842 action_send_to_layer
,
843 setup_action_bottom_layer
846 "togglealwaysonbottom",
848 setup_action_bottom_layer
852 action_cycle_windows
,
853 setup_action_cycle_windows_next
857 action_cycle_windows
,
858 setup_action_cycle_windows_previous
863 setup_action_movefromedge_north
868 setup_action_movefromedge_south
873 setup_action_movefromedge_west
878 setup_action_movefromedge_east
883 setup_action_movetoedge_north
888 setup_action_movetoedge_south
893 setup_action_movetoedge_west
898 setup_action_movetoedge_east
903 setup_action_growtoedge_north
908 setup_action_growtoedge_south
913 setup_action_growtoedge_west
918 setup_action_growtoedge_east
932 /* only key bindings can be interactive. thus saith the xor.
933 because of how the mouse is grabbed, mouse events dont even get
934 read during interactive events, so no dice! >:) */
935 #define INTERACTIVE_LIMIT(a, uact) \
936 if (uact != OB_USER_ACTION_KEYBOARD_KEY) \
937 a->data.any.interactive = FALSE;
939 ObAction
*action_from_string(const gchar
*name
, ObUserAction uact
)
942 gboolean exist
= FALSE
;
945 for (i
= 0; actionstrings
[i
].name
; i
++)
946 if (!g_ascii_strcasecmp(name
, actionstrings
[i
].name
)) {
948 a
= action_new(actionstrings
[i
].func
);
949 if (actionstrings
[i
].setup
)
950 actionstrings
[i
].setup(&a
, uact
);
952 INTERACTIVE_LIMIT(a
, uact
);
956 g_message(_("Invalid action '%s' requested. No such action exists."),
959 g_message(_("Invalid use of action '%s'. Action will be ignored."),
964 ObAction
*action_parse(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
968 ObAction
*act
= NULL
;
971 if (parse_attr_string("name", node
, &actname
)) {
972 if ((act
= action_from_string(actname
, uact
))) {
973 if (act
->func
== action_execute
|| act
->func
== action_restart
) {
974 if ((n
= parse_find_node("execute", node
->xmlChildrenNode
))) {
975 gchar
*s
= parse_string(doc
, n
);
976 act
->data
.execute
.path
= parse_expand_tilde(s
);
979 if ((n
= parse_find_node("startupnotify", node
->xmlChildrenNode
))) {
981 if ((m
= parse_find_node("enabled", n
->xmlChildrenNode
)))
982 act
->data
.execute
.startupnotify
= parse_bool(doc
, m
);
983 if ((m
= parse_find_node("name", n
->xmlChildrenNode
)))
984 act
->data
.execute
.name
= parse_string(doc
, m
);
985 if ((m
= parse_find_node("icon", n
->xmlChildrenNode
)))
986 act
->data
.execute
.icon_name
= parse_string(doc
, m
);
988 } else if (act
->func
== action_debug
) {
989 if ((n
= parse_find_node("string", node
->xmlChildrenNode
)))
990 act
->data
.debug
.string
= parse_string(doc
, n
);
991 } else if (act
->func
== action_showmenu
) {
992 if ((n
= parse_find_node("menu", node
->xmlChildrenNode
)))
993 act
->data
.showmenu
.name
= parse_string(doc
, n
);
994 } else if (act
->func
== action_move_relative_horz
||
995 act
->func
== action_move_relative_vert
||
996 act
->func
== action_resize_relative_horz
||
997 act
->func
== action_resize_relative_vert
) {
998 if ((n
= parse_find_node("delta", node
->xmlChildrenNode
)))
999 act
->data
.relative
.deltax
= parse_int(doc
, n
);
1000 } else if (act
->func
== action_move_relative
) {
1001 if ((n
= parse_find_node("x", node
->xmlChildrenNode
)))
1002 act
->data
.relative
.deltax
= parse_int(doc
, n
);
1003 if ((n
= parse_find_node("y", node
->xmlChildrenNode
)))
1004 act
->data
.relative
.deltay
= parse_int(doc
, n
);
1005 } else if (act
->func
== action_resize_relative
) {
1006 if ((n
= parse_find_node("left", node
->xmlChildrenNode
)))
1007 act
->data
.relative
.deltaxl
= parse_int(doc
, n
);
1008 if ((n
= parse_find_node("up", node
->xmlChildrenNode
)))
1009 act
->data
.relative
.deltayu
= parse_int(doc
, n
);
1010 if ((n
= parse_find_node("right", node
->xmlChildrenNode
)))
1011 act
->data
.relative
.deltax
= parse_int(doc
, n
);
1012 if ((n
= parse_find_node("down", node
->xmlChildrenNode
)))
1013 act
->data
.relative
.deltay
= parse_int(doc
, n
);
1014 } else if (act
->func
== action_desktop
) {
1015 if ((n
= parse_find_node("desktop", node
->xmlChildrenNode
)))
1016 act
->data
.desktop
.desk
= parse_int(doc
, n
);
1017 if (act
->data
.desktop
.desk
> 0) act
->data
.desktop
.desk
--;
1019 if ((n = parse_find_node("dialog", node->xmlChildrenNode)))
1020 act->data.desktop.inter.any.interactive =
1023 } else if (act
->func
== action_send_to_desktop
) {
1024 if ((n
= parse_find_node("desktop", node
->xmlChildrenNode
)))
1025 act
->data
.sendto
.desk
= parse_int(doc
, n
);
1026 if (act
->data
.sendto
.desk
> 0) act
->data
.sendto
.desk
--;
1027 if ((n
= parse_find_node("follow", node
->xmlChildrenNode
)))
1028 act
->data
.sendto
.follow
= parse_bool(doc
, n
);
1029 } else if (act
->func
== action_desktop_dir
) {
1030 if ((n
= parse_find_node("wrap", node
->xmlChildrenNode
)))
1031 act
->data
.desktopdir
.wrap
= parse_bool(doc
, n
);
1032 if ((n
= parse_find_node("dialog", node
->xmlChildrenNode
)))
1033 act
->data
.desktopdir
.inter
.any
.interactive
=
1035 } else if (act
->func
== action_send_to_desktop_dir
) {
1036 if ((n
= parse_find_node("wrap", node
->xmlChildrenNode
)))
1037 act
->data
.sendtodir
.wrap
= parse_bool(doc
, n
);
1038 if ((n
= parse_find_node("follow", node
->xmlChildrenNode
)))
1039 act
->data
.sendtodir
.follow
= parse_bool(doc
, n
);
1040 if ((n
= parse_find_node("dialog", node
->xmlChildrenNode
)))
1041 act
->data
.sendtodir
.inter
.any
.interactive
=
1043 } else if (act
->func
== action_activate
) {
1044 if ((n
= parse_find_node("here", node
->xmlChildrenNode
)))
1045 act
->data
.activate
.here
= parse_bool(doc
, n
);
1046 } else if (act
->func
== action_cycle_windows
) {
1047 if ((n
= parse_find_node("linear", node
->xmlChildrenNode
)))
1048 act
->data
.cycle
.linear
= parse_bool(doc
, n
);
1049 if ((n
= parse_find_node("dialog", node
->xmlChildrenNode
)))
1050 act
->data
.cycle
.dialog
= parse_bool(doc
, n
);
1051 if ((n
= parse_find_node("panels", node
->xmlChildrenNode
)))
1052 act
->data
.cycle
.dock_windows
= parse_bool(doc
, n
);
1053 if ((n
= parse_find_node("desktop", node
->xmlChildrenNode
)))
1054 act
->data
.cycle
.desktop_windows
= parse_bool(doc
, n
);
1055 if ((n
= parse_find_node("allDesktops",
1056 node
->xmlChildrenNode
)))
1057 act
->data
.cycle
.all_desktops
= parse_bool(doc
, n
);
1058 } else if (act
->func
== action_directional_focus
) {
1059 if ((n
= parse_find_node("dialog", node
->xmlChildrenNode
)))
1060 act
->data
.interdiraction
.dialog
= parse_bool(doc
, n
);
1061 if ((n
= parse_find_node("panels", node
->xmlChildrenNode
)))
1062 act
->data
.interdiraction
.dock_windows
= parse_bool(doc
, n
);
1063 if ((n
= parse_find_node("desktop", node
->xmlChildrenNode
)))
1064 act
->data
.interdiraction
.desktop_windows
=
1066 } else if (act
->func
== action_resize
) {
1067 if ((n
= parse_find_node("edge", node
->xmlChildrenNode
))) {
1068 gchar
*s
= parse_string(doc
, n
);
1069 if (!g_ascii_strcasecmp(s
, "top"))
1070 act
->data
.moveresize
.corner
=
1071 prop_atoms
.net_wm_moveresize_size_top
;
1072 else if (!g_ascii_strcasecmp(s
, "bottom"))
1073 act
->data
.moveresize
.corner
=
1074 prop_atoms
.net_wm_moveresize_size_bottom
;
1075 else if (!g_ascii_strcasecmp(s
, "left"))
1076 act
->data
.moveresize
.corner
=
1077 prop_atoms
.net_wm_moveresize_size_left
;
1078 else if (!g_ascii_strcasecmp(s
, "right"))
1079 act
->data
.moveresize
.corner
=
1080 prop_atoms
.net_wm_moveresize_size_right
;
1081 else if (!g_ascii_strcasecmp(s
, "topleft"))
1082 act
->data
.moveresize
.corner
=
1083 prop_atoms
.net_wm_moveresize_size_topleft
;
1084 else if (!g_ascii_strcasecmp(s
, "topright"))
1085 act
->data
.moveresize
.corner
=
1086 prop_atoms
.net_wm_moveresize_size_topright
;
1087 else if (!g_ascii_strcasecmp(s
, "bottomleft"))
1088 act
->data
.moveresize
.corner
=
1089 prop_atoms
.net_wm_moveresize_size_bottomleft
;
1090 else if (!g_ascii_strcasecmp(s
, "bottomright"))
1091 act
->data
.moveresize
.corner
=
1092 prop_atoms
.net_wm_moveresize_size_bottomright
;
1095 } else if (act
->func
== action_raise
||
1096 act
->func
== action_lower
||
1097 act
->func
== action_raiselower
||
1098 act
->func
== action_shadelower
||
1099 act
->func
== action_unshaderaise
) {
1101 INTERACTIVE_LIMIT(act
, uact
);
1108 void action_run_list(GSList
*acts
, ObClient
*c
, ObFrameContext context
,
1109 guint state
, guint button
, gint x
, gint y
, Time time
,
1110 gboolean cancel
, gboolean done
)
1119 screen_pointer_pos(&x
, &y
);
1121 for (it
= acts
; it
; it
= g_slist_next(it
)) {
1124 if (!(a
->data
.any
.client_action
== OB_CLIENT_ACTION_ALWAYS
&& !c
)) {
1125 a
->data
.any
.c
= a
->data
.any
.client_action
? c
: NULL
;
1126 a
->data
.any
.context
= context
;
1130 a
->data
.any
.button
= button
;
1132 a
->data
.any
.time
= time
;
1134 if (a
->data
.any
.interactive
) {
1135 a
->data
.inter
.cancel
= cancel
;
1136 a
->data
.inter
.final
= done
;
1137 if (!(cancel
|| done
))
1138 if (!keyboard_interactive_grab(state
, a
->data
.any
.c
, a
))
1142 /* XXX UGLY HACK race with motion event starting a move and the
1143 button release gettnig processed first. answer: don't queue
1144 moveresize starts. UGLY HACK XXX
1146 XXX ALSO don't queue showmenu events, because on button press
1147 events we need to know if a mouse grab is going to take place,
1148 and set the button to 0, so that later motion events don't think
1149 that a drag is going on. since showmenu grabs the pointer..
1151 if (a
->data
.any
.interactive
|| a
->func
== action_move
||
1152 a
->func
== action_resize
|| a
->func
== action_showmenu
)
1154 /* interactive actions are not queued */
1157 (context
== OB_FRAME_CONTEXT_CLIENT
||
1158 (c
->type
== OB_CLIENT_TYPE_DESKTOP
&&
1159 context
== OB_FRAME_CONTEXT_DESKTOP
)) &&
1160 (a
->func
== action_focus
||
1161 a
->func
== action_activate
||
1162 a
->func
== action_showmenu
))
1164 /* XXX MORE UGLY HACK
1165 actions from clicks on client windows are NOT queued.
1166 this solves the mysterious click-and-drag-doesnt-work
1167 problem. it was because the window gets focused and stuff
1168 after the button event has already been passed through. i
1169 dont really know why it should care but it does and it makes
1172 however this very bogus ! !
1173 we want to send the button press to the window BEFORE
1174 we do the action because the action might move the windows
1175 (eg change desktops) and then the button press ends up on
1176 the completely wrong window !
1177 so, this is just for that bug, and it will only NOT queue it
1178 if it is a focusing action that can be used with the mouse
1181 also with the menus, there is a race going on. if the
1182 desktop wants to pop up a menu, and we do to, we send them
1183 the button before we pop up the menu, so they pop up their
1184 menu first. but not always. if we pop up our menu before
1185 sending them the button press, then the result is
1190 ob_main_loop_queue_action(ob_main_loop
, a
);
1195 void action_run_string(const gchar
*name
, struct _ObClient
*c
, Time time
)
1200 a
= action_from_string(name
, OB_USER_ACTION_NONE
);
1203 l
= g_slist_append(NULL
, a
);
1205 action_run(l
, c
, 0, time
);
1208 void action_debug(union ActionData
*data
)
1210 if (data
->debug
.string
)
1211 g_print("%s\n", data
->debug
.string
);
1214 void action_execute(union ActionData
*data
)
1217 gchar
*cmd
, **argv
= 0;
1218 if (data
->execute
.path
) {
1219 cmd
= g_filename_from_utf8(data
->execute
.path
, -1, NULL
, NULL
, NULL
);
1221 /* If there is an interactive action going on, then cancel it
1222 to release the keyboard, so that the run application
1223 can grab the keyboard if it wants to. */
1224 if (keyboard_interactively_grabbed())
1225 keyboard_interactive_cancel();
1227 if (!g_shell_parse_argv (cmd
, NULL
, &argv
, &e
)) {
1228 g_message(_("Failed to execute '%s': %s"),
1231 } else if (data
->execute
.startupnotify
) {
1234 program
= g_path_get_basename(argv
[0]);
1235 /* sets up the environment */
1236 sn_setup_spawn_environment(program
,
1238 data
->execute
.icon_name
,
1239 /* launch it on the current
1242 data
->execute
.any
.time
);
1243 if (!g_spawn_async(NULL
, argv
, NULL
, G_SPAWN_SEARCH_PATH
|
1244 G_SPAWN_DO_NOT_REAP_CHILD
,
1245 NULL
, NULL
, NULL
, &e
)) {
1246 g_message(_("Failed to execute '%s': %s"),
1251 unsetenv("DESKTOP_STARTUP_ID");
1255 if (!g_spawn_async(NULL
, argv
, NULL
, G_SPAWN_SEARCH_PATH
|
1256 G_SPAWN_DO_NOT_REAP_CHILD
,
1257 NULL
, NULL
, NULL
, &e
))
1259 g_message(_("Failed to execute '%s': %s"),
1267 g_message(_("Failed to convert the path '%s' from utf8"),
1268 data
->execute
.path
);
1273 void action_activate(union ActionData
*data
)
1275 if (data
->client
.any
.c
) {
1276 if (!data
->any
.button
|| client_mouse_focusable(data
->client
.any
.c
) ||
1277 (data
->any
.context
!= OB_FRAME_CONTEXT_CLIENT
&&
1278 data
->any
.context
!= OB_FRAME_CONTEXT_FRAME
))
1280 /* if using focus_delay, stop the timer now so that focus doesn't
1282 event_halt_focus_delay();
1284 client_activate(data
->activate
.any
.c
, data
->activate
.here
, TRUE
);
1287 /* focus action on something other than a client, make keybindings
1288 work for this openbox instance, but don't focus any specific client
1294 void action_focus(union ActionData
*data
)
1296 if (data
->client
.any
.c
) {
1297 if (!data
->any
.button
|| client_mouse_focusable(data
->client
.any
.c
) ||
1298 (data
->any
.context
!= OB_FRAME_CONTEXT_CLIENT
&&
1299 data
->any
.context
!= OB_FRAME_CONTEXT_FRAME
))
1301 /* if using focus_delay, stop the timer now so that focus doesn't
1303 event_halt_focus_delay();
1305 client_focus(data
->client
.any
.c
);
1308 /* focus action on something other than a client, make keybindings
1309 work for this openbox instance, but don't focus any specific client
1315 void action_unfocus (union ActionData
*data
)
1317 if (data
->client
.any
.c
== focus_client
)
1318 focus_fallback(FALSE
);
1321 void action_iconify(union ActionData
*data
)
1323 client_action_start(data
);
1324 client_iconify(data
->client
.any
.c
, TRUE
, TRUE
, FALSE
);
1325 client_action_end(data
);
1328 void action_focus_order_to_bottom(union ActionData
*data
)
1330 focus_order_to_bottom(data
->client
.any
.c
);
1333 void action_raiselower(union ActionData
*data
)
1335 ObClient
*c
= data
->client
.any
.c
;
1337 gboolean raise
= FALSE
;
1339 for (it
= stacking_list
; it
; it
= g_list_next(it
)) {
1340 if (WINDOW_IS_CLIENT(it
->data
)) {
1341 ObClient
*cit
= it
->data
;
1343 if (cit
== c
) break;
1344 if (client_normal(cit
) == client_normal(c
) &&
1345 cit
->layer
== c
->layer
&&
1346 cit
->frame
->visible
&&
1347 !client_search_transient(c
, cit
))
1349 if (RECT_INTERSECTS_RECT(cit
->frame
->area
, c
->frame
->area
)) {
1363 void action_raise(union ActionData
*data
)
1365 client_action_start(data
);
1366 stacking_raise(CLIENT_AS_WINDOW(data
->client
.any
.c
));
1367 client_action_end(data
);
1370 void action_unshaderaise(union ActionData
*data
)
1372 if (data
->client
.any
.c
->shaded
)
1373 action_unshade(data
);
1378 void action_shadelower(union ActionData
*data
)
1380 if (data
->client
.any
.c
->shaded
)
1386 void action_lower(union ActionData
*data
)
1388 client_action_start(data
);
1389 stacking_lower(CLIENT_AS_WINDOW(data
->client
.any
.c
));
1390 client_action_end(data
);
1393 void action_close(union ActionData
*data
)
1395 client_close(data
->client
.any
.c
);
1398 void action_kill(union ActionData
*data
)
1400 client_kill(data
->client
.any
.c
);
1403 void action_shade(union ActionData
*data
)
1405 client_action_start(data
);
1406 client_shade(data
->client
.any
.c
, TRUE
);
1407 client_action_end(data
);
1410 void action_unshade(union ActionData
*data
)
1412 client_action_start(data
);
1413 client_shade(data
->client
.any
.c
, FALSE
);
1414 client_action_end(data
);
1417 void action_toggle_shade(union ActionData
*data
)
1419 client_action_start(data
);
1420 client_shade(data
->client
.any
.c
, !data
->client
.any
.c
->shaded
);
1421 client_action_end(data
);
1424 void action_toggle_omnipresent(union ActionData
*data
)
1426 client_set_desktop(data
->client
.any
.c
,
1427 data
->client
.any
.c
->desktop
== DESKTOP_ALL
?
1428 screen_desktop
: DESKTOP_ALL
, FALSE
);
1431 void action_move_relative_horz(union ActionData
*data
)
1433 ObClient
*c
= data
->relative
.any
.c
;
1434 client_action_start(data
);
1435 client_move(c
, c
->area
.x
+ data
->relative
.deltax
, c
->area
.y
);
1436 client_action_end(data
);
1439 void action_move_relative_vert(union ActionData
*data
)
1441 ObClient
*c
= data
->relative
.any
.c
;
1442 client_action_start(data
);
1443 client_move(c
, c
->area
.x
, c
->area
.y
+ data
->relative
.deltax
);
1444 client_action_end(data
);
1447 void action_move_to_center(union ActionData
*data
)
1449 ObClient
*c
= data
->client
.any
.c
;
1451 area
= screen_area_monitor(c
->desktop
, 0);
1452 client_action_start(data
);
1453 client_move(c
, area
->width
/ 2 - c
->area
.width
/ 2,
1454 area
->height
/ 2 - c
->area
.height
/ 2);
1455 client_action_end(data
);
1458 void action_resize_relative_horz(union ActionData
*data
)
1460 ObClient
*c
= data
->relative
.any
.c
;
1461 client_action_start(data
);
1463 c
->area
.width
+ data
->relative
.deltax
* c
->size_inc
.width
,
1465 client_action_end(data
);
1468 void action_resize_relative_vert(union ActionData
*data
)
1470 ObClient
*c
= data
->relative
.any
.c
;
1472 client_action_start(data
);
1473 client_resize(c
, c
->area
.width
, c
->area
.height
+
1474 data
->relative
.deltax
* c
->size_inc
.height
);
1475 client_action_end(data
);
1479 void action_move_relative(union ActionData
*data
)
1481 ObClient
*c
= data
->relative
.any
.c
;
1482 client_action_start(data
);
1483 client_move(c
, c
->area
.x
+ data
->relative
.deltax
, c
->area
.y
+
1484 data
->relative
.deltay
);
1485 client_action_end(data
);
1488 void action_resize_relative(union ActionData
*data
)
1490 ObClient
*c
= data
->relative
.any
.c
;
1491 gint x
, y
, ow
, w
, oh
, h
, lw
, lh
;
1493 client_action_start(data
);
1498 w
= ow
+ data
->relative
.deltax
* c
->size_inc
.width
1499 + data
->relative
.deltaxl
* c
->size_inc
.width
;
1500 oh
= c
->area
.height
;
1501 h
= oh
+ data
->relative
.deltay
* c
->size_inc
.height
1502 + data
->relative
.deltayu
* c
->size_inc
.height
;
1504 client_try_configure(c
, &x
, &y
, &w
, &h
, &lw
, &lh
, TRUE
);
1505 client_move_resize(c
, x
+ (ow
- w
), y
+ (oh
- h
), w
, h
);
1506 client_action_end(data
);
1509 void action_maximize_full(union ActionData
*data
)
1511 client_action_start(data
);
1512 client_maximize(data
->client
.any
.c
, TRUE
, 0);
1513 client_action_end(data
);
1516 void action_unmaximize_full(union ActionData
*data
)
1518 client_action_start(data
);
1519 client_maximize(data
->client
.any
.c
, FALSE
, 0);
1520 client_action_end(data
);
1523 void action_toggle_maximize_full(union ActionData
*data
)
1525 client_action_start(data
);
1526 client_maximize(data
->client
.any
.c
,
1527 !(data
->client
.any
.c
->max_horz
||
1528 data
->client
.any
.c
->max_vert
),
1530 client_action_end(data
);
1533 void action_maximize_horz(union ActionData
*data
)
1535 client_action_start(data
);
1536 client_maximize(data
->client
.any
.c
, TRUE
, 1);
1537 client_action_end(data
);
1540 void action_unmaximize_horz(union ActionData
*data
)
1542 client_action_start(data
);
1543 client_maximize(data
->client
.any
.c
, FALSE
, 1);
1544 client_action_end(data
);
1547 void action_toggle_maximize_horz(union ActionData
*data
)
1549 client_action_start(data
);
1550 client_maximize(data
->client
.any
.c
,
1551 !data
->client
.any
.c
->max_horz
, 1);
1552 client_action_end(data
);
1555 void action_maximize_vert(union ActionData
*data
)
1557 client_action_start(data
);
1558 client_maximize(data
->client
.any
.c
, TRUE
, 2);
1559 client_action_end(data
);
1562 void action_unmaximize_vert(union ActionData
*data
)
1564 client_action_start(data
);
1565 client_maximize(data
->client
.any
.c
, FALSE
, 2);
1566 client_action_end(data
);
1569 void action_toggle_maximize_vert(union ActionData
*data
)
1571 client_action_start(data
);
1572 client_maximize(data
->client
.any
.c
,
1573 !data
->client
.any
.c
->max_vert
, 2);
1574 client_action_end(data
);
1577 void action_toggle_fullscreen(union ActionData
*data
)
1579 client_action_start(data
);
1580 client_fullscreen(data
->client
.any
.c
, !(data
->client
.any
.c
->fullscreen
));
1581 client_action_end(data
);
1584 void action_send_to_desktop(union ActionData
*data
)
1586 ObClient
*c
= data
->sendto
.any
.c
;
1588 if (!client_normal(c
)) return;
1590 if (data
->sendto
.desk
< screen_num_desktops
||
1591 data
->sendto
.desk
== DESKTOP_ALL
) {
1592 client_set_desktop(c
, data
->sendto
.desk
, data
->sendto
.follow
);
1593 if (data
->sendto
.follow
)
1594 screen_set_desktop(data
->sendto
.desk
, TRUE
);
1598 void action_desktop(union ActionData
*data
)
1600 /* XXX add the interactive/dialog option back again once the dialog
1601 has been made to not use grabs */
1602 if (data
->desktop
.desk
< screen_num_desktops
||
1603 data
->desktop
.desk
== DESKTOP_ALL
)
1605 screen_set_desktop(data
->desktop
.desk
, TRUE
);
1606 if (data
->inter
.any
.interactive
)
1607 screen_desktop_popup(data
->desktop
.desk
, TRUE
);
1611 void action_desktop_dir(union ActionData
*data
)
1615 d
= screen_cycle_desktop(data
->desktopdir
.dir
,
1616 data
->desktopdir
.wrap
,
1617 data
->desktopdir
.linear
,
1618 data
->desktopdir
.inter
.any
.interactive
,
1619 data
->desktopdir
.inter
.final
,
1620 data
->desktopdir
.inter
.cancel
);
1621 /* only move the desktop when the action is complete. if we switch
1622 desktops during the interactive action, focus will move but with
1623 NotifyWhileGrabbed and applications don't like that. */
1624 if (!data
->sendtodir
.inter
.any
.interactive
||
1625 (data
->sendtodir
.inter
.final
&& !data
->sendtodir
.inter
.cancel
))
1627 if (d
!= screen_desktop
) screen_set_desktop(d
, TRUE
);
1631 void action_send_to_desktop_dir(union ActionData
*data
)
1633 ObClient
*c
= data
->sendtodir
.inter
.any
.c
;
1636 if (!client_normal(c
)) return;
1638 d
= screen_cycle_desktop(data
->sendtodir
.dir
, data
->sendtodir
.wrap
,
1639 data
->sendtodir
.linear
,
1640 data
->sendtodir
.inter
.any
.interactive
,
1641 data
->sendtodir
.inter
.final
,
1642 data
->sendtodir
.inter
.cancel
);
1643 /* only move the desktop when the action is complete. if we switch
1644 desktops during the interactive action, focus will move but with
1645 NotifyWhileGrabbed and applications don't like that. */
1646 if (!data
->sendtodir
.inter
.any
.interactive
||
1647 (data
->sendtodir
.inter
.final
&& !data
->sendtodir
.inter
.cancel
))
1649 client_set_desktop(c
, d
, data
->sendtodir
.follow
);
1650 if (data
->sendtodir
.follow
&& d
!= screen_desktop
)
1651 screen_set_desktop(d
, TRUE
);
1655 void action_desktop_last(union ActionData
*data
)
1657 screen_set_desktop(screen_last_desktop
, TRUE
);
1660 void action_toggle_decorations(union ActionData
*data
)
1662 ObClient
*c
= data
->client
.any
.c
;
1664 client_action_start(data
);
1665 client_set_undecorated(c
, !c
->undecorated
);
1666 client_action_end(data
);
1669 static guint32
pick_corner(gint x
, gint y
, gint cx
, gint cy
, gint cw
, gint ch
,
1672 /* let's make x and y client relative instead of screen relative */
1674 y
= ch
- (y
- cy
); /* y is inverted, 0 is at the bottom of the window */
1677 #define A -4*X + 7*ch/3
1678 #define B 4*X -15*ch/9
1679 #define C -X/4 + 2*ch/3
1680 #define D X/4 + 5*ch/12
1681 #define E X/4 + ch/3
1682 #define F -X/4 + 7*ch/12
1683 #define G 4*X - 4*ch/3
1684 #define H -4*X + 8*ch/3
1685 #define a (y > 5*ch/9)
1686 #define b (x < 4*cw/9)
1687 #define c (x > 5*cw/9)
1688 #define d (y < 4*ch/9)
1691 Each of these defines (except X which is just there for fun), represents
1692 the equation of a line. The lines they represent are shown in the diagram
1693 below. Checking y against these lines, we are able to choose a region
1694 of the window as shown.
1696 +---------------------A-------|-------|-------B---------------------+
1703 | northwest | A north B | northeast |
1706 C---------------------+----A--+-------+--B----+---------------------D
1707 |CCCCCCC | A B | DDDDDDD|
1708 | CCCCCCCC | A | | B | DDDDDDDD |
1709 | CCCCCCC A B DDDDDDD |
1710 - - - - - - - - - - - +CCCCCCC+aaaaaaa+DDDDDDD+ - - - - - - - - - - - -
1712 | west | b move c | east | ad
1714 - - - - - - - - - - - +EEEEEEE+ddddddd+FFFFFFF+- - - - - - - - - - - -
1715 | EEEEEEE G H FFFFFFF |
1716 | EEEEEEEE | G | | H | FFFFFFFF |
1717 |EEEEEEE | G H | FFFFFFF|
1718 E---------------------+----G--+-------+--H----+---------------------F
1721 | southwest | G south H | southeast |
1728 +---------------------G-------|-------|-------H---------------------+
1732 /* for shaded windows, you can only resize west/east and move */
1734 return prop_atoms
.net_wm_moveresize_size_left
;
1736 return prop_atoms
.net_wm_moveresize_size_right
;
1737 return prop_atoms
.net_wm_moveresize_move
;
1740 if (y
< A
&& y
>= C
)
1741 return prop_atoms
.net_wm_moveresize_size_topleft
;
1742 else if (y
>= A
&& y
>= B
&& a
)
1743 return prop_atoms
.net_wm_moveresize_size_top
;
1744 else if (y
< B
&& y
>= D
)
1745 return prop_atoms
.net_wm_moveresize_size_topright
;
1746 else if (y
< C
&& y
>= E
&& b
)
1747 return prop_atoms
.net_wm_moveresize_size_left
;
1748 else if (y
< D
&& y
>= F
&& c
)
1749 return prop_atoms
.net_wm_moveresize_size_right
;
1750 else if (y
< E
&& y
>= G
)
1751 return prop_atoms
.net_wm_moveresize_size_bottomleft
;
1752 else if (y
< G
&& y
< H
&& d
)
1753 return prop_atoms
.net_wm_moveresize_size_bottom
;
1754 else if (y
>= H
&& y
< F
)
1755 return prop_atoms
.net_wm_moveresize_size_bottomright
;
1757 return prop_atoms
.net_wm_moveresize_move
;
1774 void action_move(union ActionData
*data
)
1776 ObClient
*c
= data
->moveresize
.any
.c
;
1779 if (data
->moveresize
.keyboard
)
1780 corner
= prop_atoms
.net_wm_moveresize_move_keyboard
;
1782 corner
= prop_atoms
.net_wm_moveresize_move
;
1784 moveresize_start(c
, data
->any
.x
, data
->any
.y
, data
->any
.button
, corner
);
1787 void action_resize(union ActionData
*data
)
1789 ObClient
*c
= data
->moveresize
.any
.c
;
1792 if (data
->moveresize
.keyboard
)
1793 corner
= prop_atoms
.net_wm_moveresize_size_keyboard
;
1794 else if (data
->moveresize
.corner
)
1795 corner
= data
->moveresize
.corner
; /* it was specified in the binding */
1797 corner
= pick_corner(data
->any
.x
, data
->any
.y
,
1798 c
->frame
->area
.x
, c
->frame
->area
.y
,
1799 /* use the client size because the frame
1800 can be differently sized (shaded
1801 windows) and we want this based on the
1803 c
->area
.width
+ c
->frame
->size
.left
+
1804 c
->frame
->size
.right
,
1805 c
->area
.height
+ c
->frame
->size
.top
+
1806 c
->frame
->size
.bottom
, c
->shaded
);
1808 moveresize_start(c
, data
->any
.x
, data
->any
.y
, data
->any
.button
, corner
);
1811 void action_reconfigure(union ActionData
*data
)
1816 void action_restart(union ActionData
*data
)
1818 ob_restart_other(data
->execute
.path
);
1821 void action_exit(union ActionData
*data
)
1826 void action_showmenu(union ActionData
*data
)
1828 if (data
->showmenu
.name
) {
1829 menu_show(data
->showmenu
.name
, data
->any
.x
, data
->any
.y
,
1830 data
->any
.button
, data
->showmenu
.any
.c
);
1834 void action_cycle_windows(union ActionData
*data
)
1836 /* if using focus_delay, stop the timer now so that focus doesn't go moving
1838 event_halt_focus_delay();
1840 focus_cycle(data
->cycle
.forward
,
1841 data
->cycle
.all_desktops
,
1842 data
->cycle
.dock_windows
,
1843 data
->cycle
.desktop_windows
,
1844 data
->cycle
.linear
, data
->any
.interactive
,
1846 data
->cycle
.inter
.final
, data
->cycle
.inter
.cancel
);
1849 void action_directional_focus(union ActionData
*data
)
1851 /* if using focus_delay, stop the timer now so that focus doesn't go moving
1853 event_halt_focus_delay();
1855 focus_directional_cycle(data
->interdiraction
.direction
,
1856 data
->interdiraction
.dock_windows
,
1857 data
->interdiraction
.desktop_windows
,
1858 data
->any
.interactive
,
1859 data
->interdiraction
.dialog
,
1860 data
->interdiraction
.inter
.final
,
1861 data
->interdiraction
.inter
.cancel
);
1864 void action_movetoedge(union ActionData
*data
)
1867 ObClient
*c
= data
->diraction
.any
.c
;
1869 x
= c
->frame
->area
.x
;
1870 y
= c
->frame
->area
.y
;
1872 switch(data
->diraction
.direction
) {
1873 case OB_DIRECTION_NORTH
:
1874 y
= client_directional_edge_search(c
, OB_DIRECTION_NORTH
,
1875 data
->diraction
.hang
)
1876 - (data
->diraction
.hang
? c
->frame
->area
.height
: 0);
1878 case OB_DIRECTION_WEST
:
1879 x
= client_directional_edge_search(c
, OB_DIRECTION_WEST
,
1880 data
->diraction
.hang
)
1881 - (data
->diraction
.hang
? c
->frame
->area
.width
: 0);
1883 case OB_DIRECTION_SOUTH
:
1884 y
= client_directional_edge_search(c
, OB_DIRECTION_SOUTH
,
1885 data
->diraction
.hang
)
1886 - (data
->diraction
.hang
? 0 : c
->frame
->area
.height
);
1888 case OB_DIRECTION_EAST
:
1889 x
= client_directional_edge_search(c
, OB_DIRECTION_EAST
,
1890 data
->diraction
.hang
)
1891 - (data
->diraction
.hang
? 0 : c
->frame
->area
.width
);
1894 g_assert_not_reached();
1896 frame_frame_gravity(c
->frame
, &x
, &y
, c
->area
.width
, c
->area
.height
);
1897 client_action_start(data
);
1898 client_move(c
, x
, y
);
1899 client_action_end(data
);
1902 void action_growtoedge(union ActionData
*data
)
1904 gint x
, y
, width
, height
, dest
;
1905 ObClient
*c
= data
->diraction
.any
.c
;
1908 a
= screen_area(c
->desktop
);
1909 x
= c
->frame
->area
.x
;
1910 y
= c
->frame
->area
.y
;
1911 /* get the unshaded frame's dimensions..if it is shaded */
1912 width
= c
->area
.width
+ c
->frame
->size
.left
+ c
->frame
->size
.right
;
1913 height
= c
->area
.height
+ c
->frame
->size
.top
+ c
->frame
->size
.bottom
;
1915 switch(data
->diraction
.direction
) {
1916 case OB_DIRECTION_NORTH
:
1917 if (c
->shaded
) break; /* don't allow vertical resize if shaded */
1919 dest
= client_directional_edge_search(c
, OB_DIRECTION_NORTH
, FALSE
);
1921 height
= height
/ 2;
1923 height
= c
->frame
->area
.y
+ height
- dest
;
1927 case OB_DIRECTION_WEST
:
1928 dest
= client_directional_edge_search(c
, OB_DIRECTION_WEST
, FALSE
);
1932 width
= c
->frame
->area
.x
+ width
- dest
;
1936 case OB_DIRECTION_SOUTH
:
1937 if (c
->shaded
) break; /* don't allow vertical resize if shaded */
1939 dest
= client_directional_edge_search(c
, OB_DIRECTION_SOUTH
, FALSE
);
1940 if (a
->y
+ a
->height
== y
+ c
->frame
->area
.height
) {
1941 height
= c
->frame
->area
.height
/ 2;
1942 y
= a
->y
+ a
->height
- height
;
1944 height
= dest
- c
->frame
->area
.y
;
1945 y
+= (height
- c
->frame
->area
.height
) % c
->size_inc
.height
;
1946 height
-= (height
- c
->frame
->area
.height
) % c
->size_inc
.height
;
1948 case OB_DIRECTION_EAST
:
1949 dest
= client_directional_edge_search(c
, OB_DIRECTION_EAST
, FALSE
);
1950 if (a
->x
+ a
->width
== x
+ c
->frame
->area
.width
) {
1951 width
= c
->frame
->area
.width
/ 2;
1952 x
= a
->x
+ a
->width
- width
;
1954 width
= dest
- c
->frame
->area
.x
;
1955 x
+= (width
- c
->frame
->area
.width
) % c
->size_inc
.width
;
1956 width
-= (width
- c
->frame
->area
.width
) % c
->size_inc
.width
;
1959 g_assert_not_reached();
1961 width
-= c
->frame
->size
.left
+ c
->frame
->size
.right
;
1962 height
-= c
->frame
->size
.top
+ c
->frame
->size
.bottom
;
1963 frame_frame_gravity(c
->frame
, &x
, &y
, width
, height
);
1964 client_action_start(data
);
1965 client_move_resize(c
, x
, y
, width
, height
);
1966 client_action_end(data
);
1969 void action_send_to_layer(union ActionData
*data
)
1971 client_set_layer(data
->layer
.any
.c
, data
->layer
.layer
);
1974 void action_toggle_layer(union ActionData
*data
)
1976 ObClient
*c
= data
->layer
.any
.c
;
1978 client_action_start(data
);
1979 if (data
->layer
.layer
< 0)
1980 client_set_layer(c
, c
->below
? 0 : -1);
1981 else if (data
->layer
.layer
> 0)
1982 client_set_layer(c
, c
->above
? 0 : 1);
1983 client_action_end(data
);
1986 void action_toggle_dockautohide(union ActionData
*data
)
1988 config_dock_hide
= !config_dock_hide
;
1992 void action_toggle_show_desktop(union ActionData
*data
)
1994 screen_show_desktop(!screen_showing_desktop
, NULL
);
1997 void action_show_desktop(union ActionData
*data
)
1999 screen_show_desktop(TRUE
, NULL
);
2002 void action_unshow_desktop(union ActionData
*data
)
2004 screen_show_desktop(FALSE
, NULL
);
2007 void action_break_chroot(union ActionData
*data
)
2009 /* break out of one chroot */
2010 keyboard_reset_chains(1);