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(TRUE
, 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
&& !data
->any
.button
)
52 grab_pointer(FALSE
, FALSE
, OB_CURSOR_NONE
);
58 void (*func
)(union ActionData
*);
59 void (*setup
)(ObAction
**, ObUserAction uact
);
62 static ObAction
*action_new(void (*func
)(union ActionData
*data
))
64 ObAction
*a
= g_new0(ObAction
, 1);
71 void action_ref(ObAction
*a
)
76 void action_unref(ObAction
*a
)
78 if (a
== NULL
) return;
80 if (--a
->ref
> 0) return;
82 /* deal with pointers */
83 if (a
->func
== action_execute
|| a
->func
== action_restart
)
84 g_free(a
->data
.execute
.path
);
85 else if (a
->func
== action_showmenu
)
86 g_free(a
->data
.showmenu
.name
);
91 ObAction
* action_copy(const ObAction
*src
)
93 ObAction
*a
= action_new(src
->func
);
97 /* deal with pointers */
98 if (a
->func
== action_execute
|| a
->func
== action_restart
)
99 a
->data
.execute
.path
= g_strdup(a
->data
.execute
.path
);
100 else if (a
->func
== action_showmenu
)
101 a
->data
.showmenu
.name
= g_strdup(a
->data
.showmenu
.name
);
106 void setup_action_directional_focus_north(ObAction
**a
, ObUserAction uact
)
108 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
109 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_NORTH
;
110 (*a
)->data
.interdiraction
.dialog
= TRUE
;
111 (*a
)->data
.interdiraction
.dock_windows
= FALSE
;
112 (*a
)->data
.interdiraction
.desktop_windows
= FALSE
;
115 void setup_action_directional_focus_east(ObAction
**a
, ObUserAction uact
)
117 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
118 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_EAST
;
119 (*a
)->data
.interdiraction
.dialog
= TRUE
;
120 (*a
)->data
.interdiraction
.dock_windows
= FALSE
;
121 (*a
)->data
.interdiraction
.desktop_windows
= FALSE
;
124 void setup_action_directional_focus_south(ObAction
**a
, ObUserAction uact
)
126 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
127 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_SOUTH
;
128 (*a
)->data
.interdiraction
.dialog
= TRUE
;
129 (*a
)->data
.interdiraction
.dock_windows
= FALSE
;
130 (*a
)->data
.interdiraction
.desktop_windows
= FALSE
;
133 void setup_action_directional_focus_west(ObAction
**a
, ObUserAction uact
)
135 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
136 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_WEST
;
137 (*a
)->data
.interdiraction
.dialog
= TRUE
;
138 (*a
)->data
.interdiraction
.dock_windows
= FALSE
;
139 (*a
)->data
.interdiraction
.desktop_windows
= FALSE
;
142 void setup_action_directional_focus_northeast(ObAction
**a
, ObUserAction uact
)
144 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
145 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_NORTHEAST
;
146 (*a
)->data
.interdiraction
.dialog
= TRUE
;
147 (*a
)->data
.interdiraction
.dock_windows
= FALSE
;
148 (*a
)->data
.interdiraction
.desktop_windows
= FALSE
;
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
;
156 (*a
)->data
.interdiraction
.dock_windows
= FALSE
;
157 (*a
)->data
.interdiraction
.desktop_windows
= FALSE
;
160 void setup_action_directional_focus_southwest(ObAction
**a
, ObUserAction uact
)
162 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
163 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_SOUTHWEST
;
164 (*a
)->data
.interdiraction
.dialog
= TRUE
;
165 (*a
)->data
.interdiraction
.dock_windows
= FALSE
;
166 (*a
)->data
.interdiraction
.desktop_windows
= FALSE
;
169 void setup_action_directional_focus_northwest(ObAction
**a
, ObUserAction uact
)
171 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
172 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_NORTHWEST
;
173 (*a
)->data
.interdiraction
.dialog
= TRUE
;
174 (*a
)->data
.interdiraction
.dock_windows
= FALSE
;
175 (*a
)->data
.interdiraction
.desktop_windows
= FALSE
;
178 void setup_action_send_to_desktop(ObAction
**a
, ObUserAction uact
)
180 (*a
)->data
.sendto
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
181 (*a
)->data
.sendto
.follow
= TRUE
;
184 void setup_action_send_to_desktop_prev(ObAction
**a
, ObUserAction uact
)
186 (*a
)->data
.sendtodir
.inter
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
187 (*a
)->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
188 (*a
)->data
.sendtodir
.dir
= OB_DIRECTION_WEST
;
189 (*a
)->data
.sendtodir
.linear
= TRUE
;
190 (*a
)->data
.sendtodir
.wrap
= TRUE
;
191 (*a
)->data
.sendtodir
.follow
= TRUE
;
194 void setup_action_send_to_desktop_next(ObAction
**a
, ObUserAction uact
)
196 (*a
)->data
.sendtodir
.inter
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
197 (*a
)->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
198 (*a
)->data
.sendtodir
.dir
= OB_DIRECTION_EAST
;
199 (*a
)->data
.sendtodir
.linear
= TRUE
;
200 (*a
)->data
.sendtodir
.wrap
= TRUE
;
201 (*a
)->data
.sendtodir
.follow
= TRUE
;
204 void setup_action_send_to_desktop_left(ObAction
**a
, ObUserAction uact
)
206 (*a
)->data
.sendtodir
.inter
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
207 (*a
)->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
208 (*a
)->data
.sendtodir
.dir
= OB_DIRECTION_WEST
;
209 (*a
)->data
.sendtodir
.linear
= FALSE
;
210 (*a
)->data
.sendtodir
.wrap
= TRUE
;
211 (*a
)->data
.sendtodir
.follow
= TRUE
;
214 void setup_action_send_to_desktop_right(ObAction
**a
, ObUserAction uact
)
216 (*a
)->data
.sendtodir
.inter
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
217 (*a
)->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
218 (*a
)->data
.sendtodir
.dir
= OB_DIRECTION_EAST
;
219 (*a
)->data
.sendtodir
.linear
= FALSE
;
220 (*a
)->data
.sendtodir
.wrap
= TRUE
;
221 (*a
)->data
.sendtodir
.follow
= TRUE
;
224 void setup_action_send_to_desktop_up(ObAction
**a
, ObUserAction uact
)
226 (*a
)->data
.sendtodir
.inter
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
227 (*a
)->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
228 (*a
)->data
.sendtodir
.dir
= OB_DIRECTION_NORTH
;
229 (*a
)->data
.sendtodir
.linear
= FALSE
;
230 (*a
)->data
.sendtodir
.wrap
= TRUE
;
231 (*a
)->data
.sendtodir
.follow
= TRUE
;
234 void setup_action_send_to_desktop_down(ObAction
**a
, ObUserAction uact
)
236 (*a
)->data
.sendtodir
.inter
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
237 (*a
)->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
238 (*a
)->data
.sendtodir
.dir
= OB_DIRECTION_SOUTH
;
239 (*a
)->data
.sendtodir
.linear
= FALSE
;
240 (*a
)->data
.sendtodir
.wrap
= TRUE
;
241 (*a
)->data
.sendtodir
.follow
= TRUE
;
244 void setup_action_desktop(ObAction
**a
, ObUserAction uact
)
246 (*a
)->data
.desktop
.inter
.any
.interactive
= FALSE
;
249 void setup_action_desktop_prev(ObAction
**a
, ObUserAction uact
)
251 (*a
)->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
252 (*a
)->data
.desktopdir
.dir
= OB_DIRECTION_WEST
;
253 (*a
)->data
.desktopdir
.linear
= TRUE
;
254 (*a
)->data
.desktopdir
.wrap
= TRUE
;
257 void setup_action_desktop_next(ObAction
**a
, ObUserAction uact
)
259 (*a
)->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
260 (*a
)->data
.desktopdir
.dir
= OB_DIRECTION_EAST
;
261 (*a
)->data
.desktopdir
.linear
= TRUE
;
262 (*a
)->data
.desktopdir
.wrap
= TRUE
;
265 void setup_action_desktop_left(ObAction
**a
, ObUserAction uact
)
267 (*a
)->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
268 (*a
)->data
.desktopdir
.dir
= OB_DIRECTION_WEST
;
269 (*a
)->data
.desktopdir
.linear
= FALSE
;
270 (*a
)->data
.desktopdir
.wrap
= TRUE
;
273 void setup_action_desktop_right(ObAction
**a
, ObUserAction uact
)
275 (*a
)->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
276 (*a
)->data
.desktopdir
.dir
= OB_DIRECTION_EAST
;
277 (*a
)->data
.desktopdir
.linear
= FALSE
;
278 (*a
)->data
.desktopdir
.wrap
= TRUE
;
281 void setup_action_desktop_up(ObAction
**a
, ObUserAction uact
)
283 (*a
)->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
284 (*a
)->data
.desktopdir
.dir
= OB_DIRECTION_NORTH
;
285 (*a
)->data
.desktopdir
.linear
= FALSE
;
286 (*a
)->data
.desktopdir
.wrap
= TRUE
;
289 void setup_action_desktop_down(ObAction
**a
, ObUserAction uact
)
291 (*a
)->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
292 (*a
)->data
.desktopdir
.dir
= OB_DIRECTION_SOUTH
;
293 (*a
)->data
.desktopdir
.linear
= FALSE
;
294 (*a
)->data
.desktopdir
.wrap
= TRUE
;
297 void setup_action_cycle_windows_next(ObAction
**a
, ObUserAction uact
)
299 (*a
)->data
.cycle
.inter
.any
.interactive
= TRUE
;
300 (*a
)->data
.cycle
.linear
= FALSE
;
301 (*a
)->data
.cycle
.forward
= TRUE
;
302 (*a
)->data
.cycle
.dialog
= TRUE
;
303 (*a
)->data
.cycle
.dock_windows
= FALSE
;
304 (*a
)->data
.cycle
.desktop_windows
= FALSE
;
305 (*a
)->data
.cycle
.all_desktops
= FALSE
;
308 void setup_action_cycle_windows_previous(ObAction
**a
, ObUserAction uact
)
310 (*a
)->data
.cycle
.inter
.any
.interactive
= TRUE
;
311 (*a
)->data
.cycle
.linear
= FALSE
;
312 (*a
)->data
.cycle
.forward
= FALSE
;
313 (*a
)->data
.cycle
.dialog
= TRUE
;
314 (*a
)->data
.cycle
.dock_windows
= FALSE
;
315 (*a
)->data
.cycle
.desktop_windows
= FALSE
;
316 (*a
)->data
.cycle
.all_desktops
= FALSE
;
319 void setup_action_movefromedge_north(ObAction
**a
, ObUserAction uact
)
321 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
322 (*a
)->data
.diraction
.direction
= OB_DIRECTION_NORTH
;
323 (*a
)->data
.diraction
.hang
= TRUE
;
326 void setup_action_movefromedge_south(ObAction
**a
, ObUserAction uact
)
328 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
329 (*a
)->data
.diraction
.direction
= OB_DIRECTION_SOUTH
;
330 (*a
)->data
.diraction
.hang
= TRUE
;
333 void setup_action_movefromedge_east(ObAction
**a
, ObUserAction uact
)
335 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
336 (*a
)->data
.diraction
.direction
= OB_DIRECTION_EAST
;
337 (*a
)->data
.diraction
.hang
= TRUE
;
340 void setup_action_movefromedge_west(ObAction
**a
, ObUserAction uact
)
342 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
343 (*a
)->data
.diraction
.direction
= OB_DIRECTION_WEST
;
344 (*a
)->data
.diraction
.hang
= TRUE
;
347 void setup_action_movetoedge_north(ObAction
**a
, ObUserAction uact
)
349 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
350 (*a
)->data
.diraction
.direction
= OB_DIRECTION_NORTH
;
351 (*a
)->data
.diraction
.hang
= FALSE
;
354 void setup_action_movetoedge_south(ObAction
**a
, ObUserAction uact
)
356 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
357 (*a
)->data
.diraction
.direction
= OB_DIRECTION_SOUTH
;
358 (*a
)->data
.diraction
.hang
= FALSE
;
361 void setup_action_movetoedge_east(ObAction
**a
, ObUserAction uact
)
363 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
364 (*a
)->data
.diraction
.direction
= OB_DIRECTION_EAST
;
365 (*a
)->data
.diraction
.hang
= FALSE
;
368 void setup_action_movetoedge_west(ObAction
**a
, ObUserAction uact
)
370 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
371 (*a
)->data
.diraction
.direction
= OB_DIRECTION_WEST
;
372 (*a
)->data
.diraction
.hang
= FALSE
;
375 void setup_action_growtoedge_north(ObAction
**a
, ObUserAction uact
)
377 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
378 (*a
)->data
.diraction
.direction
= OB_DIRECTION_NORTH
;
381 void setup_action_growtoedge_south(ObAction
**a
, ObUserAction uact
)
383 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
384 (*a
)->data
.diraction
.direction
= OB_DIRECTION_SOUTH
;
387 void setup_action_growtoedge_east(ObAction
**a
, ObUserAction uact
)
389 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
390 (*a
)->data
.diraction
.direction
= OB_DIRECTION_EAST
;
393 void setup_action_growtoedge_west(ObAction
**a
, ObUserAction uact
)
395 (*a
)->data
.diraction
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
396 (*a
)->data
.diraction
.direction
= OB_DIRECTION_WEST
;
399 void setup_action_top_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_normal_layer(ObAction
**a
, ObUserAction uact
)
407 (*a
)->data
.layer
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
408 (*a
)->data
.layer
.layer
= 0;
411 void setup_action_bottom_layer(ObAction
**a
, ObUserAction uact
)
413 (*a
)->data
.layer
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
414 (*a
)->data
.layer
.layer
= -1;
417 void setup_action_move(ObAction
**a
, ObUserAction uact
)
419 (*a
)->data
.moveresize
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
420 (*a
)->data
.moveresize
.keyboard
=
421 (uact
== OB_USER_ACTION_NONE
||
422 uact
== OB_USER_ACTION_KEYBOARD_KEY
||
423 uact
== OB_USER_ACTION_MENU_SELECTION
);
424 (*a
)->data
.moveresize
.corner
= 0;
427 void setup_action_resize(ObAction
**a
, ObUserAction uact
)
429 (*a
)->data
.moveresize
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
430 (*a
)->data
.moveresize
.keyboard
=
431 (uact
== OB_USER_ACTION_NONE
||
432 uact
== OB_USER_ACTION_KEYBOARD_KEY
||
433 uact
== OB_USER_ACTION_MENU_SELECTION
);
434 (*a
)->data
.moveresize
.corner
= 0;
437 void setup_action_showmenu(ObAction
**a
, ObUserAction uact
)
439 (*a
)->data
.showmenu
.any
.client_action
= OB_CLIENT_ACTION_OPTIONAL
;
440 /* you cannot call ShowMenu from inside a menu, cuz the menu code makes
441 assumptions that there is only one menu (and submenus) open at
443 if (uact
== OB_USER_ACTION_MENU_SELECTION
) {
449 void setup_action_focus(ObAction
**a
, ObUserAction uact
)
451 (*a
)->data
.any
.client_action
= OB_CLIENT_ACTION_OPTIONAL
;
454 void setup_client_action(ObAction
**a
, ObUserAction uact
)
456 (*a
)->data
.any
.client_action
= OB_CLIENT_ACTION_ALWAYS
;
459 ActionString actionstrings
[] =
467 "directionalfocusnorth",
468 action_directional_focus
,
469 setup_action_directional_focus_north
472 "directionalfocuseast",
473 action_directional_focus
,
474 setup_action_directional_focus_east
477 "directionalfocussouth",
478 action_directional_focus
,
479 setup_action_directional_focus_south
482 "directionalfocuswest",
483 action_directional_focus
,
484 setup_action_directional_focus_west
487 "directionalfocusnortheast",
488 action_directional_focus
,
489 setup_action_directional_focus_northeast
492 "directionalfocussoutheast",
493 action_directional_focus
,
494 setup_action_directional_focus_southeast
497 "directionalfocussouthwest",
498 action_directional_focus
,
499 setup_action_directional_focus_southwest
502 "directionalfocusnorthwest",
503 action_directional_focus
,
504 setup_action_directional_focus_northwest
528 action_focus_order_to_bottom
,
583 action_toggle_omnipresent
,
588 action_move_relative_horz
,
593 action_move_relative_vert
,
598 action_move_to_center
,
602 "resizerelativehorz",
603 action_resize_relative_horz
,
607 "resizerelativevert",
608 action_resize_relative_vert
,
613 action_move_relative
,
618 action_resize_relative
,
623 action_maximize_full
,
628 action_unmaximize_full
,
632 "togglemaximizefull",
633 action_toggle_maximize_full
,
638 action_maximize_horz
,
643 action_unmaximize_horz
,
647 "togglemaximizehorz",
648 action_toggle_maximize_horz
,
653 action_maximize_vert
,
658 action_unmaximize_vert
,
662 "togglemaximizevert",
663 action_toggle_maximize_vert
,
668 action_toggle_fullscreen
,
673 action_send_to_desktop
,
674 setup_action_send_to_desktop
678 action_send_to_desktop_dir
,
679 setup_action_send_to_desktop_next
682 "sendtodesktopprevious",
683 action_send_to_desktop_dir
,
684 setup_action_send_to_desktop_prev
687 "sendtodesktopright",
688 action_send_to_desktop_dir
,
689 setup_action_send_to_desktop_right
693 action_send_to_desktop_dir
,
694 setup_action_send_to_desktop_left
698 action_send_to_desktop_dir
,
699 setup_action_send_to_desktop_up
703 action_send_to_desktop_dir
,
704 setup_action_send_to_desktop_down
714 setup_action_desktop_next
719 setup_action_desktop_prev
724 setup_action_desktop_right
729 setup_action_desktop_left
734 setup_action_desktop_up
739 setup_action_desktop_down
743 action_toggle_decorations
,
757 "toggledockautohide",
758 action_toggle_dockautohide
,
763 action_toggle_show_desktop
,
773 action_unshow_desktop
,
799 setup_action_showmenu
803 action_send_to_layer
,
804 setup_action_top_layer
809 setup_action_top_layer
813 action_send_to_layer
,
814 setup_action_normal_layer
818 action_send_to_layer
,
819 setup_action_bottom_layer
822 "togglealwaysonbottom",
824 setup_action_bottom_layer
828 action_cycle_windows
,
829 setup_action_cycle_windows_next
833 action_cycle_windows
,
834 setup_action_cycle_windows_previous
839 setup_action_movefromedge_north
844 setup_action_movefromedge_south
849 setup_action_movefromedge_west
854 setup_action_movefromedge_east
859 setup_action_movetoedge_north
864 setup_action_movetoedge_south
869 setup_action_movetoedge_west
874 setup_action_movetoedge_east
879 setup_action_growtoedge_north
884 setup_action_growtoedge_south
889 setup_action_growtoedge_west
894 setup_action_growtoedge_east
908 /* only key bindings can be interactive. thus saith the xor.
909 because of how the mouse is grabbed, mouse events dont even get
910 read during interactive events, so no dice! >:) */
911 #define INTERACTIVE_LIMIT(a, uact) \
912 if (uact != OB_USER_ACTION_KEYBOARD_KEY) \
913 a->data.any.interactive = FALSE;
915 ObAction
*action_from_string(const gchar
*name
, ObUserAction uact
)
918 gboolean exist
= FALSE
;
921 for (i
= 0; actionstrings
[i
].name
; i
++)
922 if (!g_ascii_strcasecmp(name
, actionstrings
[i
].name
)) {
924 a
= action_new(actionstrings
[i
].func
);
925 if (actionstrings
[i
].setup
)
926 actionstrings
[i
].setup(&a
, uact
);
928 INTERACTIVE_LIMIT(a
, uact
);
932 g_message(_("Invalid action '%s' requested. No such action exists."),
935 g_message(_("Invalid use of action '%s'. Action will be ignored."),
940 ObAction
*action_parse(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
944 ObAction
*act
= NULL
;
947 if (parse_attr_string("name", node
, &actname
)) {
948 if ((act
= action_from_string(actname
, uact
))) {
949 if (act
->func
== action_execute
|| act
->func
== action_restart
) {
950 if ((n
= parse_find_node("execute", node
->xmlChildrenNode
))) {
951 gchar
*s
= parse_string(doc
, n
);
952 act
->data
.execute
.path
= parse_expand_tilde(s
);
955 if ((n
= parse_find_node("startupnotify", node
->xmlChildrenNode
))) {
957 if ((m
= parse_find_node("enabled", n
->xmlChildrenNode
)))
958 act
->data
.execute
.startupnotify
= parse_bool(doc
, m
);
959 if ((m
= parse_find_node("name", n
->xmlChildrenNode
)))
960 act
->data
.execute
.name
= parse_string(doc
, m
);
961 if ((m
= parse_find_node("icon", n
->xmlChildrenNode
)))
962 act
->data
.execute
.icon_name
= parse_string(doc
, m
);
964 } else if (act
->func
== action_showmenu
) {
965 if ((n
= parse_find_node("menu", node
->xmlChildrenNode
)))
966 act
->data
.showmenu
.name
= parse_string(doc
, n
);
967 } else if (act
->func
== action_move_relative_horz
||
968 act
->func
== action_move_relative_vert
||
969 act
->func
== action_resize_relative_horz
||
970 act
->func
== action_resize_relative_vert
) {
971 if ((n
= parse_find_node("delta", node
->xmlChildrenNode
)))
972 act
->data
.relative
.deltax
= parse_int(doc
, n
);
973 } else if (act
->func
== action_move_relative
) {
974 if ((n
= parse_find_node("x", node
->xmlChildrenNode
)))
975 act
->data
.relative
.deltax
= parse_int(doc
, n
);
976 if ((n
= parse_find_node("y", node
->xmlChildrenNode
)))
977 act
->data
.relative
.deltay
= parse_int(doc
, n
);
978 } else if (act
->func
== action_resize_relative
) {
979 if ((n
= parse_find_node("left", node
->xmlChildrenNode
)))
980 act
->data
.relative
.deltaxl
= parse_int(doc
, n
);
981 if ((n
= parse_find_node("up", node
->xmlChildrenNode
)))
982 act
->data
.relative
.deltayu
= parse_int(doc
, n
);
983 if ((n
= parse_find_node("right", node
->xmlChildrenNode
)))
984 act
->data
.relative
.deltax
= parse_int(doc
, n
);
985 if ((n
= parse_find_node("down", node
->xmlChildrenNode
)))
986 act
->data
.relative
.deltay
= parse_int(doc
, n
);
987 } else if (act
->func
== action_desktop
) {
988 if ((n
= parse_find_node("desktop", node
->xmlChildrenNode
)))
989 act
->data
.desktop
.desk
= parse_int(doc
, n
);
990 if (act
->data
.desktop
.desk
> 0) act
->data
.desktop
.desk
--;
991 if ((n
= parse_find_node("dialog", node
->xmlChildrenNode
)))
992 act
->data
.desktop
.inter
.any
.interactive
=
994 } else if (act
->func
== action_send_to_desktop
) {
995 if ((n
= parse_find_node("desktop", node
->xmlChildrenNode
)))
996 act
->data
.sendto
.desk
= parse_int(doc
, n
);
997 if (act
->data
.sendto
.desk
> 0) act
->data
.sendto
.desk
--;
998 if ((n
= parse_find_node("follow", node
->xmlChildrenNode
)))
999 act
->data
.sendto
.follow
= parse_bool(doc
, n
);
1000 } else if (act
->func
== action_desktop_dir
) {
1001 if ((n
= parse_find_node("wrap", node
->xmlChildrenNode
)))
1002 act
->data
.desktopdir
.wrap
= parse_bool(doc
, n
);
1003 if ((n
= parse_find_node("dialog", node
->xmlChildrenNode
)))
1004 act
->data
.desktopdir
.inter
.any
.interactive
=
1006 } else if (act
->func
== action_send_to_desktop_dir
) {
1007 if ((n
= parse_find_node("wrap", node
->xmlChildrenNode
)))
1008 act
->data
.sendtodir
.wrap
= parse_bool(doc
, n
);
1009 if ((n
= parse_find_node("follow", node
->xmlChildrenNode
)))
1010 act
->data
.sendtodir
.follow
= parse_bool(doc
, n
);
1011 if ((n
= parse_find_node("dialog", node
->xmlChildrenNode
)))
1012 act
->data
.sendtodir
.inter
.any
.interactive
=
1014 } else if (act
->func
== action_activate
) {
1015 if ((n
= parse_find_node("here", node
->xmlChildrenNode
)))
1016 act
->data
.activate
.here
= parse_bool(doc
, n
);
1017 } else if (act
->func
== action_cycle_windows
) {
1018 if ((n
= parse_find_node("linear", node
->xmlChildrenNode
)))
1019 act
->data
.cycle
.linear
= parse_bool(doc
, n
);
1020 if ((n
= parse_find_node("dialog", node
->xmlChildrenNode
)))
1021 act
->data
.cycle
.dialog
= parse_bool(doc
, n
);
1022 if ((n
= parse_find_node("panels", node
->xmlChildrenNode
)))
1023 act
->data
.cycle
.dock_windows
= parse_bool(doc
, n
);
1024 if ((n
= parse_find_node("desktop", node
->xmlChildrenNode
)))
1025 act
->data
.cycle
.desktop_windows
= parse_bool(doc
, n
);
1026 if ((n
= parse_find_node("allDesktops",
1027 node
->xmlChildrenNode
)))
1028 act
->data
.cycle
.all_desktops
= parse_bool(doc
, n
);
1029 } else if (act
->func
== action_directional_focus
) {
1030 if ((n
= parse_find_node("dialog", node
->xmlChildrenNode
)))
1031 act
->data
.interdiraction
.dialog
= parse_bool(doc
, n
);
1032 if ((n
= parse_find_node("panels", node
->xmlChildrenNode
)))
1033 act
->data
.interdiraction
.dock_windows
= parse_bool(doc
, n
);
1034 if ((n
= parse_find_node("desktop", node
->xmlChildrenNode
)))
1035 act
->data
.interdiraction
.desktop_windows
=
1037 } else if (act
->func
== action_resize
) {
1038 if ((n
= parse_find_node("edge", node
->xmlChildrenNode
))) {
1039 gchar
*s
= parse_string(doc
, n
);
1040 if (!g_ascii_strcasecmp(s
, "top"))
1041 act
->data
.moveresize
.corner
=
1042 prop_atoms
.net_wm_moveresize_size_top
;
1043 else if (!g_ascii_strcasecmp(s
, "bottom"))
1044 act
->data
.moveresize
.corner
=
1045 prop_atoms
.net_wm_moveresize_size_bottom
;
1046 else if (!g_ascii_strcasecmp(s
, "left"))
1047 act
->data
.moveresize
.corner
=
1048 prop_atoms
.net_wm_moveresize_size_left
;
1049 else if (!g_ascii_strcasecmp(s
, "right"))
1050 act
->data
.moveresize
.corner
=
1051 prop_atoms
.net_wm_moveresize_size_right
;
1052 else if (!g_ascii_strcasecmp(s
, "topleft"))
1053 act
->data
.moveresize
.corner
=
1054 prop_atoms
.net_wm_moveresize_size_topleft
;
1055 else if (!g_ascii_strcasecmp(s
, "topright"))
1056 act
->data
.moveresize
.corner
=
1057 prop_atoms
.net_wm_moveresize_size_topright
;
1058 else if (!g_ascii_strcasecmp(s
, "bottomleft"))
1059 act
->data
.moveresize
.corner
=
1060 prop_atoms
.net_wm_moveresize_size_bottomleft
;
1061 else if (!g_ascii_strcasecmp(s
, "bottomright"))
1062 act
->data
.moveresize
.corner
=
1063 prop_atoms
.net_wm_moveresize_size_bottomright
;
1066 } else if (act
->func
== action_raise
||
1067 act
->func
== action_lower
||
1068 act
->func
== action_raiselower
||
1069 act
->func
== action_shadelower
||
1070 act
->func
== action_unshaderaise
) {
1072 INTERACTIVE_LIMIT(act
, uact
);
1079 void action_run_list(GSList
*acts
, ObClient
*c
, ObFrameContext context
,
1080 guint state
, guint button
, gint x
, gint y
, Time time
,
1081 gboolean cancel
, gboolean done
)
1085 gboolean inter
= FALSE
;
1091 screen_pointer_pos(&x
, &y
);
1093 if (grab_on_keyboard())
1096 for (it
= acts
; it
; it
= g_slist_next(it
)) {
1098 if (a
->data
.any
.interactive
) {
1104 if (!inter
&& button
== 0) {
1105 /* Ungrab the keyboard before running the action, if it was
1106 not from a mouse event.
1108 We have to do this because a key press causes a passive
1109 grab on the keyboard, and so if the action we are running
1110 wants to grab the keyboard, it will fail if the button is still
1111 held down (which is likely).
1113 Use the X function not out own, because we're not considering
1114 a grab to be in place at all so our function won't try ungrab
1117 XUngrabKeyboard(ob_display
, time
);
1120 for (it
= acts
; it
; it
= g_slist_next(it
)) {
1123 if (!(a
->data
.any
.client_action
== OB_CLIENT_ACTION_ALWAYS
&& !c
)) {
1124 a
->data
.any
.c
= a
->data
.any
.client_action
? c
: NULL
;
1125 a
->data
.any
.context
= context
;
1129 a
->data
.any
.button
= button
;
1131 a
->data
.any
.time
= time
;
1133 if (a
->data
.any
.interactive
) {
1134 a
->data
.inter
.cancel
= cancel
;
1135 a
->data
.inter
.final
= done
;
1136 if (!(cancel
|| done
))
1137 if (!keyboard_interactive_grab(state
, a
->data
.any
.c
, a
))
1141 /* XXX UGLY HACK race with motion event starting a move and the
1142 button release gettnig processed first. answer: don't queue
1143 moveresize starts. UGLY HACK XXX */
1144 if (a
->data
.any
.interactive
|| a
->func
== action_move
||
1145 a
->func
== action_resize
)
1147 /* interactive actions are not queued */
1150 (context
== OB_FRAME_CONTEXT_CLIENT
||
1151 (c
->type
== OB_CLIENT_TYPE_DESKTOP
&&
1152 context
== OB_FRAME_CONTEXT_DESKTOP
)) &&
1153 (a
->func
== action_focus
||
1154 a
->func
== action_activate
||
1155 a
->func
== action_showmenu
))
1157 /* XXX MORE UGLY HACK
1158 actions from clicks on client windows are NOT queued.
1159 this solves the mysterious click-and-drag-doesnt-work
1160 problem. it was because the window gets focused and stuff
1161 after the button event has already been passed through. i
1162 dont really know why it should care but it does and it makes
1165 however this very bogus ! !
1166 we want to send the button press to the window BEFORE
1167 we do the action because the action might move the windows
1168 (eg change desktops) and then the button press ends up on
1169 the completely wrong window !
1170 so, this is just for that bug, and it will only NOT queue it
1171 if it is a focusing action that can be used with the mouse
1174 also with the menus, there is a race going on. if the
1175 desktop wants to pop up a menu, and we do to, we send them
1176 the button before we pop up the menu, so they pop up their
1177 menu first. but not always. if we pop up our menu before
1178 sending them the button press, then the result is
1183 ob_main_loop_queue_action(ob_main_loop
, a
);
1188 void action_run_string(const gchar
*name
, struct _ObClient
*c
, Time time
)
1193 a
= action_from_string(name
, OB_USER_ACTION_NONE
);
1196 l
= g_slist_append(NULL
, a
);
1198 action_run(l
, c
, 0, time
);
1201 void action_execute(union ActionData
*data
)
1204 gchar
*cmd
, **argv
= 0;
1205 if (data
->execute
.path
) {
1206 cmd
= g_filename_from_utf8(data
->execute
.path
, -1, NULL
, NULL
, NULL
);
1208 if (!g_shell_parse_argv (cmd
, NULL
, &argv
, &e
)) {
1209 g_message(_("Failed to execute '%s': %s"),
1212 } else if (data
->execute
.startupnotify
) {
1215 program
= g_path_get_basename(argv
[0]);
1216 /* sets up the environment */
1217 sn_setup_spawn_environment(program
,
1219 data
->execute
.icon_name
,
1220 /* launch it on the current
1223 data
->execute
.any
.time
);
1224 if (!g_spawn_async(NULL
, argv
, NULL
, G_SPAWN_SEARCH_PATH
|
1225 G_SPAWN_DO_NOT_REAP_CHILD
,
1226 NULL
, NULL
, NULL
, &e
)) {
1227 g_message(_("Failed to execute '%s': %s"),
1232 unsetenv("DESKTOP_STARTUP_ID");
1236 if (!g_spawn_async(NULL
, argv
, NULL
, G_SPAWN_SEARCH_PATH
|
1237 G_SPAWN_DO_NOT_REAP_CHILD
,
1238 NULL
, NULL
, NULL
, &e
))
1240 g_message(_("Failed to execute '%s': %s"),
1248 g_message(_("Failed to convert the path '%s' from utf8"),
1249 data
->execute
.path
);
1254 void action_activate(union ActionData
*data
)
1256 if (data
->client
.any
.c
) {
1257 if (!data
->any
.button
|| client_mouse_focusable(data
->client
.any
.c
) ||
1258 (data
->any
.context
!= OB_FRAME_CONTEXT_CLIENT
&&
1259 data
->any
.context
!= OB_FRAME_CONTEXT_FRAME
))
1261 /* if using focus_delay, stop the timer now so that focus doesn't
1263 event_halt_focus_delay();
1265 client_activate(data
->activate
.any
.c
, data
->activate
.here
, TRUE
);
1268 /* focus action on something other than a client, make keybindings
1269 work for this openbox instance, but don't focus any specific client
1275 void action_focus(union ActionData
*data
)
1277 if (data
->client
.any
.c
) {
1278 if (!data
->any
.button
|| client_mouse_focusable(data
->client
.any
.c
) ||
1279 (data
->any
.context
!= OB_FRAME_CONTEXT_CLIENT
&&
1280 data
->any
.context
!= OB_FRAME_CONTEXT_FRAME
))
1282 /* if using focus_delay, stop the timer now so that focus doesn't
1284 event_halt_focus_delay();
1286 client_focus(data
->client
.any
.c
);
1289 /* focus action on something other than a client, make keybindings
1290 work for this openbox instance, but don't focus any specific client
1296 void action_unfocus (union ActionData
*data
)
1298 if (data
->client
.any
.c
== focus_client
)
1299 focus_fallback(FALSE
);
1302 void action_iconify(union ActionData
*data
)
1304 client_action_start(data
);
1305 client_iconify(data
->client
.any
.c
, TRUE
, TRUE
, FALSE
);
1306 client_action_end(data
);
1309 void action_focus_order_to_bottom(union ActionData
*data
)
1311 focus_order_to_bottom(data
->client
.any
.c
);
1314 void action_raiselower(union ActionData
*data
)
1316 ObClient
*c
= data
->client
.any
.c
;
1318 gboolean raise
= FALSE
;
1320 for (it
= stacking_list
; it
; it
= g_list_next(it
)) {
1321 if (WINDOW_IS_CLIENT(it
->data
)) {
1322 ObClient
*cit
= it
->data
;
1324 if (cit
== c
) break;
1325 if (client_normal(cit
) == client_normal(c
) &&
1326 cit
->layer
== c
->layer
&&
1327 cit
->frame
->visible
&&
1328 !client_search_transient(c
, cit
))
1330 if (RECT_INTERSECTS_RECT(cit
->frame
->area
, c
->frame
->area
)) {
1344 void action_raise(union ActionData
*data
)
1346 client_action_start(data
);
1347 stacking_raise(CLIENT_AS_WINDOW(data
->client
.any
.c
));
1348 client_action_end(data
);
1351 void action_unshaderaise(union ActionData
*data
)
1353 if (data
->client
.any
.c
->shaded
)
1354 action_unshade(data
);
1359 void action_shadelower(union ActionData
*data
)
1361 if (data
->client
.any
.c
->shaded
)
1367 void action_lower(union ActionData
*data
)
1369 client_action_start(data
);
1370 stacking_lower(CLIENT_AS_WINDOW(data
->client
.any
.c
));
1371 client_action_end(data
);
1374 void action_close(union ActionData
*data
)
1376 client_close(data
->client
.any
.c
);
1379 void action_kill(union ActionData
*data
)
1381 client_kill(data
->client
.any
.c
);
1384 void action_shade(union ActionData
*data
)
1386 client_action_start(data
);
1387 client_shade(data
->client
.any
.c
, TRUE
);
1388 client_action_end(data
);
1391 void action_unshade(union ActionData
*data
)
1393 client_action_start(data
);
1394 client_shade(data
->client
.any
.c
, FALSE
);
1395 client_action_end(data
);
1398 void action_toggle_shade(union ActionData
*data
)
1400 client_action_start(data
);
1401 client_shade(data
->client
.any
.c
, !data
->client
.any
.c
->shaded
);
1402 client_action_end(data
);
1405 void action_toggle_omnipresent(union ActionData
*data
)
1407 client_set_desktop(data
->client
.any
.c
,
1408 data
->client
.any
.c
->desktop
== DESKTOP_ALL
?
1409 screen_desktop
: DESKTOP_ALL
, FALSE
);
1412 void action_move_relative_horz(union ActionData
*data
)
1414 ObClient
*c
= data
->relative
.any
.c
;
1415 client_action_start(data
);
1416 client_move(c
, c
->area
.x
+ data
->relative
.deltax
, c
->area
.y
);
1417 client_action_end(data
);
1420 void action_move_relative_vert(union ActionData
*data
)
1422 ObClient
*c
= data
->relative
.any
.c
;
1423 client_action_start(data
);
1424 client_move(c
, c
->area
.x
, c
->area
.y
+ data
->relative
.deltax
);
1425 client_action_end(data
);
1428 void action_move_to_center(union ActionData
*data
)
1430 ObClient
*c
= data
->client
.any
.c
;
1432 area
= screen_area_monitor(c
->desktop
, 0);
1433 client_action_start(data
);
1434 client_move(c
, area
->width
/ 2 - c
->area
.width
/ 2,
1435 area
->height
/ 2 - c
->area
.height
/ 2);
1436 client_action_end(data
);
1439 void action_resize_relative_horz(union ActionData
*data
)
1441 ObClient
*c
= data
->relative
.any
.c
;
1442 client_action_start(data
);
1444 c
->area
.width
+ data
->relative
.deltax
* c
->size_inc
.width
,
1446 client_action_end(data
);
1449 void action_resize_relative_vert(union ActionData
*data
)
1451 ObClient
*c
= data
->relative
.any
.c
;
1453 client_action_start(data
);
1454 client_resize(c
, c
->area
.width
, c
->area
.height
+
1455 data
->relative
.deltax
* c
->size_inc
.height
);
1456 client_action_end(data
);
1460 void action_move_relative(union ActionData
*data
)
1462 ObClient
*c
= data
->relative
.any
.c
;
1463 client_action_start(data
);
1464 client_move(c
, c
->area
.x
+ data
->relative
.deltax
, c
->area
.y
+
1465 data
->relative
.deltay
);
1466 client_action_end(data
);
1469 void action_resize_relative(union ActionData
*data
)
1471 ObClient
*c
= data
->relative
.any
.c
;
1472 gint x
, y
, ow
, w
, oh
, h
, lw
, lh
;
1474 client_action_start(data
);
1479 w
= ow
+ data
->relative
.deltax
* c
->size_inc
.width
1480 + data
->relative
.deltaxl
* c
->size_inc
.width
;
1481 oh
= c
->area
.height
;
1482 h
= oh
+ data
->relative
.deltay
* c
->size_inc
.height
1483 + data
->relative
.deltayu
* c
->size_inc
.height
;
1485 client_try_configure(c
, &x
, &y
, &w
, &h
, &lw
, &lh
, TRUE
);
1486 client_move_resize(c
, x
+ (ow
- w
), y
+ (oh
- h
), w
, h
);
1487 client_action_end(data
);
1490 void action_maximize_full(union ActionData
*data
)
1492 client_action_start(data
);
1493 client_maximize(data
->client
.any
.c
, TRUE
, 0);
1494 client_action_end(data
);
1497 void action_unmaximize_full(union ActionData
*data
)
1499 client_action_start(data
);
1500 client_maximize(data
->client
.any
.c
, FALSE
, 0);
1501 client_action_end(data
);
1504 void action_toggle_maximize_full(union ActionData
*data
)
1506 client_action_start(data
);
1507 client_maximize(data
->client
.any
.c
,
1508 !(data
->client
.any
.c
->max_horz
||
1509 data
->client
.any
.c
->max_vert
),
1511 client_action_end(data
);
1514 void action_maximize_horz(union ActionData
*data
)
1516 client_action_start(data
);
1517 client_maximize(data
->client
.any
.c
, TRUE
, 1);
1518 client_action_end(data
);
1521 void action_unmaximize_horz(union ActionData
*data
)
1523 client_action_start(data
);
1524 client_maximize(data
->client
.any
.c
, FALSE
, 1);
1525 client_action_end(data
);
1528 void action_toggle_maximize_horz(union ActionData
*data
)
1530 client_action_start(data
);
1531 client_maximize(data
->client
.any
.c
,
1532 !data
->client
.any
.c
->max_horz
, 1);
1533 client_action_end(data
);
1536 void action_maximize_vert(union ActionData
*data
)
1538 client_action_start(data
);
1539 client_maximize(data
->client
.any
.c
, TRUE
, 2);
1540 client_action_end(data
);
1543 void action_unmaximize_vert(union ActionData
*data
)
1545 client_action_start(data
);
1546 client_maximize(data
->client
.any
.c
, FALSE
, 2);
1547 client_action_end(data
);
1550 void action_toggle_maximize_vert(union ActionData
*data
)
1552 client_action_start(data
);
1553 client_maximize(data
->client
.any
.c
,
1554 !data
->client
.any
.c
->max_vert
, 2);
1555 client_action_end(data
);
1558 void action_toggle_fullscreen(union ActionData
*data
)
1560 client_action_start(data
);
1561 client_fullscreen(data
->client
.any
.c
, !(data
->client
.any
.c
->fullscreen
));
1562 client_action_end(data
);
1565 void action_send_to_desktop(union ActionData
*data
)
1567 ObClient
*c
= data
->sendto
.any
.c
;
1569 if (!client_normal(c
)) return;
1571 if (data
->sendto
.desk
< screen_num_desktops
||
1572 data
->sendto
.desk
== DESKTOP_ALL
) {
1573 client_set_desktop(c
, data
->sendto
.desk
, data
->sendto
.follow
);
1574 if (data
->sendto
.follow
)
1575 screen_set_desktop(data
->sendto
.desk
, TRUE
);
1579 void action_desktop(union ActionData
*data
)
1581 if (!data
->inter
.any
.interactive
||
1582 (!data
->inter
.cancel
&& !data
->inter
.final
))
1584 if (data
->desktop
.desk
< screen_num_desktops
||
1585 data
->desktop
.desk
== DESKTOP_ALL
)
1587 screen_set_desktop(data
->desktop
.desk
, TRUE
);
1588 if (data
->inter
.any
.interactive
)
1589 screen_desktop_popup(data
->desktop
.desk
, TRUE
);
1592 screen_desktop_popup(0, FALSE
);
1595 void action_desktop_dir(union ActionData
*data
)
1599 d
= screen_cycle_desktop(data
->desktopdir
.dir
,
1600 data
->desktopdir
.wrap
,
1601 data
->desktopdir
.linear
,
1602 data
->desktopdir
.inter
.any
.interactive
,
1603 data
->desktopdir
.inter
.final
,
1604 data
->desktopdir
.inter
.cancel
);
1605 /* only move the desktop when the action is complete. if we switch
1606 desktops during the interactive action, focus will move but with
1607 NotifyWhileGrabbed and applications don't like that. */
1608 if (!data
->sendtodir
.inter
.any
.interactive
||
1609 (data
->sendtodir
.inter
.final
&& !data
->sendtodir
.inter
.cancel
))
1611 if (d
!= screen_desktop
) screen_set_desktop(d
, TRUE
);
1615 void action_send_to_desktop_dir(union ActionData
*data
)
1617 ObClient
*c
= data
->sendtodir
.inter
.any
.c
;
1620 if (!client_normal(c
)) return;
1622 d
= screen_cycle_desktop(data
->sendtodir
.dir
, data
->sendtodir
.wrap
,
1623 data
->sendtodir
.linear
,
1624 data
->sendtodir
.inter
.any
.interactive
,
1625 data
->sendtodir
.inter
.final
,
1626 data
->sendtodir
.inter
.cancel
);
1627 /* only move the desktop when the action is complete. if we switch
1628 desktops during the interactive action, focus will move but with
1629 NotifyWhileGrabbed and applications don't like that. */
1630 if (!data
->sendtodir
.inter
.any
.interactive
||
1631 (data
->sendtodir
.inter
.final
&& !data
->sendtodir
.inter
.cancel
))
1633 client_set_desktop(c
, d
, data
->sendtodir
.follow
);
1634 if (data
->sendtodir
.follow
&& d
!= screen_desktop
)
1635 screen_set_desktop(d
, TRUE
);
1639 void action_desktop_last(union ActionData
*data
)
1641 screen_set_desktop(screen_last_desktop
, TRUE
);
1644 void action_toggle_decorations(union ActionData
*data
)
1646 ObClient
*c
= data
->client
.any
.c
;
1648 client_action_start(data
);
1649 client_set_undecorated(c
, !c
->undecorated
);
1650 client_action_end(data
);
1653 static guint32
pick_corner(gint x
, gint y
, gint cx
, gint cy
, gint cw
, gint ch
,
1656 /* let's make x and y client relative instead of screen relative */
1658 y
= ch
- (y
- cy
); /* y is inverted, 0 is at the bottom of the window */
1661 #define A -4*X + 7*ch/3
1662 #define B 4*X -15*ch/9
1663 #define C -X/4 + 2*ch/3
1664 #define D X/4 + 5*ch/12
1665 #define E X/4 + ch/3
1666 #define F -X/4 + 7*ch/12
1667 #define G 4*X - 4*ch/3
1668 #define H -4*X + 8*ch/3
1669 #define a (y > 5*ch/9)
1670 #define b (x < 4*cw/9)
1671 #define c (x > 5*cw/9)
1672 #define d (y < 4*ch/9)
1675 Each of these defines (except X which is just there for fun), represents
1676 the equation of a line. The lines they represent are shown in the diagram
1677 below. Checking y against these lines, we are able to choose a region
1678 of the window as shown.
1680 +---------------------A-------|-------|-------B---------------------+
1687 | northwest | A north B | northeast |
1690 C---------------------+----A--+-------+--B----+---------------------D
1691 |CCCCCCC | A B | DDDDDDD|
1692 | CCCCCCCC | A | | B | DDDDDDDD |
1693 | CCCCCCC A B DDDDDDD |
1694 - - - - - - - - - - - +CCCCCCC+aaaaaaa+DDDDDDD+ - - - - - - - - - - - -
1696 | west | b move c | east | ad
1698 - - - - - - - - - - - +EEEEEEE+ddddddd+FFFFFFF+- - - - - - - - - - - -
1699 | EEEEEEE G H FFFFFFF |
1700 | EEEEEEEE | G | | H | FFFFFFFF |
1701 |EEEEEEE | G H | FFFFFFF|
1702 E---------------------+----G--+-------+--H----+---------------------F
1705 | southwest | G south H | southeast |
1712 +---------------------G-------|-------|-------H---------------------+
1716 /* for shaded windows, you can only resize west/east and move */
1718 return prop_atoms
.net_wm_moveresize_size_left
;
1720 return prop_atoms
.net_wm_moveresize_size_right
;
1721 return prop_atoms
.net_wm_moveresize_move
;
1724 if (y
< A
&& y
>= C
)
1725 return prop_atoms
.net_wm_moveresize_size_topleft
;
1726 else if (y
>= A
&& y
>= B
&& a
)
1727 return prop_atoms
.net_wm_moveresize_size_top
;
1728 else if (y
< B
&& y
>= D
)
1729 return prop_atoms
.net_wm_moveresize_size_topright
;
1730 else if (y
< C
&& y
>= E
&& b
)
1731 return prop_atoms
.net_wm_moveresize_size_left
;
1732 else if (y
< D
&& y
>= F
&& c
)
1733 return prop_atoms
.net_wm_moveresize_size_right
;
1734 else if (y
< E
&& y
>= G
)
1735 return prop_atoms
.net_wm_moveresize_size_bottomleft
;
1736 else if (y
< G
&& y
< H
&& d
)
1737 return prop_atoms
.net_wm_moveresize_size_bottom
;
1738 else if (y
>= H
&& y
< F
)
1739 return prop_atoms
.net_wm_moveresize_size_bottomright
;
1741 return prop_atoms
.net_wm_moveresize_move
;
1758 void action_move(union ActionData
*data
)
1760 ObClient
*c
= data
->moveresize
.any
.c
;
1763 if (data
->moveresize
.keyboard
)
1764 corner
= prop_atoms
.net_wm_moveresize_move_keyboard
;
1766 corner
= prop_atoms
.net_wm_moveresize_move
;
1768 moveresize_start(c
, data
->any
.x
, data
->any
.y
, data
->any
.button
, corner
);
1771 void action_resize(union ActionData
*data
)
1773 ObClient
*c
= data
->moveresize
.any
.c
;
1776 if (data
->moveresize
.keyboard
)
1777 corner
= prop_atoms
.net_wm_moveresize_size_keyboard
;
1778 else if (data
->moveresize
.corner
)
1779 corner
= data
->moveresize
.corner
; /* it was specified in the binding */
1781 corner
= pick_corner(data
->any
.x
, data
->any
.y
,
1782 c
->frame
->area
.x
, c
->frame
->area
.y
,
1783 /* use the client size because the frame
1784 can be differently sized (shaded
1785 windows) and we want this based on the
1787 c
->area
.width
+ c
->frame
->size
.left
+
1788 c
->frame
->size
.right
,
1789 c
->area
.height
+ c
->frame
->size
.top
+
1790 c
->frame
->size
.bottom
, c
->shaded
);
1792 moveresize_start(c
, data
->any
.x
, data
->any
.y
, data
->any
.button
, corner
);
1795 void action_reconfigure(union ActionData
*data
)
1800 void action_restart(union ActionData
*data
)
1802 ob_restart_other(data
->execute
.path
);
1805 void action_exit(union ActionData
*data
)
1810 void action_showmenu(union ActionData
*data
)
1812 if (data
->showmenu
.name
) {
1813 menu_show(data
->showmenu
.name
, data
->any
.x
, data
->any
.y
,
1814 data
->any
.button
, data
->showmenu
.any
.c
);
1818 void action_cycle_windows(union ActionData
*data
)
1820 /* if using focus_delay, stop the timer now so that focus doesn't go moving
1822 event_halt_focus_delay();
1824 focus_cycle(data
->cycle
.forward
,
1825 data
->cycle
.all_desktops
,
1826 data
->cycle
.dock_windows
,
1827 data
->cycle
.desktop_windows
,
1828 data
->cycle
.linear
, data
->any
.interactive
,
1830 data
->cycle
.inter
.final
, data
->cycle
.inter
.cancel
);
1833 void action_directional_focus(union ActionData
*data
)
1835 /* if using focus_delay, stop the timer now so that focus doesn't go moving
1837 event_halt_focus_delay();
1839 focus_directional_cycle(data
->interdiraction
.direction
,
1840 data
->interdiraction
.dock_windows
,
1841 data
->interdiraction
.desktop_windows
,
1842 data
->any
.interactive
,
1843 data
->interdiraction
.dialog
,
1844 data
->interdiraction
.inter
.final
,
1845 data
->interdiraction
.inter
.cancel
);
1848 void action_movetoedge(union ActionData
*data
)
1851 ObClient
*c
= data
->diraction
.any
.c
;
1853 x
= c
->frame
->area
.x
;
1854 y
= c
->frame
->area
.y
;
1856 switch(data
->diraction
.direction
) {
1857 case OB_DIRECTION_NORTH
:
1858 y
= client_directional_edge_search(c
, OB_DIRECTION_NORTH
,
1859 data
->diraction
.hang
)
1860 - (data
->diraction
.hang
? c
->frame
->area
.height
: 0);
1862 case OB_DIRECTION_WEST
:
1863 x
= client_directional_edge_search(c
, OB_DIRECTION_WEST
,
1864 data
->diraction
.hang
)
1865 - (data
->diraction
.hang
? c
->frame
->area
.width
: 0);
1867 case OB_DIRECTION_SOUTH
:
1868 y
= client_directional_edge_search(c
, OB_DIRECTION_SOUTH
,
1869 data
->diraction
.hang
)
1870 - (data
->diraction
.hang
? 0 : c
->frame
->area
.height
);
1872 case OB_DIRECTION_EAST
:
1873 x
= client_directional_edge_search(c
, OB_DIRECTION_EAST
,
1874 data
->diraction
.hang
)
1875 - (data
->diraction
.hang
? 0 : c
->frame
->area
.width
);
1878 g_assert_not_reached();
1880 frame_frame_gravity(c
->frame
, &x
, &y
, c
->area
.width
, c
->area
.height
);
1881 client_action_start(data
);
1882 client_move(c
, x
, y
);
1883 client_action_end(data
);
1886 void action_growtoedge(union ActionData
*data
)
1888 gint x
, y
, width
, height
, dest
;
1889 ObClient
*c
= data
->diraction
.any
.c
;
1892 a
= screen_area(c
->desktop
);
1893 x
= c
->frame
->area
.x
;
1894 y
= c
->frame
->area
.y
;
1895 /* get the unshaded frame's dimensions..if it is shaded */
1896 width
= c
->area
.width
+ c
->frame
->size
.left
+ c
->frame
->size
.right
;
1897 height
= c
->area
.height
+ c
->frame
->size
.top
+ c
->frame
->size
.bottom
;
1899 switch(data
->diraction
.direction
) {
1900 case OB_DIRECTION_NORTH
:
1901 if (c
->shaded
) break; /* don't allow vertical resize if shaded */
1903 dest
= client_directional_edge_search(c
, OB_DIRECTION_NORTH
, FALSE
);
1905 height
= height
/ 2;
1907 height
= c
->frame
->area
.y
+ height
- dest
;
1911 case OB_DIRECTION_WEST
:
1912 dest
= client_directional_edge_search(c
, OB_DIRECTION_WEST
, FALSE
);
1916 width
= c
->frame
->area
.x
+ width
- dest
;
1920 case OB_DIRECTION_SOUTH
:
1921 if (c
->shaded
) break; /* don't allow vertical resize if shaded */
1923 dest
= client_directional_edge_search(c
, OB_DIRECTION_SOUTH
, FALSE
);
1924 if (a
->y
+ a
->height
== y
+ c
->frame
->area
.height
) {
1925 height
= c
->frame
->area
.height
/ 2;
1926 y
= a
->y
+ a
->height
- height
;
1928 height
= dest
- c
->frame
->area
.y
;
1929 y
+= (height
- c
->frame
->area
.height
) % c
->size_inc
.height
;
1930 height
-= (height
- c
->frame
->area
.height
) % c
->size_inc
.height
;
1932 case OB_DIRECTION_EAST
:
1933 dest
= client_directional_edge_search(c
, OB_DIRECTION_EAST
, FALSE
);
1934 if (a
->x
+ a
->width
== x
+ c
->frame
->area
.width
) {
1935 width
= c
->frame
->area
.width
/ 2;
1936 x
= a
->x
+ a
->width
- width
;
1938 width
= dest
- c
->frame
->area
.x
;
1939 x
+= (width
- c
->frame
->area
.width
) % c
->size_inc
.width
;
1940 width
-= (width
- c
->frame
->area
.width
) % c
->size_inc
.width
;
1943 g_assert_not_reached();
1945 width
-= c
->frame
->size
.left
+ c
->frame
->size
.right
;
1946 height
-= c
->frame
->size
.top
+ c
->frame
->size
.bottom
;
1947 frame_frame_gravity(c
->frame
, &x
, &y
, width
, height
);
1948 client_action_start(data
);
1949 client_move_resize(c
, x
, y
, width
, height
);
1950 client_action_end(data
);
1953 void action_send_to_layer(union ActionData
*data
)
1955 client_set_layer(data
->layer
.any
.c
, data
->layer
.layer
);
1958 void action_toggle_layer(union ActionData
*data
)
1960 ObClient
*c
= data
->layer
.any
.c
;
1962 client_action_start(data
);
1963 if (data
->layer
.layer
< 0)
1964 client_set_layer(c
, c
->below
? 0 : -1);
1965 else if (data
->layer
.layer
> 0)
1966 client_set_layer(c
, c
->above
? 0 : 1);
1967 client_action_end(data
);
1970 void action_toggle_dockautohide(union ActionData
*data
)
1972 config_dock_hide
= !config_dock_hide
;
1976 void action_toggle_show_desktop(union ActionData
*data
)
1978 screen_show_desktop(!screen_showing_desktop
, NULL
);
1981 void action_show_desktop(union ActionData
*data
)
1983 screen_show_desktop(TRUE
, NULL
);
1986 void action_unshow_desktop(union ActionData
*data
)
1988 screen_show_desktop(FALSE
, NULL
);
1991 void action_break_chroot(union ActionData
*data
)
1993 /* break out of one chroot */
1994 keyboard_reset_chains(1);