3 #include "moveresize.h"
15 typedef struct ActionString
{
17 void (*func
)(union ActionData
*);
18 void (*setup
)(Action
*);
21 Action
*action_new(void (*func
)(union ActionData
*data
))
23 Action
*a
= g_new0(Action
, 1);
29 void action_free(Action
*a
)
31 if (a
== NULL
) return;
33 /* deal with pointers */
34 if (a
->func
== action_execute
|| a
->func
== action_restart
)
35 g_free(a
->data
.execute
.path
);
36 else if (a
->func
== action_showmenu
)
37 g_free(a
->data
.showmenu
.name
);
42 void setup_action_directional_focus_north(Action
*a
)
44 a
->data
.diraction
.direction
= OB_DIRECTION_NORTH
;
47 void setup_action_directional_focus_east(Action
*a
)
49 a
->data
.diraction
.direction
= OB_DIRECTION_EAST
;
52 void setup_action_directional_focus_south(Action
*a
)
54 a
->data
.diraction
.direction
= OB_DIRECTION_SOUTH
;
57 void setup_action_directional_focus_west(Action
*a
)
59 a
->data
.diraction
.direction
= OB_DIRECTION_WEST
;
62 void setup_action_directional_focus_northeast(Action
*a
)
64 a
->data
.diraction
.direction
= OB_DIRECTION_NORTHEAST
;
67 void setup_action_directional_focus_southeast(Action
*a
)
69 a
->data
.diraction
.direction
= OB_DIRECTION_SOUTHEAST
;
72 void setup_action_directional_focus_southwest(Action
*a
)
74 a
->data
.diraction
.direction
= OB_DIRECTION_SOUTHWEST
;
77 void setup_action_directional_focus_northwest(Action
*a
)
79 a
->data
.diraction
.direction
= OB_DIRECTION_NORTHWEST
;
82 void setup_action_send_to_desktop(Action
*a
)
84 a
->data
.sendto
.follow
= TRUE
;
87 void setup_action_send_to_desktop_direction(Action
*a
)
89 a
->data
.sendtodir
.wrap
= TRUE
;
90 a
->data
.sendtodir
.follow
= TRUE
;
93 void setup_action_desktop_direction(Action
*a
)
95 a
->data
.desktopdir
.wrap
= TRUE
;
98 void setup_action_move_keyboard(Action
*a
)
100 a
->data
.moveresize
.corner
= prop_atoms
.net_wm_moveresize_move_keyboard
;
103 void setup_action_move(Action
*a
)
105 a
->data
.moveresize
.corner
= prop_atoms
.net_wm_moveresize_move
;
108 void setup_action_resize(Action
*a
)
110 a
->data
.moveresize
.corner
= prop_atoms
.net_wm_moveresize_size_topleft
;
113 void setup_action_resize_keyboard(Action
*a
)
115 a
->data
.moveresize
.corner
= prop_atoms
.net_wm_moveresize_size_keyboard
;
118 void setup_action_cycle_windows_linear_next(Action
*a
)
120 a
->data
.cycle
.linear
= TRUE
;
121 a
->data
.cycle
.forward
= TRUE
;
124 void setup_action_cycle_windows_linear_previous(Action
*a
)
126 a
->data
.cycle
.linear
= TRUE
;
127 a
->data
.cycle
.forward
= FALSE
;
130 void setup_action_cycle_windows_next(Action
*a
)
132 a
->data
.cycle
.linear
= FALSE
;
133 a
->data
.cycle
.forward
= TRUE
;
136 void setup_action_cycle_windows_previous(Action
*a
)
138 a
->data
.cycle
.linear
= FALSE
;
139 a
->data
.cycle
.forward
= FALSE
;
142 void setup_action_movetoedge_north(Action
*a
)
144 a
->data
.diraction
.direction
= OB_DIRECTION_NORTH
;
147 void setup_action_movetoedge_south(Action
*a
)
149 a
->data
.diraction
.direction
= OB_DIRECTION_SOUTH
;
152 void setup_action_movetoedge_east(Action
*a
)
154 a
->data
.diraction
.direction
= OB_DIRECTION_EAST
;
157 void setup_action_movetoedge_west(Action
*a
)
159 a
->data
.diraction
.direction
= OB_DIRECTION_WEST
;
162 void setup_action_top_layer(Action
*a
)
164 a
->data
.layer
.layer
= 1;
167 void setup_action_normal_layer(Action
*a
)
169 a
->data
.layer
.layer
= 0;
172 void setup_action_bottom_layer(Action
*a
)
174 a
->data
.layer
.layer
= -1;
177 ActionString actionstrings
[] =
185 "directionalfocusnorth",
186 action_directional_focus
,
187 setup_action_directional_focus_north
190 "directionalfocuseast",
191 action_directional_focus
,
192 setup_action_directional_focus_east
195 "directionalfocussouth",
196 action_directional_focus
,
197 setup_action_directional_focus_south
200 "directionalfocuswest",
201 action_directional_focus
,
202 setup_action_directional_focus_west
205 "directionalfocusnortheast",
206 action_directional_focus
,
207 setup_action_directional_focus_northeast
210 "directionalfocussoutheast",
211 action_directional_focus
,
212 setup_action_directional_focus_southeast
215 "directionalfocussouthwest",
216 action_directional_focus
,
217 setup_action_directional_focus_southwest
220 "directionalfocusnorthwest",
221 action_directional_focus
,
222 setup_action_directional_focus_northwest
286 action_toggle_omnipresent
,
291 action_move_relative_horz
,
296 action_move_relative_vert
,
300 "resizerelativehorz",
301 action_resize_relative_horz
,
305 "resizerelativevert",
306 action_resize_relative_vert
,
311 action_maximize_full
,
316 action_unmaximize_full
,
320 "togglemaximizefull",
321 action_toggle_maximize_full
,
326 action_maximize_horz
,
331 action_unmaximize_horz
,
335 "togglemaximizehorz",
336 action_toggle_maximize_horz
,
341 action_maximize_vert
,
346 action_unmaximize_vert
,
350 "togglemaximizevert",
351 action_toggle_maximize_vert
,
356 action_send_to_desktop
,
357 setup_action_send_to_desktop
360 "sendtodesktopright",
361 action_send_to_desktop_right
,
362 setup_action_send_to_desktop_direction
366 action_send_to_desktop_left
,
367 setup_action_send_to_desktop_direction
371 action_send_to_desktop_up
,
372 setup_action_send_to_desktop_direction
376 action_send_to_desktop_down
,
377 setup_action_send_to_desktop_direction
386 action_desktop_right
,
387 setup_action_desktop_direction
392 setup_action_desktop_direction
397 setup_action_desktop_direction
402 setup_action_desktop_direction
406 action_toggle_decorations
,
412 setup_action_move_keyboard
427 setup_action_resize_keyboard
431 action_toggle_show_desktop
,
441 action_unshow_desktop
,
461 action_send_to_layer
,
462 setup_action_top_layer
467 setup_action_top_layer
471 action_send_to_layer
,
472 setup_action_normal_layer
476 action_send_to_layer
,
477 setup_action_bottom_layer
480 "togglealwaysonbottom",
482 setup_action_bottom_layer
486 action_cycle_windows
,
487 setup_action_cycle_windows_linear_next
490 "previouswindowlinear",
491 action_cycle_windows
,
492 setup_action_cycle_windows_linear_previous
496 action_cycle_windows
,
497 setup_action_cycle_windows_next
501 action_cycle_windows
,
502 setup_action_cycle_windows_previous
507 setup_action_movetoedge_north
512 setup_action_movetoedge_south
517 setup_action_movetoedge_west
522 setup_action_movetoedge_east
531 Action
*action_from_string(char *name
)
536 for (i
= 0; actionstrings
[i
].name
; i
++)
537 if (!g_ascii_strcasecmp(name
, actionstrings
[i
].name
)) {
538 a
= action_new(actionstrings
[i
].func
);
539 if (actionstrings
[i
].setup
)
540 actionstrings
[i
].setup(a
);
546 Action
*action_parse(xmlDocPtr doc
, xmlNodePtr node
)
552 if (parse_attr_string("name", node
, &actname
)) {
553 if ((act
= action_from_string(actname
))) {
554 if (act
->func
== action_execute
|| act
->func
== action_restart
) {
555 if ((n
= parse_find_node("execute", node
->xmlChildrenNode
)))
556 act
->data
.execute
.path
= parse_string(doc
, n
);
557 } else if (act
->func
== action_showmenu
) {
558 if ((n
= parse_find_node("menu", node
->xmlChildrenNode
)))
559 act
->data
.showmenu
.name
= parse_string(doc
, n
);
560 } else if (act
->func
== action_desktop
) {
561 if ((n
= parse_find_node("desktop", node
->xmlChildrenNode
)))
562 act
->data
.desktop
.desk
= parse_int(doc
, n
);
563 if (act
->data
.desktop
.desk
> 0) act
->data
.desktop
.desk
--;
564 } else if (act
->func
== action_send_to_desktop
) {
565 if ((n
= parse_find_node("desktop", node
->xmlChildrenNode
)))
566 act
->data
.sendto
.desk
= parse_int(doc
, n
);
567 if (act
->data
.sendto
.desk
> 0) act
->data
.sendto
.desk
--;
568 } else if (act
->func
== action_move_relative_horz
||
569 act
->func
== action_move_relative_vert
||
570 act
->func
== action_resize_relative_horz
||
571 act
->func
== action_resize_relative_vert
) {
572 if ((n
= parse_find_node("delta", node
->xmlChildrenNode
)))
573 act
->data
.relative
.delta
= parse_int(doc
, n
);
574 } else if (act
->func
== action_desktop_right
||
575 act
->func
== action_desktop_left
||
576 act
->func
== action_desktop_up
||
577 act
->func
== action_desktop_down
) {
578 if ((n
= parse_find_node("wrap", node
->xmlChildrenNode
))) {
579 g_message("WRAP %d", parse_bool(doc
, n
));
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
);
596 void action_execute(union ActionData
*data
)
600 if (data
->execute
.path
) {
601 cmd
= g_filename_from_utf8(data
->execute
.path
, -1, NULL
, NULL
, NULL
);
603 if (!g_spawn_command_line_async(cmd
, &e
)) {
604 g_warning("failed to execute '%s': %s",
608 g_warning("failed to convert '%s' from utf8", data
->execute
.path
);
613 void action_focus(union ActionData
*data
)
616 client_focus(data
->client
.c
);
619 void action_unfocus (union ActionData
*data
)
622 client_unfocus(data
->client
.c
);
625 void action_iconify(union ActionData
*data
)
628 client_iconify(data
->client
.c
, TRUE
, TRUE
);
631 void action_raise(union ActionData
*data
)
634 stacking_raise(CLIENT_AS_WINDOW(data
->client
.c
));
637 void action_unshaderaise(union ActionData
*data
)
639 if (data
->client
.c
) {
640 if (data
->client
.c
->shaded
)
641 client_shade(data
->client
.c
, FALSE
);
643 stacking_raise(CLIENT_AS_WINDOW(data
->client
.c
));
647 void action_shadelower(union ActionData
*data
)
649 if (data
->client
.c
) {
650 if (data
->client
.c
->shaded
)
651 stacking_lower(CLIENT_AS_WINDOW(data
->client
.c
));
653 client_shade(data
->client
.c
, TRUE
);
657 void action_lower(union ActionData
*data
)
660 stacking_lower(CLIENT_AS_WINDOW(data
->client
.c
));
663 void action_close(union ActionData
*data
)
666 client_close(data
->client
.c
);
669 void action_kill(union ActionData
*data
)
672 client_kill(data
->client
.c
);
675 void action_shade(union ActionData
*data
)
678 client_shade(data
->client
.c
, TRUE
);
681 void action_unshade(union ActionData
*data
)
684 client_shade(data
->client
.c
, FALSE
);
687 void action_toggle_shade(union ActionData
*data
)
690 client_shade(data
->client
.c
, !data
->client
.c
->shaded
);
693 void action_toggle_omnipresent(union ActionData
*data
)
696 client_set_desktop(data
->client
.c
,
697 data
->client
.c
->desktop
== DESKTOP_ALL
?
698 screen_desktop
: DESKTOP_ALL
, FALSE
);
701 void action_move_relative_horz(union ActionData
*data
)
703 ObClient
*c
= data
->relative
.c
;
705 client_configure(c
, OB_CORNER_TOPLEFT
,
706 c
->area
.x
+ data
->relative
.delta
, c
->area
.y
,
707 c
->area
.width
, c
->area
.height
, TRUE
, TRUE
);
710 void action_move_relative_vert(union ActionData
*data
)
712 ObClient
*c
= data
->relative
.c
;
714 client_configure(c
, OB_CORNER_TOPLEFT
,
715 c
->area
.x
, c
->area
.y
+ data
->relative
.delta
,
716 c
->area
.width
, c
->area
.height
, TRUE
, TRUE
);
719 void action_resize_relative_horz(union ActionData
*data
)
721 ObClient
*c
= data
->relative
.c
;
723 client_configure(c
, OB_CORNER_TOPLEFT
, c
->area
.x
, c
->area
.y
,
725 data
->relative
.delta
* c
->size_inc
.width
,
726 c
->area
.height
, TRUE
, TRUE
);
729 void action_resize_relative_vert(union ActionData
*data
)
731 ObClient
*c
= data
->relative
.c
;
733 client_configure(c
, OB_CORNER_TOPLEFT
, c
->area
.x
, c
->area
.y
,
734 c
->area
.width
, c
->area
.height
+
735 data
->relative
.delta
* c
->size_inc
.height
,
739 void action_maximize_full(union ActionData
*data
)
742 client_maximize(data
->client
.c
, TRUE
, 0, TRUE
);
745 void action_unmaximize_full(union ActionData
*data
)
748 client_maximize(data
->client
.c
, FALSE
, 0, TRUE
);
751 void action_toggle_maximize_full(union ActionData
*data
)
754 client_maximize(data
->client
.c
,
755 !(data
->client
.c
->max_horz
||
756 data
->client
.c
->max_vert
),
760 void action_maximize_horz(union ActionData
*data
)
763 client_maximize(data
->client
.c
, TRUE
, 1, TRUE
);
766 void action_unmaximize_horz(union ActionData
*data
)
769 client_maximize(data
->client
.c
, FALSE
, 1, TRUE
);
772 void action_toggle_maximize_horz(union ActionData
*data
)
775 client_maximize(data
->client
.c
, !data
->client
.c
->max_horz
, 1, TRUE
);
778 void action_maximize_vert(union ActionData
*data
)
781 client_maximize(data
->client
.c
, TRUE
, 2, TRUE
);
784 void action_unmaximize_vert(union ActionData
*data
)
787 client_maximize(data
->client
.c
, FALSE
, 2, TRUE
);
790 void action_toggle_maximize_vert(union ActionData
*data
)
793 client_maximize(data
->client
.c
, !data
->client
.c
->max_vert
, 2, TRUE
);
796 void action_send_to_desktop(union ActionData
*data
)
798 ObClient
*c
= data
->sendto
.c
;
800 if (!c
|| !client_normal(c
)) return;
802 if (data
->sendto
.desk
< screen_num_desktops
||
803 data
->sendto
.desk
== DESKTOP_ALL
) {
804 client_set_desktop(c
, data
->sendto
.desk
, data
->sendto
.follow
);
805 if (data
->sendto
.follow
) screen_set_desktop(data
->sendto
.desk
);
809 void action_desktop(union ActionData
*data
)
811 if (data
->desktop
.desk
< screen_num_desktops
||
812 data
->desktop
.desk
== DESKTOP_ALL
)
813 screen_set_desktop(data
->desktop
.desk
);
816 static void cur_row_col(guint
*r
, guint
*c
)
818 switch (screen_desktop_layout
.orientation
) {
819 case OB_ORIENTATION_HORZ
:
820 switch (screen_desktop_layout
.start_corner
) {
821 case OB_CORNER_TOPLEFT
:
822 *r
= screen_desktop
/ screen_desktop_layout
.columns
;
823 *c
= screen_desktop
% screen_desktop_layout
.columns
;
825 case OB_CORNER_BOTTOMLEFT
:
826 *r
= screen_desktop_layout
.rows
- 1 -
827 screen_desktop
/ screen_desktop_layout
.columns
;
828 *c
= screen_desktop
% screen_desktop_layout
.columns
;
830 case OB_CORNER_TOPRIGHT
:
831 *r
= screen_desktop
/ screen_desktop_layout
.columns
;
832 *c
= screen_desktop_layout
.columns
- 1 -
833 screen_desktop
% screen_desktop_layout
.columns
;
835 case OB_CORNER_BOTTOMRIGHT
:
836 *r
= screen_desktop_layout
.rows
- 1 -
837 screen_desktop
/ screen_desktop_layout
.columns
;
838 *c
= screen_desktop_layout
.columns
- 1 -
839 screen_desktop
% screen_desktop_layout
.columns
;
843 case OB_ORIENTATION_VERT
:
844 switch (screen_desktop_layout
.start_corner
) {
845 case OB_CORNER_TOPLEFT
:
846 *r
= screen_desktop
% screen_desktop_layout
.rows
;
847 *c
= screen_desktop
/ screen_desktop_layout
.rows
;
849 case OB_CORNER_BOTTOMLEFT
:
850 *r
= screen_desktop_layout
.rows
- 1 -
851 screen_desktop
% screen_desktop_layout
.rows
;
852 *c
= screen_desktop
/ screen_desktop_layout
.rows
;
854 case OB_CORNER_TOPRIGHT
:
855 *r
= screen_desktop
% screen_desktop_layout
.rows
;
856 *c
= screen_desktop_layout
.columns
- 1 -
857 screen_desktop
/ screen_desktop_layout
.rows
;
859 case OB_CORNER_BOTTOMRIGHT
:
860 *r
= screen_desktop_layout
.rows
- 1 -
861 screen_desktop
% screen_desktop_layout
.rows
;
862 *c
= screen_desktop_layout
.columns
- 1 -
863 screen_desktop
/ screen_desktop_layout
.rows
;
870 static guint
translate_row_col(guint r
, guint c
)
872 switch (screen_desktop_layout
.orientation
) {
873 case OB_ORIENTATION_HORZ
:
874 switch (screen_desktop_layout
.start_corner
) {
875 case OB_CORNER_TOPLEFT
:
876 return r
% screen_desktop_layout
.rows
*
877 screen_desktop_layout
.columns
+
878 c
% screen_desktop_layout
.columns
;
879 case OB_CORNER_BOTTOMLEFT
:
880 return (screen_desktop_layout
.rows
- 1 -
881 r
% screen_desktop_layout
.rows
) *
882 screen_desktop_layout
.columns
+
883 c
% screen_desktop_layout
.columns
;
884 case OB_CORNER_TOPRIGHT
:
885 return r
% screen_desktop_layout
.rows
*
886 screen_desktop_layout
.columns
+
887 (screen_desktop_layout
.columns
- 1 -
888 c
% screen_desktop_layout
.columns
);
889 case OB_CORNER_BOTTOMRIGHT
:
890 return (screen_desktop_layout
.rows
- 1 -
891 r
% screen_desktop_layout
.rows
) *
892 screen_desktop_layout
.columns
+
893 (screen_desktop_layout
.columns
- 1 -
894 c
% screen_desktop_layout
.columns
);
896 case OB_ORIENTATION_VERT
:
897 switch (screen_desktop_layout
.start_corner
) {
898 case OB_CORNER_TOPLEFT
:
899 return c
% screen_desktop_layout
.columns
*
900 screen_desktop_layout
.rows
+
901 r
% screen_desktop_layout
.rows
;
902 case OB_CORNER_BOTTOMLEFT
:
903 return c
% screen_desktop_layout
.columns
*
904 screen_desktop_layout
.rows
+
905 (screen_desktop_layout
.rows
- 1 -
906 r
% screen_desktop_layout
.rows
);
907 case OB_CORNER_TOPRIGHT
:
908 return (screen_desktop_layout
.columns
- 1 -
909 c
% screen_desktop_layout
.columns
) *
910 screen_desktop_layout
.rows
+
911 r
% screen_desktop_layout
.rows
;
912 case OB_CORNER_BOTTOMRIGHT
:
913 return (screen_desktop_layout
.columns
- 1 -
914 c
% screen_desktop_layout
.columns
) *
915 screen_desktop_layout
.rows
+
916 (screen_desktop_layout
.rows
- 1 -
917 r
% screen_desktop_layout
.rows
);
920 g_assert_not_reached();
924 void action_desktop_right(union ActionData
*data
)
930 if (c
>= screen_desktop_layout
.columns
) {
931 if (!data
->desktopdir
.wrap
) return;
934 d
= translate_row_col(r
, c
);
935 if (d
>= screen_num_desktops
) {
936 if (!data
->desktopdir
.wrap
) return;
939 d
= translate_row_col(r
, c
);
940 if (d
< screen_num_desktops
)
941 screen_set_desktop(d
);
944 void action_send_to_desktop_right(union ActionData
*data
)
946 ObClient
*cl
= data
->sendto
.c
;
949 if (!cl
|| !client_normal(cl
)) return;
953 if (c
>= screen_desktop_layout
.columns
) {
954 if (!data
->sendtodir
.wrap
) return;
957 d
= translate_row_col(r
, c
);
958 if (d
>= screen_num_desktops
) {
959 if (!data
->sendtodir
.wrap
) return;
962 d
= translate_row_col(r
, c
);
963 if (d
< screen_num_desktops
) {
964 client_set_desktop(cl
, d
, data
->sendtodir
.follow
);
965 if (data
->sendtodir
.follow
) screen_set_desktop(d
);
969 void action_desktop_left(union ActionData
*data
)
975 if (c
>= screen_desktop_layout
.columns
) {
976 if (!data
->desktopdir
.wrap
) return;
977 c
= screen_desktop_layout
.columns
- 1;
979 d
= translate_row_col(r
, c
);
980 if (d
>= screen_num_desktops
) {
981 if (!data
->desktopdir
.wrap
) return;
984 d
= translate_row_col(r
, c
);
985 if (d
< screen_num_desktops
)
986 screen_set_desktop(d
);
989 void action_send_to_desktop_left(union ActionData
*data
)
991 ObClient
*cl
= data
->sendto
.c
;
994 if (!cl
|| !client_normal(cl
)) return;
998 if (c
>= screen_desktop_layout
.columns
) {
999 if (!data
->sendtodir
.wrap
) return;
1000 c
= screen_desktop_layout
.columns
- 1;
1002 d
= translate_row_col(r
, c
);
1003 if (d
>= screen_num_desktops
) {
1004 if (!data
->sendtodir
.wrap
) return;
1007 d
= translate_row_col(r
, c
);
1008 if (d
< screen_num_desktops
) {
1009 client_set_desktop(cl
, d
, data
->sendtodir
.follow
);
1010 if (data
->sendtodir
.follow
) screen_set_desktop(d
);
1014 void action_desktop_down(union ActionData
*data
)
1018 cur_row_col(&r
, &c
);
1020 if (r
>= screen_desktop_layout
.rows
) {
1021 if (!data
->desktopdir
.wrap
) return;
1024 d
= translate_row_col(r
, c
);
1025 if (d
>= screen_num_desktops
) {
1026 if (!data
->desktopdir
.wrap
) return;
1029 d
= translate_row_col(r
, c
);
1030 if (d
< screen_num_desktops
)
1031 screen_set_desktop(d
);
1034 void action_send_to_desktop_down(union ActionData
*data
)
1038 if (data
->sendtodir
.c
) {
1039 cur_row_col(&r
, &c
);
1041 if (r
>= screen_desktop_layout
.rows
) {
1042 if (!data
->sendtodir
.wrap
) return;
1045 d
= translate_row_col(r
, c
);
1046 if (d
>= screen_num_desktops
) {
1047 if (!data
->sendtodir
.wrap
) return;
1050 d
= translate_row_col(r
, c
);
1051 if (d
< screen_num_desktops
) {
1052 client_set_desktop(data
->sendtodir
.c
, d
, data
->sendtodir
.follow
);
1053 if (data
->sendtodir
.follow
) screen_set_desktop(d
);
1058 void action_desktop_up(union ActionData
*data
)
1062 cur_row_col(&r
, &c
);
1064 if (r
>= screen_desktop_layout
.rows
) {
1065 if (!data
->desktopdir
.wrap
) return;
1066 r
= screen_desktop_layout
.rows
- 1;
1068 d
= translate_row_col(r
, c
);
1069 if (d
>= screen_num_desktops
) {
1070 if (!data
->desktopdir
.wrap
) return;
1073 d
= translate_row_col(r
, c
);
1074 if (d
< screen_num_desktops
)
1075 screen_set_desktop(d
);
1078 void action_send_to_desktop_up(union ActionData
*data
)
1082 if (data
->sendtodir
.c
) {
1083 cur_row_col(&r
, &c
);
1085 if (r
>= screen_desktop_layout
.rows
) {
1086 if (!data
->sendtodir
.wrap
) return;
1087 r
= screen_desktop_layout
.rows
- 1;
1089 d
= translate_row_col(r
, c
);
1090 if (d
>= screen_num_desktops
) {
1091 if (!data
->sendtodir
.wrap
) return;
1094 d
= translate_row_col(r
, c
);
1095 if (d
< screen_num_desktops
) {
1096 client_set_desktop(data
->sendtodir
.c
, d
, data
->sendtodir
.follow
);
1097 if (data
->sendtodir
.follow
) screen_set_desktop(d
);
1102 void action_toggle_decorations(union ActionData
*data
)
1104 ObClient
*c
= data
->client
.c
;;
1108 c
->disabled_decorations
= c
->disabled_decorations
? 0 : ~0;
1109 client_setup_decor_and_functions(c
);
1112 void action_moveresize(union ActionData
*data
)
1114 ObClient
*c
= data
->moveresize
.c
;
1116 if (!c
|| !client_normal(c
)) return;
1118 moveresize_start(c
, data
->moveresize
.x
, data
->moveresize
.y
,
1119 data
->moveresize
.button
, data
->moveresize
.corner
);
1122 void action_restart(union ActionData
*data
)
1124 ob_restart_other(data
->execute
.path
);
1127 void action_exit(union ActionData
*data
)
1132 void action_showmenu(union ActionData
*data
)
1134 if (data
->showmenu
.name
) {
1135 menu_show(data
->showmenu
.name
, data
->showmenu
.x
, data
->showmenu
.y
,
1140 void action_cycle_windows(union ActionData
*data
)
1144 c
= focus_cycle(data
->cycle
.forward
, data
->cycle
.linear
, data
->cycle
.final
,
1145 data
->cycle
.cancel
);
1148 void action_directional_focus(union ActionData
*data
)
1152 if (!data
->diraction
.c
)
1154 if ((nf
= client_find_directional(data
->diraction
.c
,
1155 data
->diraction
.direction
)))
1156 client_activate(nf
);
1159 void action_movetoedge(union ActionData
*data
)
1162 ObClient
*c
= data
->diraction
.c
;
1166 x
= c
->frame
->area
.x
;
1167 y
= c
->frame
->area
.y
;
1169 h
= screen_area(c
->desktop
)->height
;
1170 w
= screen_area(c
->desktop
)->width
;
1171 switch(data
->diraction
.direction
) {
1172 case OB_DIRECTION_NORTH
:
1175 case OB_DIRECTION_WEST
:
1178 case OB_DIRECTION_SOUTH
:
1179 y
= h
- c
->frame
->area
.height
;
1181 case OB_DIRECTION_EAST
:
1182 x
= w
- c
->frame
->area
.width
;
1185 g_assert_not_reached();
1187 frame_frame_gravity(c
->frame
, &x
, &y
);
1188 client_configure(c
, OB_CORNER_TOPLEFT
,
1189 x
, y
, c
->area
.width
, c
->area
.height
, TRUE
, TRUE
);
1193 void action_send_to_layer(union ActionData
*data
)
1196 client_set_layer(data
->layer
.c
, data
->layer
.layer
);
1199 void action_toggle_layer(union ActionData
*data
)
1201 ObClient
*c
= data
->layer
.c
;
1204 if (data
->layer
.layer
< 0)
1205 client_set_layer(c
, c
->below
? 0 : -1);
1206 else if (data
->layer
.layer
> 0)
1207 client_set_layer(c
, c
->above
? 0 : 1);
1211 void action_toggle_show_desktop(union ActionData
*data
)
1213 screen_show_desktop(!screen_showing_desktop
);
1216 void action_show_desktop(union ActionData
*data
)
1218 screen_show_desktop(TRUE
);
1221 void action_unshow_desktop(union ActionData
*data
)
1223 screen_show_desktop(FALSE
);