awful.remote: enhance description
[awesome.git] / wibox.c
blob3c1b0e342074c2bf0ffb22a229f7d758452d8e60
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 simplw 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_PIXMAP | XCB_CW_BORDER_PIXEL
170 | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK,
171 (const uint32_t [])
173 XCB_BACK_PIXMAP_PARENT_RELATIVE,
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 /* Activatate BMA */
262 client_ignore_enterleave_events();
264 if(mask_vals)
265 xcb_configure_window(globalconf.connection, w->window, mask_vals, moveresize_win_vals);
267 /* Deactivatate 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 /* Deactivatate 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 wibox->screen = NULL;
719 luaA_object_emit_signal(L, udx, "property::screen", 0);
721 luaA_object_unref(globalconf.L, wibox);
725 /** Attach a wibox that is on top of the stack.
726 * \param L The Lua VM state.
727 * \param udx The wibox to attach.
728 * \param s The screen to attach the wibox to.
730 static void
731 wibox_attach(lua_State *L, int udx, screen_t *s)
733 int phys_screen = screen_virttophys(screen_array_indexof(&globalconf.screens, s));
735 /* duplicate wibox */
736 lua_pushvalue(L, udx);
737 /* ref it */
738 wibox_t *wibox = luaA_object_ref(globalconf.L, -1);
740 wibox_detach(L, udx);
742 /* Set the wibox screen */
743 wibox->screen = s;
745 /* Check that the wibox coordinates matches the screen. */
746 screen_t *cscreen =
747 screen_getbycoord(wibox->screen, wibox->geometry.x, wibox->geometry.y);
749 /* If it does not match, move it to the screen coordinates */
750 if(cscreen != wibox->screen)
751 wibox_moveresize(L, udx, (area_t) { .x = s->geometry.x,
752 .y = s->geometry.y,
753 .width = wibox->geometry.width,
754 .height = wibox->geometry.height });
756 wibox_array_append(&globalconf.wiboxes, wibox);
758 wibox_init(wibox, phys_screen);
760 window_set_cursor(wibox->window,
761 xcursor_new(globalconf.connection, xcursor_font_fromstr(wibox->cursor)));
763 if(wibox->opacity != -1)
764 window_opacity_set(wibox->window, wibox->opacity);
766 ewmh_update_strut(wibox->window, &wibox->strut);
768 if(wibox->visible)
769 wibox_map(wibox);
770 else
771 wibox_need_update(wibox);
773 hook_property(wibox, "screen");
774 luaA_object_emit_signal(L, udx, "property::screen", 0);
777 /** Create a new wibox.
778 * \param L The Lua VM state.
780 * \luastack
781 * \lparam A table with optionaly defined values:
782 * fg, bg, border_width, border_color, ontop, width and height.
783 * \lreturn A brand new wibox.
785 static int
786 luaA_wibox_new(lua_State *L)
788 luaA_class_new(L, &wibox_class);
790 wibox_t *w = luaA_checkudata(L, -1, &wibox_class);
792 if(!w->ctx.fg.initialized)
793 w->ctx.fg = globalconf.colors.fg;
795 if(!w->ctx.bg.initialized)
796 w->ctx.bg = globalconf.colors.bg;
798 if(!w->border_color.initialized)
799 w->border_color = globalconf.colors.bg;
801 w->visible = true;
803 if(!w->opacity)
804 w->opacity = -1;
806 if(!w->cursor)
807 w->cursor = a_strdup("left_ptr");
809 if(!w->geometry.width)
810 w->geometry.width = 1;
812 if(!w->geometry.height)
813 w->geometry.height = 1;
815 return 1;
818 /** Check if a wibox widget table has an item.
819 * \param L The Lua VM state.
820 * \param wibox The wibox.
821 * \param item The item to look for.
823 static bool
824 luaA_wibox_hasitem(lua_State *L, wibox_t *wibox, const void *item)
826 if(wibox->widgets_table)
828 luaA_object_push(L, wibox);
829 luaA_object_push_item(L, -1, wibox->widgets_table);
830 lua_remove(L, -2);
831 if(lua_topointer(L, -1) == item || luaA_hasitem(L, item))
832 return true;
834 return false;
837 /** Invalidate a wibox by a Lua object (table, etc).
838 * \param L The Lua VM state.
839 * \param item The object identifier.
841 void
842 luaA_wibox_invalidate_byitem(lua_State *L, const void *item)
844 foreach(w, globalconf.wiboxes)
846 wibox_t *wibox = *w;
847 if(luaA_wibox_hasitem(L, wibox, item))
849 /* update wibox */
850 wibox_need_update(wibox);
851 lua_pop(L, 1); /* remove widgets table */
856 foreach(_c, globalconf.clients)
858 client_t *c = *_c;
859 if(c->titlebar && luaA_wibox_hasitem(L, c->titlebar, item))
861 /* update wibox */
862 wibox_need_update(c->titlebar);
863 lua_pop(L, 1); /* remove widgets table */
868 /* Set or get the wibox geometry.
869 * \param L The Lua VM state.
870 * \return The number of elements pushed on stack.
871 * \luastack
872 * \lparam An optional table with wibox geometry.
873 * \lreturn The wibox geometry.
875 static int
876 luaA_wibox_geometry(lua_State *L)
878 wibox_t *wibox = luaA_checkudata(L, 1, &wibox_class);
880 if(lua_gettop(L) == 2)
882 area_t wingeom;
884 luaA_checktable(L, 2);
885 wingeom.x = luaA_getopt_number(L, 2, "x", wibox->geometry.x);
886 wingeom.y = luaA_getopt_number(L, 2, "y", wibox->geometry.y);
887 wingeom.width = luaA_getopt_number(L, 2, "width", wibox->geometry.width);
888 wingeom.height = luaA_getopt_number(L, 2, "height", wibox->geometry.height);
890 if(wingeom.width > 0 && wingeom.height > 0)
891 switch(wibox->type)
893 case WIBOX_TYPE_TITLEBAR:
894 wibox_moveresize(L, 1, (area_t) { .x = wibox->geometry.x,
895 .y = wibox->geometry.y,
896 .width = wingeom.width,
897 .height = wingeom.height });
898 break;
899 case WIBOX_TYPE_NORMAL:
900 wibox_moveresize(L, 1, wingeom);
901 break;
905 return luaA_pusharea(L, wibox->geometry);
908 static int
909 luaA_wibox_struts(lua_State *L)
911 wibox_t *w = luaA_checkudata(L, 1, &wibox_class);
913 if(lua_gettop(L) == 2)
915 luaA_tostrut(L, 2, &w->strut);
916 if(w->window)
917 ewmh_update_strut(w->window, &w->strut);
918 luaA_object_emit_signal(L, 1, "property::struts", 0);
919 if(w->screen)
920 screen_emit_signal(L, w->screen, "property::workarea", 0);
923 return luaA_pushstrut(L, w->strut);
926 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, ontop, lua_pushboolean)
927 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, cursor, lua_pushstring)
928 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, visible, lua_pushboolean)
929 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, border_width, lua_pushnumber)
930 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, border_color, luaA_pushxcolor)
932 static int
933 luaA_wibox_set_x(lua_State *L, wibox_t *wibox)
935 wibox_moveresize(L, -3, (area_t) { .x = luaL_checknumber(L, -1),
936 .y = wibox->geometry.y,
937 .width = wibox->geometry.width,
938 .height = wibox->geometry.height });
939 return 0;
942 static int
943 luaA_wibox_get_x(lua_State *L, wibox_t *wibox)
945 lua_pushnumber(L, wibox->geometry.x);
946 return 1;
949 static int
950 luaA_wibox_set_y(lua_State *L, wibox_t *wibox)
952 wibox_moveresize(L, -3, (area_t) { .x = wibox->geometry.x,
953 .y = luaL_checknumber(L, -1),
954 .width = wibox->geometry.width,
955 .height = wibox->geometry.height });
956 return 0;
959 static int
960 luaA_wibox_get_y(lua_State *L, wibox_t *wibox)
962 lua_pushnumber(L, wibox->geometry.y);
963 return 1;
966 static int
967 luaA_wibox_set_width(lua_State *L, wibox_t *wibox)
969 int width = luaL_checknumber(L, -1);
970 if(width <= 0)
971 luaL_error(L, "invalid width");
972 wibox_moveresize(L, -3, (area_t) { .x = wibox->geometry.x,
973 .y = wibox->geometry.y,
974 .width = width,
975 .height = wibox->geometry.height });
976 return 0;
979 static int
980 luaA_wibox_get_width(lua_State *L, wibox_t *wibox)
982 lua_pushnumber(L, wibox->geometry.width);
983 return 1;
986 static int
987 luaA_wibox_set_height(lua_State *L, wibox_t *wibox)
989 int height = luaL_checknumber(L, -1);
990 if(height <= 0)
991 luaL_error(L, "invalid height");
992 wibox_moveresize(L, -3, (area_t) { .x = wibox->geometry.x,
993 .y = wibox->geometry.y,
994 .width = wibox->geometry.width,
995 .height = height });
996 return 0;
999 static int
1000 luaA_wibox_get_height(lua_State *L, wibox_t *wibox)
1002 lua_pushnumber(L, wibox->geometry.height);
1003 return 1;
1006 /** Set the wibox foreground color.
1007 * \param L The Lua VM state.
1008 * \param wibox The wibox object.
1009 * \return The number of elements pushed on stack.
1011 static int
1012 luaA_wibox_set_fg(lua_State *L, wibox_t *wibox)
1014 size_t len;
1015 const char *buf = luaL_checklstring(L, -1, &len);
1016 if(xcolor_init_reply(xcolor_init_unchecked(&wibox->ctx.fg, buf, len)))
1017 wibox->need_update = true;
1018 luaA_object_emit_signal(L, -3, "property::fg", 0);
1019 return 0;
1022 /** Get the wibox foreground color.
1023 * \param L The Lua VM state.
1024 * \param wibox The wibox object.
1025 * \return The number of elements pushed on stack.
1027 static int
1028 luaA_wibox_get_fg(lua_State *L, wibox_t *wibox)
1030 return luaA_pushxcolor(L, wibox->ctx.fg);
1033 /** Set the wibox background color.
1034 * \param L The Lua VM state.
1035 * \param wibox The wibox object.
1036 * \return The number of elements pushed on stack.
1038 static int
1039 luaA_wibox_set_bg(lua_State *L, wibox_t *wibox)
1041 size_t len;
1042 const char *buf = luaL_checklstring(L, -1, &len);
1043 if(xcolor_init_reply(xcolor_init_unchecked(&wibox->ctx.bg, buf, len)))
1044 wibox->need_update = true;
1045 luaA_object_emit_signal(L, -3, "property::bg", 0);
1046 return 0;
1049 /** Get the wibox background color.
1050 * \param L The Lua VM state.
1051 * \param wibox The wibox object.
1052 * \return The number of elements pushed on stack.
1054 static int
1055 luaA_wibox_get_bg(lua_State *L, wibox_t *wibox)
1057 return luaA_pushxcolor(L, wibox->ctx.bg);
1060 /** Set the wibox background image.
1061 * \param L The Lua VM state.
1062 * \param wibox The wibox object.
1063 * \return The number of elements pushed on stack.
1065 static int
1066 luaA_wibox_set_bg_image(lua_State *L, wibox_t *wibox)
1068 luaA_checkudata(L, -1, &image_class);
1069 luaA_object_unref_item(L, -3, wibox->bg_image);
1070 wibox->bg_image = luaA_object_ref_item(L, -3, -1);
1071 wibox->need_update = true;
1072 luaA_object_emit_signal(L, -2, "property::bg_image", 0);
1073 return 0;
1076 /** Get 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_get_bg_image(lua_State *L, wibox_t *wibox)
1084 return luaA_object_push_item(L, 1, wibox->bg_image);
1087 /** Set the wibox on top status.
1088 * \param L The Lua VM state.
1089 * \param wibox The wibox object.
1090 * \return The number of elements pushed on stack.
1092 static int
1093 luaA_wibox_set_ontop(lua_State *L, wibox_t *wibox)
1095 bool b = luaA_checkboolean(L, -1);
1096 if(b != wibox->ontop)
1098 wibox->ontop = b;
1099 client_stack();
1100 luaA_object_emit_signal(L, -3, "property::ontop", 0);
1102 return 0;
1105 /** Set the wibox opacity.
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_opacity(lua_State *L, wibox_t *wibox)
1113 if(lua_isnil(L, -1))
1114 wibox_set_opacity(L, -3, -1);
1115 else
1117 double d = luaL_checknumber(L, -1);
1118 if(d >= 0 && d <= 1)
1119 wibox_set_opacity(L, -3, d);
1121 return 0;
1124 /** Get the wibox opacity.
1125 * \param L The Lua VM state.
1126 * \param wibox The wibox object.
1127 * \return The number of elements pushed on stack.
1129 static int
1130 luaA_wibox_get_opacity(lua_State *L, wibox_t *wibox)
1132 if (wibox->opacity >= 0)
1134 lua_pushnumber(L, wibox->opacity);
1135 return 1;
1137 return 0;
1140 /** Set the wibox alignment.
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_set_align(lua_State *L, wibox_t *wibox)
1148 size_t len;
1149 const char *buf = luaL_checklstring(L, -1, &len);
1150 wibox->align = draw_align_fromstr(buf, len);
1151 luaA_object_emit_signal(L, -3, "property::align", 0);
1152 switch(wibox->type)
1154 case WIBOX_TYPE_NORMAL:
1155 luaA_deprecate(L, "awful.wibox.align");
1156 break;
1157 case WIBOX_TYPE_TITLEBAR:
1158 titlebar_update_geometry(client_getbytitlebar(wibox));
1159 break;
1161 return 0;
1164 /** Get the wibox alignment.
1165 * \param L The Lua VM state.
1166 * \param wibox The wibox object.
1167 * \return The number of elements pushed on stack.
1169 static int
1170 luaA_wibox_get_align(lua_State *L, wibox_t *wibox)
1172 if(wibox->type == WIBOX_TYPE_NORMAL)
1173 luaA_deprecate(L, "awful.wibox.align");
1174 lua_pushstring(L, draw_align_tostr(wibox->align));
1175 return 1;
1178 /** Set the wibox position.
1179 * \param L The Lua VM state.
1180 * \param wibox The wibox object.
1181 * \return The number of elements pushed on stack.
1183 static int
1184 luaA_wibox_set_position(lua_State *L, wibox_t *wibox)
1186 switch(wibox->type)
1188 case WIBOX_TYPE_NORMAL:
1190 size_t len;
1191 const char *buf;
1192 if((buf = luaL_checklstring(L, -1, &len)))
1194 luaA_deprecate(L, "awful.wibox.attach");
1195 wibox->position = position_fromstr(buf, len);
1198 break;
1199 case WIBOX_TYPE_TITLEBAR:
1200 return luaA_titlebar_set_position(L, -3);
1202 return 0;
1205 /** Get the wibox position.
1206 * \param L The Lua VM state.
1207 * \param wibox The wibox object.
1208 * \return The number of elements pushed on stack.
1210 static int
1211 luaA_wibox_get_position(lua_State *L, wibox_t *wibox)
1213 if(wibox->type == WIBOX_TYPE_NORMAL)
1214 luaA_deprecate(L, "awful.wibox.attach");
1215 lua_pushstring(L, position_tostr(wibox->position));
1216 return 1;
1219 /** Set the wibox (titlebar) client.
1220 * \param L The Lua VM state.
1221 * \param wibox The wibox object.
1222 * \return The number of elements pushed on stack.
1224 static int
1225 luaA_wibox_set_client(lua_State *L, wibox_t *wibox)
1227 /* first detach */
1228 if(lua_isnil(L, -1))
1229 titlebar_client_detach(client_getbytitlebar(wibox));
1230 else
1232 client_t *c = luaA_client_checkudata(L, -1);
1233 lua_pushvalue(L, -3);
1234 titlebar_client_attach(c);
1236 return 0;
1239 /** Get the wibox (titlebar) client.
1240 * \param L The Lua VM state.
1241 * \param wibox The wibox object.
1242 * \return The number of elements pushed on stack.
1244 static int
1245 luaA_wibox_get_client(lua_State *L, wibox_t *wibox)
1247 return luaA_object_push(L, client_getbytitlebar(wibox));
1250 /** Set the wibox cursor.
1251 * \param L The Lua VM state.
1252 * \param wibox The wibox object.
1253 * \return The number of elements pushed on stack.
1255 static int
1256 luaA_wibox_set_cursor(lua_State *L, wibox_t *wibox)
1258 const char *buf = luaL_checkstring(L, -1);
1259 if(buf)
1261 uint16_t cursor_font = xcursor_font_fromstr(buf);
1262 if(cursor_font)
1264 xcb_cursor_t cursor = xcursor_new(globalconf.connection, cursor_font);
1265 p_delete(&wibox->cursor);
1266 wibox->cursor = a_strdup(buf);
1267 window_set_cursor(wibox->window, cursor);
1268 luaA_object_emit_signal(L, -3, "property::cursor", 0);
1271 return 0;
1274 /** Set the wibox screen.
1275 * \param L The Lua VM state.
1276 * \param wibox The wibox object.
1277 * \return The number of elements pushed on stack.
1279 static int
1280 luaA_wibox_set_screen(lua_State *L, wibox_t *wibox)
1282 if(lua_isnil(L, -1))
1284 wibox_detach(L, -3);
1285 titlebar_client_detach(client_getbytitlebar(wibox));
1287 else
1289 int screen = luaL_checknumber(L, -1) - 1;
1290 luaA_checkscreen(screen);
1291 if(!wibox->screen || screen != screen_array_indexof(&globalconf.screens, wibox->screen))
1293 titlebar_client_detach(client_getbytitlebar(wibox));
1294 wibox_attach(L, -3, &globalconf.screens.tab[screen]);
1297 return 0;
1300 /** Get the wibox screen.
1301 * \param L The Lua VM state.
1302 * \param wibox The wibox object.
1303 * \return The number of elements pushed on stack.
1305 static int
1306 luaA_wibox_get_screen(lua_State *L, wibox_t *wibox)
1308 if(!wibox->screen)
1309 return 0;
1310 lua_pushnumber(L, screen_array_indexof(&globalconf.screens, wibox->screen) + 1);
1311 return 1;
1314 /** Set the wibox orientation.
1315 * \param L The Lua VM state.
1316 * \param wibox The wibox object.
1317 * \return The number of elements pushed on stack.
1319 static int
1320 luaA_wibox_set_orientation(lua_State *L, wibox_t *wibox)
1322 size_t len;
1323 const char *buf = luaL_checklstring(L, -1, &len);
1324 if(buf)
1326 wibox_set_orientation(L, -3, orientation_fromstr(buf, len));
1327 wibox_need_update(wibox);
1329 return 0;
1332 /** Get 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_get_orientation(lua_State *L, wibox_t *wibox)
1340 lua_pushstring(L, orientation_tostr(wibox->orientation));
1341 return 1;
1344 /** Set the wibox border color.
1345 * \param L The Lua VM state.
1346 * \param wibox The wibox object.
1347 * \return The number of elements pushed on stack.
1349 static int
1350 luaA_wibox_set_border_color(lua_State *L, wibox_t *wibox)
1352 size_t len;
1353 const char *buf = luaL_checklstring(L, -1, &len);
1354 if(buf)
1355 if(xcolor_init_reply(xcolor_init_unchecked(&wibox->border_color, buf, len)))
1356 if(wibox->window)
1357 wibox_set_border_color(L, -3, &wibox->border_color);
1358 return 0;
1361 /** Set the wibox visibility.
1362 * \param L The Lua VM state.
1363 * \param wibox The wibox object.
1364 * \return The number of elements pushed on stack.
1366 static int
1367 luaA_wibox_set_visible(lua_State *L, wibox_t *wibox)
1369 bool b = luaA_checkboolean(L, -1);
1370 if(b != wibox->visible)
1371 switch(wibox->type)
1373 case WIBOX_TYPE_NORMAL:
1374 wibox_set_visible(L, -3, b);
1375 break;
1376 case WIBOX_TYPE_TITLEBAR:
1377 titlebar_set_visible(wibox, b);
1378 break;
1380 return 0;
1383 /** Set the wibox widgets.
1384 * \param L The Lua VM state.
1385 * \param wibox The wibox object.
1386 * \return The number of elements pushed on stack.
1388 static int
1389 luaA_wibox_set_widgets(lua_State *L, wibox_t *wibox)
1391 if(luaA_isloop(L, -1))
1393 luaA_warn(L, "table is looping, cannot use this as widget table");
1394 return 0;
1396 /* duplicate table because next function will eat it */
1397 lua_pushvalue(L, -1);
1398 wibox->widgets_table = luaA_object_ref_item(L, -4, -1);
1399 luaA_object_emit_signal(L, -3, "property::widgets", 0);
1400 wibox_need_update(wibox);
1401 luaA_table2wtable(L);
1402 return 0;
1405 /** Get the wibox widgets.
1406 * \param L The Lua VM state.
1407 * \param wibox The wibox object.
1408 * \return The number of elements pushed on stack.
1410 static int
1411 luaA_wibox_get_widgets(lua_State *L, wibox_t *wibox)
1413 return luaA_object_push_item(L, 1, wibox->widgets_table);
1416 /** Get or set mouse buttons bindings to a wibox.
1417 * \param L The Lua VM state.
1418 * \luastack
1419 * \lvalue A wibox.
1420 * \lparam An array of mouse button bindings objects, or nothing.
1421 * \return The array of mouse button bindings objects of this wibox.
1423 static int
1424 luaA_wibox_buttons(lua_State *L)
1426 wibox_t *wibox = luaA_checkudata(L, 1, &wibox_class);
1428 if(lua_gettop(L) == 2)
1430 luaA_button_array_set(L, 1, 2, &wibox->buttons);
1431 luaA_object_emit_signal(L, 1, "property::buttons", 0);
1434 return luaA_button_array_get(L, 1, &wibox->buttons);
1437 /** Set the wibox border width.
1438 * \param L The Lua VM state.
1439 * \param wibox The wibox object.
1440 * \return The number of elements pushed on stack.
1442 static int
1443 luaA_wibox_set_border_width(lua_State *L, wibox_t *wibox)
1445 wibox_t *w = luaA_checkudata(L, -3, &wibox_class);
1446 uint32_t border_width = luaL_checknumber(L, -1);
1447 if(border_width != w->border_width)
1449 xcb_configure_window(globalconf.connection, w->window, XCB_CONFIG_WINDOW_BORDER_WIDTH,
1450 &border_width);
1451 w->border_width = border_width;
1452 luaA_object_emit_signal(L, -3, "property::border_width", 0);
1454 return 0;
1457 static int
1458 luaA_wibox_set_shape_bounding(lua_State *L, wibox_t *wibox)
1460 luaA_object_unref_item(L, -3, wibox->shape.bounding);
1461 wibox->shape.bounding = luaA_object_ref_item(L, -3, -1);
1462 wibox->need_shape_update = true;
1463 luaA_object_emit_signal(L, -2, "property::shape_bounding", 0);
1464 return 0;
1467 static int
1468 luaA_wibox_get_shape_bounding(lua_State *L, wibox_t *wibox)
1470 return luaA_object_push_item(L, 1, wibox->shape.bounding);
1473 static int
1474 luaA_wibox_set_shape_clip(lua_State *L, wibox_t *wibox)
1476 luaA_object_unref_item(L, -3, wibox->shape.clip);
1477 wibox->shape.clip = luaA_object_ref_item(L, -3, -1);
1478 wibox->need_shape_update = true;
1479 luaA_object_emit_signal(L, -2, "property::shape_clip", 0);
1480 return 0;
1483 static int
1484 luaA_wibox_get_shape_clip(lua_State *L, wibox_t *wibox)
1486 return luaA_object_push_item(L, 1, wibox->shape.clip);
1489 void
1490 wibox_class_setup(lua_State *L)
1492 static const struct luaL_reg wibox_methods[] =
1494 LUA_CLASS_METHODS(wibox)
1495 { "__call", luaA_wibox_new },
1496 { NULL, NULL }
1499 static const struct luaL_reg wibox_meta[] =
1501 LUA_OBJECT_META(wibox)
1502 LUA_CLASS_META
1503 { "struts", luaA_wibox_struts },
1504 { "buttons", luaA_wibox_buttons },
1505 { "geometry", luaA_wibox_geometry },
1506 { "__gc", luaA_wibox_gc },
1507 { NULL, NULL },
1510 luaA_class_setup(L, &wibox_class, "wibox", (lua_class_allocator_t) wibox_new,
1511 luaA_class_index_miss_property, luaA_class_newindex_miss_property,
1512 wibox_methods, wibox_meta);
1513 luaA_class_add_property(&wibox_class, A_TK_WIDGETS,
1514 (lua_class_propfunc_t) luaA_wibox_set_widgets,
1515 (lua_class_propfunc_t) luaA_wibox_get_widgets,
1516 (lua_class_propfunc_t) luaA_wibox_set_widgets);
1517 luaA_class_add_property(&wibox_class, A_TK_OPACITY,
1518 (lua_class_propfunc_t) luaA_wibox_set_opacity,
1519 (lua_class_propfunc_t) luaA_wibox_get_opacity,
1520 (lua_class_propfunc_t) luaA_wibox_set_opacity);
1521 luaA_class_add_property(&wibox_class, A_TK_VISIBLE,
1522 (lua_class_propfunc_t) luaA_wibox_set_visible,
1523 (lua_class_propfunc_t) luaA_wibox_get_visible,
1524 (lua_class_propfunc_t) luaA_wibox_set_visible);
1525 luaA_class_add_property(&wibox_class, A_TK_BORDER_COLOR,
1526 (lua_class_propfunc_t) luaA_wibox_set_border_color,
1527 (lua_class_propfunc_t) luaA_wibox_get_border_color,
1528 (lua_class_propfunc_t) luaA_wibox_set_border_color);
1529 luaA_class_add_property(&wibox_class, A_TK_BORDER_WIDTH,
1530 (lua_class_propfunc_t) luaA_wibox_set_border_width,
1531 (lua_class_propfunc_t) luaA_wibox_get_border_width,
1532 (lua_class_propfunc_t) luaA_wibox_set_border_width);
1533 luaA_class_add_property(&wibox_class, A_TK_ORIENTATION,
1534 (lua_class_propfunc_t) luaA_wibox_set_orientation,
1535 (lua_class_propfunc_t) luaA_wibox_get_orientation,
1536 (lua_class_propfunc_t) luaA_wibox_set_orientation);
1537 luaA_class_add_property(&wibox_class, A_TK_ONTOP,
1538 (lua_class_propfunc_t) luaA_wibox_set_ontop,
1539 (lua_class_propfunc_t) luaA_wibox_get_ontop,
1540 (lua_class_propfunc_t) luaA_wibox_set_ontop);
1541 luaA_class_add_property(&wibox_class, A_TK_SCREEN,
1542 NULL,
1543 (lua_class_propfunc_t) luaA_wibox_get_screen,
1544 (lua_class_propfunc_t) luaA_wibox_set_screen);
1545 luaA_class_add_property(&wibox_class, A_TK_CURSOR,
1546 (lua_class_propfunc_t) luaA_wibox_set_cursor,
1547 (lua_class_propfunc_t) luaA_wibox_get_cursor,
1548 (lua_class_propfunc_t) luaA_wibox_set_cursor);
1549 luaA_class_add_property(&wibox_class, A_TK_CLIENT,
1550 (lua_class_propfunc_t) luaA_wibox_set_client,
1551 (lua_class_propfunc_t) luaA_wibox_get_client,
1552 (lua_class_propfunc_t) luaA_wibox_set_client);
1553 luaA_class_add_property(&wibox_class, A_TK_POSITION,
1554 (lua_class_propfunc_t) luaA_wibox_set_position,
1555 (lua_class_propfunc_t) luaA_wibox_get_position,
1556 (lua_class_propfunc_t) luaA_wibox_set_position);
1557 luaA_class_add_property(&wibox_class, A_TK_ALIGN,
1558 (lua_class_propfunc_t) luaA_wibox_set_align,
1559 (lua_class_propfunc_t) luaA_wibox_get_align,
1560 (lua_class_propfunc_t) luaA_wibox_set_align);
1561 luaA_class_add_property(&wibox_class, A_TK_FG,
1562 (lua_class_propfunc_t) luaA_wibox_set_fg,
1563 (lua_class_propfunc_t) luaA_wibox_get_fg,
1564 (lua_class_propfunc_t) luaA_wibox_set_fg);
1565 luaA_class_add_property(&wibox_class, A_TK_BG,
1566 (lua_class_propfunc_t) luaA_wibox_set_bg,
1567 (lua_class_propfunc_t) luaA_wibox_get_bg,
1568 (lua_class_propfunc_t) luaA_wibox_set_bg);
1569 luaA_class_add_property(&wibox_class, A_TK_BG_IMAGE,
1570 (lua_class_propfunc_t) luaA_wibox_set_bg_image,
1571 (lua_class_propfunc_t) luaA_wibox_get_bg_image,
1572 (lua_class_propfunc_t) luaA_wibox_set_bg_image);
1573 luaA_class_add_property(&wibox_class, A_TK_X,
1574 (lua_class_propfunc_t) luaA_wibox_set_x,
1575 (lua_class_propfunc_t) luaA_wibox_get_x,
1576 (lua_class_propfunc_t) luaA_wibox_set_x);
1577 luaA_class_add_property(&wibox_class, A_TK_Y,
1578 (lua_class_propfunc_t) luaA_wibox_set_y,
1579 (lua_class_propfunc_t) luaA_wibox_get_y,
1580 (lua_class_propfunc_t) luaA_wibox_set_y);
1581 luaA_class_add_property(&wibox_class, A_TK_WIDTH,
1582 (lua_class_propfunc_t) luaA_wibox_set_width,
1583 (lua_class_propfunc_t) luaA_wibox_get_width,
1584 (lua_class_propfunc_t) luaA_wibox_set_width);
1585 luaA_class_add_property(&wibox_class, A_TK_HEIGHT,
1586 (lua_class_propfunc_t) luaA_wibox_set_height,
1587 (lua_class_propfunc_t) luaA_wibox_get_height,
1588 (lua_class_propfunc_t) luaA_wibox_set_height);
1589 luaA_class_add_property(&wibox_class, A_TK_SHAPE_BOUNDING,
1590 (lua_class_propfunc_t) luaA_wibox_set_shape_bounding,
1591 (lua_class_propfunc_t) luaA_wibox_get_shape_bounding,
1592 (lua_class_propfunc_t) luaA_wibox_set_shape_bounding);
1593 luaA_class_add_property(&wibox_class, A_TK_SHAPE_CLIP,
1594 (lua_class_propfunc_t) luaA_wibox_set_shape_clip,
1595 (lua_class_propfunc_t) luaA_wibox_get_shape_clip,
1596 (lua_class_propfunc_t) luaA_wibox_set_shape_clip);
1599 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80