4 #include "moveresize.h"
16 typedef struct ActionString
{
18 void (*func
)(union ActionData
*);
19 void (*setup
)(ObAction
**, ObUserAction uact
);
22 static ObAction
*action_new(void (*func
)(union ActionData
*data
),
25 ObAction
*a
= g_new0(ObAction
, 1);
31 void action_free(ObAction
*a
)
33 if (a
== NULL
) return;
35 /* deal with pointers */
36 if (a
->func
== action_execute
|| a
->func
== action_restart
)
37 g_free(a
->data
.execute
.path
);
38 else if (a
->func
== action_showmenu
)
39 g_free(a
->data
.showmenu
.name
);
44 void setup_action_directional_focus_north(ObAction
**a
, ObUserAction uact
)
46 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
47 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_NORTH
;
50 void setup_action_directional_focus_east(ObAction
**a
, ObUserAction uact
)
52 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
53 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_EAST
;
56 void setup_action_directional_focus_south(ObAction
**a
, ObUserAction uact
)
58 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
59 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_SOUTH
;
62 void setup_action_directional_focus_west(ObAction
**a
, ObUserAction uact
)
64 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
65 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_WEST
;
68 void setup_action_directional_focus_northeast(ObAction
**a
, ObUserAction uact
)
70 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
71 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_NORTHEAST
;
74 void setup_action_directional_focus_southeast(ObAction
**a
, ObUserAction uact
)
76 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
77 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_SOUTHEAST
;
80 void setup_action_directional_focus_southwest(ObAction
**a
, ObUserAction uact
)
82 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
83 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_SOUTHWEST
;
86 void setup_action_directional_focus_northwest(ObAction
**a
, ObUserAction uact
)
88 (*a
)->data
.interdiraction
.inter
.any
.interactive
= TRUE
;
89 (*a
)->data
.interdiraction
.direction
= OB_DIRECTION_NORTHWEST
;
92 void setup_action_send_to_desktop(ObAction
**a
, ObUserAction uact
)
94 (*a
)->data
.sendto
.follow
= TRUE
;
97 void setup_action_send_to_desktop_prev(ObAction
**a
, ObUserAction uact
)
99 (*a
)->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
100 (*a
)->data
.sendtodir
.dir
= OB_DIRECTION_WEST
;
101 (*a
)->data
.sendtodir
.linear
= TRUE
;
102 (*a
)->data
.sendtodir
.wrap
= TRUE
;
103 (*a
)->data
.sendtodir
.follow
= TRUE
;
106 void setup_action_send_to_desktop_next(ObAction
**a
, ObUserAction uact
)
108 (*a
)->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
109 (*a
)->data
.sendtodir
.dir
= OB_DIRECTION_EAST
;
110 (*a
)->data
.sendtodir
.linear
= TRUE
;
111 (*a
)->data
.sendtodir
.wrap
= TRUE
;
112 (*a
)->data
.sendtodir
.follow
= TRUE
;
115 void setup_action_send_to_desktop_left(ObAction
**a
, ObUserAction uact
)
117 (*a
)->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
118 (*a
)->data
.sendtodir
.dir
= OB_DIRECTION_WEST
;
119 (*a
)->data
.sendtodir
.linear
= FALSE
;
120 (*a
)->data
.sendtodir
.wrap
= TRUE
;
121 (*a
)->data
.sendtodir
.follow
= TRUE
;
124 void setup_action_send_to_desktop_right(ObAction
**a
, ObUserAction uact
)
126 (*a
)->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
127 (*a
)->data
.sendtodir
.dir
= OB_DIRECTION_EAST
;
128 (*a
)->data
.sendtodir
.linear
= FALSE
;
129 (*a
)->data
.sendtodir
.wrap
= TRUE
;
130 (*a
)->data
.sendtodir
.follow
= TRUE
;
133 void setup_action_send_to_desktop_up(ObAction
**a
, ObUserAction uact
)
135 (*a
)->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
136 (*a
)->data
.sendtodir
.dir
= OB_DIRECTION_NORTH
;
137 (*a
)->data
.sendtodir
.linear
= FALSE
;
138 (*a
)->data
.sendtodir
.wrap
= TRUE
;
139 (*a
)->data
.sendtodir
.follow
= TRUE
;
142 void setup_action_send_to_desktop_down(ObAction
**a
, ObUserAction uact
)
144 (*a
)->data
.sendtodir
.inter
.any
.interactive
= TRUE
;
145 (*a
)->data
.sendtodir
.dir
= OB_DIRECTION_SOUTH
;
146 (*a
)->data
.sendtodir
.linear
= FALSE
;
147 (*a
)->data
.sendtodir
.wrap
= TRUE
;
148 (*a
)->data
.sendtodir
.follow
= TRUE
;
151 void setup_action_desktop_prev(ObAction
**a
, ObUserAction uact
)
153 (*a
)->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
154 (*a
)->data
.desktopdir
.dir
= OB_DIRECTION_WEST
;
155 (*a
)->data
.desktopdir
.linear
= TRUE
;
156 (*a
)->data
.desktopdir
.wrap
= TRUE
;
159 void setup_action_desktop_next(ObAction
**a
, ObUserAction uact
)
161 (*a
)->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
162 (*a
)->data
.desktopdir
.dir
= OB_DIRECTION_EAST
;
163 (*a
)->data
.desktopdir
.linear
= TRUE
;
164 (*a
)->data
.desktopdir
.wrap
= TRUE
;
167 void setup_action_desktop_left(ObAction
**a
, ObUserAction uact
)
169 (*a
)->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
170 (*a
)->data
.desktopdir
.dir
= OB_DIRECTION_WEST
;
171 (*a
)->data
.desktopdir
.linear
= FALSE
;
172 (*a
)->data
.desktopdir
.wrap
= TRUE
;
175 void setup_action_desktop_right(ObAction
**a
, ObUserAction uact
)
177 (*a
)->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
178 (*a
)->data
.desktopdir
.dir
= OB_DIRECTION_EAST
;
179 (*a
)->data
.desktopdir
.linear
= FALSE
;
180 (*a
)->data
.desktopdir
.wrap
= TRUE
;
183 void setup_action_desktop_up(ObAction
**a
, ObUserAction uact
)
185 (*a
)->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
186 (*a
)->data
.desktopdir
.dir
= OB_DIRECTION_NORTH
;
187 (*a
)->data
.desktopdir
.linear
= FALSE
;
188 (*a
)->data
.desktopdir
.wrap
= TRUE
;
191 void setup_action_desktop_down(ObAction
**a
, ObUserAction uact
)
193 (*a
)->data
.desktopdir
.inter
.any
.interactive
= TRUE
;
194 (*a
)->data
.desktopdir
.dir
= OB_DIRECTION_SOUTH
;
195 (*a
)->data
.desktopdir
.linear
= FALSE
;
196 (*a
)->data
.desktopdir
.wrap
= TRUE
;
199 void setup_action_cycle_windows_next(ObAction
**a
, ObUserAction uact
)
201 (*a
)->data
.cycle
.inter
.any
.interactive
= TRUE
;
202 (*a
)->data
.cycle
.linear
= FALSE
;
203 (*a
)->data
.cycle
.forward
= TRUE
;
206 void setup_action_cycle_windows_previous(ObAction
**a
, ObUserAction uact
)
208 (*a
)->data
.cycle
.inter
.any
.interactive
= TRUE
;
209 (*a
)->data
.cycle
.linear
= FALSE
;
210 (*a
)->data
.cycle
.forward
= FALSE
;
213 void setup_action_movetoedge_north(ObAction
**a
, ObUserAction uact
)
215 (*a
)->data
.diraction
.direction
= OB_DIRECTION_NORTH
;
218 void setup_action_movetoedge_south(ObAction
**a
, ObUserAction uact
)
220 (*a
)->data
.diraction
.direction
= OB_DIRECTION_SOUTH
;
223 void setup_action_movetoedge_east(ObAction
**a
, ObUserAction uact
)
225 (*a
)->data
.diraction
.direction
= OB_DIRECTION_EAST
;
228 void setup_action_movetoedge_west(ObAction
**a
, ObUserAction uact
)
230 (*a
)->data
.diraction
.direction
= OB_DIRECTION_WEST
;
233 void setup_action_growtoedge_north(ObAction
**a
, ObUserAction uact
)
235 (*a
)->data
.diraction
.direction
= OB_DIRECTION_NORTH
;
238 void setup_action_growtoedge_south(ObAction
**a
, ObUserAction uact
)
240 (*a
)->data
.diraction
.direction
= OB_DIRECTION_SOUTH
;
243 void setup_action_growtoedge_east(ObAction
**a
, ObUserAction uact
)
245 (*a
)->data
.diraction
.direction
= OB_DIRECTION_EAST
;
248 void setup_action_growtoedge_west(ObAction
**a
, ObUserAction uact
)
250 (*a
)->data
.diraction
.direction
= OB_DIRECTION_WEST
;
253 void setup_action_top_layer(ObAction
**a
, ObUserAction uact
)
255 (*a
)->data
.layer
.layer
= 1;
258 void setup_action_normal_layer(ObAction
**a
, ObUserAction uact
)
260 (*a
)->data
.layer
.layer
= 0;
263 void setup_action_bottom_layer(ObAction
**a
, ObUserAction uact
)
265 (*a
)->data
.layer
.layer
= -1;
268 void setup_action_move(ObAction
**a
, ObUserAction uact
)
270 (*a
)->data
.moveresize
.move
= TRUE
;
271 (*a
)->data
.moveresize
.keyboard
=
272 (uact
== OB_USER_ACTION_KEYBOARD_KEY
||
273 uact
== OB_USER_ACTION_MENU_SELECTION
);
276 void setup_action_resize(ObAction
**a
, ObUserAction uact
)
278 (*a
)->data
.moveresize
.move
= FALSE
;
279 (*a
)->data
.moveresize
.keyboard
=
280 (uact
== OB_USER_ACTION_KEYBOARD_KEY
||
281 uact
== OB_USER_ACTION_MENU_SELECTION
);
284 void setup_action_showmenu(ObAction
**a
, ObUserAction uact
)
286 /* you cannot call ShowMenu from inside a menu, cuz the menu code makes
287 assumptions that there is only one menu (and submenus) open at
289 if (uact
== OB_USER_ACTION_MENU_SELECTION
) {
295 ActionString actionstrings
[] =
303 "directionalfocusnorth",
304 action_directional_focus
,
305 setup_action_directional_focus_north
308 "directionalfocuseast",
309 action_directional_focus
,
310 setup_action_directional_focus_east
313 "directionalfocussouth",
314 action_directional_focus
,
315 setup_action_directional_focus_south
318 "directionalfocuswest",
319 action_directional_focus
,
320 setup_action_directional_focus_west
323 "directionalfocusnortheast",
324 action_directional_focus
,
325 setup_action_directional_focus_northeast
328 "directionalfocussoutheast",
329 action_directional_focus
,
330 setup_action_directional_focus_southeast
333 "directionalfocussouthwest",
334 action_directional_focus
,
335 setup_action_directional_focus_southwest
338 "directionalfocusnorthwest",
339 action_directional_focus
,
340 setup_action_directional_focus_northwest
414 action_toggle_omnipresent
,
419 action_move_relative_horz
,
424 action_move_relative_vert
,
428 "resizerelativehorz",
429 action_resize_relative_horz
,
433 "resizerelativevert",
434 action_resize_relative_vert
,
439 action_maximize_full
,
444 action_unmaximize_full
,
448 "togglemaximizefull",
449 action_toggle_maximize_full
,
454 action_maximize_horz
,
459 action_unmaximize_horz
,
463 "togglemaximizehorz",
464 action_toggle_maximize_horz
,
469 action_maximize_vert
,
474 action_unmaximize_vert
,
478 "togglemaximizevert",
479 action_toggle_maximize_vert
,
484 action_send_to_desktop
,
485 setup_action_send_to_desktop
489 action_send_to_desktop_dir
,
490 setup_action_send_to_desktop_next
493 "sendtodesktopprevious",
494 action_send_to_desktop_dir
,
495 setup_action_send_to_desktop_prev
498 "sendtodesktopright",
499 action_send_to_desktop_dir
,
500 setup_action_send_to_desktop_right
504 action_send_to_desktop_dir
,
505 setup_action_send_to_desktop_left
509 action_send_to_desktop_dir
,
510 setup_action_send_to_desktop_up
514 action_send_to_desktop_dir
,
515 setup_action_send_to_desktop_down
525 setup_action_desktop_next
530 setup_action_desktop_prev
535 setup_action_desktop_right
540 setup_action_desktop_left
545 setup_action_desktop_up
550 setup_action_desktop_down
554 action_toggle_decorations
,
569 action_toggle_show_desktop
,
579 action_unshow_desktop
,
605 setup_action_showmenu
609 action_send_to_layer
,
610 setup_action_top_layer
615 setup_action_top_layer
619 action_send_to_layer
,
620 setup_action_normal_layer
624 action_send_to_layer
,
625 setup_action_bottom_layer
628 "togglealwaysonbottom",
630 setup_action_bottom_layer
634 action_cycle_windows
,
635 setup_action_cycle_windows_next
639 action_cycle_windows
,
640 setup_action_cycle_windows_previous
645 setup_action_movetoedge_north
650 setup_action_movetoedge_south
655 setup_action_movetoedge_west
660 setup_action_movetoedge_east
665 setup_action_growtoedge_north
670 setup_action_growtoedge_south
675 setup_action_growtoedge_west
680 setup_action_growtoedge_east
689 ObAction
*action_from_string(char *name
, ObUserAction uact
)
692 gboolean exist
= FALSE
;
695 for (i
= 0; actionstrings
[i
].name
; i
++)
696 if (!g_ascii_strcasecmp(name
, actionstrings
[i
].name
)) {
698 a
= action_new(actionstrings
[i
].func
, uact
);
699 if (actionstrings
[i
].setup
)
700 actionstrings
[i
].setup(&a
, uact
);
701 /* only key bindings can be interactive. thus saith the xor. */
702 if (uact
!= OB_USER_ACTION_KEYBOARD_KEY
)
703 a
->data
.any
.interactive
= FALSE
;
707 g_warning("Invalid action '%s' requested. No such action exists.",
710 g_warning("Invalid use of action '%s'. Action will be ignored.", name
);
714 ObAction
*action_parse(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
718 ObAction
*act
= NULL
;
721 if (parse_attr_string("name", node
, &actname
)) {
722 if ((act
= action_from_string(actname
, uact
))) {
723 if (act
->func
== action_execute
|| act
->func
== action_restart
) {
724 if ((n
= parse_find_node("execute", node
->xmlChildrenNode
))) {
725 gchar
*s
= parse_string(doc
, n
);
726 act
->data
.execute
.path
= ob_expand_tilde(s
);
729 } else if (act
->func
== action_showmenu
) {
730 if ((n
= parse_find_node("menu", node
->xmlChildrenNode
)))
731 act
->data
.showmenu
.name
= parse_string(doc
, n
);
732 } else if (act
->func
== action_move_relative_horz
||
733 act
->func
== action_move_relative_vert
||
734 act
->func
== action_resize_relative_horz
||
735 act
->func
== action_resize_relative_vert
) {
736 if ((n
= parse_find_node("delta", node
->xmlChildrenNode
)))
737 act
->data
.relative
.delta
= parse_int(doc
, n
);
738 } else if (act
->func
== action_desktop
) {
739 if ((n
= parse_find_node("desktop", node
->xmlChildrenNode
)))
740 act
->data
.desktop
.desk
= parse_int(doc
, n
);
741 if (act
->data
.desktop
.desk
> 0) act
->data
.desktop
.desk
--;
742 } else if (act
->func
== action_send_to_desktop
) {
743 if ((n
= parse_find_node("desktop", node
->xmlChildrenNode
)))
744 act
->data
.sendto
.desk
= parse_int(doc
, n
);
745 if (act
->data
.sendto
.desk
> 0) act
->data
.sendto
.desk
--;
746 if ((n
= parse_find_node("follow", node
->xmlChildrenNode
)))
747 act
->data
.sendto
.follow
= parse_bool(doc
, n
);
748 } else if (act
->func
== action_desktop_dir
) {
749 if ((n
= parse_find_node("wrap", node
->xmlChildrenNode
)))
750 act
->data
.desktopdir
.wrap
= parse_bool(doc
, n
);
751 } else if (act
->func
== action_send_to_desktop_dir
) {
752 if ((n
= parse_find_node("wrap", node
->xmlChildrenNode
)))
753 act
->data
.sendtodir
.wrap
= parse_bool(doc
, n
);
754 if ((n
= parse_find_node("follow", node
->xmlChildrenNode
)))
755 act
->data
.sendtodir
.follow
= parse_bool(doc
, n
);
756 } else if (act
->func
== action_activate
) {
757 if ((n
= parse_find_node("here", node
->xmlChildrenNode
)))
758 act
->data
.activate
.here
= parse_bool(doc
, n
);
759 } else if (act
->func
== action_cycle_windows
) {
760 if ((n
= parse_find_node("linear", node
->xmlChildrenNode
)))
761 act
->data
.cycle
.linear
= parse_bool(doc
, n
);
769 void action_run_full(ObAction
*a
, struct _ObClient
*c
,
770 guint state
, guint button
, gint x
, gint y
,
771 gboolean cancel
, gboolean done
)
774 screen_pointer_pos(&x
, &y
);
780 a
->data
.any
.button
= button
;
782 if (a
->data
.any
.interactive
) {
783 a
->data
.inter
.cancel
= cancel
;
784 a
->data
.inter
.final
= done
;
785 if (!(cancel
|| done
))
786 keyboard_interactive_grab(state
, c
, a
);
792 void action_execute(union ActionData
*data
)
796 if (data
->execute
.path
) {
797 cmd
= g_filename_from_utf8(data
->execute
.path
, -1, NULL
, NULL
, NULL
);
799 if (!g_spawn_command_line_async(cmd
, &e
)) {
800 g_warning("failed to execute '%s': %s",
804 g_warning("failed to convert '%s' from utf8", data
->execute
.path
);
809 void action_activate(union ActionData
*data
)
811 if (data
->activate
.any
.c
)
812 client_activate(data
->activate
.any
.c
, data
->activate
.here
);
815 void action_focus(union ActionData
*data
)
817 if (data
->client
.any
.c
)
818 client_focus(data
->client
.any
.c
);
821 void action_unfocus (union ActionData
*data
)
823 if (data
->client
.any
.c
)
824 client_unfocus(data
->client
.any
.c
);
827 void action_iconify(union ActionData
*data
)
829 if (data
->client
.any
.c
)
830 client_iconify(data
->client
.any
.c
, TRUE
, TRUE
);
833 void action_raiselower(union ActionData
*data
)
835 ObClient
*c
= data
->client
.any
.c
;
837 gboolean raise
= FALSE
;
841 for (it
= stacking_list
; it
; it
= g_list_next(it
)) {
842 ObClient
*cit
= it
->data
;
845 if (client_normal(cit
) == client_normal(c
) &&
846 cit
->layer
== c
->layer
&&
849 if (RECT_INTERSECTS_RECT(cit
->frame
->area
, c
->frame
->area
)) {
857 stacking_raise(CLIENT_AS_WINDOW(c
));
859 stacking_lower(CLIENT_AS_WINDOW(c
));
862 void action_raise(union ActionData
*data
)
864 if (data
->client
.any
.c
)
865 stacking_raise(CLIENT_AS_WINDOW(data
->client
.any
.c
));
868 void action_unshaderaise(union ActionData
*data
)
870 if (data
->client
.any
.c
) {
871 if (data
->client
.any
.c
->shaded
) {
872 grab_pointer(TRUE
, OB_CURSOR_NONE
);
873 client_shade(data
->client
.any
.c
, FALSE
);
874 grab_pointer(FALSE
, OB_CURSOR_NONE
);
876 stacking_raise(CLIENT_AS_WINDOW(data
->client
.any
.c
));
880 void action_shadelower(union ActionData
*data
)
882 if (data
->client
.any
.c
) {
883 if (data
->client
.any
.c
->shaded
)
884 stacking_lower(CLIENT_AS_WINDOW(data
->client
.any
.c
));
886 grab_pointer(TRUE
, OB_CURSOR_NONE
);
887 client_shade(data
->client
.any
.c
, TRUE
);
888 grab_pointer(FALSE
, OB_CURSOR_NONE
);
893 void action_lower(union ActionData
*data
)
895 if (data
->client
.any
.c
)
896 stacking_lower(CLIENT_AS_WINDOW(data
->client
.any
.c
));
899 void action_close(union ActionData
*data
)
901 if (data
->client
.any
.c
)
902 client_close(data
->client
.any
.c
);
905 void action_kill(union ActionData
*data
)
907 if (data
->client
.any
.c
)
908 client_kill(data
->client
.any
.c
);
911 void action_shade(union ActionData
*data
)
913 if (data
->client
.any
.c
) {
914 grab_pointer(TRUE
, OB_CURSOR_NONE
);
915 client_shade(data
->client
.any
.c
, TRUE
);
916 grab_pointer(FALSE
, OB_CURSOR_NONE
);
920 void action_unshade(union ActionData
*data
)
922 if (data
->client
.any
.c
) {
923 grab_pointer(TRUE
, OB_CURSOR_NONE
);
924 client_shade(data
->client
.any
.c
, FALSE
);
925 grab_pointer(FALSE
, OB_CURSOR_NONE
);
929 void action_toggle_shade(union ActionData
*data
)
931 if (data
->client
.any
.c
) {
932 grab_pointer(TRUE
, OB_CURSOR_NONE
);
933 client_shade(data
->client
.any
.c
, !data
->client
.any
.c
->shaded
);
934 grab_pointer(FALSE
, OB_CURSOR_NONE
);
938 void action_toggle_omnipresent(union ActionData
*data
)
940 if (data
->client
.any
.c
)
941 client_set_desktop(data
->client
.any
.c
,
942 data
->client
.any
.c
->desktop
== DESKTOP_ALL
?
943 screen_desktop
: DESKTOP_ALL
, FALSE
);
946 void action_move_relative_horz(union ActionData
*data
)
948 ObClient
*c
= data
->relative
.any
.c
;
950 grab_pointer(TRUE
, OB_CURSOR_NONE
);
951 client_move(c
, c
->area
.x
+ data
->relative
.delta
, c
->area
.y
);
952 grab_pointer(FALSE
, OB_CURSOR_NONE
);
956 void action_move_relative_vert(union ActionData
*data
)
958 ObClient
*c
= data
->relative
.any
.c
;
960 grab_pointer(TRUE
, OB_CURSOR_NONE
);
961 client_move(c
, c
->area
.x
, c
->area
.y
+ data
->relative
.delta
);
962 grab_pointer(FALSE
, OB_CURSOR_NONE
);
966 void action_resize_relative_horz(union ActionData
*data
)
968 ObClient
*c
= data
->relative
.any
.c
;
970 grab_pointer(TRUE
, OB_CURSOR_NONE
);
972 c
->area
.width
+ data
->relative
.delta
* c
->size_inc
.width
,
974 grab_pointer(FALSE
, OB_CURSOR_NONE
);
978 void action_resize_relative_vert(union ActionData
*data
)
980 ObClient
*c
= data
->relative
.any
.c
;
981 if (c
&& !c
->shaded
) {
982 grab_pointer(TRUE
, OB_CURSOR_NONE
);
983 client_resize(c
, c
->area
.width
, c
->area
.height
+
984 data
->relative
.delta
* c
->size_inc
.height
);
985 grab_pointer(FALSE
, OB_CURSOR_NONE
);
989 void action_maximize_full(union ActionData
*data
)
991 if (data
->client
.any
.c
)
992 client_maximize(data
->client
.any
.c
, TRUE
, 0, TRUE
);
995 void action_unmaximize_full(union ActionData
*data
)
997 if (data
->client
.any
.c
)
998 client_maximize(data
->client
.any
.c
, FALSE
, 0, TRUE
);
1001 void action_toggle_maximize_full(union ActionData
*data
)
1003 if (data
->client
.any
.c
)
1004 client_maximize(data
->client
.any
.c
,
1005 !(data
->client
.any
.c
->max_horz
||
1006 data
->client
.any
.c
->max_vert
),
1010 void action_maximize_horz(union ActionData
*data
)
1012 if (data
->client
.any
.c
)
1013 client_maximize(data
->client
.any
.c
, TRUE
, 1, TRUE
);
1016 void action_unmaximize_horz(union ActionData
*data
)
1018 if (data
->client
.any
.c
)
1019 client_maximize(data
->client
.any
.c
, FALSE
, 1, TRUE
);
1022 void action_toggle_maximize_horz(union ActionData
*data
)
1024 if (data
->client
.any
.c
)
1025 client_maximize(data
->client
.any
.c
,
1026 !data
->client
.any
.c
->max_horz
, 1, TRUE
);
1029 void action_maximize_vert(union ActionData
*data
)
1031 if (data
->client
.any
.c
)
1032 client_maximize(data
->client
.any
.c
, TRUE
, 2, TRUE
);
1035 void action_unmaximize_vert(union ActionData
*data
)
1037 if (data
->client
.any
.c
)
1038 client_maximize(data
->client
.any
.c
, FALSE
, 2, TRUE
);
1041 void action_toggle_maximize_vert(union ActionData
*data
)
1043 if (data
->client
.any
.c
)
1044 client_maximize(data
->client
.any
.c
, !data
->client
.any
.c
->max_vert
, 2, TRUE
);
1047 void action_send_to_desktop(union ActionData
*data
)
1049 ObClient
*c
= data
->sendto
.any
.c
;
1051 if (!c
|| !client_normal(c
)) return;
1053 if (data
->sendto
.desk
< screen_num_desktops
||
1054 data
->sendto
.desk
== DESKTOP_ALL
) {
1055 client_set_desktop(c
, data
->sendto
.desk
, data
->sendto
.follow
);
1056 if (data
->sendto
.follow
)
1057 screen_set_desktop(data
->sendto
.desk
);
1061 void action_desktop(union ActionData
*data
)
1063 if (data
->desktop
.desk
< screen_num_desktops
||
1064 data
->desktop
.desk
== DESKTOP_ALL
)
1065 screen_set_desktop(data
->desktop
.desk
);
1068 void action_desktop_dir(union ActionData
*data
)
1072 d
= screen_cycle_desktop(data
->desktopdir
.dir
,
1073 data
->desktopdir
.wrap
,
1074 data
->sendtodir
.linear
,
1075 data
->desktopdir
.inter
.any
.interactive
,
1076 data
->desktopdir
.inter
.final
,
1077 data
->desktopdir
.inter
.cancel
);
1078 screen_set_desktop(d
);
1081 void action_send_to_desktop_dir(union ActionData
*data
)
1083 ObClient
*c
= data
->sendtodir
.inter
.any
.c
;
1086 if (!c
|| !client_normal(c
)) return;
1088 d
= screen_cycle_desktop(data
->sendtodir
.dir
, data
->sendtodir
.wrap
,
1089 data
->sendtodir
.linear
,
1090 data
->sendtodir
.inter
.any
.interactive
,
1091 data
->sendtodir
.inter
.final
,
1092 data
->sendtodir
.inter
.cancel
);
1093 client_set_desktop(c
, d
, data
->sendtodir
.follow
);
1094 if (data
->sendtodir
.follow
)
1095 screen_set_desktop(d
);
1098 void action_desktop_last(union ActionData
*data
)
1100 screen_set_desktop(screen_last_desktop
);
1103 void action_toggle_decorations(union ActionData
*data
)
1105 ObClient
*c
= data
->client
.any
.c
;
1109 c
->decorate
= !c
->decorate
;
1110 client_setup_decor_and_functions(c
);
1113 static guint32
pick_corner(int x
, int y
, int cx
, int cy
, int cw
, int ch
)
1115 if (x
- cx
> cw
/ 2) {
1116 if (y
- cy
> ch
/ 2)
1117 return prop_atoms
.net_wm_moveresize_size_bottomright
;
1119 return prop_atoms
.net_wm_moveresize_size_topright
;
1121 if (y
- cy
> ch
/ 2)
1122 return prop_atoms
.net_wm_moveresize_size_bottomleft
;
1124 return prop_atoms
.net_wm_moveresize_size_topleft
;
1128 void action_moveresize(union ActionData
*data
)
1130 ObClient
*c
= data
->moveresize
.any
.c
;
1133 if (!c
|| !client_normal(c
)) return;
1135 if (data
->moveresize
.keyboard
) {
1136 corner
= (data
->moveresize
.move
?
1137 prop_atoms
.net_wm_moveresize_move_keyboard
:
1138 prop_atoms
.net_wm_moveresize_size_keyboard
);
1140 corner
= (data
->moveresize
.move
?
1141 prop_atoms
.net_wm_moveresize_move
:
1142 pick_corner(data
->any
.x
, data
->any
.y
,
1143 c
->frame
->area
.x
, c
->frame
->area
.y
,
1144 /* use the client size because the frame
1145 can be differently sized (shaded
1146 windows) and we want this based on the
1148 c
->area
.width
+ c
->frame
->size
.left
+
1149 c
->frame
->size
.right
,
1150 c
->area
.height
+ c
->frame
->size
.top
+
1151 c
->frame
->size
.bottom
));
1154 moveresize_start(c
, data
->any
.x
, data
->any
.y
, data
->any
.button
, corner
);
1157 void action_reconfigure(union ActionData
*data
)
1162 void action_restart(union ActionData
*data
)
1164 ob_restart_other(data
->execute
.path
);
1167 void action_exit(union ActionData
*data
)
1172 void action_showmenu(union ActionData
*data
)
1174 if (data
->showmenu
.name
) {
1175 menu_show(data
->showmenu
.name
, data
->any
.x
, data
->any
.y
,
1176 data
->showmenu
.any
.c
);
1180 void action_cycle_windows(union ActionData
*data
)
1182 focus_cycle(data
->cycle
.forward
, data
->cycle
.linear
,
1183 data
->cycle
.inter
.any
.interactive
,
1184 data
->cycle
.inter
.final
, data
->cycle
.inter
.cancel
);
1187 void action_directional_focus(union ActionData
*data
)
1189 focus_directional_cycle(data
->interdiraction
.direction
,
1190 data
->interdiraction
.inter
.any
.interactive
,
1191 data
->interdiraction
.inter
.final
,
1192 data
->interdiraction
.inter
.cancel
);
1195 void action_movetoedge(union ActionData
*data
)
1198 ObClient
*c
= data
->diraction
.any
.c
;
1202 x
= c
->frame
->area
.x
;
1203 y
= c
->frame
->area
.y
;
1205 switch(data
->diraction
.direction
) {
1206 case OB_DIRECTION_NORTH
:
1207 y
= client_directional_edge_search(c
, OB_DIRECTION_NORTH
);
1209 case OB_DIRECTION_WEST
:
1210 x
= client_directional_edge_search(c
, OB_DIRECTION_WEST
);
1212 case OB_DIRECTION_SOUTH
:
1213 y
= client_directional_edge_search(c
, OB_DIRECTION_SOUTH
) -
1214 c
->frame
->area
.height
;
1216 case OB_DIRECTION_EAST
:
1217 x
= client_directional_edge_search(c
, OB_DIRECTION_EAST
) -
1218 c
->frame
->area
.width
;
1221 g_assert_not_reached();
1223 frame_frame_gravity(c
->frame
, &x
, &y
);
1224 grab_pointer(TRUE
, OB_CURSOR_NONE
);
1225 client_move(c
, x
, y
);
1226 grab_pointer(FALSE
, OB_CURSOR_NONE
);
1230 void action_growtoedge(union ActionData
*data
)
1232 int x
, y
, width
, height
, dest
;
1233 ObClient
*c
= data
->diraction
.any
.c
;
1239 a
= screen_area(c
->desktop
);
1240 x
= c
->frame
->area
.x
;
1241 y
= c
->frame
->area
.y
;
1242 width
= c
->frame
->area
.width
;
1243 height
= c
->frame
->area
.height
;
1245 switch(data
->diraction
.direction
) {
1246 case OB_DIRECTION_NORTH
:
1247 dest
= client_directional_edge_search(c
, OB_DIRECTION_NORTH
);
1249 height
= c
->frame
->area
.height
/ 2;
1251 height
= c
->frame
->area
.y
+ c
->frame
->area
.height
- dest
;
1255 case OB_DIRECTION_WEST
:
1256 dest
= client_directional_edge_search(c
, OB_DIRECTION_WEST
);
1258 width
= c
->frame
->area
.width
/ 2;
1260 width
= c
->frame
->area
.x
+ c
->frame
->area
.width
- dest
;
1264 case OB_DIRECTION_SOUTH
:
1265 dest
= client_directional_edge_search(c
, OB_DIRECTION_SOUTH
);
1266 if (a
->y
+ a
->height
== y
+ c
->frame
->area
.height
) {
1267 height
= c
->frame
->area
.height
/ 2;
1268 y
= a
->y
+ a
->height
- height
;
1270 height
= dest
- c
->frame
->area
.y
;
1271 y
+= (height
- c
->frame
->area
.height
) % c
->size_inc
.height
;
1272 height
-= (height
- c
->frame
->area
.height
) % c
->size_inc
.height
;
1274 case OB_DIRECTION_EAST
:
1275 dest
= client_directional_edge_search(c
, OB_DIRECTION_EAST
);
1276 if (a
->x
+ a
->width
== x
+ c
->frame
->area
.width
) {
1277 width
= c
->frame
->area
.width
/ 2;
1278 x
= a
->x
+ a
->width
- width
;
1280 width
= dest
- c
->frame
->area
.x
;
1281 x
+= (width
- c
->frame
->area
.width
) % c
->size_inc
.width
;
1282 width
-= (width
- c
->frame
->area
.width
) % c
->size_inc
.width
;
1285 g_assert_not_reached();
1287 frame_frame_gravity(c
->frame
, &x
, &y
);
1288 width
-= c
->frame
->size
.left
+ c
->frame
->size
.right
;
1289 height
-= c
->frame
->size
.top
+ c
->frame
->size
.bottom
;
1290 grab_pointer(TRUE
, OB_CURSOR_NONE
);
1291 client_move_resize(c
, x
, y
, width
, height
);
1292 grab_pointer(FALSE
, OB_CURSOR_NONE
);
1295 void action_send_to_layer(union ActionData
*data
)
1297 if (data
->layer
.any
.c
)
1298 client_set_layer(data
->layer
.any
.c
, data
->layer
.layer
);
1301 void action_toggle_layer(union ActionData
*data
)
1303 ObClient
*c
= data
->layer
.any
.c
;
1306 if (data
->layer
.layer
< 0)
1307 client_set_layer(c
, c
->below
? 0 : -1);
1308 else if (data
->layer
.layer
> 0)
1309 client_set_layer(c
, c
->above
? 0 : 1);
1313 void action_toggle_show_desktop(union ActionData
*data
)
1315 screen_show_desktop(!screen_showing_desktop
);
1318 void action_show_desktop(union ActionData
*data
)
1320 screen_show_desktop(TRUE
);
1323 void action_unshow_desktop(union ActionData
*data
)
1325 screen_show_desktop(FALSE
);