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