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
);
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
);