awful.util: pread return error
[awesome.git] / wibox.c
blob5e788ee8e528f92f53e33eaa07fcd8d82abfa97a
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 idx 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 w The wibox.
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 wibox The wibox.
622 * \param v The visible value.
624 static void
625 wibox_set_visible(lua_State *L, int udx, bool v)
627 wibox_t *wibox = luaA_checkudata(L, udx, &wibox_class);
628 if(v != wibox->visible)
630 wibox->visible = v;
631 wibox->mouse_over = NULL;
633 if(wibox->screen)
635 if(wibox->visible)
636 wibox_map(wibox);
637 else
639 /* Active BMA */
640 client_ignore_enterleave_events();
641 /* Unmap window */
642 xcb_unmap_window(globalconf.connection, wibox->window);
643 /* Active BMA */
644 client_restore_enterleave_events();
647 /* kick out systray if needed */
648 wibox_systray_refresh(wibox);
651 luaA_object_emit_signal(L, udx, "property::visible", 0);
653 hook_property(wibox, "visible");
657 /** Destroy all X resources of a wibox.
658 * \param w The wibox to wipe.
660 void
661 wibox_wipe(wibox_t *w)
663 if(w->window)
665 /* Activate BMA */
666 client_ignore_enterleave_events();
667 xcb_destroy_window(globalconf.connection, w->window);
668 /* Deactivate BMA */
669 client_restore_enterleave_events();
670 w->window = XCB_NONE;
672 if(w->pixmap)
674 xcb_free_pixmap(globalconf.connection, w->pixmap);
675 w->pixmap = XCB_NONE;
677 if(w->gc)
679 xcb_free_gc(globalconf.connection, w->gc);
680 w->gc = XCB_NONE;
682 draw_context_wipe(&w->ctx);
685 /** Remove a wibox from a screen.
686 * \param L The Lua VM state.
687 * \param udx Wibox to detach from screen.
689 static void
690 wibox_detach(lua_State *L, int udx)
692 wibox_t *wibox = luaA_checkudata(L, udx, &wibox_class);
693 if(wibox->screen)
695 bool v;
697 /* save visible state */
698 v = wibox->visible;
699 wibox->visible = false;
700 wibox_systray_refresh(wibox);
701 /* restore visibility */
702 wibox->visible = v;
704 wibox->mouse_over = NULL;
706 wibox_wipe(wibox);
708 foreach(item, globalconf.wiboxes)
709 if(*item == wibox)
711 wibox_array_remove(&globalconf.wiboxes, item);
712 break;
715 hook_property(wibox, "screen");
717 wibox->screen = NULL;
718 luaA_object_emit_signal(L, udx, "property::screen", 0);
720 luaA_object_unref(globalconf.L, wibox);
724 /** Attach a wibox that is on top of the stack.
725 * \param s The screen to attach the wibox to.
727 static void
728 wibox_attach(lua_State *L, int udx, screen_t *s)
730 int phys_screen = screen_virttophys(screen_array_indexof(&globalconf.screens, s));
732 /* duplicate wibox */
733 lua_pushvalue(L, udx);
734 /* ref it */
735 wibox_t *wibox = luaA_object_ref(globalconf.L, -1);
737 wibox_detach(L, udx);
739 /* Set the wibox screen */
740 wibox->screen = s;
742 /* Check that the wibox coordinates matches the screen. */
743 screen_t *cscreen =
744 screen_getbycoord(wibox->screen, wibox->geometry.x, wibox->geometry.y);
746 /* If it does not match, move it to the screen coordinates */
747 if(cscreen != wibox->screen)
748 wibox_moveresize(L, udx, (area_t) { .x = s->geometry.x,
749 .y = s->geometry.y,
750 .width = wibox->geometry.width,
751 .height = wibox->geometry.height });
753 wibox_array_append(&globalconf.wiboxes, wibox);
755 wibox_init(wibox, phys_screen);
757 window_set_cursor(wibox->window,
758 xcursor_new(globalconf.connection, xcursor_font_fromstr(wibox->cursor)));
760 if(wibox->opacity != -1)
761 window_opacity_set(wibox->window, wibox->opacity);
763 ewmh_update_strut(wibox->window, &wibox->strut);
765 if(wibox->visible)
766 wibox_map(wibox);
767 else
768 wibox_need_update(wibox);
770 hook_property(wibox, "screen");
771 luaA_object_emit_signal(L, udx, "property::screen", 0);
774 /** Create a new wibox.
775 * \param L The Lua VM state.
777 * \luastack
778 * \lparam A table with optionaly defined values:
779 * fg, bg, border_width, border_color, ontop, width and height.
780 * \lreturn A brand new wibox.
782 static int
783 luaA_wibox_new(lua_State *L)
785 luaA_class_new(L, &wibox_class);
787 wibox_t *w = luaA_checkudata(L, -1, &wibox_class);
789 if(!w->ctx.fg.initialized)
790 w->ctx.fg = globalconf.colors.fg;
792 if(!w->ctx.bg.initialized)
793 w->ctx.bg = globalconf.colors.bg;
795 if(!w->border_color.initialized)
796 w->border_color = globalconf.colors.bg;
798 w->visible = true;
800 if(!w->opacity)
801 w->opacity = -1;
803 if(!w->cursor)
804 w->cursor = a_strdup("left_ptr");
806 if(!w->geometry.width)
807 w->geometry.width = 1;
809 if(!w->geometry.height)
810 w->geometry.height = 1;
812 return 1;
815 /** Check if a wibox widget table has an item.
816 * \param L The Lua VM state.
817 * \param wibox The wibox.
818 * \param item The item to look for.
820 static bool
821 luaA_wibox_hasitem(lua_State *L, wibox_t *wibox, const void *item)
823 if(wibox->widgets_table)
825 luaA_object_push(L, wibox);
826 luaA_object_push_item(L, -1, wibox->widgets_table);
827 lua_remove(L, -2);
828 if(lua_topointer(L, -1) == item || luaA_hasitem(L, item))
829 return true;
831 return false;
834 /** Invalidate a wibox by a Lua object (table, etc).
835 * \param L The Lua VM state.
836 * \param item The object identifier.
838 void
839 luaA_wibox_invalidate_byitem(lua_State *L, const void *item)
841 foreach(w, globalconf.wiboxes)
843 wibox_t *wibox = *w;
844 if(luaA_wibox_hasitem(L, wibox, item))
846 /* update wibox */
847 wibox_need_update(wibox);
848 lua_pop(L, 1); /* remove widgets table */
853 foreach(_c, globalconf.clients)
855 client_t *c = *_c;
856 if(c->titlebar && luaA_wibox_hasitem(L, c->titlebar, item))
858 /* update wibox */
859 wibox_need_update(c->titlebar);
860 lua_pop(L, 1); /* remove widgets table */
865 /* Set or get the wibox geometry.
866 * \param L The Lua VM state.
867 * \return The number of elements pushed on stack.
868 * \luastack
869 * \lparam An optional table with wibox geometry.
870 * \lreturn The wibox geometry.
872 static int
873 luaA_wibox_geometry(lua_State *L)
875 wibox_t *wibox = luaA_checkudata(L, 1, &wibox_class);
877 if(lua_gettop(L) == 2)
879 area_t wingeom;
881 luaA_checktable(L, 2);
882 wingeom.x = luaA_getopt_number(L, 2, "x", wibox->geometry.x);
883 wingeom.y = luaA_getopt_number(L, 2, "y", wibox->geometry.y);
884 wingeom.width = luaA_getopt_number(L, 2, "width", wibox->geometry.width);
885 wingeom.height = luaA_getopt_number(L, 2, "height", wibox->geometry.height);
887 if(wingeom.width > 0 && wingeom.height > 0)
888 switch(wibox->type)
890 case WIBOX_TYPE_TITLEBAR:
891 wibox_moveresize(L, 1, (area_t) { .x = wibox->geometry.x,
892 .y = wibox->geometry.y,
893 .width = wingeom.width,
894 .height = wingeom.height });
895 break;
896 case WIBOX_TYPE_NORMAL:
897 wibox_moveresize(L, 1, wingeom);
898 break;
902 return luaA_pusharea(L, wibox->geometry);
905 static int
906 luaA_wibox_struts(lua_State *L)
908 wibox_t *w = luaA_checkudata(L, 1, &wibox_class);
910 if(lua_gettop(L) == 2)
912 luaA_tostrut(L, 2, &w->strut);
913 if(w->window)
914 ewmh_update_strut(w->window, &w->strut);
915 luaA_object_emit_signal(L, 1, "property::struts", 0);
916 if(w->screen)
917 screen_emit_signal(L, w->screen, "property::workarea", 0);
920 return luaA_pushstrut(L, w->strut);
923 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, ontop, lua_pushboolean)
924 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, cursor, lua_pushstring)
925 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, visible, lua_pushboolean)
926 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, border_width, lua_pushnumber)
927 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, border_color, luaA_pushxcolor)
929 static int
930 luaA_wibox_set_x(lua_State *L, wibox_t *wibox)
932 wibox_moveresize(L, -3, (area_t) { .x = luaL_checknumber(L, -1),
933 .y = wibox->geometry.y,
934 .width = wibox->geometry.width,
935 .height = wibox->geometry.height });
936 return 0;
939 static int
940 luaA_wibox_get_x(lua_State *L, wibox_t *wibox)
942 lua_pushnumber(L, wibox->geometry.x);
943 return 1;
946 static int
947 luaA_wibox_set_y(lua_State *L, wibox_t *wibox)
949 wibox_moveresize(L, -3, (area_t) { .x = wibox->geometry.x,
950 .y = luaL_checknumber(L, -1),
951 .width = wibox->geometry.width,
952 .height = wibox->geometry.height });
953 return 0;
956 static int
957 luaA_wibox_get_y(lua_State *L, wibox_t *wibox)
959 lua_pushnumber(L, wibox->geometry.y);
960 return 1;
963 static int
964 luaA_wibox_set_width(lua_State *L, wibox_t *wibox)
966 int width = luaL_checknumber(L, -1);
967 if(width <= 0)
968 luaL_error(L, "invalid width");
969 wibox_moveresize(L, -3, (area_t) { .x = wibox->geometry.x,
970 .y = wibox->geometry.y,
971 .width = width,
972 .height = wibox->geometry.height });
973 return 0;
976 static int
977 luaA_wibox_get_width(lua_State *L, wibox_t *wibox)
979 lua_pushnumber(L, wibox->geometry.width);
980 return 1;
983 static int
984 luaA_wibox_set_height(lua_State *L, wibox_t *wibox)
986 int height = luaL_checknumber(L, -1);
987 if(height <= 0)
988 luaL_error(L, "invalid height");
989 wibox_moveresize(L, -3, (area_t) { .x = wibox->geometry.x,
990 .y = wibox->geometry.y,
991 .width = wibox->geometry.width,
992 .height = height });
993 return 0;
996 static int
997 luaA_wibox_get_height(lua_State *L, wibox_t *wibox)
999 lua_pushnumber(L, wibox->geometry.height);
1000 return 1;
1003 /** Set the wibox foreground color.
1004 * \param L The Lua VM state.
1005 * \param wibox The wibox object.
1006 * \return The number of elements pushed on stack.
1008 static int
1009 luaA_wibox_set_fg(lua_State *L, wibox_t *wibox)
1011 size_t len;
1012 const char *buf = luaL_checklstring(L, -1, &len);
1013 if(xcolor_init_reply(xcolor_init_unchecked(&wibox->ctx.fg, buf, len)))
1014 wibox->need_update = true;
1015 luaA_object_emit_signal(L, -3, "property::fg", 0);
1016 return 0;
1019 /** Get the wibox foreground color.
1020 * \param L The Lua VM state.
1021 * \param wibox The wibox object.
1022 * \return The number of elements pushed on stack.
1024 static int
1025 luaA_wibox_get_fg(lua_State *L, wibox_t *wibox)
1027 return luaA_pushxcolor(L, wibox->ctx.fg);
1030 /** Set the wibox background color.
1031 * \param L The Lua VM state.
1032 * \param wibox The wibox object.
1033 * \return The number of elements pushed on stack.
1035 static int
1036 luaA_wibox_set_bg(lua_State *L, wibox_t *wibox)
1038 size_t len;
1039 const char *buf = luaL_checklstring(L, -1, &len);
1040 if(xcolor_init_reply(xcolor_init_unchecked(&wibox->ctx.bg, buf, len)))
1041 wibox->need_update = true;
1042 luaA_object_emit_signal(L, -3, "property::bg", 0);
1043 return 0;
1046 /** Get the wibox background color.
1047 * \param L The Lua VM state.
1048 * \param wibox The wibox object.
1049 * \return The number of elements pushed on stack.
1051 static int
1052 luaA_wibox_get_bg(lua_State *L, wibox_t *wibox)
1054 return luaA_pushxcolor(L, wibox->ctx.bg);
1057 /** Set the wibox background image.
1058 * \param L The Lua VM state.
1059 * \param wibox The wibox object.
1060 * \return The number of elements pushed on stack.
1062 static int
1063 luaA_wibox_set_bg_image(lua_State *L, wibox_t *wibox)
1065 luaA_checkudata(L, -1, &image_class);
1066 luaA_object_unref_item(L, -3, wibox->bg_image);
1067 wibox->bg_image = luaA_object_ref_item(L, -3, -1);
1068 wibox->need_update = true;
1069 luaA_object_emit_signal(L, -2, "property::bg_image", 0);
1070 return 0;
1073 /** Get the wibox background image.
1074 * \param L The Lua VM state.
1075 * \param wibox The wibox object.
1076 * \return The number of elements pushed on stack.
1078 static int
1079 luaA_wibox_get_bg_image(lua_State *L, wibox_t *wibox)
1081 return luaA_object_push_item(L, 1, wibox->bg_image);
1084 /** Set the wibox on top status.
1085 * \param L The Lua VM state.
1086 * \param wibox The wibox object.
1087 * \return The number of elements pushed on stack.
1089 static int
1090 luaA_wibox_set_ontop(lua_State *L, wibox_t *wibox)
1092 bool b = luaA_checkboolean(L, -1);
1093 if(b != wibox->ontop)
1095 wibox->ontop = b;
1096 client_stack();
1097 luaA_object_emit_signal(L, -3, "property::ontop", 0);
1099 return 0;
1102 /** Set the wibox opacity.
1103 * \param L The Lua VM state.
1104 * \param wibox The wibox object.
1105 * \return The number of elements pushed on stack.
1107 static int
1108 luaA_wibox_set_opacity(lua_State *L, wibox_t *wibox)
1110 if(lua_isnil(L, -1))
1111 wibox_set_opacity(L, -3, -1);
1112 else
1114 double d = luaL_checknumber(L, -1);
1115 if(d >= 0 && d <= 1)
1116 wibox_set_opacity(L, -3, d);
1118 return 0;
1121 /** Get the wibox opacity.
1122 * \param L The Lua VM state.
1123 * \param wibox The wibox object.
1124 * \return The number of elements pushed on stack.
1126 static int
1127 luaA_wibox_get_opacity(lua_State *L, wibox_t *wibox)
1129 if (wibox->opacity >= 0)
1131 lua_pushnumber(L, wibox->opacity);
1132 return 1;
1134 return 0;
1137 /** Set the wibox alignment.
1138 * \param L The Lua VM state.
1139 * \param wibox The wibox object.
1140 * \return The number of elements pushed on stack.
1142 static int
1143 luaA_wibox_set_align(lua_State *L, wibox_t *wibox)
1145 size_t len;
1146 const char *buf = luaL_checklstring(L, -1, &len);
1147 wibox->align = draw_align_fromstr(buf, len);
1148 luaA_object_emit_signal(L, -3, "property::align", 0);
1149 switch(wibox->type)
1151 case WIBOX_TYPE_NORMAL:
1152 luaA_deprecate(L, "awful.wibox.align");
1153 break;
1154 case WIBOX_TYPE_TITLEBAR:
1155 titlebar_update_geometry(client_getbytitlebar(wibox));
1156 break;
1158 return 0;
1161 /** Get the wibox alignment.
1162 * \param L The Lua VM state.
1163 * \param wibox The wibox object.
1164 * \return The number of elements pushed on stack.
1166 static int
1167 luaA_wibox_get_align(lua_State *L, wibox_t *wibox)
1169 if(wibox->type == WIBOX_TYPE_NORMAL)
1170 luaA_deprecate(L, "awful.wibox.align");
1171 lua_pushstring(L, draw_align_tostr(wibox->align));
1172 return 1;
1175 /** Set the wibox position.
1176 * \param L The Lua VM state.
1177 * \param wibox The wibox object.
1178 * \return The number of elements pushed on stack.
1180 static int
1181 luaA_wibox_set_position(lua_State *L, wibox_t *wibox)
1183 switch(wibox->type)
1185 case WIBOX_TYPE_NORMAL:
1187 size_t len;
1188 const char *buf;
1189 if((buf = luaL_checklstring(L, -1, &len)))
1191 luaA_deprecate(L, "awful.wibox.attach");
1192 wibox->position = position_fromstr(buf, len);
1195 break;
1196 case WIBOX_TYPE_TITLEBAR:
1197 return luaA_titlebar_set_position(L, -3);
1199 return 0;
1202 /** Get the wibox position.
1203 * \param L The Lua VM state.
1204 * \param wibox The wibox object.
1205 * \return The number of elements pushed on stack.
1207 static int
1208 luaA_wibox_get_position(lua_State *L, wibox_t *wibox)
1210 if(wibox->type == WIBOX_TYPE_NORMAL)
1211 luaA_deprecate(L, "awful.wibox.attach");
1212 lua_pushstring(L, position_tostr(wibox->position));
1213 return 1;
1216 /** Set the wibox (titlebar) client.
1217 * \param L The Lua VM state.
1218 * \param wibox The wibox object.
1219 * \return The number of elements pushed on stack.
1221 static int
1222 luaA_wibox_set_client(lua_State *L, wibox_t *wibox)
1224 /* first detach */
1225 if(lua_isnil(L, -1))
1226 titlebar_client_detach(client_getbytitlebar(wibox));
1227 else
1229 client_t *c = luaA_client_checkudata(L, -1);
1230 lua_pushvalue(L, -3);
1231 titlebar_client_attach(c);
1233 return 0;
1236 /** Get the wibox (titlebar) client.
1237 * \param L The Lua VM state.
1238 * \param wibox The wibox object.
1239 * \return The number of elements pushed on stack.
1241 static int
1242 luaA_wibox_get_client(lua_State *L, wibox_t *wibox)
1244 return luaA_object_push(L, client_getbytitlebar(wibox));
1247 /** Set the wibox cursor.
1248 * \param L The Lua VM state.
1249 * \param wibox The wibox object.
1250 * \return The number of elements pushed on stack.
1252 static int
1253 luaA_wibox_set_cursor(lua_State *L, wibox_t *wibox)
1255 const char *buf = luaL_checkstring(L, -1);
1256 if(buf)
1258 uint16_t cursor_font = xcursor_font_fromstr(buf);
1259 if(cursor_font)
1261 xcb_cursor_t cursor = xcursor_new(globalconf.connection, cursor_font);
1262 p_delete(&wibox->cursor);
1263 wibox->cursor = a_strdup(buf);
1264 window_set_cursor(wibox->window, cursor);
1265 luaA_object_emit_signal(L, -3, "property::cursor", 0);
1268 return 0;
1271 /** Set the wibox screen.
1272 * \param L The Lua VM state.
1273 * \param wibox The wibox object.
1274 * \return The number of elements pushed on stack.
1276 static int
1277 luaA_wibox_set_screen(lua_State *L, wibox_t *wibox)
1279 if(lua_isnil(L, -1))
1281 wibox_detach(L, -3);
1282 titlebar_client_detach(client_getbytitlebar(wibox));
1284 else
1286 int screen = luaL_checknumber(L, -1) - 1;
1287 luaA_checkscreen(screen);
1288 if(!wibox->screen || screen != screen_array_indexof(&globalconf.screens, wibox->screen))
1290 titlebar_client_detach(client_getbytitlebar(wibox));
1291 wibox_attach(L, -3, &globalconf.screens.tab[screen]);
1294 return 0;
1297 /** Get the wibox screen.
1298 * \param L The Lua VM state.
1299 * \param wibox The wibox object.
1300 * \return The number of elements pushed on stack.
1302 static int
1303 luaA_wibox_get_screen(lua_State *L, wibox_t *wibox)
1305 if(!wibox->screen)
1306 return 0;
1307 lua_pushnumber(L, screen_array_indexof(&globalconf.screens, wibox->screen) + 1);
1308 return 1;
1311 /** Set the wibox orientation.
1312 * \param L The Lua VM state.
1313 * \param wibox The wibox object.
1314 * \return The number of elements pushed on stack.
1316 static int
1317 luaA_wibox_set_orientation(lua_State *L, wibox_t *wibox)
1319 size_t len;
1320 const char *buf = luaL_checklstring(L, -1, &len);
1321 if(buf)
1323 wibox_set_orientation(L, -3, orientation_fromstr(buf, len));
1324 wibox_need_update(wibox);
1326 return 0;
1329 /** Get the wibox orientation.
1330 * \param L The Lua VM state.
1331 * \param wibox The wibox object.
1332 * \return The number of elements pushed on stack.
1334 static int
1335 luaA_wibox_get_orientation(lua_State *L, wibox_t *wibox)
1337 lua_pushstring(L, orientation_tostr(wibox->orientation));
1338 return 1;
1341 /** Set the wibox border color.
1342 * \param L The Lua VM state.
1343 * \param wibox The wibox object.
1344 * \return The number of elements pushed on stack.
1346 static int
1347 luaA_wibox_set_border_color(lua_State *L, wibox_t *wibox)
1349 size_t len;
1350 const char *buf = luaL_checklstring(L, -1, &len);
1351 if(buf)
1352 if(xcolor_init_reply(xcolor_init_unchecked(&wibox->border_color, buf, len)))
1353 if(wibox->window)
1354 wibox_set_border_color(L, -3, &wibox->border_color);
1355 return 0;
1358 /** Set the wibox visibility.
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_visible(lua_State *L, wibox_t *wibox)
1366 bool b = luaA_checkboolean(L, -1);
1367 if(b != wibox->visible)
1368 switch(wibox->type)
1370 case WIBOX_TYPE_NORMAL:
1371 wibox_set_visible(L, -3, b);
1372 break;
1373 case WIBOX_TYPE_TITLEBAR:
1374 titlebar_set_visible(wibox, b);
1375 break;
1377 return 0;
1380 /** Set 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_set_widgets(lua_State *L, wibox_t *wibox)
1388 if(luaA_isloop(L, -1))
1390 luaA_warn(L, "table is looping, cannot use this as widget table");
1391 return 0;
1393 /* duplicate table because next function will eat it */
1394 lua_pushvalue(L, -1);
1395 wibox->widgets_table = luaA_object_ref_item(L, -4, -1);
1396 luaA_object_emit_signal(L, -3, "property::widgets", 0);
1397 wibox_need_update(wibox);
1398 luaA_table2wtable(L);
1399 return 0;
1402 /** Get the wibox widgets.
1403 * \param L The Lua VM state.
1404 * \param wibox The wibox object.
1405 * \return The number of elements pushed on stack.
1407 static int
1408 luaA_wibox_get_widgets(lua_State *L, wibox_t *wibox)
1410 return luaA_object_push_item(L, 1, wibox->widgets_table);
1413 /** Get or set mouse buttons bindings to a wibox.
1414 * \param L The Lua VM state.
1415 * \luastack
1416 * \lvalue A wibox.
1417 * \lparam An array of mouse button bindings objects, or nothing.
1418 * \return The array of mouse button bindings objects of this wibox.
1420 static int
1421 luaA_wibox_buttons(lua_State *L)
1423 wibox_t *wibox = luaA_checkudata(L, 1, &wibox_class);
1425 if(lua_gettop(L) == 2)
1427 luaA_button_array_set(L, 1, 2, &wibox->buttons);
1428 luaA_object_emit_signal(L, 1, "property::buttons", 0);
1431 return luaA_button_array_get(L, 1, &wibox->buttons);
1434 /** Set the wibox border width.
1435 * \param L The Lua VM state.
1436 * \param wibox The wibox object.
1437 * \return The number of elements pushed on stack.
1439 static int
1440 luaA_wibox_set_border_width(lua_State *L, wibox_t *wibox)
1442 wibox_t *w = luaA_checkudata(L, -3, &wibox_class);
1443 uint32_t border_width = luaL_checknumber(L, -1);
1444 if(border_width != w->border_width)
1446 xcb_configure_window(globalconf.connection, w->window, XCB_CONFIG_WINDOW_BORDER_WIDTH,
1447 &border_width);
1448 w->border_width = border_width;
1449 luaA_object_emit_signal(L, -3, "property::border_width", 0);
1451 return 0;
1454 static int
1455 luaA_wibox_set_shape_bounding(lua_State *L, wibox_t *wibox)
1457 luaA_object_unref_item(L, -3, wibox->shape.bounding);
1458 wibox->shape.bounding = luaA_object_ref_item(L, -3, -1);
1459 wibox->need_shape_update = true;
1460 luaA_object_emit_signal(L, -2, "property::shape_bounding", 0);
1461 return 0;
1464 static int
1465 luaA_wibox_get_shape_bounding(lua_State *L, wibox_t *wibox)
1467 return luaA_object_push_item(L, 1, wibox->shape.bounding);
1470 static int
1471 luaA_wibox_set_shape_clip(lua_State *L, wibox_t *wibox)
1473 luaA_object_unref_item(L, -3, wibox->shape.clip);
1474 wibox->shape.clip = luaA_object_ref_item(L, -3, -1);
1475 wibox->need_shape_update = true;
1476 luaA_object_emit_signal(L, -2, "property::shape_clip", 0);
1477 return 0;
1480 static int
1481 luaA_wibox_get_shape_clip(lua_State *L, wibox_t *wibox)
1483 return luaA_object_push_item(L, 1, wibox->shape.clip);
1486 void
1487 wibox_class_setup(lua_State *L)
1489 static const struct luaL_reg wibox_methods[] =
1491 LUA_CLASS_METHODS(wibox)
1492 { "__call", luaA_wibox_new },
1493 { NULL, NULL }
1496 static const struct luaL_reg wibox_meta[] =
1498 LUA_OBJECT_META(wibox)
1499 LUA_CLASS_META
1500 { "struts", luaA_wibox_struts },
1501 { "buttons", luaA_wibox_buttons },
1502 { "geometry", luaA_wibox_geometry },
1503 { "__gc", luaA_wibox_gc },
1504 { NULL, NULL },
1507 luaA_class_setup(L, &wibox_class, "wibox", (lua_class_allocator_t) wibox_new,
1508 luaA_class_index_miss_property, luaA_class_newindex_miss_property,
1509 wibox_methods, wibox_meta);
1510 luaA_class_add_property(&wibox_class, A_TK_WIDGETS,
1511 (lua_class_propfunc_t) luaA_wibox_set_widgets,
1512 (lua_class_propfunc_t) luaA_wibox_get_widgets,
1513 (lua_class_propfunc_t) luaA_wibox_set_widgets);
1514 luaA_class_add_property(&wibox_class, A_TK_OPACITY,
1515 (lua_class_propfunc_t) luaA_wibox_set_opacity,
1516 (lua_class_propfunc_t) luaA_wibox_get_opacity,
1517 (lua_class_propfunc_t) luaA_wibox_set_opacity);
1518 luaA_class_add_property(&wibox_class, A_TK_VISIBLE,
1519 (lua_class_propfunc_t) luaA_wibox_set_visible,
1520 (lua_class_propfunc_t) luaA_wibox_get_visible,
1521 (lua_class_propfunc_t) luaA_wibox_set_visible);
1522 luaA_class_add_property(&wibox_class, A_TK_BORDER_COLOR,
1523 (lua_class_propfunc_t) luaA_wibox_set_border_color,
1524 (lua_class_propfunc_t) luaA_wibox_get_border_color,
1525 (lua_class_propfunc_t) luaA_wibox_set_border_color);
1526 luaA_class_add_property(&wibox_class, A_TK_BORDER_WIDTH,
1527 (lua_class_propfunc_t) luaA_wibox_set_border_width,
1528 (lua_class_propfunc_t) luaA_wibox_get_border_width,
1529 (lua_class_propfunc_t) luaA_wibox_set_border_width);
1530 luaA_class_add_property(&wibox_class, A_TK_ORIENTATION,
1531 (lua_class_propfunc_t) luaA_wibox_set_orientation,
1532 (lua_class_propfunc_t) luaA_wibox_get_orientation,
1533 (lua_class_propfunc_t) luaA_wibox_set_orientation);
1534 luaA_class_add_property(&wibox_class, A_TK_ONTOP,
1535 (lua_class_propfunc_t) luaA_wibox_set_ontop,
1536 (lua_class_propfunc_t) luaA_wibox_get_ontop,
1537 (lua_class_propfunc_t) luaA_wibox_set_ontop);
1538 luaA_class_add_property(&wibox_class, A_TK_SCREEN,
1539 NULL,
1540 (lua_class_propfunc_t) luaA_wibox_get_screen,
1541 (lua_class_propfunc_t) luaA_wibox_set_screen);
1542 luaA_class_add_property(&wibox_class, A_TK_CURSOR,
1543 (lua_class_propfunc_t) luaA_wibox_set_cursor,
1544 (lua_class_propfunc_t) luaA_wibox_get_cursor,
1545 (lua_class_propfunc_t) luaA_wibox_set_cursor);
1546 luaA_class_add_property(&wibox_class, A_TK_CLIENT,
1547 (lua_class_propfunc_t) luaA_wibox_set_client,
1548 (lua_class_propfunc_t) luaA_wibox_get_client,
1549 (lua_class_propfunc_t) luaA_wibox_set_client);
1550 luaA_class_add_property(&wibox_class, A_TK_POSITION,
1551 (lua_class_propfunc_t) luaA_wibox_set_position,
1552 (lua_class_propfunc_t) luaA_wibox_get_position,
1553 (lua_class_propfunc_t) luaA_wibox_set_position);
1554 luaA_class_add_property(&wibox_class, A_TK_ALIGN,
1555 (lua_class_propfunc_t) luaA_wibox_set_align,
1556 (lua_class_propfunc_t) luaA_wibox_get_align,
1557 (lua_class_propfunc_t) luaA_wibox_set_align);
1558 luaA_class_add_property(&wibox_class, A_TK_FG,
1559 (lua_class_propfunc_t) luaA_wibox_set_fg,
1560 (lua_class_propfunc_t) luaA_wibox_get_fg,
1561 (lua_class_propfunc_t) luaA_wibox_set_fg);
1562 luaA_class_add_property(&wibox_class, A_TK_BG,
1563 (lua_class_propfunc_t) luaA_wibox_set_bg,
1564 (lua_class_propfunc_t) luaA_wibox_get_bg,
1565 (lua_class_propfunc_t) luaA_wibox_set_bg);
1566 luaA_class_add_property(&wibox_class, A_TK_BG_IMAGE,
1567 (lua_class_propfunc_t) luaA_wibox_set_bg_image,
1568 (lua_class_propfunc_t) luaA_wibox_get_bg_image,
1569 (lua_class_propfunc_t) luaA_wibox_set_bg_image);
1570 luaA_class_add_property(&wibox_class, A_TK_X,
1571 (lua_class_propfunc_t) luaA_wibox_set_x,
1572 (lua_class_propfunc_t) luaA_wibox_get_x,
1573 (lua_class_propfunc_t) luaA_wibox_set_x);
1574 luaA_class_add_property(&wibox_class, A_TK_Y,
1575 (lua_class_propfunc_t) luaA_wibox_set_y,
1576 (lua_class_propfunc_t) luaA_wibox_get_y,
1577 (lua_class_propfunc_t) luaA_wibox_set_y);
1578 luaA_class_add_property(&wibox_class, A_TK_WIDTH,
1579 (lua_class_propfunc_t) luaA_wibox_set_width,
1580 (lua_class_propfunc_t) luaA_wibox_get_width,
1581 (lua_class_propfunc_t) luaA_wibox_set_width);
1582 luaA_class_add_property(&wibox_class, A_TK_HEIGHT,
1583 (lua_class_propfunc_t) luaA_wibox_set_height,
1584 (lua_class_propfunc_t) luaA_wibox_get_height,
1585 (lua_class_propfunc_t) luaA_wibox_set_height);
1586 luaA_class_add_property(&wibox_class, A_TK_SHAPE_BOUNDING,
1587 (lua_class_propfunc_t) luaA_wibox_set_shape_bounding,
1588 (lua_class_propfunc_t) luaA_wibox_get_shape_bounding,
1589 (lua_class_propfunc_t) luaA_wibox_set_shape_bounding);
1590 luaA_class_add_property(&wibox_class, A_TK_SHAPE_CLIP,
1591 (lua_class_propfunc_t) luaA_wibox_set_shape_clip,
1592 (lua_class_propfunc_t) luaA_wibox_get_shape_clip,
1593 (lua_class_propfunc_t) luaA_wibox_set_shape_clip);
1596 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80