]> icculus.org git repositories - dana/openbox.git/blob - openbox/action.h
make interactive actions a type and not special cases.
[dana/openbox.git] / openbox / action.h
1 #ifndef __action_h
2 #define __action_h
3
4 #include "misc.h"
5 #include "parser/parse.h"
6
7 typedef struct _ObAction ObAction;
8
9 /* These have to all have a Client* at the top even if they don't use it, so
10    that I can set it blindly later on. So every function will have a Client*
11    available (possibly NULL though) if it wants it.
12 */
13
14 struct AnyAction {
15     struct _ObClient *c;
16     gboolean interactive;
17 };
18
19 struct InteractiveAction {
20     struct AnyAction any;
21     gboolean final;
22     gboolean cancel;
23 };
24
25 struct DirectionalAction{
26     struct AnyAction any;
27     ObDirection direction;
28 };
29
30 struct Execute {
31     struct AnyAction any;
32     char *path;
33 };
34
35 struct ClientAction {
36     struct AnyAction any;
37 };
38
39 struct Activate {
40     struct AnyAction any;
41     gboolean here; /* bring it to the current desktop */
42 };
43
44 struct MoveResizeRelative {
45     struct AnyAction any;
46     int delta;
47 };
48
49 struct SendToDesktop {
50     struct AnyAction any;
51     guint desk;
52     gboolean follow;
53 };
54
55 struct SendToDesktopDirection {
56     struct InteractiveAction inter;
57     ObDirection dir;
58     gboolean wrap;
59     gboolean linear;
60     gboolean follow;
61 };
62
63 struct Desktop {
64     struct AnyAction any;
65     guint desk;
66 };
67
68 struct Layer {
69     struct AnyAction any;
70     int layer; /* < 0 = below, 0 = normal, > 0 = above */
71 };
72
73 struct DesktopDirection {
74     struct InteractiveAction inter;
75     ObDirection dir;
76     gboolean wrap;
77     gboolean linear;
78 };
79
80 struct MoveResize {
81     struct AnyAction any;
82     int x;
83     int y;
84     guint32 corner; /* prop_atoms.net_wm_moveresize_* */
85     guint button;
86 };
87
88 struct ShowMenu {
89     struct AnyAction any;
90     char *name;
91     int x;
92     int y;
93 };
94
95 struct CycleWindows {
96     struct InteractiveAction inter;
97     gboolean linear;
98     gboolean forward;
99 };
100
101 union ActionData {
102     struct AnyAction any;
103     struct InteractiveAction inter;
104     struct DirectionalAction diraction;
105     struct Execute execute;
106     struct ClientAction client;
107     struct Activate activate;
108     struct MoveResizeRelative relative;
109     struct SendToDesktop sendto;
110     struct SendToDesktopDirection sendtodir;
111     struct Desktop desktop;
112     struct DesktopDirection desktopdir;
113     struct MoveResize moveresize;
114     struct ShowMenu showmenu;
115     struct CycleWindows cycle;
116     struct Layer layer;
117 };
118
119 struct _ObAction {
120     /* The func member acts like an enum to tell which one of the structs in
121        the data union are valid.
122     */
123     void (*func)(union ActionData *data);
124     union ActionData data;
125 };
126
127 ObAction *action_new(void (*func)(union ActionData *data));
128
129 /* Creates a new Action from the name of the action
130    A few action types need data set after making this call still. Check if
131    the returned action's "func" is one of these.
132    action_execute - the path needs to be set
133    action_restart - the path can optionally be set
134    action_desktop - the destination desktop needs to be set
135    action_move_relative_horz - the delta
136    action_move_relative_vert - the delta
137    action_resize_relative_horz - the delta
138    action_resize_relative_vert - the delta
139 */
140
141 ObAction *action_from_string(char *name);
142 ObAction *action_parse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
143 void action_free(ObAction *a);
144
145 /* Execute */
146 void action_execute(union ActionData *data);
147 /* ActivateAction */
148 void action_activate(union ActionData *data);
149 /* ClientAction */
150 void action_focus(union ActionData *data);
151 /* ClientAction */
152 void action_unfocus(union ActionData *data);
153 /* ClientAction */
154 void action_iconify(union ActionData *data);
155 /* ClientAction */
156 void action_raiselower(union ActionData *data);
157 /* ClientAction */
158 void action_raise(union ActionData *data);
159 /* ClientAction */
160 void action_lower(union ActionData *data);
161 /* ClientAction */
162 void action_close(union ActionData *data);
163 /* ClientAction */
164 void action_kill(union ActionData *data);
165 /* ClientAction */
166 void action_shade(union ActionData *data);
167 /* ClientAction */
168 void action_shadelower(union ActionData *data);
169 /* ClientAction */
170 void action_unshaderaise(union ActionData *data);
171 /* ClientAction */
172 void action_unshade(union ActionData *data);
173 /* ClientAction */
174 void action_toggle_shade(union ActionData *data);
175 /* ClientAction */
176 void action_toggle_omnipresent(union ActionData *data);
177 /* MoveResizeRelative */
178 void action_move_relative_horz(union ActionData *data);
179 /* MoveResizeRelative */
180 void action_move_relative_vert(union ActionData *data);
181 /* MoveResizeRelative */
182 void action_resize_relative_horz(union ActionData *data);
183 /* MoveResizeRelative */
184 void action_resize_relative_vert(union ActionData *data);
185 /* ClientAction */
186 void action_maximize_full(union ActionData *data);
187 /* ClientAction */
188 void action_unmaximize_full(union ActionData *data);
189 /* ClientAction */
190 void action_toggle_maximize_full(union ActionData *data);
191 /* ClientAction */
192 void action_maximize_horz(union ActionData *data);
193 /* ClientAction */
194 void action_unmaximize_horz(union ActionData *data);
195 /* ClientAction */
196 void action_toggle_maximize_horz(union ActionData *data);
197 /* ClientAction */
198 void action_maximize_vert(union ActionData *data);
199 /* ClientAction */
200 void action_unmaximize_vert(union ActionData *data);
201 /* ClientAction */
202 void action_toggle_maximize_vert(union ActionData *data);
203 /* SendToDesktop */
204 void action_send_to_desktop(union ActionData *data);
205 /* SendToDesktopDirection */
206 void action_send_to_desktop_dir(union ActionData *data);
207 /* Desktop */
208 void action_desktop(union ActionData *data);
209 /* DesktopDirection */
210 void action_desktop_dir(union ActionData *data);
211 /* ClientAction */
212 void action_toggle_decorations(union ActionData *data);
213 /* MoveResize */
214 void action_moveresize(union ActionData *data);
215 /* Execute */
216 void action_restart(union ActionData *data);
217 /* Any */
218 void action_exit(union ActionData *data);
219 /* ShowMenu */
220 void action_showmenu(union ActionData *data);
221 /* CycleWindows */
222 void action_cycle_windows(union ActionData *data);
223 /* DirectionalAction */
224 void action_directional_focus(union ActionData *data);
225 /* DirectionalAction */
226 void action_movetoedge(union ActionData *data);
227 /* DirectionalAction */
228 void action_growtoedge(union ActionData *data);
229 /* Layer */
230 void action_send_to_layer(union ActionData *data);
231 /* Layer */
232 void action_toggle_layer(union ActionData *data);
233 /* Any */
234 void action_toggle_show_desktop(union ActionData *data);
235 /* Any */
236 void action_show_desktop(union ActionData *data);
237 /* Any */
238 void action_unshow_desktop(union ActionData *data);
239
240 #endif