wibox: Set a proper back pixel
[awesome.git] / wibox.c
blob392e8ed4b9a280106266446fa4f5aeaee15cfcbe
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
170 | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK,
171 (const uint32_t [])
173 w->ctx.bg.pixel,
174 w->border_color.pixel,
176 XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT
177 | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_ENTER_WINDOW
178 | XCB_EVENT_MASK_LEAVE_WINDOW | XCB_EVENT_MASK_STRUCTURE_NOTIFY
179 | XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE
180 | XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE
181 | XCB_EVENT_MASK_PROPERTY_CHANGE
184 /* Create a pixmap. */
185 w->pixmap = xcb_generate_id(globalconf.connection);
186 xcb_create_pixmap(globalconf.connection, s->root_depth, w->pixmap, s->root,
187 w->geometry.width, w->geometry.height);
189 /* Update draw context physical screen, important for Zaphod. */
190 w->ctx.phys_screen = phys_screen;
191 wibox_draw_context_update(w, s);
193 /* The default GC is just a newly created associated to the root window */
194 w->gc = xcb_generate_id(globalconf.connection);
195 xcb_create_gc(globalconf.connection, w->gc, s->root, XCB_GC_FOREGROUND | XCB_GC_BACKGROUND,
196 (const uint32_t[]) { s->black_pixel, s->white_pixel });
198 wibox_shape_update(w);
201 /** Refresh the window content by copying its pixmap data to its window.
202 * \param w The wibox to refresh.
204 static inline void
205 wibox_refresh_pixmap(wibox_t *w)
207 wibox_refresh_pixmap_partial(w, 0, 0, w->geometry.width, w->geometry.height);
210 /** Move and/or resize a wibox
211 * \param L The Lua VM state.
212 * \param udx The index of the wibox.
213 * \param geometry The new geometry.
215 void
216 wibox_moveresize(lua_State *L, int udx, area_t geometry)
218 wibox_t *w = luaA_checkudata(L, udx, &wibox_class);
219 if(w->window)
221 int number_of_vals = 0;
222 uint32_t moveresize_win_vals[4], mask_vals = 0;
224 if(w->geometry.x != geometry.x)
226 w->geometry.x = moveresize_win_vals[number_of_vals++] = geometry.x;
227 mask_vals |= XCB_CONFIG_WINDOW_X;
230 if(w->geometry.y != geometry.y)
232 w->geometry.y = moveresize_win_vals[number_of_vals++] = geometry.y;
233 mask_vals |= XCB_CONFIG_WINDOW_Y;
236 if(geometry.width > 0 && w->geometry.width != geometry.width)
238 w->geometry.width = moveresize_win_vals[number_of_vals++] = geometry.width;
239 mask_vals |= XCB_CONFIG_WINDOW_WIDTH;
242 if(geometry.height > 0 && w->geometry.height != geometry.height)
244 w->geometry.height = moveresize_win_vals[number_of_vals++] = geometry.height;
245 mask_vals |= XCB_CONFIG_WINDOW_HEIGHT;
248 if(mask_vals & (XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT))
250 xcb_free_pixmap(globalconf.connection, w->pixmap);
251 /* orientation != East */
252 if(w->pixmap != w->ctx.pixmap)
253 xcb_free_pixmap(globalconf.connection, w->ctx.pixmap);
254 w->pixmap = xcb_generate_id(globalconf.connection);
255 xcb_screen_t *s = xutil_screen_get(globalconf.connection, w->ctx.phys_screen);
256 xcb_create_pixmap(globalconf.connection, s->root_depth, w->pixmap, s->root,
257 w->geometry.width, w->geometry.height);
258 wibox_draw_context_update(w, s);
261 /* Activate BMA */
262 client_ignore_enterleave_events();
264 if(mask_vals)
265 xcb_configure_window(globalconf.connection, w->window, mask_vals, moveresize_win_vals);
267 /* Deactivate BMA */
268 client_restore_enterleave_events();
270 w->screen = screen_getbycoord(w->screen, w->geometry.x, w->geometry.y);
272 if(mask_vals & XCB_CONFIG_WINDOW_X)
273 luaA_object_emit_signal(L, udx, "property::x", 0);
274 if(mask_vals & XCB_CONFIG_WINDOW_Y)
275 luaA_object_emit_signal(L, udx, "property::y", 0);
276 if(mask_vals & XCB_CONFIG_WINDOW_WIDTH)
277 luaA_object_emit_signal(L, udx, "property::width", 0);
278 if(mask_vals & XCB_CONFIG_WINDOW_HEIGHT)
279 luaA_object_emit_signal(L, udx, "property::height", 0);
281 else
283 #define DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(prop) \
284 if(w->geometry.prop != geometry.prop) \
286 w->geometry.prop = geometry.prop; \
287 luaA_object_emit_signal(L, udx, "property::" #prop, 0); \
289 DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(x)
290 DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(y)
291 DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(width)
292 DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(height)
293 #undef DO_WIBOX_GEOMETRY_CHECK_AND_EMIT
296 wibox_need_update(w);
299 /** Refresh the window content by copying its pixmap data to its window.
300 * \param wibox The wibox to refresh.
301 * \param x The copy starting point x component.
302 * \param y The copy starting point y component.
303 * \param w The copy width from the x component.
304 * \param h The copy height from the y component.
306 void
307 wibox_refresh_pixmap_partial(wibox_t *wibox,
308 int16_t x, int16_t y,
309 uint16_t w, uint16_t h)
311 xcb_copy_area(globalconf.connection, wibox->pixmap,
312 wibox->window, wibox->gc, x, y, x, y,
313 w, h);
316 void
317 wibox_set_opacity(lua_State *L, int udx, double opacity)
319 wibox_t *w = luaA_checkudata(L, udx, &wibox_class);
320 if(w->opacity != opacity)
322 w->opacity = opacity;
323 if(w->window)
324 window_opacity_set(w->window, opacity);
325 luaA_object_emit_signal(L, udx, "property::opacity", 0);
329 /** Set a wibox border color.
330 * \param L The Lua VM state.
331 * \param udx The wibox to change border width.
332 * \param color The border color.
334 static void
335 wibox_set_border_color(lua_State *L, int udx, const xcolor_t *color)
337 wibox_t *w = luaA_checkudata(L, udx, &wibox_class);
338 xcb_change_window_attributes(globalconf.connection, w->window,
339 XCB_CW_BORDER_PIXEL, &color->pixel);
340 w->border_color = *color;
341 luaA_object_emit_signal(L, udx, "property::border_color", 0);
344 /** Set wibox orientation.
345 * \param L The Lua VM state.
346 * \param udx The wibox to change orientation.
347 * \param o The new orientation.
349 void
350 wibox_set_orientation(lua_State *L, int udx, orientation_t o)
352 wibox_t *w = luaA_checkudata(L, udx, &wibox_class);
353 if(o != w->orientation)
355 xcb_screen_t *s = xutil_screen_get(globalconf.connection, w->ctx.phys_screen);
356 w->orientation = o;
357 /* orientation != East */
358 if(w->pixmap != w->ctx.pixmap)
359 xcb_free_pixmap(globalconf.connection, w->ctx.pixmap);
360 wibox_draw_context_update(w, s);
361 luaA_object_emit_signal(L, udx, "property::orientation", 0);
365 static void
366 wibox_map(wibox_t *wibox)
368 /* Activate BMA */
369 client_ignore_enterleave_events();
370 /* Map the wibox */
371 xcb_map_window(globalconf.connection, wibox->window);
372 /* Deactivate BMA */
373 client_restore_enterleave_events();
374 /* We must make sure the wibox does not display garbage */
375 wibox_need_update(wibox);
376 /* Stack this wibox correctly */
377 client_stack();
380 /** Kick out systray windows.
381 * \param phys_screen Physical screen number.
383 static void
384 wibox_systray_kickout(int phys_screen)
386 xcb_screen_t *s = xutil_screen_get(globalconf.connection, phys_screen);
388 if(globalconf.screens.tab[phys_screen].systray.parent != s->root)
390 /* Who! Check that we're not deleting a wibox with a systray, because it
391 * may be its parent. If so, we reparent to root before, otherwise it will
392 * hurt very much. */
393 xcb_reparent_window(globalconf.connection,
394 globalconf.screens.tab[phys_screen].systray.window,
395 s->root, -512, -512);
397 globalconf.screens.tab[phys_screen].systray.parent = s->root;
401 static void
402 wibox_systray_refresh(wibox_t *wibox)
404 if(!wibox->screen)
405 return;
407 for(int i = 0; i < wibox->widgets.len; i++)
409 widget_node_t *systray = &wibox->widgets.tab[i];
410 if(systray->widget->type == widget_systray)
412 uint32_t config_back[] = { wibox->ctx.bg.pixel };
413 uint32_t config_win_vals[4];
414 uint32_t config_win_vals_off[2] = { -512, -512 };
415 xembed_window_t *em;
416 int phys_screen = wibox->ctx.phys_screen;
418 if(wibox->visible
419 && systray->widget->isvisible
420 && systray->geometry.width)
422 /* Set background of the systray window. */
423 xcb_change_window_attributes(globalconf.connection,
424 globalconf.screens.tab[phys_screen].systray.window,
425 XCB_CW_BACK_PIXEL, config_back);
426 /* Map it. */
427 xcb_map_window(globalconf.connection, globalconf.screens.tab[phys_screen].systray.window);
428 /* Move it. */
429 switch(wibox->orientation)
431 case North:
432 config_win_vals[0] = systray->geometry.y;
433 config_win_vals[1] = wibox->geometry.height - systray->geometry.x - systray->geometry.width;
434 config_win_vals[2] = systray->geometry.height;
435 config_win_vals[3] = systray->geometry.width;
436 break;
437 case South:
438 config_win_vals[0] = systray->geometry.y;
439 config_win_vals[1] = systray->geometry.x;
440 config_win_vals[2] = systray->geometry.height;
441 config_win_vals[3] = systray->geometry.width;
442 break;
443 case East:
444 config_win_vals[0] = systray->geometry.x;
445 config_win_vals[1] = systray->geometry.y;
446 config_win_vals[2] = systray->geometry.width;
447 config_win_vals[3] = systray->geometry.height;
448 break;
450 /* reparent */
451 if(globalconf.screens.tab[phys_screen].systray.parent != wibox->window)
453 xcb_reparent_window(globalconf.connection,
454 globalconf.screens.tab[phys_screen].systray.window,
455 wibox->window,
456 config_win_vals[0], config_win_vals[1]);
457 globalconf.screens.tab[phys_screen].systray.parent = wibox->window;
459 xcb_configure_window(globalconf.connection,
460 globalconf.screens.tab[phys_screen].systray.window,
461 XCB_CONFIG_WINDOW_X
462 | XCB_CONFIG_WINDOW_Y
463 | XCB_CONFIG_WINDOW_WIDTH
464 | XCB_CONFIG_WINDOW_HEIGHT,
465 config_win_vals);
466 /* width = height = systray height */
467 config_win_vals[2] = config_win_vals[3] = systray->geometry.height;
468 config_win_vals[0] = 0;
470 else
471 return wibox_systray_kickout(phys_screen);
473 switch(wibox->orientation)
475 case North:
476 config_win_vals[1] = systray->geometry.width - config_win_vals[3];
477 for(int j = 0; j < globalconf.embedded.len; j++)
479 em = &globalconf.embedded.tab[j];
480 if(em->phys_screen == phys_screen)
482 if(config_win_vals[1] - config_win_vals[2] >= (uint32_t) wibox->geometry.y)
484 xcb_map_window(globalconf.connection, em->win);
485 xcb_configure_window(globalconf.connection, em->win,
486 XCB_CONFIG_WINDOW_X
487 | XCB_CONFIG_WINDOW_Y
488 | XCB_CONFIG_WINDOW_WIDTH
489 | XCB_CONFIG_WINDOW_HEIGHT,
490 config_win_vals);
491 config_win_vals[1] -= config_win_vals[3];
493 else
494 xcb_configure_window(globalconf.connection, em->win,
495 XCB_CONFIG_WINDOW_X
496 | XCB_CONFIG_WINDOW_Y,
497 config_win_vals_off);
500 break;
501 case South:
502 config_win_vals[1] = 0;
503 for(int j = 0; j < globalconf.embedded.len; j++)
505 em = &globalconf.embedded.tab[j];
506 if(em->phys_screen == phys_screen)
508 /* if(y + width <= wibox.y + systray.right) */
509 if(config_win_vals[1] + config_win_vals[3] <= (uint32_t) wibox->geometry.y + AREA_RIGHT(systray->geometry))
511 xcb_map_window(globalconf.connection, em->win);
512 xcb_configure_window(globalconf.connection, em->win,
513 XCB_CONFIG_WINDOW_X
514 | XCB_CONFIG_WINDOW_Y
515 | XCB_CONFIG_WINDOW_WIDTH
516 | XCB_CONFIG_WINDOW_HEIGHT,
517 config_win_vals);
518 config_win_vals[1] += config_win_vals[3];
520 else
521 xcb_configure_window(globalconf.connection, em->win,
522 XCB_CONFIG_WINDOW_X
523 | XCB_CONFIG_WINDOW_Y,
524 config_win_vals_off);
527 break;
528 case East:
529 config_win_vals[1] = 0;
530 for(int j = 0; j < globalconf.embedded.len; j++)
532 em = &globalconf.embedded.tab[j];
533 if(em->phys_screen == phys_screen)
535 /* if(x + width < systray.x + systray.width) */
536 if(config_win_vals[0] + config_win_vals[2] <= (uint32_t) AREA_RIGHT(systray->geometry) + wibox->geometry.x)
538 xcb_map_window(globalconf.connection, em->win);
539 xcb_configure_window(globalconf.connection, em->win,
540 XCB_CONFIG_WINDOW_X
541 | XCB_CONFIG_WINDOW_Y
542 | XCB_CONFIG_WINDOW_WIDTH
543 | XCB_CONFIG_WINDOW_HEIGHT,
544 config_win_vals);
545 config_win_vals[0] += config_win_vals[2];
547 else
548 xcb_configure_window(globalconf.connection, em->win,
549 XCB_CONFIG_WINDOW_X
550 | XCB_CONFIG_WINDOW_Y,
551 config_win_vals_off);
554 break;
556 break;
561 /** Get a wibox by its window.
562 * \param win The window id.
563 * \return A wibox if found, NULL otherwise.
565 wibox_t *
566 wibox_getbywin(xcb_window_t win)
568 foreach(w, globalconf.wiboxes)
569 if((*w)->window == win)
570 return *w;
572 foreach(_c, globalconf.clients)
574 client_t *c = *_c;
575 if(c->titlebar && c->titlebar->window == win)
576 return c->titlebar;
579 return NULL;
582 /** Draw a wibox.
583 * \param wibox The wibox to draw.
585 static void
586 wibox_draw(wibox_t *wibox)
588 if(wibox->visible)
590 widget_render(wibox);
591 wibox_refresh_pixmap(wibox);
593 wibox->need_update = false;
596 wibox_systray_refresh(wibox);
599 /** Refresh all wiboxes.
601 void
602 wibox_refresh(void)
604 foreach(w, globalconf.wiboxes)
606 if((*w)->need_shape_update)
607 wibox_shape_update(*w);
608 if((*w)->need_update)
609 wibox_draw(*w);
612 foreach(_c, globalconf.clients)
614 client_t *c = *_c;
615 if(c->titlebar && c->titlebar->need_update)
616 wibox_draw(c->titlebar);
620 /** Set a wibox visible or not.
621 * \param L The Lua VM state.
622 * \param udx The wibox.
623 * \param v The visible value.
625 static void
626 wibox_set_visible(lua_State *L, int udx, bool v)
628 wibox_t *wibox = luaA_checkudata(L, udx, &wibox_class);
629 if(v != wibox->visible)
631 wibox->visible = v;
632 wibox->mouse_over = NULL;
634 if(wibox->screen)
636 if(wibox->visible)
637 wibox_map(wibox);
638 else
640 /* Active BMA */
641 client_ignore_enterleave_events();
642 /* Unmap window */
643 xcb_unmap_window(globalconf.connection, wibox->window);
644 /* Active BMA */
645 client_restore_enterleave_events();
648 /* kick out systray if needed */
649 wibox_systray_refresh(wibox);
652 luaA_object_emit_signal(L, udx, "property::visible", 0);
654 hook_property(wibox, "visible");
658 /** Destroy all X resources of a wibox.
659 * \param w The wibox to wipe.
661 void
662 wibox_wipe(wibox_t *w)
664 if(w->window)
666 /* Activate BMA */
667 client_ignore_enterleave_events();
668 xcb_destroy_window(globalconf.connection, w->window);
669 /* Deactivate BMA */
670 client_restore_enterleave_events();
671 w->window = XCB_NONE;
673 if(w->pixmap)
675 xcb_free_pixmap(globalconf.connection, w->pixmap);
676 w->pixmap = XCB_NONE;
678 if(w->gc)
680 xcb_free_gc(globalconf.connection, w->gc);
681 w->gc = XCB_NONE;
683 draw_context_wipe(&w->ctx);
686 /** Remove a wibox from a screen.
687 * \param L The Lua VM state.
688 * \param udx Wibox to detach from screen.
690 static void
691 wibox_detach(lua_State *L, int udx)
693 wibox_t *wibox = luaA_checkudata(L, udx, &wibox_class);
694 if(wibox->screen)
696 bool v;
698 /* save visible state */
699 v = wibox->visible;
700 wibox->visible = false;
701 wibox_systray_refresh(wibox);
702 /* restore visibility */
703 wibox->visible = v;
705 wibox->mouse_over = NULL;
707 wibox_wipe(wibox);
709 foreach(item, globalconf.wiboxes)
710 if(*item == wibox)
712 wibox_array_remove(&globalconf.wiboxes, item);
713 break;
716 hook_property(wibox, "screen");
718 if(strut_has_value(&wibox->strut))
719 screen_emit_signal(L, wibox->screen, "property::workarea", 0);
721 wibox->screen = NULL;
722 luaA_object_emit_signal(L, udx, "property::screen", 0);
724 luaA_object_unref(globalconf.L, wibox);
728 /** Attach a wibox that is on top of the stack.
729 * \param L The Lua VM state.
730 * \param udx The wibox to attach.
731 * \param s The screen to attach the wibox to.
733 static void
734 wibox_attach(lua_State *L, int udx, screen_t *s)
736 int phys_screen = screen_virttophys(screen_array_indexof(&globalconf.screens, s));
738 /* duplicate wibox */
739 lua_pushvalue(L, udx);
740 /* ref it */
741 wibox_t *wibox = luaA_object_ref_class(globalconf.L, -1, &wibox_class);
743 wibox_detach(L, udx);
745 /* Set the wibox screen */
746 wibox->screen = s;
748 /* Check that the wibox coordinates matches the screen. */
749 screen_t *cscreen =
750 screen_getbycoord(wibox->screen, wibox->geometry.x, wibox->geometry.y);
752 /* If it does not match, move it to the screen coordinates */
753 if(cscreen != wibox->screen)
754 wibox_moveresize(L, udx, (area_t) { .x = s->geometry.x,
755 .y = s->geometry.y,
756 .width = wibox->geometry.width,
757 .height = wibox->geometry.height });
759 wibox_array_append(&globalconf.wiboxes, wibox);
761 wibox_init(wibox, phys_screen);
763 window_set_cursor(wibox->window,
764 xcursor_new(globalconf.connection, xcursor_font_fromstr(wibox->cursor)));
766 if(wibox->opacity != -1)
767 window_opacity_set(wibox->window, wibox->opacity);
769 ewmh_update_strut(wibox->window, &wibox->strut);
771 if(wibox->visible)
772 wibox_map(wibox);
773 else
774 wibox_need_update(wibox);
776 hook_property(wibox, "screen");
777 luaA_object_emit_signal(L, udx, "property::screen", 0);
779 if(strut_has_value(&wibox->strut))
780 screen_emit_signal(L, wibox->screen, "property::workarea", 0);
783 /** Create a new wibox.
784 * \param L The Lua VM state.
786 * \luastack
787 * \lparam A table with optionally defined values:
788 * fg, bg, border_width, border_color, ontop, width and height.
789 * \lreturn A brand new wibox.
791 static int
792 luaA_wibox_new(lua_State *L)
794 luaA_class_new(L, &wibox_class);
796 wibox_t *w = luaA_checkudata(L, -1, &wibox_class);
798 if(!w->ctx.fg.initialized)
799 w->ctx.fg = globalconf.colors.fg;
801 if(!w->ctx.bg.initialized)
802 w->ctx.bg = globalconf.colors.bg;
804 if(!w->border_color.initialized)
805 w->border_color = globalconf.colors.bg;
807 w->visible = true;
809 if(!w->opacity)
810 w->opacity = -1;
812 if(!w->cursor)
813 w->cursor = a_strdup("left_ptr");
815 if(!w->geometry.width)
816 w->geometry.width = 1;
818 if(!w->geometry.height)
819 w->geometry.height = 1;
821 return 1;
824 /** Check if a wibox widget table has an item.
825 * \param L The Lua VM state.
826 * \param wibox The wibox.
827 * \param item The item to look for.
829 static bool
830 luaA_wibox_hasitem(lua_State *L, wibox_t *wibox, const void *item)
832 if(wibox->widgets_table)
834 luaA_object_push(L, wibox);
835 luaA_object_push_item(L, -1, wibox->widgets_table);
836 lua_remove(L, -2);
837 if(lua_topointer(L, -1) == item || luaA_hasitem(L, item))
838 return true;
840 return false;
843 /** Invalidate a wibox by a Lua object (table, etc).
844 * \param L The Lua VM state.
845 * \param item The object identifier.
847 void
848 luaA_wibox_invalidate_byitem(lua_State *L, const void *item)
850 foreach(w, globalconf.wiboxes)
852 wibox_t *wibox = *w;
853 if(luaA_wibox_hasitem(L, wibox, item))
855 /* update wibox */
856 wibox_need_update(wibox);
857 lua_pop(L, 1); /* remove widgets table */
862 foreach(_c, globalconf.clients)
864 client_t *c = *_c;
865 if(c->titlebar && luaA_wibox_hasitem(L, c->titlebar, item))
867 /* update wibox */
868 wibox_need_update(c->titlebar);
869 lua_pop(L, 1); /* remove widgets table */
874 /* Set or get the wibox geometry.
875 * \param L The Lua VM state.
876 * \return The number of elements pushed on stack.
877 * \luastack
878 * \lparam An optional table with wibox geometry.
879 * \lreturn The wibox geometry.
881 static int
882 luaA_wibox_geometry(lua_State *L)
884 wibox_t *wibox = luaA_checkudata(L, 1, &wibox_class);
886 if(lua_gettop(L) == 2)
888 area_t wingeom;
890 luaA_checktable(L, 2);
891 wingeom.x = luaA_getopt_number(L, 2, "x", wibox->geometry.x);
892 wingeom.y = luaA_getopt_number(L, 2, "y", wibox->geometry.y);
893 wingeom.width = luaA_getopt_number(L, 2, "width", wibox->geometry.width);
894 wingeom.height = luaA_getopt_number(L, 2, "height", wibox->geometry.height);
896 if(wingeom.width > 0 && wingeom.height > 0)
897 switch(wibox->type)
899 case WIBOX_TYPE_TITLEBAR:
900 wibox_moveresize(L, 1, (area_t) { .x = wibox->geometry.x,
901 .y = wibox->geometry.y,
902 .width = wingeom.width,
903 .height = wingeom.height });
904 break;
905 case WIBOX_TYPE_NORMAL:
906 wibox_moveresize(L, 1, wingeom);
907 break;
911 return luaA_pusharea(L, wibox->geometry);
914 static int
915 luaA_wibox_struts(lua_State *L)
917 wibox_t *w = luaA_checkudata(L, 1, &wibox_class);
919 if(lua_gettop(L) == 2)
921 luaA_tostrut(L, 2, &w->strut);
922 if(w->window)
923 ewmh_update_strut(w->window, &w->strut);
924 luaA_object_emit_signal(L, 1, "property::struts", 0);
925 if(w->screen)
926 screen_emit_signal(L, w->screen, "property::workarea", 0);
929 return luaA_pushstrut(L, w->strut);
932 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, ontop, lua_pushboolean)
933 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, cursor, lua_pushstring)
934 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, visible, lua_pushboolean)
935 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, border_width, lua_pushnumber)
936 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, border_color, luaA_pushxcolor)
938 static int
939 luaA_wibox_set_x(lua_State *L, wibox_t *wibox)
941 wibox_moveresize(L, -3, (area_t) { .x = luaL_checknumber(L, -1),
942 .y = wibox->geometry.y,
943 .width = wibox->geometry.width,
944 .height = wibox->geometry.height });
945 return 0;
948 static int
949 luaA_wibox_get_x(lua_State *L, wibox_t *wibox)
951 lua_pushnumber(L, wibox->geometry.x);
952 return 1;
955 static int
956 luaA_wibox_set_y(lua_State *L, wibox_t *wibox)
958 wibox_moveresize(L, -3, (area_t) { .x = wibox->geometry.x,
959 .y = luaL_checknumber(L, -1),
960 .width = wibox->geometry.width,
961 .height = wibox->geometry.height });
962 return 0;
965 static int
966 luaA_wibox_get_y(lua_State *L, wibox_t *wibox)
968 lua_pushnumber(L, wibox->geometry.y);
969 return 1;
972 static int
973 luaA_wibox_set_width(lua_State *L, wibox_t *wibox)
975 int width = luaL_checknumber(L, -1);
976 if(width <= 0)
977 luaL_error(L, "invalid width");
978 wibox_moveresize(L, -3, (area_t) { .x = wibox->geometry.x,
979 .y = wibox->geometry.y,
980 .width = width,
981 .height = wibox->geometry.height });
982 return 0;
985 static int
986 luaA_wibox_get_width(lua_State *L, wibox_t *wibox)
988 lua_pushnumber(L, wibox->geometry.width);
989 return 1;
992 static int
993 luaA_wibox_set_height(lua_State *L, wibox_t *wibox)
995 int height = luaL_checknumber(L, -1);
996 if(height <= 0)
997 luaL_error(L, "invalid height");
998 wibox_moveresize(L, -3, (area_t) { .x = wibox->geometry.x,
999 .y = wibox->geometry.y,
1000 .width = wibox->geometry.width,
1001 .height = height });
1002 return 0;
1005 static int
1006 luaA_wibox_get_height(lua_State *L, wibox_t *wibox)
1008 lua_pushnumber(L, wibox->geometry.height);
1009 return 1;
1012 /** Set the wibox foreground color.
1013 * \param L The Lua VM state.
1014 * \param wibox The wibox object.
1015 * \return The number of elements pushed on stack.
1017 static int
1018 luaA_wibox_set_fg(lua_State *L, wibox_t *wibox)
1020 size_t len;
1021 const char *buf = luaL_checklstring(L, -1, &len);
1022 if(xcolor_init_reply(xcolor_init_unchecked(&wibox->ctx.fg, buf, len)))
1023 wibox->need_update = true;
1024 luaA_object_emit_signal(L, -3, "property::fg", 0);
1025 return 0;
1028 /** Get the wibox foreground color.
1029 * \param L The Lua VM state.
1030 * \param wibox The wibox object.
1031 * \return The number of elements pushed on stack.
1033 static int
1034 luaA_wibox_get_fg(lua_State *L, wibox_t *wibox)
1036 return luaA_pushxcolor(L, wibox->ctx.fg);
1039 /** Set the wibox background color.
1040 * \param L The Lua VM state.
1041 * \param wibox The wibox object.
1042 * \return The number of elements pushed on stack.
1044 static int
1045 luaA_wibox_set_bg(lua_State *L, wibox_t *wibox)
1047 size_t len;
1048 const char *buf = luaL_checklstring(L, -1, &len);
1049 if(xcolor_init_reply(xcolor_init_unchecked(&wibox->ctx.bg, buf, len)))
1051 uint32_t mask = XCB_CW_BACK_PIXEL;
1052 uint32_t values[] = { wibox->ctx.bg.pixel };
1054 wibox->need_update = true;
1055 xcb_change_window_attributes(globalconf.connection,
1056 wibox->window,
1057 mask,
1058 values);
1060 luaA_object_emit_signal(L, -3, "property::bg", 0);
1061 return 0;
1064 /** Get the wibox background color.
1065 * \param L The Lua VM state.
1066 * \param wibox The wibox object.
1067 * \return The number of elements pushed on stack.
1069 static int
1070 luaA_wibox_get_bg(lua_State *L, wibox_t *wibox)
1072 return luaA_pushxcolor(L, wibox->ctx.bg);
1075 /** Set the wibox background image.
1076 * \param L The Lua VM state.
1077 * \param wibox The wibox object.
1078 * \return The number of elements pushed on stack.
1080 static int
1081 luaA_wibox_set_bg_image(lua_State *L, wibox_t *wibox)
1083 luaA_checkudata(L, -1, &image_class);
1084 luaA_object_unref_item(L, -3, wibox->bg_image);
1085 wibox->bg_image = luaA_object_ref_item(L, -3, -1);
1086 wibox->need_update = true;
1087 luaA_object_emit_signal(L, -2, "property::bg_image", 0);
1088 return 0;
1091 /** Get the wibox background image.
1092 * \param L The Lua VM state.
1093 * \param wibox The wibox object.
1094 * \return The number of elements pushed on stack.
1096 static int
1097 luaA_wibox_get_bg_image(lua_State *L, wibox_t *wibox)
1099 return luaA_object_push_item(L, 1, wibox->bg_image);
1102 /** Set the wibox on top status.
1103 * \param L The Lua VM state.
1104 * \param wibox The wibox object.
1105 * \return The number of elements pushed on stack.
1107 static int
1108 luaA_wibox_set_ontop(lua_State *L, wibox_t *wibox)
1110 bool b = luaA_checkboolean(L, -1);
1111 if(b != wibox->ontop)
1113 wibox->ontop = b;
1114 client_stack();
1115 luaA_object_emit_signal(L, -3, "property::ontop", 0);
1117 return 0;
1120 /** Set the wibox opacity.
1121 * \param L The Lua VM state.
1122 * \param wibox The wibox object.
1123 * \return The number of elements pushed on stack.
1125 static int
1126 luaA_wibox_set_opacity(lua_State *L, wibox_t *wibox)
1128 if(lua_isnil(L, -1))
1129 wibox_set_opacity(L, -3, -1);
1130 else
1132 double d = luaL_checknumber(L, -1);
1133 if(d >= 0 && d <= 1)
1134 wibox_set_opacity(L, -3, d);
1136 return 0;
1139 /** Get the wibox opacity.
1140 * \param L The Lua VM state.
1141 * \param wibox The wibox object.
1142 * \return The number of elements pushed on stack.
1144 static int
1145 luaA_wibox_get_opacity(lua_State *L, wibox_t *wibox)
1147 if (wibox->opacity >= 0)
1149 lua_pushnumber(L, wibox->opacity);
1150 return 1;
1152 return 0;
1155 /** Set the wibox alignment.
1156 * \param L The Lua VM state.
1157 * \param wibox The wibox object.
1158 * \return The number of elements pushed on stack.
1160 static int
1161 luaA_wibox_set_align(lua_State *L, wibox_t *wibox)
1163 size_t len;
1164 const char *buf = luaL_checklstring(L, -1, &len);
1165 wibox->align = draw_align_fromstr(buf, len);
1166 luaA_object_emit_signal(L, -3, "property::align", 0);
1167 switch(wibox->type)
1169 case WIBOX_TYPE_NORMAL:
1170 luaA_deprecate(L, "awful.wibox.align");
1171 break;
1172 case WIBOX_TYPE_TITLEBAR:
1173 titlebar_update_geometry(client_getbytitlebar(wibox));
1174 break;
1176 return 0;
1179 /** Get the wibox alignment.
1180 * \param L The Lua VM state.
1181 * \param wibox The wibox object.
1182 * \return The number of elements pushed on stack.
1184 static int
1185 luaA_wibox_get_align(lua_State *L, wibox_t *wibox)
1187 if(wibox->type == WIBOX_TYPE_NORMAL)
1188 luaA_deprecate(L, "awful.wibox.align");
1189 lua_pushstring(L, draw_align_tostr(wibox->align));
1190 return 1;
1193 /** Set the wibox position.
1194 * \param L The Lua VM state.
1195 * \param wibox The wibox object.
1196 * \return The number of elements pushed on stack.
1198 static int
1199 luaA_wibox_set_position(lua_State *L, wibox_t *wibox)
1201 switch(wibox->type)
1203 case WIBOX_TYPE_NORMAL:
1205 size_t len;
1206 const char *buf;
1207 if((buf = luaL_checklstring(L, -1, &len)))
1209 luaA_deprecate(L, "awful.wibox.attach");
1210 wibox->position = position_fromstr(buf, len);
1213 break;
1214 case WIBOX_TYPE_TITLEBAR:
1215 return luaA_titlebar_set_position(L, -3);
1217 return 0;
1220 /** Get the wibox position.
1221 * \param L The Lua VM state.
1222 * \param wibox The wibox object.
1223 * \return The number of elements pushed on stack.
1225 static int
1226 luaA_wibox_get_position(lua_State *L, wibox_t *wibox)
1228 if(wibox->type == WIBOX_TYPE_NORMAL)
1229 luaA_deprecate(L, "awful.wibox.attach");
1230 lua_pushstring(L, position_tostr(wibox->position));
1231 return 1;
1234 /** Set the wibox (titlebar) client.
1235 * \param L The Lua VM state.
1236 * \param wibox The wibox object.
1237 * \return The number of elements pushed on stack.
1239 static int
1240 luaA_wibox_set_client(lua_State *L, wibox_t *wibox)
1242 /* first detach */
1243 if(lua_isnil(L, -1))
1244 titlebar_client_detach(client_getbytitlebar(wibox));
1245 else
1247 client_t *c = luaA_client_checkudata(L, -1);
1248 lua_pushvalue(L, -3);
1249 titlebar_client_attach(c);
1251 return 0;
1254 /** Get the wibox (titlebar) client.
1255 * \param L The Lua VM state.
1256 * \param wibox The wibox object.
1257 * \return The number of elements pushed on stack.
1259 static int
1260 luaA_wibox_get_client(lua_State *L, wibox_t *wibox)
1262 return luaA_object_push(L, client_getbytitlebar(wibox));
1265 /** Set the wibox cursor.
1266 * \param L The Lua VM state.
1267 * \param wibox The wibox object.
1268 * \return The number of elements pushed on stack.
1270 static int
1271 luaA_wibox_set_cursor(lua_State *L, wibox_t *wibox)
1273 const char *buf = luaL_checkstring(L, -1);
1274 if(buf)
1276 uint16_t cursor_font = xcursor_font_fromstr(buf);
1277 if(cursor_font)
1279 xcb_cursor_t cursor = xcursor_new(globalconf.connection, cursor_font);
1280 p_delete(&wibox->cursor);
1281 wibox->cursor = a_strdup(buf);
1282 window_set_cursor(wibox->window, cursor);
1283 luaA_object_emit_signal(L, -3, "property::cursor", 0);
1286 return 0;
1289 /** Set the wibox screen.
1290 * \param L The Lua VM state.
1291 * \param wibox The wibox object.
1292 * \return The number of elements pushed on stack.
1294 static int
1295 luaA_wibox_set_screen(lua_State *L, wibox_t *wibox)
1297 if(lua_isnil(L, -1))
1299 wibox_detach(L, -3);
1300 titlebar_client_detach(client_getbytitlebar(wibox));
1302 else
1304 int screen = luaL_checknumber(L, -1) - 1;
1305 luaA_checkscreen(screen);
1306 if(!wibox->screen || screen != screen_array_indexof(&globalconf.screens, wibox->screen))
1308 titlebar_client_detach(client_getbytitlebar(wibox));
1309 wibox_attach(L, -3, &globalconf.screens.tab[screen]);
1312 return 0;
1315 /** Get the wibox screen.
1316 * \param L The Lua VM state.
1317 * \param wibox The wibox object.
1318 * \return The number of elements pushed on stack.
1320 static int
1321 luaA_wibox_get_screen(lua_State *L, wibox_t *wibox)
1323 if(!wibox->screen)
1324 return 0;
1325 lua_pushnumber(L, screen_array_indexof(&globalconf.screens, wibox->screen) + 1);
1326 return 1;
1329 /** Set the wibox orientation.
1330 * \param L The Lua VM state.
1331 * \param wibox The wibox object.
1332 * \return The number of elements pushed on stack.
1334 static int
1335 luaA_wibox_set_orientation(lua_State *L, wibox_t *wibox)
1337 size_t len;
1338 const char *buf = luaL_checklstring(L, -1, &len);
1339 if(buf)
1341 wibox_set_orientation(L, -3, orientation_fromstr(buf, len));
1342 wibox_need_update(wibox);
1344 return 0;
1347 /** Get the wibox orientation.
1348 * \param L The Lua VM state.
1349 * \param wibox The wibox object.
1350 * \return The number of elements pushed on stack.
1352 static int
1353 luaA_wibox_get_orientation(lua_State *L, wibox_t *wibox)
1355 lua_pushstring(L, orientation_tostr(wibox->orientation));
1356 return 1;
1359 /** Set the wibox border color.
1360 * \param L The Lua VM state.
1361 * \param wibox The wibox object.
1362 * \return The number of elements pushed on stack.
1364 static int
1365 luaA_wibox_set_border_color(lua_State *L, wibox_t *wibox)
1367 size_t len;
1368 const char *buf = luaL_checklstring(L, -1, &len);
1369 if(buf)
1370 if(xcolor_init_reply(xcolor_init_unchecked(&wibox->border_color, buf, len)))
1371 if(wibox->window)
1372 wibox_set_border_color(L, -3, &wibox->border_color);
1373 return 0;
1376 /** Set the wibox visibility.
1377 * \param L The Lua VM state.
1378 * \param wibox The wibox object.
1379 * \return The number of elements pushed on stack.
1381 static int
1382 luaA_wibox_set_visible(lua_State *L, wibox_t *wibox)
1384 bool b = luaA_checkboolean(L, -1);
1385 if(b != wibox->visible)
1386 switch(wibox->type)
1388 case WIBOX_TYPE_NORMAL:
1389 wibox_set_visible(L, -3, b);
1390 break;
1391 case WIBOX_TYPE_TITLEBAR:
1392 titlebar_set_visible(wibox, b);
1393 break;
1395 return 0;
1398 /** Set the wibox widgets.
1399 * \param L The Lua VM state.
1400 * \param wibox The wibox object.
1401 * \return The number of elements pushed on stack.
1403 static int
1404 luaA_wibox_set_widgets(lua_State *L, wibox_t *wibox)
1406 if(luaA_isloop(L, -1))
1408 luaA_warn(L, "table is looping, cannot use this as widget table");
1409 return 0;
1411 /* duplicate table because next function will eat it */
1412 lua_pushvalue(L, -1);
1413 wibox->widgets_table = luaA_object_ref_item(L, -4, -1);
1414 luaA_object_emit_signal(L, -3, "property::widgets", 0);
1415 wibox_need_update(wibox);
1416 luaA_table2wtable(L);
1417 return 0;
1420 /** Get the wibox widgets.
1421 * \param L The Lua VM state.
1422 * \param wibox The wibox object.
1423 * \return The number of elements pushed on stack.
1425 static int
1426 luaA_wibox_get_widgets(lua_State *L, wibox_t *wibox)
1428 return luaA_object_push_item(L, 1, wibox->widgets_table);
1431 /** Get or set mouse buttons bindings to a wibox.
1432 * \param L The Lua VM state.
1433 * \luastack
1434 * \lvalue A wibox.
1435 * \lparam An array of mouse button bindings objects, or nothing.
1436 * \return The array of mouse button bindings objects of this wibox.
1438 static int
1439 luaA_wibox_buttons(lua_State *L)
1441 wibox_t *wibox = luaA_checkudata(L, 1, &wibox_class);
1443 if(lua_gettop(L) == 2)
1445 luaA_button_array_set(L, 1, 2, &wibox->buttons);
1446 luaA_object_emit_signal(L, 1, "property::buttons", 0);
1449 return luaA_button_array_get(L, 1, &wibox->buttons);
1452 /** Set the wibox border width.
1453 * \param L The Lua VM state.
1454 * \param wibox The wibox object.
1455 * \return The number of elements pushed on stack.
1457 static int
1458 luaA_wibox_set_border_width(lua_State *L, wibox_t *wibox)
1460 wibox_t *w = luaA_checkudata(L, -3, &wibox_class);
1461 uint32_t border_width = luaL_checknumber(L, -1);
1462 if(border_width != w->border_width)
1464 xcb_configure_window(globalconf.connection, w->window, XCB_CONFIG_WINDOW_BORDER_WIDTH,
1465 &border_width);
1466 w->border_width = border_width;
1467 /* Need update if transparent background */
1468 wibox_need_update(w);
1469 luaA_object_emit_signal(L, -3, "property::border_width", 0);
1471 return 0;
1474 static int
1475 luaA_wibox_set_shape_bounding(lua_State *L, wibox_t *wibox)
1477 luaA_checkudata(L, -1, &image_class);
1478 luaA_object_unref_item(L, -3, wibox->shape.bounding);
1479 wibox->shape.bounding = luaA_object_ref_item(L, -3, -1);
1480 wibox->need_shape_update = true;
1481 luaA_object_emit_signal(L, -2, "property::shape_bounding", 0);
1482 return 0;
1485 static int
1486 luaA_wibox_get_shape_bounding(lua_State *L, wibox_t *wibox)
1488 return luaA_object_push_item(L, 1, wibox->shape.bounding);
1491 static int
1492 luaA_wibox_set_shape_clip(lua_State *L, wibox_t *wibox)
1494 luaA_checkudata(L, -1, &image_class);
1495 luaA_object_unref_item(L, -3, wibox->shape.clip);
1496 wibox->shape.clip = luaA_object_ref_item(L, -3, -1);
1497 wibox->need_shape_update = true;
1498 luaA_object_emit_signal(L, -2, "property::shape_clip", 0);
1499 return 0;
1502 static int
1503 luaA_wibox_get_shape_clip(lua_State *L, wibox_t *wibox)
1505 return luaA_object_push_item(L, 1, wibox->shape.clip);
1508 void
1509 wibox_class_setup(lua_State *L)
1511 static const struct luaL_reg wibox_methods[] =
1513 LUA_CLASS_METHODS(wibox)
1514 { "__call", luaA_wibox_new },
1515 { NULL, NULL }
1518 static const struct luaL_reg wibox_meta[] =
1520 LUA_OBJECT_META(wibox)
1521 LUA_CLASS_META
1522 { "struts", luaA_wibox_struts },
1523 { "buttons", luaA_wibox_buttons },
1524 { "geometry", luaA_wibox_geometry },
1525 { "__gc", luaA_wibox_gc },
1526 { NULL, NULL },
1529 luaA_class_setup(L, &wibox_class, "wibox", (lua_class_allocator_t) wibox_new,
1530 luaA_class_index_miss_property, luaA_class_newindex_miss_property,
1531 wibox_methods, wibox_meta);
1532 luaA_class_add_property(&wibox_class, A_TK_WIDGETS,
1533 (lua_class_propfunc_t) luaA_wibox_set_widgets,
1534 (lua_class_propfunc_t) luaA_wibox_get_widgets,
1535 (lua_class_propfunc_t) luaA_wibox_set_widgets);
1536 luaA_class_add_property(&wibox_class, A_TK_OPACITY,
1537 (lua_class_propfunc_t) luaA_wibox_set_opacity,
1538 (lua_class_propfunc_t) luaA_wibox_get_opacity,
1539 (lua_class_propfunc_t) luaA_wibox_set_opacity);
1540 luaA_class_add_property(&wibox_class, A_TK_VISIBLE,
1541 (lua_class_propfunc_t) luaA_wibox_set_visible,
1542 (lua_class_propfunc_t) luaA_wibox_get_visible,
1543 (lua_class_propfunc_t) luaA_wibox_set_visible);
1544 luaA_class_add_property(&wibox_class, A_TK_BORDER_COLOR,
1545 (lua_class_propfunc_t) luaA_wibox_set_border_color,
1546 (lua_class_propfunc_t) luaA_wibox_get_border_color,
1547 (lua_class_propfunc_t) luaA_wibox_set_border_color);
1548 luaA_class_add_property(&wibox_class, A_TK_BORDER_WIDTH,
1549 (lua_class_propfunc_t) luaA_wibox_set_border_width,
1550 (lua_class_propfunc_t) luaA_wibox_get_border_width,
1551 (lua_class_propfunc_t) luaA_wibox_set_border_width);
1552 luaA_class_add_property(&wibox_class, A_TK_ORIENTATION,
1553 (lua_class_propfunc_t) luaA_wibox_set_orientation,
1554 (lua_class_propfunc_t) luaA_wibox_get_orientation,
1555 (lua_class_propfunc_t) luaA_wibox_set_orientation);
1556 luaA_class_add_property(&wibox_class, A_TK_ONTOP,
1557 (lua_class_propfunc_t) luaA_wibox_set_ontop,
1558 (lua_class_propfunc_t) luaA_wibox_get_ontop,
1559 (lua_class_propfunc_t) luaA_wibox_set_ontop);
1560 luaA_class_add_property(&wibox_class, A_TK_SCREEN,
1561 NULL,
1562 (lua_class_propfunc_t) luaA_wibox_get_screen,
1563 (lua_class_propfunc_t) luaA_wibox_set_screen);
1564 luaA_class_add_property(&wibox_class, A_TK_CURSOR,
1565 (lua_class_propfunc_t) luaA_wibox_set_cursor,
1566 (lua_class_propfunc_t) luaA_wibox_get_cursor,
1567 (lua_class_propfunc_t) luaA_wibox_set_cursor);
1568 luaA_class_add_property(&wibox_class, A_TK_CLIENT,
1569 (lua_class_propfunc_t) luaA_wibox_set_client,
1570 (lua_class_propfunc_t) luaA_wibox_get_client,
1571 (lua_class_propfunc_t) luaA_wibox_set_client);
1572 luaA_class_add_property(&wibox_class, A_TK_POSITION,
1573 (lua_class_propfunc_t) luaA_wibox_set_position,
1574 (lua_class_propfunc_t) luaA_wibox_get_position,
1575 (lua_class_propfunc_t) luaA_wibox_set_position);
1576 luaA_class_add_property(&wibox_class, A_TK_ALIGN,
1577 (lua_class_propfunc_t) luaA_wibox_set_align,
1578 (lua_class_propfunc_t) luaA_wibox_get_align,
1579 (lua_class_propfunc_t) luaA_wibox_set_align);
1580 luaA_class_add_property(&wibox_class, A_TK_FG,
1581 (lua_class_propfunc_t) luaA_wibox_set_fg,
1582 (lua_class_propfunc_t) luaA_wibox_get_fg,
1583 (lua_class_propfunc_t) luaA_wibox_set_fg);
1584 luaA_class_add_property(&wibox_class, A_TK_BG,
1585 (lua_class_propfunc_t) luaA_wibox_set_bg,
1586 (lua_class_propfunc_t) luaA_wibox_get_bg,
1587 (lua_class_propfunc_t) luaA_wibox_set_bg);
1588 luaA_class_add_property(&wibox_class, A_TK_BG_IMAGE,
1589 (lua_class_propfunc_t) luaA_wibox_set_bg_image,
1590 (lua_class_propfunc_t) luaA_wibox_get_bg_image,
1591 (lua_class_propfunc_t) luaA_wibox_set_bg_image);
1592 luaA_class_add_property(&wibox_class, A_TK_X,
1593 (lua_class_propfunc_t) luaA_wibox_set_x,
1594 (lua_class_propfunc_t) luaA_wibox_get_x,
1595 (lua_class_propfunc_t) luaA_wibox_set_x);
1596 luaA_class_add_property(&wibox_class, A_TK_Y,
1597 (lua_class_propfunc_t) luaA_wibox_set_y,
1598 (lua_class_propfunc_t) luaA_wibox_get_y,
1599 (lua_class_propfunc_t) luaA_wibox_set_y);
1600 luaA_class_add_property(&wibox_class, A_TK_WIDTH,
1601 (lua_class_propfunc_t) luaA_wibox_set_width,
1602 (lua_class_propfunc_t) luaA_wibox_get_width,
1603 (lua_class_propfunc_t) luaA_wibox_set_width);
1604 luaA_class_add_property(&wibox_class, A_TK_HEIGHT,
1605 (lua_class_propfunc_t) luaA_wibox_set_height,
1606 (lua_class_propfunc_t) luaA_wibox_get_height,
1607 (lua_class_propfunc_t) luaA_wibox_set_height);
1608 luaA_class_add_property(&wibox_class, A_TK_SHAPE_BOUNDING,
1609 (lua_class_propfunc_t) luaA_wibox_set_shape_bounding,
1610 (lua_class_propfunc_t) luaA_wibox_get_shape_bounding,
1611 (lua_class_propfunc_t) luaA_wibox_set_shape_bounding);
1612 luaA_class_add_property(&wibox_class, A_TK_SHAPE_CLIP,
1613 (lua_class_propfunc_t) luaA_wibox_set_shape_clip,
1614 (lua_class_propfunc_t) luaA_wibox_get_shape_clip,
1615 (lua_class_propfunc_t) luaA_wibox_set_shape_clip);
1618 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80