invaders: clean code
[awesome.git] / structs.h
bloba50cff3179d5b41b044c80b774639f3d7e6fb5f7
1 /*
2 * structs.h - basic structs header
4 * Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef AWESOME_STRUCTS_H
23 #define AWESOME_STRUCTS_H
25 #include <xcb/xcb_event.h>
26 #include <xcb/xcb_icccm.h>
27 #include <xcb/xcb_property.h>
28 #include <ev.h>
30 #include "luaa.h"
31 #include "layout.h"
32 #include "swindow.h"
33 #include "image.h"
34 #include "common/xutil.h"
35 #include "common/xembed.h"
36 #include "common/refcount.h"
38 /** Windows type */
39 typedef enum
41 WINDOW_TYPE_NORMAL = 0,
42 WINDOW_TYPE_DESKTOP,
43 WINDOW_TYPE_DOCK,
44 WINDOW_TYPE_SPLASH,
45 WINDOW_TYPE_DIALOG,
46 } window_type_t;
48 /** Wibox types */
49 typedef enum
51 WIBOX_TYPE_NORMAL = 0,
52 WIBOX_TYPE_TITLEBAR
53 } wibox_type_t;
55 /** Cursors */
56 enum
58 CurNormal, CurResize, CurResizeH, CurResizeV, CurMove,
59 CurTopLeft, CurTopRight, CurBotLeft, CurBotRight, CurLast
62 typedef struct button_t button_t;
63 typedef struct widget_t widget_t;
64 typedef struct widget_node_t widget_node_t;
65 typedef struct client_t client_t;
66 typedef struct client_node_t client_node_t;
67 typedef struct tag tag_t;
68 typedef struct tag_client_node_t tag_client_node_t;
69 typedef widget_t *(widget_constructor_t)(alignment_t);
70 typedef void (widget_destructor_t)(widget_t *);
71 typedef struct awesome_t awesome_t;
73 ARRAY_TYPE(widget_node_t, widget_node)
75 /** Wibox type */
76 typedef struct
78 /** Ref count */
79 int refcount;
80 /** Ontop */
81 bool ontop;
82 /** Visible */
83 bool isvisible;
84 /** Position */
85 position_t position;
86 /** Wibox type */
87 wibox_type_t type;
88 /** Window */
89 simple_window_t sw;
90 /** Alignment */
91 alignment_t align;
92 /** Screen */
93 int screen;
94 /** Widget list */
95 widget_node_array_t widgets;
96 luaA_ref widgets_table;
97 /** Widget the mouse is over */
98 widget_t *mouse_over;
99 /** Need update */
100 bool need_update;
101 } wibox_t;
102 ARRAY_TYPE(wibox_t *, wibox)
104 /** Mouse buttons bindings */
105 struct button_t
107 /** Ref count */
108 int refcount;
109 /** Key modifiers */
110 unsigned long mod;
111 /** Mouse button number */
112 unsigned int button;
113 /** Lua function to execute on press. */
114 luaA_ref press;
115 /** Lua function to execute on release. */
116 luaA_ref release;
118 DO_RCNT(button_t, button, p_delete)
119 DO_ARRAY(button_t *, button, button_unref)
121 /** Widget */
122 struct widget_t
124 /** Ref count */
125 int refcount;
126 /** widget_t name */
127 char *name;
128 /** Widget type is constructor */
129 widget_constructor_t *type;
130 /** Widget destructor */
131 widget_destructor_t *destructor;
132 /** Draw function */
133 int (*draw)(draw_context_t *, int, widget_node_t *, int, int, wibox_t *);
134 /** Index function */
135 int (*index)(lua_State *, awesome_token_t);
136 /** Newindex function */
137 int (*newindex)(lua_State *, awesome_token_t);
138 /** Button event handler */
139 void (*button)(widget_node_t *, xcb_button_press_event_t *, int, wibox_t *);
140 /** Mouse over event handler */
141 luaA_ref mouse_enter, mouse_leave;
142 /** Alignement */
143 alignment_t align;
144 /** Misc private data */
145 void *data;
146 /** Button bindings */
147 button_array_t buttons;
148 /** Cache flags */
149 int cache_flags;
150 /** True if the widget is visible */
151 bool isvisible;
154 /* Strut */
155 typedef struct
157 uint16_t left, right, top, bottom;
158 uint16_t left_start_y, left_end_y;
159 uint16_t right_start_y, right_end_y;
160 uint16_t top_start_x, top_end_x;
161 uint16_t bottom_start_x, bottom_end_x;
162 } strut_t;
164 /** client_t type */
165 struct client_t
167 /** Ref counter */
168 int refcount;
169 /** Valid, or not ? */
170 bool invalid;
171 /** Client name */
172 char *name, *icon_name;
173 /** Window geometry */
174 area_t geometry;
175 /** Floating window geometry */
176 area_t f_geometry;
177 /** Max window geometry */
178 area_t m_geometry;
179 /* Size hints */
180 int basew, baseh, incw, inch, maxw, maxh, minw, minh;
181 int minax, maxax, minay, maxay;
182 bool hassizehints;
183 /** Strut */
184 strut_t strut;
185 /** Respect resize hints */
186 bool honorsizehints;
187 int border, oldborder;
188 xcolor_t border_color;
189 /** True if the client is sticky */
190 bool issticky;
191 /** Has urgency hint */
192 bool isurgent;
193 /** true if the window is floating */
194 bool isfloating;
195 /** true if the client is moving */
196 bool ismoving;
197 /** True if the client is hidden */
198 bool ishidden;
199 /** True if the client is minimized */
200 bool isminimized;
201 /** True if the client is fullscreen */
202 bool isfullscreen;
203 /** True if the client is above others */
204 bool isabove;
205 /** True if the client is below others */
206 bool isbelow;
207 /** True if the client is modal */
208 bool ismodal;
209 /** True if the client is on top */
210 bool isontop;
211 /** true if the client must be skipped from task bar client list */
212 bool skiptb;
213 /** True if the client cannot have focus */
214 bool nofocus;
215 /** The window type */
216 window_type_t type;
217 /** Window of the client */
218 xcb_window_t win;
219 /** Client logical screen */
220 int screen;
221 /** Client physical screen */
222 int phys_screen;
223 /** Path to an icon */
224 char *icon_path;
225 /** Titlebar */
226 wibox_t *titlebar;
227 /** Button bindings */
228 button_array_t buttons;
229 /** Icon */
230 image_t *icon;
231 /** Size hints */
232 xcb_size_hints_t size_hints;
233 /** Window it is transient for */
234 client_t *transient_for;
235 /** Next and previous clients */
236 client_t *prev, *next;
238 ARRAY_TYPE(client_t *, client)
240 struct client_node_t
242 /** The client */
243 client_t *client;
244 /** Next and previous client_nodes */
245 client_node_t *prev, *next;
248 /** Tag type */
249 struct tag
251 /** Ref count */
252 int refcount;
253 /** Tag name */
254 char *name;
255 /** Screen */
256 int screen;
257 /** true if selected */
258 bool selected;
259 /** Current tag layout */
260 layout_t *layout;
261 /** Master width factor */
262 double mwfact;
263 /** Number of master windows */
264 int nmaster;
265 /** Number of columns in tile layout */
266 int ncol;
267 /** clients in this tag */
268 client_array_t clients;
270 ARRAY_TYPE(tag_t *, tag)
272 /** Padding type */
273 typedef struct
275 /** Padding at top */
276 int top;
277 /** Padding at bottom */
278 int bottom;
279 /** Padding at left */
280 int left;
281 /** Padding at right */
282 int right;
283 } padding_t;
285 typedef struct
287 /** Screen index */
288 int index;
289 /** Screen geometry */
290 area_t geometry;
291 /** true if we need to arrange() */
292 bool need_arrange;
293 /** Tag list */
294 tag_array_t tags;
295 /** Wiboxes */
296 wibox_array_t wiboxes;
297 /** Padding */
298 padding_t padding;
299 /** Window that contains the systray */
300 struct
302 xcb_window_t window;
303 /** Systray window parent */
304 xcb_window_t parent;
305 } systray;
306 /** Focused client */
307 client_t *client_focus;
308 } screen_t;
310 /** Main configuration structure */
311 struct awesome_t
313 /** Connection ref */
314 xcb_connection_t *connection;
315 /** Event and error handlers */
316 xcb_event_handlers_t evenths;
317 /** Property change handler */
318 xcb_property_handlers_t prophs;
319 /** Default screen number */
320 int default_screen;
321 /** Keys symbol table */
322 xcb_key_symbols_t *keysyms;
323 /** Logical screens */
324 screen_t *screens;
325 /** Number of screens */
326 int nscreen;
327 /** True if xinerama is active */
328 bool xinerama_is_active;
329 /** Mouse bindings list */
330 button_array_t buttons;
331 /** Numlock mask */
332 unsigned int numlockmask;
333 /** Numlock mask */
334 unsigned int shiftlockmask;
335 /** Numlock mask */
336 unsigned int capslockmask;
337 /** Check for XRandR extension */
338 bool have_randr;
339 /** Cursors */
340 xcb_cursor_t cursor[CurLast];
341 /** Clients list */
342 client_t *clients;
343 /** Embedded windows */
344 xembed_window_t *embedded;
345 /** Path to config file */
346 char *conffile;
347 /** Stack client history */
348 client_node_t *stack;
349 /** Command line passed to awesome */
350 char *argv;
351 /** Last XMotionEvent coords */
352 int pointer_x, pointer_y;
353 /** Lua VM state */
354 lua_State *L;
355 /** Default colors */
356 struct
358 xcolor_t fg, bg;
359 } colors;
360 /** Default font */
361 font_t *font;
362 struct
364 /** Command to execute when spawning a new client */
365 luaA_ref manage;
366 /** Command to execute when unmanaging client */
367 luaA_ref unmanage;
368 /** Command to execute when giving focus to a client */
369 luaA_ref focus;
370 /** Command to execute when removing focus to a client */
371 luaA_ref unfocus;
372 /** Command to run when mouse enter a client */
373 luaA_ref mouse_enter;
374 /** Command to run on arrange */
375 luaA_ref arrange;
376 /** Command to run when client list changes */
377 luaA_ref clients;
378 /** Command to run on numbers of tag changes */
379 luaA_ref tags;
380 /** Command to run when client gets (un)tagged */
381 luaA_ref tagged;
382 /** Command to run on property change */
383 luaA_ref property;
384 /** Command to run on time */
385 luaA_ref timer;
386 } hooks;
387 /** The event loop */
388 struct ev_loop *loop;
389 /** The timeout after which we need to stop select() */
390 struct ev_timer timer;
391 /** The key grabber function */
392 luaA_ref keygrabber;
393 /** Focused screen */
394 screen_t *screen_focus;
397 #endif
398 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80