screen: move the tagging on screen change to Lua
[awesome.git] / wibox.c
blobca9f9a2cb2e41ad9e47e11b46d19d0655386f3bb
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 if(mask_vals)
262 xcb_configure_window(globalconf.connection, w->window, mask_vals, moveresize_win_vals);
264 w->screen = screen_getbycoord(w->screen, w->geometry.x, w->geometry.y);
266 if(mask_vals & XCB_CONFIG_WINDOW_X)
267 luaA_object_emit_signal(L, udx, "property::x", 0);
268 if(mask_vals & XCB_CONFIG_WINDOW_Y)
269 luaA_object_emit_signal(L, udx, "property::y", 0);
270 if(mask_vals & XCB_CONFIG_WINDOW_WIDTH)
271 luaA_object_emit_signal(L, udx, "property::width", 0);
272 if(mask_vals & XCB_CONFIG_WINDOW_HEIGHT)
273 luaA_object_emit_signal(L, udx, "property::height", 0);
275 else
277 #define DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(prop) \
278 if(w->geometry.prop != geometry.prop) \
280 w->geometry.prop = geometry.prop; \
281 luaA_object_emit_signal(L, udx, "property::" #prop, 0); \
283 DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(x)
284 DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(y)
285 DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(width)
286 DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(height)
287 #undef DO_WIBOX_GEOMETRY_CHECK_AND_EMIT
290 wibox_need_update(w);
293 /** Refresh the window content by copying its pixmap data to its window.
294 * \param wibox The wibox to refresh.
295 * \param x The copy starting point x component.
296 * \param y The copy starting point y component.
297 * \param w The copy width from the x component.
298 * \param h The copy height from the y component.
300 void
301 wibox_refresh_pixmap_partial(wibox_t *wibox,
302 int16_t x, int16_t y,
303 uint16_t w, uint16_t h)
305 xcb_copy_area(globalconf.connection, wibox->pixmap,
306 wibox->window, wibox->gc, x, y, x, y,
307 w, h);
310 void
311 wibox_set_opacity(lua_State *L, int udx, double opacity)
313 wibox_t *w = luaA_checkudata(L, udx, &wibox_class);
314 if(w->opacity != opacity)
316 w->opacity = opacity;
317 if(w->window)
318 window_opacity_set(w->window, opacity);
319 luaA_object_emit_signal(L, udx, "property::opacity", 0);
323 /** Set a wibox border color.
324 * \param L The Lua VM state.
325 * \param idx The wibox to change border width.
326 * \param color The border color.
328 static void
329 wibox_set_border_color(lua_State *L, int udx, const xcolor_t *color)
331 wibox_t *w = luaA_checkudata(L, udx, &wibox_class);
332 xcb_change_window_attributes(globalconf.connection, w->window,
333 XCB_CW_BORDER_PIXEL, &color->pixel);
334 w->border_color = *color;
335 luaA_object_emit_signal(L, udx, "property::border_color", 0);
338 /** Set wibox orientation.
339 * \param L The Lua VM state.
340 * \param w The wibox.
341 * \param o The new orientation.
343 void
344 wibox_set_orientation(lua_State *L, int udx, orientation_t o)
346 wibox_t *w = luaA_checkudata(L, udx, &wibox_class);
347 if(o != w->orientation)
349 xcb_screen_t *s = xutil_screen_get(globalconf.connection, w->ctx.phys_screen);
350 w->orientation = o;
351 /* orientation != East */
352 if(w->pixmap != w->ctx.pixmap)
353 xcb_free_pixmap(globalconf.connection, w->ctx.pixmap);
354 wibox_draw_context_update(w, s);
355 luaA_object_emit_signal(L, udx, "property::orientation", 0);
359 static void
360 wibox_map(wibox_t *wibox)
362 xcb_map_window(globalconf.connection, wibox->window);
363 /* We must make sure the wibox does not display garbage */
364 wibox_need_update(wibox);
365 /* Stack this wibox correctly */
366 client_stack();
369 /** Kick out systray windows.
370 * \param phys_screen Physical screen number.
372 static void
373 wibox_systray_kickout(int phys_screen)
375 xcb_screen_t *s = xutil_screen_get(globalconf.connection, phys_screen);
377 if(globalconf.screens.tab[phys_screen].systray.parent != s->root)
379 /* Who! Check that we're not deleting a wibox with a systray, because it
380 * may be its parent. If so, we reparent to root before, otherwise it will
381 * hurt very much. */
382 xcb_reparent_window(globalconf.connection,
383 globalconf.screens.tab[phys_screen].systray.window,
384 s->root, -512, -512);
386 globalconf.screens.tab[phys_screen].systray.parent = s->root;
390 static void
391 wibox_systray_refresh(wibox_t *wibox)
393 if(!wibox->screen)
394 return;
396 for(int i = 0; i < wibox->widgets.len; i++)
398 widget_node_t *systray = &wibox->widgets.tab[i];
399 if(systray->widget->type == widget_systray)
401 uint32_t config_back[] = { wibox->ctx.bg.pixel };
402 uint32_t config_win_vals[4];
403 uint32_t config_win_vals_off[2] = { -512, -512 };
404 xembed_window_t *em;
405 int phys_screen = wibox->ctx.phys_screen;
407 if(wibox->visible
408 && systray->widget->isvisible
409 && systray->geometry.width)
411 /* Set background of the systray window. */
412 xcb_change_window_attributes(globalconf.connection,
413 globalconf.screens.tab[phys_screen].systray.window,
414 XCB_CW_BACK_PIXEL, config_back);
415 /* Map it. */
416 xcb_map_window(globalconf.connection, globalconf.screens.tab[phys_screen].systray.window);
417 /* Move it. */
418 switch(wibox->orientation)
420 case North:
421 config_win_vals[0] = systray->geometry.y;
422 config_win_vals[1] = wibox->geometry.height - systray->geometry.x - systray->geometry.width;
423 config_win_vals[2] = systray->geometry.height;
424 config_win_vals[3] = systray->geometry.width;
425 break;
426 case South:
427 config_win_vals[0] = systray->geometry.y;
428 config_win_vals[1] = systray->geometry.x;
429 config_win_vals[2] = systray->geometry.height;
430 config_win_vals[3] = systray->geometry.width;
431 break;
432 case East:
433 config_win_vals[0] = systray->geometry.x;
434 config_win_vals[1] = systray->geometry.y;
435 config_win_vals[2] = systray->geometry.width;
436 config_win_vals[3] = systray->geometry.height;
437 break;
439 /* reparent */
440 if(globalconf.screens.tab[phys_screen].systray.parent != wibox->window)
442 xcb_reparent_window(globalconf.connection,
443 globalconf.screens.tab[phys_screen].systray.window,
444 wibox->window,
445 config_win_vals[0], config_win_vals[1]);
446 globalconf.screens.tab[phys_screen].systray.parent = wibox->window;
448 xcb_configure_window(globalconf.connection,
449 globalconf.screens.tab[phys_screen].systray.window,
450 XCB_CONFIG_WINDOW_X
451 | XCB_CONFIG_WINDOW_Y
452 | XCB_CONFIG_WINDOW_WIDTH
453 | XCB_CONFIG_WINDOW_HEIGHT,
454 config_win_vals);
455 /* width = height = systray height */
456 config_win_vals[2] = config_win_vals[3] = systray->geometry.height;
457 config_win_vals[0] = 0;
459 else
460 return wibox_systray_kickout(phys_screen);
462 switch(wibox->orientation)
464 case North:
465 config_win_vals[1] = systray->geometry.width - config_win_vals[3];
466 for(int j = 0; j < globalconf.embedded.len; j++)
468 em = &globalconf.embedded.tab[j];
469 if(em->phys_screen == phys_screen)
471 if(config_win_vals[1] - config_win_vals[2] >= (uint32_t) wibox->geometry.y)
473 xcb_map_window(globalconf.connection, em->win);
474 xcb_configure_window(globalconf.connection, em->win,
475 XCB_CONFIG_WINDOW_X
476 | XCB_CONFIG_WINDOW_Y
477 | XCB_CONFIG_WINDOW_WIDTH
478 | XCB_CONFIG_WINDOW_HEIGHT,
479 config_win_vals);
480 config_win_vals[1] -= config_win_vals[3];
482 else
483 xcb_configure_window(globalconf.connection, em->win,
484 XCB_CONFIG_WINDOW_X
485 | XCB_CONFIG_WINDOW_Y,
486 config_win_vals_off);
489 break;
490 case South:
491 config_win_vals[1] = 0;
492 for(int j = 0; j < globalconf.embedded.len; j++)
494 em = &globalconf.embedded.tab[j];
495 if(em->phys_screen == phys_screen)
497 /* if(y + width <= wibox.y + systray.right) */
498 if(config_win_vals[1] + config_win_vals[3] <= (uint32_t) wibox->geometry.y + AREA_RIGHT(systray->geometry))
500 xcb_map_window(globalconf.connection, em->win);
501 xcb_configure_window(globalconf.connection, em->win,
502 XCB_CONFIG_WINDOW_X
503 | XCB_CONFIG_WINDOW_Y
504 | XCB_CONFIG_WINDOW_WIDTH
505 | XCB_CONFIG_WINDOW_HEIGHT,
506 config_win_vals);
507 config_win_vals[1] += config_win_vals[3];
509 else
510 xcb_configure_window(globalconf.connection, em->win,
511 XCB_CONFIG_WINDOW_X
512 | XCB_CONFIG_WINDOW_Y,
513 config_win_vals_off);
516 break;
517 case East:
518 config_win_vals[1] = 0;
519 for(int j = 0; j < globalconf.embedded.len; j++)
521 em = &globalconf.embedded.tab[j];
522 if(em->phys_screen == phys_screen)
524 /* if(x + width < systray.x + systray.width) */
525 if(config_win_vals[0] + config_win_vals[2] <= (uint32_t) AREA_RIGHT(systray->geometry) + wibox->geometry.x)
527 xcb_map_window(globalconf.connection, em->win);
528 xcb_configure_window(globalconf.connection, em->win,
529 XCB_CONFIG_WINDOW_X
530 | XCB_CONFIG_WINDOW_Y
531 | XCB_CONFIG_WINDOW_WIDTH
532 | XCB_CONFIG_WINDOW_HEIGHT,
533 config_win_vals);
534 config_win_vals[0] += config_win_vals[2];
536 else
537 xcb_configure_window(globalconf.connection, em->win,
538 XCB_CONFIG_WINDOW_X
539 | XCB_CONFIG_WINDOW_Y,
540 config_win_vals_off);
543 break;
545 break;
550 /** Get a wibox by its window.
551 * \param win The window id.
552 * \return A wibox if found, NULL otherwise.
554 wibox_t *
555 wibox_getbywin(xcb_window_t win)
557 foreach(w, globalconf.wiboxes)
558 if((*w)->window == win)
559 return *w;
561 foreach(_c, globalconf.clients)
563 client_t *c = *_c;
564 if(c->titlebar && c->titlebar->window == win)
565 return c->titlebar;
568 return NULL;
571 /** Draw a wibox.
572 * \param wibox The wibox to draw.
574 static void
575 wibox_draw(wibox_t *wibox)
577 if(wibox->visible)
579 widget_render(wibox);
580 wibox_refresh_pixmap(wibox);
582 wibox->need_update = false;
585 wibox_systray_refresh(wibox);
588 /** Refresh all wiboxes.
590 void
591 wibox_refresh(void)
593 foreach(w, globalconf.wiboxes)
595 if((*w)->need_shape_update)
596 wibox_shape_update(*w);
597 if((*w)->need_update)
598 wibox_draw(*w);
601 foreach(_c, globalconf.clients)
603 client_t *c = *_c;
604 if(c->titlebar && c->titlebar->need_update)
605 wibox_draw(c->titlebar);
609 /** Set a wibox visible or not.
610 * \param wibox The wibox.
611 * \param v The visible value.
613 static void
614 wibox_set_visible(lua_State *L, int udx, bool v)
616 wibox_t *wibox = luaA_checkudata(L, udx, &wibox_class);
617 if(v != wibox->visible)
619 wibox->visible = v;
620 wibox->mouse_over = NULL;
622 if(wibox->screen)
624 if(wibox->visible)
625 wibox_map(wibox);
626 else
627 xcb_unmap_window(globalconf.connection, wibox->window);
629 /* kick out systray if needed */
630 wibox_systray_refresh(wibox);
633 luaA_object_emit_signal(L, udx, "property::visible", 0);
635 hook_property(wibox, "visible");
639 /** Destroy all X resources of a wibox.
640 * \param w The wibox to wipe.
642 void
643 wibox_wipe(wibox_t *w)
645 if(w->window)
647 xcb_destroy_window(globalconf.connection, w->window);
648 w->window = XCB_NONE;
650 if(w->pixmap)
652 xcb_free_pixmap(globalconf.connection, w->pixmap);
653 w->pixmap = XCB_NONE;
655 if(w->gc)
657 xcb_free_gc(globalconf.connection, w->gc);
658 w->gc = XCB_NONE;
660 draw_context_wipe(&w->ctx);
663 /** Remove a wibox from a screen.
664 * \param L The Lua VM state.
665 * \param udx Wibox to detach from screen.
667 static void
668 wibox_detach(lua_State *L, int udx)
670 wibox_t *wibox = luaA_checkudata(L, udx, &wibox_class);
671 if(wibox->screen)
673 bool v;
675 /* save visible state */
676 v = wibox->visible;
677 wibox->visible = false;
678 wibox_systray_refresh(wibox);
679 /* restore visibility */
680 wibox->visible = v;
682 wibox->mouse_over = NULL;
684 wibox_wipe(wibox);
686 foreach(item, globalconf.wiboxes)
687 if(*item == wibox)
689 wibox_array_remove(&globalconf.wiboxes, item);
690 break;
693 hook_property(wibox, "screen");
695 wibox->screen = NULL;
696 luaA_object_emit_signal(L, udx, "property::screen", 0);
698 luaA_object_unref(globalconf.L, wibox);
702 /** Attach a wibox that is on top of the stack.
703 * \param s The screen to attach the wibox to.
705 static void
706 wibox_attach(lua_State *L, int udx, screen_t *s)
708 int phys_screen = screen_virttophys(screen_array_indexof(&globalconf.screens, s));
710 /* duplicate wibox */
711 lua_pushvalue(L, udx);
712 /* ref it */
713 wibox_t *wibox = luaA_object_ref(globalconf.L, -1);
715 wibox_detach(L, udx);
717 /* Set the wibox screen */
718 wibox->screen = s;
720 /* Check that the wibox coordinates matches the screen. */
721 screen_t *cscreen =
722 screen_getbycoord(wibox->screen, wibox->geometry.x, wibox->geometry.y);
724 /* If it does not match, move it to the screen coordinates */
725 if(cscreen != wibox->screen)
726 wibox_moveresize(L, udx, (area_t) { .x = s->geometry.x,
727 .y = s->geometry.y,
728 .width = wibox->geometry.width,
729 .height = wibox->geometry.height });
731 wibox_array_append(&globalconf.wiboxes, wibox);
733 wibox_init(wibox, phys_screen);
735 window_set_cursor(wibox->window,
736 xcursor_new(globalconf.connection, xcursor_font_fromstr(wibox->cursor)));
738 if(wibox->opacity != -1)
739 window_opacity_set(wibox->window, wibox->opacity);
741 ewmh_update_strut(wibox->window, &wibox->strut);
743 if(wibox->visible)
744 wibox_map(wibox);
745 else
746 wibox_need_update(wibox);
748 hook_property(wibox, "screen");
749 luaA_object_emit_signal(L, udx, "property::screen", 0);
752 /** Create a new wibox.
753 * \param L The Lua VM state.
755 * \luastack
756 * \lparam A table with optionaly defined values:
757 * fg, bg, border_width, border_color, ontop, width and height.
758 * \lreturn A brand new wibox.
760 static int
761 luaA_wibox_new(lua_State *L)
763 luaA_class_new(L, &wibox_class);
765 wibox_t *w = luaA_checkudata(L, -1, &wibox_class);
767 if(!w->ctx.fg.initialized)
768 w->ctx.fg = globalconf.colors.fg;
770 if(!w->ctx.bg.initialized)
771 w->ctx.bg = globalconf.colors.bg;
773 if(!w->border_color.initialized)
774 w->border_color = globalconf.colors.bg;
776 w->visible = true;
778 if(!w->opacity)
779 w->opacity = -1;
781 if(!w->cursor)
782 w->cursor = a_strdup("left_ptr");
784 if(!w->geometry.width)
785 w->geometry.width = 1;
787 if(!w->geometry.height)
788 w->geometry.height = 1;
790 return 1;
793 /** Check if a wibox widget table has an item.
794 * \param L The Lua VM state.
795 * \param wibox The wibox.
796 * \param item The item to look for.
798 static bool
799 luaA_wibox_hasitem(lua_State *L, wibox_t *wibox, const void *item)
801 if(wibox->widgets_table)
803 luaA_object_push(L, wibox);
804 luaA_object_push_item(L, -1, wibox->widgets_table);
805 lua_remove(L, -2);
806 if(lua_topointer(L, -1) == item || luaA_hasitem(L, item))
807 return true;
809 return false;
812 /** Invalidate a wibox by a Lua object (table, etc).
813 * \param L The Lua VM state.
814 * \param item The object identifier.
816 void
817 luaA_wibox_invalidate_byitem(lua_State *L, const void *item)
819 foreach(w, globalconf.wiboxes)
821 wibox_t *wibox = *w;
822 if(luaA_wibox_hasitem(L, wibox, item))
824 /* update wibox */
825 wibox_need_update(wibox);
826 lua_pop(L, 1); /* remove widgets table */
831 foreach(_c, globalconf.clients)
833 client_t *c = *_c;
834 if(c->titlebar && luaA_wibox_hasitem(L, c->titlebar, item))
836 /* update wibox */
837 wibox_need_update(c->titlebar);
838 lua_pop(L, 1); /* remove widgets table */
843 /* Set or get the wibox geometry.
844 * \param L The Lua VM state.
845 * \return The number of elements pushed on stack.
846 * \luastack
847 * \lparam An optional table with wibox geometry.
848 * \lreturn The wibox geometry.
850 static int
851 luaA_wibox_geometry(lua_State *L)
853 wibox_t *wibox = luaA_checkudata(L, 1, &wibox_class);
855 if(lua_gettop(L) == 2)
857 area_t wingeom;
859 luaA_checktable(L, 2);
860 wingeom.x = luaA_getopt_number(L, 2, "x", wibox->geometry.x);
861 wingeom.y = luaA_getopt_number(L, 2, "y", wibox->geometry.y);
862 wingeom.width = luaA_getopt_number(L, 2, "width", wibox->geometry.width);
863 wingeom.height = luaA_getopt_number(L, 2, "height", wibox->geometry.height);
865 if(wingeom.width > 0 && wingeom.height > 0)
866 switch(wibox->type)
868 case WIBOX_TYPE_TITLEBAR:
869 wibox_moveresize(L, 1, (area_t) { .x = wibox->geometry.x,
870 .y = wibox->geometry.y,
871 .width = wingeom.width,
872 .height = wingeom.height });
873 break;
874 case WIBOX_TYPE_NORMAL:
875 wibox_moveresize(L, 1, wingeom);
876 break;
880 return luaA_pusharea(L, wibox->geometry);
883 static int
884 luaA_wibox_struts(lua_State *L)
886 wibox_t *w = luaA_checkudata(L, 1, &wibox_class);
888 if(lua_gettop(L) == 2)
890 luaA_tostrut(L, 2, &w->strut);
891 if(w->window)
892 ewmh_update_strut(w->window, &w->strut);
893 luaA_object_emit_signal(L, 1, "property::struts", 0);
894 if(w->screen)
895 screen_emit_signal(L, w->screen, "property::workarea", 0);
898 return luaA_pushstrut(L, w->strut);
901 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, ontop, lua_pushboolean)
902 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, cursor, lua_pushstring)
903 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, visible, lua_pushboolean)
904 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, border_width, lua_pushnumber)
905 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, border_color, luaA_pushxcolor)
907 static int
908 luaA_wibox_set_x(lua_State *L, wibox_t *wibox)
910 wibox_moveresize(L, -3, (area_t) { .x = luaL_checknumber(L, -1),
911 .y = wibox->geometry.y,
912 .width = wibox->geometry.width,
913 .height = wibox->geometry.height });
914 return 0;
917 static int
918 luaA_wibox_get_x(lua_State *L, wibox_t *wibox)
920 lua_pushnumber(L, wibox->geometry.x);
921 return 1;
924 static int
925 luaA_wibox_set_y(lua_State *L, wibox_t *wibox)
927 wibox_moveresize(L, -3, (area_t) { .x = wibox->geometry.x,
928 .y = luaL_checknumber(L, -1),
929 .width = wibox->geometry.width,
930 .height = wibox->geometry.height });
931 return 0;
934 static int
935 luaA_wibox_get_y(lua_State *L, wibox_t *wibox)
937 lua_pushnumber(L, wibox->geometry.y);
938 return 1;
941 static int
942 luaA_wibox_set_width(lua_State *L, wibox_t *wibox)
944 int width = luaL_checknumber(L, -1);
945 if(width <= 0)
946 luaL_error(L, "invalid width");
947 wibox_moveresize(L, -3, (area_t) { .x = wibox->geometry.x,
948 .y = wibox->geometry.y,
949 .width = width,
950 .height = wibox->geometry.height });
951 return 0;
954 static int
955 luaA_wibox_get_width(lua_State *L, wibox_t *wibox)
957 lua_pushnumber(L, wibox->geometry.width);
958 return 1;
961 static int
962 luaA_wibox_set_height(lua_State *L, wibox_t *wibox)
964 int height = luaL_checknumber(L, -1);
965 if(height <= 0)
966 luaL_error(L, "invalid height");
967 wibox_moveresize(L, -3, (area_t) { .x = wibox->geometry.x,
968 .y = wibox->geometry.y,
969 .width = wibox->geometry.width,
970 .height = height });
971 return 0;
974 static int
975 luaA_wibox_get_height(lua_State *L, wibox_t *wibox)
977 lua_pushnumber(L, wibox->geometry.height);
978 return 1;
981 /** Set the wibox foreground color.
982 * \param L The Lua VM state.
983 * \param wibox The wibox object.
984 * \return The number of elements pushed on stack.
986 static int
987 luaA_wibox_set_fg(lua_State *L, wibox_t *wibox)
989 size_t len;
990 const char *buf = luaL_checklstring(L, -1, &len);
991 if(xcolor_init_reply(xcolor_init_unchecked(&wibox->ctx.fg, buf, len)))
992 wibox->need_update = true;
993 luaA_object_emit_signal(L, -3, "property::fg", 0);
994 return 0;
997 /** Get the wibox foreground color.
998 * \param L The Lua VM state.
999 * \param wibox The wibox object.
1000 * \return The number of elements pushed on stack.
1002 static int
1003 luaA_wibox_get_fg(lua_State *L, wibox_t *wibox)
1005 return luaA_pushxcolor(L, wibox->ctx.fg);
1008 /** Set the wibox background color.
1009 * \param L The Lua VM state.
1010 * \param wibox The wibox object.
1011 * \return The number of elements pushed on stack.
1013 static int
1014 luaA_wibox_set_bg(lua_State *L, wibox_t *wibox)
1016 size_t len;
1017 const char *buf = luaL_checklstring(L, -1, &len);
1018 if(xcolor_init_reply(xcolor_init_unchecked(&wibox->ctx.bg, buf, len)))
1019 wibox->need_update = true;
1020 luaA_object_emit_signal(L, -3, "property::bg", 0);
1021 return 0;
1024 /** Get the wibox background color.
1025 * \param L The Lua VM state.
1026 * \param wibox The wibox object.
1027 * \return The number of elements pushed on stack.
1029 static int
1030 luaA_wibox_get_bg(lua_State *L, wibox_t *wibox)
1032 return luaA_pushxcolor(L, wibox->ctx.bg);
1035 /** Set the wibox background image.
1036 * \param L The Lua VM state.
1037 * \param wibox The wibox object.
1038 * \return The number of elements pushed on stack.
1040 static int
1041 luaA_wibox_set_bg_image(lua_State *L, wibox_t *wibox)
1043 luaA_checkudata(L, -1, &image_class);
1044 luaA_object_unref_item(L, -3, wibox->bg_image);
1045 wibox->bg_image = luaA_object_ref_item(L, -3, -1);
1046 wibox->need_update = true;
1047 luaA_object_emit_signal(L, -2, "property::bg_image", 0);
1048 return 0;
1051 /** Get the wibox background image.
1052 * \param L The Lua VM state.
1053 * \param wibox The wibox object.
1054 * \return The number of elements pushed on stack.
1056 static int
1057 luaA_wibox_get_bg_image(lua_State *L, wibox_t *wibox)
1059 return luaA_object_push_item(L, 1, wibox->bg_image);
1062 /** Set the wibox on top status.
1063 * \param L The Lua VM state.
1064 * \param wibox The wibox object.
1065 * \return The number of elements pushed on stack.
1067 static int
1068 luaA_wibox_set_ontop(lua_State *L, wibox_t *wibox)
1070 bool b = luaA_checkboolean(L, -1);
1071 if(b != wibox->ontop)
1073 wibox->ontop = b;
1074 client_stack();
1075 luaA_object_emit_signal(L, -3, "property::ontop", 0);
1077 return 0;
1080 /** Set the wibox opacity.
1081 * \param L The Lua VM state.
1082 * \param wibox The wibox object.
1083 * \return The number of elements pushed on stack.
1085 static int
1086 luaA_wibox_set_opacity(lua_State *L, wibox_t *wibox)
1088 if(lua_isnil(L, -1))
1089 wibox_set_opacity(L, -3, -1);
1090 else
1092 double d = luaL_checknumber(L, -1);
1093 if(d >= 0 && d <= 1)
1094 wibox_set_opacity(L, -3, d);
1096 return 0;
1099 /** Get the wibox opacity.
1100 * \param L The Lua VM state.
1101 * \param wibox The wibox object.
1102 * \return The number of elements pushed on stack.
1104 static int
1105 luaA_wibox_get_opacity(lua_State *L, wibox_t *wibox)
1107 if (wibox->opacity >= 0)
1109 lua_pushnumber(L, wibox->opacity);
1110 return 1;
1112 return 0;
1115 /** Set the wibox alignment.
1116 * \param L The Lua VM state.
1117 * \param wibox The wibox object.
1118 * \return The number of elements pushed on stack.
1120 static int
1121 luaA_wibox_set_align(lua_State *L, wibox_t *wibox)
1123 size_t len;
1124 const char *buf = luaL_checklstring(L, -1, &len);
1125 wibox->align = draw_align_fromstr(buf, len);
1126 luaA_object_emit_signal(L, -3, "property::align", 0);
1127 switch(wibox->type)
1129 case WIBOX_TYPE_NORMAL:
1130 luaA_deprecate(L, "awful.wibox.align");
1131 break;
1132 case WIBOX_TYPE_TITLEBAR:
1133 titlebar_update_geometry(client_getbytitlebar(wibox));
1134 break;
1136 return 0;
1139 /** Get the wibox alignment.
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_align(lua_State *L, wibox_t *wibox)
1147 if(wibox->type == WIBOX_TYPE_NORMAL)
1148 luaA_deprecate(L, "awful.wibox.align");
1149 lua_pushstring(L, draw_align_tostr(wibox->align));
1150 return 1;
1153 /** Set the wibox position.
1154 * \param L The Lua VM state.
1155 * \param wibox The wibox object.
1156 * \return The number of elements pushed on stack.
1158 static int
1159 luaA_wibox_set_position(lua_State *L, wibox_t *wibox)
1161 switch(wibox->type)
1163 case WIBOX_TYPE_NORMAL:
1165 size_t len;
1166 const char *buf;
1167 if((buf = luaL_checklstring(L, -1, &len)))
1169 luaA_deprecate(L, "awful.wibox.attach");
1170 wibox->position = position_fromstr(buf, len);
1173 break;
1174 case WIBOX_TYPE_TITLEBAR:
1175 return luaA_titlebar_set_position(L, -3);
1177 return 0;
1180 /** Get the wibox position.
1181 * \param L The Lua VM state.
1182 * \param wibox The wibox object.
1183 * \return The number of elements pushed on stack.
1185 static int
1186 luaA_wibox_get_position(lua_State *L, wibox_t *wibox)
1188 if(wibox->type == WIBOX_TYPE_NORMAL)
1189 luaA_deprecate(L, "awful.wibox.attach");
1190 lua_pushstring(L, position_tostr(wibox->position));
1191 return 1;
1194 /** Set the wibox (titlebar) client.
1195 * \param L The Lua VM state.
1196 * \param wibox The wibox object.
1197 * \return The number of elements pushed on stack.
1199 static int
1200 luaA_wibox_set_client(lua_State *L, wibox_t *wibox)
1202 /* first detach */
1203 if(lua_isnil(L, -1))
1204 titlebar_client_detach(client_getbytitlebar(wibox));
1205 else
1207 client_t *c = luaA_client_checkudata(L, -1);
1208 lua_pushvalue(L, -3);
1209 titlebar_client_attach(c);
1211 return 0;
1214 /** Get the wibox (titlebar) client.
1215 * \param L The Lua VM state.
1216 * \param wibox The wibox object.
1217 * \return The number of elements pushed on stack.
1219 static int
1220 luaA_wibox_get_client(lua_State *L, wibox_t *wibox)
1222 return luaA_object_push(L, client_getbytitlebar(wibox));
1225 /** Set the wibox cursor.
1226 * \param L The Lua VM state.
1227 * \param wibox The wibox object.
1228 * \return The number of elements pushed on stack.
1230 static int
1231 luaA_wibox_set_cursor(lua_State *L, wibox_t *wibox)
1233 const char *buf = luaL_checkstring(L, -1);
1234 if(buf)
1236 uint16_t cursor_font = xcursor_font_fromstr(buf);
1237 if(cursor_font)
1239 xcb_cursor_t cursor = xcursor_new(globalconf.connection, cursor_font);
1240 p_delete(&wibox->cursor);
1241 wibox->cursor = a_strdup(buf);
1242 window_set_cursor(wibox->window, cursor);
1243 luaA_object_emit_signal(L, -3, "property::cursor", 0);
1246 return 0;
1249 /** Set the wibox screen.
1250 * \param L The Lua VM state.
1251 * \param wibox The wibox object.
1252 * \return The number of elements pushed on stack.
1254 static int
1255 luaA_wibox_set_screen(lua_State *L, wibox_t *wibox)
1257 if(lua_isnil(L, -1))
1259 wibox_detach(L, -3);
1260 titlebar_client_detach(client_getbytitlebar(wibox));
1262 else
1264 int screen = luaL_checknumber(L, -1) - 1;
1265 luaA_checkscreen(screen);
1266 if(!wibox->screen || screen != screen_array_indexof(&globalconf.screens, wibox->screen))
1268 titlebar_client_detach(client_getbytitlebar(wibox));
1269 wibox_attach(L, -3, &globalconf.screens.tab[screen]);
1272 return 0;
1275 /** Get the wibox screen.
1276 * \param L The Lua VM state.
1277 * \param wibox The wibox object.
1278 * \return The number of elements pushed on stack.
1280 static int
1281 luaA_wibox_get_screen(lua_State *L, wibox_t *wibox)
1283 if(!wibox->screen)
1284 return 0;
1285 lua_pushnumber(L, screen_array_indexof(&globalconf.screens, wibox->screen) + 1);
1286 return 1;
1289 /** Set the wibox orientation.
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_orientation(lua_State *L, wibox_t *wibox)
1297 size_t len;
1298 const char *buf = luaL_checklstring(L, -1, &len);
1299 if(buf)
1301 wibox_set_orientation(L, -3, orientation_fromstr(buf, len));
1302 wibox_need_update(wibox);
1304 return 0;
1307 /** Get the wibox orientation.
1308 * \param L The Lua VM state.
1309 * \param wibox The wibox object.
1310 * \return The number of elements pushed on stack.
1312 static int
1313 luaA_wibox_get_orientation(lua_State *L, wibox_t *wibox)
1315 lua_pushstring(L, orientation_tostr(wibox->orientation));
1316 return 1;
1319 /** Set the wibox border color.
1320 * \param L The Lua VM state.
1321 * \param wibox The wibox object.
1322 * \return The number of elements pushed on stack.
1324 static int
1325 luaA_wibox_set_border_color(lua_State *L, wibox_t *wibox)
1327 size_t len;
1328 const char *buf = luaL_checklstring(L, -1, &len);
1329 if(buf)
1330 if(xcolor_init_reply(xcolor_init_unchecked(&wibox->border_color, buf, len)))
1331 if(wibox->window)
1332 wibox_set_border_color(L, -3, &wibox->border_color);
1333 return 0;
1336 /** Set the wibox visibility.
1337 * \param L The Lua VM state.
1338 * \param wibox The wibox object.
1339 * \return The number of elements pushed on stack.
1341 static int
1342 luaA_wibox_set_visible(lua_State *L, wibox_t *wibox)
1344 bool b = luaA_checkboolean(L, -1);
1345 if(b != wibox->visible)
1346 switch(wibox->type)
1348 case WIBOX_TYPE_NORMAL:
1349 wibox_set_visible(L, -3, b);
1350 break;
1351 case WIBOX_TYPE_TITLEBAR:
1352 titlebar_set_visible(wibox, b);
1353 break;
1355 return 0;
1358 /** Set the wibox widgets.
1359 * \param L The Lua VM state.
1360 * \param wibox The wibox object.
1361 * \return The number of elements pushed on stack.
1363 static int
1364 luaA_wibox_set_widgets(lua_State *L, wibox_t *wibox)
1366 if(luaA_isloop(L, -1))
1368 luaA_warn(L, "table is looping, cannot use this as widget table");
1369 return 0;
1371 /* duplicate table because next function will eat it */
1372 lua_pushvalue(L, -1);
1373 wibox->widgets_table = luaA_object_ref_item(L, -4, -1);
1374 luaA_object_emit_signal(L, -3, "property::widgets", 0);
1375 wibox_need_update(wibox);
1376 luaA_table2wtable(L);
1377 return 0;
1380 /** Get the wibox widgets.
1381 * \param L The Lua VM state.
1382 * \param wibox The wibox object.
1383 * \return The number of elements pushed on stack.
1385 static int
1386 luaA_wibox_get_widgets(lua_State *L, wibox_t *wibox)
1388 return luaA_object_push_item(L, 1, wibox->widgets_table);
1391 /** Get or set mouse buttons bindings to a wibox.
1392 * \param L The Lua VM state.
1393 * \luastack
1394 * \lvalue A wibox.
1395 * \lparam An array of mouse button bindings objects, or nothing.
1396 * \return The array of mouse button bindings objects of this wibox.
1398 static int
1399 luaA_wibox_buttons(lua_State *L)
1401 wibox_t *wibox = luaA_checkudata(L, 1, &wibox_class);
1403 if(lua_gettop(L) == 2)
1405 luaA_button_array_set(L, 1, 2, &wibox->buttons);
1406 luaA_object_emit_signal(L, 1, "property::buttons", 0);
1409 return luaA_button_array_get(L, 1, &wibox->buttons);
1412 /** Set the wibox border width.
1413 * \param L The Lua VM state.
1414 * \param wibox The wibox object.
1415 * \return The number of elements pushed on stack.
1417 static int
1418 luaA_wibox_set_border_width(lua_State *L, wibox_t *wibox)
1420 wibox_t *w = luaA_checkudata(L, -3, &wibox_class);
1421 uint32_t border_width = luaL_checknumber(L, -1);
1422 if(border_width != w->border_width)
1424 xcb_configure_window(globalconf.connection, w->window, XCB_CONFIG_WINDOW_BORDER_WIDTH,
1425 &border_width);
1426 w->border_width = border_width;
1427 luaA_object_emit_signal(L, -3, "property::border_width", 0);
1429 return 0;
1432 static int
1433 luaA_wibox_set_shape_bounding(lua_State *L, wibox_t *wibox)
1435 luaA_object_unref_item(L, -3, wibox->shape.bounding);
1436 wibox->shape.bounding = luaA_object_ref_item(L, -3, -1);
1437 wibox->need_shape_update = true;
1438 luaA_object_emit_signal(L, -2, "property::shape_bounding", 0);
1439 return 0;
1442 static int
1443 luaA_wibox_get_shape_bounding(lua_State *L, wibox_t *wibox)
1445 return luaA_object_push_item(L, 1, wibox->shape.bounding);
1448 static int
1449 luaA_wibox_set_shape_clip(lua_State *L, wibox_t *wibox)
1451 luaA_object_unref_item(L, -3, wibox->shape.clip);
1452 wibox->shape.clip = luaA_object_ref_item(L, -3, -1);
1453 wibox->need_shape_update = true;
1454 luaA_object_emit_signal(L, -2, "property::shape_clip", 0);
1455 return 0;
1458 static int
1459 luaA_wibox_get_shape_clip(lua_State *L, wibox_t *wibox)
1461 return luaA_object_push_item(L, 1, wibox->shape.clip);
1464 void
1465 wibox_class_setup(lua_State *L)
1467 static const struct luaL_reg wibox_methods[] =
1469 LUA_CLASS_METHODS(wibox)
1470 { "__call", luaA_wibox_new },
1471 { NULL, NULL }
1474 static const struct luaL_reg wibox_meta[] =
1476 LUA_OBJECT_META(wibox)
1477 LUA_CLASS_META
1478 { "struts", luaA_wibox_struts },
1479 { "buttons", luaA_wibox_buttons },
1480 { "geometry", luaA_wibox_geometry },
1481 { "__gc", luaA_wibox_gc },
1482 { NULL, NULL },
1485 luaA_class_setup(L, &wibox_class, "wibox", (lua_class_allocator_t) wibox_new,
1486 luaA_class_index_miss_property, luaA_class_newindex_miss_property,
1487 wibox_methods, wibox_meta);
1488 luaA_class_add_property(&wibox_class, A_TK_WIDGETS,
1489 (lua_class_propfunc_t) luaA_wibox_set_widgets,
1490 (lua_class_propfunc_t) luaA_wibox_get_widgets,
1491 (lua_class_propfunc_t) luaA_wibox_set_widgets);
1492 luaA_class_add_property(&wibox_class, A_TK_OPACITY,
1493 (lua_class_propfunc_t) luaA_wibox_set_opacity,
1494 (lua_class_propfunc_t) luaA_wibox_get_opacity,
1495 (lua_class_propfunc_t) luaA_wibox_set_opacity);
1496 luaA_class_add_property(&wibox_class, A_TK_VISIBLE,
1497 (lua_class_propfunc_t) luaA_wibox_set_visible,
1498 (lua_class_propfunc_t) luaA_wibox_get_visible,
1499 (lua_class_propfunc_t) luaA_wibox_set_visible);
1500 luaA_class_add_property(&wibox_class, A_TK_BORDER_COLOR,
1501 (lua_class_propfunc_t) luaA_wibox_set_border_color,
1502 (lua_class_propfunc_t) luaA_wibox_get_border_color,
1503 (lua_class_propfunc_t) luaA_wibox_set_border_color);
1504 luaA_class_add_property(&wibox_class, A_TK_BORDER_WIDTH,
1505 (lua_class_propfunc_t) luaA_wibox_set_border_width,
1506 (lua_class_propfunc_t) luaA_wibox_get_border_width,
1507 (lua_class_propfunc_t) luaA_wibox_set_border_width);
1508 luaA_class_add_property(&wibox_class, A_TK_ORIENTATION,
1509 (lua_class_propfunc_t) luaA_wibox_set_orientation,
1510 (lua_class_propfunc_t) luaA_wibox_get_orientation,
1511 (lua_class_propfunc_t) luaA_wibox_set_orientation);
1512 luaA_class_add_property(&wibox_class, A_TK_ONTOP,
1513 (lua_class_propfunc_t) luaA_wibox_set_ontop,
1514 (lua_class_propfunc_t) luaA_wibox_get_ontop,
1515 (lua_class_propfunc_t) luaA_wibox_set_ontop);
1516 luaA_class_add_property(&wibox_class, A_TK_SCREEN,
1517 NULL,
1518 (lua_class_propfunc_t) luaA_wibox_get_screen,
1519 (lua_class_propfunc_t) luaA_wibox_set_screen);
1520 luaA_class_add_property(&wibox_class, A_TK_CURSOR,
1521 (lua_class_propfunc_t) luaA_wibox_set_cursor,
1522 (lua_class_propfunc_t) luaA_wibox_get_cursor,
1523 (lua_class_propfunc_t) luaA_wibox_set_cursor);
1524 luaA_class_add_property(&wibox_class, A_TK_CLIENT,
1525 (lua_class_propfunc_t) luaA_wibox_set_client,
1526 (lua_class_propfunc_t) luaA_wibox_get_client,
1527 (lua_class_propfunc_t) luaA_wibox_set_client);
1528 luaA_class_add_property(&wibox_class, A_TK_POSITION,
1529 (lua_class_propfunc_t) luaA_wibox_set_position,
1530 (lua_class_propfunc_t) luaA_wibox_get_position,
1531 (lua_class_propfunc_t) luaA_wibox_set_position);
1532 luaA_class_add_property(&wibox_class, A_TK_ALIGN,
1533 (lua_class_propfunc_t) luaA_wibox_set_align,
1534 (lua_class_propfunc_t) luaA_wibox_get_align,
1535 (lua_class_propfunc_t) luaA_wibox_set_align);
1536 luaA_class_add_property(&wibox_class, A_TK_FG,
1537 (lua_class_propfunc_t) luaA_wibox_set_fg,
1538 (lua_class_propfunc_t) luaA_wibox_get_fg,
1539 (lua_class_propfunc_t) luaA_wibox_set_fg);
1540 luaA_class_add_property(&wibox_class, A_TK_BG,
1541 (lua_class_propfunc_t) luaA_wibox_set_bg,
1542 (lua_class_propfunc_t) luaA_wibox_get_bg,
1543 (lua_class_propfunc_t) luaA_wibox_set_bg);
1544 luaA_class_add_property(&wibox_class, A_TK_BG_IMAGE,
1545 (lua_class_propfunc_t) luaA_wibox_set_bg_image,
1546 (lua_class_propfunc_t) luaA_wibox_get_bg_image,
1547 (lua_class_propfunc_t) luaA_wibox_set_bg_image);
1548 luaA_class_add_property(&wibox_class, A_TK_X,
1549 (lua_class_propfunc_t) luaA_wibox_set_x,
1550 (lua_class_propfunc_t) luaA_wibox_get_x,
1551 (lua_class_propfunc_t) luaA_wibox_set_x);
1552 luaA_class_add_property(&wibox_class, A_TK_Y,
1553 (lua_class_propfunc_t) luaA_wibox_set_y,
1554 (lua_class_propfunc_t) luaA_wibox_get_y,
1555 (lua_class_propfunc_t) luaA_wibox_set_y);
1556 luaA_class_add_property(&wibox_class, A_TK_WIDTH,
1557 (lua_class_propfunc_t) luaA_wibox_set_width,
1558 (lua_class_propfunc_t) luaA_wibox_get_width,
1559 (lua_class_propfunc_t) luaA_wibox_set_width);
1560 luaA_class_add_property(&wibox_class, A_TK_HEIGHT,
1561 (lua_class_propfunc_t) luaA_wibox_set_height,
1562 (lua_class_propfunc_t) luaA_wibox_get_height,
1563 (lua_class_propfunc_t) luaA_wibox_set_height);
1564 luaA_class_add_property(&wibox_class, A_TK_SHAPE_BOUNDING,
1565 (lua_class_propfunc_t) luaA_wibox_set_shape_bounding,
1566 (lua_class_propfunc_t) luaA_wibox_get_shape_bounding,
1567 (lua_class_propfunc_t) luaA_wibox_set_shape_bounding);
1568 luaA_class_add_property(&wibox_class, A_TK_SHAPE_CLIP,
1569 (lua_class_propfunc_t) luaA_wibox_set_shape_clip,
1570 (lua_class_propfunc_t) luaA_wibox_get_shape_clip,
1571 (lua_class_propfunc_t) luaA_wibox_set_shape_clip);
1574 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80