Widgets: Remove
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
2eae7e5cf4
commit
d213f19c5f
|
@ -74,11 +74,7 @@ set(AWE_SRCS
|
|||
${SOURCE_DIR}/objects/tag.c
|
||||
${SOURCE_DIR}/objects/timer.c
|
||||
${SOURCE_DIR}/objects/wibox.c
|
||||
${SOURCE_DIR}/objects/window.c
|
||||
${SOURCE_DIR}/objects/widget.c
|
||||
${SOURCE_DIR}/objects/widgets/imagebox.c
|
||||
${SOURCE_DIR}/objects/widgets/systray.c
|
||||
${SOURCE_DIR}/objects/widgets/textbox.c)
|
||||
${SOURCE_DIR}/objects/window.c)
|
||||
|
||||
set(AWE_MAN_SRCS
|
||||
${SOURCE_DIR}/manpages/awesome.1.txt
|
||||
|
|
123
event.c
123
event.c
|
@ -32,7 +32,6 @@
|
|||
#include "xwindow.h"
|
||||
#include "ewmh.h"
|
||||
#include "objects/client.h"
|
||||
#include "objects/widget.h"
|
||||
#include "keyresolv.h"
|
||||
#include "keygrabber.h"
|
||||
#include "mousegrabber.h"
|
||||
|
@ -194,28 +193,8 @@ event_handle_button(xcb_button_press_event_t *ev)
|
|||
/* Handle the button event on it */
|
||||
event_button_callback(ev, &wibox->buttons, -1, 1, NULL);
|
||||
|
||||
/* Duplicate the wibox */
|
||||
lua_pushvalue(globalconf.L, -1);
|
||||
/* And handle the button event on it again */
|
||||
event_emit_button(ev);
|
||||
|
||||
/* then try to match a widget binding */
|
||||
widget_t *w = widget_getbycoords(wibox->orientation, &wibox->widgets,
|
||||
wibox->geometry.width,
|
||||
wibox->geometry.height,
|
||||
&ev->event_x, &ev->event_y);
|
||||
if(w)
|
||||
{
|
||||
/* Push widget (the wibox is already on stack) */
|
||||
luaA_object_push_item(globalconf.L, -1, w);
|
||||
/* Move widget before wibox */
|
||||
lua_insert(globalconf.L, -2);
|
||||
event_button_callback(ev, &w->buttons, -2, 2, NULL);
|
||||
}
|
||||
else
|
||||
/* Remove the wibox, we did not use it */
|
||||
lua_pop(globalconf.L, 1);
|
||||
|
||||
}
|
||||
else if((c = client_getbyframewin(ev->event)))
|
||||
{
|
||||
|
@ -350,92 +329,21 @@ event_handle_destroynotify(xcb_destroy_notify_event_t *ev)
|
|||
if(globalconf.embedded.tab[i].win == ev->window)
|
||||
{
|
||||
xembed_window_array_take(&globalconf.embedded, i);
|
||||
widget_invalidate_bytype(widget_systray);
|
||||
}
|
||||
}
|
||||
|
||||
/** Handle a motion notify over widgets.
|
||||
* \param wibox The wibox.
|
||||
* \param mouse_over The pointer to the registered mouse over widget.
|
||||
* \param widget The new widget the mouse is over.
|
||||
*/
|
||||
static void
|
||||
event_handle_widget_motionnotify(wibox_t *wibox,
|
||||
widget_t *widget)
|
||||
{
|
||||
if(widget != wibox->mouse_over)
|
||||
{
|
||||
if(wibox->mouse_over)
|
||||
{
|
||||
/* Emit mouse leave signal on old widget:
|
||||
* - Push wibox.*/
|
||||
luaA_object_push(globalconf.L, wibox);
|
||||
/* - Push the widget the mouse was on */
|
||||
luaA_object_push_item(globalconf.L, -1, wibox->mouse_over);
|
||||
/* - Invert wibox/widget */
|
||||
lua_insert(globalconf.L, -2);
|
||||
/* - Emit the signal mouse::leave with the wibox as argument */
|
||||
luaA_object_emit_signal(globalconf.L, -2, "mouse::leave", 1);
|
||||
/* - Remove the widget */
|
||||
lua_pop(globalconf.L, 1);
|
||||
|
||||
/* Re-push wibox */
|
||||
luaA_object_push(globalconf.L, wibox);
|
||||
luaA_object_unref_item(globalconf.L, -1, wibox->mouse_over);
|
||||
/* Remove the wibox */
|
||||
lua_pop(globalconf.L, 1);
|
||||
}
|
||||
if(widget)
|
||||
{
|
||||
/* Get a ref on this widget so that it can't be unref'd from
|
||||
* underneath us (-> invalid pointer dereference):
|
||||
* - Push the wibox */
|
||||
luaA_object_push(globalconf.L, wibox);
|
||||
/* - Push the widget */
|
||||
luaA_object_push_item(globalconf.L, -1, widget);
|
||||
/* - Reference the widget into the wibox */
|
||||
luaA_object_ref_item(globalconf.L, -2, -1);
|
||||
|
||||
/* Emit mouse::enter signal on new widget:
|
||||
* - Push the widget */
|
||||
luaA_object_push_item(globalconf.L, -1, widget);
|
||||
/* - Move the widget before the wibox we pushed just above */
|
||||
lua_insert(globalconf.L, -2);
|
||||
/* - Emit the signal with the wibox as argument */
|
||||
|
||||
luaA_object_emit_signal(globalconf.L, -2, "mouse::enter", 1);
|
||||
/* - Remove the widget from the stack */
|
||||
lua_pop(globalconf.L, 1);
|
||||
}
|
||||
|
||||
/* Store that this widget was the one with the mouse over */
|
||||
wibox->mouse_over = widget;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/** The motion notify event handler.
|
||||
* \param ev The event.
|
||||
*/
|
||||
static void
|
||||
event_handle_motionnotify(xcb_motion_notify_event_t *ev)
|
||||
{
|
||||
wibox_t *wibox;
|
||||
|
||||
globalconf.timestamp = ev->time;
|
||||
|
||||
if(event_handle_mousegrabber(ev->root_x, ev->root_y, ev->state))
|
||||
return;
|
||||
|
||||
if((wibox = wibox_getbywin(ev->event)))
|
||||
{
|
||||
widget_t *w = widget_getbycoords(wibox->orientation, &wibox->widgets,
|
||||
wibox->geometry.width,
|
||||
wibox->geometry.height,
|
||||
&ev->event_x, &ev->event_y);
|
||||
|
||||
event_handle_widget_motionnotify(wibox, w);
|
||||
}
|
||||
#warning
|
||||
}
|
||||
|
||||
/** The leave notify event handler.
|
||||
|
@ -461,22 +369,6 @@ event_handle_leavenotify(xcb_leave_notify_event_t *ev)
|
|||
|
||||
if((wibox = wibox_getbywin(ev->event)))
|
||||
{
|
||||
if(wibox->mouse_over)
|
||||
{
|
||||
/* Push the wibox */
|
||||
luaA_object_push(globalconf.L, wibox);
|
||||
/* Push the widget the mouse is over in this wibox */
|
||||
luaA_object_push_item(globalconf.L, -1, wibox->mouse_over);
|
||||
/* Move the widget before the wibox */
|
||||
lua_insert(globalconf.L, -2);
|
||||
/* Emit mouse::leave signal on widget the mouse was over with
|
||||
* its wibox as argument */
|
||||
luaA_object_emit_signal(globalconf.L, -2, "mouse::leave", 1);
|
||||
/* Remove the widget from the stack */
|
||||
lua_pop(globalconf.L, 1);
|
||||
wibox_clear_mouse_over(wibox);
|
||||
}
|
||||
|
||||
luaA_object_push(globalconf.L, wibox);
|
||||
luaA_object_emit_signal(globalconf.L, -1, "mouse::leave", 0);
|
||||
lua_pop(globalconf.L, 1);
|
||||
|
@ -499,13 +391,6 @@ event_handle_enternotify(xcb_enter_notify_event_t *ev)
|
|||
|
||||
if((wibox = wibox_getbywin(ev->event)))
|
||||
{
|
||||
widget_t *w = widget_getbycoords(wibox->orientation, &wibox->widgets,
|
||||
wibox->geometry.width,
|
||||
wibox->geometry.height,
|
||||
&ev->event_x, &ev->event_y);
|
||||
|
||||
event_handle_widget_motionnotify(wibox, w);
|
||||
|
||||
luaA_object_push(globalconf.L, wibox);
|
||||
luaA_object_emit_signal(globalconf.L, -1, "mouse::enter", 0);
|
||||
lua_pop(globalconf.L, 1);
|
||||
|
@ -558,10 +443,7 @@ event_handle_expose(xcb_expose_event_t *ev)
|
|||
{
|
||||
wibox_t *wibox;
|
||||
|
||||
/* If the wibox got need_update set, skip this because it will be repainted
|
||||
* soon anyway. Without this we could be painting garbage to the screen!
|
||||
*/
|
||||
if((wibox = wibox_getbywin(ev->window)) && !wibox->need_update)
|
||||
if((wibox = wibox_getbywin(ev->window)))
|
||||
wibox_refresh_pixmap_partial(wibox,
|
||||
ev->x, ev->y,
|
||||
ev->width, ev->height);
|
||||
|
@ -677,7 +559,6 @@ event_handle_unmapnotify(xcb_unmap_notify_event_t *ev)
|
|||
if(globalconf.embedded.tab[i].win == ev->window)
|
||||
{
|
||||
xembed_window_array_take(&globalconf.embedded, i);
|
||||
widget_invalidate_bytype(widget_systray);
|
||||
xcb_change_save_set(globalconf.connection, XCB_SET_MODE_DELETE, ev->window);
|
||||
}
|
||||
}
|
||||
|
|
1
event.h
1
event.h
|
@ -30,7 +30,6 @@ static inline int
|
|||
awesome_refresh(void)
|
||||
{
|
||||
banning_refresh();
|
||||
wibox_refresh();
|
||||
systray_refresh();
|
||||
stack_refresh();
|
||||
return xcb_flush(globalconf.connection);
|
||||
|
|
1
ewmh.c
1
ewmh.c
|
@ -29,7 +29,6 @@
|
|||
#include "objects/tag.h"
|
||||
#include "screen.h"
|
||||
#include "objects/client.h"
|
||||
#include "objects/widget.h"
|
||||
#include "objects/wibox.h"
|
||||
#include "luaa.h"
|
||||
#include "common/atoms.h"
|
||||
|
|
151
luaa.c
151
luaa.c
|
@ -277,151 +277,6 @@ luaA_fixups(lua_State *L)
|
|||
lua_settable(L, LUA_GLOBALSINDEX);
|
||||
}
|
||||
|
||||
/** __next function for wtable objects.
|
||||
* \param L The Lua VM state.
|
||||
* \return The number of elements pushed on stack.
|
||||
*/
|
||||
static int
|
||||
luaA_wtable_next(lua_State *L)
|
||||
{
|
||||
/* upvalue 1 is content table */
|
||||
if(lua_next(L, lua_upvalueindex(1)))
|
||||
return 2;
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** __ipairs function for wtable objects.
|
||||
* \param L The Lua VM state.
|
||||
* \return The number of elements pushed on stack.
|
||||
*/
|
||||
static int
|
||||
luaA_wtable_ipairs(lua_State *L)
|
||||
{
|
||||
/* push ipairs_aux */
|
||||
lua_pushvalue(L, lua_upvalueindex(2));
|
||||
/* push content table */
|
||||
lua_pushvalue(L, lua_upvalueindex(1));
|
||||
lua_pushinteger(L, 0); /* and initial value */
|
||||
return 3;
|
||||
}
|
||||
|
||||
/** Index function of wtable objects.
|
||||
* \param L The Lua VM state.
|
||||
* \return The number of elements pushed on stack.
|
||||
*/
|
||||
static int
|
||||
luaA_wtable_index(lua_State *L)
|
||||
{
|
||||
const char *buf;
|
||||
|
||||
lua_pushvalue(L, 2);
|
||||
/* check for size, waiting lua 5.2 and __len on tables */
|
||||
if((buf = lua_tostring(L, -1)))
|
||||
if(a_strcmp(buf, "len") == 0)
|
||||
{
|
||||
lua_pushnumber(L, lua_objlen(L, lua_upvalueindex(1)));
|
||||
return 1;
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
/* upvalue 1 is content table */
|
||||
lua_rawget(L, lua_upvalueindex(1));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** Newindex function of wtable objects.
|
||||
* \param L The Lua VM state.
|
||||
* \return The number of elements pushed on stack.
|
||||
*/
|
||||
static int
|
||||
luaA_wtable_newindex(lua_State *L)
|
||||
{
|
||||
bool invalid = false;
|
||||
|
||||
/* push key on top */
|
||||
lua_pushvalue(L, 2);
|
||||
/* get current key value in content table */
|
||||
lua_rawget(L, lua_upvalueindex(1));
|
||||
/* if value is a widget, notify change */
|
||||
if(lua_istable(L, -1) || luaA_toudata(L, -1, &widget_class))
|
||||
invalid = true;
|
||||
|
||||
lua_pop(L, 1); /* remove value */
|
||||
|
||||
/* if new value is a widget or a table */
|
||||
if(lua_istable(L, 3))
|
||||
{
|
||||
luaA_table2wtable(L);
|
||||
invalid = true;
|
||||
}
|
||||
else if(!invalid && luaA_toudata(L, 3, &widget_class))
|
||||
invalid = true;
|
||||
|
||||
/* upvalue 1 is content table */
|
||||
lua_rawset(L, lua_upvalueindex(1));
|
||||
|
||||
if(invalid)
|
||||
luaA_wibox_invalidate_byitem(L, lua_topointer(L, 1));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Convert the top element of the stack to a proxied wtable.
|
||||
* \param L The Lua VM state.
|
||||
*/
|
||||
void
|
||||
luaA_table2wtable(lua_State *L)
|
||||
{
|
||||
if(!lua_istable(L, -1))
|
||||
return;
|
||||
|
||||
lua_newtable(L); /* create *real* content table */
|
||||
lua_createtable(L, 0, 5); /* metatable */
|
||||
lua_pushvalue(L, -2); /* copy content table */
|
||||
lua_pushcfunction(L, luaA_ipairs_aux); /* push ipairs aux */
|
||||
lua_pushcclosure(L, luaA_wtable_ipairs, 2);
|
||||
lua_pushvalue(L, -3); /* copy content table */
|
||||
lua_pushcclosure(L, luaA_wtable_next, 1); /* __next has the content table as upvalue */
|
||||
lua_pushvalue(L, -4); /* copy content table */
|
||||
lua_pushcclosure(L, luaA_wtable_index, 1); /* __index has the content table as upvalue */
|
||||
lua_pushvalue(L, -5); /* copy content table */
|
||||
lua_pushcclosure(L, luaA_wtable_newindex, 1); /* __newindex has the content table as upvalue */
|
||||
/* set metatable field with just pushed closure */
|
||||
lua_setfield(L, -5, "__newindex");
|
||||
lua_setfield(L, -4, "__index");
|
||||
lua_setfield(L, -3, "__next");
|
||||
lua_setfield(L, -2, "__ipairs");
|
||||
/* set metatable impossible to touch */
|
||||
lua_pushliteral(L, "wtable");
|
||||
lua_setfield(L, -2, "__metatable");
|
||||
/* set new metatable on original table */
|
||||
lua_setmetatable(L, -3);
|
||||
|
||||
/* initial key */
|
||||
lua_pushnil(L);
|
||||
/* go through original table */
|
||||
while(lua_next(L, -3))
|
||||
{
|
||||
/* if convert value to wtable */
|
||||
luaA_table2wtable(L);
|
||||
/* copy key */
|
||||
lua_pushvalue(L, -2);
|
||||
/* move key before value */
|
||||
lua_insert(L, -2);
|
||||
/* set same value in content table */
|
||||
lua_rawset(L, -4);
|
||||
/* copy key */
|
||||
lua_pushvalue(L, -1);
|
||||
/* push the new value :-> */
|
||||
lua_pushnil(L);
|
||||
/* set orig[k] = nil */
|
||||
lua_rawset(L, -5);
|
||||
}
|
||||
/* remove content table */
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
/** Look for an item: table, function, etc.
|
||||
* \param L The Lua VM state.
|
||||
* \param item The pointer item.
|
||||
|
@ -574,9 +429,6 @@ luaA_awesome_newindex(lua_State *L)
|
|||
const char *newfont = luaL_checkstring(L, 3);
|
||||
font_delete(&globalconf.font);
|
||||
globalconf.font = font_new(newfont);
|
||||
/* refresh all wiboxes */
|
||||
foreach(wibox, globalconf.wiboxes)
|
||||
(*wibox)->need_update = true;
|
||||
}
|
||||
else if(a_strcmp(buf, "fg") == 0)
|
||||
{
|
||||
|
@ -750,9 +602,6 @@ luaA_init(xdgHandle* xdg)
|
|||
/* Export wibox */
|
||||
wibox_class_setup(L);
|
||||
|
||||
/* Export widget */
|
||||
widget_class_setup(L);
|
||||
|
||||
/* Export client */
|
||||
client_class_setup(L);
|
||||
|
||||
|
|
1
luaa.h
1
luaa.h
|
@ -189,7 +189,6 @@ luaA_warn(lua_State *L, const char *fmt, ...)
|
|||
void luaA_init(xdgHandle *);
|
||||
bool luaA_parserc(xdgHandle *, const char *, bool);
|
||||
bool luaA_hasitem(lua_State *, const void *);
|
||||
void luaA_table2wtable(lua_State *);
|
||||
bool luaA_isloop(lua_State *, int);
|
||||
|
||||
/** Global signals */
|
||||
|
|
13
mouse.c
13
mouse.c
|
@ -234,19 +234,6 @@ luaA_mouse_object_under_pointer(lua_State *L)
|
|||
{
|
||||
luaA_object_push(L, wibox);
|
||||
|
||||
int16_t x = mouse_x - wibox->geometry.x;
|
||||
int16_t y = mouse_y - wibox->geometry.y;
|
||||
|
||||
widget_t *widget = widget_getbycoords(wibox->orientation, &wibox->widgets,
|
||||
wibox->geometry.width,
|
||||
wibox->geometry.height,
|
||||
&x, &y);
|
||||
|
||||
if(widget)
|
||||
{
|
||||
luaA_object_push(L, widget);
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
else if((client = client_getbyframewin(child)))
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "tag.h"
|
||||
#include "client.h"
|
||||
#include "ewmh.h"
|
||||
#include "widget.h"
|
||||
#include "luaa.h"
|
||||
|
||||
/** Tag type */
|
||||
|
|
322
objects/wibox.c
322
objects/wibox.c
|
@ -82,38 +82,16 @@ wibox_wipe(wibox_t *wibox)
|
|||
{
|
||||
p_delete(&wibox->cursor);
|
||||
wibox_wipe_resources(wibox);
|
||||
widget_node_array_wipe(&wibox->widgets);
|
||||
if(wibox->bg_image)
|
||||
cairo_surface_destroy(wibox->bg_image);
|
||||
}
|
||||
|
||||
/** 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)
|
||||
luaA_object_unref_item(globalconf.L, idx, widget_node->widget);
|
||||
widget_node_array_wipe(&wibox->widgets);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
wibox_unref_simplified(wibox_t **item)
|
||||
{
|
||||
luaA_object_unref(globalconf.L, *item);
|
||||
}
|
||||
|
||||
static void
|
||||
wibox_need_update(wibox_t *wibox)
|
||||
{
|
||||
wibox->need_update = true;
|
||||
wibox_clear_mouse_over(wibox);
|
||||
}
|
||||
|
||||
static void
|
||||
wibox_draw_context_update(wibox_t *w)
|
||||
{
|
||||
|
@ -283,8 +261,6 @@ wibox_moveresize(lua_State *L, int udx, area_t geometry)
|
|||
DO_WIBOX_GEOMETRY_CHECK_AND_EMIT(height)
|
||||
#undef DO_WIBOX_GEOMETRY_CHECK_AND_EMIT
|
||||
}
|
||||
|
||||
wibox_need_update(w);
|
||||
}
|
||||
|
||||
/** Refresh the window content by copying its pixmap data to its window.
|
||||
|
@ -333,166 +309,10 @@ wibox_map(wibox_t *wibox)
|
|||
xcb_map_window(globalconf.connection, wibox->window);
|
||||
/* Deactivate BMA */
|
||||
client_restore_enterleave_events();
|
||||
/* We must make sure the wibox does not display garbage */
|
||||
wibox_need_update(wibox);
|
||||
/* Stack this wibox correctly */
|
||||
stack_windows();
|
||||
}
|
||||
|
||||
static void
|
||||
wibox_systray_refresh(wibox_t *wibox)
|
||||
{
|
||||
wibox->has_systray = false;
|
||||
|
||||
if(!wibox->screen)
|
||||
return;
|
||||
|
||||
for(int i = 0; i < wibox->widgets.len; i++)
|
||||
{
|
||||
widget_node_t *systray = &wibox->widgets.tab[i];
|
||||
if(systray->widget->type == widget_systray)
|
||||
{
|
||||
uint32_t config_back[] = { wibox->ctx.bg.pixel };
|
||||
uint32_t config_win_vals[4];
|
||||
uint32_t config_win_vals_off[2] = { -512, -512 };
|
||||
xembed_window_t *em;
|
||||
|
||||
wibox->has_systray = true;
|
||||
|
||||
if(wibox->visible
|
||||
&& systray->widget->isvisible
|
||||
&& systray->geometry.width)
|
||||
{
|
||||
/* Set background of the systray window. */
|
||||
xcb_change_window_attributes(globalconf.connection,
|
||||
globalconf.systray.window,
|
||||
XCB_CW_BACK_PIXEL, config_back);
|
||||
/* Map it. */
|
||||
xcb_map_window(globalconf.connection, globalconf.systray.window);
|
||||
/* Move it. */
|
||||
switch(wibox->orientation)
|
||||
{
|
||||
case North:
|
||||
config_win_vals[0] = systray->geometry.y;
|
||||
config_win_vals[1] = wibox->geometry.height - systray->geometry.x - systray->geometry.width;
|
||||
config_win_vals[2] = systray->geometry.height;
|
||||
config_win_vals[3] = systray->geometry.width;
|
||||
break;
|
||||
case South:
|
||||
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;
|
||||
break;
|
||||
case East:
|
||||
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;
|
||||
break;
|
||||
}
|
||||
/* reparent */
|
||||
if(globalconf.systray.parent != wibox->window)
|
||||
{
|
||||
xcb_reparent_window(globalconf.connection,
|
||||
globalconf.systray.window,
|
||||
wibox->window,
|
||||
config_win_vals[0], config_win_vals[1]);
|
||||
globalconf.systray.parent = wibox->window;
|
||||
}
|
||||
xcb_configure_window(globalconf.connection,
|
||||
globalconf.systray.window,
|
||||
XCB_CONFIG_WINDOW_X
|
||||
| XCB_CONFIG_WINDOW_Y
|
||||
| XCB_CONFIG_WINDOW_WIDTH
|
||||
| XCB_CONFIG_WINDOW_HEIGHT,
|
||||
config_win_vals);
|
||||
/* width = height = systray height */
|
||||
config_win_vals[2] = config_win_vals[3] = systray->geometry.height;
|
||||
config_win_vals[0] = 0;
|
||||
}
|
||||
else
|
||||
return wibox_systray_kickout();
|
||||
|
||||
switch(wibox->orientation)
|
||||
{
|
||||
case North:
|
||||
config_win_vals[1] = systray->geometry.width - config_win_vals[3];
|
||||
for(int j = 0; j < globalconf.embedded.len; j++)
|
||||
{
|
||||
em = &globalconf.embedded.tab[j];
|
||||
if(config_win_vals[1] - config_win_vals[2] >= (uint32_t) wibox->geometry.y)
|
||||
{
|
||||
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);
|
||||
}
|
||||
break;
|
||||
case South:
|
||||
config_win_vals[1] = 0;
|
||||
for(int j = 0; j < globalconf.embedded.len; j++)
|
||||
{
|
||||
em = &globalconf.embedded.tab[j];
|
||||
/* 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))
|
||||
{
|
||||
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);
|
||||
}
|
||||
break;
|
||||
case East:
|
||||
config_win_vals[1] = 0;
|
||||
for(int j = 0; j < globalconf.embedded.len; j++)
|
||||
{
|
||||
em = &globalconf.embedded.tab[j];
|
||||
/* 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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Get a wibox by its window.
|
||||
* \param win The window id.
|
||||
* \return A wibox if found, NULL otherwise.
|
||||
|
@ -506,48 +326,6 @@ wibox_getbywin(xcb_window_t win)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/** Draw a wibox.
|
||||
* \param wibox The wibox to draw.
|
||||
*/
|
||||
static void
|
||||
wibox_draw(wibox_t *wibox)
|
||||
{
|
||||
if(wibox->visible)
|
||||
{
|
||||
widget_render(wibox);
|
||||
wibox_refresh_pixmap(wibox);
|
||||
|
||||
wibox->need_update = false;
|
||||
}
|
||||
|
||||
wibox_systray_refresh(wibox);
|
||||
}
|
||||
|
||||
/** Refresh all wiboxes.
|
||||
*/
|
||||
void
|
||||
wibox_refresh(void)
|
||||
{
|
||||
foreach(w, globalconf.wiboxes)
|
||||
{
|
||||
if((*w)->need_update)
|
||||
wibox_draw(*w);
|
||||
}
|
||||
}
|
||||
|
||||
/** 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;
|
||||
}
|
||||
}
|
||||
|
||||
/** Set a wibox visible or not.
|
||||
* \param L The Lua VM state.
|
||||
* \param udx The wibox.
|
||||
|
@ -560,7 +338,6 @@ wibox_set_visible(lua_State *L, int udx, bool v)
|
|||
if(v != wibox->visible)
|
||||
{
|
||||
wibox->visible = v;
|
||||
wibox_clear_mouse_over(wibox);
|
||||
|
||||
if(wibox->screen)
|
||||
{
|
||||
|
@ -575,9 +352,6 @@ wibox_set_visible(lua_State *L, int udx, bool v)
|
|||
/* Active BMA */
|
||||
client_restore_enterleave_events();
|
||||
}
|
||||
|
||||
/* kick out systray if needed */
|
||||
wibox_systray_refresh(wibox);
|
||||
}
|
||||
|
||||
luaA_object_emit_signal(L, udx, "property::visible", 0);
|
||||
|
@ -599,12 +373,9 @@ wibox_detach(lua_State *L, int udx)
|
|||
/* save visible state */
|
||||
v = wibox->visible;
|
||||
wibox->visible = false;
|
||||
wibox_systray_refresh(wibox);
|
||||
/* restore visibility */
|
||||
wibox->visible = v;
|
||||
|
||||
wibox_clear_mouse_over(wibox);
|
||||
|
||||
wibox_wipe_resources(wibox);
|
||||
|
||||
foreach(item, globalconf.wiboxes)
|
||||
|
@ -667,8 +438,6 @@ wibox_attach(lua_State *L, int udx, screen_t *s)
|
|||
|
||||
if(wibox->visible)
|
||||
wibox_map(wibox);
|
||||
else
|
||||
wibox_need_update(wibox);
|
||||
|
||||
luaA_object_emit_signal(L, udx, "property::screen", 0);
|
||||
|
||||
|
@ -676,13 +445,6 @@ wibox_attach(lua_State *L, int udx, screen_t *s)
|
|||
screen_emit_signal(L, wibox->screen, "property::workarea", 0);
|
||||
}
|
||||
|
||||
static int
|
||||
luaA_wibox_need_update(lua_State *L)
|
||||
{
|
||||
wibox_need_update(luaA_checkudata(L, 1, &wibox_class));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Create a new wibox.
|
||||
* \param L The Lua VM state.
|
||||
* \return The number of elements pushed on stack.
|
||||
|
@ -717,49 +479,9 @@ luaA_wibox_new(lua_State *L)
|
|||
if(w->type == 0)
|
||||
w->type = _NET_WM_WINDOW_TYPE_NORMAL;
|
||||
|
||||
luaA_object_connect_signal(L, -2, "property::border_width", luaA_wibox_need_update);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** 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)
|
||||
{
|
||||
if(wibox->widgets_table)
|
||||
{
|
||||
luaA_object_push(L, wibox);
|
||||
luaA_object_push_item(L, -1, wibox->widgets_table);
|
||||
lua_remove(L, -2);
|
||||
if(lua_topointer(L, -1) == item || luaA_hasitem(L, item))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** 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)
|
||||
{
|
||||
foreach(w, globalconf.wiboxes)
|
||||
{
|
||||
wibox_t *wibox = *w;
|
||||
if(luaA_wibox_hasitem(L, wibox, item))
|
||||
{
|
||||
/* update wibox */
|
||||
wibox_need_update(wibox);
|
||||
lua_pop(L, 1); /* remove widgets table */
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Set or get the wibox geometry.
|
||||
* \param L The Lua VM state.
|
||||
|
@ -878,8 +600,7 @@ luaA_wibox_set_fg(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.fg, buf, len)))
|
||||
wibox->need_update = true;
|
||||
xcolor_init_reply(xcolor_init_unchecked(&wibox->ctx.fg, buf, len));
|
||||
luaA_object_emit_signal(L, -3, "property::fg", 0);
|
||||
return 0;
|
||||
}
|
||||
|
@ -910,8 +631,6 @@ luaA_wibox_set_bg(lua_State *L, wibox_t *wibox)
|
|||
uint32_t mask = XCB_CW_BACK_PIXEL;
|
||||
uint32_t values[] = { wibox->ctx.bg.pixel };
|
||||
|
||||
wibox->need_update = true;
|
||||
|
||||
if (wibox->window != XCB_NONE)
|
||||
xcb_change_window_attributes(globalconf.connection,
|
||||
wibox->window,
|
||||
|
@ -952,7 +671,6 @@ luaA_wibox_set_bg_image(lua_State *L, wibox_t *wibox)
|
|||
cairo_surface_destroy(wibox->bg_image);
|
||||
wibox->bg_image = draw_dup_image_surface(*cairo_surface);
|
||||
}
|
||||
wibox->need_update = true;
|
||||
luaA_object_emit_signal(L, -3, "property::bg_image", 0);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1058,7 +776,6 @@ luaA_wibox_set_orientation(lua_State *L, wibox_t *wibox)
|
|||
if(buf)
|
||||
{
|
||||
wibox_set_orientation(L, -3, orientation_fromstr(buf));
|
||||
wibox_need_update(wibox);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1087,39 +804,6 @@ luaA_wibox_set_visible(lua_State *L, wibox_t *wibox)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/** 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);
|
||||
luaA_object_unref_item(L, -4, wibox->widgets_table);
|
||||
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);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** 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)
|
||||
{
|
||||
|
@ -1144,10 +828,6 @@ wibox_class_setup(lua_State *L)
|
|||
NULL,
|
||||
luaA_class_index_miss_property, luaA_class_newindex_miss_property,
|
||||
wibox_methods, wibox_meta);
|
||||
luaA_class_add_property(&wibox_class, "widgets",
|
||||
(lua_class_propfunc_t) luaA_wibox_set_widgets,
|
||||
(lua_class_propfunc_t) luaA_wibox_get_widgets,
|
||||
(lua_class_propfunc_t) luaA_wibox_set_widgets);
|
||||
luaA_class_add_property(&wibox_class, "visible",
|
||||
(lua_class_propfunc_t) luaA_wibox_set_visible,
|
||||
(lua_class_propfunc_t) luaA_wibox_get_visible,
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
#ifndef AWESOME_OBJECTS_WIBOX_H
|
||||
#define AWESOME_OBJECTS_WIBOX_H
|
||||
|
||||
#include "objects/widget.h"
|
||||
#include "objects/window.h"
|
||||
#include "common/luaobject.h"
|
||||
#include "draw.h"
|
||||
|
||||
/** Wibox type */
|
||||
struct wibox_t
|
||||
|
@ -34,13 +34,6 @@ struct wibox_t
|
|||
bool ontop;
|
||||
/** Visible */
|
||||
bool visible;
|
||||
/** Widget list */
|
||||
widget_node_array_t widgets;
|
||||
void *widgets_table;
|
||||
/** Widget the mouse is over */
|
||||
widget_t *mouse_over;
|
||||
/** Need update */
|
||||
bool need_update;
|
||||
/** Cursor */
|
||||
char *cursor;
|
||||
/** Background image */
|
||||
|
@ -53,18 +46,11 @@ struct wibox_t
|
|||
draw_context_t ctx;
|
||||
/** Orientation */
|
||||
orientation_t orientation;
|
||||
/** Has wibox an attached systray **/
|
||||
bool has_systray;
|
||||
};
|
||||
|
||||
void wibox_unref_simplified(wibox_t **);
|
||||
|
||||
ARRAY_FUNCS(wibox_t *, wibox, wibox_unref_simplified)
|
||||
void wibox_widget_node_array_wipe(lua_State *, int);
|
||||
|
||||
void wibox_refresh(void);
|
||||
|
||||
void luaA_wibox_invalidate_byitem(lua_State *, const void *);
|
||||
|
||||
wibox_t * wibox_getbywin(xcb_window_t);
|
||||
|
||||
|
@ -74,7 +60,5 @@ void wibox_class_setup(lua_State *);
|
|||
|
||||
lua_class_t wibox_class;
|
||||
|
||||
void wibox_clear_mouse_over(wibox_t *);
|
||||
|
||||
#endif
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||
|
|
594
objects/widget.c
594
objects/widget.c
|
@ -1,594 +0,0 @@
|
|||
/*
|
||||
* widget.c - widget managing
|
||||
*
|
||||
* Copyright © 2007-2009 Julien Danjou <julien@danjou.info>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/xcb_atom.h>
|
||||
|
||||
#include "screen.h"
|
||||
#include "mouse.h"
|
||||
#include "widget.h"
|
||||
#include "wibox.h"
|
||||
#include "client.h"
|
||||
#include "luaa.h"
|
||||
#include "common/atoms.h"
|
||||
#include "common/xutil.h"
|
||||
|
||||
LUA_OBJECT_FUNCS(widget_class, widget_t, widget);
|
||||
|
||||
static void
|
||||
widget_wipe(widget_t *widget)
|
||||
{
|
||||
if(widget->destructor)
|
||||
widget->destructor(widget);
|
||||
button_array_wipe(&widget->buttons);
|
||||
}
|
||||
|
||||
/** Get a widget node from a wibox by coords.
|
||||
* \param orientation Wibox orientation.
|
||||
* \param widgets The widget list.
|
||||
* \param width The container width.
|
||||
* \param height The container height.
|
||||
* \param x X coordinate of the widget.
|
||||
* \param y Y coordinate of the widget.
|
||||
* \return A widget.
|
||||
*/
|
||||
widget_t *
|
||||
widget_getbycoords(orientation_t orientation, widget_node_array_t *widgets,
|
||||
int width, int height, int16_t *x, int16_t *y)
|
||||
{
|
||||
int tmp;
|
||||
|
||||
/* Need to transform coordinates like it was top/bottom */
|
||||
switch(orientation)
|
||||
{
|
||||
case South:
|
||||
tmp = *y;
|
||||
*y = width - *x;
|
||||
*x = tmp;
|
||||
break;
|
||||
case North:
|
||||
tmp = *y;
|
||||
*y = *x;
|
||||
*x = height - tmp;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
foreach(w, *widgets)
|
||||
if(w->widget->isvisible
|
||||
&& *x >= w->geometry.x && *x < w->geometry.x + w->geometry.width
|
||||
&& *y >= w->geometry.y && *y < w->geometry.y + w->geometry.height)
|
||||
return w->widget;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** Convert a Lua table to a list of widget nodes.
|
||||
* \param L The Lua VM state.
|
||||
* \param idx Index of the table where to store the widgets references.
|
||||
* \param widgets The linked list of widget node.
|
||||
*/
|
||||
static void
|
||||
luaA_table2widgets(lua_State *L, int idx, widget_node_array_t *widgets)
|
||||
{
|
||||
if(lua_istable(L, -1))
|
||||
{
|
||||
int table_idx = luaA_absindex(L, idx);
|
||||
int i = 1;
|
||||
lua_pushnumber(L, i++);
|
||||
lua_gettable(L, -2);
|
||||
while(!lua_isnil(L, -1))
|
||||
{
|
||||
luaA_table2widgets(L, table_idx, widgets);
|
||||
lua_pushnumber(L, i++);
|
||||
lua_gettable(L, -2);
|
||||
}
|
||||
|
||||
/* remove the nil and the table */
|
||||
lua_pop(L, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
widget_t *widget = luaA_toudata(L, -1, &widget_class);
|
||||
if(widget)
|
||||
{
|
||||
widget_node_t w;
|
||||
p_clear(&w, 1);
|
||||
w.widget = luaA_object_ref_item(L, idx, -1);
|
||||
widget_node_array_append(widgets, w);
|
||||
}
|
||||
else
|
||||
lua_pop(L, 1); /* remove value */
|
||||
}
|
||||
}
|
||||
|
||||
/** Retrieve a list of widget geometries using a Lua layout function.
|
||||
* a table which contains the geometries is then pushed onto the stack
|
||||
* \param wibox The wibox.
|
||||
* \return True is everything is ok, false otherwise.
|
||||
*/
|
||||
static bool
|
||||
widget_geometries(wibox_t *wibox)
|
||||
{
|
||||
/* get the layout field of the widget table */
|
||||
if(wibox->widgets_table)
|
||||
{
|
||||
/* push wibox */
|
||||
luaA_object_push(globalconf.L, wibox);
|
||||
/* push widgets table */
|
||||
luaA_object_push_item(globalconf.L, -1, wibox->widgets_table);
|
||||
/* remove wibox */
|
||||
lua_remove(globalconf.L, -2);
|
||||
/* get layout field from the table */
|
||||
lua_getfield(globalconf.L, -1, "layout");
|
||||
/* remove the widget table */
|
||||
lua_remove(globalconf.L, -2);
|
||||
}
|
||||
else
|
||||
lua_pushnil(globalconf.L);
|
||||
|
||||
/* if the layout field is a function */
|
||||
if(lua_isfunction(globalconf.L, -1))
|
||||
{
|
||||
/* Push 1st argument: wibox geometry */
|
||||
area_t geometry = wibox->geometry;
|
||||
geometry.x = 0;
|
||||
geometry.y = 0;
|
||||
/* we need to exchange the width and height of the wibox window if it
|
||||
* it is rotated, so the layout function doesn't need to care about that
|
||||
*/
|
||||
if(wibox->orientation != East)
|
||||
{
|
||||
int i = geometry.height;
|
||||
geometry.height = geometry.width;
|
||||
geometry.width = i;
|
||||
}
|
||||
luaA_pusharea(globalconf.L, geometry);
|
||||
/* Push 2nd argument: widget table */
|
||||
luaA_object_push(globalconf.L, wibox);
|
||||
luaA_object_push_item(globalconf.L, -1, wibox->widgets_table);
|
||||
lua_remove(globalconf.L, -2);
|
||||
/* Push 3rd argument: wibox screen */
|
||||
lua_pushnumber(globalconf.L, screen_array_indexof(&globalconf.screens, wibox->screen) + 1);
|
||||
/* Re-push the layout function */
|
||||
lua_pushvalue(globalconf.L, -4);
|
||||
/* call the layout function with 3 arguments (wibox geometry, widget
|
||||
* table, screen) and wait for one result */
|
||||
if(!luaA_dofunction(globalconf.L, 3, 1))
|
||||
return false;
|
||||
|
||||
/* Remove the left over layout function */
|
||||
lua_remove(globalconf.L, -2);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Remove the "nil function" */
|
||||
lua_pop(globalconf.L, 1);
|
||||
|
||||
/* If no layout function has been specified, we just push a table with
|
||||
* geometries onto the stack. These geometries are nothing fancy, they
|
||||
* have x = y = 0 and their height and width set to the widgets demands
|
||||
* or the wibox size, depending on which is less.
|
||||
*/
|
||||
|
||||
/* push wibox */
|
||||
luaA_object_push(globalconf.L, wibox);
|
||||
|
||||
widget_node_array_t *widgets = &wibox->widgets;
|
||||
wibox_widget_node_array_wipe(globalconf.L, -1);
|
||||
widget_node_array_init(widgets);
|
||||
|
||||
/* push widgets table */
|
||||
luaA_object_push_item(globalconf.L, -1, wibox->widgets_table);
|
||||
/* Convert widgets table */
|
||||
luaA_table2widgets(globalconf.L, -2, widgets);
|
||||
/* remove wibox */
|
||||
lua_remove(globalconf.L, -1);
|
||||
|
||||
lua_newtable(globalconf.L);
|
||||
for(int i = 0; i < widgets->len; i++)
|
||||
{
|
||||
lua_pushnumber(globalconf.L, i + 1);
|
||||
widget_t *widget = widgets->tab[i].widget;
|
||||
lua_pushnumber(globalconf.L, screen_array_indexof(&globalconf.screens, wibox->screen) + 1);
|
||||
area_t geometry = widget->extents(globalconf.L, widget);
|
||||
lua_pop(globalconf.L, 1);
|
||||
geometry.x = geometry.y = 0;
|
||||
geometry.width = MIN(wibox->geometry.width, geometry.width);
|
||||
geometry.height = MIN(wibox->geometry.height, geometry.height);
|
||||
|
||||
luaA_pusharea(globalconf.L, geometry);
|
||||
|
||||
lua_settable(globalconf.L, -3);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Render a list of widgets.
|
||||
* \param wibox The wibox.
|
||||
* \todo Remove GC.
|
||||
*/
|
||||
void
|
||||
widget_render(wibox_t *wibox)
|
||||
{
|
||||
lua_State *L = globalconf.L;
|
||||
draw_context_t *ctx = &wibox->ctx;
|
||||
area_t rectangle = { 0, 0, 0, 0 };
|
||||
color_t col;
|
||||
|
||||
rectangle.width = ctx->width;
|
||||
rectangle.height = ctx->height;
|
||||
|
||||
if (!widget_geometries(wibox))
|
||||
return;
|
||||
|
||||
if(ctx->bg.alpha != 0xffff)
|
||||
{
|
||||
int x = wibox->geometry.x + wibox->border_width,
|
||||
y = wibox->geometry.y + wibox->border_width;
|
||||
xcb_get_property_reply_t *prop_r;
|
||||
char *data;
|
||||
xcb_pixmap_t rootpix;
|
||||
xcb_get_property_cookie_t prop_c;
|
||||
xcb_screen_t *s = globalconf.screen;
|
||||
prop_c = xcb_get_property_unchecked(globalconf.connection, false, s->root, _XROOTPMAP_ID,
|
||||
XCB_ATOM_PIXMAP, 0, 1);
|
||||
if((prop_r = xcb_get_property_reply(globalconf.connection, prop_c, NULL)))
|
||||
{
|
||||
if(prop_r->value_len
|
||||
&& (data = xcb_get_property_value(prop_r))
|
||||
&& (rootpix = *(xcb_pixmap_t *) data))
|
||||
switch(wibox->orientation)
|
||||
{
|
||||
case North:
|
||||
draw_rotate(ctx,
|
||||
rootpix, ctx->pixmap,
|
||||
s->width_in_pixels, s->height_in_pixels,
|
||||
ctx->width, ctx->height,
|
||||
M_PI_2,
|
||||
y + ctx->width,
|
||||
- x);
|
||||
break;
|
||||
case South:
|
||||
draw_rotate(ctx,
|
||||
rootpix, ctx->pixmap,
|
||||
s->width_in_pixels, s->height_in_pixels,
|
||||
ctx->width, ctx->height,
|
||||
- M_PI_2,
|
||||
- y,
|
||||
x + ctx->height);
|
||||
break;
|
||||
case East:
|
||||
xcb_copy_area(globalconf.connection, rootpix,
|
||||
wibox->pixmap, globalconf.gc,
|
||||
x, y,
|
||||
0, 0,
|
||||
ctx->width, ctx->height);
|
||||
break;
|
||||
}
|
||||
p_delete(&prop_r);
|
||||
}
|
||||
}
|
||||
|
||||
widget_node_array_t *widgets = &wibox->widgets;
|
||||
|
||||
/* push wibox */
|
||||
luaA_object_push(globalconf.L, wibox);
|
||||
|
||||
wibox_widget_node_array_wipe(globalconf.L, -1);
|
||||
widget_node_array_init(widgets);
|
||||
|
||||
/* push widgets table */
|
||||
luaA_object_push_item(globalconf.L, -1, wibox->widgets_table);
|
||||
luaA_table2widgets(L, -2, widgets);
|
||||
/* remove wibox */
|
||||
lua_remove(globalconf.L, -1);
|
||||
|
||||
size_t num_widgets = lua_objlen(L, -1);
|
||||
if(lua_objlen(L, -1) != (size_t) widgets->len)
|
||||
{
|
||||
warn("Widget layout returned wrong number of geometries. Got %d widgets and %lu geometries.",
|
||||
widgets->len, (unsigned long) lua_objlen(L, -1));
|
||||
/* Set num_widgets to min(widgets->len, lua_objlen(L, -1)); */
|
||||
if(num_widgets > (size_t) widgets->len)
|
||||
num_widgets = widgets->len;
|
||||
}
|
||||
|
||||
/* get computed geometries */
|
||||
for(size_t i = 0; i < num_widgets; i++)
|
||||
{
|
||||
lua_pushnumber(L, i + 1);
|
||||
lua_gettable(L, -2);
|
||||
|
||||
widgets->tab[i].geometry.x = luaA_getopt_number(L, -1, "x", wibox->geometry.x);
|
||||
widgets->tab[i].geometry.y = luaA_getopt_number(L, -1, "y", wibox->geometry.y);
|
||||
widgets->tab[i].geometry.width = luaA_getopt_number(L, -1, "width", 1);
|
||||
widgets->tab[i].geometry.height = luaA_getopt_number(L, -1, "height", 1);
|
||||
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
/* draw background image, only if the background color is not opaque */
|
||||
if(wibox->bg_image && ctx->bg.alpha != 0xffff)
|
||||
draw_surface(ctx, 0, 0, 1.0, wibox->bg_image);
|
||||
|
||||
/* draw background color */
|
||||
xcolor_to_color(&ctx->bg, &col);
|
||||
draw_rectangle(ctx, rectangle, 1.0, true, &col);
|
||||
|
||||
/* draw everything! */
|
||||
for(int i = 0; i < widgets->len; i++)
|
||||
if(widgets->tab[i].widget->isvisible)
|
||||
widgets->tab[i].widget->draw(widgets->tab[i].widget,
|
||||
ctx, widgets->tab[i].geometry, wibox);
|
||||
|
||||
cairo_surface_flush(ctx->surface);
|
||||
|
||||
switch(wibox->orientation)
|
||||
{
|
||||
case South:
|
||||
draw_rotate(ctx, ctx->pixmap, wibox->pixmap,
|
||||
ctx->width, ctx->height,
|
||||
ctx->height, ctx->width,
|
||||
M_PI_2, ctx->height, 0);
|
||||
break;
|
||||
case North:
|
||||
draw_rotate(ctx, ctx->pixmap, wibox->pixmap,
|
||||
ctx->width, ctx->height,
|
||||
ctx->height, ctx->width,
|
||||
- M_PI_2, 0, ctx->width);
|
||||
break;
|
||||
case East:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** Invalidate widgets which should be refresh depending on their types.
|
||||
* \param type Widget type to invalidate.
|
||||
*/
|
||||
void
|
||||
widget_invalidate_bytype(widget_constructor_t *type)
|
||||
{
|
||||
foreach(wibox, globalconf.wiboxes)
|
||||
foreach(wnode, (*wibox)->widgets)
|
||||
if(wnode->widget->type == type)
|
||||
{
|
||||
(*wibox)->need_update = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** Set a wibox needs update because it has widget.
|
||||
* \param widget The widget to look for.
|
||||
*/
|
||||
void
|
||||
widget_invalidate_bywidget(widget_t *widget)
|
||||
{
|
||||
foreach(wibox, globalconf.wiboxes)
|
||||
if(!(*wibox)->need_update)
|
||||
foreach(wnode, (*wibox)->widgets)
|
||||
if(wnode->widget == widget)
|
||||
{
|
||||
(*wibox)->need_update = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** Create a new widget.
|
||||
* \param L The Lua VM state.
|
||||
*
|
||||
* \luastack
|
||||
* \lparam A table with at least a type value.
|
||||
* \lreturn A brand new widget.
|
||||
*/
|
||||
static int
|
||||
luaA_widget_new(lua_State *L)
|
||||
{
|
||||
luaA_class_new(L, &widget_class);
|
||||
|
||||
widget_t *w = luaA_checkudata(L, -1, &widget_class);
|
||||
/* Set visible by default. */
|
||||
w->isvisible = true;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** Get or set mouse buttons bindings to a widget.
|
||||
* \param L The Lua VM state.
|
||||
*
|
||||
* \luastack
|
||||
* \lvalue A widget.
|
||||
* \lparam An array of mouse button bindings objects, or nothing.
|
||||
* \return The array of mouse button bindings objects of this widget.
|
||||
*/
|
||||
static int
|
||||
luaA_widget_buttons(lua_State *L)
|
||||
{
|
||||
widget_t *widget = luaA_checkudata(L, 1, &widget_class);
|
||||
|
||||
if(lua_gettop(L) == 2)
|
||||
{
|
||||
luaA_button_array_set(L, 1, 2, &widget->buttons);
|
||||
luaA_object_emit_signal(L, 1, "property::buttons", 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return luaA_button_array_get(L, 1, &widget->buttons);
|
||||
}
|
||||
|
||||
/** Generic widget.
|
||||
* \param L The Lua VM state.
|
||||
* \return The number of elements pushed on stack.
|
||||
* \luastack
|
||||
* \lfield visible The widget visibility.
|
||||
* \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.
|
||||
*/
|
||||
static int
|
||||
luaA_widget_index(lua_State *L)
|
||||
{
|
||||
const char *prop = luaL_checkstring(L, 2);
|
||||
|
||||
/* Try standard method */
|
||||
if(luaA_class_index(L))
|
||||
return 1;
|
||||
|
||||
/* Then call special widget index */
|
||||
widget_t *widget = luaA_checkudata(L, 1, &widget_class);
|
||||
return widget->index ? widget->index(L, prop) : 0;
|
||||
}
|
||||
|
||||
/** Generic widget newindex.
|
||||
* \param L The Lua VM state.
|
||||
* \return The number of elements pushed on stack.
|
||||
*/
|
||||
static int
|
||||
luaA_widget_newindex(lua_State *L)
|
||||
{
|
||||
const char *prop = luaL_checkstring(L, 2);
|
||||
|
||||
/* Try standard method */
|
||||
luaA_class_newindex(L);
|
||||
|
||||
/* Then call special widget newindex */
|
||||
widget_t *widget = luaA_checkudata(L, 1, &widget_class);
|
||||
return widget->newindex ? widget->newindex(L, prop) : 0;
|
||||
}
|
||||
|
||||
static int
|
||||
luaA_widget_extents(lua_State *L)
|
||||
{
|
||||
widget_t *widget = luaA_checkudata(L, 1, &widget_class);
|
||||
area_t g = {
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.width = 0,
|
||||
.height = 0
|
||||
};
|
||||
|
||||
if(widget->extents)
|
||||
g = widget->extents(L, widget);
|
||||
|
||||
lua_newtable(L);
|
||||
lua_pushnumber(L, g.width);
|
||||
lua_setfield(L, -2, "width");
|
||||
lua_pushnumber(L, g.height);
|
||||
lua_setfield(L, -2, "height");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
luaA_widget_get_type(lua_State *L, widget_t *w)
|
||||
{
|
||||
if (w->type == widget_textbox) lua_pushstring(L, "textbox");
|
||||
else if (w->type == widget_systray) lua_pushstring(L, "systray");
|
||||
else if (w->type == widget_imagebox) lua_pushstring(L, "imagebox");
|
||||
else lua_pushstring(L, "unknown");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
luaA_widget_set_type(lua_State *L, widget_t *w)
|
||||
{
|
||||
const char *type = luaL_checkstring(L, -1);
|
||||
widget_constructor_t *wc = NULL;
|
||||
|
||||
if(a_strcmp(type, "textbox") == 0)
|
||||
wc = widget_textbox;
|
||||
else if(a_strcmp(type, "systray") == 0)
|
||||
wc = widget_systray;
|
||||
else if(a_strcmp(type, "imagebox") == 0)
|
||||
wc = widget_imagebox;
|
||||
|
||||
if(!wc)
|
||||
luaL_error(L, "unknown widget type: %s", type);
|
||||
|
||||
wc(w);
|
||||
w->type = wc;
|
||||
luaA_object_emit_signal(L, -3, "property::type", 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
luaA_widget_get_visible(lua_State *L, widget_t *w)
|
||||
{
|
||||
lua_pushboolean(L, w->isvisible);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
luaA_widget_set_visible(lua_State *L, widget_t *w)
|
||||
{
|
||||
w->isvisible = luaA_checkboolean(L, -1);
|
||||
widget_invalidate_bywidget(w);
|
||||
luaA_object_emit_signal(L, -3, "property::visible", 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
widget_class_setup(lua_State *L)
|
||||
{
|
||||
static const struct luaL_reg widget_methods[] =
|
||||
{
|
||||
LUA_CLASS_METHODS(widget)
|
||||
{ "__call", luaA_widget_new },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static const struct luaL_reg widget_meta[] =
|
||||
{
|
||||
LUA_OBJECT_META(widget)
|
||||
{ "buttons", luaA_widget_buttons },
|
||||
{ "extents", luaA_widget_extents },
|
||||
{ "__index", luaA_widget_index },
|
||||
{ "__newindex", luaA_widget_newindex },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
luaA_class_setup(L, &widget_class, "widget", NULL,
|
||||
(lua_class_allocator_t) widget_new,
|
||||
(lua_class_collector_t) widget_wipe,
|
||||
NULL, NULL, NULL,
|
||||
widget_methods, widget_meta);
|
||||
luaA_class_add_property(&widget_class, "visible",
|
||||
(lua_class_propfunc_t) luaA_widget_set_visible,
|
||||
(lua_class_propfunc_t) luaA_widget_get_visible,
|
||||
(lua_class_propfunc_t) luaA_widget_set_visible);
|
||||
luaA_class_add_property(&widget_class, "type",
|
||||
(lua_class_propfunc_t) luaA_widget_set_type,
|
||||
(lua_class_propfunc_t) luaA_widget_get_type,
|
||||
NULL);
|
||||
|
||||
signal_add(&widget_class.signals, "mouse::enter");
|
||||
signal_add(&widget_class.signals, "mouse::leave");
|
||||
signal_add(&widget_class.signals, "property::buttons");
|
||||
signal_add(&widget_class.signals, "property::type");
|
||||
signal_add(&widget_class.signals, "property::visible");
|
||||
}
|
||||
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
* widget.h - widget managing header
|
||||
*
|
||||
* Copyright © 2007-2009 Julien Danjou <julien@danjou.info>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AWESOME_OBJECTS_WIDGET_H
|
||||
#define AWESOME_OBJECTS_WIDGET_H
|
||||
|
||||
#include "button.h"
|
||||
#include "draw.h"
|
||||
|
||||
typedef widget_t *(widget_constructor_t)(widget_t *);
|
||||
typedef void (widget_destructor_t)(widget_t *);
|
||||
typedef struct widget_node widget_node_t;
|
||||
|
||||
/** Widget */
|
||||
struct widget_t
|
||||
{
|
||||
LUA_OBJECT_HEADER
|
||||
/** Widget type is constructor */
|
||||
widget_constructor_t *type;
|
||||
/** Widget destructor */
|
||||
widget_destructor_t *destructor;
|
||||
/** Extents function */
|
||||
area_t (*extents)(lua_State *, widget_t *);
|
||||
/** Draw function */
|
||||
void (*draw)(widget_t *, draw_context_t *, area_t, wibox_t *);
|
||||
/** Index function */
|
||||
int (*index)(lua_State *, const char *);
|
||||
/** Newindex function */
|
||||
int (*newindex)(lua_State *, const char *);
|
||||
/** Misc private data */
|
||||
void *data;
|
||||
/** Button bindings */
|
||||
button_array_t buttons;
|
||||
/** True if the widget is visible */
|
||||
bool isvisible;
|
||||
};
|
||||
|
||||
struct widget_node
|
||||
{
|
||||
/** The widget object */
|
||||
widget_t *widget;
|
||||
/** The geometry where the widget was drawn */
|
||||
area_t geometry;
|
||||
};
|
||||
DO_ARRAY(widget_node_t, widget_node, DO_NOTHING)
|
||||
|
||||
widget_t *widget_getbycoords(orientation_t, widget_node_array_t *, int, int, int16_t *, int16_t *);
|
||||
void widget_render(wibox_t *);
|
||||
|
||||
void widget_invalidate_bywidget(widget_t *);
|
||||
void widget_invalidate_bytype(widget_constructor_t *);
|
||||
|
||||
lua_class_t widget_class;
|
||||
void widget_class_setup(lua_State *);
|
||||
|
||||
widget_constructor_t widget_textbox;
|
||||
widget_constructor_t widget_systray;
|
||||
widget_constructor_t widget_imagebox;
|
||||
|
||||
#endif
|
||||
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
|
@ -1,187 +0,0 @@
|
|||
/*
|
||||
* imagebox.c - imagebox widget
|
||||
*
|
||||
* Copyright © 2008-2009 Julien Danjou <julien@danjou.info>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "objects/widget.h"
|
||||
#include "luaa.h"
|
||||
|
||||
/** The imagebox private data structure */
|
||||
typedef struct
|
||||
{
|
||||
/** Imagebox image */
|
||||
cairo_surface_t *image;
|
||||
color_t bg;
|
||||
bool resize;
|
||||
} imagebox_data_t;
|
||||
|
||||
static area_t
|
||||
imagebox_extents(lua_State *L, widget_t *widget)
|
||||
{
|
||||
area_t geometry = { .x = 0, .y = 0 };
|
||||
imagebox_data_t *d = widget->data;
|
||||
|
||||
if(d->image)
|
||||
{
|
||||
geometry.width = cairo_image_surface_get_width(d->image);
|
||||
geometry.height = cairo_image_surface_get_height(d->image);
|
||||
}
|
||||
else
|
||||
{
|
||||
geometry.width = 0;
|
||||
geometry.height = 0;
|
||||
}
|
||||
|
||||
return geometry;
|
||||
}
|
||||
|
||||
/** Draw an image.
|
||||
* \param widget The widget.
|
||||
* \param ctx The draw context.
|
||||
* \param geometry The geometry we draw in.
|
||||
* \param p A pointer to the object we're draw onto.
|
||||
*/
|
||||
static void
|
||||
imagebox_draw(widget_t *widget, draw_context_t *ctx, area_t geometry, wibox_t *p)
|
||||
{
|
||||
imagebox_data_t *d = widget->data;
|
||||
|
||||
if(d->image && geometry.width && geometry.height)
|
||||
{
|
||||
if(d->bg.initialized)
|
||||
draw_rectangle(ctx, geometry, 1.0, true, &d->bg);
|
||||
|
||||
double ratio = d->resize ? (double) geometry.height / cairo_image_surface_get_height(d->image) : 1;
|
||||
draw_surface(ctx, geometry.x, geometry.y, ratio, d->image);
|
||||
}
|
||||
}
|
||||
|
||||
/** Delete a imagebox widget.
|
||||
* \param w The widget to destroy.
|
||||
*/
|
||||
static void
|
||||
imagebox_destructor(widget_t *w)
|
||||
{
|
||||
imagebox_data_t *d = w->data;
|
||||
if(d->image)
|
||||
cairo_surface_destroy(d->image);
|
||||
p_delete(&d);
|
||||
}
|
||||
|
||||
static int
|
||||
imagebox_set_image(lua_State *L, widget_t *widget, int idx)
|
||||
{
|
||||
imagebox_data_t *d = widget->data;
|
||||
|
||||
if(lua_isnil(L, idx))
|
||||
{
|
||||
if(d->image)
|
||||
cairo_surface_destroy(d->image);
|
||||
d->image = NULL;
|
||||
} else {
|
||||
cairo_surface_t **cairo_surface = (cairo_surface_t **)luaL_checkudata(L, idx, OOCAIRO_MT_NAME_SURFACE);
|
||||
if(d->image)
|
||||
cairo_surface_destroy(d->image);
|
||||
d->image = draw_dup_image_surface(*cairo_surface);
|
||||
}
|
||||
|
||||
widget_invalidate_bywidget(widget);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Imagebox widget.
|
||||
* \param L The Lua VM state.
|
||||
* \param prop The key that is being indexed.
|
||||
* \param resize Resize image.
|
||||
* \return The number of elements pushed on stack.
|
||||
* \luastack
|
||||
* \lfield image The image to display.
|
||||
* \lfield bg The background color to use.
|
||||
*/
|
||||
static int
|
||||
luaA_imagebox_index(lua_State *L, const char *prop)
|
||||
{
|
||||
widget_t *widget = luaA_checkudata(L, 1, &widget_class);
|
||||
imagebox_data_t *d = widget->data;
|
||||
|
||||
if(a_strcmp(prop, "image") == 0)
|
||||
oocairo_surface_push(L, d->image);
|
||||
else if(a_strcmp(prop, "bg") == 0)
|
||||
luaA_pushcolor(L, &d->bg);
|
||||
else if(a_strcmp(prop, "resize") == 0)
|
||||
lua_pushboolean(L, d->resize);
|
||||
else
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** The __newindex method for a imagebox object.
|
||||
* \param L The Lua VM state.
|
||||
* \param token The key token.
|
||||
* \return The number of elements pushed on stack.
|
||||
*/
|
||||
static int
|
||||
luaA_imagebox_newindex(lua_State *L, const char *prop)
|
||||
{
|
||||
widget_t *widget = luaA_checkudata(L, 1, &widget_class);
|
||||
imagebox_data_t *d = widget->data;
|
||||
|
||||
if(a_strcmp(prop, "image") == 0)
|
||||
imagebox_set_image(L, widget, 3);
|
||||
else if(a_strcmp(prop, "bg") == 0)
|
||||
{
|
||||
const char *buf;
|
||||
size_t len;
|
||||
if(lua_isnil(L, 3))
|
||||
p_clear(&d->bg, 1);
|
||||
else if((buf = luaL_checklstring(L, 3, &len)))
|
||||
color_init_unchecked(&d->bg, buf, len);
|
||||
}
|
||||
else if(a_strcmp(prop, "resize") == 0)
|
||||
d->resize = luaA_checkboolean(L, 3);
|
||||
else
|
||||
return 0;
|
||||
|
||||
widget_invalidate_bywidget(widget);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/** Create a new imagebox widget.
|
||||
* \param w The widget to initialize.
|
||||
* \return A brand new widget.
|
||||
*/
|
||||
widget_t *
|
||||
widget_imagebox(widget_t *w)
|
||||
{
|
||||
imagebox_data_t *d;
|
||||
w->draw = imagebox_draw;
|
||||
w->index = luaA_imagebox_index;
|
||||
w->newindex = luaA_imagebox_newindex;
|
||||
w->destructor = imagebox_destructor;
|
||||
w->extents = imagebox_extents;
|
||||
w->data = d = p_new(imagebox_data_t, 1);
|
||||
d->resize = true;
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
|
@ -1,109 +0,0 @@
|
|||
/*
|
||||
* systray.c - systray widget
|
||||
*
|
||||
* Copyright © 2008-2009 Julien Danjou <julien@danjou.info>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/xcb_atom.h>
|
||||
|
||||
#include "objects/widget.h"
|
||||
#include "screen.h"
|
||||
#include "objects/wibox.h"
|
||||
#include "luaa.h"
|
||||
#include "globalconf.h"
|
||||
#include "common/xembed.h"
|
||||
#include "common/atoms.h"
|
||||
|
||||
#define _NET_SYSTEM_TRAY_ORIENTATION_HORZ 0
|
||||
#define _NET_SYSTEM_TRAY_ORIENTATION_VERT 1
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* systray height */
|
||||
int height;
|
||||
} systray_data_t;
|
||||
|
||||
static area_t
|
||||
systray_extents(lua_State *L, widget_t *widget)
|
||||
{
|
||||
int screen = luaL_optnumber(L, -1, 1) - 1;
|
||||
luaA_checkscreen(screen);
|
||||
|
||||
area_t geometry;
|
||||
int n = 0;
|
||||
systray_data_t *d = widget->data;
|
||||
|
||||
for(int i = 0; i < globalconf.embedded.len; i++)
|
||||
n++;
|
||||
|
||||
/** \todo use class hints */
|
||||
geometry.width = d->height * n;
|
||||
geometry.height = d->height;
|
||||
geometry.x = geometry.y = 0;
|
||||
|
||||
return geometry;
|
||||
}
|
||||
|
||||
static void
|
||||
systray_draw(widget_t *widget, draw_context_t *ctx,
|
||||
area_t geometry, wibox_t *p)
|
||||
{
|
||||
uint32_t orient = _NET_SYSTEM_TRAY_ORIENTATION_HORZ;
|
||||
|
||||
systray_data_t *d = widget->data;
|
||||
|
||||
if (p->orientation == East)
|
||||
d->height = p->geometry.height;
|
||||
else
|
||||
d->height = p->geometry.width;
|
||||
|
||||
/* set wibox orientation */
|
||||
/** \todo stop setting that property on each redraw */
|
||||
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
|
||||
globalconf.systray.window,
|
||||
_NET_SYSTEM_TRAY_ORIENTATION, XCB_ATOM_CARDINAL, 32, 1, &orient);
|
||||
}
|
||||
|
||||
/** Delete a systray widget.
|
||||
* \param w The widget to destroy.
|
||||
*/
|
||||
static void
|
||||
systray_destructor(widget_t *w)
|
||||
{
|
||||
systray_data_t *d = w->data;
|
||||
p_delete(&d);
|
||||
}
|
||||
|
||||
/** Initialize a systray widget.
|
||||
* \param w The widget to initialize.
|
||||
* \return The same widget.
|
||||
*/
|
||||
widget_t *
|
||||
widget_systray(widget_t *w)
|
||||
{
|
||||
w->draw = systray_draw;
|
||||
w->extents = systray_extents;
|
||||
w->destructor = systray_destructor;
|
||||
|
||||
systray_data_t *d = w->data = p_new(systray_data_t, 1);
|
||||
d->height = 0;
|
||||
|
||||
return w;
|
||||
}
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
|
@ -1,480 +0,0 @@
|
|||
/*
|
||||
* textbox.c - text box widget
|
||||
*
|
||||
* Copyright © 2007-2009 Julien Danjou <julien@danjou.info>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "objects/widget.h"
|
||||
#include "luaa.h"
|
||||
|
||||
/** Padding type */
|
||||
typedef struct
|
||||
{
|
||||
/** Padding at top */
|
||||
int top;
|
||||
/** Padding at bottom */
|
||||
int bottom;
|
||||
/** Padding at left */
|
||||
int left;
|
||||
/** Padding at right */
|
||||
int right;
|
||||
} padding_t;
|
||||
|
||||
/** The textbox private data structure */
|
||||
typedef struct
|
||||
{
|
||||
/** The actual text the textbox is set to */
|
||||
char *text;
|
||||
/** The length of text */
|
||||
size_t text_len;
|
||||
draw_text_context_t data;
|
||||
/** Textbox width and height */
|
||||
int width, height;
|
||||
/** Extents */
|
||||
area_t extents;
|
||||
PangoEllipsizeMode ellip;
|
||||
PangoWrapMode wrap;
|
||||
/** Border */
|
||||
struct
|
||||
{
|
||||
int width;
|
||||
color_t color;
|
||||
} border;
|
||||
/** Text alignment */
|
||||
alignment_t align, valign;
|
||||
/** Margin */
|
||||
padding_t margin;
|
||||
/** Background color */
|
||||
color_t bg;
|
||||
/** Background image */
|
||||
cairo_surface_t *bg_image;
|
||||
/** Background resize to wibox height. */
|
||||
bool bg_resize;
|
||||
/** Background alignment */
|
||||
alignment_t bg_align;
|
||||
} textbox_data_t;
|
||||
|
||||
/** Get an optional padding table from a Lua table.
|
||||
* \param L The Lua VM state.
|
||||
* \param idx The table index on the stack.
|
||||
* \param dpadding The default padding value to use.
|
||||
*/
|
||||
static inline padding_t
|
||||
luaA_getopt_padding(lua_State *L, int idx, padding_t *dpadding)
|
||||
{
|
||||
padding_t padding;
|
||||
|
||||
luaA_checktable(L, idx);
|
||||
|
||||
padding.right = luaA_getopt_number(L, idx, "right", dpadding->right);
|
||||
padding.left = luaA_getopt_number(L, idx, "left", dpadding->left);
|
||||
padding.top = luaA_getopt_number(L, idx, "top", dpadding->top);
|
||||
padding.bottom = luaA_getopt_number(L, idx, "bottom", dpadding->bottom);
|
||||
|
||||
return padding;
|
||||
}
|
||||
|
||||
|
||||
/** Push a padding structure into a table on the Lua stack.
|
||||
* \param L The Lua VM state.
|
||||
* \param padding The padding struct pointer.
|
||||
* \return The number of elements pushed on stack.
|
||||
*/
|
||||
static inline int
|
||||
luaA_pushpadding(lua_State *L, padding_t *padding)
|
||||
{
|
||||
lua_createtable(L, 0, 4);
|
||||
lua_pushnumber(L, padding->right);
|
||||
lua_setfield(L, -2, "right");
|
||||
lua_pushnumber(L, padding->left);
|
||||
lua_setfield(L, -2, "left");
|
||||
lua_pushnumber(L, padding->top);
|
||||
lua_setfield(L, -2, "top");
|
||||
lua_pushnumber(L, padding->bottom);
|
||||
lua_setfield(L, -2, "bottom");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static area_t
|
||||
textbox_extents(lua_State *L, widget_t *widget)
|
||||
{
|
||||
textbox_data_t *d = widget->data;
|
||||
area_t geometry = d->extents;
|
||||
geometry.width += d->margin.left + d->margin.left;
|
||||
geometry.height += d->margin.bottom + d->margin.top;
|
||||
|
||||
if(d->width)
|
||||
geometry.width = d->width;
|
||||
|
||||
if(d->height)
|
||||
geometry.width = d->height;
|
||||
|
||||
if(d->bg_image)
|
||||
{
|
||||
int bgi_height = cairo_image_surface_get_height(d->bg_image);
|
||||
int bgi_width = cairo_image_surface_get_width(d->bg_image);
|
||||
double ratio = d->bg_resize ? (double) geometry.height / bgi_height : 1;
|
||||
geometry.width = MAX(d->extents.width + d->margin.left + d->margin.right, MAX(d->width, bgi_width * ratio));
|
||||
}
|
||||
|
||||
geometry.x = geometry.y = 0;
|
||||
|
||||
return geometry;
|
||||
}
|
||||
|
||||
/** Draw a textbox widget.
|
||||
* \param widget The widget.
|
||||
* \param ctx The draw context.
|
||||
* \param p A pointer to the object we're draw onto.
|
||||
*/
|
||||
static void
|
||||
textbox_draw(widget_t *widget, draw_context_t *ctx, area_t geometry, wibox_t *p)
|
||||
{
|
||||
textbox_data_t *d = widget->data;
|
||||
|
||||
if(d->bg.initialized)
|
||||
draw_rectangle(ctx, geometry, 1.0, true, &d->bg);
|
||||
|
||||
if(d->border.width > 0)
|
||||
draw_rectangle(ctx, geometry, d->border.width, false, &d->border.color);
|
||||
|
||||
if(d->bg_image)
|
||||
{
|
||||
int bgi_height = cairo_image_surface_get_height(d->bg_image);
|
||||
int bgi_width = cairo_image_surface_get_width(d->bg_image);
|
||||
double ratio = d->bg_resize ? (double) geometry.height / bgi_height : 1;
|
||||
/* check there is enough space to draw the image */
|
||||
if(ratio * bgi_width <= geometry.width)
|
||||
{
|
||||
int x = geometry.x;
|
||||
int y = geometry.y;
|
||||
switch(d->bg_align)
|
||||
{
|
||||
case AlignCenter:
|
||||
x += (geometry.width - bgi_width * ratio) / 2;
|
||||
break;
|
||||
case AlignRight:
|
||||
x += geometry.width - bgi_width * ratio;
|
||||
break;
|
||||
case AlignBottom:
|
||||
y += geometry.height - bgi_height * ratio;
|
||||
break;
|
||||
case AlignMiddle:
|
||||
y += (geometry.height - bgi_height * ratio) / 2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
draw_surface(ctx, x, y, ratio, d->bg_image);
|
||||
}
|
||||
}
|
||||
|
||||
geometry.x += d->margin.left;
|
||||
geometry.y += d->margin.top;
|
||||
|
||||
int margin_width = d->margin.left + d->margin.right;
|
||||
if(margin_width <= geometry.width)
|
||||
geometry.width -= d->margin.left + d->margin.right;
|
||||
else
|
||||
geometry.width = 0;
|
||||
|
||||
int margin_height = d->margin.top + d->margin.bottom;
|
||||
if(margin_height <= geometry.height)
|
||||
geometry.height -= d->margin.top + d->margin.bottom;
|
||||
else
|
||||
geometry.height = 0;
|
||||
|
||||
draw_text(ctx, &d->data, d->ellip, d->wrap, d->align, d->valign, geometry);
|
||||
}
|
||||
|
||||
/** Delete a textbox widget.
|
||||
* \param w The widget to destroy.
|
||||
*/
|
||||
static void
|
||||
textbox_destructor(widget_t *w)
|
||||
{
|
||||
textbox_data_t *d = w->data;
|
||||
draw_text_context_wipe(&d->data);
|
||||
if(d->bg_image)
|
||||
cairo_surface_destroy(d->bg_image);
|
||||
p_delete(&d->text);
|
||||
p_delete(&d);
|
||||
}
|
||||
|
||||
static int
|
||||
luaA_textbox_margin(lua_State *L)
|
||||
{
|
||||
widget_t *widget = luaA_checkudata(L, 1, &widget_class);
|
||||
textbox_data_t *d = widget->data;
|
||||
|
||||
if(lua_gettop(L) == 2)
|
||||
{
|
||||
d->margin = luaA_getopt_padding(L, 2, &d->margin);
|
||||
widget_invalidate_bywidget(widget);
|
||||
}
|
||||
|
||||
return luaA_pushpadding(L, &d->margin);
|
||||
}
|
||||
|
||||
/** Textbox widget.
|
||||
* \param L The Lua VM state.
|
||||
* \param prop The property's name.
|
||||
* \return The number of elements pushed on stack.
|
||||
* \luastack
|
||||
* \lfield text The text to display.
|
||||
* \lfield width The width of the textbox. Set to 0 for auto.
|
||||
* \lfield wrap The wrap mode: word, char, word_char.
|
||||
* \lfield ellipsize The ellipsize mode: start, middle or end.
|
||||
* \lfield border_width The border width to draw around.
|
||||
* \lfield border_color The border color.
|
||||
* \lfield align Text alignment, left, center or right.
|
||||
* \lfield margin Method to pass text margin: a table with top, left, right and bottom keys.
|
||||
* \lfield bg Background color.
|
||||
* \lfield bg_image Background image.
|
||||
* \lfield bg_align Background image alignment, left, center, right, bottom, top or middle
|
||||
* \lfield bg_resize Background resize.
|
||||
*/
|
||||
static int
|
||||
luaA_textbox_index(lua_State *L, const char *prop)
|
||||
{
|
||||
widget_t *widget = luaA_checkudata(L, 1, &widget_class);
|
||||
textbox_data_t *d = widget->data;
|
||||
|
||||
if(a_strcmp(prop, "bg_resize") == 0)
|
||||
lua_pushboolean(L, d->bg_resize);
|
||||
else if(a_strcmp(prop, "bg_align") == 0)
|
||||
lua_pushstring(L, draw_align_tostr(d->bg_align));
|
||||
else if(a_strcmp(prop, "bg_image") == 0)
|
||||
return oocairo_surface_push(L, d->bg_image);
|
||||
else if(a_strcmp(prop, "bg") == 0)
|
||||
return luaA_pushcolor(L, &d->bg);
|
||||
else if(a_strcmp(prop, "margin") == 0)
|
||||
lua_pushcfunction(L, luaA_textbox_margin);
|
||||
else if(a_strcmp(prop, "align") == 0)
|
||||
lua_pushstring(L, draw_align_tostr(d->align));
|
||||
else if(a_strcmp(prop, "valign") == 0)
|
||||
lua_pushstring(L, draw_align_tostr(d->valign));
|
||||
else if(a_strcmp(prop, "border_width") == 0)
|
||||
lua_pushnumber(L, d->border.width);
|
||||
else if(a_strcmp(prop, "border_color") == 0)
|
||||
luaA_pushcolor(L, &d->border.color);
|
||||
else if(a_strcmp(prop, "text") == 0)
|
||||
{
|
||||
if(d->text_len > 0)
|
||||
{
|
||||
lua_pushlstring(L, d->text, d->text_len);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else if(a_strcmp(prop, "width") == 0)
|
||||
lua_pushnumber(L, d->width);
|
||||
else if(a_strcmp(prop, "height") == 0)
|
||||
lua_pushnumber(L, d->height);
|
||||
else if(a_strcmp(prop, "wrap") == 0)
|
||||
switch(d->wrap)
|
||||
{
|
||||
default:
|
||||
lua_pushliteral(L, "word");
|
||||
break;
|
||||
case PANGO_WRAP_CHAR:
|
||||
lua_pushliteral(L, "char");
|
||||
break;
|
||||
case PANGO_WRAP_WORD_CHAR:
|
||||
lua_pushliteral(L, "word_char");
|
||||
break;
|
||||
}
|
||||
else if(a_strcmp(prop, "ellipsize") == 0)
|
||||
switch(d->ellip)
|
||||
{
|
||||
case PANGO_ELLIPSIZE_START:
|
||||
lua_pushliteral(L, "start");
|
||||
break;
|
||||
case PANGO_ELLIPSIZE_MIDDLE:
|
||||
lua_pushliteral(L, "middle");
|
||||
break;
|
||||
default:
|
||||
lua_pushliteral(L, "end");
|
||||
break;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** The __newindex method for a textbox object.
|
||||
* \param L The Lua VM state.
|
||||
* \param token The key token.
|
||||
* \return The number of elements pushed on stack.
|
||||
*/
|
||||
static int
|
||||
luaA_textbox_newindex(lua_State *L, const char *prop)
|
||||
{
|
||||
size_t len = 0;
|
||||
widget_t *widget = luaA_checkudata(L, 1, &widget_class);
|
||||
const char *buf = NULL;
|
||||
textbox_data_t *d = widget->data;
|
||||
|
||||
if(a_strcmp(prop, "bg_align") == 0)
|
||||
{
|
||||
buf = luaL_checkstring(L, 3);
|
||||
d->bg_align = draw_align_fromstr(buf);
|
||||
}
|
||||
else if(a_strcmp(prop, "bg_resize") == 0)
|
||||
d->bg_resize = luaA_checkboolean(L, 3);
|
||||
else if(a_strcmp(prop, "bg_image") == 0)
|
||||
{
|
||||
if(lua_isnil(L, -1))
|
||||
{
|
||||
cairo_surface_destroy(d->bg_image);
|
||||
d->bg_image = NULL;
|
||||
} else {
|
||||
cairo_surface_t **cairo_surface = (cairo_surface_t **)luaL_checkudata(L, -1, OOCAIRO_MT_NAME_SURFACE);
|
||||
cairo_surface_destroy(d->bg_image);
|
||||
d->bg_image = draw_dup_image_surface(*cairo_surface);
|
||||
}
|
||||
}
|
||||
else if(a_strcmp(prop, "bg") == 0)
|
||||
{
|
||||
if(lua_isnil(L, 3))
|
||||
p_clear(&d->bg, 1);
|
||||
else if((buf = luaL_checklstring(L, 3, &len)))
|
||||
color_init_unchecked(&d->bg, buf, len);
|
||||
}
|
||||
else if(a_strcmp(prop, "align") == 0)
|
||||
{
|
||||
if((buf = luaL_checkstring(L, 3)))
|
||||
d->align = draw_align_fromstr(buf);
|
||||
}
|
||||
else if(a_strcmp(prop, "valign") == 0)
|
||||
{
|
||||
if((buf = luaL_checkstring(L, 3)))
|
||||
d->valign = draw_align_fromstr(buf);
|
||||
}
|
||||
else if(a_strcmp(prop, "border_color") == 0)
|
||||
{
|
||||
if((buf = luaL_checklstring(L, 3, &len)))
|
||||
color_init_unchecked(&d->border.color, buf, len);
|
||||
}
|
||||
else if(a_strcmp(prop, "border_width") == 0)
|
||||
d->border.width = luaL_checknumber(L, 3);
|
||||
else if(a_strcmp(prop, "text") == 0)
|
||||
{
|
||||
if(lua_isnil(L, 3)
|
||||
|| (buf = luaL_checklstring(L, 3, &len)))
|
||||
{
|
||||
/* delete */
|
||||
draw_text_context_wipe(&d->data);
|
||||
p_delete(&d->text);
|
||||
d->text_len = 0;
|
||||
p_clear(&d->data, 1);
|
||||
|
||||
if(buf)
|
||||
{
|
||||
char *text;
|
||||
ssize_t tlen;
|
||||
bool success;
|
||||
|
||||
/* if text has been converted to UTF-8 */
|
||||
if(draw_iso2utf8(buf, len, &text, &tlen))
|
||||
{
|
||||
success = draw_text_context_init(&d->data, text, tlen);
|
||||
if(success)
|
||||
{
|
||||
d->text = p_dup(text, tlen);
|
||||
d->text_len = tlen;
|
||||
}
|
||||
p_delete(&text);
|
||||
}
|
||||
else
|
||||
{
|
||||
success = draw_text_context_init(&d->data, buf, len);
|
||||
if(success)
|
||||
{
|
||||
d->text = p_dup(buf, len);
|
||||
d->text_len = len;
|
||||
}
|
||||
}
|
||||
|
||||
d->extents = draw_text_extents(&d->data);
|
||||
|
||||
if(!success)
|
||||
luaL_error(L, "Invalid markup in '%s'", buf);
|
||||
}
|
||||
else
|
||||
p_clear(&d->extents, 1);
|
||||
}
|
||||
}
|
||||
else if(a_strcmp(prop, "width") == 0)
|
||||
d->width = luaL_checknumber(L, 3);
|
||||
else if(a_strcmp(prop, "height") == 0)
|
||||
d->height = luaL_checknumber(L, 3);
|
||||
else if(a_strcmp(prop, "wrap") == 0)
|
||||
{
|
||||
if((buf = luaL_checkstring(L, 3)))
|
||||
{
|
||||
if(a_strcmp(buf, "word") == 0)
|
||||
d->wrap = PANGO_WRAP_WORD;
|
||||
else if(a_strcmp(buf, "char") == 0)
|
||||
d->wrap = PANGO_WRAP_CHAR;
|
||||
else if(a_strcmp(buf, "word_char") == 0)
|
||||
d->wrap = PANGO_WRAP_WORD_CHAR;
|
||||
}
|
||||
}
|
||||
else if(a_strcmp(prop, "ellipsize") == 0)
|
||||
{
|
||||
if((buf = luaL_checkstring(L, 3)))
|
||||
{
|
||||
if(a_strcmp(buf, "start") == 0)
|
||||
d->ellip = PANGO_ELLIPSIZE_START;
|
||||
else if(a_strcmp(buf, "middle") == 0)
|
||||
d->ellip = PANGO_ELLIPSIZE_MIDDLE;
|
||||
else if(a_strcmp(buf, "end") == 0)
|
||||
d->ellip = PANGO_ELLIPSIZE_END;
|
||||
}
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
|
||||
widget_invalidate_bywidget(widget);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Create a new textbox widget.
|
||||
* \param w The widget to initialize.
|
||||
* \return A brand new widget.
|
||||
*/
|
||||
widget_t *
|
||||
widget_textbox(widget_t *w)
|
||||
{
|
||||
w->draw = textbox_draw;
|
||||
w->index = luaA_textbox_index;
|
||||
w->newindex = luaA_textbox_newindex;
|
||||
w->destructor = textbox_destructor;
|
||||
w->extents = textbox_extents;
|
||||
|
||||
textbox_data_t *d = w->data = p_new(textbox_data_t, 1);
|
||||
d->ellip = PANGO_ELLIPSIZE_END;
|
||||
d->valign = AlignCenter;
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
|
@ -332,8 +332,11 @@ static int
|
|||
property_handle_xrootpmap_id(uint8_t state,
|
||||
xcb_window_t window)
|
||||
{
|
||||
#warning
|
||||
#if 0
|
||||
foreach(w, globalconf.wiboxes)
|
||||
(*w)->need_update = true;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
1
screen.c
1
screen.c
|
@ -29,7 +29,6 @@
|
|||
#include "ewmh.h"
|
||||
#include "objects/tag.h"
|
||||
#include "objects/client.h"
|
||||
#include "objects/widget.h"
|
||||
#include "objects/wibox.h"
|
||||
#include "luaa.h"
|
||||
#include "common/xutil.h"
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "screen.h"
|
||||
#include "systray.h"
|
||||
#include "xwindow.h"
|
||||
#include "objects/widget.h"
|
||||
#include "objects/wibox.h"
|
||||
#include "common/array.h"
|
||||
#include "common/atoms.h"
|
||||
|
@ -55,6 +54,8 @@ systray_init(void)
|
|||
void
|
||||
systray_refresh(void)
|
||||
{
|
||||
#warning
|
||||
#if 0
|
||||
bool has_systray = false;
|
||||
foreach(w, globalconf.wiboxes)
|
||||
if((*w)->has_systray)
|
||||
|
@ -65,6 +66,7 @@ systray_refresh(void)
|
|||
systray_register();
|
||||
else
|
||||
systray_cleanup();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -211,8 +213,6 @@ systray_request_handle(xcb_window_t embed_win, xembed_info_t *info)
|
|||
|
||||
xembed_window_array_append(&globalconf.embedded, em);
|
||||
|
||||
widget_invalidate_bytype(widget_systray);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue