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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-07-28 16:04:58 +02:00
|
|
|
#include <xcb/shape.h>
|
|
|
|
|
2008-09-21 20:39:23 +02:00
|
|
|
#include "screen.h"
|
2008-09-21 11:47:29 +02:00
|
|
|
#include "wibox.h"
|
|
|
|
#include "titlebar.h"
|
2008-09-21 20:39:23 +02:00
|
|
|
#include "client.h"
|
2009-01-08 11:01:06 +01:00
|
|
|
#include "screen.h"
|
2009-01-24 23:48:05 +01:00
|
|
|
#include "window.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-04-11 00:27:06 +02:00
|
|
|
DO_LUA_TOSTRING(wibox_t, wibox, "wibox")
|
|
|
|
|
|
|
|
/** Take care of garbage collecting a wibox.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \return The number of elements pushed on stack, 0!
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_wibox_gc(lua_State *L)
|
|
|
|
{
|
|
|
|
wibox_t *wibox = luaL_checkudata(L, 1, "wibox");
|
2009-04-13 12:40:33 +02:00
|
|
|
p_delete(&wibox->cursor);
|
2009-07-28 16:04:58 +02:00
|
|
|
wibox_wipe(wibox);
|
2009-04-11 00:27:06 +02:00
|
|
|
widget_node_array_wipe(&wibox->widgets);
|
2009-06-16 16:24:58 +02:00
|
|
|
return luaA_object_gc(L);
|
2009-04-11 00:27:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
wibox_unref_simplified(wibox_t **item)
|
|
|
|
{
|
|
|
|
wibox_unref(globalconf.L, *item);
|
|
|
|
}
|
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;
|
|
|
|
wibox->mouse_over = NULL;
|
|
|
|
}
|
|
|
|
|
2009-07-28 16:04:58 +02:00
|
|
|
static int
|
|
|
|
have_shape(void)
|
|
|
|
{
|
|
|
|
const xcb_query_extension_reply_t *reply;
|
|
|
|
|
|
|
|
reply = xcb_get_extension_data(globalconf.connection, &xcb_shape_id);
|
|
|
|
if (!reply || !reply->present)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* We don't need a specific version of SHAPE, no version check required */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
shape_update(xcb_window_t win, xcb_shape_kind_t kind, image_t *image, int offset)
|
|
|
|
{
|
|
|
|
xcb_pixmap_t shape;
|
|
|
|
|
|
|
|
if(image)
|
|
|
|
shape = image_to_1bit_pixmap(image, win);
|
|
|
|
else
|
|
|
|
/* Reset the shape */
|
|
|
|
shape = XCB_NONE;
|
|
|
|
|
|
|
|
xcb_shape_mask(globalconf.connection, XCB_SHAPE_SO_SET, kind,
|
|
|
|
win, offset, offset, shape);
|
|
|
|
|
|
|
|
if (shape != XCB_NONE)
|
|
|
|
xcb_free_pixmap(globalconf.connection, shape);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Update the window's shape.
|
|
|
|
* \param wibox The simplw window whose shape should be updated.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
wibox_shape_update(wibox_t *wibox)
|
|
|
|
{
|
|
|
|
if(wibox->window == XCB_NONE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if(!have_shape())
|
|
|
|
{
|
|
|
|
static bool warned = false;
|
|
|
|
if(!warned)
|
|
|
|
warn("The X server doesn't have the SHAPE extension; "
|
|
|
|
"can't change window's shape");
|
|
|
|
warned = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
shape_update(wibox->window, XCB_SHAPE_SK_CLIP, wibox->shape.clip, 0);
|
|
|
|
shape_update(wibox->window, XCB_SHAPE_SK_BOUNDING, wibox->shape.bounding, - wibox->border.width);
|
|
|
|
|
|
|
|
wibox->need_shape_update = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wibox_draw_context_update(wibox_t *w, xcb_screen_t *s)
|
|
|
|
{
|
|
|
|
xcolor_t fg = w->ctx.fg, bg = w->ctx.bg;
|
|
|
|
int phys_screen = w->ctx.phys_screen;
|
|
|
|
|
|
|
|
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,
|
|
|
|
s->root_depth,
|
|
|
|
w->ctx.pixmap, s->root,
|
2009-07-29 11:04:59 +02:00
|
|
|
w->geometry.height,
|
|
|
|
w->geometry.width);
|
2009-07-28 16:04:58 +02:00
|
|
|
draw_context_init(&w->ctx, phys_screen,
|
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:
|
|
|
|
draw_context_init(&w->ctx, phys_screen,
|
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.
|
|
|
|
* \param phys_screen Physical screen number.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
wibox_init(wibox_t *w, int phys_screen)
|
|
|
|
{
|
|
|
|
xcb_screen_t *s = xutil_screen_get(globalconf.connection, phys_screen);
|
|
|
|
|
|
|
|
w->window = xcb_generate_id(globalconf.connection);
|
|
|
|
xcb_create_window(globalconf.connection, s->root_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,
|
2009-07-28 16:04:58 +02:00
|
|
|
w->border.width, XCB_COPY_FROM_PARENT, s->root_visual,
|
|
|
|
XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL
|
|
|
|
| XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK,
|
|
|
|
(const uint32_t [])
|
|
|
|
{
|
|
|
|
XCB_BACK_PIXMAP_PARENT_RELATIVE,
|
|
|
|
w->border.color.pixel,
|
|
|
|
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_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE
|
|
|
|
| XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE
|
|
|
|
| XCB_EVENT_MASK_PROPERTY_CHANGE
|
|
|
|
});
|
|
|
|
|
|
|
|
/* Create a pixmap. */
|
|
|
|
w->pixmap = xcb_generate_id(globalconf.connection);
|
|
|
|
xcb_create_pixmap(globalconf.connection, s->root_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. */
|
|
|
|
w->ctx.phys_screen = phys_screen;
|
|
|
|
wibox_draw_context_update(w, s);
|
|
|
|
|
|
|
|
/* The default GC is just a newly created associated to the root window */
|
|
|
|
w->gc = xcb_generate_id(globalconf.connection);
|
|
|
|
xcb_create_gc(globalconf.connection, w->gc, s->root, XCB_GC_FOREGROUND | XCB_GC_BACKGROUND,
|
|
|
|
(const uint32_t[]) { s->black_pixel, s->white_pixel });
|
|
|
|
|
|
|
|
wibox_shape_update(w);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set a wibox opacity.
|
|
|
|
* \param w The wibox the adjust the opacity of.
|
|
|
|
* \param opacity A value between 0 and 1 which describes the opacity.
|
|
|
|
*/
|
|
|
|
static inline void
|
|
|
|
wibox_opacity_set(wibox_t *w, double opacity)
|
|
|
|
{
|
|
|
|
w->opacity = opacity;
|
|
|
|
if(w->window != XCB_NONE)
|
|
|
|
window_opacity_set(w->window, opacity);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
wibox_moveresize(wibox_t *w, area_t geometry)
|
|
|
|
{
|
|
|
|
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);
|
2009-07-28 17:18:41 +02:00
|
|
|
xcb_screen_t *s = xutil_screen_get(globalconf.connection, w->ctx.phys_screen);
|
2009-07-29 11:04:59 +02:00
|
|
|
xcb_create_pixmap(globalconf.connection, s->root_depth, w->pixmap, s->root,
|
|
|
|
w->geometry.width, w->geometry.height);
|
2009-07-28 16:04:58 +02:00
|
|
|
wibox_draw_context_update(w, s);
|
|
|
|
}
|
|
|
|
|
2009-07-28 17:18:41 +02:00
|
|
|
if(mask_vals)
|
|
|
|
xcb_configure_window(globalconf.connection, w->window, mask_vals, moveresize_win_vals);
|
2009-07-28 16:04:58 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
w->geometry = geometry;
|
|
|
|
|
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,
|
|
|
|
wibox->window, wibox->gc, x, y, x, y,
|
|
|
|
w, h);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set a wibox border width.
|
|
|
|
* \param w The wibox to change border width.
|
|
|
|
* \param border_width The border width in pixel.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
wibox_border_width_set(wibox_t *w, uint32_t border_width)
|
|
|
|
{
|
|
|
|
xcb_configure_window(globalconf.connection, w->window, XCB_CONFIG_WINDOW_BORDER_WIDTH,
|
|
|
|
&border_width);
|
|
|
|
w->border.width = border_width;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set a wibox border color.
|
|
|
|
* \param w The wibox to change border width.
|
|
|
|
* \param color The border color.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
wibox_border_color_set(wibox_t *w, const xcolor_t *color)
|
|
|
|
{
|
|
|
|
xcb_change_window_attributes(globalconf.connection, w->window,
|
|
|
|
XCB_CW_BORDER_PIXEL, &color->pixel);
|
|
|
|
w->border.color = *color;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set wibox orientation.
|
|
|
|
* \param w The wibox.
|
|
|
|
* \param o The new orientation.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
wibox_orientation_set(wibox_t *w, orientation_t o)
|
|
|
|
{
|
|
|
|
if(o != w->orientation)
|
|
|
|
{
|
|
|
|
xcb_screen_t *s = xutil_screen_get(globalconf.connection, w->ctx.phys_screen);
|
|
|
|
w->orientation = o;
|
|
|
|
/* orientation != East */
|
|
|
|
if(w->pixmap != w->ctx.pixmap)
|
|
|
|
xcb_free_pixmap(globalconf.connection, w->ctx.pixmap);
|
|
|
|
wibox_draw_context_update(w, s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set wibox cursor.
|
|
|
|
* \param w The wibox.
|
|
|
|
* \param c The cursor.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
wibox_cursor_set(wibox_t *w, xcb_cursor_t c)
|
|
|
|
{
|
|
|
|
if(w->window)
|
|
|
|
xcb_change_window_attributes(globalconf.connection, w->window, XCB_CW_CURSOR,
|
|
|
|
(const uint32_t[]) { c });
|
|
|
|
}
|
|
|
|
|
2009-04-11 13:14:50 +02:00
|
|
|
static void
|
|
|
|
wibox_map(wibox_t *wibox)
|
|
|
|
{
|
2009-07-28 16:04:58 +02:00
|
|
|
xcb_map_window(globalconf.connection, wibox->window);
|
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 */
|
|
|
|
client_stack();
|
|
|
|
}
|
|
|
|
|
2008-09-24 12:13:21 +02:00
|
|
|
static void
|
|
|
|
wibox_move(wibox_t *wibox, int16_t x, int16_t y)
|
|
|
|
{
|
2009-07-28 16:04:58 +02:00
|
|
|
if(wibox->window
|
2009-07-28 17:18:41 +02:00
|
|
|
&& (x != wibox->geometry.x || y != wibox->geometry.y))
|
2009-01-08 11:01:06 +01:00
|
|
|
{
|
2009-07-28 16:04:58 +02:00
|
|
|
xcb_configure_window(globalconf.connection, wibox->window,
|
|
|
|
XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y,
|
|
|
|
(const uint32_t[]) { x, y });
|
|
|
|
|
2009-01-08 11:01:06 +01:00
|
|
|
wibox->screen = screen_getbycoord(wibox->screen, x, y);
|
|
|
|
}
|
2009-07-28 17:18:41 +02:00
|
|
|
|
|
|
|
wibox->geometry.x = x;
|
|
|
|
wibox->geometry.y = y;
|
2008-09-24 12:13:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-07-28 16:04:58 +02:00
|
|
|
wibox_resize(wibox_t *w, uint16_t width, uint16_t height)
|
2008-09-24 12:13:21 +02:00
|
|
|
{
|
2009-07-29 11:04:59 +02:00
|
|
|
if(width <= 0 || height <= 0 || (w->geometry.width == width && w->geometry.height == height))
|
2009-07-28 17:18:41 +02:00
|
|
|
return;
|
2009-07-28 16:04:58 +02:00
|
|
|
|
2009-07-29 11:04:59 +02:00
|
|
|
w->geometry.width = width;
|
|
|
|
w->geometry.height = height;
|
|
|
|
|
2009-07-28 17:18:41 +02:00
|
|
|
if(w->window)
|
2008-09-24 12:13:21 +02:00
|
|
|
{
|
2009-07-28 17:18:41 +02:00
|
|
|
xcb_screen_t *s = xutil_screen_get(globalconf.connection, w->ctx.phys_screen);
|
|
|
|
|
|
|
|
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);
|
2009-07-29 11:04:59 +02:00
|
|
|
xcb_create_pixmap(globalconf.connection, s->root_depth, w->pixmap, s->root,
|
|
|
|
w->geometry.width, w->geometry.height);
|
2009-07-28 17:18:41 +02:00
|
|
|
xcb_configure_window(globalconf.connection, w->window,
|
|
|
|
XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
|
2009-07-29 11:04:59 +02:00
|
|
|
(const uint32_t[]) { w->geometry.width, w->geometry.height });
|
2009-07-28 17:18:41 +02:00
|
|
|
wibox_draw_context_update(w, s);
|
2008-09-24 12:13:21 +02:00
|
|
|
}
|
2009-07-28 17:18:41 +02:00
|
|
|
|
2009-07-28 16:04:58 +02:00
|
|
|
wibox_need_update(w);
|
2008-09-24 12:13:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Kick out systray windows.
|
|
|
|
* \param phys_screen Physical screen number.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
wibox_systray_kickout(int phys_screen)
|
|
|
|
{
|
|
|
|
xcb_screen_t *s = xutil_screen_get(globalconf.connection, phys_screen);
|
|
|
|
|
2009-04-17 16:14:09 +02:00
|
|
|
if(globalconf.screens.tab[phys_screen].systray.parent != s->root)
|
2009-01-30 16:13:34 +01: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,
|
2009-04-17 16:14:09 +02:00
|
|
|
globalconf.screens.tab[phys_screen].systray.window,
|
2009-01-30 16:13:34 +01:00
|
|
|
s->root, -512, -512);
|
2008-09-24 12:13:21 +02:00
|
|
|
|
2009-04-17 16:14:09 +02:00
|
|
|
globalconf.screens.tab[phys_screen].systray.parent = s->root;
|
2009-01-30 16:13:34 +01:00
|
|
|
}
|
2008-09-24 12:13:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wibox_systray_refresh(wibox_t *wibox)
|
|
|
|
{
|
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;
|
2009-07-28 16:04:58 +02:00
|
|
|
int phys_screen = wibox->ctx.phys_screen;
|
2008-09-24 12:13:21 +02:00
|
|
|
|
|
|
|
if(wibox->isvisible
|
|
|
|
&& 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,
|
2009-04-17 16:14:09 +02:00
|
|
|
globalconf.screens.tab[phys_screen].systray.window,
|
2008-09-24 12:13:21 +02:00
|
|
|
XCB_CW_BACK_PIXEL, config_back);
|
|
|
|
/* Map it. */
|
2009-04-17 16:14:09 +02:00
|
|
|
xcb_map_window(globalconf.connection, globalconf.screens.tab[phys_screen].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 */
|
2009-07-28 16:04:58 +02:00
|
|
|
if(globalconf.screens.tab[phys_screen].systray.parent != wibox->window)
|
2008-09-24 12:13:21 +02:00
|
|
|
{
|
|
|
|
xcb_reparent_window(globalconf.connection,
|
2009-04-17 16:14:09 +02:00
|
|
|
globalconf.screens.tab[phys_screen].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]);
|
2009-07-28 16:04:58 +02:00
|
|
|
globalconf.screens.tab[phys_screen].systray.parent = wibox->window;
|
2008-09-24 12:13:21 +02:00
|
|
|
}
|
|
|
|
xcb_configure_window(globalconf.connection,
|
2009-04-17 16:14:09 +02:00
|
|
|
globalconf.screens.tab[phys_screen].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
|
|
|
|
return wibox_systray_kickout(phys_screen);
|
|
|
|
|
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];
|
2008-09-24 12:13:21 +02:00
|
|
|
if(em->phys_screen == phys_screen)
|
|
|
|
{
|
2009-07-28 16:04:58 +02:00
|
|
|
if(config_win_vals[1] - config_win_vals[2] >= (uint32_t) wibox->geometry.y)
|
2008-09-24 12:13:21 +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];
|
|
|
|
}
|
|
|
|
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];
|
2008-09-24 12:13:21 +02:00
|
|
|
if(em->phys_screen == phys_screen)
|
|
|
|
{
|
2009-02-23 15:39:37 +01:00
|
|
|
/* if(y + width <= wibox.y + systray.right) */
|
2009-07-28 16:04:58 +02:00
|
|
|
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
|
|
|
{
|
|
|
|
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];
|
|
|
|
}
|
|
|
|
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];
|
2008-09-24 12:13:21 +02:00
|
|
|
if(em->phys_screen == phys_screen)
|
|
|
|
{
|
|
|
|
/* if(x + width < systray.x + systray.width) */
|
2009-07-28 16:04:58 +02:00
|
|
|
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
|
|
|
{
|
|
|
|
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];
|
|
|
|
}
|
|
|
|
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
|
|
|
|
2009-04-09 17:17:10 +02:00
|
|
|
foreach(_c, globalconf.clients)
|
|
|
|
{
|
|
|
|
client_t *c = *_c;
|
2009-07-28 16:04:58 +02:00
|
|
|
if(c->titlebar && c->titlebar->window == win)
|
2008-09-24 12:13:21 +02:00
|
|
|
return c->titlebar;
|
2009-04-09 17:17:10 +02:00
|
|
|
}
|
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)
|
|
|
|
{
|
|
|
|
if(wibox->isvisible)
|
|
|
|
{
|
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
|
|
|
{
|
|
|
|
if((*w)->need_shape_update)
|
2009-07-28 16:04:58 +02:00
|
|
|
wibox_shape_update(*w);
|
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-04-09 17:17:10 +02:00
|
|
|
foreach(_c, globalconf.clients)
|
|
|
|
{
|
|
|
|
client_t *c = *_c;
|
2008-09-24 12:13:21 +02:00
|
|
|
if(c->titlebar && c->titlebar->need_update)
|
|
|
|
wibox_draw(c->titlebar);
|
2009-04-09 17:17:10 +02:00
|
|
|
}
|
2008-09-24 12:13:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Set a wibox visible or not.
|
|
|
|
* \param wibox The wibox.
|
|
|
|
* \param v The visible value.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
wibox_setvisible(wibox_t *wibox, bool v)
|
|
|
|
{
|
|
|
|
if(v != wibox->isvisible)
|
|
|
|
{
|
2008-12-09 16:23:39 +01:00
|
|
|
wibox->isvisible = v;
|
2008-12-18 16:58:15 +01:00
|
|
|
wibox->mouse_over = NULL;
|
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
|
|
|
{
|
2008-12-09 16:23:39 +01:00
|
|
|
if(wibox->isvisible)
|
2009-04-11 13:14:50 +02:00
|
|
|
wibox_map(wibox);
|
2008-12-09 16:23:39 +01:00
|
|
|
else
|
2009-07-28 16:04:58 +02:00
|
|
|
xcb_unmap_window(globalconf.connection, wibox->window);
|
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
|
|
|
|
|
|
|
hook_property(wibox, wibox, "visible");
|
2008-09-24 12:13:21 +02:00
|
|
|
}
|
2008-09-21 11:47:29 +02:00
|
|
|
}
|
|
|
|
|
2009-07-28 16:04:58 +02:00
|
|
|
/** Destroy all X resources of a wibox.
|
|
|
|
* \param w The wibox to wipe.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
wibox_wipe(wibox_t *w)
|
|
|
|
{
|
|
|
|
if(w->window)
|
|
|
|
{
|
|
|
|
xcb_destroy_window(globalconf.connection, w->window);
|
|
|
|
w->window = XCB_NONE;
|
|
|
|
}
|
|
|
|
if(w->pixmap)
|
|
|
|
{
|
|
|
|
xcb_free_pixmap(globalconf.connection, w->pixmap);
|
|
|
|
w->pixmap = XCB_NONE;
|
|
|
|
}
|
|
|
|
if(w->gc)
|
|
|
|
{
|
|
|
|
xcb_free_gc(globalconf.connection, w->gc);
|
|
|
|
w->gc = XCB_NONE;
|
|
|
|
}
|
|
|
|
draw_context_wipe(&w->ctx);
|
|
|
|
}
|
|
|
|
|
2008-09-24 12:13:21 +02:00
|
|
|
/** Remove a wibox from a screen.
|
|
|
|
* \param wibox Wibox to detach from screen.
|
|
|
|
*/
|
2009-05-05 17:32:53 +02:00
|
|
|
static void
|
2008-09-24 12:13:21 +02:00
|
|
|
wibox_detach(wibox_t *wibox)
|
|
|
|
{
|
2009-05-05 17:32:53 +02:00
|
|
|
if(wibox->screen)
|
2008-09-24 12:13:21 +02:00
|
|
|
{
|
|
|
|
bool v;
|
|
|
|
|
|
|
|
/* save visible state */
|
|
|
|
v = wibox->isvisible;
|
|
|
|
wibox->isvisible = false;
|
2008-11-17 13:54:57 +01:00
|
|
|
wibox_systray_refresh(wibox);
|
2009-05-05 17:32:53 +02:00
|
|
|
/* restore visibility */
|
2008-09-24 12:13:21 +02:00
|
|
|
wibox->isvisible = v;
|
|
|
|
|
2008-12-18 16:58:15 +01:00
|
|
|
wibox->mouse_over = NULL;
|
|
|
|
|
2009-07-28 16:04:58 +02:00
|
|
|
wibox_wipe(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-05-07 14:13:36 +02:00
|
|
|
hook_property(wibox, wibox, "screen");
|
|
|
|
|
2009-04-17 16:14:09 +02:00
|
|
|
wibox->screen = NULL;
|
2009-05-07 14:13:36 +02:00
|
|
|
|
2009-04-11 00:27:06 +02:00
|
|
|
wibox_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.
|
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
|
|
|
|
wibox_attach(screen_t *s)
|
2008-09-24 12:13:21 +02:00
|
|
|
{
|
2009-04-18 17:51:31 +02:00
|
|
|
int phys_screen = screen_virttophys(screen_array_indexof(&globalconf.screens, s));
|
2008-09-24 12:13:21 +02:00
|
|
|
|
2009-06-16 17:14:48 +02:00
|
|
|
wibox_t *wibox = wibox_ref(globalconf.L, -1);
|
2009-04-11 00:27:06 +02:00
|
|
|
|
2008-09-24 12:13:21 +02:00
|
|
|
wibox_detach(wibox);
|
|
|
|
|
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 =
|
2009-07-28 16:04:58 +02:00
|
|
|
screen_getbycoord(wibox->screen, 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)
|
|
|
|
wibox_move(wibox, s->geometry.x, s->geometry.y);
|
|
|
|
|
2009-05-10 14:55:13 +02:00
|
|
|
wibox_array_append(&globalconf.wiboxes, wibox);
|
2008-09-24 12:13:21 +02:00
|
|
|
|
2009-07-28 16:04:58 +02:00
|
|
|
wibox_init(wibox, phys_screen);
|
2008-09-24 12:13:21 +02:00
|
|
|
|
2009-07-28 16:04:58 +02:00
|
|
|
wibox_cursor_set(wibox,
|
|
|
|
xcursor_new(globalconf.connection, xcursor_font_fromstr(wibox->cursor)));
|
2009-05-25 15:26:16 +02:00
|
|
|
|
2009-07-28 16:04:58 +02:00
|
|
|
wibox_opacity_set(wibox, wibox->opacity);
|
2009-05-25 15:26:16 +02:00
|
|
|
|
2008-10-24 11:57:01 +02:00
|
|
|
if(wibox->isvisible)
|
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
|
|
|
|
|
|
|
hook_property(wibox, wibox, "screen");
|
2008-09-24 12:13:21 +02:00
|
|
|
}
|
|
|
|
|
2008-09-21 20:39:23 +02:00
|
|
|
/** Create a new wibox.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
*
|
|
|
|
* \luastack
|
|
|
|
* \lparam A table with optionaly defined values:
|
2009-05-05 17:32:53 +02:00
|
|
|
* fg, bg, border_width, border_color, ontop, width and height.
|
2008-09-21 20:39:23 +02:00
|
|
|
* \lreturn A brand new wibox.
|
|
|
|
*/
|
2009-04-11 00:27:06 +02:00
|
|
|
static int
|
2008-09-21 20:39:23 +02:00
|
|
|
luaA_wibox_new(lua_State *L)
|
|
|
|
{
|
|
|
|
wibox_t *w;
|
|
|
|
const char *buf;
|
|
|
|
size_t len;
|
|
|
|
xcolor_init_request_t reqs[3];
|
2009-01-19 13:24:33 +01:00
|
|
|
int i, reqs_nbr = -1;
|
2008-09-21 20:39:23 +02:00
|
|
|
|
|
|
|
luaA_checktable(L, 2);
|
|
|
|
|
2009-04-11 00:27:06 +02:00
|
|
|
w = wibox_new(L);
|
2008-09-21 20:39:23 +02:00
|
|
|
|
2009-07-28 16:04:58 +02:00
|
|
|
w->ctx.fg = globalconf.colors.fg;
|
2008-09-21 20:39:23 +02:00
|
|
|
if((buf = luaA_getopt_lstring(L, 2, "fg", NULL, &len)))
|
2009-07-28 16:04:58 +02:00
|
|
|
reqs[++reqs_nbr] = xcolor_init_unchecked(&w->ctx.fg, buf, len);
|
2008-09-21 20:39:23 +02:00
|
|
|
|
2009-07-28 16:04:58 +02:00
|
|
|
w->ctx.bg = globalconf.colors.bg;
|
2008-09-21 20:39:23 +02:00
|
|
|
if((buf = luaA_getopt_lstring(L, 2, "bg", NULL, &len)))
|
2009-07-28 16:04:58 +02:00
|
|
|
reqs[++reqs_nbr] = xcolor_init_unchecked(&w->ctx.bg, buf, len);
|
2008-09-21 20:39:23 +02:00
|
|
|
|
2009-07-28 16:04:58 +02:00
|
|
|
w->border.color = globalconf.colors.bg;
|
2008-09-24 12:13:21 +02:00
|
|
|
if((buf = luaA_getopt_lstring(L, 2, "border_color", NULL, &len)))
|
2009-07-28 16:04:58 +02:00
|
|
|
reqs[++reqs_nbr] = xcolor_init_unchecked(&w->border.color, buf, len);
|
2008-09-21 20:39:23 +02:00
|
|
|
|
2009-01-14 11:28:13 +01:00
|
|
|
w->ontop = luaA_getopt_boolean(L, 2, "ontop", false);
|
|
|
|
|
2009-07-28 16:04:58 +02:00
|
|
|
w->opacity = -1;
|
|
|
|
w->border.width = luaA_getopt_number(L, 2, "border_width", 0);
|
|
|
|
w->geometry.x = luaA_getopt_number(L, 2, "x", 0);
|
|
|
|
w->geometry.y = luaA_getopt_number(L, 2, "y", 0);
|
|
|
|
w->geometry.width = luaA_getopt_number(L, 2, "width", 100);
|
|
|
|
w->geometry.height = luaA_getopt_number(L, 2, "height", globalconf.font->height * 1.5);
|
2008-09-21 20:39:23 +02:00
|
|
|
|
2008-09-23 17:20:07 +02:00
|
|
|
w->isvisible = true;
|
2008-11-13 11:04:07 +01:00
|
|
|
w->cursor = a_strdup("left_ptr");
|
2008-09-21 20:39:23 +02:00
|
|
|
|
|
|
|
for(i = 0; i <= reqs_nbr; i++)
|
|
|
|
xcolor_init_reply(reqs[i]);
|
|
|
|
|
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-07-28 10:29:30 +02:00
|
|
|
wibox_push(L, wibox);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2009-04-09 17:17:10 +02:00
|
|
|
foreach(_c, globalconf.clients)
|
|
|
|
{
|
|
|
|
client_t *c = *_c;
|
2008-10-19 19:14:55 +02:00
|
|
|
if(c->titlebar && luaA_wibox_hasitem(L, c->titlebar, item))
|
|
|
|
{
|
2009-01-16 11:10:27 +01:00
|
|
|
/* update wibox */
|
|
|
|
wibox_need_update(c->titlebar);
|
2008-10-19 19:14:55 +02:00
|
|
|
lua_pop(L, 1); /* remove widgets table */
|
|
|
|
}
|
2009-04-09 17:17:10 +02:00
|
|
|
}
|
2008-10-19 19:14:55 +02:00
|
|
|
}
|
|
|
|
|
2008-09-21 20:39:23 +02:00
|
|
|
/** Wibox object.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \return The number of elements pushed on stack.
|
|
|
|
* \luastack
|
|
|
|
* \lfield screen Screen number.
|
2009-05-07 15:03:45 +02:00
|
|
|
* \lfield client The client attached to (titlebar).
|
2008-09-21 20:39:23 +02:00
|
|
|
* \lfield border_width Border width.
|
|
|
|
* \lfield border_color Border color.
|
2009-05-05 17:32:53 +02:00
|
|
|
* \lfield align The alignment (titlebar).
|
2008-09-21 20:39:23 +02:00
|
|
|
* \lfield fg Foreground color.
|
|
|
|
* \lfield bg Background color.
|
2009-05-07 15:03:45 +02:00
|
|
|
* \lfield bg_image Background image.
|
2009-05-05 17:32:53 +02:00
|
|
|
* \lfield position The position (titlebar).
|
2008-09-22 19:23:28 +02:00
|
|
|
* \lfield ontop On top of other windows.
|
2008-11-13 11:04:07 +01:00
|
|
|
* \lfield cursor The mouse cursor.
|
2009-05-07 15:03:45 +02:00
|
|
|
* \lfield visible Visibility.
|
|
|
|
* \lfield orientation The drawing orientation: east, north or south.
|
|
|
|
* \lfield widgets An array with all widgets drawn on this wibox.
|
|
|
|
* \lfield opacity The opacity of the wibox, between 0 and 1.
|
2009-02-13 21:19:14 +01:00
|
|
|
* \lfield mouse_enter A function to execute when the mouse enter the widget.
|
|
|
|
* \lfield mouse_leave A function to execute when the mouse leave the widget.
|
2009-06-23 12:55:50 +02:00
|
|
|
* \lfield shape_clip Image describing the window's content shape.
|
|
|
|
* \lfield shape_bounding Image describing the window's border shape.
|
2008-09-21 20:39:23 +02:00
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_wibox_index(lua_State *L)
|
|
|
|
{
|
|
|
|
size_t len;
|
2009-04-11 00:27:06 +02:00
|
|
|
wibox_t *wibox = luaL_checkudata(L, 1, "wibox");
|
2008-09-21 20:39:23 +02:00
|
|
|
const char *attr = luaL_checklstring(L, 2, &len);
|
|
|
|
|
|
|
|
if(luaA_usemetatable(L, 1, 2))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
switch(a_tokenize(attr, len))
|
|
|
|
{
|
2008-09-23 17:20:07 +02:00
|
|
|
case A_TK_VISIBLE:
|
2009-04-11 00:27:06 +02:00
|
|
|
lua_pushboolean(L, wibox->isvisible);
|
2008-09-23 17:20:07 +02:00
|
|
|
break;
|
2008-09-21 20:39:23 +02:00
|
|
|
case A_TK_CLIENT:
|
2009-04-11 00:27:06 +02:00
|
|
|
return client_push(L, client_getbytitlebar(wibox));
|
2008-09-21 20:39:23 +02:00
|
|
|
case A_TK_SCREEN:
|
2009-04-17 16:14:09 +02:00
|
|
|
if(!wibox->screen)
|
2008-09-21 20:39:23 +02:00
|
|
|
return 0;
|
2009-04-18 17:51:31 +02:00
|
|
|
lua_pushnumber(L, screen_array_indexof(&globalconf.screens, wibox->screen) + 1);
|
2008-09-21 20:39:23 +02:00
|
|
|
break;
|
|
|
|
case A_TK_BORDER_WIDTH:
|
2009-07-28 16:04:58 +02:00
|
|
|
lua_pushnumber(L, wibox->border.width);
|
2008-09-21 20:39:23 +02:00
|
|
|
break;
|
|
|
|
case A_TK_BORDER_COLOR:
|
2009-07-28 16:04:58 +02:00
|
|
|
luaA_pushxcolor(L, &wibox->border.color);
|
2008-09-21 20:39:23 +02:00
|
|
|
break;
|
|
|
|
case A_TK_ALIGN:
|
2009-05-05 17:32:53 +02:00
|
|
|
if(wibox->type == WIBOX_TYPE_NORMAL)
|
|
|
|
luaA_deprecate(L, "awful.wibox.align");
|
2009-04-11 00:27:06 +02:00
|
|
|
lua_pushstring(L, draw_align_tostr(wibox->align));
|
2008-09-21 20:39:23 +02:00
|
|
|
break;
|
|
|
|
case A_TK_FG:
|
2009-07-28 16:04:58 +02:00
|
|
|
luaA_pushxcolor(L, &wibox->ctx.fg);
|
2008-09-21 20:39:23 +02:00
|
|
|
break;
|
|
|
|
case A_TK_BG:
|
2009-07-28 16:04:58 +02:00
|
|
|
luaA_pushxcolor(L, &wibox->ctx.bg);
|
2008-09-21 20:39:23 +02:00
|
|
|
break;
|
2009-03-03 10:22:39 +01:00
|
|
|
case A_TK_BG_IMAGE:
|
2009-07-28 10:29:30 +02:00
|
|
|
luaA_object_push_item(L, 1, wibox->bg_image);
|
2009-03-03 10:22:39 +01:00
|
|
|
break;
|
2008-09-21 20:39:23 +02:00
|
|
|
case A_TK_POSITION:
|
2009-05-05 17:32:53 +02:00
|
|
|
if(wibox->type == WIBOX_TYPE_NORMAL)
|
|
|
|
luaA_deprecate(L, "awful.wibox.attach");
|
2009-04-11 00:27:06 +02:00
|
|
|
lua_pushstring(L, position_tostr(wibox->position));
|
2008-09-21 20:39:23 +02:00
|
|
|
break;
|
2008-09-22 19:23:28 +02:00
|
|
|
case A_TK_ONTOP:
|
2009-04-11 00:27:06 +02:00
|
|
|
lua_pushboolean(L, wibox->ontop);
|
2008-09-22 19:23:28 +02:00
|
|
|
break;
|
2008-09-24 12:13:21 +02:00
|
|
|
case A_TK_ORIENTATION:
|
2009-07-28 16:04:58 +02:00
|
|
|
lua_pushstring(L, orientation_tostr(wibox->orientation));
|
2008-09-24 12:13:21 +02:00
|
|
|
break;
|
2008-10-19 19:14:55 +02:00
|
|
|
case A_TK_WIDGETS:
|
2009-07-28 10:29:30 +02:00
|
|
|
return luaA_object_push_item(L, 1, wibox->widgets_table);
|
2008-11-13 11:04:07 +01:00
|
|
|
case A_TK_CURSOR:
|
2009-04-11 00:27:06 +02:00
|
|
|
lua_pushstring(L, wibox->cursor);
|
2008-11-13 11:04:07 +01:00
|
|
|
break;
|
2009-01-24 23:48:05 +01:00
|
|
|
case A_TK_OPACITY:
|
2009-07-28 16:04:58 +02:00
|
|
|
if (wibox->opacity >= 0)
|
|
|
|
lua_pushnumber(L, wibox->opacity);
|
|
|
|
else
|
|
|
|
return 0;
|
2009-01-24 23:48:05 +01:00
|
|
|
break;
|
2009-02-13 21:19:14 +01:00
|
|
|
case A_TK_MOUSE_ENTER:
|
2009-07-28 10:29:30 +02:00
|
|
|
return luaA_object_push_item(L, 1, wibox->mouse_enter);
|
2009-02-13 21:19:14 +01:00
|
|
|
case A_TK_MOUSE_LEAVE:
|
2009-07-28 10:29:30 +02:00
|
|
|
return luaA_object_push_item(L, 1, wibox->mouse_leave);
|
2009-06-23 12:55:50 +02:00
|
|
|
case A_TK_SHAPE_BOUNDING:
|
2009-07-28 16:04:58 +02:00
|
|
|
return luaA_object_push_item(L, 1, wibox->shape.bounding);
|
2009-06-23 12:55:50 +02:00
|
|
|
case A_TK_SHAPE_CLIP:
|
2009-07-28 16:04:58 +02:00
|
|
|
return luaA_object_push_item(L, 1, wibox->shape.clip);
|
2009-07-28 10:44:54 +02:00
|
|
|
case A_TK_BUTTONS:
|
|
|
|
return luaA_object_push_item(L, 1, wibox->buttons);
|
2008-09-21 20:39:23 +02:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
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-04-11 00:27:06 +02:00
|
|
|
wibox_t *wibox = luaL_checkudata(L, 1, "wibox");
|
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-04-11 00:27:06 +02:00
|
|
|
switch(wibox->type)
|
2008-09-24 12:13:21 +02:00
|
|
|
{
|
|
|
|
case WIBOX_TYPE_TITLEBAR:
|
2009-04-11 00:27:06 +02:00
|
|
|
wibox_resize(wibox, wingeom.width, wingeom.height);
|
2008-09-24 12:13:21 +02:00
|
|
|
break;
|
|
|
|
case WIBOX_TYPE_NORMAL:
|
2009-05-05 17:32:53 +02:00
|
|
|
wibox_moveresize(wibox, wingeom);
|
2008-09-24 12:13:21 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-28 16:04:58 +02:00
|
|
|
return luaA_pusharea(L, wibox->geometry);
|
2008-09-24 12:13:21 +02:00
|
|
|
}
|
|
|
|
|
2008-09-21 20:39:23 +02:00
|
|
|
/** Wibox newindex.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \return The number of elements pushed on stack.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_wibox_newindex(lua_State *L)
|
|
|
|
{
|
|
|
|
size_t len;
|
2009-04-11 00:27:06 +02:00
|
|
|
wibox_t *wibox = luaL_checkudata(L, 1, "wibox");
|
2008-09-21 20:39:23 +02:00
|
|
|
const char *buf, *attr = luaL_checklstring(L, 2, &len);
|
|
|
|
awesome_token_t tok;
|
|
|
|
|
|
|
|
switch((tok = a_tokenize(attr, len)))
|
|
|
|
{
|
2008-09-22 19:23:28 +02:00
|
|
|
bool b;
|
|
|
|
|
2008-09-21 20:39:23 +02:00
|
|
|
case A_TK_FG:
|
|
|
|
if((buf = luaL_checklstring(L, 3, &len)))
|
2009-07-28 16:04:58 +02:00
|
|
|
if(xcolor_init_reply(xcolor_init_unchecked(&wibox->ctx.fg, buf, len)))
|
2009-04-11 00:27:06 +02:00
|
|
|
wibox->need_update = true;
|
2008-09-21 20:39:23 +02:00
|
|
|
break;
|
|
|
|
case A_TK_BG:
|
|
|
|
if((buf = luaL_checklstring(L, 3, &len)))
|
2009-07-28 16:04:58 +02:00
|
|
|
if(xcolor_init_reply(xcolor_init_unchecked(&wibox->ctx.bg, buf, len)))
|
2009-04-11 00:27:06 +02:00
|
|
|
wibox->need_update = true;
|
2008-09-24 12:13:21 +02:00
|
|
|
break;
|
2009-03-03 10:22:39 +01:00
|
|
|
case A_TK_BG_IMAGE:
|
2009-07-28 10:29:30 +02:00
|
|
|
luaA_object_unref_item(L, 1, wibox->bg_image);
|
|
|
|
wibox->bg_image = luaA_object_ref_item(L, 1, 3);
|
2009-04-11 00:27:06 +02:00
|
|
|
wibox->need_update = true;
|
2009-03-03 10:22:39 +01:00
|
|
|
break;
|
2008-09-24 12:13:21 +02:00
|
|
|
case A_TK_ALIGN:
|
|
|
|
buf = luaL_checklstring(L, 3, &len);
|
2009-04-11 00:27:06 +02:00
|
|
|
wibox->align = draw_align_fromstr(buf, len);
|
|
|
|
switch(wibox->type)
|
2008-10-12 17:15:01 +02:00
|
|
|
{
|
|
|
|
case WIBOX_TYPE_NORMAL:
|
2009-05-05 17:32:53 +02:00
|
|
|
luaA_deprecate(L, "awful.wibox.align");
|
2008-10-12 17:15:01 +02:00
|
|
|
break;
|
|
|
|
case WIBOX_TYPE_TITLEBAR:
|
2009-04-11 00:27:06 +02:00
|
|
|
titlebar_update_geometry(client_getbytitlebar(wibox));
|
2008-10-12 17:15:01 +02:00
|
|
|
break;
|
|
|
|
}
|
2008-09-21 20:39:23 +02:00
|
|
|
break;
|
|
|
|
case A_TK_POSITION:
|
2009-04-11 00:27:06 +02:00
|
|
|
switch(wibox->type)
|
2008-09-21 20:39:23 +02:00
|
|
|
{
|
2008-09-24 12:13:21 +02:00
|
|
|
case WIBOX_TYPE_NORMAL:
|
2008-09-21 20:39:23 +02:00
|
|
|
if((buf = luaL_checklstring(L, 3, &len)))
|
2009-05-05 17:32:53 +02:00
|
|
|
{
|
|
|
|
luaA_deprecate(L, "awful.wibox.attach");
|
|
|
|
wibox->position = position_fromstr(buf, len);
|
|
|
|
}
|
2008-09-21 20:39:23 +02:00
|
|
|
break;
|
2009-05-05 17:32:53 +02:00
|
|
|
case WIBOX_TYPE_TITLEBAR:
|
|
|
|
return luaA_titlebar_newindex(L, wibox, tok);
|
2008-09-21 20:39:23 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case A_TK_CLIENT:
|
|
|
|
/* first detach */
|
|
|
|
if(lua_isnil(L, 3))
|
2009-04-11 00:27:06 +02:00
|
|
|
titlebar_client_detach(client_getbytitlebar(wibox));
|
2008-09-21 20:39:23 +02:00
|
|
|
else
|
|
|
|
{
|
2009-04-10 15:23:55 +02:00
|
|
|
client_t *c = luaA_client_checkudata(L, -1);
|
2009-04-11 00:27:06 +02:00
|
|
|
lua_pushvalue(L, 1);
|
|
|
|
titlebar_client_attach(c);
|
2008-09-21 20:39:23 +02:00
|
|
|
}
|
|
|
|
break;
|
2008-11-13 11:04:07 +01:00
|
|
|
case A_TK_CURSOR:
|
|
|
|
if((buf = luaL_checkstring(L, 3)))
|
|
|
|
{
|
|
|
|
uint16_t cursor_font = xcursor_font_fromstr(buf);
|
|
|
|
if(cursor_font)
|
|
|
|
{
|
|
|
|
xcb_cursor_t cursor = xcursor_new(globalconf.connection, cursor_font);
|
2009-04-11 00:27:06 +02:00
|
|
|
p_delete(&wibox->cursor);
|
|
|
|
wibox->cursor = a_strdup(buf);
|
2009-07-28 16:04:58 +02:00
|
|
|
wibox_cursor_set(wibox, cursor);
|
2008-11-13 11:04:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2008-09-21 20:39:23 +02:00
|
|
|
case A_TK_SCREEN:
|
2008-09-24 12:13:21 +02:00
|
|
|
if(lua_isnil(L, 3))
|
2008-09-21 20:39:23 +02:00
|
|
|
{
|
2009-04-11 00:27:06 +02:00
|
|
|
wibox_detach(wibox);
|
|
|
|
titlebar_client_detach(client_getbytitlebar(wibox));
|
2008-09-21 20:39:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int screen = luaL_checknumber(L, 3) - 1;
|
|
|
|
luaA_checkscreen(screen);
|
2009-04-18 17:51:31 +02:00
|
|
|
if(!wibox->screen || screen != screen_array_indexof(&globalconf.screens, wibox->screen))
|
2008-09-24 12:13:21 +02:00
|
|
|
{
|
2009-04-11 00:27:06 +02:00
|
|
|
titlebar_client_detach(client_getbytitlebar(wibox));
|
|
|
|
lua_pushvalue(L, 1);
|
2009-04-17 16:14:09 +02:00
|
|
|
wibox_attach(&globalconf.screens.tab[screen]);
|
2008-09-24 12:13:21 +02:00
|
|
|
}
|
2008-09-21 20:39:23 +02:00
|
|
|
}
|
|
|
|
break;
|
2008-09-22 19:23:28 +02:00
|
|
|
case A_TK_ONTOP:
|
|
|
|
b = luaA_checkboolean(L, 3);
|
2009-04-11 00:27:06 +02:00
|
|
|
if(b != wibox->ontop)
|
2008-09-22 19:23:28 +02:00
|
|
|
{
|
2009-04-11 00:27:06 +02:00
|
|
|
wibox->ontop = b;
|
2008-09-22 19:23:28 +02:00
|
|
|
client_stack();
|
|
|
|
}
|
|
|
|
break;
|
2008-09-24 12:13:21 +02:00
|
|
|
case A_TK_ORIENTATION:
|
|
|
|
if((buf = luaL_checklstring(L, 3, &len)))
|
|
|
|
{
|
2009-07-28 16:04:58 +02:00
|
|
|
wibox_orientation_set(wibox, orientation_fromstr(buf, len));
|
2009-04-11 00:27:06 +02:00
|
|
|
wibox_need_update(wibox);
|
2008-09-24 12:13:21 +02:00
|
|
|
}
|
|
|
|
break;
|
2008-10-12 17:02:42 +02:00
|
|
|
case A_TK_BORDER_COLOR:
|
|
|
|
if((buf = luaL_checklstring(L, 3, &len)))
|
2009-07-28 16:04:58 +02:00
|
|
|
if(xcolor_init_reply(xcolor_init_unchecked(&wibox->border.color, buf, len)))
|
|
|
|
if(wibox->window)
|
|
|
|
wibox_border_color_set(wibox, &wibox->border.color);
|
2008-10-12 17:02:42 +02:00
|
|
|
break;
|
2008-09-23 17:20:07 +02:00
|
|
|
case A_TK_VISIBLE:
|
|
|
|
b = luaA_checkboolean(L, 3);
|
2009-04-11 00:27:06 +02:00
|
|
|
if(b != wibox->isvisible)
|
|
|
|
switch(wibox->type)
|
2008-09-23 17:20:07 +02:00
|
|
|
{
|
2008-09-24 12:13:21 +02:00
|
|
|
case WIBOX_TYPE_NORMAL:
|
2009-04-11 00:27:06 +02:00
|
|
|
wibox_setvisible(wibox, b);
|
2008-09-23 17:20:07 +02:00
|
|
|
break;
|
|
|
|
case WIBOX_TYPE_TITLEBAR:
|
2009-04-11 00:27:06 +02:00
|
|
|
titlebar_set_visible(wibox, b);
|
2008-09-23 17:20:07 +02:00
|
|
|
break;
|
|
|
|
}
|
2008-09-24 12:13:21 +02:00
|
|
|
break;
|
2008-10-19 19:14:55 +02:00
|
|
|
case A_TK_WIDGETS:
|
2008-10-27 14:17:12 +01:00
|
|
|
if(luaA_isloop(L, 3))
|
2008-11-07 11:18:14 +01:00
|
|
|
{
|
|
|
|
luaA_warn(L, "table is looping, cannot use this as widget table");
|
|
|
|
return 0;
|
|
|
|
}
|
2009-07-28 10:29:30 +02:00
|
|
|
/* duplicate table because next function will eat it */
|
|
|
|
lua_pushvalue(L, 3);
|
|
|
|
/* register object */
|
|
|
|
wibox->widgets_table = luaA_object_ref_item(L, 1, -1);
|
2009-01-16 11:10:27 +01:00
|
|
|
wibox_need_update(wibox);
|
2008-10-19 19:14:55 +02:00
|
|
|
luaA_table2wtable(L);
|
|
|
|
break;
|
2009-01-24 23:48:05 +01:00
|
|
|
case A_TK_OPACITY:
|
|
|
|
if(lua_isnil(L, 3))
|
2009-07-28 16:04:58 +02:00
|
|
|
wibox_opacity_set(wibox, -1);
|
2009-01-24 23:48:05 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
double d = luaL_checknumber(L, 3);
|
|
|
|
if(d >= 0 && d <= 1)
|
2009-07-28 16:04:58 +02:00
|
|
|
wibox_opacity_set(wibox, d);
|
2009-01-24 23:48:05 +01:00
|
|
|
}
|
|
|
|
break;
|
2009-02-13 21:19:14 +01:00
|
|
|
case A_TK_MOUSE_ENTER:
|
2009-07-28 10:29:30 +02:00
|
|
|
luaA_checkfunction(L, 3);
|
|
|
|
luaA_object_unref_item(L, 1, wibox->mouse_enter);
|
|
|
|
wibox->mouse_enter = luaA_object_ref_item(L, 1, 3);
|
2009-02-13 21:19:14 +01:00
|
|
|
return 0;
|
|
|
|
case A_TK_MOUSE_LEAVE:
|
2009-07-28 10:29:30 +02:00
|
|
|
luaA_checkfunction(L, 3);
|
|
|
|
luaA_object_unref_item(L, 1, wibox->mouse_leave);
|
|
|
|
wibox->mouse_leave = luaA_object_ref_item(L, 1, 3);
|
2009-02-13 21:19:14 +01:00
|
|
|
return 0;
|
2009-06-23 12:55:50 +02:00
|
|
|
case A_TK_SHAPE_BOUNDING:
|
2009-07-28 16:04:58 +02:00
|
|
|
luaA_object_unref_item(L, 1, wibox->shape.bounding);
|
|
|
|
wibox->shape.bounding = luaA_object_ref_item(L, 1, 3);
|
2009-06-23 12:55:50 +02:00
|
|
|
wibox->need_shape_update = true;
|
|
|
|
break;
|
|
|
|
case A_TK_SHAPE_CLIP:
|
2009-07-28 16:04:58 +02:00
|
|
|
luaA_object_unref_item(L, 1, wibox->shape.clip);
|
|
|
|
wibox->shape.clip = luaA_object_ref_item(L, 1, 3);
|
2009-06-23 12:55:50 +02:00
|
|
|
wibox->need_shape_update = true;
|
2009-07-28 10:44:54 +02:00
|
|
|
case A_TK_BUTTONS:
|
|
|
|
luaA_object_unref_item(L, 1, wibox->buttons);
|
|
|
|
wibox->buttons = luaA_object_ref_item(L, 1, 3);
|
2009-06-23 12:55:50 +02:00
|
|
|
break;
|
2008-09-21 20:39:23 +02:00
|
|
|
default:
|
2009-04-11 00:27:06 +02:00
|
|
|
switch(wibox->type)
|
2008-09-21 20:39:23 +02:00
|
|
|
{
|
|
|
|
case WIBOX_TYPE_TITLEBAR:
|
2009-04-11 00:27:06 +02:00
|
|
|
return luaA_titlebar_newindex(L, wibox, tok);
|
2008-09-24 12:13:21 +02:00
|
|
|
case WIBOX_TYPE_NORMAL:
|
2008-09-21 20:39:23 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct luaL_reg awesome_wibox_methods[] =
|
|
|
|
{
|
|
|
|
{ "__call", luaA_wibox_new },
|
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
const struct luaL_reg awesome_wibox_meta[] =
|
|
|
|
{
|
2008-09-24 12:13:21 +02:00
|
|
|
{ "geometry", luaA_wibox_geometry },
|
2008-09-21 20:39:23 +02:00
|
|
|
{ "__index", luaA_wibox_index },
|
|
|
|
{ "__newindex", luaA_wibox_newindex },
|
|
|
|
{ "__gc", luaA_wibox_gc },
|
|
|
|
{ "__tostring", luaA_wibox_tostring },
|
|
|
|
{ NULL, NULL },
|
|
|
|
};
|
|
|
|
|
2008-09-21 10:13:21 +02:00
|
|
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|