4 #include "moveresize.h"
16 typedef struct ActionString
{
18 void (*func
)(union ActionData
*);
19 void (*setup
)(Action
*);
22 Action
*action_new(void (*func
)(union ActionData
*data
))
24 Action
*a
= g_new0(Action
, 1);
30 void action_free(Action
*a
)
32 if (a
== NULL
) return;
34 /* deal with pointers */
35 if (a
->func
== action_execute
|| a
->func
== action_restart
)
36 g_free(a
->data
.execute
.path
);
37 else if (a
->func
== action_showmenu
)
38 g_free(a
->data
.showmenu
.name
);
43 void setup_action_directional_focus_north(Action
*a
)
45 a
->data
.diraction
.direction
= OB_DIRECTION_NORTH
;
48 void setup_action_directional_focus_east(Action
*a
)
50 a
->data
.diraction
.direction
= OB_DIRECTION_EAST
;
53 void setup_action_directional_focus_south(Action
*a
)
55 a
->data
.diraction
.direction
= OB_DIRECTION_SOUTH
;
58 void setup_action_directional_focus_west(Action
*a
)
60 a
->data
.diraction
.direction
= OB_DIRECTION_WEST
;
63 void setup_action_directional_focus_northeast(Action
*a
)
65 a
->data
.diraction
.direction
= OB_DIRECTION_NORTHEAST
;
68 void setup_action_directional_focus_southeast(Action
*a
)
70 a
->data
.diraction
.direction
= OB_DIRECTION_SOUTHEAST
;
73 void setup_action_directional_focus_southwest(Action
*a
)
75 a
->data
.diraction
.direction
= OB_DIRECTION_SOUTHWEST
;
78 void setup_action_directional_focus_northwest(Action
*a
)
80 a
->data
.diraction
.direction
= OB_DIRECTION_NORTHWEST
;
83 void setup_action_send_to_desktop(Action
*a
)
85 a
->data
.sendto
.follow
= TRUE
;
88 void setup_action_send_to_desktop_direction(Action
*a
)
90 a
->data
.sendtodir
.wrap
= TRUE
;
91 a
->data
.sendtodir
.follow
= TRUE
;
94 void setup_action_desktop_direction(Action
*a
)
96 a
->data
.desktopdir
.wrap
= TRUE
;
99 void setup_action_move_keyboard(Action
*a
)
101 a
->data
.moveresize
.corner
= prop_atoms
.net_wm_moveresize_move_keyboard
;
104 void setup_action_move(Action
*a
)
106 a
->data
.moveresize
.corner
= prop_atoms
.net_wm_moveresize_move
;
109 void setup_action_resize(Action
*a
)
111 a
->data
.moveresize
.corner
= prop_atoms
.net_wm_moveresize_size_topleft
;
114 void setup_action_resize_keyboard(Action
*a
)
116 a
->data
.moveresize
.corner
= prop_atoms
.net_wm_moveresize_size_keyboard
;
119 void setup_action_cycle_windows_linear_next(Action
*a
)
121 a
->data
.cycle
.linear
= TRUE
;
122 a
->data
.cycle
.forward
= TRUE
;
125 void setup_action_cycle_windows_linear_previous(Action
*a
)
127 a
->data
.cycle
.linear
= TRUE
;
128 a
->data
.cycle
.forward
= FALSE
;
131 void setup_action_cycle_windows_next(Action
*a
)
133 a
->data
.cycle
.linear
= FALSE
;
134 a
->data
.cycle
.forward
= TRUE
;
137 void setup_action_cycle_windows_previous(Action
*a
)
139 a
->data
.cycle
.linear
= FALSE
;
140 a
->data
.cycle
.forward
= FALSE
;
143 void setup_action_movetoedge_north(Action
*a
)
145 a
->data
.diraction
.direction
= OB_DIRECTION_NORTH
;
148 void setup_action_movetoedge_south(Action
*a
)
150 a
->data
.diraction
.direction
= OB_DIRECTION_SOUTH
;
153 void setup_action_movetoedge_east(Action
*a
)
155 a
->data
.diraction
.direction
= OB_DIRECTION_EAST
;
158 void setup_action_movetoedge_west(Action
*a
)
160 a
->data
.diraction
.direction
= OB_DIRECTION_WEST
;
163 void setup_action_top_layer(Action
*a
)
165 a
->data
.layer
.layer
= 1;
168 void setup_action_normal_layer(Action
*a
)
170 a
->data
.layer
.layer
= 0;
173 void setup_action_bottom_layer(Action
*a
)
175 a
->data
.layer
.layer
= -1;
178 ActionString actionstrings
[] =
186 "directionalfocusnorth",
187 action_directional_focus
,
188 setup_action_directional_focus_north
191 "directionalfocuseast",
192 action_directional_focus
,
193 setup_action_directional_focus_east
196 "directionalfocussouth",
197 action_directional_focus
,
198 setup_action_directional_focus_south
201 "directionalfocuswest",
202 action_directional_focus
,
203 setup_action_directional_focus_west
206 "directionalfocusnortheast",
207 action_directional_focus
,
208 setup_action_directional_focus_northeast
211 "directionalfocussoutheast",
212 action_directional_focus
,
213 setup_action_directional_focus_southeast
216 "directionalfocussouthwest",
217 action_directional_focus
,
218 setup_action_directional_focus_southwest
221 "directionalfocusnorthwest",
222 action_directional_focus
,
223 setup_action_directional_focus_northwest
287 action_toggle_omnipresent
,
292 action_move_relative_horz
,
297 action_move_relative_vert
,
301 "resizerelativehorz",
302 action_resize_relative_horz
,
306 "resizerelativevert",
307 action_resize_relative_vert
,
312 action_maximize_full
,
317 action_unmaximize_full
,
321 "togglemaximizefull",
322 action_toggle_maximize_full
,
327 action_maximize_horz
,
332 action_unmaximize_horz
,
336 "togglemaximizehorz",
337 action_toggle_maximize_horz
,
342 action_maximize_vert
,
347 action_unmaximize_vert
,
351 "togglemaximizevert",
352 action_toggle_maximize_vert
,
357 action_send_to_desktop
,
358 setup_action_send_to_desktop
361 "sendtodesktopright",
362 action_send_to_desktop_right
,
363 setup_action_send_to_desktop_direction
367 action_send_to_desktop_left
,
368 setup_action_send_to_desktop_direction
372 action_send_to_desktop_up
,
373 setup_action_send_to_desktop_direction
377 action_send_to_desktop_down
,
378 setup_action_send_to_desktop_direction
387 action_desktop_right
,
388 setup_action_desktop_direction
393 setup_action_desktop_direction
398 setup_action_desktop_direction
403 setup_action_desktop_direction
407 action_toggle_decorations
,
413 setup_action_move_keyboard
428 setup_action_resize_keyboard
432 action_toggle_show_desktop
,
442 action_unshow_desktop
,
462 action_send_to_layer
,
463 setup_action_top_layer
468 setup_action_top_layer
472 action_send_to_layer
,
473 setup_action_normal_layer
477 action_send_to_layer
,
478 setup_action_bottom_layer
481 "togglealwaysonbottom",
483 setup_action_bottom_layer
487 action_cycle_windows
,
488 setup_action_cycle_windows_linear_next
491 "previouswindowlinear",
492 action_cycle_windows
,
493 setup_action_cycle_windows_linear_previous
497 action_cycle_windows
,
498 setup_action_cycle_windows_next
502 action_cycle_windows
,
503 setup_action_cycle_windows_previous
508 setup_action_movetoedge_north
513 setup_action_movetoedge_south
518 setup_action_movetoedge_west
523 setup_action_movetoedge_east
532 Action
*action_from_string(char *name
)
537 for (i
= 0; actionstrings
[i
].name
; i
++)
538 if (!g_ascii_strcasecmp(name
, actionstrings
[i
].name
)) {
539 a
= action_new(actionstrings
[i
].func
);
540 if (actionstrings
[i
].setup
)
541 actionstrings
[i
].setup(a
);
547 Action
*action_parse(xmlDocPtr doc
, xmlNodePtr node
)
553 if (parse_attr_string("name", node
, &actname
)) {
554 if ((act
= action_from_string(actname
))) {
555 if (act
->func
== action_execute
|| act
->func
== action_restart
) {
556 if ((n
= parse_find_node("execute", node
->xmlChildrenNode
)))
557 act
->data
.execute
.path
= parse_string(doc
, n
);
558 } else if (act
->func
== action_showmenu
) {
559 if ((n
= parse_find_node("menu", node
->xmlChildrenNode
)))
560 act
->data
.showmenu
.name
= parse_string(doc
, n
);
561 } else if (act
->func
== action_desktop
) {
562 if ((n
= parse_find_node("desktop", node
->xmlChildrenNode
)))
563 act
->data
.desktop
.desk
= parse_int(doc
, n
);
564 if (act
->data
.desktop
.desk
> 0) act
->data
.desktop
.desk
--;
565 } else if (act
->func
== action_send_to_desktop
) {
566 if ((n
= parse_find_node("desktop", node
->xmlChildrenNode
)))
567 act
->data
.sendto
.desk
= parse_int(doc
, n
);
568 if (act
->data
.sendto
.desk
> 0) act
->data
.sendto
.desk
--;
569 } else if (act
->func
== action_move_relative_horz
||
570 act
->func
== action_move_relative_vert
||
571 act
->func
== action_resize_relative_horz
||
572 act
->func
== action_resize_relative_vert
) {
573 if ((n
= parse_find_node("delta", node
->xmlChildrenNode
)))
574 act
->data
.relative
.delta
= parse_int(doc
, n
);
575 } else if (act
->func
== action_desktop_right
||
576 act
->func
== action_desktop_left
||
577 act
->func
== action_desktop_up
||
578 act
->func
== action_desktop_down
) {
579 if ((n
= parse_find_node("wrap", node
->xmlChildrenNode
))) {
580 act
->data
.desktopdir
.wrap
= parse_bool(doc
, n
);
582 } else if (act
->func
== action_send_to_desktop_right
||
583 act
->func
== action_send_to_desktop_left
||
584 act
->func
== action_send_to_desktop_up
||
585 act
->func
== action_send_to_desktop_down
) {
586 if ((n
= parse_find_node("wrap", node
->xmlChildrenNode
)))
587 act
->data
.sendtodir
.wrap
= parse_bool(doc
, n
);
588 if ((n
= parse_find_node("follow", node
->xmlChildrenNode
)))
589 act
->data
.sendtodir
.follow
= parse_bool(doc
, n
);
597 void action_execute(union ActionData
*data
)
601 if (data
->execute
.path
) {
602 cmd
= g_filename_from_utf8(data
->execute
.path
, -1, NULL
, NULL
, NULL
);
604 if (!g_spawn_command_line_async(cmd
, &e
)) {
605 g_warning("failed to execute '%s': %s",
609 g_warning("failed to convert '%s' from utf8", data
->execute
.path
);
614 void action_focus(union ActionData
*data
)
617 client_focus(data
->client
.c
);
620 void action_unfocus (union ActionData
*data
)
623 client_unfocus(data
->client
.c
);
626 void action_iconify(union ActionData
*data
)
629 client_iconify(data
->client
.c
, TRUE
, TRUE
);
632 void action_raise(union ActionData
*data
)
635 stacking_raise(CLIENT_AS_WINDOW(data
->client
.c
));
638 void action_unshaderaise(union ActionData
*data
)
640 if (data
->client
.c
) {
641 if (data
->client
.c
->shaded
)
642 client_shade(data
->client
.c
, FALSE
);
644 stacking_raise(CLIENT_AS_WINDOW(data
->client
.c
));
648 void action_shadelower(union ActionData
*data
)
650 if (data
->client
.c
) {
651 if (data
->client
.c
->shaded
)
652 stacking_lower(CLIENT_AS_WINDOW(data
->client
.c
));
654 client_shade(data
->client
.c
, TRUE
);
658 void action_lower(union ActionData
*data
)
661 stacking_lower(CLIENT_AS_WINDOW(data
->client
.c
));
664 void action_close(union ActionData
*data
)
667 client_close(data
->client
.c
);
670 void action_kill(union ActionData
*data
)
673 client_kill(data
->client
.c
);
676 void action_shade(union ActionData
*data
)
679 client_shade(data
->client
.c
, TRUE
);
682 void action_unshade(union ActionData
*data
)
685 client_shade(data
->client
.c
, FALSE
);
688 void action_toggle_shade(union ActionData
*data
)
691 client_shade(data
->client
.c
, !data
->client
.c
->shaded
);
694 void action_toggle_omnipresent(union ActionData
*data
)
697 client_set_desktop(data
->client
.c
,
698 data
->client
.c
->desktop
== DESKTOP_ALL
?
699 screen_desktop
: DESKTOP_ALL
, FALSE
);
702 void action_move_relative_horz(union ActionData
*data
)
704 ObClient
*c
= data
->relative
.c
;
706 client_configure(c
, OB_CORNER_TOPLEFT
,
707 c
->area
.x
+ data
->relative
.delta
, c
->area
.y
,
708 c
->area
.width
, c
->area
.height
, TRUE
, TRUE
);
711 void action_move_relative_vert(union ActionData
*data
)
713 ObClient
*c
= data
->relative
.c
;
715 client_configure(c
, OB_CORNER_TOPLEFT
,
716 c
->area
.x
, c
->area
.y
+ data
->relative
.delta
,
717 c
->area
.width
, c
->area
.height
, TRUE
, TRUE
);
720 void action_resize_relative_horz(union ActionData
*data
)
722 ObClient
*c
= data
->relative
.c
;
724 client_configure(c
, OB_CORNER_TOPLEFT
, c
->area
.x
, c
->area
.y
,
726 data
->relative
.delta
* c
->size_inc
.width
,
727 c
->area
.height
, TRUE
, TRUE
);
730 void action_resize_relative_vert(union ActionData
*data
)
732 ObClient
*c
= data
->relative
.c
;
734 client_configure(c
, OB_CORNER_TOPLEFT
, c
->area
.x
, c
->area
.y
,
735 c
->area
.width
, c
->area
.height
+
736 data
->relative
.delta
* c
->size_inc
.height
,
740 void action_maximize_full(union ActionData
*data
)
743 client_maximize(data
->client
.c
, TRUE
, 0, TRUE
);
746 void action_unmaximize_full(union ActionData
*data
)
749 client_maximize(data
->client
.c
, FALSE
, 0, TRUE
);
752 void action_toggle_maximize_full(union ActionData
*data
)
755 client_maximize(data
->client
.c
,
756 !(data
->client
.c
->max_horz
||
757 data
->client
.c
->max_vert
),
761 void action_maximize_horz(union ActionData
*data
)
764 client_maximize(data
->client
.c
, TRUE
, 1, TRUE
);
767 void action_unmaximize_horz(union ActionData
*data
)
770 client_maximize(data
->client
.c
, FALSE
, 1, TRUE
);
773 void action_toggle_maximize_horz(union ActionData
*data
)
776 client_maximize(data
->client
.c
, !data
->client
.c
->max_horz
, 1, TRUE
);
779 void action_maximize_vert(union ActionData
*data
)
782 client_maximize(data
->client
.c
, TRUE
, 2, TRUE
);
785 void action_unmaximize_vert(union ActionData
*data
)
788 client_maximize(data
->client
.c
, FALSE
, 2, TRUE
);
791 void action_toggle_maximize_vert(union ActionData
*data
)
794 client_maximize(data
->client
.c
, !data
->client
.c
->max_vert
, 2, TRUE
);
797 void action_send_to_desktop(union ActionData
*data
)
799 ObClient
*c
= data
->sendto
.c
;
801 if (!c
|| !client_normal(c
)) return;
803 if (data
->sendto
.desk
< screen_num_desktops
||
804 data
->sendto
.desk
== DESKTOP_ALL
) {
805 client_set_desktop(c
, data
->sendto
.desk
, data
->sendto
.follow
);
806 if (data
->sendto
.follow
) screen_set_desktop(data
->sendto
.desk
);
810 void action_desktop(union ActionData
*data
)
812 if (data
->desktop
.desk
< screen_num_desktops
||
813 data
->desktop
.desk
== DESKTOP_ALL
)
814 screen_set_desktop(data
->desktop
.desk
);
817 static void cur_row_col(guint
*r
, guint
*c
)
819 switch (screen_desktop_layout
.orientation
) {
820 case OB_ORIENTATION_HORZ
:
821 switch (screen_desktop_layout
.start_corner
) {
822 case OB_CORNER_TOPLEFT
:
823 *r
= screen_desktop
/ screen_desktop_layout
.columns
;
824 *c
= screen_desktop
% screen_desktop_layout
.columns
;
826 case OB_CORNER_BOTTOMLEFT
:
827 *r
= screen_desktop_layout
.rows
- 1 -
828 screen_desktop
/ screen_desktop_layout
.columns
;
829 *c
= screen_desktop
% screen_desktop_layout
.columns
;
831 case OB_CORNER_TOPRIGHT
:
832 *r
= screen_desktop
/ screen_desktop_layout
.columns
;
833 *c
= screen_desktop_layout
.columns
- 1 -
834 screen_desktop
% screen_desktop_layout
.columns
;
836 case OB_CORNER_BOTTOMRIGHT
:
837 *r
= screen_desktop_layout
.rows
- 1 -
838 screen_desktop
/ screen_desktop_layout
.columns
;
839 *c
= screen_desktop_layout
.columns
- 1 -
840 screen_desktop
% screen_desktop_layout
.columns
;
844 case OB_ORIENTATION_VERT
:
845 switch (screen_desktop_layout
.start_corner
) {
846 case OB_CORNER_TOPLEFT
:
847 *r
= screen_desktop
% screen_desktop_layout
.rows
;
848 *c
= screen_desktop
/ screen_desktop_layout
.rows
;
850 case OB_CORNER_BOTTOMLEFT
:
851 *r
= screen_desktop_layout
.rows
- 1 -
852 screen_desktop
% screen_desktop_layout
.rows
;
853 *c
= screen_desktop
/ screen_desktop_layout
.rows
;
855 case OB_CORNER_TOPRIGHT
:
856 *r
= screen_desktop
% screen_desktop_layout
.rows
;
857 *c
= screen_desktop_layout
.columns
- 1 -
858 screen_desktop
/ screen_desktop_layout
.rows
;
860 case OB_CORNER_BOTTOMRIGHT
:
861 *r
= screen_desktop_layout
.rows
- 1 -
862 screen_desktop
% screen_desktop_layout
.rows
;
863 *c
= screen_desktop_layout
.columns
- 1 -
864 screen_desktop
/ screen_desktop_layout
.rows
;
871 static guint
translate_row_col(guint r
, guint c
)
873 switch (screen_desktop_layout
.orientation
) {
874 case OB_ORIENTATION_HORZ
:
875 switch (screen_desktop_layout
.start_corner
) {
876 case OB_CORNER_TOPLEFT
:
877 return r
% screen_desktop_layout
.rows
*
878 screen_desktop_layout
.columns
+
879 c
% screen_desktop_layout
.columns
;
880 case OB_CORNER_BOTTOMLEFT
:
881 return (screen_desktop_layout
.rows
- 1 -
882 r
% screen_desktop_layout
.rows
) *
883 screen_desktop_layout
.columns
+
884 c
% screen_desktop_layout
.columns
;
885 case OB_CORNER_TOPRIGHT
:
886 return r
% screen_desktop_layout
.rows
*
887 screen_desktop_layout
.columns
+
888 (screen_desktop_layout
.columns
- 1 -
889 c
% screen_desktop_layout
.columns
);
890 case OB_CORNER_BOTTOMRIGHT
:
891 return (screen_desktop_layout
.rows
- 1 -
892 r
% screen_desktop_layout
.rows
) *
893 screen_desktop_layout
.columns
+
894 (screen_desktop_layout
.columns
- 1 -
895 c
% screen_desktop_layout
.columns
);
897 case OB_ORIENTATION_VERT
:
898 switch (screen_desktop_layout
.start_corner
) {
899 case OB_CORNER_TOPLEFT
:
900 return c
% screen_desktop_layout
.columns
*
901 screen_desktop_layout
.rows
+
902 r
% screen_desktop_layout
.rows
;
903 case OB_CORNER_BOTTOMLEFT
:
904 return c
% screen_desktop_layout
.columns
*
905 screen_desktop_layout
.rows
+
906 (screen_desktop_layout
.rows
- 1 -
907 r
% screen_desktop_layout
.rows
);
908 case OB_CORNER_TOPRIGHT
:
909 return (screen_desktop_layout
.columns
- 1 -
910 c
% screen_desktop_layout
.columns
) *
911 screen_desktop_layout
.rows
+
912 r
% screen_desktop_layout
.rows
;
913 case OB_CORNER_BOTTOMRIGHT
:
914 return (screen_desktop_layout
.columns
- 1 -
915 c
% screen_desktop_layout
.columns
) *
916 screen_desktop_layout
.rows
+
917 (screen_desktop_layout
.rows
- 1 -
918 r
% screen_desktop_layout
.rows
);
921 g_assert_not_reached();
925 void action_desktop_right(union ActionData
*data
)
931 if (c
>= screen_desktop_layout
.columns
) {
932 if (!data
->desktopdir
.wrap
) return;
935 d
= translate_row_col(r
, c
);
936 if (d
>= screen_num_desktops
) {
937 if (!data
->desktopdir
.wrap
) return;
940 d
= translate_row_col(r
, c
);
941 if (d
< screen_num_desktops
)
942 screen_set_desktop(d
);
945 void action_send_to_desktop_right(union ActionData
*data
)
947 ObClient
*cl
= data
->sendto
.c
;
950 if (!cl
|| !client_normal(cl
)) return;
954 if (c
>= screen_desktop_layout
.columns
) {
955 if (!data
->sendtodir
.wrap
) return;
958 d
= translate_row_col(r
, c
);
959 if (d
>= screen_num_desktops
) {
960 if (!data
->sendtodir
.wrap
) return;
963 d
= translate_row_col(r
, c
);
964 if (d
< screen_num_desktops
) {
965 client_set_desktop(cl
, d
, data
->sendtodir
.follow
);
966 if (data
->sendtodir
.follow
) screen_set_desktop(d
);
970 void action_desktop_left(union ActionData
*data
)
976 if (c
>= screen_desktop_layout
.columns
) {
977 if (!data
->desktopdir
.wrap
) return;
978 c
= screen_desktop_layout
.columns
- 1;
980 d
= translate_row_col(r
, c
);
981 if (d
>= screen_num_desktops
) {
982 if (!data
->desktopdir
.wrap
) return;
985 d
= translate_row_col(r
, c
);
986 if (d
< screen_num_desktops
)
987 screen_set_desktop(d
);
990 void action_send_to_desktop_left(union ActionData
*data
)
992 ObClient
*cl
= data
->sendto
.c
;
995 if (!cl
|| !client_normal(cl
)) return;
999 if (c
>= screen_desktop_layout
.columns
) {
1000 if (!data
->sendtodir
.wrap
) return;
1001 c
= screen_desktop_layout
.columns
- 1;
1003 d
= translate_row_col(r
, c
);
1004 if (d
>= screen_num_desktops
) {
1005 if (!data
->sendtodir
.wrap
) return;
1008 d
= translate_row_col(r
, c
);
1009 if (d
< screen_num_desktops
) {
1010 client_set_desktop(cl
, d
, data
->sendtodir
.follow
);
1011 if (data
->sendtodir
.follow
) screen_set_desktop(d
);
1015 void action_desktop_down(union ActionData
*data
)
1019 cur_row_col(&r
, &c
);
1021 if (r
>= screen_desktop_layout
.rows
) {
1022 if (!data
->desktopdir
.wrap
) return;
1025 d
= translate_row_col(r
, c
);
1026 if (d
>= screen_num_desktops
) {
1027 if (!data
->desktopdir
.wrap
) return;
1030 d
= translate_row_col(r
, c
);
1031 if (d
< screen_num_desktops
)
1032 screen_set_desktop(d
);
1035 void action_send_to_desktop_down(union ActionData
*data
)
1039 if (data
->sendtodir
.c
) {
1040 cur_row_col(&r
, &c
);
1042 if (r
>= screen_desktop_layout
.rows
) {
1043 if (!data
->sendtodir
.wrap
) return;
1046 d
= translate_row_col(r
, c
);
1047 if (d
>= screen_num_desktops
) {
1048 if (!data
->sendtodir
.wrap
) return;
1051 d
= translate_row_col(r
, c
);
1052 if (d
< screen_num_desktops
) {
1053 client_set_desktop(data
->sendtodir
.c
, d
, data
->sendtodir
.follow
);
1054 if (data
->sendtodir
.follow
) screen_set_desktop(d
);
1059 void action_desktop_up(union ActionData
*data
)
1063 cur_row_col(&r
, &c
);
1065 if (r
>= screen_desktop_layout
.rows
) {
1066 if (!data
->desktopdir
.wrap
) return;
1067 r
= screen_desktop_layout
.rows
- 1;
1069 d
= translate_row_col(r
, c
);
1070 if (d
>= screen_num_desktops
) {
1071 if (!data
->desktopdir
.wrap
) return;
1074 d
= translate_row_col(r
, c
);
1075 if (d
< screen_num_desktops
)
1076 screen_set_desktop(d
);
1079 void action_send_to_desktop_up(union ActionData
*data
)
1083 if (data
->sendtodir
.c
) {
1084 cur_row_col(&r
, &c
);
1086 if (r
>= screen_desktop_layout
.rows
) {
1087 if (!data
->sendtodir
.wrap
) return;
1088 r
= screen_desktop_layout
.rows
- 1;
1090 d
= translate_row_col(r
, c
);
1091 if (d
>= screen_num_desktops
) {
1092 if (!data
->sendtodir
.wrap
) return;
1095 d
= translate_row_col(r
, c
);
1096 if (d
< screen_num_desktops
) {
1097 client_set_desktop(data
->sendtodir
.c
, d
, data
->sendtodir
.follow
);
1098 if (data
->sendtodir
.follow
) screen_set_desktop(d
);
1103 void action_toggle_decorations(union ActionData
*data
)
1105 ObClient
*c
= data
->client
.c
;;
1109 c
->decorate
= !c
->decorate
;
1110 client_setup_decor_and_functions(c
);
1113 void action_moveresize(union ActionData
*data
)
1115 ObClient
*c
= data
->moveresize
.c
;
1117 if (!c
|| !client_normal(c
)) return;
1119 moveresize_start(c
, data
->moveresize
.x
, data
->moveresize
.y
,
1120 data
->moveresize
.button
, data
->moveresize
.corner
);
1123 void action_restart(union ActionData
*data
)
1125 ob_restart_other(data
->execute
.path
);
1128 void action_exit(union ActionData
*data
)
1133 void action_showmenu(union ActionData
*data
)
1135 if (data
->showmenu
.name
) {
1136 menu_show(data
->showmenu
.name
, data
->showmenu
.x
, data
->showmenu
.y
,
1141 void action_cycle_windows(union ActionData
*data
)
1145 c
= focus_cycle(data
->cycle
.forward
, data
->cycle
.linear
, data
->cycle
.final
,
1146 data
->cycle
.cancel
);
1149 void action_directional_focus(union ActionData
*data
)
1153 if (!data
->diraction
.c
)
1155 if ((nf
= client_find_directional(data
->diraction
.c
,
1156 data
->diraction
.direction
)))
1157 client_activate(nf
);
1160 void action_movetoedge(union ActionData
*data
)
1163 ObClient
*c
= data
->diraction
.c
;
1167 x
= c
->frame
->area
.x
;
1168 y
= c
->frame
->area
.y
;
1170 h
= screen_area(c
->desktop
)->height
;
1171 w
= screen_area(c
->desktop
)->width
;
1172 switch(data
->diraction
.direction
) {
1173 case OB_DIRECTION_NORTH
:
1176 case OB_DIRECTION_WEST
:
1179 case OB_DIRECTION_SOUTH
:
1180 y
= h
- c
->frame
->area
.height
;
1182 case OB_DIRECTION_EAST
:
1183 x
= w
- c
->frame
->area
.width
;
1186 g_assert_not_reached();
1188 frame_frame_gravity(c
->frame
, &x
, &y
);
1189 client_configure(c
, OB_CORNER_TOPLEFT
,
1190 x
, y
, c
->area
.width
, c
->area
.height
, TRUE
, TRUE
);
1194 void action_send_to_layer(union ActionData
*data
)
1197 client_set_layer(data
->layer
.c
, data
->layer
.layer
);
1200 void action_toggle_layer(union ActionData
*data
)
1202 ObClient
*c
= data
->layer
.c
;
1205 if (data
->layer
.layer
< 0)
1206 client_set_layer(c
, c
->below
? 0 : -1);
1207 else if (data
->layer
.layer
> 0)
1208 client_set_layer(c
, c
->above
? 0 : 1);
1212 void action_toggle_show_desktop(union ActionData
*data
)
1214 screen_show_desktop(!screen_showing_desktop
);
1217 void action_show_desktop(union ActionData
*data
)
1219 screen_show_desktop(TRUE
);
1222 void action_unshow_desktop(union ActionData
*data
)
1224 screen_show_desktop(FALSE
);