luaa: add support for meta __ipairs
[awesome.git] / structs.h
bloba7ea86357445b8784ad82551ffa6cd1e5c19ebb0
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_icccm.h>
26 #include <xcb/xcb_property.h>
28 #include "luaa.h"
29 #include "layout.h"
30 #include "swindow.h"
31 #include "keybinding.h"
32 #include "common/xutil.h"
33 #include "common/xembed.h"
34 #include "common/refcount.h"
36 /** Windows type */
37 typedef enum
39 WINDOW_TYPE_NORMAL = 0,
40 WINDOW_TYPE_DESKTOP,
41 WINDOW_TYPE_DOCK,
42 WINDOW_TYPE_SPLASH,
43 WINDOW_TYPE_DIALOG,
44 } window_type_t;
46 /** Wibox types */
47 typedef enum
49 WIBOX_TYPE_NORMAL = 0,
50 WIBOX_TYPE_TITLEBAR
51 } wibox_type_t;
53 /** Cursors */
54 enum
56 CurNormal, CurResize, CurResizeH, CurResizeV, CurMove,
57 CurTopLeft, CurTopRight, CurBotLeft, CurBotRight, CurLast
60 typedef struct button_t button_t;
61 typedef struct widget_t widget_t;
62 typedef struct widget_node_t widget_node_t;
63 typedef struct client_t client_t;
64 typedef struct client_node client_node_t;
65 typedef struct tag tag_t;
66 typedef struct tag_client_node_t tag_client_node_t;
67 typedef widget_t *(widget_constructor_t)(alignment_t);
68 typedef void (widget_destructor_t)(widget_t *);
69 typedef struct awesome_t awesome_t;
71 ARRAY_TYPE(widget_node_t, widget_node)
72 ARRAY_TYPE(button_t *, button)
74 /** Wibox type */
75 typedef struct
77 /** Ref count */
78 int refcount;
79 /** Ontop */
80 bool ontop;
81 /** Visible */
82 bool isvisible;
83 /** Position */
84 position_t position;
85 /** Wibox type */
86 wibox_type_t type;
87 /** Window */
88 simple_window_t sw;
89 /** Alignment */
90 alignment_t align;
91 /** Screen */
92 int screen;
93 /** Widget list */
94 widget_node_array_t widgets;
95 luaA_ref widgets_table;
96 /** Widget the mouse is over */
97 widget_t *mouse_over;
98 /** Need update */
99 bool need_update;
100 } wibox_t;
101 ARRAY_TYPE(wibox_t *, wibox)
103 /** Widget */
104 struct widget_t
106 /** Ref count */
107 int refcount;
108 /** widget_t name */
109 char *name;
110 /** Widget type is constructor */
111 widget_constructor_t *type;
112 /** Widget destructor */
113 widget_destructor_t *destructor;
114 /** Geometry function */
115 area_t (*geometry)(widget_t *, int, int, int);
116 /** Draw function */
117 void (*draw)(widget_t *, draw_context_t *, area_t, int, wibox_t *);
118 /** Index function */
119 int (*index)(lua_State *, awesome_token_t);
120 /** Newindex function */
121 int (*newindex)(lua_State *, awesome_token_t);
122 /** Button event handler */
123 void (*button)(widget_node_t *, xcb_button_press_event_t *, int, wibox_t *);
124 /** Mouse over event handler */
125 luaA_ref mouse_enter, mouse_leave;
126 /** Alignement */
127 alignment_t align;
128 /** Supported alignment */
129 alignment_t align_supported;
130 /** Misc private data */
131 void *data;
132 /** Button bindings */
133 button_array_t buttons;
134 /** Cache flags */
135 int cache_flags;
136 /** True if the widget is visible */
137 bool isvisible;
140 /* Strut */
141 typedef struct
143 uint16_t left, right, top, bottom;
144 uint16_t left_start_y, left_end_y;
145 uint16_t right_start_y, right_end_y;
146 uint16_t top_start_x, top_end_x;
147 uint16_t bottom_start_x, bottom_end_x;
148 } strut_t;
150 /** client_t type */
151 struct client_t
153 /** Ref counter */
154 int refcount;
155 /** Valid, or not ? */
156 bool invalid;
157 /** Client name */
158 char *name, *icon_name;
159 /** Window geometry */
160 area_t geometry;
161 /** Floating window geometry */
162 area_t f_geometry;
163 /** Max window geometry */
164 area_t m_geometry;
165 /* Size hints */
166 int basew, baseh, incw, inch, maxw, maxh, minw, minh;
167 int minax, maxax, minay, maxay;
168 bool hassizehints;
169 /** Strut */
170 strut_t strut;
171 /** Respect resize hints */
172 bool honorsizehints;
173 int border, oldborder;
174 xcolor_t border_color;
175 /** True if the client is sticky */
176 bool issticky;
177 /** Has urgency hint */
178 bool isurgent;
179 /** true if the window is floating */
180 bool isfloating;
181 /** true if the client is moving */
182 bool ismoving;
183 /** True if the client is hidden */
184 bool ishidden;
185 /** True if the client is minimized */
186 bool isminimized;
187 /** True if the client is fullscreen */
188 bool isfullscreen;
189 /** True if the client is above others */
190 bool isabove;
191 /** True if the client is below others */
192 bool isbelow;
193 /** True if the client is modal */
194 bool ismodal;
195 /** True if the client is on top */
196 bool isontop;
197 /** true if the client must be skipped from task bar client list */
198 bool skiptb;
199 /** True if the client cannot have focus */
200 bool nofocus;
201 /** The window type */
202 window_type_t type;
203 /** Window of the client */
204 xcb_window_t win;
205 /** Client logical screen */
206 int screen;
207 /** Client physical screen */
208 int phys_screen;
209 /** Path to an icon */
210 char *icon_path;
211 /** Titlebar */
212 wibox_t *titlebar;
213 /** Button bindings */
214 button_array_t buttons;
215 /** Icon */
216 image_t *icon;
217 /** Size hints */
218 xcb_size_hints_t size_hints;
219 /** Window it is transient for */
220 client_t *transient_for;
221 /** Next and previous clients */
222 client_t *prev, *next;
224 ARRAY_TYPE(client_t *, client)
226 /** Tag type */
227 struct tag
229 /** Ref count */
230 int refcount;
231 /** Tag name */
232 char *name;
233 /** Screen */
234 int screen;
235 /** true if selected */
236 bool selected;
237 /** Current tag layout */
238 layout_t *layout;
239 /** Master width factor */
240 double mwfact;
241 /** Number of master windows */
242 int nmaster;
243 /** Number of columns in tile layout */
244 int ncol;
245 /** clients in this tag */
246 client_array_t clients;
248 ARRAY_TYPE(tag_t *, tag)
250 /** Padding type */
251 typedef struct
253 /** Padding at top */
254 int top;
255 /** Padding at bottom */
256 int bottom;
257 /** Padding at left */
258 int left;
259 /** Padding at right */
260 int right;
261 } padding_t;
263 typedef struct
265 /** Screen index */
266 int index;
267 /** Screen geometry */
268 area_t geometry;
269 /** true if we need to arrange() */
270 bool need_arrange;
271 /** Tag list */
272 tag_array_t tags;
273 /** Wiboxes */
274 wibox_array_t wiboxes;
275 /** Padding */
276 padding_t padding;
277 /** Window that contains the systray */
278 struct
280 xcb_window_t window;
281 /** Systray window parent */
282 xcb_window_t parent;
283 } systray;
284 /** Focused client */
285 client_t *client_focus;
286 } screen_t;
288 /** Main configuration structure */
289 struct awesome_t
291 /** Connection ref */
292 xcb_connection_t *connection;
293 /** Event and error handlers */
294 xcb_event_handlers_t evenths;
295 /** Property change handler */
296 xcb_property_handlers_t prophs;
297 /** Default screen number */
298 int default_screen;
299 /** Keys symbol table */
300 xcb_key_symbols_t *keysyms;
301 /** Logical screens */
302 screen_t *screens;
303 /** Number of screens */
304 int nscreen;
305 /** True if xinerama is active */
306 bool xinerama_is_active;
307 /** Key bindings */
308 struct
310 keybinding_array_t by_code;
311 keybinding_array_t by_sym;
312 } keys;
313 /** Mouse bindings list */
314 button_array_t buttons;
315 /** Numlock mask */
316 unsigned int numlockmask;
317 /** Numlock mask */
318 unsigned int shiftlockmask;
319 /** Numlock mask */
320 unsigned int capslockmask;
321 /** Check for XRandR extension */
322 bool have_randr;
323 /** Cursors */
324 xcb_cursor_t cursor[CurLast];
325 /** Clients list */
326 client_t *clients;
327 /** Embedded windows */
328 xembed_window_t *embedded;
329 /** Path to config file */
330 char *conffile;
331 /** Stack client history */
332 client_node_t *stack;
333 /** Command line passed to awesome */
334 char *argv;
335 /** Last XMotionEvent coords */
336 int pointer_x, pointer_y;
337 /** Lua VM state */
338 lua_State *L;
339 /** Default colors */
340 struct
342 xcolor_t fg, bg;
343 } colors;
344 /** Default font */
345 font_t *font;
346 struct
348 /** Command to execute when spawning a new client */
349 luaA_ref manage;
350 /** Command to execute when unmanaging client */
351 luaA_ref unmanage;
352 /** Command to execute when giving focus to a client */
353 luaA_ref focus;
354 /** Command to execute when removing focus to a client */
355 luaA_ref unfocus;
356 /** Command to run when mouse enter a client */
357 luaA_ref mouse_enter;
358 /** Command to run on arrange */
359 luaA_ref arrange;
360 /** Command to run when client list changes */
361 luaA_ref clients;
362 /** Command to run on numbers of tag changes */
363 luaA_ref tags;
364 /** Command to run when client gets (un)tagged */
365 luaA_ref tagged;
366 /** Command to run on property change */
367 luaA_ref property;
368 /** Command to run on time */
369 luaA_ref timer;
370 } hooks;
371 /** The event loop */
372 struct ev_loop *loop;
373 /** The timeout after which we need to stop select() */
374 struct ev_timer timer;
375 /** The key grabber function */
376 luaA_ref keygrabber;
377 /** Focused screen */
378 screen_t *screen_focus;
381 #endif
382 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80