wibox: make sure no garbage is painted to the screen
[awesome.git] / wibox.c
blob3310c6766572df17fce223b47bfbc598d929b0f4
1 /*
2 * wibox.c - wibox functions
4 * Copyright © 2008-2009 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 #include <xcb/shape.h>
24 #include "screen.h"
25 #include "wibox.h"
26 #include "titlebar.h"
27 #include "client.h"
28 #include "screen.h"
29 #include "window.h"
30 #include "luaa.h"
31 #include "ewmh.h"
32 #include "common/xcursor.h"
33 #include "common/xutil.h"
35 LUA_OBJECT_FUNCS(wibox_class, wibox_t, wibox)
37 /** Take care of garbage collecting a wibox.
38 * \param L The Lua VM state.
39 * \return The number of elements pushed on stack, 0!
41 static int
42 luaA_wibox_gc(lua_State *L)
44 wibox_t *wibox = luaA_checkudata(L, 1, &wibox_class);
45 p_delete(&wibox->cursor);
46 wibox_wipe(wibox);
47 button_array_wipe(&wibox->buttons);
48 widget_node_array_wipe(&wibox->widgets);
49 return luaA_object_gc(L);
52 void
53 wibox_unref_simplified(wibox_t **item)
55 luaA_object_unref(globalconf.L, *item);
58 static void
59 wibox_need_update(wibox_t *wibox)
61 wibox->need_update = true;
62 wibox->mouse_over = NULL;
65 static int
66 have_shape(void)
68 const xcb_query_extension_reply_t *reply;
70 reply = xcb_get_extension_data(globalconf.connection, &xcb_shape_id);
71 if (!reply || !reply->present)
72 return 0;
74 /* We don't need a specific version of SHAPE, no version check required */
75 return 1;
78 static void
79 shape_update(xcb_window_t win, xcb_shape_kind_t kind, image_t *image, int offset)
81 xcb_pixmap_t shape;
83 if(image)
84 shape = image_to_1bit_pixmap(image, win);
85 else
86 /* Reset the shape */
87 shape = XCB_NONE;
89 xcb_shape_mask(globalconf.connection, XCB_SHAPE_SO_SET, kind,
90 win, offset, offset, shape);
92 if (shape != XCB_NONE)
93 xcb_free_pixmap(globalconf.connection, shape);
96 /** Update the window's shape.
97 * \param wibox The simple window whose shape should be updated.
99 static void
100 wibox_shape_update(wibox_t *wibox)
102 if(wibox->window == XCB_NONE)
103 return;
105 if(!have_shape())
107 static bool warned = false;
108 if(!warned)
109 warn("The X server doesn't have the SHAPE extension; "
110 "can't change window's shape");
111 warned = true;
112 return;
115 shape_update(wibox->window, XCB_SHAPE_SK_CLIP, wibox->shape.clip, 0);
116 shape_update(wibox->window, XCB_SHAPE_SK_BOUNDING, wibox->shape.bounding, - wibox->border_width);
118 wibox->need_shape_update = false;
121 static void
122 wibox_draw_context_update(wibox_t *w, xcb_screen_t *s)
124 xcolor_t fg = w->ctx.fg, bg = w->ctx.bg;
125 int phys_screen = w->ctx.phys_screen;
127 draw_context_wipe(&w->ctx);
129 /* update draw context */
130 switch(w->orientation)
132 case South:
133 case North:
134 /* we need a new pixmap this way [ ] to render */
135 w->ctx.pixmap = xcb_generate_id(globalconf.connection);
136 xcb_create_pixmap(globalconf.connection,
137 s->root_depth,
138 w->ctx.pixmap, s->root,
139 w->geometry.height,
140 w->geometry.width);
141 draw_context_init(&w->ctx, phys_screen,
142 w->geometry.height,
143 w->geometry.width,
144 w->ctx.pixmap, &fg, &bg);
145 break;
146 case East:
147 draw_context_init(&w->ctx, phys_screen,
148 w->geometry.width,
149 w->geometry.height,
150 w->pixmap, &fg, &bg);
151 break;
155 /** Initialize a wibox.
156 * \param w The wibox to initialize.
157 * \param phys_screen Physical screen number.
159 void
160 wibox_init(wibox_t *w, int phys_screen)
162 xcb_screen_t *s = xutil_screen_get(globalconf.connection, phys_screen);
164 w->window = xcb_generate_id(globalconf.connection);
165 xcb_create_window(globalconf.connection, s->root_depth, w->window, s->root,
166 w->geometry.x, w->geometry.y,
167 w->geometry.width, w->geometry.height,
168 w->border_width, XCB_COPY_FROM_PARENT, s->root_visual,
169 XCB_CW_BACK_PIXEL | XCB_CW_BORDER_PIXEL | XCB_CW_BIT_GRAVITY
170 | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK,
171 (const uint32_t [])
173 w->ctx.bg.pixel,
174 w->border_color.pixel,
175 XCB_GRAVITY_NORTH_WEST,
177 XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT
178 | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_ENTER_WINDOW
179 | XCB_EVENT_MASK_LEAVE_WINDOW | XCB_EVENT_MASK_STRUCTURE_NOTIFY
180 | XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE
181 | XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE
182 | XCB_EVENT_MASK_PROPERTY_CHANGE
185 /* Create a pixmap. */
186 w->pixmap = xcb_generate_id(globalconf.connection);
187 xcb_create_pixmap(globalconf.connection, s->root_depth, w->pixmap, s->root,
188 w->geometry.width, w->geometry.height);
190 /* Update draw context physical screen, important for Zaphod. */
191 w->ctx.phys_screen = phys_screen;
192 wibox_draw_context_update(w, s);
194 /* The default GC is just a newly created associated to the root window */
195 w->gc = xcb_generate_id(globalconf.connection);
196 xcb_create_gc(globalconf.connection, w->gc, s->root, XCB_GC_FOREGROUND | XCB_GC_BACKGROUND,
197 (const uint32_t[]) { s->black_pixel, s->white_pixel });
199 wibox_shape_update(w);
202 /** Refresh the window content by copying its pixmap data to its window.
203 * \param w The wibox to refresh.
205 static inline void
206 wibox_refresh_pixmap(wibox_t *w)
208 wibox_refresh_pixmap_partial(w, 0, 0, w->geometry.width, w->geometry.height);
211 /** Move and/or resize a wibox
212 * \param L The Lua VM state.
213 * \param udx The index of the wibox.
214 * \param geometry The new geometry.
216 void
217 wibox_moveresize(lua_State *L, int udx, area_t geometry)
219 wibox_t *w = luaA_checkudata(L, udx, &wibox_class);
220 if(w->window)
222 int number_of_vals = 0;
223 uint32_t moveresize_win_vals[4], mask_vals = 0;
225 if(w->geometry.x != geometry.x)
227 w->geometry.x = moveresize_win_vals[number_of_vals++] = geometry.x;
228 mask_vals |= XCB_CONFIG_WINDOW_X;
231 if(w->geometry.y != geometry.y)
233 w->geometry.y = moveresize_win_vals[number_of_vals++] = geometry.y;
234 mask_vals |= XCB_CONFIG_WINDOW_Y;
237 if(geometry.width > 0 && w->geometry.width != geometry.width)
239 w->geometry.width = moveresize_win_vals[number_of_vals++] = geometry.width;
240 mask_vals |= XCB_CONFIG_WINDOW_WIDTH;
243 if(geometry.height > 0 && w->geometry.height != geometry.height)
245 w->geometry.height = moveresize_win_vals[number_of_vals++] = geometry.height;
246 mask_vals |= XCB_CONFIG_WINDOW_HEIGHT;
249 if(mask_vals & (XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT))
251 xcb_free_pixmap(globalconf.connection, w->pixmap);
252 /* orientation != East */
253 if(w->pixmap != w->ctx.pixmap)
254 xcb_free_pixmap(globalconf.connection, w->ctx.pixmap);
255 w->pixmap = xcb_generate_id(globalconf.connection);
256 xcb_screen_t *s = xutil_screen_get(globalconf.connection, w->ctx.phys_screen);
257 xcb_create_pixmap(globalconf.connection, s->root_depth, w->pixmap, s->root,
258 w->geometry.width, w->geometry.height);
259 wibox_draw_context_update(w, s);
262 /* Activate BMA */
263 client_ignore_enterleave_events();
265 if(mask_vals)
266 xcb_configure_window(globalconf.connection, w->window, mask_vals, moveresize_win_vals);
268 /* Deactivate BMA */
269 client_restore_enterleave_events();
271 w->screen = screen_getbycoord(w->screen, w->geometry.x, w->geometry.y);
273 if(mask_vals & XCB_CONFIG_WINDOW_X)
274 luaA_object_emit_signal(L, udx, "property::x", 0);
275 if(mask_vals & XCB_CONFIG_WINDOW_Y)
276 luaA_object_emit_signal(L, udx, "property::y", 0);
277 if(mask_vals & XCB_CONFIG_WINDOW_WIDTH)
278 luaA_object_emit_signal(L, udx, "property::width", 0);
279 if(mask_vals & XCB_CONFIG_WINDOW_HEIGHT)
280 luaA_object_emit_signal(L, udx, "property::height", 0);
282 else
284 #define DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(prop) \
285 if(w->geometry.prop != geometry.prop) \
287 w->geometry.prop = geometry.prop; \
288 luaA_object_emit_signal(L, udx, "property::" #prop, 0); \
290 DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(x)
291 DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(y)
292 DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(width)
293 DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(height)
294 #undef DO_WIBOX_GEOMETRY_CHECK_AND_EMIT
297 wibox_need_update(w);
300 /** Refresh the window content by copying its pixmap data to its window.
301 * \param wibox The wibox to refresh.
302 * \param x The copy starting point x component.
303 * \param y The copy starting point y component.
304 * \param w The copy width from the x component.
305 * \param h The copy height from the y component.
307 void
308 wibox_refresh_pixmap_partial(wibox_t *wibox,
309 int16_t x, int16_t y,
310 uint16_t w, uint16_t h)
312 xcb_copy_area(globalconf.connection, wibox->pixmap,
313 wibox->window, wibox->gc, x, y, x, y,
314 w, h);
317 void
318 wibox_set_opacity(lua_State *L, int udx, double opacity)
320 wibox_t *w = luaA_checkudata(L, udx, &wibox_class);
321 if(w->opacity != opacity)
323 w->opacity = opacity;
324 if(w->window)
325 window_opacity_set(w->window, opacity);
326 luaA_object_emit_signal(L, udx, "property::opacity", 0);
330 /** Set a wibox border color.
331 * \param L The Lua VM state.
332 * \param udx The wibox to change border width.
333 * \param color The border color.
335 static void
336 wibox_set_border_color(lua_State *L, int udx, const xcolor_t *color)
338 wibox_t *w = luaA_checkudata(L, udx, &wibox_class);
339 xcb_change_window_attributes(globalconf.connection, w->window,
340 XCB_CW_BORDER_PIXEL, &color->pixel);
341 w->border_color = *color;
342 luaA_object_emit_signal(L, udx, "property::border_color", 0);
345 /** Set wibox orientation.
346 * \param L The Lua VM state.
347 * \param udx The wibox to change orientation.
348 * \param o The new orientation.
350 void
351 wibox_set_orientation(lua_State *L, int udx, orientation_t o)
353 wibox_t *w = luaA_checkudata(L, udx, &wibox_class);
354 if(o != w->orientation)
356 xcb_screen_t *s = xutil_screen_get(globalconf.connection, w->ctx.phys_screen);
357 w->orientation = o;
358 /* orientation != East */
359 if(w->pixmap != w->ctx.pixmap)
360 xcb_free_pixmap(globalconf.connection, w->ctx.pixmap);
361 wibox_draw_context_update(w, s);
362 luaA_object_emit_signal(L, udx, "property::orientation", 0);
366 static void
367 wibox_map(wibox_t *wibox)
369 /* Activate BMA */
370 client_ignore_enterleave_events();
371 /* Map the wibox */
372 xcb_map_window(globalconf.connection, wibox->window);
373 /* Deactivate BMA */
374 client_restore_enterleave_events();
375 /* We must make sure the wibox does not display garbage */
376 wibox_need_update(wibox);
377 /* Stack this wibox correctly */
378 client_stack();
381 /** Kick out systray windows.
382 * \param phys_screen Physical screen number.
384 static void
385 wibox_systray_kickout(int phys_screen)
387 xcb_screen_t *s = xutil_screen_get(globalconf.connection, phys_screen);
389 if(globalconf.screens.tab[phys_screen].systray.parent != s->root)
391 /* Who! Check that we're not deleting a wibox with a systray, because it
392 * may be its parent. If so, we reparent to root before, otherwise it will
393 * hurt very much. */
394 xcb_reparent_window(globalconf.connection,
395 globalconf.screens.tab[phys_screen].systray.window,
396 s->root, -512, -512);
398 globalconf.screens.tab[phys_screen].systray.parent = s->root;
402 static void
403 wibox_systray_refresh(wibox_t *wibox)
405 if(!wibox->screen)
406 return;
408 for(int i = 0; i < wibox->widgets.len; i++)
410 widget_node_t *systray = &wibox->widgets.tab[i];
411 if(systray->widget->type == widget_systray)
413 uint32_t config_back[] = { wibox->ctx.bg.pixel };
414 uint32_t config_win_vals[4];
415 uint32_t config_win_vals_off[2] = { -512, -512 };
416 xembed_window_t *em;
417 int phys_screen = wibox->ctx.phys_screen;
419 if(wibox->visible
420 && systray->widget->isvisible
421 && systray->geometry.width)
423 /* Set background of the systray window. */
424 xcb_change_window_attributes(globalconf.connection,
425 globalconf.screens.tab[phys_screen].systray.window,
426 XCB_CW_BACK_PIXEL, config_back);
427 /* Map it. */
428 xcb_map_window(globalconf.connection, globalconf.screens.tab[phys_screen].systray.window);
429 /* Move it. */
430 switch(wibox->orientation)
432 case North:
433 config_win_vals[0] = systray->geometry.y;
434 config_win_vals[1] = wibox->geometry.height - systray->geometry.x - systray->geometry.width;
435 config_win_vals[2] = systray->geometry.height;
436 config_win_vals[3] = systray->geometry.width;
437 break;
438 case South:
439 config_win_vals[0] = systray->geometry.y;
440 config_win_vals[1] = systray->geometry.x;
441 config_win_vals[2] = systray->geometry.height;
442 config_win_vals[3] = systray->geometry.width;
443 break;
444 case East:
445 config_win_vals[0] = systray->geometry.x;
446 config_win_vals[1] = systray->geometry.y;
447 config_win_vals[2] = systray->geometry.width;
448 config_win_vals[3] = systray->geometry.height;
449 break;
451 /* reparent */
452 if(globalconf.screens.tab[phys_screen].systray.parent != wibox->window)
454 xcb_reparent_window(globalconf.connection,
455 globalconf.screens.tab[phys_screen].systray.window,
456 wibox->window,
457 config_win_vals[0], config_win_vals[1]);
458 globalconf.screens.tab[phys_screen].systray.parent = wibox->window;
460 xcb_configure_window(globalconf.connection,
461 globalconf.screens.tab[phys_screen].systray.window,
462 XCB_CONFIG_WINDOW_X
463 | XCB_CONFIG_WINDOW_Y
464 | XCB_CONFIG_WINDOW_WIDTH
465 | XCB_CONFIG_WINDOW_HEIGHT,
466 config_win_vals);
467 /* width = height = systray height */
468 config_win_vals[2] = config_win_vals[3] = systray->geometry.height;
469 config_win_vals[0] = 0;
471 else
472 return wibox_systray_kickout(phys_screen);
474 switch(wibox->orientation)
476 case North:
477 config_win_vals[1] = systray->geometry.width - config_win_vals[3];
478 for(int j = 0; j < globalconf.embedded.len; j++)
480 em = &globalconf.embedded.tab[j];
481 if(em->phys_screen == phys_screen)
483 if(config_win_vals[1] - config_win_vals[2] >= (uint32_t) wibox->geometry.y)
485 xcb_map_window(globalconf.connection, em->win);
486 xcb_configure_window(globalconf.connection, em->win,
487 XCB_CONFIG_WINDOW_X
488 | XCB_CONFIG_WINDOW_Y
489 | XCB_CONFIG_WINDOW_WIDTH
490 | XCB_CONFIG_WINDOW_HEIGHT,
491 config_win_vals);
492 config_win_vals[1] -= config_win_vals[3];
494 else
495 xcb_configure_window(globalconf.connection, em->win,
496 XCB_CONFIG_WINDOW_X
497 | XCB_CONFIG_WINDOW_Y,
498 config_win_vals_off);
501 break;
502 case South:
503 config_win_vals[1] = 0;
504 for(int j = 0; j < globalconf.embedded.len; j++)
506 em = &globalconf.embedded.tab[j];
507 if(em->phys_screen == phys_screen)
509 /* if(y + width <= wibox.y + systray.right) */
510 if(config_win_vals[1] + config_win_vals[3] <= (uint32_t) wibox->geometry.y + AREA_RIGHT(systray->geometry))
512 xcb_map_window(globalconf.connection, em->win);
513 xcb_configure_window(globalconf.connection, em->win,
514 XCB_CONFIG_WINDOW_X
515 | XCB_CONFIG_WINDOW_Y
516 | XCB_CONFIG_WINDOW_WIDTH
517 | XCB_CONFIG_WINDOW_HEIGHT,
518 config_win_vals);
519 config_win_vals[1] += config_win_vals[3];
521 else
522 xcb_configure_window(globalconf.connection, em->win,
523 XCB_CONFIG_WINDOW_X
524 | XCB_CONFIG_WINDOW_Y,
525 config_win_vals_off);
528 break;
529 case East:
530 config_win_vals[1] = 0;
531 for(int j = 0; j < globalconf.embedded.len; j++)
533 em = &globalconf.embedded.tab[j];
534 if(em->phys_screen == phys_screen)
536 /* if(x + width < systray.x + systray.width) */
537 if(config_win_vals[0] + config_win_vals[2] <= (uint32_t) AREA_RIGHT(systray->geometry) + wibox->geometry.x)
539 xcb_map_window(globalconf.connection, em->win);
540 xcb_configure_window(globalconf.connection, em->win,
541 XCB_CONFIG_WINDOW_X
542 | XCB_CONFIG_WINDOW_Y
543 | XCB_CONFIG_WINDOW_WIDTH
544 | XCB_CONFIG_WINDOW_HEIGHT,
545 config_win_vals);
546 config_win_vals[0] += config_win_vals[2];
548 else
549 xcb_configure_window(globalconf.connection, em->win,
550 XCB_CONFIG_WINDOW_X
551 | XCB_CONFIG_WINDOW_Y,
552 config_win_vals_off);
555 break;
557 break;
562 /** Get a wibox by its window.
563 * \param win The window id.
564 * \return A wibox if found, NULL otherwise.
566 wibox_t *
567 wibox_getbywin(xcb_window_t win)
569 foreach(w, globalconf.wiboxes)
570 if((*w)->window == win)
571 return *w;
573 foreach(_c, globalconf.clients)
575 client_t *c = *_c;
576 if(c->titlebar && c->titlebar->window == win)
577 return c->titlebar;
580 return NULL;
583 /** Draw a wibox.
584 * \param wibox The wibox to draw.
586 static void
587 wibox_draw(wibox_t *wibox)
589 if(wibox->visible)
591 widget_render(wibox);
592 wibox_refresh_pixmap(wibox);
594 wibox->need_update = false;
597 wibox_systray_refresh(wibox);
600 /** Refresh all wiboxes.
602 void
603 wibox_refresh(void)
605 foreach(w, globalconf.wiboxes)
607 if((*w)->need_shape_update)
608 wibox_shape_update(*w);
609 if((*w)->need_update)
610 wibox_draw(*w);
613 foreach(_c, globalconf.clients)
615 client_t *c = *_c;
616 if(c->titlebar && c->titlebar->need_update)
617 wibox_draw(c->titlebar);
621 /** Set a wibox visible or not.
622 * \param L The Lua VM state.
623 * \param udx The wibox.
624 * \param v The visible value.
626 static void
627 wibox_set_visible(lua_State *L, int udx, bool v)
629 wibox_t *wibox = luaA_checkudata(L, udx, &wibox_class);
630 if(v != wibox->visible)
632 wibox->visible = v;
633 wibox->mouse_over = NULL;
635 if(wibox->screen)
637 if(wibox->visible)
638 wibox_map(wibox);
639 else
641 /* Active BMA */
642 client_ignore_enterleave_events();
643 /* Unmap window */
644 xcb_unmap_window(globalconf.connection, wibox->window);
645 /* Active BMA */
646 client_restore_enterleave_events();
649 /* kick out systray if needed */
650 wibox_systray_refresh(wibox);
653 luaA_object_emit_signal(L, udx, "property::visible", 0);
655 hook_property(wibox, "visible");
659 /** Destroy all X resources of a wibox.
660 * \param w The wibox to wipe.
662 void
663 wibox_wipe(wibox_t *w)
665 if(w->window)
667 /* Activate BMA */
668 client_ignore_enterleave_events();
669 xcb_destroy_window(globalconf.connection, w->window);
670 /* Deactivate BMA */
671 client_restore_enterleave_events();
672 w->window = XCB_NONE;
674 if(w->pixmap)
676 xcb_free_pixmap(globalconf.connection, w->pixmap);
677 w->pixmap = XCB_NONE;
679 if(w->gc)
681 xcb_free_gc(globalconf.connection, w->gc);
682 w->gc = XCB_NONE;
684 draw_context_wipe(&w->ctx);
687 /** Remove a wibox from a screen.
688 * \param L The Lua VM state.
689 * \param udx Wibox to detach from screen.
691 static void
692 wibox_detach(lua_State *L, int udx)
694 wibox_t *wibox = luaA_checkudata(L, udx, &wibox_class);
695 if(wibox->screen)
697 bool v;
699 /* save visible state */
700 v = wibox->visible;
701 wibox->visible = false;
702 wibox_systray_refresh(wibox);
703 /* restore visibility */
704 wibox->visible = v;
706 wibox->mouse_over = NULL;
708 wibox_wipe(wibox);
710 foreach(item, globalconf.wiboxes)
711 if(*item == wibox)
713 wibox_array_remove(&globalconf.wiboxes, item);
714 break;
717 hook_property(wibox, "screen");
719 if(strut_has_value(&wibox->strut))
720 screen_emit_signal(L, wibox->screen, "property::workarea", 0);
722 wibox->screen = NULL;
723 luaA_object_emit_signal(L, udx, "property::screen", 0);
725 luaA_object_unref(globalconf.L, wibox);
729 /** Attach a wibox that is on top of the stack.
730 * \param L The Lua VM state.
731 * \param udx The wibox to attach.
732 * \param s The screen to attach the wibox to.
734 static void
735 wibox_attach(lua_State *L, int udx, screen_t *s)
737 int phys_screen = screen_virttophys(screen_array_indexof(&globalconf.screens, s));
739 /* duplicate wibox */
740 lua_pushvalue(L, udx);
741 /* ref it */
742 wibox_t *wibox = luaA_object_ref_class(globalconf.L, -1, &wibox_class);
744 wibox_detach(L, udx);
746 /* Set the wibox screen */
747 wibox->screen = s;
749 /* Check that the wibox coordinates matches the screen. */
750 screen_t *cscreen =
751 screen_getbycoord(wibox->screen, wibox->geometry.x, wibox->geometry.y);
753 /* If it does not match, move it to the screen coordinates */
754 if(cscreen != wibox->screen)
755 wibox_moveresize(L, udx, (area_t) { .x = s->geometry.x,
756 .y = s->geometry.y,
757 .width = wibox->geometry.width,
758 .height = wibox->geometry.height });
760 wibox_array_append(&globalconf.wiboxes, wibox);
762 wibox_init(wibox, phys_screen);
764 window_set_cursor(wibox->window,
765 xcursor_new(globalconf.connection, xcursor_font_fromstr(wibox->cursor)));
767 if(wibox->opacity != -1)
768 window_opacity_set(wibox->window, wibox->opacity);
770 ewmh_update_strut(wibox->window, &wibox->strut);
772 if(wibox->visible)
773 wibox_map(wibox);
774 else
775 wibox_need_update(wibox);
777 hook_property(wibox, "screen");
778 luaA_object_emit_signal(L, udx, "property::screen", 0);
780 if(strut_has_value(&wibox->strut))
781 screen_emit_signal(L, wibox->screen, "property::workarea", 0);
784 /** Create a new wibox.
785 * \param L The Lua VM state.
787 * \luastack
788 * \lparam A table with optionally defined values:
789 * fg, bg, border_width, border_color, ontop, width and height.
790 * \lreturn A brand new wibox.
792 static int
793 luaA_wibox_new(lua_State *L)
795 luaA_class_new(L, &wibox_class);
797 wibox_t *w = luaA_checkudata(L, -1, &wibox_class);
799 if(!w->ctx.fg.initialized)
800 w->ctx.fg = globalconf.colors.fg;
802 if(!w->ctx.bg.initialized)
803 w->ctx.bg = globalconf.colors.bg;
805 if(!w->border_color.initialized)
806 w->border_color = globalconf.colors.bg;
808 w->visible = true;
810 if(!w->opacity)
811 w->opacity = -1;
813 if(!w->cursor)
814 w->cursor = a_strdup("left_ptr");
816 if(!w->geometry.width)
817 w->geometry.width = 1;
819 if(!w->geometry.height)
820 w->geometry.height = 1;
822 return 1;
825 /** Check if a wibox widget table has an item.
826 * \param L The Lua VM state.
827 * \param wibox The wibox.
828 * \param item The item to look for.
830 static bool
831 luaA_wibox_hasitem(lua_State *L, wibox_t *wibox, const void *item)
833 if(wibox->widgets_table)
835 luaA_object_push(L, wibox);
836 luaA_object_push_item(L, -1, wibox->widgets_table);
837 lua_remove(L, -2);
838 if(lua_topointer(L, -1) == item || luaA_hasitem(L, item))
839 return true;
841 return false;
844 /** Invalidate a wibox by a Lua object (table, etc).
845 * \param L The Lua VM state.
846 * \param item The object identifier.
848 void
849 luaA_wibox_invalidate_byitem(lua_State *L, const void *item)
851 foreach(w, globalconf.wiboxes)
853 wibox_t *wibox = *w;
854 if(luaA_wibox_hasitem(L, wibox, item))
856 /* update wibox */
857 wibox_need_update(wibox);
858 lua_pop(L, 1); /* remove widgets table */
863 foreach(_c, globalconf.clients)
865 client_t *c = *_c;
866 if(c->titlebar && luaA_wibox_hasitem(L, c->titlebar, item))
868 /* update wibox */
869 wibox_need_update(c->titlebar);
870 lua_pop(L, 1); /* remove widgets table */
875 /* Set or get the wibox geometry.
876 * \param L The Lua VM state.
877 * \return The number of elements pushed on stack.
878 * \luastack
879 * \lparam An optional table with wibox geometry.
880 * \lreturn The wibox geometry.
882 static int
883 luaA_wibox_geometry(lua_State *L)
885 wibox_t *wibox = luaA_checkudata(L, 1, &wibox_class);
887 if(lua_gettop(L) == 2)
889 area_t wingeom;
891 luaA_checktable(L, 2);
892 wingeom.x = luaA_getopt_number(L, 2, "x", wibox->geometry.x);
893 wingeom.y = luaA_getopt_number(L, 2, "y", wibox->geometry.y);
894 wingeom.width = luaA_getopt_number(L, 2, "width", wibox->geometry.width);
895 wingeom.height = luaA_getopt_number(L, 2, "height", wibox->geometry.height);
897 if(wingeom.width > 0 && wingeom.height > 0)
898 switch(wibox->type)
900 case WIBOX_TYPE_TITLEBAR:
901 wibox_moveresize(L, 1, (area_t) { .x = wibox->geometry.x,
902 .y = wibox->geometry.y,
903 .width = wingeom.width,
904 .height = wingeom.height });
905 break;
906 case WIBOX_TYPE_NORMAL:
907 wibox_moveresize(L, 1, wingeom);
908 break;
912 return luaA_pusharea(L, wibox->geometry);
915 static int
916 luaA_wibox_struts(lua_State *L)
918 wibox_t *w = luaA_checkudata(L, 1, &wibox_class);
920 if(lua_gettop(L) == 2)
922 luaA_tostrut(L, 2, &w->strut);
923 if(w->window)
924 ewmh_update_strut(w->window, &w->strut);
925 luaA_object_emit_signal(L, 1, "property::struts", 0);
926 if(w->screen)
927 screen_emit_signal(L, w->screen, "property::workarea", 0);
930 return luaA_pushstrut(L, w->strut);
933 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, ontop, lua_pushboolean)
934 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, cursor, lua_pushstring)
935 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, visible, lua_pushboolean)
936 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, border_width, lua_pushnumber)
937 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, border_color, luaA_pushxcolor)
939 static int
940 luaA_wibox_set_x(lua_State *L, wibox_t *wibox)
942 wibox_moveresize(L, -3, (area_t) { .x = luaL_checknumber(L, -1),
943 .y = wibox->geometry.y,
944 .width = wibox->geometry.width,
945 .height = wibox->geometry.height });
946 return 0;
949 static int
950 luaA_wibox_get_x(lua_State *L, wibox_t *wibox)
952 lua_pushnumber(L, wibox->geometry.x);
953 return 1;
956 static int
957 luaA_wibox_set_y(lua_State *L, wibox_t *wibox)
959 wibox_moveresize(L, -3, (area_t) { .x = wibox->geometry.x,
960 .y = luaL_checknumber(L, -1),
961 .width = wibox->geometry.width,
962 .height = wibox->geometry.height });
963 return 0;
966 static int
967 luaA_wibox_get_y(lua_State *L, wibox_t *wibox)
969 lua_pushnumber(L, wibox->geometry.y);
970 return 1;
973 static int
974 luaA_wibox_set_width(lua_State *L, wibox_t *wibox)
976 int width = luaL_checknumber(L, -1);
977 if(width <= 0)
978 luaL_error(L, "invalid width");
979 wibox_moveresize(L, -3, (area_t) { .x = wibox->geometry.x,
980 .y = wibox->geometry.y,
981 .width = width,
982 .height = wibox->geometry.height });
983 return 0;
986 static int
987 luaA_wibox_get_width(lua_State *L, wibox_t *wibox)
989 lua_pushnumber(L, wibox->geometry.width);
990 return 1;
993 static int
994 luaA_wibox_set_height(lua_State *L, wibox_t *wibox)
996 int height = luaL_checknumber(L, -1);
997 if(height <= 0)
998 luaL_error(L, "invalid height");
999 wibox_moveresize(L, -3, (area_t) { .x = wibox->geometry.x,
1000 .y = wibox->geometry.y,
1001 .width = wibox->geometry.width,
1002 .height = height });
1003 return 0;
1006 static int
1007 luaA_wibox_get_height(lua_State *L, wibox_t *wibox)
1009 lua_pushnumber(L, wibox->geometry.height);
1010 return 1;
1013 /** Set the wibox foreground color.
1014 * \param L The Lua VM state.
1015 * \param wibox The wibox object.
1016 * \return The number of elements pushed on stack.
1018 static int
1019 luaA_wibox_set_fg(lua_State *L, wibox_t *wibox)
1021 size_t len;
1022 const char *buf = luaL_checklstring(L, -1, &len);
1023 if(xcolor_init_reply(xcolor_init_unchecked(&wibox->ctx.fg, buf, len)))
1024 wibox->need_update = true;
1025 luaA_object_emit_signal(L, -3, "property::fg", 0);
1026 return 0;
1029 /** Get the wibox foreground color.
1030 * \param L The Lua VM state.
1031 * \param wibox The wibox object.
1032 * \return The number of elements pushed on stack.
1034 static int
1035 luaA_wibox_get_fg(lua_State *L, wibox_t *wibox)
1037 return luaA_pushxcolor(L, wibox->ctx.fg);
1040 /** Set the wibox background color.
1041 * \param L The Lua VM state.
1042 * \param wibox The wibox object.
1043 * \return The number of elements pushed on stack.
1045 static int
1046 luaA_wibox_set_bg(lua_State *L, wibox_t *wibox)
1048 size_t len;
1049 const char *buf = luaL_checklstring(L, -1, &len);
1050 if(xcolor_init_reply(xcolor_init_unchecked(&wibox->ctx.bg, buf, len)))
1052 uint32_t mask = XCB_CW_BACK_PIXEL;
1053 uint32_t values[] = { wibox->ctx.bg.pixel };
1055 wibox->need_update = true;
1056 xcb_change_window_attributes(globalconf.connection,
1057 wibox->window,
1058 mask,
1059 values);
1061 luaA_object_emit_signal(L, -3, "property::bg", 0);
1062 return 0;
1065 /** Get the wibox background color.
1066 * \param L The Lua VM state.
1067 * \param wibox The wibox object.
1068 * \return The number of elements pushed on stack.
1070 static int
1071 luaA_wibox_get_bg(lua_State *L, wibox_t *wibox)
1073 return luaA_pushxcolor(L, wibox->ctx.bg);
1076 /** Set the wibox background image.
1077 * \param L The Lua VM state.
1078 * \param wibox The wibox object.
1079 * \return The number of elements pushed on stack.
1081 static int
1082 luaA_wibox_set_bg_image(lua_State *L, wibox_t *wibox)
1084 luaA_checkudata(L, -1, &image_class);
1085 luaA_object_unref_item(L, -3, wibox->bg_image);
1086 wibox->bg_image = luaA_object_ref_item(L, -3, -1);
1087 wibox->need_update = true;
1088 luaA_object_emit_signal(L, -2, "property::bg_image", 0);
1089 return 0;
1092 /** Get the wibox background image.
1093 * \param L The Lua VM state.
1094 * \param wibox The wibox object.
1095 * \return The number of elements pushed on stack.
1097 static int
1098 luaA_wibox_get_bg_image(lua_State *L, wibox_t *wibox)
1100 return luaA_object_push_item(L, 1, wibox->bg_image);
1103 /** Set the wibox on top status.
1104 * \param L The Lua VM state.
1105 * \param wibox The wibox object.
1106 * \return The number of elements pushed on stack.
1108 static int
1109 luaA_wibox_set_ontop(lua_State *L, wibox_t *wibox)
1111 bool b = luaA_checkboolean(L, -1);
1112 if(b != wibox->ontop)
1114 wibox->ontop = b;
1115 client_stack();
1116 luaA_object_emit_signal(L, -3, "property::ontop", 0);
1118 return 0;
1121 /** Set the wibox opacity.
1122 * \param L The Lua VM state.
1123 * \param wibox The wibox object.
1124 * \return The number of elements pushed on stack.
1126 static int
1127 luaA_wibox_set_opacity(lua_State *L, wibox_t *wibox)
1129 if(lua_isnil(L, -1))
1130 wibox_set_opacity(L, -3, -1);
1131 else
1133 double d = luaL_checknumber(L, -1);
1134 if(d >= 0 && d <= 1)
1135 wibox_set_opacity(L, -3, d);
1137 return 0;
1140 /** Get the wibox opacity.
1141 * \param L The Lua VM state.
1142 * \param wibox The wibox object.
1143 * \return The number of elements pushed on stack.
1145 static int
1146 luaA_wibox_get_opacity(lua_State *L, wibox_t *wibox)
1148 if (wibox->opacity >= 0)
1150 lua_pushnumber(L, wibox->opacity);
1151 return 1;
1153 return 0;
1156 /** Set the wibox alignment.
1157 * \param L The Lua VM state.
1158 * \param wibox The wibox object.
1159 * \return The number of elements pushed on stack.
1161 static int
1162 luaA_wibox_set_align(lua_State *L, wibox_t *wibox)
1164 size_t len;
1165 const char *buf = luaL_checklstring(L, -1, &len);
1166 wibox->align = draw_align_fromstr(buf, len);
1167 luaA_object_emit_signal(L, -3, "property::align", 0);
1168 switch(wibox->type)
1170 case WIBOX_TYPE_NORMAL:
1171 luaA_deprecate(L, "awful.wibox.align");
1172 break;
1173 case WIBOX_TYPE_TITLEBAR:
1174 titlebar_update_geometry(client_getbytitlebar(wibox));
1175 break;
1177 return 0;
1180 /** Get the wibox alignment.
1181 * \param L The Lua VM state.
1182 * \param wibox The wibox object.
1183 * \return The number of elements pushed on stack.
1185 static int
1186 luaA_wibox_get_align(lua_State *L, wibox_t *wibox)
1188 if(wibox->type == WIBOX_TYPE_NORMAL)
1189 luaA_deprecate(L, "awful.wibox.align");
1190 lua_pushstring(L, draw_align_tostr(wibox->align));
1191 return 1;
1194 /** Set the wibox position.
1195 * \param L The Lua VM state.
1196 * \param wibox The wibox object.
1197 * \return The number of elements pushed on stack.
1199 static int
1200 luaA_wibox_set_position(lua_State *L, wibox_t *wibox)
1202 switch(wibox->type)
1204 case WIBOX_TYPE_NORMAL:
1206 size_t len;
1207 const char *buf;
1208 if((buf = luaL_checklstring(L, -1, &len)))
1210 luaA_deprecate(L, "awful.wibox.attach");
1211 wibox->position = position_fromstr(buf, len);
1214 break;
1215 case WIBOX_TYPE_TITLEBAR:
1216 return luaA_titlebar_set_position(L, -3);
1218 return 0;
1221 /** Get the wibox position.
1222 * \param L The Lua VM state.
1223 * \param wibox The wibox object.
1224 * \return The number of elements pushed on stack.
1226 static int
1227 luaA_wibox_get_position(lua_State *L, wibox_t *wibox)
1229 if(wibox->type == WIBOX_TYPE_NORMAL)
1230 luaA_deprecate(L, "awful.wibox.attach");
1231 lua_pushstring(L, position_tostr(wibox->position));
1232 return 1;
1235 /** Set the wibox (titlebar) client.
1236 * \param L The Lua VM state.
1237 * \param wibox The wibox object.
1238 * \return The number of elements pushed on stack.
1240 static int
1241 luaA_wibox_set_client(lua_State *L, wibox_t *wibox)
1243 /* first detach */
1244 if(lua_isnil(L, -1))
1245 titlebar_client_detach(client_getbytitlebar(wibox));
1246 else
1248 client_t *c = luaA_client_checkudata(L, -1);
1249 lua_pushvalue(L, -3);
1250 titlebar_client_attach(c);
1252 return 0;
1255 /** Get the wibox (titlebar) client.
1256 * \param L The Lua VM state.
1257 * \param wibox The wibox object.
1258 * \return The number of elements pushed on stack.
1260 static int
1261 luaA_wibox_get_client(lua_State *L, wibox_t *wibox)
1263 return luaA_object_push(L, client_getbytitlebar(wibox));
1266 /** Set the wibox cursor.
1267 * \param L The Lua VM state.
1268 * \param wibox The wibox object.
1269 * \return The number of elements pushed on stack.
1271 static int
1272 luaA_wibox_set_cursor(lua_State *L, wibox_t *wibox)
1274 const char *buf = luaL_checkstring(L, -1);
1275 if(buf)
1277 uint16_t cursor_font = xcursor_font_fromstr(buf);
1278 if(cursor_font)
1280 xcb_cursor_t cursor = xcursor_new(globalconf.connection, cursor_font);
1281 p_delete(&wibox->cursor);
1282 wibox->cursor = a_strdup(buf);
1283 window_set_cursor(wibox->window, cursor);
1284 luaA_object_emit_signal(L, -3, "property::cursor", 0);
1287 return 0;
1290 /** Set the wibox screen.
1291 * \param L The Lua VM state.
1292 * \param wibox The wibox object.
1293 * \return The number of elements pushed on stack.
1295 static int
1296 luaA_wibox_set_screen(lua_State *L, wibox_t *wibox)
1298 if(lua_isnil(L, -1))
1300 wibox_detach(L, -3);
1301 titlebar_client_detach(client_getbytitlebar(wibox));
1303 else
1305 int screen = luaL_checknumber(L, -1) - 1;
1306 luaA_checkscreen(screen);
1307 if(!wibox->screen || screen != screen_array_indexof(&globalconf.screens, wibox->screen))
1309 titlebar_client_detach(client_getbytitlebar(wibox));
1310 wibox_attach(L, -3, &globalconf.screens.tab[screen]);
1313 return 0;
1316 /** Get the wibox screen.
1317 * \param L The Lua VM state.
1318 * \param wibox The wibox object.
1319 * \return The number of elements pushed on stack.
1321 static int
1322 luaA_wibox_get_screen(lua_State *L, wibox_t *wibox)
1324 if(!wibox->screen)
1325 return 0;
1326 lua_pushnumber(L, screen_array_indexof(&globalconf.screens, wibox->screen) + 1);
1327 return 1;
1330 /** Set the wibox orientation.
1331 * \param L The Lua VM state.
1332 * \param wibox The wibox object.
1333 * \return The number of elements pushed on stack.
1335 static int
1336 luaA_wibox_set_orientation(lua_State *L, wibox_t *wibox)
1338 size_t len;
1339 const char *buf = luaL_checklstring(L, -1, &len);
1340 if(buf)
1342 wibox_set_orientation(L, -3, orientation_fromstr(buf, len));
1343 wibox_need_update(wibox);
1345 return 0;
1348 /** Get the wibox orientation.
1349 * \param L The Lua VM state.
1350 * \param wibox The wibox object.
1351 * \return The number of elements pushed on stack.
1353 static int
1354 luaA_wibox_get_orientation(lua_State *L, wibox_t *wibox)
1356 lua_pushstring(L, orientation_tostr(wibox->orientation));
1357 return 1;
1360 /** Set the wibox border color.
1361 * \param L The Lua VM state.
1362 * \param wibox The wibox object.
1363 * \return The number of elements pushed on stack.
1365 static int
1366 luaA_wibox_set_border_color(lua_State *L, wibox_t *wibox)
1368 size_t len;
1369 const char *buf = luaL_checklstring(L, -1, &len);
1370 if(buf)
1371 if(xcolor_init_reply(xcolor_init_unchecked(&wibox->border_color, buf, len)))
1372 if(wibox->window)
1373 wibox_set_border_color(L, -3, &wibox->border_color);
1374 return 0;
1377 /** Set the wibox visibility.
1378 * \param L The Lua VM state.
1379 * \param wibox The wibox object.
1380 * \return The number of elements pushed on stack.
1382 static int
1383 luaA_wibox_set_visible(lua_State *L, wibox_t *wibox)
1385 bool b = luaA_checkboolean(L, -1);
1386 if(b != wibox->visible)
1387 switch(wibox->type)
1389 case WIBOX_TYPE_NORMAL:
1390 wibox_set_visible(L, -3, b);
1391 break;
1392 case WIBOX_TYPE_TITLEBAR:
1393 titlebar_set_visible(wibox, b);
1394 break;
1396 return 0;
1399 /** Set the wibox widgets.
1400 * \param L The Lua VM state.
1401 * \param wibox The wibox object.
1402 * \return The number of elements pushed on stack.
1404 static int
1405 luaA_wibox_set_widgets(lua_State *L, wibox_t *wibox)
1407 if(luaA_isloop(L, -1))
1409 luaA_warn(L, "table is looping, cannot use this as widget table");
1410 return 0;
1412 /* duplicate table because next function will eat it */
1413 lua_pushvalue(L, -1);
1414 wibox->widgets_table = luaA_object_ref_item(L, -4, -1);
1415 luaA_object_emit_signal(L, -3, "property::widgets", 0);
1416 wibox_need_update(wibox);
1417 luaA_table2wtable(L);
1418 return 0;
1421 /** Get the wibox widgets.
1422 * \param L The Lua VM state.
1423 * \param wibox The wibox object.
1424 * \return The number of elements pushed on stack.
1426 static int
1427 luaA_wibox_get_widgets(lua_State *L, wibox_t *wibox)
1429 return luaA_object_push_item(L, 1, wibox->widgets_table);
1432 /** Get or set mouse buttons bindings to a wibox.
1433 * \param L The Lua VM state.
1434 * \luastack
1435 * \lvalue A wibox.
1436 * \lparam An array of mouse button bindings objects, or nothing.
1437 * \return The array of mouse button bindings objects of this wibox.
1439 static int
1440 luaA_wibox_buttons(lua_State *L)
1442 wibox_t *wibox = luaA_checkudata(L, 1, &wibox_class);
1444 if(lua_gettop(L) == 2)
1446 luaA_button_array_set(L, 1, 2, &wibox->buttons);
1447 luaA_object_emit_signal(L, 1, "property::buttons", 0);
1450 return luaA_button_array_get(L, 1, &wibox->buttons);
1453 /** Set the wibox border width.
1454 * \param L The Lua VM state.
1455 * \param wibox The wibox object.
1456 * \return The number of elements pushed on stack.
1458 static int
1459 luaA_wibox_set_border_width(lua_State *L, wibox_t *wibox)
1461 wibox_t *w = luaA_checkudata(L, -3, &wibox_class);
1462 uint32_t border_width = luaL_checknumber(L, -1);
1463 if(border_width != w->border_width)
1465 xcb_configure_window(globalconf.connection, w->window, XCB_CONFIG_WINDOW_BORDER_WIDTH,
1466 &border_width);
1467 w->border_width = border_width;
1468 /* Need update if transparent background */
1469 wibox_need_update(w);
1470 luaA_object_emit_signal(L, -3, "property::border_width", 0);
1472 return 0;
1475 static int
1476 luaA_wibox_set_shape_bounding(lua_State *L, wibox_t *wibox)
1478 luaA_checkudata(L, -1, &image_class);
1479 luaA_object_unref_item(L, -3, wibox->shape.bounding);
1480 wibox->shape.bounding = luaA_object_ref_item(L, -3, -1);
1481 wibox->need_shape_update = true;
1482 luaA_object_emit_signal(L, -2, "property::shape_bounding", 0);
1483 return 0;
1486 static int
1487 luaA_wibox_get_shape_bounding(lua_State *L, wibox_t *wibox)
1489 return luaA_object_push_item(L, 1, wibox->shape.bounding);
1492 static int
1493 luaA_wibox_set_shape_clip(lua_State *L, wibox_t *wibox)
1495 luaA_checkudata(L, -1, &image_class);
1496 luaA_object_unref_item(L, -3, wibox->shape.clip);
1497 wibox->shape.clip = luaA_object_ref_item(L, -3, -1);
1498 wibox->need_shape_update = true;
1499 luaA_object_emit_signal(L, -2, "property::shape_clip", 0);
1500 return 0;
1503 static int
1504 luaA_wibox_get_shape_clip(lua_State *L, wibox_t *wibox)
1506 return luaA_object_push_item(L, 1, wibox->shape.clip);
1509 void
1510 wibox_class_setup(lua_State *L)
1512 static const struct luaL_reg wibox_methods[] =
1514 LUA_CLASS_METHODS(wibox)
1515 { "__call", luaA_wibox_new },
1516 { NULL, NULL }
1519 static const struct luaL_reg wibox_meta[] =
1521 LUA_OBJECT_META(wibox)
1522 LUA_CLASS_META
1523 { "struts", luaA_wibox_struts },
1524 { "buttons", luaA_wibox_buttons },
1525 { "geometry", luaA_wibox_geometry },
1526 { "__gc", luaA_wibox_gc },
1527 { NULL, NULL },
1530 luaA_class_setup(L, &wibox_class, "wibox", (lua_class_allocator_t) wibox_new,
1531 luaA_class_index_miss_property, luaA_class_newindex_miss_property,
1532 wibox_methods, wibox_meta);
1533 luaA_class_add_property(&wibox_class, A_TK_WIDGETS,
1534 (lua_class_propfunc_t) luaA_wibox_set_widgets,
1535 (lua_class_propfunc_t) luaA_wibox_get_widgets,
1536 (lua_class_propfunc_t) luaA_wibox_set_widgets);
1537 luaA_class_add_property(&wibox_class, A_TK_OPACITY,
1538 (lua_class_propfunc_t) luaA_wibox_set_opacity,
1539 (lua_class_propfunc_t) luaA_wibox_get_opacity,
1540 (lua_class_propfunc_t) luaA_wibox_set_opacity);
1541 luaA_class_add_property(&wibox_class, A_TK_VISIBLE,
1542 (lua_class_propfunc_t) luaA_wibox_set_visible,
1543 (lua_class_propfunc_t) luaA_wibox_get_visible,
1544 (lua_class_propfunc_t) luaA_wibox_set_visible);
1545 luaA_class_add_property(&wibox_class, A_TK_BORDER_COLOR,
1546 (lua_class_propfunc_t) luaA_wibox_set_border_color,
1547 (lua_class_propfunc_t) luaA_wibox_get_border_color,
1548 (lua_class_propfunc_t) luaA_wibox_set_border_color);
1549 luaA_class_add_property(&wibox_class, A_TK_BORDER_WIDTH,
1550 (lua_class_propfunc_t) luaA_wibox_set_border_width,
1551 (lua_class_propfunc_t) luaA_wibox_get_border_width,
1552 (lua_class_propfunc_t) luaA_wibox_set_border_width);
1553 luaA_class_add_property(&wibox_class, A_TK_ORIENTATION,
1554 (lua_class_propfunc_t) luaA_wibox_set_orientation,
1555 (lua_class_propfunc_t) luaA_wibox_get_orientation,
1556 (lua_class_propfunc_t) luaA_wibox_set_orientation);
1557 luaA_class_add_property(&wibox_class, A_TK_ONTOP,
1558 (lua_class_propfunc_t) luaA_wibox_set_ontop,
1559 (lua_class_propfunc_t) luaA_wibox_get_ontop,
1560 (lua_class_propfunc_t) luaA_wibox_set_ontop);
1561 luaA_class_add_property(&wibox_class, A_TK_SCREEN,
1562 NULL,
1563 (lua_class_propfunc_t) luaA_wibox_get_screen,
1564 (lua_class_propfunc_t) luaA_wibox_set_screen);
1565 luaA_class_add_property(&wibox_class, A_TK_CURSOR,
1566 (lua_class_propfunc_t) luaA_wibox_set_cursor,
1567 (lua_class_propfunc_t) luaA_wibox_get_cursor,
1568 (lua_class_propfunc_t) luaA_wibox_set_cursor);
1569 luaA_class_add_property(&wibox_class, A_TK_CLIENT,
1570 (lua_class_propfunc_t) luaA_wibox_set_client,
1571 (lua_class_propfunc_t) luaA_wibox_get_client,
1572 (lua_class_propfunc_t) luaA_wibox_set_client);
1573 luaA_class_add_property(&wibox_class, A_TK_POSITION,
1574 (lua_class_propfunc_t) luaA_wibox_set_position,
1575 (lua_class_propfunc_t) luaA_wibox_get_position,
1576 (lua_class_propfunc_t) luaA_wibox_set_position);
1577 luaA_class_add_property(&wibox_class, A_TK_ALIGN,
1578 (lua_class_propfunc_t) luaA_wibox_set_align,
1579 (lua_class_propfunc_t) luaA_wibox_get_align,
1580 (lua_class_propfunc_t) luaA_wibox_set_align);
1581 luaA_class_add_property(&wibox_class, A_TK_FG,
1582 (lua_class_propfunc_t) luaA_wibox_set_fg,
1583 (lua_class_propfunc_t) luaA_wibox_get_fg,
1584 (lua_class_propfunc_t) luaA_wibox_set_fg);
1585 luaA_class_add_property(&wibox_class, A_TK_BG,
1586 (lua_class_propfunc_t) luaA_wibox_set_bg,
1587 (lua_class_propfunc_t) luaA_wibox_get_bg,
1588 (lua_class_propfunc_t) luaA_wibox_set_bg);
1589 luaA_class_add_property(&wibox_class, A_TK_BG_IMAGE,
1590 (lua_class_propfunc_t) luaA_wibox_set_bg_image,
1591 (lua_class_propfunc_t) luaA_wibox_get_bg_image,
1592 (lua_class_propfunc_t) luaA_wibox_set_bg_image);
1593 luaA_class_add_property(&wibox_class, A_TK_X,
1594 (lua_class_propfunc_t) luaA_wibox_set_x,
1595 (lua_class_propfunc_t) luaA_wibox_get_x,
1596 (lua_class_propfunc_t) luaA_wibox_set_x);
1597 luaA_class_add_property(&wibox_class, A_TK_Y,
1598 (lua_class_propfunc_t) luaA_wibox_set_y,
1599 (lua_class_propfunc_t) luaA_wibox_get_y,
1600 (lua_class_propfunc_t) luaA_wibox_set_y);
1601 luaA_class_add_property(&wibox_class, A_TK_WIDTH,
1602 (lua_class_propfunc_t) luaA_wibox_set_width,
1603 (lua_class_propfunc_t) luaA_wibox_get_width,
1604 (lua_class_propfunc_t) luaA_wibox_set_width);
1605 luaA_class_add_property(&wibox_class, A_TK_HEIGHT,
1606 (lua_class_propfunc_t) luaA_wibox_set_height,
1607 (lua_class_propfunc_t) luaA_wibox_get_height,
1608 (lua_class_propfunc_t) luaA_wibox_set_height);
1609 luaA_class_add_property(&wibox_class, A_TK_SHAPE_BOUNDING,
1610 (lua_class_propfunc_t) luaA_wibox_set_shape_bounding,
1611 (lua_class_propfunc_t) luaA_wibox_get_shape_bounding,
1612 (lua_class_propfunc_t) luaA_wibox_set_shape_bounding);
1613 luaA_class_add_property(&wibox_class, A_TK_SHAPE_CLIP,
1614 (lua_class_propfunc_t) luaA_wibox_set_shape_clip,
1615 (lua_class_propfunc_t) luaA_wibox_get_shape_clip,
1616 (lua_class_propfunc_t) luaA_wibox_set_shape_clip);
1619 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80