dbus: check that interface is not NULL (FS#667)
[awesome.git] / wibox.c
blob6b2b44e06cfc9bcb134625c17525ff5ce06ccae5
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;
1057 if (wibox->window != XCB_NONE)
1058 xcb_change_window_attributes(globalconf.connection,
1059 wibox->window,
1060 mask,
1061 values);
1063 luaA_object_emit_signal(L, -3, "property::bg", 0);
1064 return 0;
1067 /** Get the wibox background color.
1068 * \param L The Lua VM state.
1069 * \param wibox The wibox object.
1070 * \return The number of elements pushed on stack.
1072 static int
1073 luaA_wibox_get_bg(lua_State *L, wibox_t *wibox)
1075 return luaA_pushxcolor(L, wibox->ctx.bg);
1078 /** Set the wibox background image.
1079 * \param L The Lua VM state.
1080 * \param wibox The wibox object.
1081 * \return The number of elements pushed on stack.
1083 static int
1084 luaA_wibox_set_bg_image(lua_State *L, wibox_t *wibox)
1086 luaA_checkudata(L, -1, &image_class);
1087 luaA_object_unref_item(L, -3, wibox->bg_image);
1088 wibox->bg_image = luaA_object_ref_item(L, -3, -1);
1089 wibox->need_update = true;
1090 luaA_object_emit_signal(L, -2, "property::bg_image", 0);
1091 return 0;
1094 /** Get the wibox background image.
1095 * \param L The Lua VM state.
1096 * \param wibox The wibox object.
1097 * \return The number of elements pushed on stack.
1099 static int
1100 luaA_wibox_get_bg_image(lua_State *L, wibox_t *wibox)
1102 return luaA_object_push_item(L, 1, wibox->bg_image);
1105 /** Set the wibox on top status.
1106 * \param L The Lua VM state.
1107 * \param wibox The wibox object.
1108 * \return The number of elements pushed on stack.
1110 static int
1111 luaA_wibox_set_ontop(lua_State *L, wibox_t *wibox)
1113 bool b = luaA_checkboolean(L, -1);
1114 if(b != wibox->ontop)
1116 wibox->ontop = b;
1117 client_stack();
1118 luaA_object_emit_signal(L, -3, "property::ontop", 0);
1120 return 0;
1123 /** Set the wibox opacity.
1124 * \param L The Lua VM state.
1125 * \param wibox The wibox object.
1126 * \return The number of elements pushed on stack.
1128 static int
1129 luaA_wibox_set_opacity(lua_State *L, wibox_t *wibox)
1131 if(lua_isnil(L, -1))
1132 wibox_set_opacity(L, -3, -1);
1133 else
1135 double d = luaL_checknumber(L, -1);
1136 if(d >= 0 && d <= 1)
1137 wibox_set_opacity(L, -3, d);
1139 return 0;
1142 /** Get the wibox opacity.
1143 * \param L The Lua VM state.
1144 * \param wibox The wibox object.
1145 * \return The number of elements pushed on stack.
1147 static int
1148 luaA_wibox_get_opacity(lua_State *L, wibox_t *wibox)
1150 if (wibox->opacity >= 0)
1152 lua_pushnumber(L, wibox->opacity);
1153 return 1;
1155 return 0;
1158 /** Set the wibox alignment.
1159 * \param L The Lua VM state.
1160 * \param wibox The wibox object.
1161 * \return The number of elements pushed on stack.
1163 static int
1164 luaA_wibox_set_align(lua_State *L, wibox_t *wibox)
1166 size_t len;
1167 const char *buf = luaL_checklstring(L, -1, &len);
1168 wibox->align = draw_align_fromstr(buf, len);
1169 luaA_object_emit_signal(L, -3, "property::align", 0);
1170 switch(wibox->type)
1172 case WIBOX_TYPE_NORMAL:
1173 luaA_deprecate(L, "awful.wibox.align");
1174 break;
1175 case WIBOX_TYPE_TITLEBAR:
1176 titlebar_update_geometry(client_getbytitlebar(wibox));
1177 break;
1179 return 0;
1182 /** Get the wibox alignment.
1183 * \param L The Lua VM state.
1184 * \param wibox The wibox object.
1185 * \return The number of elements pushed on stack.
1187 static int
1188 luaA_wibox_get_align(lua_State *L, wibox_t *wibox)
1190 if(wibox->type == WIBOX_TYPE_NORMAL)
1191 luaA_deprecate(L, "awful.wibox.align");
1192 lua_pushstring(L, draw_align_tostr(wibox->align));
1193 return 1;
1196 /** Set the wibox position.
1197 * \param L The Lua VM state.
1198 * \param wibox The wibox object.
1199 * \return The number of elements pushed on stack.
1201 static int
1202 luaA_wibox_set_position(lua_State *L, wibox_t *wibox)
1204 switch(wibox->type)
1206 case WIBOX_TYPE_NORMAL:
1208 size_t len;
1209 const char *buf;
1210 if((buf = luaL_checklstring(L, -1, &len)))
1212 luaA_deprecate(L, "awful.wibox.attach");
1213 wibox->position = position_fromstr(buf, len);
1216 break;
1217 case WIBOX_TYPE_TITLEBAR:
1218 return luaA_titlebar_set_position(L, -3);
1220 return 0;
1223 /** Get the wibox position.
1224 * \param L The Lua VM state.
1225 * \param wibox The wibox object.
1226 * \return The number of elements pushed on stack.
1228 static int
1229 luaA_wibox_get_position(lua_State *L, wibox_t *wibox)
1231 if(wibox->type == WIBOX_TYPE_NORMAL)
1232 luaA_deprecate(L, "awful.wibox.attach");
1233 lua_pushstring(L, position_tostr(wibox->position));
1234 return 1;
1237 /** Set the wibox (titlebar) client.
1238 * \param L The Lua VM state.
1239 * \param wibox The wibox object.
1240 * \return The number of elements pushed on stack.
1242 static int
1243 luaA_wibox_set_client(lua_State *L, wibox_t *wibox)
1245 /* first detach */
1246 if(lua_isnil(L, -1))
1247 titlebar_client_detach(client_getbytitlebar(wibox));
1248 else
1250 client_t *c = luaA_client_checkudata(L, -1);
1251 lua_pushvalue(L, -3);
1252 titlebar_client_attach(c);
1254 return 0;
1257 /** Get the wibox (titlebar) client.
1258 * \param L The Lua VM state.
1259 * \param wibox The wibox object.
1260 * \return The number of elements pushed on stack.
1262 static int
1263 luaA_wibox_get_client(lua_State *L, wibox_t *wibox)
1265 return luaA_object_push(L, client_getbytitlebar(wibox));
1268 /** Set the wibox cursor.
1269 * \param L The Lua VM state.
1270 * \param wibox The wibox object.
1271 * \return The number of elements pushed on stack.
1273 static int
1274 luaA_wibox_set_cursor(lua_State *L, wibox_t *wibox)
1276 const char *buf = luaL_checkstring(L, -1);
1277 if(buf)
1279 uint16_t cursor_font = xcursor_font_fromstr(buf);
1280 if(cursor_font)
1282 xcb_cursor_t cursor = xcursor_new(globalconf.connection, cursor_font);
1283 p_delete(&wibox->cursor);
1284 wibox->cursor = a_strdup(buf);
1285 window_set_cursor(wibox->window, cursor);
1286 luaA_object_emit_signal(L, -3, "property::cursor", 0);
1289 return 0;
1292 /** Set the wibox screen.
1293 * \param L The Lua VM state.
1294 * \param wibox The wibox object.
1295 * \return The number of elements pushed on stack.
1297 static int
1298 luaA_wibox_set_screen(lua_State *L, wibox_t *wibox)
1300 if(lua_isnil(L, -1))
1302 wibox_detach(L, -3);
1303 titlebar_client_detach(client_getbytitlebar(wibox));
1305 else
1307 int screen = luaL_checknumber(L, -1) - 1;
1308 luaA_checkscreen(screen);
1309 if(!wibox->screen || screen != screen_array_indexof(&globalconf.screens, wibox->screen))
1311 titlebar_client_detach(client_getbytitlebar(wibox));
1312 wibox_attach(L, -3, &globalconf.screens.tab[screen]);
1315 return 0;
1318 /** Get the wibox screen.
1319 * \param L The Lua VM state.
1320 * \param wibox The wibox object.
1321 * \return The number of elements pushed on stack.
1323 static int
1324 luaA_wibox_get_screen(lua_State *L, wibox_t *wibox)
1326 if(!wibox->screen)
1327 return 0;
1328 lua_pushnumber(L, screen_array_indexof(&globalconf.screens, wibox->screen) + 1);
1329 return 1;
1332 /** Set the wibox orientation.
1333 * \param L The Lua VM state.
1334 * \param wibox The wibox object.
1335 * \return The number of elements pushed on stack.
1337 static int
1338 luaA_wibox_set_orientation(lua_State *L, wibox_t *wibox)
1340 size_t len;
1341 const char *buf = luaL_checklstring(L, -1, &len);
1342 if(buf)
1344 wibox_set_orientation(L, -3, orientation_fromstr(buf, len));
1345 wibox_need_update(wibox);
1347 return 0;
1350 /** Get the wibox orientation.
1351 * \param L The Lua VM state.
1352 * \param wibox The wibox object.
1353 * \return The number of elements pushed on stack.
1355 static int
1356 luaA_wibox_get_orientation(lua_State *L, wibox_t *wibox)
1358 lua_pushstring(L, orientation_tostr(wibox->orientation));
1359 return 1;
1362 /** Set the wibox border color.
1363 * \param L The Lua VM state.
1364 * \param wibox The wibox object.
1365 * \return The number of elements pushed on stack.
1367 static int
1368 luaA_wibox_set_border_color(lua_State *L, wibox_t *wibox)
1370 size_t len;
1371 const char *buf = luaL_checklstring(L, -1, &len);
1372 if(buf)
1373 if(xcolor_init_reply(xcolor_init_unchecked(&wibox->border_color, buf, len)))
1374 if(wibox->window)
1375 wibox_set_border_color(L, -3, &wibox->border_color);
1376 return 0;
1379 /** Set the wibox visibility.
1380 * \param L The Lua VM state.
1381 * \param wibox The wibox object.
1382 * \return The number of elements pushed on stack.
1384 static int
1385 luaA_wibox_set_visible(lua_State *L, wibox_t *wibox)
1387 bool b = luaA_checkboolean(L, -1);
1388 if(b != wibox->visible)
1389 switch(wibox->type)
1391 case WIBOX_TYPE_NORMAL:
1392 wibox_set_visible(L, -3, b);
1393 break;
1394 case WIBOX_TYPE_TITLEBAR:
1395 titlebar_set_visible(wibox, b);
1396 break;
1398 return 0;
1401 /** Set the wibox widgets.
1402 * \param L The Lua VM state.
1403 * \param wibox The wibox object.
1404 * \return The number of elements pushed on stack.
1406 static int
1407 luaA_wibox_set_widgets(lua_State *L, wibox_t *wibox)
1409 if(luaA_isloop(L, -1))
1411 luaA_warn(L, "table is looping, cannot use this as widget table");
1412 return 0;
1414 /* duplicate table because next function will eat it */
1415 lua_pushvalue(L, -1);
1416 wibox->widgets_table = luaA_object_ref_item(L, -4, -1);
1417 luaA_object_emit_signal(L, -3, "property::widgets", 0);
1418 wibox_need_update(wibox);
1419 luaA_table2wtable(L);
1420 return 0;
1423 /** Get the wibox widgets.
1424 * \param L The Lua VM state.
1425 * \param wibox The wibox object.
1426 * \return The number of elements pushed on stack.
1428 static int
1429 luaA_wibox_get_widgets(lua_State *L, wibox_t *wibox)
1431 return luaA_object_push_item(L, 1, wibox->widgets_table);
1434 /** Get or set mouse buttons bindings to a wibox.
1435 * \param L The Lua VM state.
1436 * \luastack
1437 * \lvalue A wibox.
1438 * \lparam An array of mouse button bindings objects, or nothing.
1439 * \return The array of mouse button bindings objects of this wibox.
1441 static int
1442 luaA_wibox_buttons(lua_State *L)
1444 wibox_t *wibox = luaA_checkudata(L, 1, &wibox_class);
1446 if(lua_gettop(L) == 2)
1448 luaA_button_array_set(L, 1, 2, &wibox->buttons);
1449 luaA_object_emit_signal(L, 1, "property::buttons", 0);
1452 return luaA_button_array_get(L, 1, &wibox->buttons);
1455 /** Set the wibox border width.
1456 * \param L The Lua VM state.
1457 * \param wibox The wibox object.
1458 * \return The number of elements pushed on stack.
1460 static int
1461 luaA_wibox_set_border_width(lua_State *L, wibox_t *wibox)
1463 wibox_t *w = luaA_checkudata(L, -3, &wibox_class);
1464 uint32_t border_width = luaL_checknumber(L, -1);
1465 if(border_width != w->border_width)
1467 xcb_configure_window(globalconf.connection, w->window, XCB_CONFIG_WINDOW_BORDER_WIDTH,
1468 &border_width);
1469 w->border_width = border_width;
1470 /* Need update if transparent background */
1471 wibox_need_update(w);
1472 luaA_object_emit_signal(L, -3, "property::border_width", 0);
1474 return 0;
1477 static int
1478 luaA_wibox_set_shape_bounding(lua_State *L, wibox_t *wibox)
1480 luaA_checkudata(L, -1, &image_class);
1481 luaA_object_unref_item(L, -3, wibox->shape.bounding);
1482 wibox->shape.bounding = luaA_object_ref_item(L, -3, -1);
1483 wibox->need_shape_update = true;
1484 luaA_object_emit_signal(L, -2, "property::shape_bounding", 0);
1485 return 0;
1488 static int
1489 luaA_wibox_get_shape_bounding(lua_State *L, wibox_t *wibox)
1491 return luaA_object_push_item(L, 1, wibox->shape.bounding);
1494 static int
1495 luaA_wibox_set_shape_clip(lua_State *L, wibox_t *wibox)
1497 luaA_checkudata(L, -1, &image_class);
1498 luaA_object_unref_item(L, -3, wibox->shape.clip);
1499 wibox->shape.clip = luaA_object_ref_item(L, -3, -1);
1500 wibox->need_shape_update = true;
1501 luaA_object_emit_signal(L, -2, "property::shape_clip", 0);
1502 return 0;
1505 static int
1506 luaA_wibox_get_shape_clip(lua_State *L, wibox_t *wibox)
1508 return luaA_object_push_item(L, 1, wibox->shape.clip);
1511 void
1512 wibox_class_setup(lua_State *L)
1514 static const struct luaL_reg wibox_methods[] =
1516 LUA_CLASS_METHODS(wibox)
1517 { "__call", luaA_wibox_new },
1518 { NULL, NULL }
1521 static const struct luaL_reg wibox_meta[] =
1523 LUA_OBJECT_META(wibox)
1524 LUA_CLASS_META
1525 { "struts", luaA_wibox_struts },
1526 { "buttons", luaA_wibox_buttons },
1527 { "geometry", luaA_wibox_geometry },
1528 { "__gc", luaA_wibox_gc },
1529 { NULL, NULL },
1532 luaA_class_setup(L, &wibox_class, "wibox", (lua_class_allocator_t) wibox_new,
1533 luaA_class_index_miss_property, luaA_class_newindex_miss_property,
1534 wibox_methods, wibox_meta);
1535 luaA_class_add_property(&wibox_class, A_TK_WIDGETS,
1536 (lua_class_propfunc_t) luaA_wibox_set_widgets,
1537 (lua_class_propfunc_t) luaA_wibox_get_widgets,
1538 (lua_class_propfunc_t) luaA_wibox_set_widgets);
1539 luaA_class_add_property(&wibox_class, A_TK_OPACITY,
1540 (lua_class_propfunc_t) luaA_wibox_set_opacity,
1541 (lua_class_propfunc_t) luaA_wibox_get_opacity,
1542 (lua_class_propfunc_t) luaA_wibox_set_opacity);
1543 luaA_class_add_property(&wibox_class, A_TK_VISIBLE,
1544 (lua_class_propfunc_t) luaA_wibox_set_visible,
1545 (lua_class_propfunc_t) luaA_wibox_get_visible,
1546 (lua_class_propfunc_t) luaA_wibox_set_visible);
1547 luaA_class_add_property(&wibox_class, A_TK_BORDER_COLOR,
1548 (lua_class_propfunc_t) luaA_wibox_set_border_color,
1549 (lua_class_propfunc_t) luaA_wibox_get_border_color,
1550 (lua_class_propfunc_t) luaA_wibox_set_border_color);
1551 luaA_class_add_property(&wibox_class, A_TK_BORDER_WIDTH,
1552 (lua_class_propfunc_t) luaA_wibox_set_border_width,
1553 (lua_class_propfunc_t) luaA_wibox_get_border_width,
1554 (lua_class_propfunc_t) luaA_wibox_set_border_width);
1555 luaA_class_add_property(&wibox_class, A_TK_ORIENTATION,
1556 (lua_class_propfunc_t) luaA_wibox_set_orientation,
1557 (lua_class_propfunc_t) luaA_wibox_get_orientation,
1558 (lua_class_propfunc_t) luaA_wibox_set_orientation);
1559 luaA_class_add_property(&wibox_class, A_TK_ONTOP,
1560 (lua_class_propfunc_t) luaA_wibox_set_ontop,
1561 (lua_class_propfunc_t) luaA_wibox_get_ontop,
1562 (lua_class_propfunc_t) luaA_wibox_set_ontop);
1563 luaA_class_add_property(&wibox_class, A_TK_SCREEN,
1564 NULL,
1565 (lua_class_propfunc_t) luaA_wibox_get_screen,
1566 (lua_class_propfunc_t) luaA_wibox_set_screen);
1567 luaA_class_add_property(&wibox_class, A_TK_CURSOR,
1568 (lua_class_propfunc_t) luaA_wibox_set_cursor,
1569 (lua_class_propfunc_t) luaA_wibox_get_cursor,
1570 (lua_class_propfunc_t) luaA_wibox_set_cursor);
1571 luaA_class_add_property(&wibox_class, A_TK_CLIENT,
1572 (lua_class_propfunc_t) luaA_wibox_set_client,
1573 (lua_class_propfunc_t) luaA_wibox_get_client,
1574 (lua_class_propfunc_t) luaA_wibox_set_client);
1575 luaA_class_add_property(&wibox_class, A_TK_POSITION,
1576 (lua_class_propfunc_t) luaA_wibox_set_position,
1577 (lua_class_propfunc_t) luaA_wibox_get_position,
1578 (lua_class_propfunc_t) luaA_wibox_set_position);
1579 luaA_class_add_property(&wibox_class, A_TK_ALIGN,
1580 (lua_class_propfunc_t) luaA_wibox_set_align,
1581 (lua_class_propfunc_t) luaA_wibox_get_align,
1582 (lua_class_propfunc_t) luaA_wibox_set_align);
1583 luaA_class_add_property(&wibox_class, A_TK_FG,
1584 (lua_class_propfunc_t) luaA_wibox_set_fg,
1585 (lua_class_propfunc_t) luaA_wibox_get_fg,
1586 (lua_class_propfunc_t) luaA_wibox_set_fg);
1587 luaA_class_add_property(&wibox_class, A_TK_BG,
1588 (lua_class_propfunc_t) luaA_wibox_set_bg,
1589 (lua_class_propfunc_t) luaA_wibox_get_bg,
1590 (lua_class_propfunc_t) luaA_wibox_set_bg);
1591 luaA_class_add_property(&wibox_class, A_TK_BG_IMAGE,
1592 (lua_class_propfunc_t) luaA_wibox_set_bg_image,
1593 (lua_class_propfunc_t) luaA_wibox_get_bg_image,
1594 (lua_class_propfunc_t) luaA_wibox_set_bg_image);
1595 luaA_class_add_property(&wibox_class, A_TK_X,
1596 (lua_class_propfunc_t) luaA_wibox_set_x,
1597 (lua_class_propfunc_t) luaA_wibox_get_x,
1598 (lua_class_propfunc_t) luaA_wibox_set_x);
1599 luaA_class_add_property(&wibox_class, A_TK_Y,
1600 (lua_class_propfunc_t) luaA_wibox_set_y,
1601 (lua_class_propfunc_t) luaA_wibox_get_y,
1602 (lua_class_propfunc_t) luaA_wibox_set_y);
1603 luaA_class_add_property(&wibox_class, A_TK_WIDTH,
1604 (lua_class_propfunc_t) luaA_wibox_set_width,
1605 (lua_class_propfunc_t) luaA_wibox_get_width,
1606 (lua_class_propfunc_t) luaA_wibox_set_width);
1607 luaA_class_add_property(&wibox_class, A_TK_HEIGHT,
1608 (lua_class_propfunc_t) luaA_wibox_set_height,
1609 (lua_class_propfunc_t) luaA_wibox_get_height,
1610 (lua_class_propfunc_t) luaA_wibox_set_height);
1611 luaA_class_add_property(&wibox_class, A_TK_SHAPE_BOUNDING,
1612 (lua_class_propfunc_t) luaA_wibox_set_shape_bounding,
1613 (lua_class_propfunc_t) luaA_wibox_get_shape_bounding,
1614 (lua_class_propfunc_t) luaA_wibox_set_shape_bounding);
1615 luaA_class_add_property(&wibox_class, A_TK_SHAPE_CLIP,
1616 (lua_class_propfunc_t) luaA_wibox_set_shape_clip,
1617 (lua_class_propfunc_t) luaA_wibox_get_shape_clip,
1618 (lua_class_propfunc_t) luaA_wibox_set_shape_clip);
1621 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80