awful.mouse: load finder
[awesome.git] / wibox.c
blobfeb8403dc5b5114058d02402abb8631361439037
1 /*
2 * wibox.c - wibox functions
4 * Copyright © 2008-2009 Julien Danjou <julien@danjou.info>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include <xcb/shape.h>
24 #include "screen.h"
25 #include "wibox.h"
26 #include "titlebar.h"
27 #include "client.h"
28 #include "screen.h"
29 #include "window.h"
30 #include "luaa.h"
31 #include "ewmh.h"
32 #include "common/xcursor.h"
33 #include "common/xutil.h"
35 LUA_OBJECT_FUNCS(wibox_class, wibox_t, wibox)
37 /** Take care of garbage collecting a wibox.
38 * \param L The Lua VM state.
39 * \return The number of elements pushed on stack, 0!
41 static int
42 luaA_wibox_gc(lua_State *L)
44 wibox_t *wibox = luaA_checkudata(L, 1, &wibox_class);
45 p_delete(&wibox->cursor);
46 wibox_wipe(wibox);
47 button_array_wipe(&wibox->buttons);
48 widget_node_array_wipe(&wibox->widgets);
49 return luaA_object_gc(L);
52 void
53 wibox_unref_simplified(wibox_t **item)
55 luaA_object_unref(globalconf.L, *item);
58 static void
59 wibox_need_update(wibox_t *wibox)
61 wibox->need_update = true;
62 wibox->mouse_over = NULL;
65 static int
66 have_shape(void)
68 const xcb_query_extension_reply_t *reply;
70 reply = xcb_get_extension_data(globalconf.connection, &xcb_shape_id);
71 if (!reply || !reply->present)
72 return 0;
74 /* We don't need a specific version of SHAPE, no version check required */
75 return 1;
78 static void
79 shape_update(xcb_window_t win, xcb_shape_kind_t kind, image_t *image, int offset)
81 xcb_pixmap_t shape;
83 if(image)
84 shape = image_to_1bit_pixmap(image, win);
85 else
86 /* Reset the shape */
87 shape = XCB_NONE;
89 xcb_shape_mask(globalconf.connection, XCB_SHAPE_SO_SET, kind,
90 win, offset, offset, shape);
92 if (shape != XCB_NONE)
93 xcb_free_pixmap(globalconf.connection, shape);
96 /** Update the window's shape.
97 * \param wibox The simple window whose shape should be updated.
99 static void
100 wibox_shape_update(wibox_t *wibox)
102 if(wibox->window == XCB_NONE)
103 return;
105 if(!have_shape())
107 static bool warned = false;
108 if(!warned)
109 warn("The X server doesn't have the SHAPE extension; "
110 "can't change window's shape");
111 warned = true;
112 return;
115 shape_update(wibox->window, XCB_SHAPE_SK_CLIP, wibox->shape.clip, 0);
116 shape_update(wibox->window, XCB_SHAPE_SK_BOUNDING, wibox->shape.bounding, - wibox->border_width);
118 wibox->need_shape_update = false;
121 static void
122 wibox_draw_context_update(wibox_t *w, xcb_screen_t *s)
124 xcolor_t fg = w->ctx.fg, bg = w->ctx.bg;
125 int phys_screen = w->ctx.phys_screen;
127 draw_context_wipe(&w->ctx);
129 /* update draw context */
130 switch(w->orientation)
132 case South:
133 case North:
134 /* we need a new pixmap this way [ ] to render */
135 w->ctx.pixmap = xcb_generate_id(globalconf.connection);
136 xcb_create_pixmap(globalconf.connection,
137 s->root_depth,
138 w->ctx.pixmap, s->root,
139 w->geometry.height,
140 w->geometry.width);
141 draw_context_init(&w->ctx, phys_screen,
142 w->geometry.height,
143 w->geometry.width,
144 w->ctx.pixmap, &fg, &bg);
145 break;
146 case East:
147 draw_context_init(&w->ctx, phys_screen,
148 w->geometry.width,
149 w->geometry.height,
150 w->pixmap, &fg, &bg);
151 break;
155 /** Initialize a wibox.
156 * \param w The wibox to initialize.
157 * \param phys_screen Physical screen number.
159 void
160 wibox_init(wibox_t *w, int phys_screen)
162 xcb_screen_t *s = xutil_screen_get(globalconf.connection, phys_screen);
164 w->window = xcb_generate_id(globalconf.connection);
165 xcb_create_window(globalconf.connection, s->root_depth, w->window, s->root,
166 w->geometry.x, w->geometry.y,
167 w->geometry.width, w->geometry.height,
168 w->border_width, XCB_COPY_FROM_PARENT, s->root_visual,
169 XCB_CW_BACK_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 /* Activate BMA */
262 client_ignore_enterleave_events();
264 if(mask_vals)
265 xcb_configure_window(globalconf.connection, w->window, mask_vals, moveresize_win_vals);
267 /* Deactivate BMA */
268 client_restore_enterleave_events();
270 w->screen = screen_getbycoord(w->screen, w->geometry.x, w->geometry.y);
272 if(mask_vals & XCB_CONFIG_WINDOW_X)
273 luaA_object_emit_signal(L, udx, "property::x", 0);
274 if(mask_vals & XCB_CONFIG_WINDOW_Y)
275 luaA_object_emit_signal(L, udx, "property::y", 0);
276 if(mask_vals & XCB_CONFIG_WINDOW_WIDTH)
277 luaA_object_emit_signal(L, udx, "property::width", 0);
278 if(mask_vals & XCB_CONFIG_WINDOW_HEIGHT)
279 luaA_object_emit_signal(L, udx, "property::height", 0);
281 else
283 #define DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(prop) \
284 if(w->geometry.prop != geometry.prop) \
286 w->geometry.prop = geometry.prop; \
287 luaA_object_emit_signal(L, udx, "property::" #prop, 0); \
289 DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(x)
290 DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(y)
291 DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(width)
292 DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(height)
293 #undef DO_WIBOX_GEOMETRY_CHECK_AND_EMIT
296 wibox_need_update(w);
299 /** Refresh the window content by copying its pixmap data to its window.
300 * \param wibox The wibox to refresh.
301 * \param x The copy starting point x component.
302 * \param y The copy starting point y component.
303 * \param w The copy width from the x component.
304 * \param h The copy height from the y component.
306 void
307 wibox_refresh_pixmap_partial(wibox_t *wibox,
308 int16_t x, int16_t y,
309 uint16_t w, uint16_t h)
311 xcb_copy_area(globalconf.connection, wibox->pixmap,
312 wibox->window, wibox->gc, x, y, x, y,
313 w, h);
316 void
317 wibox_set_opacity(lua_State *L, int udx, double opacity)
319 wibox_t *w = luaA_checkudata(L, udx, &wibox_class);
320 if(w->opacity != opacity)
322 w->opacity = opacity;
323 if(w->window)
324 window_opacity_set(w->window, opacity);
325 luaA_object_emit_signal(L, udx, "property::opacity", 0);
329 /** Set a wibox border color.
330 * \param L The Lua VM state.
331 * \param udx The wibox to change border width.
332 * \param color The border color.
334 static void
335 wibox_set_border_color(lua_State *L, int udx, const xcolor_t *color)
337 wibox_t *w = luaA_checkudata(L, udx, &wibox_class);
338 xcb_change_window_attributes(globalconf.connection, w->window,
339 XCB_CW_BORDER_PIXEL, &color->pixel);
340 w->border_color = *color;
341 luaA_object_emit_signal(L, udx, "property::border_color", 0);
344 /** Set wibox orientation.
345 * \param L The Lua VM state.
346 * \param udx The wibox to change orientation.
347 * \param o The new orientation.
349 void
350 wibox_set_orientation(lua_State *L, int udx, orientation_t o)
352 wibox_t *w = luaA_checkudata(L, udx, &wibox_class);
353 if(o != w->orientation)
355 xcb_screen_t *s = xutil_screen_get(globalconf.connection, w->ctx.phys_screen);
356 w->orientation = o;
357 /* orientation != East */
358 if(w->pixmap != w->ctx.pixmap)
359 xcb_free_pixmap(globalconf.connection, w->ctx.pixmap);
360 wibox_draw_context_update(w, s);
361 luaA_object_emit_signal(L, udx, "property::orientation", 0);
365 static void
366 wibox_map(wibox_t *wibox)
368 /* Activate BMA */
369 client_ignore_enterleave_events();
370 /* Map the wibox */
371 xcb_map_window(globalconf.connection, wibox->window);
372 /* Deactivate BMA */
373 client_restore_enterleave_events();
374 /* We must make sure the wibox does not display garbage */
375 wibox_need_update(wibox);
376 /* Stack this wibox correctly */
377 client_stack();
380 /** Kick out systray windows.
381 * \param phys_screen Physical screen number.
383 static void
384 wibox_systray_kickout(int phys_screen)
386 xcb_screen_t *s = xutil_screen_get(globalconf.connection, phys_screen);
388 if(globalconf.screens.tab[phys_screen].systray.parent != s->root)
390 /* Who! Check that we're not deleting a wibox with a systray, because it
391 * may be its parent. If so, we reparent to root before, otherwise it will
392 * hurt very much. */
393 xcb_reparent_window(globalconf.connection,
394 globalconf.screens.tab[phys_screen].systray.window,
395 s->root, -512, -512);
397 globalconf.screens.tab[phys_screen].systray.parent = s->root;
401 static void
402 wibox_systray_refresh(wibox_t *wibox)
404 if(!wibox->screen)
405 return;
407 for(int i = 0; i < wibox->widgets.len; i++)
409 widget_node_t *systray = &wibox->widgets.tab[i];
410 if(systray->widget->type == widget_systray)
412 uint32_t config_back[] = { wibox->ctx.bg.pixel };
413 uint32_t config_win_vals[4];
414 uint32_t config_win_vals_off[2] = { -512, -512 };
415 xembed_window_t *em;
416 int phys_screen = wibox->ctx.phys_screen;
418 if(wibox->visible
419 && systray->widget->isvisible
420 && systray->geometry.width)
422 /* Set background of the systray window. */
423 xcb_change_window_attributes(globalconf.connection,
424 globalconf.screens.tab[phys_screen].systray.window,
425 XCB_CW_BACK_PIXEL, config_back);
426 /* Map it. */
427 xcb_map_window(globalconf.connection, globalconf.screens.tab[phys_screen].systray.window);
428 /* Move it. */
429 switch(wibox->orientation)
431 case North:
432 config_win_vals[0] = systray->geometry.y;
433 config_win_vals[1] = wibox->geometry.height - systray->geometry.x - systray->geometry.width;
434 config_win_vals[2] = systray->geometry.height;
435 config_win_vals[3] = systray->geometry.width;
436 break;
437 case South:
438 config_win_vals[0] = systray->geometry.y;
439 config_win_vals[1] = systray->geometry.x;
440 config_win_vals[2] = systray->geometry.height;
441 config_win_vals[3] = systray->geometry.width;
442 break;
443 case East:
444 config_win_vals[0] = systray->geometry.x;
445 config_win_vals[1] = systray->geometry.y;
446 config_win_vals[2] = systray->geometry.width;
447 config_win_vals[3] = systray->geometry.height;
448 break;
450 /* reparent */
451 if(globalconf.screens.tab[phys_screen].systray.parent != wibox->window)
453 xcb_reparent_window(globalconf.connection,
454 globalconf.screens.tab[phys_screen].systray.window,
455 wibox->window,
456 config_win_vals[0], config_win_vals[1]);
457 globalconf.screens.tab[phys_screen].systray.parent = wibox->window;
459 xcb_configure_window(globalconf.connection,
460 globalconf.screens.tab[phys_screen].systray.window,
461 XCB_CONFIG_WINDOW_X
462 | XCB_CONFIG_WINDOW_Y
463 | XCB_CONFIG_WINDOW_WIDTH
464 | XCB_CONFIG_WINDOW_HEIGHT,
465 config_win_vals);
466 /* width = height = systray height */
467 config_win_vals[2] = config_win_vals[3] = systray->geometry.height;
468 config_win_vals[0] = 0;
470 else
471 return wibox_systray_kickout(phys_screen);
473 switch(wibox->orientation)
475 case North:
476 config_win_vals[1] = systray->geometry.width - config_win_vals[3];
477 for(int j = 0; j < globalconf.embedded.len; j++)
479 em = &globalconf.embedded.tab[j];
480 if(em->phys_screen == phys_screen)
482 if(config_win_vals[1] - config_win_vals[2] >= (uint32_t) wibox->geometry.y)
484 xcb_map_window(globalconf.connection, em->win);
485 xcb_configure_window(globalconf.connection, em->win,
486 XCB_CONFIG_WINDOW_X
487 | XCB_CONFIG_WINDOW_Y
488 | XCB_CONFIG_WINDOW_WIDTH
489 | XCB_CONFIG_WINDOW_HEIGHT,
490 config_win_vals);
491 config_win_vals[1] -= config_win_vals[3];
493 else
494 xcb_configure_window(globalconf.connection, em->win,
495 XCB_CONFIG_WINDOW_X
496 | XCB_CONFIG_WINDOW_Y,
497 config_win_vals_off);
500 break;
501 case South:
502 config_win_vals[1] = 0;
503 for(int j = 0; j < globalconf.embedded.len; j++)
505 em = &globalconf.embedded.tab[j];
506 if(em->phys_screen == phys_screen)
508 /* if(y + width <= wibox.y + systray.right) */
509 if(config_win_vals[1] + config_win_vals[3] <= (uint32_t) wibox->geometry.y + AREA_RIGHT(systray->geometry))
511 xcb_map_window(globalconf.connection, em->win);
512 xcb_configure_window(globalconf.connection, em->win,
513 XCB_CONFIG_WINDOW_X
514 | XCB_CONFIG_WINDOW_Y
515 | XCB_CONFIG_WINDOW_WIDTH
516 | XCB_CONFIG_WINDOW_HEIGHT,
517 config_win_vals);
518 config_win_vals[1] += config_win_vals[3];
520 else
521 xcb_configure_window(globalconf.connection, em->win,
522 XCB_CONFIG_WINDOW_X
523 | XCB_CONFIG_WINDOW_Y,
524 config_win_vals_off);
527 break;
528 case East:
529 config_win_vals[1] = 0;
530 for(int j = 0; j < globalconf.embedded.len; j++)
532 em = &globalconf.embedded.tab[j];
533 if(em->phys_screen == phys_screen)
535 /* if(x + width < systray.x + systray.width) */
536 if(config_win_vals[0] + config_win_vals[2] <= (uint32_t) AREA_RIGHT(systray->geometry) + wibox->geometry.x)
538 xcb_map_window(globalconf.connection, em->win);
539 xcb_configure_window(globalconf.connection, em->win,
540 XCB_CONFIG_WINDOW_X
541 | XCB_CONFIG_WINDOW_Y
542 | XCB_CONFIG_WINDOW_WIDTH
543 | XCB_CONFIG_WINDOW_HEIGHT,
544 config_win_vals);
545 config_win_vals[0] += config_win_vals[2];
547 else
548 xcb_configure_window(globalconf.connection, em->win,
549 XCB_CONFIG_WINDOW_X
550 | XCB_CONFIG_WINDOW_Y,
551 config_win_vals_off);
554 break;
556 break;
561 /** Get a wibox by its window.
562 * \param win The window id.
563 * \return A wibox if found, NULL otherwise.
565 wibox_t *
566 wibox_getbywin(xcb_window_t win)
568 foreach(w, globalconf.wiboxes)
569 if((*w)->window == win)
570 return *w;
572 foreach(_c, globalconf.clients)
574 client_t *c = *_c;
575 if(c->titlebar && c->titlebar->window == win)
576 return c->titlebar;
579 return NULL;
582 /** Draw a wibox.
583 * \param wibox The wibox to draw.
585 static void
586 wibox_draw(wibox_t *wibox)
588 if(wibox->visible)
590 widget_render(wibox);
591 wibox_refresh_pixmap(wibox);
593 wibox->need_update = false;
596 wibox_systray_refresh(wibox);
599 /** Refresh all wiboxes.
601 void
602 wibox_refresh(void)
604 foreach(w, globalconf.wiboxes)
606 if((*w)->need_shape_update)
607 wibox_shape_update(*w);
608 if((*w)->need_update)
609 wibox_draw(*w);
612 foreach(_c, globalconf.clients)
614 client_t *c = *_c;
615 if(c->titlebar && c->titlebar->need_update)
616 wibox_draw(c->titlebar);
620 /** Set a wibox visible or not.
621 * \param L The Lua VM state.
622 * \param udx The wibox.
623 * \param v The visible value.
625 static void
626 wibox_set_visible(lua_State *L, int udx, bool v)
628 wibox_t *wibox = luaA_checkudata(L, udx, &wibox_class);
629 if(v != wibox->visible)
631 wibox->visible = v;
632 wibox->mouse_over = NULL;
634 if(wibox->screen)
636 if(wibox->visible)
637 wibox_map(wibox);
638 else
640 /* Active BMA */
641 client_ignore_enterleave_events();
642 /* Unmap window */
643 xcb_unmap_window(globalconf.connection, wibox->window);
644 /* Active BMA */
645 client_restore_enterleave_events();
648 /* kick out systray if needed */
649 wibox_systray_refresh(wibox);
652 luaA_object_emit_signal(L, udx, "property::visible", 0);
654 hook_property(wibox, "visible");
658 /** Destroy all X resources of a wibox.
659 * \param w The wibox to wipe.
661 void
662 wibox_wipe(wibox_t *w)
664 if(w->window)
666 /* Activate BMA */
667 client_ignore_enterleave_events();
668 xcb_destroy_window(globalconf.connection, w->window);
669 /* Deactivate BMA */
670 client_restore_enterleave_events();
671 w->window = XCB_NONE;
673 if(w->pixmap)
675 xcb_free_pixmap(globalconf.connection, w->pixmap);
676 w->pixmap = XCB_NONE;
678 if(w->gc)
680 xcb_free_gc(globalconf.connection, w->gc);
681 w->gc = XCB_NONE;
683 draw_context_wipe(&w->ctx);
686 /** Remove a wibox from a screen.
687 * \param L The Lua VM state.
688 * \param udx Wibox to detach from screen.
690 static void
691 wibox_detach(lua_State *L, int udx)
693 wibox_t *wibox = luaA_checkudata(L, udx, &wibox_class);
694 if(wibox->screen)
696 bool v;
698 /* save visible state */
699 v = wibox->visible;
700 wibox->visible = false;
701 wibox_systray_refresh(wibox);
702 /* restore visibility */
703 wibox->visible = v;
705 wibox->mouse_over = NULL;
707 wibox_wipe(wibox);
709 foreach(item, globalconf.wiboxes)
710 if(*item == wibox)
712 wibox_array_remove(&globalconf.wiboxes, item);
713 break;
716 hook_property(wibox, "screen");
718 if(strut_has_value(&wibox->strut))
719 screen_emit_signal(L, wibox->screen, "property::workarea", 0);
721 wibox->screen = NULL;
722 luaA_object_emit_signal(L, udx, "property::screen", 0);
724 luaA_object_unref(globalconf.L, wibox);
728 /** Attach a wibox that is on top of the stack.
729 * \param L The Lua VM state.
730 * \param udx The wibox to attach.
731 * \param s The screen to attach the wibox to.
733 static void
734 wibox_attach(lua_State *L, int udx, screen_t *s)
736 int phys_screen = screen_virttophys(screen_array_indexof(&globalconf.screens, s));
738 /* duplicate wibox */
739 lua_pushvalue(L, udx);
740 /* ref it */
741 wibox_t *wibox = luaA_object_ref_class(globalconf.L, -1, &wibox_class);
743 wibox_detach(L, udx);
745 /* Set the wibox screen */
746 wibox->screen = s;
748 /* Check that the wibox coordinates matches the screen. */
749 screen_t *cscreen =
750 screen_getbycoord(wibox->screen, wibox->geometry.x, wibox->geometry.y);
752 /* If it does not match, move it to the screen coordinates */
753 if(cscreen != wibox->screen)
754 wibox_moveresize(L, udx, (area_t) { .x = s->geometry.x,
755 .y = s->geometry.y,
756 .width = wibox->geometry.width,
757 .height = wibox->geometry.height });
759 wibox_array_append(&globalconf.wiboxes, wibox);
761 wibox_init(wibox, phys_screen);
763 window_set_cursor(wibox->window,
764 xcursor_new(globalconf.connection, xcursor_font_fromstr(wibox->cursor)));
766 if(wibox->opacity != -1)
767 window_opacity_set(wibox->window, wibox->opacity);
769 ewmh_update_strut(wibox->window, &wibox->strut);
771 if(wibox->visible)
772 wibox_map(wibox);
773 else
774 wibox_need_update(wibox);
776 hook_property(wibox, "screen");
777 luaA_object_emit_signal(L, udx, "property::screen", 0);
779 if(strut_has_value(&wibox->strut))
780 screen_emit_signal(L, wibox->screen, "property::workarea", 0);
783 /** Create a new wibox.
784 * \param L The Lua VM state.
786 * \luastack
787 * \lparam A table with optionally defined values:
788 * fg, bg, border_width, border_color, ontop, width and height.
789 * \lreturn A brand new wibox.
791 static int
792 luaA_wibox_new(lua_State *L)
794 luaA_class_new(L, &wibox_class);
796 wibox_t *w = luaA_checkudata(L, -1, &wibox_class);
798 if(!w->ctx.fg.initialized)
799 w->ctx.fg = globalconf.colors.fg;
801 if(!w->ctx.bg.initialized)
802 w->ctx.bg = globalconf.colors.bg;
804 if(!w->border_color.initialized)
805 w->border_color = globalconf.colors.bg;
807 w->visible = true;
809 if(!w->opacity)
810 w->opacity = -1;
812 if(!w->cursor)
813 w->cursor = a_strdup("left_ptr");
815 if(!w->geometry.width)
816 w->geometry.width = 1;
818 if(!w->geometry.height)
819 w->geometry.height = 1;
821 return 1;
824 /** Check if a wibox widget table has an item.
825 * \param L The Lua VM state.
826 * \param wibox The wibox.
827 * \param item The item to look for.
829 static bool
830 luaA_wibox_hasitem(lua_State *L, wibox_t *wibox, const void *item)
832 if(wibox->widgets_table)
834 luaA_object_push(L, wibox);
835 luaA_object_push_item(L, -1, wibox->widgets_table);
836 lua_remove(L, -2);
837 if(lua_topointer(L, -1) == item || luaA_hasitem(L, item))
838 return true;
840 return false;
843 /** Invalidate a wibox by a Lua object (table, etc).
844 * \param L The Lua VM state.
845 * \param item The object identifier.
847 void
848 luaA_wibox_invalidate_byitem(lua_State *L, const void *item)
850 foreach(w, globalconf.wiboxes)
852 wibox_t *wibox = *w;
853 if(luaA_wibox_hasitem(L, wibox, item))
855 /* update wibox */
856 wibox_need_update(wibox);
857 lua_pop(L, 1); /* remove widgets table */
862 foreach(_c, globalconf.clients)
864 client_t *c = *_c;
865 if(c->titlebar && luaA_wibox_hasitem(L, c->titlebar, item))
867 /* update wibox */
868 wibox_need_update(c->titlebar);
869 lua_pop(L, 1); /* remove widgets table */
874 /* Set or get the wibox geometry.
875 * \param L The Lua VM state.
876 * \return The number of elements pushed on stack.
877 * \luastack
878 * \lparam An optional table with wibox geometry.
879 * \lreturn The wibox geometry.
881 static int
882 luaA_wibox_geometry(lua_State *L)
884 wibox_t *wibox = luaA_checkudata(L, 1, &wibox_class);
886 if(lua_gettop(L) == 2)
888 area_t wingeom;
890 luaA_checktable(L, 2);
891 wingeom.x = luaA_getopt_number(L, 2, "x", wibox->geometry.x);
892 wingeom.y = luaA_getopt_number(L, 2, "y", wibox->geometry.y);
893 wingeom.width = luaA_getopt_number(L, 2, "width", wibox->geometry.width);
894 wingeom.height = luaA_getopt_number(L, 2, "height", wibox->geometry.height);
896 if(wingeom.width > 0 && wingeom.height > 0)
897 switch(wibox->type)
899 case WIBOX_TYPE_TITLEBAR:
900 wibox_moveresize(L, 1, (area_t) { .x = wibox->geometry.x,
901 .y = wibox->geometry.y,
902 .width = wingeom.width,
903 .height = wingeom.height });
904 break;
905 case WIBOX_TYPE_NORMAL:
906 wibox_moveresize(L, 1, wingeom);
907 break;
911 return luaA_pusharea(L, wibox->geometry);
914 static int
915 luaA_wibox_struts(lua_State *L)
917 wibox_t *w = luaA_checkudata(L, 1, &wibox_class);
919 if(lua_gettop(L) == 2)
921 luaA_tostrut(L, 2, &w->strut);
922 if(w->window)
923 ewmh_update_strut(w->window, &w->strut);
924 luaA_object_emit_signal(L, 1, "property::struts", 0);
925 if(w->screen)
926 screen_emit_signal(L, w->screen, "property::workarea", 0);
929 return luaA_pushstrut(L, w->strut);
932 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, ontop, lua_pushboolean)
933 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, cursor, lua_pushstring)
934 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, visible, lua_pushboolean)
935 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, border_width, lua_pushnumber)
936 LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, border_color, luaA_pushxcolor)
938 static int
939 luaA_wibox_set_x(lua_State *L, wibox_t *wibox)
941 wibox_moveresize(L, -3, (area_t) { .x = luaL_checknumber(L, -1),
942 .y = wibox->geometry.y,
943 .width = wibox->geometry.width,
944 .height = wibox->geometry.height });
945 return 0;
948 static int
949 luaA_wibox_get_x(lua_State *L, wibox_t *wibox)
951 lua_pushnumber(L, wibox->geometry.x);
952 return 1;
955 static int
956 luaA_wibox_set_y(lua_State *L, wibox_t *wibox)
958 wibox_moveresize(L, -3, (area_t) { .x = wibox->geometry.x,
959 .y = luaL_checknumber(L, -1),
960 .width = wibox->geometry.width,
961 .height = wibox->geometry.height });
962 return 0;
965 static int
966 luaA_wibox_get_y(lua_State *L, wibox_t *wibox)
968 lua_pushnumber(L, wibox->geometry.y);
969 return 1;
972 static int
973 luaA_wibox_set_width(lua_State *L, wibox_t *wibox)
975 int width = luaL_checknumber(L, -1);
976 if(width <= 0)
977 luaL_error(L, "invalid width");
978 wibox_moveresize(L, -3, (area_t) { .x = wibox->geometry.x,
979 .y = wibox->geometry.y,
980 .width = width,
981 .height = wibox->geometry.height });
982 return 0;
985 static int
986 luaA_wibox_get_width(lua_State *L, wibox_t *wibox)
988 lua_pushnumber(L, wibox->geometry.width);
989 return 1;
992 static int
993 luaA_wibox_set_height(lua_State *L, wibox_t *wibox)
995 int height = luaL_checknumber(L, -1);
996 if(height <= 0)
997 luaL_error(L, "invalid height");
998 wibox_moveresize(L, -3, (area_t) { .x = wibox->geometry.x,
999 .y = wibox->geometry.y,
1000 .width = wibox->geometry.width,
1001 .height = height });
1002 return 0;
1005 static int
1006 luaA_wibox_get_height(lua_State *L, wibox_t *wibox)
1008 lua_pushnumber(L, wibox->geometry.height);
1009 return 1;
1012 /** Set the wibox foreground color.
1013 * \param L The Lua VM state.
1014 * \param wibox The wibox object.
1015 * \return The number of elements pushed on stack.
1017 static int
1018 luaA_wibox_set_fg(lua_State *L, wibox_t *wibox)
1020 size_t len;
1021 const char *buf = luaL_checklstring(L, -1, &len);
1022 if(xcolor_init_reply(xcolor_init_unchecked(&wibox->ctx.fg, buf, len)))
1023 wibox->need_update = true;
1024 luaA_object_emit_signal(L, -3, "property::fg", 0);
1025 return 0;
1028 /** Get the wibox foreground color.
1029 * \param L The Lua VM state.
1030 * \param wibox The wibox object.
1031 * \return The number of elements pushed on stack.
1033 static int
1034 luaA_wibox_get_fg(lua_State *L, wibox_t *wibox)
1036 return luaA_pushxcolor(L, wibox->ctx.fg);
1039 /** Set the wibox background color.
1040 * \param L The Lua VM state.
1041 * \param wibox The wibox object.
1042 * \return The number of elements pushed on stack.
1044 static int
1045 luaA_wibox_set_bg(lua_State *L, wibox_t *wibox)
1047 size_t len;
1048 const char *buf = luaL_checklstring(L, -1, &len);
1049 if(xcolor_init_reply(xcolor_init_unchecked(&wibox->ctx.bg, buf, len)))
1050 wibox->need_update = true;
1051 luaA_object_emit_signal(L, -3, "property::bg", 0);
1052 return 0;
1055 /** Get the wibox background color.
1056 * \param L The Lua VM state.
1057 * \param wibox The wibox object.
1058 * \return The number of elements pushed on stack.
1060 static int
1061 luaA_wibox_get_bg(lua_State *L, wibox_t *wibox)
1063 return luaA_pushxcolor(L, wibox->ctx.bg);
1066 /** Set the wibox background image.
1067 * \param L The Lua VM state.
1068 * \param wibox The wibox object.
1069 * \return The number of elements pushed on stack.
1071 static int
1072 luaA_wibox_set_bg_image(lua_State *L, wibox_t *wibox)
1074 luaA_checkudata(L, -1, &image_class);
1075 luaA_object_unref_item(L, -3, wibox->bg_image);
1076 wibox->bg_image = luaA_object_ref_item(L, -3, -1);
1077 wibox->need_update = true;
1078 luaA_object_emit_signal(L, -2, "property::bg_image", 0);
1079 return 0;
1082 /** Get the wibox background image.
1083 * \param L The Lua VM state.
1084 * \param wibox The wibox object.
1085 * \return The number of elements pushed on stack.
1087 static int
1088 luaA_wibox_get_bg_image(lua_State *L, wibox_t *wibox)
1090 return luaA_object_push_item(L, 1, wibox->bg_image);
1093 /** Set the wibox on top status.
1094 * \param L The Lua VM state.
1095 * \param wibox The wibox object.
1096 * \return The number of elements pushed on stack.
1098 static int
1099 luaA_wibox_set_ontop(lua_State *L, wibox_t *wibox)
1101 bool b = luaA_checkboolean(L, -1);
1102 if(b != wibox->ontop)
1104 wibox->ontop = b;
1105 client_stack();
1106 luaA_object_emit_signal(L, -3, "property::ontop", 0);
1108 return 0;
1111 /** Set the wibox opacity.
1112 * \param L The Lua VM state.
1113 * \param wibox The wibox object.
1114 * \return The number of elements pushed on stack.
1116 static int
1117 luaA_wibox_set_opacity(lua_State *L, wibox_t *wibox)
1119 if(lua_isnil(L, -1))
1120 wibox_set_opacity(L, -3, -1);
1121 else
1123 double d = luaL_checknumber(L, -1);
1124 if(d >= 0 && d <= 1)
1125 wibox_set_opacity(L, -3, d);
1127 return 0;
1130 /** Get the wibox opacity.
1131 * \param L The Lua VM state.
1132 * \param wibox The wibox object.
1133 * \return The number of elements pushed on stack.
1135 static int
1136 luaA_wibox_get_opacity(lua_State *L, wibox_t *wibox)
1138 if (wibox->opacity >= 0)
1140 lua_pushnumber(L, wibox->opacity);
1141 return 1;
1143 return 0;
1146 /** Set the wibox alignment.
1147 * \param L The Lua VM state.
1148 * \param wibox The wibox object.
1149 * \return The number of elements pushed on stack.
1151 static int
1152 luaA_wibox_set_align(lua_State *L, wibox_t *wibox)
1154 size_t len;
1155 const char *buf = luaL_checklstring(L, -1, &len);
1156 wibox->align = draw_align_fromstr(buf, len);
1157 luaA_object_emit_signal(L, -3, "property::align", 0);
1158 switch(wibox->type)
1160 case WIBOX_TYPE_NORMAL:
1161 luaA_deprecate(L, "awful.wibox.align");
1162 break;
1163 case WIBOX_TYPE_TITLEBAR:
1164 titlebar_update_geometry(client_getbytitlebar(wibox));
1165 break;
1167 return 0;
1170 /** Get the wibox alignment.
1171 * \param L The Lua VM state.
1172 * \param wibox The wibox object.
1173 * \return The number of elements pushed on stack.
1175 static int
1176 luaA_wibox_get_align(lua_State *L, wibox_t *wibox)
1178 if(wibox->type == WIBOX_TYPE_NORMAL)
1179 luaA_deprecate(L, "awful.wibox.align");
1180 lua_pushstring(L, draw_align_tostr(wibox->align));
1181 return 1;
1184 /** Set the wibox position.
1185 * \param L The Lua VM state.
1186 * \param wibox The wibox object.
1187 * \return The number of elements pushed on stack.
1189 static int
1190 luaA_wibox_set_position(lua_State *L, wibox_t *wibox)
1192 switch(wibox->type)
1194 case WIBOX_TYPE_NORMAL:
1196 size_t len;
1197 const char *buf;
1198 if((buf = luaL_checklstring(L, -1, &len)))
1200 luaA_deprecate(L, "awful.wibox.attach");
1201 wibox->position = position_fromstr(buf, len);
1204 break;
1205 case WIBOX_TYPE_TITLEBAR:
1206 return luaA_titlebar_set_position(L, -3);
1208 return 0;
1211 /** Get the wibox position.
1212 * \param L The Lua VM state.
1213 * \param wibox The wibox object.
1214 * \return The number of elements pushed on stack.
1216 static int
1217 luaA_wibox_get_position(lua_State *L, wibox_t *wibox)
1219 if(wibox->type == WIBOX_TYPE_NORMAL)
1220 luaA_deprecate(L, "awful.wibox.attach");
1221 lua_pushstring(L, position_tostr(wibox->position));
1222 return 1;
1225 /** Set the wibox (titlebar) client.
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_client(lua_State *L, wibox_t *wibox)
1233 /* first detach */
1234 if(lua_isnil(L, -1))
1235 titlebar_client_detach(client_getbytitlebar(wibox));
1236 else
1238 client_t *c = luaA_client_checkudata(L, -1);
1239 lua_pushvalue(L, -3);
1240 titlebar_client_attach(c);
1242 return 0;
1245 /** Get the wibox (titlebar) client.
1246 * \param L The Lua VM state.
1247 * \param wibox The wibox object.
1248 * \return The number of elements pushed on stack.
1250 static int
1251 luaA_wibox_get_client(lua_State *L, wibox_t *wibox)
1253 return luaA_object_push(L, client_getbytitlebar(wibox));
1256 /** Set the wibox cursor.
1257 * \param L The Lua VM state.
1258 * \param wibox The wibox object.
1259 * \return The number of elements pushed on stack.
1261 static int
1262 luaA_wibox_set_cursor(lua_State *L, wibox_t *wibox)
1264 const char *buf = luaL_checkstring(L, -1);
1265 if(buf)
1267 uint16_t cursor_font = xcursor_font_fromstr(buf);
1268 if(cursor_font)
1270 xcb_cursor_t cursor = xcursor_new(globalconf.connection, cursor_font);
1271 p_delete(&wibox->cursor);
1272 wibox->cursor = a_strdup(buf);
1273 window_set_cursor(wibox->window, cursor);
1274 luaA_object_emit_signal(L, -3, "property::cursor", 0);
1277 return 0;
1280 /** Set the wibox screen.
1281 * \param L The Lua VM state.
1282 * \param wibox The wibox object.
1283 * \return The number of elements pushed on stack.
1285 static int
1286 luaA_wibox_set_screen(lua_State *L, wibox_t *wibox)
1288 if(lua_isnil(L, -1))
1290 wibox_detach(L, -3);
1291 titlebar_client_detach(client_getbytitlebar(wibox));
1293 else
1295 int screen = luaL_checknumber(L, -1) - 1;
1296 luaA_checkscreen(screen);
1297 if(!wibox->screen || screen != screen_array_indexof(&globalconf.screens, wibox->screen))
1299 titlebar_client_detach(client_getbytitlebar(wibox));
1300 wibox_attach(L, -3, &globalconf.screens.tab[screen]);
1303 return 0;
1306 /** Get the wibox screen.
1307 * \param L The Lua VM state.
1308 * \param wibox The wibox object.
1309 * \return The number of elements pushed on stack.
1311 static int
1312 luaA_wibox_get_screen(lua_State *L, wibox_t *wibox)
1314 if(!wibox->screen)
1315 return 0;
1316 lua_pushnumber(L, screen_array_indexof(&globalconf.screens, wibox->screen) + 1);
1317 return 1;
1320 /** Set the wibox orientation.
1321 * \param L The Lua VM state.
1322 * \param wibox The wibox object.
1323 * \return The number of elements pushed on stack.
1325 static int
1326 luaA_wibox_set_orientation(lua_State *L, wibox_t *wibox)
1328 size_t len;
1329 const char *buf = luaL_checklstring(L, -1, &len);
1330 if(buf)
1332 wibox_set_orientation(L, -3, orientation_fromstr(buf, len));
1333 wibox_need_update(wibox);
1335 return 0;
1338 /** Get the wibox orientation.
1339 * \param L The Lua VM state.
1340 * \param wibox The wibox object.
1341 * \return The number of elements pushed on stack.
1343 static int
1344 luaA_wibox_get_orientation(lua_State *L, wibox_t *wibox)
1346 lua_pushstring(L, orientation_tostr(wibox->orientation));
1347 return 1;
1350 /** Set the wibox border color.
1351 * \param L The Lua VM state.
1352 * \param wibox The wibox object.
1353 * \return The number of elements pushed on stack.
1355 static int
1356 luaA_wibox_set_border_color(lua_State *L, wibox_t *wibox)
1358 size_t len;
1359 const char *buf = luaL_checklstring(L, -1, &len);
1360 if(buf)
1361 if(xcolor_init_reply(xcolor_init_unchecked(&wibox->border_color, buf, len)))
1362 if(wibox->window)
1363 wibox_set_border_color(L, -3, &wibox->border_color);
1364 return 0;
1367 /** Set the wibox visibility.
1368 * \param L The Lua VM state.
1369 * \param wibox The wibox object.
1370 * \return The number of elements pushed on stack.
1372 static int
1373 luaA_wibox_set_visible(lua_State *L, wibox_t *wibox)
1375 bool b = luaA_checkboolean(L, -1);
1376 if(b != wibox->visible)
1377 switch(wibox->type)
1379 case WIBOX_TYPE_NORMAL:
1380 wibox_set_visible(L, -3, b);
1381 break;
1382 case WIBOX_TYPE_TITLEBAR:
1383 titlebar_set_visible(wibox, b);
1384 break;
1386 return 0;
1389 /** Set the wibox widgets.
1390 * \param L The Lua VM state.
1391 * \param wibox The wibox object.
1392 * \return The number of elements pushed on stack.
1394 static int
1395 luaA_wibox_set_widgets(lua_State *L, wibox_t *wibox)
1397 if(luaA_isloop(L, -1))
1399 luaA_warn(L, "table is looping, cannot use this as widget table");
1400 return 0;
1402 /* duplicate table because next function will eat it */
1403 lua_pushvalue(L, -1);
1404 wibox->widgets_table = luaA_object_ref_item(L, -4, -1);
1405 luaA_object_emit_signal(L, -3, "property::widgets", 0);
1406 wibox_need_update(wibox);
1407 luaA_table2wtable(L);
1408 return 0;
1411 /** Get the wibox widgets.
1412 * \param L The Lua VM state.
1413 * \param wibox The wibox object.
1414 * \return The number of elements pushed on stack.
1416 static int
1417 luaA_wibox_get_widgets(lua_State *L, wibox_t *wibox)
1419 return luaA_object_push_item(L, 1, wibox->widgets_table);
1422 /** Get or set mouse buttons bindings to a wibox.
1423 * \param L The Lua VM state.
1424 * \luastack
1425 * \lvalue A wibox.
1426 * \lparam An array of mouse button bindings objects, or nothing.
1427 * \return The array of mouse button bindings objects of this wibox.
1429 static int
1430 luaA_wibox_buttons(lua_State *L)
1432 wibox_t *wibox = luaA_checkudata(L, 1, &wibox_class);
1434 if(lua_gettop(L) == 2)
1436 luaA_button_array_set(L, 1, 2, &wibox->buttons);
1437 luaA_object_emit_signal(L, 1, "property::buttons", 0);
1440 return luaA_button_array_get(L, 1, &wibox->buttons);
1443 /** Set the wibox border width.
1444 * \param L The Lua VM state.
1445 * \param wibox The wibox object.
1446 * \return The number of elements pushed on stack.
1448 static int
1449 luaA_wibox_set_border_width(lua_State *L, wibox_t *wibox)
1451 wibox_t *w = luaA_checkudata(L, -3, &wibox_class);
1452 uint32_t border_width = luaL_checknumber(L, -1);
1453 if(border_width != w->border_width)
1455 xcb_configure_window(globalconf.connection, w->window, XCB_CONFIG_WINDOW_BORDER_WIDTH,
1456 &border_width);
1457 w->border_width = border_width;
1458 luaA_object_emit_signal(L, -3, "property::border_width", 0);
1460 return 0;
1463 static int
1464 luaA_wibox_set_shape_bounding(lua_State *L, wibox_t *wibox)
1466 luaA_checkudata(L, -1, &image_class);
1467 luaA_object_unref_item(L, -3, wibox->shape.bounding);
1468 wibox->shape.bounding = luaA_object_ref_item(L, -3, -1);
1469 wibox->need_shape_update = true;
1470 luaA_object_emit_signal(L, -2, "property::shape_bounding", 0);
1471 return 0;
1474 static int
1475 luaA_wibox_get_shape_bounding(lua_State *L, wibox_t *wibox)
1477 return luaA_object_push_item(L, 1, wibox->shape.bounding);
1480 static int
1481 luaA_wibox_set_shape_clip(lua_State *L, wibox_t *wibox)
1483 luaA_checkudata(L, -1, &image_class);
1484 luaA_object_unref_item(L, -3, wibox->shape.clip);
1485 wibox->shape.clip = luaA_object_ref_item(L, -3, -1);
1486 wibox->need_shape_update = true;
1487 luaA_object_emit_signal(L, -2, "property::shape_clip", 0);
1488 return 0;
1491 static int
1492 luaA_wibox_get_shape_clip(lua_State *L, wibox_t *wibox)
1494 return luaA_object_push_item(L, 1, wibox->shape.clip);
1497 void
1498 wibox_class_setup(lua_State *L)
1500 static const struct luaL_reg wibox_methods[] =
1502 LUA_CLASS_METHODS(wibox)
1503 { "__call", luaA_wibox_new },
1504 { NULL, NULL }
1507 static const struct luaL_reg wibox_meta[] =
1509 LUA_OBJECT_META(wibox)
1510 LUA_CLASS_META
1511 { "struts", luaA_wibox_struts },
1512 { "buttons", luaA_wibox_buttons },
1513 { "geometry", luaA_wibox_geometry },
1514 { "__gc", luaA_wibox_gc },
1515 { NULL, NULL },
1518 luaA_class_setup(L, &wibox_class, "wibox", (lua_class_allocator_t) wibox_new,
1519 luaA_class_index_miss_property, luaA_class_newindex_miss_property,
1520 wibox_methods, wibox_meta);
1521 luaA_class_add_property(&wibox_class, A_TK_WIDGETS,
1522 (lua_class_propfunc_t) luaA_wibox_set_widgets,
1523 (lua_class_propfunc_t) luaA_wibox_get_widgets,
1524 (lua_class_propfunc_t) luaA_wibox_set_widgets);
1525 luaA_class_add_property(&wibox_class, A_TK_OPACITY,
1526 (lua_class_propfunc_t) luaA_wibox_set_opacity,
1527 (lua_class_propfunc_t) luaA_wibox_get_opacity,
1528 (lua_class_propfunc_t) luaA_wibox_set_opacity);
1529 luaA_class_add_property(&wibox_class, A_TK_VISIBLE,
1530 (lua_class_propfunc_t) luaA_wibox_set_visible,
1531 (lua_class_propfunc_t) luaA_wibox_get_visible,
1532 (lua_class_propfunc_t) luaA_wibox_set_visible);
1533 luaA_class_add_property(&wibox_class, A_TK_BORDER_COLOR,
1534 (lua_class_propfunc_t) luaA_wibox_set_border_color,
1535 (lua_class_propfunc_t) luaA_wibox_get_border_color,
1536 (lua_class_propfunc_t) luaA_wibox_set_border_color);
1537 luaA_class_add_property(&wibox_class, A_TK_BORDER_WIDTH,
1538 (lua_class_propfunc_t) luaA_wibox_set_border_width,
1539 (lua_class_propfunc_t) luaA_wibox_get_border_width,
1540 (lua_class_propfunc_t) luaA_wibox_set_border_width);
1541 luaA_class_add_property(&wibox_class, A_TK_ORIENTATION,
1542 (lua_class_propfunc_t) luaA_wibox_set_orientation,
1543 (lua_class_propfunc_t) luaA_wibox_get_orientation,
1544 (lua_class_propfunc_t) luaA_wibox_set_orientation);
1545 luaA_class_add_property(&wibox_class, A_TK_ONTOP,
1546 (lua_class_propfunc_t) luaA_wibox_set_ontop,
1547 (lua_class_propfunc_t) luaA_wibox_get_ontop,
1548 (lua_class_propfunc_t) luaA_wibox_set_ontop);
1549 luaA_class_add_property(&wibox_class, A_TK_SCREEN,
1550 NULL,
1551 (lua_class_propfunc_t) luaA_wibox_get_screen,
1552 (lua_class_propfunc_t) luaA_wibox_set_screen);
1553 luaA_class_add_property(&wibox_class, A_TK_CURSOR,
1554 (lua_class_propfunc_t) luaA_wibox_set_cursor,
1555 (lua_class_propfunc_t) luaA_wibox_get_cursor,
1556 (lua_class_propfunc_t) luaA_wibox_set_cursor);
1557 luaA_class_add_property(&wibox_class, A_TK_CLIENT,
1558 (lua_class_propfunc_t) luaA_wibox_set_client,
1559 (lua_class_propfunc_t) luaA_wibox_get_client,
1560 (lua_class_propfunc_t) luaA_wibox_set_client);
1561 luaA_class_add_property(&wibox_class, A_TK_POSITION,
1562 (lua_class_propfunc_t) luaA_wibox_set_position,
1563 (lua_class_propfunc_t) luaA_wibox_get_position,
1564 (lua_class_propfunc_t) luaA_wibox_set_position);
1565 luaA_class_add_property(&wibox_class, A_TK_ALIGN,
1566 (lua_class_propfunc_t) luaA_wibox_set_align,
1567 (lua_class_propfunc_t) luaA_wibox_get_align,
1568 (lua_class_propfunc_t) luaA_wibox_set_align);
1569 luaA_class_add_property(&wibox_class, A_TK_FG,
1570 (lua_class_propfunc_t) luaA_wibox_set_fg,
1571 (lua_class_propfunc_t) luaA_wibox_get_fg,
1572 (lua_class_propfunc_t) luaA_wibox_set_fg);
1573 luaA_class_add_property(&wibox_class, A_TK_BG,
1574 (lua_class_propfunc_t) luaA_wibox_set_bg,
1575 (lua_class_propfunc_t) luaA_wibox_get_bg,
1576 (lua_class_propfunc_t) luaA_wibox_set_bg);
1577 luaA_class_add_property(&wibox_class, A_TK_BG_IMAGE,
1578 (lua_class_propfunc_t) luaA_wibox_set_bg_image,
1579 (lua_class_propfunc_t) luaA_wibox_get_bg_image,
1580 (lua_class_propfunc_t) luaA_wibox_set_bg_image);
1581 luaA_class_add_property(&wibox_class, A_TK_X,
1582 (lua_class_propfunc_t) luaA_wibox_set_x,
1583 (lua_class_propfunc_t) luaA_wibox_get_x,
1584 (lua_class_propfunc_t) luaA_wibox_set_x);
1585 luaA_class_add_property(&wibox_class, A_TK_Y,
1586 (lua_class_propfunc_t) luaA_wibox_set_y,
1587 (lua_class_propfunc_t) luaA_wibox_get_y,
1588 (lua_class_propfunc_t) luaA_wibox_set_y);
1589 luaA_class_add_property(&wibox_class, A_TK_WIDTH,
1590 (lua_class_propfunc_t) luaA_wibox_set_width,
1591 (lua_class_propfunc_t) luaA_wibox_get_width,
1592 (lua_class_propfunc_t) luaA_wibox_set_width);
1593 luaA_class_add_property(&wibox_class, A_TK_HEIGHT,
1594 (lua_class_propfunc_t) luaA_wibox_set_height,
1595 (lua_class_propfunc_t) luaA_wibox_get_height,
1596 (lua_class_propfunc_t) luaA_wibox_set_height);
1597 luaA_class_add_property(&wibox_class, A_TK_SHAPE_BOUNDING,
1598 (lua_class_propfunc_t) luaA_wibox_set_shape_bounding,
1599 (lua_class_propfunc_t) luaA_wibox_get_shape_bounding,
1600 (lua_class_propfunc_t) luaA_wibox_set_shape_bounding);
1601 luaA_class_add_property(&wibox_class, A_TK_SHAPE_CLIP,
1602 (lua_class_propfunc_t) luaA_wibox_set_shape_clip,
1603 (lua_class_propfunc_t) luaA_wibox_get_shape_clip,
1604 (lua_class_propfunc_t) luaA_wibox_set_shape_clip);
1607 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80