Increased Invaders difficulty
[awesome.git] / structs.h
blob5de9a4b4d38383866830423b17f852db2fafb7c7
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 /** Stacking layout layers */
39 typedef enum
41 LAYER_DESKTOP = 1,
42 LAYER_BELOW,
43 LAYER_TILE,
44 LAYER_FLOAT,
45 LAYER_ABOVE,
46 LAYER_FULLSCREEN,
47 LAYER_MODAL,
48 LAYER_ONTOP,
49 LAYER_OUTOFSPACE
50 } layer_t;
52 /** Windows type */
53 typedef enum
55 WINDOW_TYPE_NORMAL = 0,
56 WINDOW_TYPE_DESKTOP,
57 WINDOW_TYPE_DOCK,
58 WINDOW_TYPE_SPLASH,
59 WINDOW_TYPE_DIALOG,
60 } window_type_t;
62 /** Wibox types */
63 typedef enum
65 WIBOX_TYPE_NORMAL = 0,
66 WIBOX_TYPE_TITLEBAR
67 } wibox_type_t;
69 /** Cursors */
70 enum
72 CurNormal, CurResize, CurResizeH, CurResizeV, CurMove,
73 CurTopLeft, CurTopRight, CurBotLeft, CurBotRight, CurLast
76 typedef struct button_t button_t;
77 typedef struct widget_t widget_t;
78 typedef struct widget_node_t widget_node_t;
79 typedef struct client_t client_t;
80 typedef struct client_node_t client_node_t;
81 typedef struct _tag_t tag_t;
82 typedef struct tag_client_node_t tag_client_node_t;
83 typedef widget_t *(widget_constructor_t)(alignment_t);
84 typedef void (widget_destructor_t)(widget_t *);
85 typedef struct awesome_t awesome_t;
87 /** Wibox type */
88 typedef struct
90 /** Ref count */
91 int refcount;
92 /** Ontop */
93 bool ontop;
94 /** Visible */
95 bool isvisible;
96 /** Position */
97 position_t position;
98 /** Wibox type */
99 wibox_type_t type;
100 /** Window */
101 simple_window_t sw;
102 /** Alignment */
103 alignment_t align;
104 /** Screen */
105 int screen;
106 /** Widget list */
107 widget_node_t *widgets;
108 /** Widget the mouse is over */
109 widget_node_t *mouse_over;
110 /** Need update */
111 bool need_update;
112 } wibox_t;
113 ARRAY_TYPE(wibox_t *, wibox)
115 /** Mouse buttons bindings */
116 struct button_t
118 /** Ref count */
119 int refcount;
120 /** Key modifiers */
121 unsigned long mod;
122 /** Mouse button number */
123 unsigned int button;
124 /** Lua function to execute on press. */
125 luaA_ref press;
126 /** Lua function to execute on release. */
127 luaA_ref release;
130 DO_RCNT(button_t, button, p_delete)
131 DO_ARRAY(button_t *, button, button_unref)
133 /** Widget */
134 struct widget_t
136 /** Ref count */
137 int refcount;
138 /** widget_t name */
139 char *name;
140 /** Widget type is constructor */
141 widget_constructor_t *type;
142 /** Widget destructor */
143 widget_destructor_t *destructor;
144 /** Widget detach function */
145 void (*detach)(widget_t *, wibox_t *);
146 /** Draw function */
147 int (*draw)(draw_context_t *, int, widget_node_t *, int, int, wibox_t *);
148 /** Index function */
149 int (*index)(lua_State *, awesome_token_t);
150 /** Newindex function */
151 int (*newindex)(lua_State *, awesome_token_t);
152 /** Button event handler */
153 void (*button)(widget_node_t *, xcb_button_press_event_t *, int, wibox_t *);
154 /** Mouse over event handler */
155 luaA_ref mouse_enter, mouse_leave;
156 /** Alignement */
157 alignment_t align;
158 /** Misc private data */
159 void *data;
160 /** Button bindings */
161 button_array_t buttons;
162 /** Cache flags */
163 int cache_flags;
164 /** True if the widget is visible */
165 bool isvisible;
168 /** Delete a widget structure.
169 * \param widget The widget to destroy.
171 static inline void
172 widget_delete(widget_t **widget)
174 if((*widget)->destructor)
175 (*widget)->destructor(*widget);
176 button_array_wipe(&(*widget)->buttons);
177 p_delete(&(*widget)->name);
178 p_delete(widget);
181 DO_RCNT(widget_t, widget, widget_delete)
183 struct widget_node_t
185 /** The widget */
186 widget_t *widget;
187 /** The area where the widget was drawn */
188 area_t area;
189 /** Next and previous widget in the list */
190 widget_node_t *prev, *next;
193 /** Delete a widget node structure.
194 * \param node The node to destroy.
196 static inline void
197 widget_node_delete(widget_node_t **node)
199 widget_unref(&(*node)->widget);
200 p_delete(node);
203 DO_SLIST(widget_node_t, widget_node, widget_node_delete)
205 /* Strut */
206 typedef struct
208 uint16_t left, right, top, bottom;
209 uint16_t left_start_y, left_end_y;
210 uint16_t right_start_y, right_end_y;
211 uint16_t top_start_x, top_end_x;
212 uint16_t bottom_start_x, bottom_end_x;
213 } strut_t;
215 /** client_t type */
216 struct client_t
218 /** Ref counter */
219 int refcount;
220 /** Valid, or not ? */
221 bool invalid;
222 /** Client name */
223 char *name;
224 /** Window geometry */
225 area_t geometry;
226 /** Floating window geometry */
227 area_t f_geometry;
228 /** Max window geometry */
229 area_t m_geometry;
230 /* Size hints */
231 int basew, baseh, incw, inch, maxw, maxh, minw, minh;
232 int minax, maxax, minay, maxay;
233 bool hassizehints;
234 /** Strut */
235 strut_t strut;
236 /** Respect resize hints */
237 bool honorsizehints;
238 int border, oldborder;
239 xcolor_t border_color;
240 /** True if the client is sticky */
241 bool issticky;
242 /** Has urgency hint */
243 bool isurgent;
244 /** true if the window is floating */
245 bool isfloating;
246 /** true if the client is moving */
247 bool ismoving;
248 /** True if the client is hidden */
249 bool ishidden;
250 /** True if the client is minimized */
251 bool isminimized;
252 /** True if the client is fullscreen */
253 bool isfullscreen;
254 /** True if the client is above others */
255 bool isabove;
256 /** True if the client is below others */
257 bool isbelow;
258 /** True if the client is modal */
259 bool ismodal;
260 /** True if the client is on top */
261 bool isontop;
262 /** true if the client must be skipped from task bar client list */
263 bool skiptb;
264 /** True if the client cannot have focus */
265 bool nofocus;
266 /** The window type */
267 window_type_t type;
268 /** Window of the client */
269 xcb_window_t win;
270 /** Client logical screen */
271 int screen;
272 /** Client physical screen */
273 int phys_screen;
274 /** Path to an icon */
275 char *icon_path;
276 /** Titlebar */
277 wibox_t *titlebar;
278 /** Button bindings */
279 button_array_t buttons;
280 /** Icon */
281 image_t *icon;
282 /** Size hints */
283 xcb_size_hints_t size_hints;
284 /** Window it is transient for */
285 client_t *transient_for;
286 /** Next and previous clients */
287 client_t *prev, *next;
290 static void
291 client_delete(client_t **c)
293 button_array_wipe(&(*c)->buttons);
294 p_delete(&(*c)->icon_path);
295 p_delete(&(*c)->name);
296 p_delete(c);
299 DO_ARRAY(client_t *, client, DO_NOTHING)
300 DO_RCNT(client_t, client, client_delete)
302 struct client_node_t
304 /** The client */
305 client_t *client;
306 /** Next and previous client_nodes */
307 client_node_t *prev, *next;
310 /** Tag type */
311 struct _tag_t
313 /** Ref count */
314 int refcount;
315 /** Tag name */
316 char *name;
317 /** Screen */
318 int screen;
319 /** true if selected */
320 bool selected;
321 /** Current tag layout */
322 layout_t *layout;
323 /** Master width factor */
324 double mwfact;
325 /** Number of master windows */
326 int nmaster;
327 /** Number of columns in tile layout */
328 int ncol;
329 /** clients in this tag */
330 client_array_t clients;
332 ARRAY_TYPE(tag_t *, tag)
334 /** Padding type */
335 typedef struct
337 /** Padding at top */
338 int top;
339 /** Padding at bottom */
340 int bottom;
341 /** Padding at left */
342 int left;
343 /** Padding at right */
344 int right;
345 } padding_t;
347 typedef struct
349 /** Screen index */
350 int index;
351 /** Screen geometry */
352 area_t geometry;
353 /** true if we need to arrange() */
354 bool need_arrange;
355 /** Tag list */
356 tag_array_t tags;
357 /** Wiboxes */
358 wibox_array_t wiboxes;
359 /** Padding */
360 padding_t padding;
361 /** Window that contains the systray */
362 struct
364 xcb_window_t window;
365 /** Systray window parent */
366 xcb_window_t parent;
367 } systray;
368 /** Focused client */
369 client_t *client_focus;
370 } screen_t;
372 /** Main configuration structure */
373 struct awesome_t
375 /** Connection ref */
376 xcb_connection_t *connection;
377 /** Event and error handlers */
378 xcb_event_handlers_t evenths;
379 /** Property change handler */
380 xcb_property_handlers_t prophs;
381 /** Default screen number */
382 int default_screen;
383 /** Keys symbol table */
384 xcb_key_symbols_t *keysyms;
385 /** Logical screens */
386 screen_t *screens;
387 /** Number of screens */
388 int nscreen;
389 /** True if xinerama is active */
390 bool xinerama_is_active;
391 /** Mouse bindings list */
392 button_array_t buttons;
393 /** Numlock mask */
394 unsigned int numlockmask;
395 /** Numlock mask */
396 unsigned int shiftlockmask;
397 /** Numlock mask */
398 unsigned int capslockmask;
399 /** Check for XRandR extension */
400 bool have_randr;
401 /** Cursors */
402 xcb_cursor_t cursor[CurLast];
403 /** Clients list */
404 client_t *clients;
405 /** Embedded windows */
406 xembed_window_t *embedded;
407 /** Path to config file */
408 char *conffile;
409 /** Stack client history */
410 client_node_t *stack;
411 /** Command line passed to awesome */
412 char *argv;
413 /** Last XMotionEvent coords */
414 int pointer_x, pointer_y;
415 /** Lua VM state */
416 lua_State *L;
417 /** Default colors */
418 struct
420 xcolor_t fg, bg;
421 } colors;
422 /** Default font */
423 font_t *font;
424 struct
426 /** Command to execute when spawning a new client */
427 luaA_ref manage;
428 /** Command to execute when unmanaging client */
429 luaA_ref unmanage;
430 /** Command to execute when giving focus to a client */
431 luaA_ref focus;
432 /** Command to execute when removing focus to a client */
433 luaA_ref unfocus;
434 /** Command to run when mouse enter a client */
435 luaA_ref mouse_enter;
436 /** Command to run on arrange */
437 luaA_ref arrange;
438 /** Command to run when client list changes */
439 luaA_ref clients;
440 /** Command to run on property change */
441 luaA_ref property;
442 /** Command to run on time */
443 luaA_ref timer;
444 } hooks;
445 /** The event loop */
446 struct ev_loop *loop;
447 /** The timeout after which we need to stop select() */
448 struct ev_timer timer;
449 /** The key grabber function */
450 luaA_ref keygrabber;
451 /** Focused screen */
452 screen_t *screen_focus;
455 #endif
456 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80