ewmh: store NET_WM icon
[awesome.git] / structs.h
blobe53b36d3a827b25a51f9c9fcba0534b78d5496ed
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 <ev.h>
28 #include "lua.h"
29 #include "layout.h"
30 #include "common/xutil.h"
31 #include "common/draw.h"
32 #include "common/swindow.h"
33 #include "common/xscreen.h"
34 #include "common/xembed.h"
35 #include "common/refcount.h"
37 /** Stacking layout layers */
38 typedef enum
40 LAYER_DESKTOP = 1,
41 LAYER_BELOW,
42 LAYER_TILE,
43 LAYER_FLOAT,
44 LAYER_ABOVE,
45 LAYER_FULLSCREEN,
46 LAYER_MODAL,
47 LAYER_OUTOFSPACE
48 } layer_t;
50 /** Cursors */
51 enum
53 CurNormal, CurResize, CurResizeH, CurResizeV, CurMove,
54 CurTopLeft, CurTopRight, CurBotLeft, CurBotRight, CurLast
57 typedef struct button_t button_t;
58 typedef struct widget_t widget_t;
59 typedef struct widget_node_t widget_node_t;
60 typedef struct statusbar_t statusbar_t;
61 typedef struct client_t client_t;
62 typedef struct titlebar_t titlebar_t;
63 typedef struct client_node_t client_node_t;
64 typedef struct _tag_t tag_t;
65 typedef struct tag_client_node_t tag_client_node_t;
66 typedef area_t (floating_placement_t)(client_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 /** Mouse buttons bindings */
72 struct button_t
74 /** Ref count */
75 int refcount;
76 /** Key modifiers */
77 unsigned long mod;
78 /** Mouse button number */
79 unsigned int button;
80 /** Lua function to execute. */
81 luaA_ref fct;
82 /** Next and previous buttons */
83 button_t *prev, *next;
86 DO_SLIST(button_t, button, p_delete)
87 DO_RCNT(button_t, button, p_delete)
89 /** Widget */
90 struct widget_t
92 /** Ref count */
93 int refcount;
94 /** widget_t name */
95 char *name;
96 /** Widget type is constructor */
97 widget_constructor_t *type;
98 /** Widget destructor */
99 widget_destructor_t *destructor;
100 /** Widget detach function */
101 void (*detach)(widget_t *, void *);
102 /** Draw function */
103 int (*draw)(draw_context_t *, int, widget_node_t *, int, int, void *, awesome_type_t);
104 /** Index function */
105 int (*index)(lua_State *, awesome_token_t);
106 /** Newindex function */
107 int (*newindex)(lua_State *, awesome_token_t);
108 /** ButtonPressedEvent handler */
109 void (*button_press)(widget_node_t *, xcb_button_press_event_t *, int, void *, awesome_type_t);
110 /** Alignement */
111 alignment_t align;
112 /** Misc private data */
113 void *data;
114 /** Button bindings */
115 button_t *buttons;
116 /** Cache flags */
117 int cache_flags;
118 /** True if the widget is visible */
119 bool isvisible;
122 /** Delete a widget structure.
123 * \param widget The widget to destroy.
125 static inline void
126 widget_delete(widget_t **widget)
128 if((*widget)->destructor)
129 (*widget)->destructor(*widget);
130 button_list_wipe(&(*widget)->buttons);
131 p_delete(&(*widget)->name);
132 p_delete(widget);
135 DO_RCNT(widget_t, widget, widget_delete)
137 struct widget_node_t
139 /** The widget */
140 widget_t *widget;
141 /** The area where the widget was drawn */
142 area_t area;
143 /** Next and previous widget in the list */
144 widget_node_t *prev, *next;
147 /** Delete a widget node structure.
148 * \param node The node to destroy.
150 static inline void
151 widget_node_delete(widget_node_t **node)
153 widget_unref(&(*node)->widget);
154 p_delete(node);
157 DO_SLIST(widget_node_t, widget_node, widget_node_delete)
159 /** Titlebar template structure */
160 struct titlebar_t
162 /** Ref count */
163 int refcount;
164 /** Position */
165 position_t position, oldposition;
166 /** Alignment on window */
167 alignment_t align;
168 /** Widgets */
169 widget_node_t *widgets;
170 /** Width and height */
171 int width, height;
172 /** Titlebar window */
173 simple_window_t *sw;
174 /** Default colors */
175 struct
177 xcolor_t fg, bg;
178 } colors;
179 /** Border */
180 struct
182 xcolor_t color;
183 int width;
184 } border;
185 /** Need update */
186 bool need_update;
189 /** Delete a titlebar structure.
190 * \param t The titlebar to destroy.
192 static inline void
193 titlebar_delete(titlebar_t **t)
195 widget_node_list_wipe(&(*t)->widgets);
196 p_delete(t);
199 DO_RCNT(titlebar_t, titlebar, titlebar_delete)
201 /** Status bar */
202 struct statusbar_t
204 /** Ref count */
205 int refcount;
206 /** Window */
207 simple_window_t *sw;
208 /** statusbar_t name */
209 char *name;
210 /** Bar width */
211 int width;
212 /** Bar height */
213 int height;
214 /** True if user specified width */
215 bool width_user;
216 /** Bar position */
217 position_t position;
218 /** Alignment */
219 alignment_t align;
220 /** Screen */
221 int screen;
222 /** Physical screen id */
223 int phys_screen;
224 /** Widget list */
225 widget_node_t *widgets;
226 /** Draw context */
227 draw_context_t *ctx;
228 /** Need update */
229 bool need_update;
230 /** Default colors */
231 struct
233 xcolor_t fg, bg;
234 } colors;
235 /** Next and previous statusbars */
236 statusbar_t *prev, *next;
239 /** Netwm icon */
240 typedef struct
242 int height;
243 int width;
244 unsigned char *image;
245 } netwm_icon_t;
247 /** client_t type */
248 struct client_t
250 /** Ref counter */
251 int refcount;
252 /** Valid, or not ? */
253 bool invalid;
254 /** Client name */
255 char *name;
256 /** Window geometry */
257 area_t geometry;
258 /** Floating window geometry */
259 area_t f_geometry;
260 /** Max window geometry */
261 area_t m_geometry;
262 /* Size hints */
263 int basew, baseh, incw, inch, maxw, maxh, minw, minh;
264 int minax, maxax, minay, maxay;
265 bool hassizehints;
266 /** Respect resize hints */
267 bool honorsizehints;
268 int border, oldborder;
269 xcolor_t border_color;
270 /** True if the client does not want any border */
271 bool noborder;
272 /** Has urgency hint */
273 bool isurgent;
274 /** Store previous floating state before maximizing */
275 bool wasfloating;
276 /** true if the window is floating */
277 bool isfloating;
278 /** true if the window is fixed */
279 bool isfixed;
280 /** true if the window is maximized */
281 bool ismax;
282 /** true if the client must be skipped from client list */
283 bool skip;
284 /** true if the client is moving */
285 bool ismoving;
286 /** True if the client is hidden */
287 bool ishidden;
288 /** true if the client must be skipped from task bar client list */
289 bool skiptb;
290 /** Window of the client */
291 xcb_window_t win;
292 /** Client logical screen */
293 int screen;
294 /** Client physical screen */
295 int phys_screen;
296 /** Layer in the stacking order */
297 layer_t layer, oldlayer;
298 /** Path to an icon */
299 char *icon_path;
300 /** Titlebar */
301 titlebar_t *titlebar;
302 /** Button bindings */
303 button_t *buttons;
304 /** Floating window placement algo */
305 floating_placement_t *floating_placement;
306 /** Icon */
307 netwm_icon_t *icon;
308 /** Next and previous clients */
309 client_t *prev, *next;
312 static void
313 client_delete(client_t **c)
315 button_list_wipe(&(*c)->buttons);
316 p_delete(&(*c)->icon_path);
317 p_delete(&(*c)->name);
318 p_delete(c);
321 DO_ARRAY(client_t *, client, DO_NOTHING)
322 DO_RCNT(client_t, client, client_delete)
324 struct client_node_t
326 /** The client */
327 client_t *client;
328 /** Next and previous client_nodes */
329 client_node_t *prev, *next;
332 /** Tag type */
333 struct _tag_t
335 /** Ref count */
336 int refcount;
337 /** Tag name */
338 char *name;
339 /** Screen */
340 int screen;
341 /** true if selected */
342 bool selected;
343 /** Current tag layout */
344 layout_t *layout;
345 /** Master width factor */
346 double mwfact;
347 /** Number of master windows */
348 int nmaster;
349 /** Number of columns in tile layout */
350 int ncol;
351 /** clients in this tag */
352 client_array_t clients;
354 ARRAY_TYPE(tag_t *, tag)
356 /** Padding type */
357 typedef struct
359 /** Padding at top */
360 int top;
361 /** Padding at bottom */
362 int bottom;
363 /** Padding at left */
364 int left;
365 /** Padding at right */
366 int right;
367 } padding_t;
369 typedef struct
371 /** Screen index */
372 int index;
373 /** Screen geometry */
374 area_t geometry;
375 /** true if we need to arrange() */
376 bool need_arrange;
377 /** Tag list */
378 tag_array_t tags;
379 /** Status bar */
380 statusbar_t *statusbar;
381 /** Padding */
382 padding_t padding;
383 /** Window that contains the systray */
384 struct
386 xcb_window_t window;
387 } systray;
388 /** Focused client */
389 client_t *client_focus;
390 } screen_t;
392 /** Main configuration structure */
393 struct awesome_t
395 /** Connection ref */
396 xcb_connection_t *connection;
397 /** Event and error handlers */
398 xcb_event_handlers_t *evenths;
399 /** Default screen number */
400 int default_screen;
401 /** Keys symbol table */
402 xcb_key_symbols_t *keysyms;
403 /** Logical screens */
404 screen_t *screens;
405 /** Screens info */
406 screens_info_t *screens_info;
407 /** Mouse bindings list */
408 struct
410 button_t *root;
411 } buttons;
412 /** Numlock mask */
413 unsigned int numlockmask;
414 /** Numlock mask */
415 unsigned int shiftlockmask;
416 /** Numlock mask */
417 unsigned int capslockmask;
418 /** Check for XRandR extension */
419 bool have_randr;
420 /** Cursors */
421 xcb_cursor_t cursor[CurLast];
422 /** Clients list */
423 client_t *clients;
424 /** Embedded windows */
425 xembed_window_t *embedded;
426 /** Path to config file */
427 char *configpath;
428 /** Stack client history */
429 client_node_t *stack;
430 /** Command line passed to awesome */
431 char *argv;
432 /** Last XMotionEvent coords */
433 int pointer_x, pointer_y;
434 /** Lua VM state */
435 lua_State *L;
436 /** Default colors */
437 struct
439 xcolor_t fg, bg;
440 } colors;
441 /** Default font */
442 font_t *font;
443 struct
445 /** Command to execute when spawning a new client */
446 luaA_ref manage;
447 /** Command to execute when unmanaging client */
448 luaA_ref unmanage;
449 /** Command to execute when giving focus to a client */
450 luaA_ref focus;
451 /** Command to execute when removing focus to a client */
452 luaA_ref unfocus;
453 /** Command to run when mouse is over */
454 luaA_ref mouseover;
455 /** Command to run on arrange */
456 luaA_ref arrange;
457 /** Command to run on title change */
458 luaA_ref titleupdate;
459 /** Command to run on urgent flag */
460 luaA_ref urgent;
461 /** Command to run on time */
462 luaA_ref timer;
463 } hooks;
464 /** The event loop */
465 struct ev_loop *loop;
466 /** The timeout after which we need to stop select() */
467 struct ev_timer timer;
468 /** The key grabber function */
469 luaA_ref keygrabber;
470 /** Focused screen */
471 screen_t *screen_focus;
474 #endif
475 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80