2008-09-21 10:13:21 +02:00
|
|
|
/*
|
2008-09-24 12:13:21 +02:00
|
|
|
* wibox.c - wibox functions
|
2008-09-21 10:13:21 +02:00
|
|
|
*
|
2009-07-28 16:04:58 +02:00
|
|
|
* Copyright © 2008-2009 Julien Danjou <julien@danjou.info>
|
2008-09-21 10:13:21 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-09-21 20:39:23 +02:00
|
|
|
#include "screen.h"
|
2008-09-21 11:47:29 +02:00
|
|
|
#include "wibox.h"
|
2009-09-14 20:22:12 +02:00
|
|
|
#include "objects/client.h"
|
2009-01-08 11:01:06 +01:00
|
|
|
#include "screen.h"
|
2009-09-17 17:51:06 +02:00
|
|
|
#include "xwindow.h"
|
2009-08-17 16:38:56 +02:00
|
|
|
#include "luaa.h"
|
2009-08-18 14:23:41 +02:00
|
|
|
#include "ewmh.h"
|
2009-04-17 16:52:25 +02:00
|
|
|
#include "common/xcursor.h"
|
|
|
|
#include "common/xutil.h"
|
2008-09-21 11:47:29 +02:00
|
|
|
|
2009-08-17 16:56:03 +02:00
|
|
|
LUA_OBJECT_FUNCS(wibox_class, wibox_t, wibox)
|
|
|
|
|
2010-07-18 09:53:45 +02:00
|
|
|
/** Kick out systray windows.
|
|
|
|
*/
|
|
|
|
static void
|
2010-08-16 13:47:40 +02:00
|
|
|
wibox_systray_kickout(void)
|
2010-07-18 09:53:45 +02:00
|
|
|
{
|
2010-08-16 14:10:58 +02:00
|
|
|
xcb_screen_t *s = globalconf.screen;
|
2010-07-18 09:53:45 +02:00
|
|
|
|
2010-08-16 13:55:12 +02:00
|
|
|
if(globalconf.systray.parent != s->root)
|
2010-07-18 09:53:45 +02:00
|
|
|
{
|
|
|
|
/* Who! Check that we're not deleting a wibox with a systray, because it
|
|
|
|
* may be its parent. If so, we reparent to root before, otherwise it will
|
|
|
|
* hurt very much. */
|
|
|
|
xcb_reparent_window(globalconf.connection,
|
2010-08-16 13:55:12 +02:00
|
|
|
globalconf.systray.window,
|
2010-07-18 09:53:45 +02:00
|
|
|
s->root, -512, -512);
|
|
|
|
|
2010-08-16 13:55:12 +02:00
|
|
|
globalconf.systray.parent = s->root;
|
2010-07-18 09:53:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-17 15:05:53 +02:00
|
|
|
/** Destroy all X resources of a wibox.
|
|
|
|
* \param w The wibox to wipe.
|
|
|
|
*/
|
|
|
|
static void
|
2009-10-02 15:48:32 +02:00
|
|
|
wibox_wipe_resources(wibox_t *w)
|
2009-09-17 15:05:53 +02:00
|
|
|
{
|
|
|
|
if(w->window)
|
|
|
|
{
|
|
|
|
/* Activate BMA */
|
|
|
|
client_ignore_enterleave_events();
|
2010-07-18 09:54:30 +02:00
|
|
|
/* Make sure we don't accidentally kill the systray window */
|
2010-08-16 13:55:12 +02:00
|
|
|
if(globalconf.systray.parent == w->window)
|
2010-08-16 13:47:40 +02:00
|
|
|
wibox_systray_kickout();
|
2009-09-17 15:05:53 +02:00
|
|
|
xcb_destroy_window(globalconf.connection, w->window);
|
|
|
|
/* Deactivate BMA */
|
|
|
|
client_restore_enterleave_events();
|
|
|
|
w->window = XCB_NONE;
|
|
|
|
}
|
|
|
|
if(w->pixmap)
|
|
|
|
{
|
|
|
|
xcb_free_pixmap(globalconf.connection, w->pixmap);
|
|
|
|
w->pixmap = XCB_NONE;
|
|
|
|
}
|
|
|
|
draw_context_wipe(&w->ctx);
|
|
|
|
}
|
|
|
|
|
2009-10-02 15:48:32 +02:00
|
|
|
static void
|
|
|
|
wibox_wipe(wibox_t *wibox)
|
2009-04-11 00:27:06 +02:00
|
|
|
{
|
2009-04-13 12:40:33 +02:00
|
|
|
p_delete(&wibox->cursor);
|
2009-10-02 15:48:32 +02:00
|
|
|
wibox_wipe_resources(wibox);
|
2009-04-11 00:27:06 +02:00
|
|
|
widget_node_array_wipe(&wibox->widgets);
|
2010-08-20 14:18:20 +02:00
|
|
|
if(wibox->bg_image)
|
|
|
|
cairo_surface_destroy(wibox->bg_image);
|
2009-04-11 00:27:06 +02:00
|
|
|
}
|
|
|
|
|
2010-05-25 15:43:18 +02:00
|
|
|
/** Wipe an array of widget_node. Release references to widgets.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param idx The index of the wibox on the stack.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
wibox_widget_node_array_wipe(lua_State *L, int idx)
|
|
|
|
{
|
|
|
|
wibox_t *wibox = luaA_checkudata(L, idx, &wibox_class);
|
|
|
|
foreach(widget_node, wibox->widgets)
|
2010-09-17 15:45:24 +02:00
|
|
|
luaA_object_unref_item(globalconf.L, idx, widget_node->widget);
|
2010-05-25 15:43:18 +02:00
|
|
|
widget_node_array_wipe(&wibox->widgets);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-11 00:27:06 +02:00
|
|
|
void
|
|
|
|
wibox_unref_simplified(wibox_t **item)
|
|
|
|
{
|
2009-06-29 11:02:13 +02:00
|
|
|
luaA_object_unref(globalconf.L, *item);
|
2009-04-11 00:27:06 +02:00
|
|
|
}
|
2008-09-21 20:39:23 +02:00
|
|
|
|
2009-07-28 17:18:41 +02:00
|
|
|
static void
|
|
|
|
wibox_need_update(wibox_t *wibox)
|
|
|
|
{
|
|
|
|
wibox->need_update = true;
|
2009-11-21 10:54:44 +01:00
|
|
|
wibox_clear_mouse_over(wibox);
|
2009-07-28 17:18:41 +02:00
|
|
|
}
|
|
|
|
|
2009-07-28 16:04:58 +02:00
|
|
|
static void
|
2010-08-16 14:12:27 +02:00
|
|
|
wibox_draw_context_update(wibox_t *w)
|
2009-07-28 16:04:58 +02:00
|
|
|
{
|
2010-08-16 14:12:27 +02:00
|
|
|
xcb_screen_t *s = globalconf.screen;
|
2009-07-28 16:04:58 +02:00
|
|
|
xcolor_t fg = w->ctx.fg, bg = w->ctx.bg;
|
|
|
|
|
|
|
|
draw_context_wipe(&w->ctx);
|
|
|
|
|
|
|
|
/* update draw context */
|
|
|
|
switch(w->orientation)
|
|
|
|
{
|
|
|
|
case South:
|
|
|
|
case North:
|
|
|
|
/* we need a new pixmap this way [ ] to render */
|
|
|
|
w->ctx.pixmap = xcb_generate_id(globalconf.connection);
|
|
|
|
xcb_create_pixmap(globalconf.connection,
|
2010-09-30 12:55:58 +02:00
|
|
|
globalconf.default_depth,
|
2009-07-28 16:04:58 +02:00
|
|
|
w->ctx.pixmap, s->root,
|
2009-07-29 11:04:59 +02:00
|
|
|
w->geometry.height,
|
|
|
|
w->geometry.width);
|
2010-08-16 13:47:40 +02:00
|
|
|
draw_context_init(&w->ctx,
|
2009-07-29 11:04:59 +02:00
|
|
|
w->geometry.height,
|
|
|
|
w->geometry.width,
|
2009-07-28 16:04:58 +02:00
|
|
|
w->ctx.pixmap, &fg, &bg);
|
|
|
|
break;
|
|
|
|
case East:
|
2010-08-16 13:47:40 +02:00
|
|
|
draw_context_init(&w->ctx,
|
2009-07-29 11:04:59 +02:00
|
|
|
w->geometry.width,
|
|
|
|
w->geometry.height,
|
2009-07-28 16:04:58 +02:00
|
|
|
w->pixmap, &fg, &bg);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Initialize a wibox.
|
|
|
|
* \param w The wibox to initialize.
|
|
|
|
*/
|
2009-09-17 15:05:53 +02:00
|
|
|
static void
|
2010-08-16 13:47:40 +02:00
|
|
|
wibox_init(wibox_t *w)
|
2009-07-28 16:04:58 +02:00
|
|
|
{
|
2010-08-16 14:10:58 +02:00
|
|
|
xcb_screen_t *s = globalconf.screen;
|
2009-07-28 16:04:58 +02:00
|
|
|
|
|
|
|
w->window = xcb_generate_id(globalconf.connection);
|
2010-09-30 12:55:58 +02:00
|
|
|
xcb_create_window(globalconf.connection, globalconf.default_depth, w->window, s->root,
|
2009-07-28 17:18:41 +02:00
|
|
|
w->geometry.x, w->geometry.y,
|
2009-07-29 11:04:59 +02:00
|
|
|
w->geometry.width, w->geometry.height,
|
2010-09-30 12:55:58 +02:00
|
|
|
w->border_width, XCB_COPY_FROM_PARENT, globalconf.visual->visual_id,
|
2009-11-07 20:06:46 +01:00
|
|
|
XCB_CW_BACK_PIXEL | XCB_CW_BORDER_PIXEL | XCB_CW_BIT_GRAVITY
|
2009-07-28 16:04:58 +02:00
|
|
|
| XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK,
|
|
|
|
(const uint32_t [])
|
|
|
|
{
|
2009-11-07 20:02:22 +01:00
|
|
|
w->ctx.bg.pixel,
|
2009-08-17 16:56:03 +02:00
|
|
|
w->border_color.pixel,
|
2009-11-07 20:06:46 +01:00
|
|
|
XCB_GRAVITY_NORTH_WEST,
|
2009-07-28 16:04:58 +02:00
|
|
|
1,
|
|
|
|
XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT
|
|
|
|
| XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_ENTER_WINDOW
|
|
|
|
| XCB_EVENT_MASK_LEAVE_WINDOW | XCB_EVENT_MASK_STRUCTURE_NOTIFY
|
|
|
|
| XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE
|
|
|
|
| XCB_EVENT_MASK_PROPERTY_CHANGE
|
|
|
|
});
|
|
|
|
|
|
|
|
/* Create a pixmap. */
|
|
|
|
w->pixmap = xcb_generate_id(globalconf.connection);
|
2010-09-30 12:55:58 +02:00
|
|
|
xcb_create_pixmap(globalconf.connection, globalconf.default_depth, w->pixmap, s->root,
|
2009-07-29 11:04:59 +02:00
|
|
|
w->geometry.width, w->geometry.height);
|
2009-07-28 16:04:58 +02:00
|
|
|
|
|
|
|
/* Update draw context physical screen, important for Zaphod. */
|
2010-08-16 14:12:27 +02:00
|
|
|
wibox_draw_context_update(w);
|
2010-09-27 22:03:34 +02:00
|
|
|
|
|
|
|
/* Set the right type property */
|
2010-09-28 13:07:31 +02:00
|
|
|
ewmh_update_window_type(w->window, window_translate_type(w->type));
|
2009-07-28 16:04:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Refresh the window content by copying its pixmap data to its window.
|
|
|
|
* \param w The wibox to refresh.
|
|
|
|
*/
|
|
|
|
static inline void
|
|
|
|
wibox_refresh_pixmap(wibox_t *w)
|
|
|
|
{
|
|
|
|
wibox_refresh_pixmap_partial(w, 0, 0, w->geometry.width, w->geometry.height);
|
|
|
|
}
|
|
|
|
|
2009-08-17 16:56:03 +02:00
|
|
|
/** Move and/or resize a wibox
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param udx The index of the wibox.
|
|
|
|
* \param geometry The new geometry.
|
|
|
|
*/
|
2009-09-17 15:05:53 +02:00
|
|
|
static void
|
2009-08-17 16:56:03 +02:00
|
|
|
wibox_moveresize(lua_State *L, int udx, area_t geometry)
|
2009-07-28 16:04:58 +02:00
|
|
|
{
|
2009-08-17 16:56:03 +02:00
|
|
|
wibox_t *w = luaA_checkudata(L, udx, &wibox_class);
|
2009-07-28 16:04:58 +02:00
|
|
|
if(w->window)
|
|
|
|
{
|
2009-07-28 17:18:41 +02:00
|
|
|
int number_of_vals = 0;
|
2009-07-28 16:04:58 +02:00
|
|
|
uint32_t moveresize_win_vals[4], mask_vals = 0;
|
|
|
|
|
2009-07-28 17:18:41 +02:00
|
|
|
if(w->geometry.x != geometry.x)
|
|
|
|
{
|
|
|
|
w->geometry.x = moveresize_win_vals[number_of_vals++] = geometry.x;
|
|
|
|
mask_vals |= XCB_CONFIG_WINDOW_X;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(w->geometry.y != geometry.y)
|
|
|
|
{
|
|
|
|
w->geometry.y = moveresize_win_vals[number_of_vals++] = geometry.y;
|
|
|
|
mask_vals |= XCB_CONFIG_WINDOW_Y;
|
|
|
|
}
|
2009-07-28 16:04:58 +02:00
|
|
|
|
2009-07-29 11:04:59 +02:00
|
|
|
if(geometry.width > 0 && w->geometry.width != geometry.width)
|
2009-07-28 16:04:58 +02:00
|
|
|
{
|
2009-07-29 11:04:59 +02:00
|
|
|
w->geometry.width = moveresize_win_vals[number_of_vals++] = geometry.width;
|
2009-07-28 17:18:41 +02:00
|
|
|
mask_vals |= XCB_CONFIG_WINDOW_WIDTH;
|
2009-07-28 16:04:58 +02:00
|
|
|
}
|
|
|
|
|
2009-07-29 11:04:59 +02:00
|
|
|
if(geometry.height > 0 && w->geometry.height != geometry.height)
|
2009-07-28 17:18:41 +02:00
|
|
|
{
|
2009-07-29 11:04:59 +02:00
|
|
|
w->geometry.height = moveresize_win_vals[number_of_vals++] = geometry.height;
|
2009-07-28 17:18:41 +02:00
|
|
|
mask_vals |= XCB_CONFIG_WINDOW_HEIGHT;
|
|
|
|
}
|
|
|
|
|
2009-07-29 11:04:59 +02:00
|
|
|
if(mask_vals & (XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT))
|
2009-07-28 16:04:58 +02:00
|
|
|
{
|
|
|
|
xcb_free_pixmap(globalconf.connection, w->pixmap);
|
|
|
|
/* orientation != East */
|
|
|
|
if(w->pixmap != w->ctx.pixmap)
|
|
|
|
xcb_free_pixmap(globalconf.connection, w->ctx.pixmap);
|
|
|
|
w->pixmap = xcb_generate_id(globalconf.connection);
|
2010-08-16 14:10:58 +02:00
|
|
|
xcb_screen_t *s = globalconf.screen;
|
2010-09-30 12:55:58 +02:00
|
|
|
xcb_create_pixmap(globalconf.connection, globalconf.default_depth, w->pixmap, s->root,
|
2009-07-29 11:04:59 +02:00
|
|
|
w->geometry.width, w->geometry.height);
|
2010-08-16 14:12:27 +02:00
|
|
|
wibox_draw_context_update(w);
|
2009-07-28 16:04:58 +02:00
|
|
|
}
|
|
|
|
|
2009-08-30 07:26:19 +02:00
|
|
|
/* Activate BMA */
|
2009-08-25 11:02:36 +02:00
|
|
|
client_ignore_enterleave_events();
|
|
|
|
|
2009-07-28 17:18:41 +02:00
|
|
|
if(mask_vals)
|
|
|
|
xcb_configure_window(globalconf.connection, w->window, mask_vals, moveresize_win_vals);
|
2009-08-04 12:03:26 +02:00
|
|
|
|
2009-08-30 07:26:19 +02:00
|
|
|
/* Deactivate BMA */
|
2009-08-25 11:02:36 +02:00
|
|
|
client_restore_enterleave_events();
|
|
|
|
|
2010-08-16 14:25:12 +02:00
|
|
|
w->screen = screen_getbycoord(w->geometry.x, w->geometry.y);
|
2009-08-17 16:56:03 +02:00
|
|
|
|
|
|
|
if(mask_vals & XCB_CONFIG_WINDOW_X)
|
|
|
|
luaA_object_emit_signal(L, udx, "property::x", 0);
|
|
|
|
if(mask_vals & XCB_CONFIG_WINDOW_Y)
|
|
|
|
luaA_object_emit_signal(L, udx, "property::y", 0);
|
|
|
|
if(mask_vals & XCB_CONFIG_WINDOW_WIDTH)
|
|
|
|
luaA_object_emit_signal(L, udx, "property::width", 0);
|
|
|
|
if(mask_vals & XCB_CONFIG_WINDOW_HEIGHT)
|
|
|
|
luaA_object_emit_signal(L, udx, "property::height", 0);
|
2009-07-28 16:04:58 +02:00
|
|
|
}
|
|
|
|
else
|
2009-08-17 16:56:03 +02:00
|
|
|
{
|
|
|
|
#define DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(prop) \
|
|
|
|
if(w->geometry.prop != geometry.prop) \
|
|
|
|
{ \
|
|
|
|
w->geometry.prop = geometry.prop; \
|
|
|
|
luaA_object_emit_signal(L, udx, "property::" #prop, 0); \
|
|
|
|
}
|
|
|
|
DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(x)
|
|
|
|
DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(y)
|
|
|
|
DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(width)
|
|
|
|
DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(height)
|
|
|
|
#undef DO_WIBOX_GEOMETRY_CHECK_AND_EMIT
|
|
|
|
}
|
2009-07-28 16:04:58 +02:00
|
|
|
|
2009-07-28 17:18:41 +02:00
|
|
|
wibox_need_update(w);
|
2009-07-28 16:04:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Refresh the window content by copying its pixmap data to its window.
|
|
|
|
* \param wibox The wibox to refresh.
|
|
|
|
* \param x The copy starting point x component.
|
|
|
|
* \param y The copy starting point y component.
|
|
|
|
* \param w The copy width from the x component.
|
|
|
|
* \param h The copy height from the y component.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
wibox_refresh_pixmap_partial(wibox_t *wibox,
|
|
|
|
int16_t x, int16_t y,
|
|
|
|
uint16_t w, uint16_t h)
|
|
|
|
{
|
|
|
|
xcb_copy_area(globalconf.connection, wibox->pixmap,
|
2010-08-17 15:44:44 +02:00
|
|
|
wibox->window, globalconf.gc, x, y, x, y,
|
2009-07-28 16:04:58 +02:00
|
|
|
w, h);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set wibox orientation.
|
2009-08-17 16:56:03 +02:00
|
|
|
* \param L The Lua VM state.
|
2009-08-25 04:55:10 +02:00
|
|
|
* \param udx The wibox to change orientation.
|
2009-07-28 16:04:58 +02:00
|
|
|
* \param o The new orientation.
|
|
|
|
*/
|
2009-09-17 15:05:53 +02:00
|
|
|
static void
|
2009-08-17 16:56:03 +02:00
|
|
|
wibox_set_orientation(lua_State *L, int udx, orientation_t o)
|
2009-07-28 16:04:58 +02:00
|
|
|
{
|
2009-08-17 16:56:03 +02:00
|
|
|
wibox_t *w = luaA_checkudata(L, udx, &wibox_class);
|
2009-07-28 16:04:58 +02:00
|
|
|
if(o != w->orientation)
|
|
|
|
{
|
|
|
|
w->orientation = o;
|
|
|
|
/* orientation != East */
|
|
|
|
if(w->pixmap != w->ctx.pixmap)
|
|
|
|
xcb_free_pixmap(globalconf.connection, w->ctx.pixmap);
|
2010-08-16 14:12:27 +02:00
|
|
|
wibox_draw_context_update(w);
|
2009-08-17 16:56:03 +02:00
|
|
|
luaA_object_emit_signal(L, udx, "property::orientation", 0);
|
2009-07-28 16:04:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-11 13:14:50 +02:00
|
|
|
static void
|
|
|
|
wibox_map(wibox_t *wibox)
|
|
|
|
{
|
2009-08-25 11:02:36 +02:00
|
|
|
/* Activate BMA */
|
|
|
|
client_ignore_enterleave_events();
|
|
|
|
/* Map the wibox */
|
2009-07-28 16:04:58 +02:00
|
|
|
xcb_map_window(globalconf.connection, wibox->window);
|
2009-08-30 07:26:19 +02:00
|
|
|
/* Deactivate BMA */
|
2009-08-25 11:02:36 +02:00
|
|
|
client_restore_enterleave_events();
|
2009-04-11 13:26:58 +02:00
|
|
|
/* We must make sure the wibox does not display garbage */
|
|
|
|
wibox_need_update(wibox);
|
2009-04-11 13:14:50 +02:00
|
|
|
/* Stack this wibox correctly */
|
2009-10-05 20:36:02 +02:00
|
|
|
stack_windows();
|
2009-04-11 13:14:50 +02:00
|
|
|
}
|
|
|
|
|
2008-09-24 12:13:21 +02:00
|
|
|
static void
|
|
|
|
wibox_systray_refresh(wibox_t *wibox)
|
|
|
|
{
|
2010-05-21 21:18:12 +02:00
|
|
|
wibox->has_systray = false;
|
|
|
|
|
2009-04-17 16:14:09 +02:00
|
|
|
if(!wibox->screen)
|
2008-09-24 12:13:21 +02:00
|
|
|
return;
|
|
|
|
|
2008-10-21 17:21:21 +02:00
|
|
|
for(int i = 0; i < wibox->widgets.len; i++)
|
|
|
|
{
|
|
|
|
widget_node_t *systray = &wibox->widgets.tab[i];
|
2008-11-12 14:55:30 +01:00
|
|
|
if(systray->widget->type == widget_systray)
|
2008-09-24 12:13:21 +02:00
|
|
|
{
|
2009-07-28 16:04:58 +02:00
|
|
|
uint32_t config_back[] = { wibox->ctx.bg.pixel };
|
2008-09-24 12:13:21 +02:00
|
|
|
uint32_t config_win_vals[4];
|
|
|
|
uint32_t config_win_vals_off[2] = { -512, -512 };
|
|
|
|
xembed_window_t *em;
|
|
|
|
|
2010-05-21 21:18:12 +02:00
|
|
|
wibox->has_systray = true;
|
|
|
|
|
2009-08-17 16:56:03 +02:00
|
|
|
if(wibox->visible
|
2008-09-24 12:13:21 +02:00
|
|
|
&& systray->widget->isvisible
|
2008-10-22 17:32:17 +02:00
|
|
|
&& systray->geometry.width)
|
2008-09-24 12:13:21 +02:00
|
|
|
{
|
|
|
|
/* Set background of the systray window. */
|
|
|
|
xcb_change_window_attributes(globalconf.connection,
|
2010-08-16 13:55:12 +02:00
|
|
|
globalconf.systray.window,
|
2008-09-24 12:13:21 +02:00
|
|
|
XCB_CW_BACK_PIXEL, config_back);
|
|
|
|
/* Map it. */
|
2010-08-16 13:55:12 +02:00
|
|
|
xcb_map_window(globalconf.connection, globalconf.systray.window);
|
2008-09-24 12:13:21 +02:00
|
|
|
/* Move it. */
|
2009-07-28 16:04:58 +02:00
|
|
|
switch(wibox->orientation)
|
2008-09-24 12:13:21 +02:00
|
|
|
{
|
2009-02-23 14:51:30 +01:00
|
|
|
case North:
|
2008-10-22 17:32:17 +02:00
|
|
|
config_win_vals[0] = systray->geometry.y;
|
2009-07-28 16:04:58 +02:00
|
|
|
config_win_vals[1] = wibox->geometry.height - systray->geometry.x - systray->geometry.width;
|
2008-10-22 17:32:17 +02:00
|
|
|
config_win_vals[2] = systray->geometry.height;
|
|
|
|
config_win_vals[3] = systray->geometry.width;
|
2008-09-24 12:13:21 +02:00
|
|
|
break;
|
2009-02-23 14:51:30 +01:00
|
|
|
case South:
|
2008-10-22 17:32:17 +02:00
|
|
|
config_win_vals[0] = systray->geometry.y;
|
|
|
|
config_win_vals[1] = systray->geometry.x;
|
|
|
|
config_win_vals[2] = systray->geometry.height;
|
|
|
|
config_win_vals[3] = systray->geometry.width;
|
2008-09-24 12:13:21 +02:00
|
|
|
break;
|
2009-02-23 14:51:30 +01:00
|
|
|
case East:
|
2008-10-22 17:32:17 +02:00
|
|
|
config_win_vals[0] = systray->geometry.x;
|
|
|
|
config_win_vals[1] = systray->geometry.y;
|
|
|
|
config_win_vals[2] = systray->geometry.width;
|
|
|
|
config_win_vals[3] = systray->geometry.height;
|
2008-09-24 12:13:21 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* reparent */
|
2010-08-16 13:55:12 +02:00
|
|
|
if(globalconf.systray.parent != wibox->window)
|
2008-09-24 12:13:21 +02:00
|
|
|
{
|
|
|
|
xcb_reparent_window(globalconf.connection,
|
2010-08-16 13:55:12 +02:00
|
|
|
globalconf.systray.window,
|
2009-07-28 16:04:58 +02:00
|
|
|
wibox->window,
|
2008-09-24 12:13:21 +02:00
|
|
|
config_win_vals[0], config_win_vals[1]);
|
2010-08-16 13:55:12 +02:00
|
|
|
globalconf.systray.parent = wibox->window;
|
2008-09-24 12:13:21 +02:00
|
|
|
}
|
|
|
|
xcb_configure_window(globalconf.connection,
|
2010-08-16 13:55:12 +02:00
|
|
|
globalconf.systray.window,
|
2008-09-24 12:13:21 +02:00
|
|
|
XCB_CONFIG_WINDOW_X
|
|
|
|
| XCB_CONFIG_WINDOW_Y
|
|
|
|
| XCB_CONFIG_WINDOW_WIDTH
|
|
|
|
| XCB_CONFIG_WINDOW_HEIGHT,
|
|
|
|
config_win_vals);
|
|
|
|
/* width = height = systray height */
|
2008-10-22 17:32:17 +02:00
|
|
|
config_win_vals[2] = config_win_vals[3] = systray->geometry.height;
|
2008-09-24 12:13:21 +02:00
|
|
|
config_win_vals[0] = 0;
|
|
|
|
}
|
|
|
|
else
|
2010-08-16 13:47:40 +02:00
|
|
|
return wibox_systray_kickout();
|
2008-09-24 12:13:21 +02:00
|
|
|
|
2009-07-28 16:04:58 +02:00
|
|
|
switch(wibox->orientation)
|
2008-09-24 12:13:21 +02:00
|
|
|
{
|
2009-02-23 14:51:30 +01:00
|
|
|
case North:
|
2008-10-22 17:32:17 +02:00
|
|
|
config_win_vals[1] = systray->geometry.width - config_win_vals[3];
|
2008-12-01 16:43:44 +01:00
|
|
|
for(int j = 0; j < globalconf.embedded.len; j++)
|
|
|
|
{
|
|
|
|
em = &globalconf.embedded.tab[j];
|
2010-08-16 13:47:40 +02:00
|
|
|
if(config_win_vals[1] - config_win_vals[2] >= (uint32_t) wibox->geometry.y)
|
2008-09-24 12:13:21 +02:00
|
|
|
{
|
2010-08-16 13:47:40 +02:00
|
|
|
xcb_map_window(globalconf.connection, em->win);
|
|
|
|
xcb_configure_window(globalconf.connection, em->win,
|
|
|
|
XCB_CONFIG_WINDOW_X
|
|
|
|
| XCB_CONFIG_WINDOW_Y
|
|
|
|
| XCB_CONFIG_WINDOW_WIDTH
|
|
|
|
| XCB_CONFIG_WINDOW_HEIGHT,
|
|
|
|
config_win_vals);
|
|
|
|
config_win_vals[1] -= config_win_vals[3];
|
2008-09-24 12:13:21 +02:00
|
|
|
}
|
2010-08-16 13:47:40 +02:00
|
|
|
else
|
|
|
|
xcb_configure_window(globalconf.connection, em->win,
|
|
|
|
XCB_CONFIG_WINDOW_X
|
|
|
|
| XCB_CONFIG_WINDOW_Y,
|
|
|
|
config_win_vals_off);
|
2008-12-01 16:43:44 +01:00
|
|
|
}
|
2008-09-24 12:13:21 +02:00
|
|
|
break;
|
2009-02-23 14:51:30 +01:00
|
|
|
case South:
|
2008-09-24 12:13:21 +02:00
|
|
|
config_win_vals[1] = 0;
|
2008-12-01 16:43:44 +01:00
|
|
|
for(int j = 0; j < globalconf.embedded.len; j++)
|
|
|
|
{
|
|
|
|
em = &globalconf.embedded.tab[j];
|
2010-08-16 13:47:40 +02:00
|
|
|
/* if(y + width <= wibox.y + systray.right) */
|
|
|
|
if(config_win_vals[1] + config_win_vals[3] <= (uint32_t) wibox->geometry.y + AREA_RIGHT(systray->geometry))
|
2008-09-24 12:13:21 +02:00
|
|
|
{
|
2010-08-16 13:47:40 +02:00
|
|
|
xcb_map_window(globalconf.connection, em->win);
|
|
|
|
xcb_configure_window(globalconf.connection, em->win,
|
|
|
|
XCB_CONFIG_WINDOW_X
|
|
|
|
| XCB_CONFIG_WINDOW_Y
|
|
|
|
| XCB_CONFIG_WINDOW_WIDTH
|
|
|
|
| XCB_CONFIG_WINDOW_HEIGHT,
|
|
|
|
config_win_vals);
|
|
|
|
config_win_vals[1] += config_win_vals[3];
|
2008-09-24 12:13:21 +02:00
|
|
|
}
|
2010-08-16 13:47:40 +02:00
|
|
|
else
|
|
|
|
xcb_configure_window(globalconf.connection, em->win,
|
|
|
|
XCB_CONFIG_WINDOW_X
|
|
|
|
| XCB_CONFIG_WINDOW_Y,
|
|
|
|
config_win_vals_off);
|
2008-12-01 16:43:44 +01:00
|
|
|
}
|
2008-09-24 12:13:21 +02:00
|
|
|
break;
|
2009-02-23 14:51:30 +01:00
|
|
|
case East:
|
2008-09-24 12:13:21 +02:00
|
|
|
config_win_vals[1] = 0;
|
2008-12-01 16:43:44 +01:00
|
|
|
for(int j = 0; j < globalconf.embedded.len; j++)
|
|
|
|
{
|
|
|
|
em = &globalconf.embedded.tab[j];
|
2010-08-16 13:47:40 +02:00
|
|
|
/* if(x + width < systray.x + systray.width) */
|
|
|
|
if(config_win_vals[0] + config_win_vals[2] <= (uint32_t) AREA_RIGHT(systray->geometry) + wibox->geometry.x)
|
2008-09-24 12:13:21 +02:00
|
|
|
{
|
2010-08-16 13:47:40 +02:00
|
|
|
xcb_map_window(globalconf.connection, em->win);
|
|
|
|
xcb_configure_window(globalconf.connection, em->win,
|
|
|
|
XCB_CONFIG_WINDOW_X
|
|
|
|
| XCB_CONFIG_WINDOW_Y
|
|
|
|
| XCB_CONFIG_WINDOW_WIDTH
|
|
|
|
| XCB_CONFIG_WINDOW_HEIGHT,
|
|
|
|
config_win_vals);
|
|
|
|
config_win_vals[0] += config_win_vals[2];
|
2008-09-24 12:13:21 +02:00
|
|
|
}
|
2010-08-16 13:47:40 +02:00
|
|
|
else
|
|
|
|
xcb_configure_window(globalconf.connection, em->win,
|
|
|
|
XCB_CONFIG_WINDOW_X
|
|
|
|
| XCB_CONFIG_WINDOW_Y,
|
|
|
|
config_win_vals_off);
|
2008-12-01 16:43:44 +01:00
|
|
|
}
|
2008-09-24 12:13:21 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2008-10-21 17:21:21 +02:00
|
|
|
}
|
2008-09-24 12:13:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Get a wibox by its window.
|
2009-07-27 06:20:00 +02:00
|
|
|
* \param win The window id.
|
2008-09-24 12:13:21 +02:00
|
|
|
* \return A wibox if found, NULL otherwise.
|
|
|
|
*/
|
|
|
|
wibox_t *
|
2009-04-11 00:27:06 +02:00
|
|
|
wibox_getbywin(xcb_window_t win)
|
2008-09-24 12:13:21 +02:00
|
|
|
{
|
2009-05-10 14:55:13 +02:00
|
|
|
foreach(w, globalconf.wiboxes)
|
2009-07-28 16:04:58 +02:00
|
|
|
if((*w)->window == win)
|
2009-05-10 14:55:13 +02:00
|
|
|
return *w;
|
2008-09-24 12:13:21 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Draw a wibox.
|
|
|
|
* \param wibox The wibox to draw.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
wibox_draw(wibox_t *wibox)
|
|
|
|
{
|
2009-08-17 16:56:03 +02:00
|
|
|
if(wibox->visible)
|
2008-09-24 12:13:21 +02:00
|
|
|
{
|
2009-01-16 10:31:13 +01:00
|
|
|
widget_render(wibox);
|
2009-07-28 16:04:58 +02:00
|
|
|
wibox_refresh_pixmap(wibox);
|
2008-09-24 12:13:21 +02:00
|
|
|
|
|
|
|
wibox->need_update = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
wibox_systray_refresh(wibox);
|
|
|
|
}
|
|
|
|
|
2008-09-21 20:39:23 +02:00
|
|
|
/** Refresh all wiboxes.
|
|
|
|
*/
|
2008-09-21 11:47:29 +02:00
|
|
|
void
|
|
|
|
wibox_refresh(void)
|
|
|
|
{
|
2009-05-10 14:55:13 +02:00
|
|
|
foreach(w, globalconf.wiboxes)
|
2009-06-23 12:55:50 +02:00
|
|
|
{
|
2009-05-10 14:55:13 +02:00
|
|
|
if((*w)->need_update)
|
|
|
|
wibox_draw(*w);
|
2009-06-23 12:55:50 +02:00
|
|
|
}
|
2008-09-24 12:13:21 +02:00
|
|
|
}
|
|
|
|
|
2009-11-21 10:54:44 +01:00
|
|
|
/** Clear the wibox' mouse_over pointer.
|
|
|
|
* \param wibox The wibox.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
wibox_clear_mouse_over(wibox_t *wibox)
|
|
|
|
{
|
|
|
|
if (wibox->mouse_over)
|
|
|
|
{
|
|
|
|
luaA_object_unref(globalconf.L, wibox->mouse_over);
|
|
|
|
wibox->mouse_over = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-24 12:13:21 +02:00
|
|
|
/** Set a wibox visible or not.
|
2009-08-25 04:55:10 +02:00
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param udx The wibox.
|
2008-09-24 12:13:21 +02:00
|
|
|
* \param v The visible value.
|
|
|
|
*/
|
|
|
|
static void
|
2009-08-17 16:56:03 +02:00
|
|
|
wibox_set_visible(lua_State *L, int udx, bool v)
|
2008-09-24 12:13:21 +02:00
|
|
|
{
|
2009-08-17 16:56:03 +02:00
|
|
|
wibox_t *wibox = luaA_checkudata(L, udx, &wibox_class);
|
|
|
|
if(v != wibox->visible)
|
2008-09-24 12:13:21 +02:00
|
|
|
{
|
2009-08-17 16:56:03 +02:00
|
|
|
wibox->visible = v;
|
2009-11-21 10:54:44 +01:00
|
|
|
wibox_clear_mouse_over(wibox);
|
2008-12-09 16:23:39 +01:00
|
|
|
|
2009-05-05 17:32:53 +02:00
|
|
|
if(wibox->screen)
|
2008-11-03 16:33:17 +01:00
|
|
|
{
|
2009-08-17 16:56:03 +02:00
|
|
|
if(wibox->visible)
|
2009-04-11 13:14:50 +02:00
|
|
|
wibox_map(wibox);
|
2008-12-09 16:23:39 +01:00
|
|
|
else
|
2009-08-25 11:02:36 +02:00
|
|
|
{
|
|
|
|
/* Active BMA */
|
|
|
|
client_ignore_enterleave_events();
|
|
|
|
/* Unmap window */
|
2009-07-28 16:04:58 +02:00
|
|
|
xcb_unmap_window(globalconf.connection, wibox->window);
|
2009-08-25 11:02:36 +02:00
|
|
|
/* Active BMA */
|
|
|
|
client_restore_enterleave_events();
|
|
|
|
}
|
2008-11-03 16:33:17 +01:00
|
|
|
|
2008-12-09 16:23:39 +01:00
|
|
|
/* kick out systray if needed */
|
|
|
|
wibox_systray_refresh(wibox);
|
|
|
|
}
|
2009-05-07 14:13:36 +02:00
|
|
|
|
2009-08-17 16:56:03 +02:00
|
|
|
luaA_object_emit_signal(L, udx, "property::visible", 0);
|
2008-09-24 12:13:21 +02:00
|
|
|
}
|
2008-09-21 11:47:29 +02:00
|
|
|
}
|
|
|
|
|
2008-09-24 12:13:21 +02:00
|
|
|
/** Remove a wibox from a screen.
|
2009-08-17 16:56:03 +02:00
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param udx Wibox to detach from screen.
|
2008-09-24 12:13:21 +02:00
|
|
|
*/
|
2009-05-05 17:32:53 +02:00
|
|
|
static void
|
2009-08-17 16:56:03 +02:00
|
|
|
wibox_detach(lua_State *L, int udx)
|
2008-09-24 12:13:21 +02:00
|
|
|
{
|
2009-08-17 16:56:03 +02:00
|
|
|
wibox_t *wibox = luaA_checkudata(L, udx, &wibox_class);
|
2009-05-05 17:32:53 +02:00
|
|
|
if(wibox->screen)
|
2008-09-24 12:13:21 +02:00
|
|
|
{
|
|
|
|
bool v;
|
|
|
|
|
|
|
|
/* save visible state */
|
2009-08-17 16:56:03 +02:00
|
|
|
v = wibox->visible;
|
|
|
|
wibox->visible = false;
|
2008-11-17 13:54:57 +01:00
|
|
|
wibox_systray_refresh(wibox);
|
2009-05-05 17:32:53 +02:00
|
|
|
/* restore visibility */
|
2009-08-17 16:56:03 +02:00
|
|
|
wibox->visible = v;
|
2008-09-24 12:13:21 +02:00
|
|
|
|
2009-11-21 10:54:44 +01:00
|
|
|
wibox_clear_mouse_over(wibox);
|
2008-12-18 16:58:15 +01:00
|
|
|
|
2009-10-02 15:48:32 +02:00
|
|
|
wibox_wipe_resources(wibox);
|
2008-09-24 12:13:21 +02:00
|
|
|
|
2009-05-10 14:55:13 +02:00
|
|
|
foreach(item, globalconf.wiboxes)
|
2009-04-11 00:27:06 +02:00
|
|
|
if(*item == wibox)
|
2008-09-24 12:13:21 +02:00
|
|
|
{
|
2009-05-10 14:55:13 +02:00
|
|
|
wibox_array_remove(&globalconf.wiboxes, item);
|
2008-09-24 12:13:21 +02:00
|
|
|
break;
|
|
|
|
}
|
2009-04-11 00:27:06 +02:00
|
|
|
|
2009-08-28 17:48:52 +02:00
|
|
|
if(strut_has_value(&wibox->strut))
|
|
|
|
screen_emit_signal(L, wibox->screen, "property::workarea", 0);
|
|
|
|
|
2009-04-17 16:14:09 +02:00
|
|
|
wibox->screen = NULL;
|
2009-08-17 16:56:03 +02:00
|
|
|
luaA_object_emit_signal(L, udx, "property::screen", 0);
|
2009-05-07 14:13:36 +02:00
|
|
|
|
2009-06-29 11:02:13 +02:00
|
|
|
luaA_object_unref(globalconf.L, wibox);
|
2008-09-24 12:13:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-11 00:27:06 +02:00
|
|
|
/** Attach a wibox that is on top of the stack.
|
2009-08-25 04:55:10 +02:00
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param udx The wibox to attach.
|
2008-09-24 12:13:21 +02:00
|
|
|
* \param s The screen to attach the wibox to.
|
|
|
|
*/
|
2009-04-11 00:27:06 +02:00
|
|
|
static void
|
2009-08-17 16:56:03 +02:00
|
|
|
wibox_attach(lua_State *L, int udx, screen_t *s)
|
2008-09-24 12:13:21 +02:00
|
|
|
{
|
2009-08-17 16:56:03 +02:00
|
|
|
/* duplicate wibox */
|
|
|
|
lua_pushvalue(L, udx);
|
|
|
|
/* ref it */
|
2009-09-04 12:46:20 +02:00
|
|
|
wibox_t *wibox = luaA_object_ref_class(globalconf.L, -1, &wibox_class);
|
2009-04-11 00:27:06 +02:00
|
|
|
|
2009-08-17 16:56:03 +02:00
|
|
|
wibox_detach(L, udx);
|
2008-09-24 12:13:21 +02:00
|
|
|
|
2009-01-08 11:01:06 +01:00
|
|
|
/* Set the wibox screen */
|
2009-04-17 16:14:09 +02:00
|
|
|
wibox->screen = s;
|
2008-09-24 12:13:21 +02:00
|
|
|
|
2009-01-08 11:01:06 +01:00
|
|
|
/* Check that the wibox coordinates matches the screen. */
|
2009-04-17 16:14:09 +02:00
|
|
|
screen_t *cscreen =
|
2010-08-16 14:25:12 +02:00
|
|
|
screen_getbycoord(wibox->geometry.x, wibox->geometry.y);
|
2009-01-08 11:01:06 +01:00
|
|
|
|
|
|
|
/* If it does not match, move it to the screen coordinates */
|
|
|
|
if(cscreen != wibox->screen)
|
2009-08-17 16:56:03 +02:00
|
|
|
wibox_moveresize(L, udx, (area_t) { .x = s->geometry.x,
|
|
|
|
.y = s->geometry.y,
|
|
|
|
.width = wibox->geometry.width,
|
|
|
|
.height = wibox->geometry.height });
|
2009-01-08 11:01:06 +01:00
|
|
|
|
2009-05-10 14:55:13 +02:00
|
|
|
wibox_array_append(&globalconf.wiboxes, wibox);
|
2008-09-24 12:13:21 +02:00
|
|
|
|
2010-08-16 13:47:40 +02:00
|
|
|
wibox_init(wibox);
|
2008-09-24 12:13:21 +02:00
|
|
|
|
2009-09-17 17:51:06 +02:00
|
|
|
xwindow_set_cursor(wibox->window,
|
2009-08-05 15:56:00 +02:00
|
|
|
xcursor_new(globalconf.connection, xcursor_font_fromstr(wibox->cursor)));
|
2009-05-25 15:26:16 +02:00
|
|
|
|
2009-08-17 16:56:03 +02:00
|
|
|
if(wibox->opacity != -1)
|
2009-09-17 17:51:06 +02:00
|
|
|
xwindow_set_opacity(wibox->window, wibox->opacity);
|
2009-05-25 15:26:16 +02:00
|
|
|
|
2009-08-18 14:23:41 +02:00
|
|
|
ewmh_update_strut(wibox->window, &wibox->strut);
|
|
|
|
|
2009-08-17 16:56:03 +02:00
|
|
|
if(wibox->visible)
|
2009-04-11 13:14:50 +02:00
|
|
|
wibox_map(wibox);
|
2008-10-24 11:57:01 +02:00
|
|
|
else
|
2009-04-07 18:25:37 +02:00
|
|
|
wibox_need_update(wibox);
|
2009-05-07 14:13:36 +02:00
|
|
|
|
2009-08-17 16:56:03 +02:00
|
|
|
luaA_object_emit_signal(L, udx, "property::screen", 0);
|
2009-08-28 17:48:52 +02:00
|
|
|
|
|
|
|
if(strut_has_value(&wibox->strut))
|
|
|
|
screen_emit_signal(L, wibox->screen, "property::workarea", 0);
|
2008-09-24 12:13:21 +02:00
|
|
|
}
|
|
|
|
|
2009-10-06 19:04:36 +02:00
|
|
|
static int
|
|
|
|
luaA_wibox_need_update(lua_State *L)
|
|
|
|
{
|
|
|
|
wibox_need_update(luaA_checkudata(L, 1, &wibox_class));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-09-21 20:39:23 +02:00
|
|
|
/** Create a new wibox.
|
|
|
|
* \param L The Lua VM state.
|
2009-10-02 16:42:31 +02:00
|
|
|
* \return The number of elements pushed on stack.
|
2008-09-21 20:39:23 +02:00
|
|
|
*/
|
2009-04-11 00:27:06 +02:00
|
|
|
static int
|
2008-09-21 20:39:23 +02:00
|
|
|
luaA_wibox_new(lua_State *L)
|
|
|
|
{
|
2009-08-17 16:56:03 +02:00
|
|
|
luaA_class_new(L, &wibox_class);
|
2008-09-21 20:39:23 +02:00
|
|
|
|
2009-08-17 16:56:03 +02:00
|
|
|
wibox_t *w = luaA_checkudata(L, -1, &wibox_class);
|
2008-09-21 20:39:23 +02:00
|
|
|
|
2009-08-17 16:56:03 +02:00
|
|
|
if(!w->ctx.fg.initialized)
|
|
|
|
w->ctx.fg = globalconf.colors.fg;
|
2008-09-21 20:39:23 +02:00
|
|
|
|
2009-08-17 16:56:03 +02:00
|
|
|
if(!w->ctx.bg.initialized)
|
|
|
|
w->ctx.bg = globalconf.colors.bg;
|
2008-09-21 20:39:23 +02:00
|
|
|
|
2009-08-17 16:56:03 +02:00
|
|
|
w->visible = true;
|
2008-09-21 20:39:23 +02:00
|
|
|
|
2009-08-17 16:56:03 +02:00
|
|
|
if(!w->opacity)
|
|
|
|
w->opacity = -1;
|
2009-01-14 11:28:13 +01:00
|
|
|
|
2009-08-17 16:56:03 +02:00
|
|
|
if(!w->cursor)
|
|
|
|
w->cursor = a_strdup("left_ptr");
|
2008-09-21 20:39:23 +02:00
|
|
|
|
2009-08-17 16:56:03 +02:00
|
|
|
if(!w->geometry.width)
|
|
|
|
w->geometry.width = 1;
|
2008-09-21 20:39:23 +02:00
|
|
|
|
2009-08-17 16:56:03 +02:00
|
|
|
if(!w->geometry.height)
|
|
|
|
w->geometry.height = 1;
|
2008-09-21 20:39:23 +02:00
|
|
|
|
2010-09-27 22:03:34 +02:00
|
|
|
if(w->type == 0)
|
|
|
|
w->type = _NET_WM_WINDOW_TYPE_NORMAL;
|
|
|
|
|
2009-10-09 20:39:55 +02:00
|
|
|
luaA_object_connect_signal(L, -2, "property::border_width", luaA_wibox_need_update);
|
2009-10-06 19:04:36 +02:00
|
|
|
|
2009-04-11 00:27:06 +02:00
|
|
|
return 1;
|
2008-09-21 20:39:23 +02:00
|
|
|
}
|
|
|
|
|
2008-10-19 19:14:55 +02:00
|
|
|
/** Check if a wibox widget table has an item.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param wibox The wibox.
|
|
|
|
* \param item The item to look for.
|
|
|
|
*/
|
|
|
|
static bool
|
|
|
|
luaA_wibox_hasitem(lua_State *L, wibox_t *wibox, const void *item)
|
|
|
|
{
|
2009-07-28 10:29:30 +02:00
|
|
|
if(wibox->widgets_table)
|
2008-10-21 10:35:23 +02:00
|
|
|
{
|
2009-06-29 11:02:13 +02:00
|
|
|
luaA_object_push(L, wibox);
|
2009-07-28 10:29:30 +02:00
|
|
|
luaA_object_push_item(L, -1, wibox->widgets_table);
|
|
|
|
lua_remove(L, -2);
|
2008-10-21 10:35:23 +02:00
|
|
|
if(lua_topointer(L, -1) == item || luaA_hasitem(L, item))
|
2008-12-09 16:45:02 +01:00
|
|
|
return true;
|
2008-10-21 10:35:23 +02:00
|
|
|
}
|
2008-12-09 16:45:02 +01:00
|
|
|
return false;
|
2008-10-19 19:14:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Invalidate a wibox by a Lua object (table, etc).
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param item The object identifier.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
luaA_wibox_invalidate_byitem(lua_State *L, const void *item)
|
|
|
|
{
|
2009-05-10 14:55:13 +02:00
|
|
|
foreach(w, globalconf.wiboxes)
|
|
|
|
{
|
|
|
|
wibox_t *wibox = *w;
|
|
|
|
if(luaA_wibox_hasitem(L, wibox, item))
|
2008-10-19 19:14:55 +02:00
|
|
|
{
|
2009-01-16 11:10:27 +01:00
|
|
|
/* update wibox */
|
|
|
|
wibox_need_update(wibox);
|
2009-05-10 14:55:13 +02:00
|
|
|
lua_pop(L, 1); /* remove widgets table */
|
2008-10-19 19:14:55 +02:00
|
|
|
}
|
|
|
|
|
2009-05-10 14:55:13 +02:00
|
|
|
}
|
2008-10-19 19:14:55 +02:00
|
|
|
}
|
|
|
|
|
2008-09-24 12:13:21 +02:00
|
|
|
/* Set or get the wibox geometry.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \return The number of elements pushed on stack.
|
|
|
|
* \luastack
|
|
|
|
* \lparam An optional table with wibox geometry.
|
|
|
|
* \lreturn The wibox geometry.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_wibox_geometry(lua_State *L)
|
|
|
|
{
|
2009-08-17 15:52:41 +02:00
|
|
|
wibox_t *wibox = luaA_checkudata(L, 1, &wibox_class);
|
2008-09-24 12:13:21 +02:00
|
|
|
|
|
|
|
if(lua_gettop(L) == 2)
|
|
|
|
{
|
|
|
|
area_t wingeom;
|
|
|
|
|
|
|
|
luaA_checktable(L, 2);
|
2009-07-28 16:04:58 +02:00
|
|
|
wingeom.x = luaA_getopt_number(L, 2, "x", wibox->geometry.x);
|
|
|
|
wingeom.y = luaA_getopt_number(L, 2, "y", wibox->geometry.y);
|
|
|
|
wingeom.width = luaA_getopt_number(L, 2, "width", wibox->geometry.width);
|
|
|
|
wingeom.height = luaA_getopt_number(L, 2, "height", wibox->geometry.height);
|
2008-09-24 12:13:21 +02:00
|
|
|
|
2009-08-17 16:56:03 +02:00
|
|
|
if(wingeom.width > 0 && wingeom.height > 0)
|
2009-09-17 15:05:53 +02:00
|
|
|
wibox_moveresize(L, 1, wingeom);
|
2008-09-24 12:13:21 +02:00
|
|
|
}
|
|
|
|
|
2009-07-28 16:04:58 +02:00
|
|
|
return luaA_pusharea(L, wibox->geometry);
|
2008-09-24 12:13:21 +02:00
|
|
|
}
|
|
|
|
|
2009-08-17 16:56:03 +02:00
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, ontop, lua_pushboolean)
|
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, cursor, lua_pushstring)
|
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, visible, lua_pushboolean)
|
|
|
|
|
|
|
|
static int
|
|
|
|
luaA_wibox_set_x(lua_State *L, wibox_t *wibox)
|
|
|
|
{
|
|
|
|
wibox_moveresize(L, -3, (area_t) { .x = luaL_checknumber(L, -1),
|
|
|
|
.y = wibox->geometry.y,
|
|
|
|
.width = wibox->geometry.width,
|
|
|
|
.height = wibox->geometry.height });
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
luaA_wibox_get_x(lua_State *L, wibox_t *wibox)
|
|
|
|
{
|
|
|
|
lua_pushnumber(L, wibox->geometry.x);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
luaA_wibox_set_y(lua_State *L, wibox_t *wibox)
|
|
|
|
{
|
|
|
|
wibox_moveresize(L, -3, (area_t) { .x = wibox->geometry.x,
|
|
|
|
.y = luaL_checknumber(L, -1),
|
|
|
|
.width = wibox->geometry.width,
|
|
|
|
.height = wibox->geometry.height });
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
luaA_wibox_get_y(lua_State *L, wibox_t *wibox)
|
|
|
|
{
|
|
|
|
lua_pushnumber(L, wibox->geometry.y);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
luaA_wibox_set_width(lua_State *L, wibox_t *wibox)
|
|
|
|
{
|
|
|
|
int width = luaL_checknumber(L, -1);
|
|
|
|
if(width <= 0)
|
|
|
|
luaL_error(L, "invalid width");
|
|
|
|
wibox_moveresize(L, -3, (area_t) { .x = wibox->geometry.x,
|
|
|
|
.y = wibox->geometry.y,
|
|
|
|
.width = width,
|
|
|
|
.height = wibox->geometry.height });
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
luaA_wibox_get_width(lua_State *L, wibox_t *wibox)
|
|
|
|
{
|
|
|
|
lua_pushnumber(L, wibox->geometry.width);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
luaA_wibox_set_height(lua_State *L, wibox_t *wibox)
|
|
|
|
{
|
|
|
|
int height = luaL_checknumber(L, -1);
|
|
|
|
if(height <= 0)
|
|
|
|
luaL_error(L, "invalid height");
|
|
|
|
wibox_moveresize(L, -3, (area_t) { .x = wibox->geometry.x,
|
|
|
|
.y = wibox->geometry.y,
|
|
|
|
.width = wibox->geometry.width,
|
|
|
|
.height = height });
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
luaA_wibox_get_height(lua_State *L, wibox_t *wibox)
|
|
|
|
{
|
|
|
|
lua_pushnumber(L, wibox->geometry.height);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set the wibox foreground color.
|
2008-09-21 20:39:23 +02:00
|
|
|
* \param L The Lua VM state.
|
2009-08-17 16:56:03 +02:00
|
|
|
* \param wibox The wibox object.
|
2008-09-21 20:39:23 +02:00
|
|
|
* \return The number of elements pushed on stack.
|
|
|
|
*/
|
|
|
|
static int
|
2009-08-17 16:56:03 +02:00
|
|
|
luaA_wibox_set_fg(lua_State *L, wibox_t *wibox)
|
2008-09-21 20:39:23 +02:00
|
|
|
{
|
|
|
|
size_t len;
|
2009-08-17 16:56:03 +02:00
|
|
|
const char *buf = luaL_checklstring(L, -1, &len);
|
|
|
|
if(xcolor_init_reply(xcolor_init_unchecked(&wibox->ctx.fg, buf, len)))
|
|
|
|
wibox->need_update = true;
|
|
|
|
luaA_object_emit_signal(L, -3, "property::fg", 0);
|
|
|
|
return 0;
|
|
|
|
}
|
2008-09-21 20:39:23 +02:00
|
|
|
|
2009-08-17 16:56:03 +02:00
|
|
|
/** Get the wibox foreground color.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param wibox The wibox object.
|
|
|
|
* \return The number of elements pushed on stack.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_wibox_get_fg(lua_State *L, wibox_t *wibox)
|
|
|
|
{
|
|
|
|
return luaA_pushxcolor(L, wibox->ctx.fg);
|
|
|
|
}
|
2008-09-22 19:23:28 +02:00
|
|
|
|
2009-08-17 16:56:03 +02:00
|
|
|
/** Set the wibox background color.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param wibox The wibox object.
|
|
|
|
* \return The number of elements pushed on stack.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_wibox_set_bg(lua_State *L, wibox_t *wibox)
|
|
|
|
{
|
|
|
|
size_t len;
|
|
|
|
const char *buf = luaL_checklstring(L, -1, &len);
|
|
|
|
if(xcolor_init_reply(xcolor_init_unchecked(&wibox->ctx.bg, buf, len)))
|
2009-11-07 20:02:22 +01:00
|
|
|
{
|
|
|
|
uint32_t mask = XCB_CW_BACK_PIXEL;
|
|
|
|
uint32_t values[] = { wibox->ctx.bg.pixel };
|
|
|
|
|
2009-04-11 00:27:06 +02:00
|
|
|
wibox->need_update = true;
|
2009-11-08 11:03:56 +01:00
|
|
|
|
|
|
|
if (wibox->window != XCB_NONE)
|
|
|
|
xcb_change_window_attributes(globalconf.connection,
|
|
|
|
wibox->window,
|
|
|
|
mask,
|
|
|
|
values);
|
2009-11-07 20:02:22 +01:00
|
|
|
}
|
2009-08-17 16:56:03 +02:00
|
|
|
luaA_object_emit_signal(L, -3, "property::bg", 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Get the wibox background color.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param wibox The wibox object.
|
|
|
|
* \return The number of elements pushed on stack.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_wibox_get_bg(lua_State *L, wibox_t *wibox)
|
|
|
|
{
|
|
|
|
return luaA_pushxcolor(L, wibox->ctx.bg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set the wibox background image.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param wibox The wibox object.
|
|
|
|
* \return The number of elements pushed on stack.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_wibox_set_bg_image(lua_State *L, wibox_t *wibox)
|
|
|
|
{
|
2010-08-20 14:18:20 +02:00
|
|
|
if(lua_isnil(L, -1))
|
|
|
|
{
|
|
|
|
if(wibox->bg_image)
|
|
|
|
cairo_surface_destroy(wibox->bg_image);
|
|
|
|
wibox->bg_image = NULL;
|
|
|
|
} else {
|
2010-09-29 19:35:59 +02:00
|
|
|
cairo_surface_t **cairo_surface = (cairo_surface_t **)luaL_checkudata(L, -1, OOCAIRO_MT_NAME_SURFACE);
|
2010-08-20 14:18:20 +02:00
|
|
|
if(wibox->bg_image)
|
|
|
|
cairo_surface_destroy(wibox->bg_image);
|
2010-09-29 19:35:59 +02:00
|
|
|
wibox->bg_image = draw_dup_image_surface(*cairo_surface);
|
2010-08-20 14:18:20 +02:00
|
|
|
}
|
2009-08-17 16:56:03 +02:00
|
|
|
wibox->need_update = true;
|
2010-08-20 14:18:20 +02:00
|
|
|
luaA_object_emit_signal(L, -3, "property::bg_image", 0);
|
2009-08-17 16:56:03 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Get the wibox background image.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param wibox The wibox object.
|
|
|
|
* \return The number of elements pushed on stack.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_wibox_get_bg_image(lua_State *L, wibox_t *wibox)
|
|
|
|
{
|
2010-08-20 14:18:20 +02:00
|
|
|
if(wibox->bg_image)
|
|
|
|
return oocairo_surface_push(L, wibox->bg_image);
|
|
|
|
return 0;
|
2009-08-17 16:56:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Set the wibox on top status.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param wibox The wibox object.
|
|
|
|
* \return The number of elements pushed on stack.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_wibox_set_ontop(lua_State *L, wibox_t *wibox)
|
|
|
|
{
|
|
|
|
bool b = luaA_checkboolean(L, -1);
|
|
|
|
if(b != wibox->ontop)
|
|
|
|
{
|
|
|
|
wibox->ontop = b;
|
2009-10-05 20:36:02 +02:00
|
|
|
stack_windows();
|
2009-08-17 16:56:03 +02:00
|
|
|
luaA_object_emit_signal(L, -3, "property::ontop", 0);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set the wibox cursor.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param wibox The wibox object.
|
|
|
|
* \return The number of elements pushed on stack.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_wibox_set_cursor(lua_State *L, wibox_t *wibox)
|
|
|
|
{
|
|
|
|
const char *buf = luaL_checkstring(L, -1);
|
|
|
|
if(buf)
|
|
|
|
{
|
|
|
|
uint16_t cursor_font = xcursor_font_fromstr(buf);
|
|
|
|
if(cursor_font)
|
2008-11-13 11:04:07 +01:00
|
|
|
{
|
2009-08-17 16:56:03 +02:00
|
|
|
xcb_cursor_t cursor = xcursor_new(globalconf.connection, cursor_font);
|
|
|
|
p_delete(&wibox->cursor);
|
|
|
|
wibox->cursor = a_strdup(buf);
|
2009-09-17 17:51:06 +02:00
|
|
|
xwindow_set_cursor(wibox->window, cursor);
|
2009-08-17 16:56:03 +02:00
|
|
|
luaA_object_emit_signal(L, -3, "property::cursor", 0);
|
2008-11-13 11:04:07 +01:00
|
|
|
}
|
2009-08-17 16:56:03 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set the wibox screen.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param wibox The wibox object.
|
|
|
|
* \return The number of elements pushed on stack.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_wibox_set_screen(lua_State *L, wibox_t *wibox)
|
|
|
|
{
|
|
|
|
if(lua_isnil(L, -1))
|
|
|
|
wibox_detach(L, -3);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int screen = luaL_checknumber(L, -1) - 1;
|
|
|
|
luaA_checkscreen(screen);
|
|
|
|
if(!wibox->screen || screen != screen_array_indexof(&globalconf.screens, wibox->screen))
|
|
|
|
wibox_attach(L, -3, &globalconf.screens.tab[screen]);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Get the wibox screen.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param wibox The wibox object.
|
|
|
|
* \return The number of elements pushed on stack.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_wibox_get_screen(lua_State *L, wibox_t *wibox)
|
|
|
|
{
|
|
|
|
if(!wibox->screen)
|
2009-02-13 21:19:14 +01:00
|
|
|
return 0;
|
2009-08-17 16:56:03 +02:00
|
|
|
lua_pushnumber(L, screen_array_indexof(&globalconf.screens, wibox->screen) + 1);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set the wibox orientation.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param wibox The wibox object.
|
|
|
|
* \return The number of elements pushed on stack.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_wibox_set_orientation(lua_State *L, wibox_t *wibox)
|
|
|
|
{
|
2010-09-02 19:00:31 +02:00
|
|
|
const char *buf = luaL_checkstring(L, -1);
|
2009-08-17 16:56:03 +02:00
|
|
|
if(buf)
|
|
|
|
{
|
2010-09-02 19:00:31 +02:00
|
|
|
wibox_set_orientation(L, -3, orientation_fromstr(buf));
|
2009-08-17 16:56:03 +02:00
|
|
|
wibox_need_update(wibox);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Get the wibox orientation.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param wibox The wibox object.
|
|
|
|
* \return The number of elements pushed on stack.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_wibox_get_orientation(lua_State *L, wibox_t *wibox)
|
|
|
|
{
|
|
|
|
lua_pushstring(L, orientation_tostr(wibox->orientation));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set the wibox visibility.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param wibox The wibox object.
|
|
|
|
* \return The number of elements pushed on stack.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_wibox_set_visible(lua_State *L, wibox_t *wibox)
|
|
|
|
{
|
2009-09-17 15:05:53 +02:00
|
|
|
wibox_set_visible(L, -3, luaA_checkboolean(L, -1));
|
2009-08-17 16:56:03 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2008-09-21 20:39:23 +02:00
|
|
|
|
2009-08-17 16:56:03 +02:00
|
|
|
/** Set the wibox widgets.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param wibox The wibox object.
|
|
|
|
* \return The number of elements pushed on stack.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_wibox_set_widgets(lua_State *L, wibox_t *wibox)
|
|
|
|
{
|
|
|
|
if(luaA_isloop(L, -1))
|
|
|
|
{
|
|
|
|
luaA_warn(L, "table is looping, cannot use this as widget table");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* duplicate table because next function will eat it */
|
|
|
|
lua_pushvalue(L, -1);
|
2010-09-16 18:27:04 +02:00
|
|
|
luaA_object_unref_item(L, -4, wibox->widgets_table);
|
2009-08-17 16:56:03 +02:00
|
|
|
wibox->widgets_table = luaA_object_ref_item(L, -4, -1);
|
|
|
|
luaA_object_emit_signal(L, -3, "property::widgets", 0);
|
|
|
|
wibox_need_update(wibox);
|
|
|
|
luaA_table2wtable(L);
|
2008-09-21 20:39:23 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-17 16:56:03 +02:00
|
|
|
/** Get the wibox widgets.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param wibox The wibox object.
|
|
|
|
* \return The number of elements pushed on stack.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_wibox_get_widgets(lua_State *L, wibox_t *wibox)
|
|
|
|
{
|
|
|
|
return luaA_object_push_item(L, 1, wibox->widgets_table);
|
|
|
|
}
|
|
|
|
void
|
|
|
|
wibox_class_setup(lua_State *L)
|
|
|
|
{
|
|
|
|
static const struct luaL_reg wibox_methods[] =
|
|
|
|
{
|
|
|
|
LUA_CLASS_METHODS(wibox)
|
|
|
|
{ "__call", luaA_wibox_new },
|
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct luaL_reg wibox_meta[] =
|
|
|
|
{
|
|
|
|
LUA_OBJECT_META(wibox)
|
|
|
|
LUA_CLASS_META
|
|
|
|
{ "geometry", luaA_wibox_geometry },
|
|
|
|
{ NULL, NULL },
|
|
|
|
};
|
|
|
|
|
2009-09-30 16:04:42 +02:00
|
|
|
luaA_class_setup(L, &wibox_class, "wibox", &window_class,
|
2009-10-02 15:48:32 +02:00
|
|
|
(lua_class_allocator_t) wibox_new,
|
|
|
|
(lua_class_collector_t) wibox_wipe,
|
|
|
|
NULL,
|
2009-08-20 17:37:46 +02:00
|
|
|
luaA_class_index_miss_property, luaA_class_newindex_miss_property,
|
2009-08-17 16:56:03 +02:00
|
|
|
wibox_methods, wibox_meta);
|
2010-09-01 15:41:41 +02:00
|
|
|
luaA_class_add_property(&wibox_class, "widgets",
|
2009-08-17 16:56:03 +02:00
|
|
|
(lua_class_propfunc_t) luaA_wibox_set_widgets,
|
|
|
|
(lua_class_propfunc_t) luaA_wibox_get_widgets,
|
|
|
|
(lua_class_propfunc_t) luaA_wibox_set_widgets);
|
2010-09-01 15:41:41 +02:00
|
|
|
luaA_class_add_property(&wibox_class, "visible",
|
2009-08-17 16:56:03 +02:00
|
|
|
(lua_class_propfunc_t) luaA_wibox_set_visible,
|
|
|
|
(lua_class_propfunc_t) luaA_wibox_get_visible,
|
|
|
|
(lua_class_propfunc_t) luaA_wibox_set_visible);
|
2010-09-01 15:41:41 +02:00
|
|
|
luaA_class_add_property(&wibox_class, "orientation",
|
2009-08-17 16:56:03 +02:00
|
|
|
(lua_class_propfunc_t) luaA_wibox_set_orientation,
|
|
|
|
(lua_class_propfunc_t) luaA_wibox_get_orientation,
|
|
|
|
(lua_class_propfunc_t) luaA_wibox_set_orientation);
|
2010-09-01 15:41:41 +02:00
|
|
|
luaA_class_add_property(&wibox_class, "ontop",
|
2009-08-17 16:56:03 +02:00
|
|
|
(lua_class_propfunc_t) luaA_wibox_set_ontop,
|
|
|
|
(lua_class_propfunc_t) luaA_wibox_get_ontop,
|
|
|
|
(lua_class_propfunc_t) luaA_wibox_set_ontop);
|
2010-09-01 15:41:41 +02:00
|
|
|
luaA_class_add_property(&wibox_class, "screen",
|
2009-08-17 16:56:03 +02:00
|
|
|
NULL,
|
|
|
|
(lua_class_propfunc_t) luaA_wibox_get_screen,
|
|
|
|
(lua_class_propfunc_t) luaA_wibox_set_screen);
|
2010-09-01 15:41:41 +02:00
|
|
|
luaA_class_add_property(&wibox_class, "cursor",
|
2009-08-17 16:56:03 +02:00
|
|
|
(lua_class_propfunc_t) luaA_wibox_set_cursor,
|
|
|
|
(lua_class_propfunc_t) luaA_wibox_get_cursor,
|
|
|
|
(lua_class_propfunc_t) luaA_wibox_set_cursor);
|
2010-09-01 15:41:41 +02:00
|
|
|
luaA_class_add_property(&wibox_class, "fg",
|
2009-08-17 16:56:03 +02:00
|
|
|
(lua_class_propfunc_t) luaA_wibox_set_fg,
|
|
|
|
(lua_class_propfunc_t) luaA_wibox_get_fg,
|
|
|
|
(lua_class_propfunc_t) luaA_wibox_set_fg);
|
2010-09-01 15:41:41 +02:00
|
|
|
luaA_class_add_property(&wibox_class, "bg",
|
2009-08-17 16:56:03 +02:00
|
|
|
(lua_class_propfunc_t) luaA_wibox_set_bg,
|
|
|
|
(lua_class_propfunc_t) luaA_wibox_get_bg,
|
|
|
|
(lua_class_propfunc_t) luaA_wibox_set_bg);
|
2010-09-01 15:41:41 +02:00
|
|
|
luaA_class_add_property(&wibox_class, "bg_image",
|
2009-08-17 16:56:03 +02:00
|
|
|
(lua_class_propfunc_t) luaA_wibox_set_bg_image,
|
|
|
|
(lua_class_propfunc_t) luaA_wibox_get_bg_image,
|
|
|
|
(lua_class_propfunc_t) luaA_wibox_set_bg_image);
|
2010-09-01 15:41:41 +02:00
|
|
|
luaA_class_add_property(&wibox_class, "x",
|
2009-08-17 16:56:03 +02:00
|
|
|
(lua_class_propfunc_t) luaA_wibox_set_x,
|
|
|
|
(lua_class_propfunc_t) luaA_wibox_get_x,
|
|
|
|
(lua_class_propfunc_t) luaA_wibox_set_x);
|
2010-09-01 15:41:41 +02:00
|
|
|
luaA_class_add_property(&wibox_class, "y",
|
2009-08-17 16:56:03 +02:00
|
|
|
(lua_class_propfunc_t) luaA_wibox_set_y,
|
|
|
|
(lua_class_propfunc_t) luaA_wibox_get_y,
|
|
|
|
(lua_class_propfunc_t) luaA_wibox_set_y);
|
2010-09-01 15:41:41 +02:00
|
|
|
luaA_class_add_property(&wibox_class, "width",
|
2009-08-17 16:56:03 +02:00
|
|
|
(lua_class_propfunc_t) luaA_wibox_set_width,
|
|
|
|
(lua_class_propfunc_t) luaA_wibox_get_width,
|
|
|
|
(lua_class_propfunc_t) luaA_wibox_set_width);
|
2010-09-01 15:41:41 +02:00
|
|
|
luaA_class_add_property(&wibox_class, "height",
|
2009-08-17 16:56:03 +02:00
|
|
|
(lua_class_propfunc_t) luaA_wibox_set_height,
|
|
|
|
(lua_class_propfunc_t) luaA_wibox_get_height,
|
|
|
|
(lua_class_propfunc_t) luaA_wibox_set_height);
|
2010-09-27 22:03:34 +02:00
|
|
|
luaA_class_add_property(&wibox_class, "type",
|
|
|
|
(lua_class_propfunc_t) luaA_window_set_type,
|
|
|
|
(lua_class_propfunc_t) luaA_window_get_type,
|
|
|
|
(lua_class_propfunc_t) luaA_window_set_type);
|
2010-08-25 23:00:36 +02:00
|
|
|
|
2010-08-26 17:46:17 +02:00
|
|
|
signal_add(&wibox_class.signals, "mouse::enter");
|
|
|
|
signal_add(&wibox_class.signals, "mouse::leave");
|
2010-08-25 23:00:36 +02:00
|
|
|
signal_add(&wibox_class.signals, "property::bg");
|
2010-08-26 17:43:24 +02:00
|
|
|
signal_add(&wibox_class.signals, "property::bg_image");
|
2010-08-26 17:46:17 +02:00
|
|
|
signal_add(&wibox_class.signals, "property::border_width");
|
|
|
|
signal_add(&wibox_class.signals, "property::cursor");
|
|
|
|
signal_add(&wibox_class.signals, "property::fg");
|
2010-08-25 23:00:36 +02:00
|
|
|
signal_add(&wibox_class.signals, "property::height");
|
|
|
|
signal_add(&wibox_class.signals, "property::ontop");
|
2010-08-26 17:43:24 +02:00
|
|
|
signal_add(&wibox_class.signals, "property::orientation");
|
2010-08-26 17:46:17 +02:00
|
|
|
signal_add(&wibox_class.signals, "property::screen");
|
|
|
|
signal_add(&wibox_class.signals, "property::visible");
|
|
|
|
signal_add(&wibox_class.signals, "property::widgets");
|
|
|
|
signal_add(&wibox_class.signals, "property::width");
|
|
|
|
signal_add(&wibox_class.signals, "property::x");
|
|
|
|
signal_add(&wibox_class.signals, "property::y");
|
2009-08-17 16:56:03 +02:00
|
|
|
}
|
2008-09-21 20:39:23 +02:00
|
|
|
|
2008-09-21 10:13:21 +02:00
|
|
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|