draw: stop using font as argument, use global
[awesome.git] / structs.h
blob19138a8007307477efdf765c9a440c96874ac9c3
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 "config.h"
29 #include "luaa.h"
30 #include "swindow.h"
31 #include "keybinding.h"
32 #include "common/xutil.h"
33 #include "common/xembed.h"
34 #include "common/refcount.h"
35 #include "common/tokenize.h"
37 /** Windows type */
38 typedef enum
40 WINDOW_TYPE_NORMAL = 0,
41 WINDOW_TYPE_DESKTOP,
42 WINDOW_TYPE_DOCK,
43 WINDOW_TYPE_SPLASH,
44 WINDOW_TYPE_DIALOG,
45 /* The ones below may have TRANSIENT_FOR, but are not plain dialogs.
46 * They were purposefully placed below DIALOG.
48 WINDOW_TYPE_MENU,
49 WINDOW_TYPE_TOOLBAR,
50 WINDOW_TYPE_UTILITY
51 } window_type_t;
53 /** Wibox types */
54 typedef enum
56 WIBOX_TYPE_NORMAL = 0,
57 WIBOX_TYPE_TITLEBAR
58 } wibox_type_t;
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)(widget_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 /** Cursor */
101 char *cursor;
102 } wibox_t;
103 ARRAY_TYPE(wibox_t *, wibox)
105 /** Widget */
106 struct widget_t
108 /** Ref count */
109 int refcount;
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 /** Mouse over event handler */
123 luaA_ref mouse_enter, mouse_leave;
124 /** Alignement */
125 alignment_t align;
126 /** Supported alignment */
127 alignment_t align_supported;
128 /** Misc private data */
129 void *data;
130 /** Button bindings */
131 button_array_t buttons;
132 /** True if the widget is visible */
133 bool isvisible;
136 /* Strut */
137 typedef struct
139 uint16_t left, right, top, bottom;
140 uint16_t left_start_y, left_end_y;
141 uint16_t right_start_y, right_end_y;
142 uint16_t top_start_x, top_end_x;
143 uint16_t bottom_start_x, bottom_end_x;
144 } strut_t;
146 /** client_t type */
147 struct client_t
149 /** Ref counter */
150 int refcount;
151 /** Valid, or not ? */
152 bool invalid;
153 /** Client name */
154 char *name, *icon_name;
155 /** Window geometry */
156 area_t geometry;
157 struct
159 /** Client geometry when (un)fullscreen */
160 area_t fullscreen;
161 /** Client geometry when (un)-max */
162 area_t max;
163 } geometries;
164 /* Size hints */
165 int basew, baseh, incw, inch, maxw, maxh, minw, minh;
166 int minax, maxax, minay, maxay;
167 /** Strut */
168 strut_t strut;
169 /** Respect resize hints */
170 bool honorsizehints;
171 int border, oldborder;
172 xcolor_t border_color;
173 /** True if the client is sticky */
174 bool issticky;
175 /** Has urgency hint */
176 bool isurgent;
177 /** True if the client is hidden */
178 bool ishidden;
179 /** True if the client is minimized */
180 bool isminimized;
181 /** True if the client is fullscreen */
182 bool isfullscreen;
183 /** True if the client is maximized horizontally */
184 bool ismaxhoriz;
185 /** True if the client is maximized vertically */
186 bool ismaxvert;
187 /** True if the client is above others */
188 bool isabove;
189 /** True if the client is below others */
190 bool isbelow;
191 /** True if the client is modal */
192 bool ismodal;
193 /** True if the client is on top */
194 bool isontop;
195 /** True if a client is banned to a position outside the viewport.
196 * Note that the geometry remains unchanged and that the window is still mapped.
198 bool isbanned;
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 /** Window of the group leader */
208 xcb_window_t group_win;
209 /** Window holding command needed to start it (session management related) */
210 xcb_window_t leader_win;
211 /** Client logical screen */
212 int screen;
213 /** Client physical screen */
214 int phys_screen;
215 /** Path to an icon */
216 char *icon_path;
217 /** Titlebar */
218 wibox_t *titlebar;
219 /** Button bindings */
220 button_array_t buttons;
221 /** Icon */
222 image_t *icon;
223 /** Size hints */
224 xcb_size_hints_t size_hints;
225 /** Window it is transient for */
226 client_t *transient_for;
227 /** Next and previous clients */
228 client_t *prev, *next;
230 ARRAY_TYPE(client_t *, client)
232 /** Tag type */
233 struct tag
235 /** Ref count */
236 int refcount;
237 /** Tag name */
238 char *name;
239 /** Screen */
240 int screen;
241 /** true if selected */
242 bool selected;
243 /** clients in this tag */
244 client_array_t clients;
246 ARRAY_TYPE(tag_t *, tag)
248 typedef struct
250 /** Screen index */
251 int index;
252 /** Screen geometry */
253 area_t geometry;
254 /** true if we need to arrange() */
255 bool need_arrange;
256 /** Tag list */
257 tag_array_t tags;
258 /** Wiboxes */
259 wibox_array_t wiboxes;
260 /** Padding */
261 padding_t padding;
262 /** Window that contains the systray */
263 struct
265 xcb_window_t window;
266 /** Systray window parent */
267 xcb_window_t parent;
268 } systray;
269 /** Focused client */
270 client_t *client_focus;
271 } screen_t;
273 /** Main configuration structure */
274 struct awesome_t
276 /** Connection ref */
277 xcb_connection_t *connection;
278 /** Event and error handlers */
279 xcb_event_handlers_t evenths;
280 /** Property change handler */
281 xcb_property_handlers_t prophs;
282 /** Default screen number */
283 int default_screen;
284 /** Keys symbol table */
285 xcb_key_symbols_t *keysyms;
286 /** Logical screens */
287 screen_t *screens;
288 /** Number of screens */
289 int nscreen;
290 /** True if xinerama is active */
291 bool xinerama_is_active;
292 /** Key bindings */
293 struct
295 keybinding_array_t by_code;
296 keybinding_array_t by_sym;
297 } keys;
298 /** Mouse bindings list */
299 button_array_t buttons;
300 /** Numlock mask */
301 unsigned int numlockmask;
302 /** Numlock mask */
303 unsigned int shiftlockmask;
304 /** Numlock mask */
305 unsigned int capslockmask;
306 /** Check for XRandR extension */
307 bool have_randr;
308 /** Clients list */
309 client_t *clients;
310 /** Embedded windows */
311 xembed_window_array_t embedded;
312 /** Path to config file */
313 char *conffile;
314 /** Stack client history */
315 client_node_t *stack;
316 /** Command line passed to awesome */
317 char *argv;
318 /** Last XMotionEvent coords */
319 int pointer_x, pointer_y;
320 /** Lua VM state */
321 lua_State *L;
322 /** Default colors */
323 struct
325 xcolor_t fg, bg;
326 } colors;
327 /** Default font */
328 font_t *font;
329 struct
331 /** Command to execute when spawning a new client */
332 luaA_ref manage;
333 /** Command to execute when unmanaging client */
334 luaA_ref unmanage;
335 /** Command to execute when giving focus to a client */
336 luaA_ref focus;
337 /** Command to execute when removing focus to a client */
338 luaA_ref unfocus;
339 /** Command to run when mouse enter a client */
340 luaA_ref mouse_enter;
341 /** Command to run when mouse leave a client */
342 luaA_ref mouse_leave;
343 /** Command to run on arrange */
344 luaA_ref arrange;
345 /** Command to run when client list changes */
346 luaA_ref clients;
347 /** Command to run on numbers of tag changes */
348 luaA_ref tags;
349 /** Command to run when client gets (un)tagged */
350 luaA_ref tagged;
351 /** Command to run on property change */
352 luaA_ref property;
353 /** Command to run on time */
354 luaA_ref timer;
355 #ifdef WITH_DBUS
356 /** Command to run on dbus events */
357 luaA_ref dbus;
358 #endif
359 } hooks;
360 /** The event loop */
361 struct ev_loop *loop;
362 /** The timeout after which we need to stop select() */
363 struct ev_timer timer;
364 /** The key grabber function */
365 luaA_ref keygrabber;
366 /** The mouse pointer grabber function */
367 luaA_ref mousegrabber;
368 /** Focused screen */
369 screen_t *screen_focus;
372 #endif
373 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80