widget: remove button property
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
0716ecb4fd
commit
a5de5ab48c
25
event.c
25
event.c
|
@ -166,7 +166,30 @@ event_handle_button(void *data, xcb_connection_t *connection, xcb_button_press_e
|
|||
wibox->sw.geometry.width,
|
||||
wibox->sw.geometry.height,
|
||||
&ev->event_x, &ev->event_y)))
|
||||
w->widget->button(w, ev, wibox->screen, wibox);
|
||||
{
|
||||
button_array_t *b = &w->widget->buttons;
|
||||
|
||||
for(int i = 0; i < b->len; i++)
|
||||
if(ev->detail == b->tab[i]->button
|
||||
&& XUTIL_MASK_CLEAN(ev->state) == b->tab[i]->mod)
|
||||
switch(ev->response_type)
|
||||
{
|
||||
case XCB_BUTTON_PRESS:
|
||||
if(b->tab[i]->press != LUA_REFNIL)
|
||||
{
|
||||
luaA_wibox_userdata_new(globalconf.L, wibox);
|
||||
luaA_dofunction(globalconf.L, b->tab[i]->press, 1, 0);
|
||||
}
|
||||
break;
|
||||
case XCB_BUTTON_RELEASE:
|
||||
if(b->tab[i]->release != LUA_REFNIL)
|
||||
{
|
||||
luaA_wibox_userdata_new(globalconf.L, wibox);
|
||||
luaA_dofunction(globalconf.L, b->tab[i]->release, 1, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* return even if no widget match */
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -117,8 +117,6 @@ struct widget_t
|
|||
int (*index)(lua_State *, awesome_token_t);
|
||||
/** Newindex function */
|
||||
int (*newindex)(lua_State *, awesome_token_t);
|
||||
/** Button event handler */
|
||||
void (*button)(widget_node_t *, xcb_button_press_event_t *, int, wibox_t *);
|
||||
/** Mouse over event handler */
|
||||
luaA_ref mouse_enter, mouse_leave;
|
||||
/** Alignement */
|
||||
|
|
38
widget.c
38
widget.c
|
@ -69,43 +69,6 @@ widget_calculate_offset(int barwidth, int widgetwidth, int offset, int alignment
|
|||
return barwidth - offset - widgetwidth;
|
||||
}
|
||||
|
||||
/** Common function for button press event on widget.
|
||||
* It will look into configuration to find the callback function to call.
|
||||
* \param w The widget node.
|
||||
* \param ev The button press event the widget received.
|
||||
* \param screen The screen number.
|
||||
* \param p The object where user clicked.
|
||||
*/
|
||||
static void
|
||||
widget_common_button(widget_node_t *w,
|
||||
xcb_button_press_event_t *ev,
|
||||
int screen __attribute__ ((unused)),
|
||||
wibox_t *p)
|
||||
{
|
||||
button_array_t *b = &w->widget->buttons;
|
||||
|
||||
for(int i = 0; i < b->len; i++)
|
||||
if(ev->detail == b->tab[i]->button
|
||||
&& XUTIL_MASK_CLEAN(ev->state) == b->tab[i]->mod)
|
||||
switch(ev->response_type)
|
||||
{
|
||||
case XCB_BUTTON_PRESS:
|
||||
if(b->tab[i]->press != LUA_REFNIL)
|
||||
{
|
||||
luaA_wibox_userdata_new(globalconf.L, p);
|
||||
luaA_dofunction(globalconf.L, b->tab[i]->press, 1, 0);
|
||||
}
|
||||
break;
|
||||
case XCB_BUTTON_RELEASE:
|
||||
if(b->tab[i]->release != LUA_REFNIL)
|
||||
{
|
||||
luaA_wibox_userdata_new(globalconf.L, p);
|
||||
luaA_dofunction(globalconf.L, b->tab[i]->release, 1, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** Convert a Lua table to a list of widget nodet.
|
||||
* \param L The Lua VM state.
|
||||
* \param widgets The linked list of widget node.
|
||||
|
@ -304,7 +267,6 @@ widget_render(widget_node_array_t *widgets, draw_context_t *ctx, xcb_gcontext_t
|
|||
void
|
||||
widget_common_new(widget_t *widget)
|
||||
{
|
||||
widget->button = widget_common_button;
|
||||
widget->align_supported = AlignLeft | AlignRight;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue