wibox: add mouse_enter and mouse_leave for wibox
Signed-off-by: Gregor Best <farhaven@googlemail.com> Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
d2fc646590
commit
10bfb36d4b
26
event.c
26
event.c
|
@ -472,6 +472,9 @@ event_handle_leavenotify(void *data __attribute__ ((unused)),
|
||||||
}
|
}
|
||||||
wibox->mouse_over = NULL;
|
wibox->mouse_over = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(wibox->mouse_leave != LUA_REFNIL)
|
||||||
|
luaA_dofunction(globalconf.L, wibox->mouse_leave, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -489,7 +492,6 @@ event_handle_enternotify(void *data __attribute__ ((unused)),
|
||||||
{
|
{
|
||||||
client_t *c;
|
client_t *c;
|
||||||
xembed_window_t *emwin;
|
xembed_window_t *emwin;
|
||||||
wibox_t *wibox;
|
|
||||||
widget_t *w;
|
widget_t *w;
|
||||||
|
|
||||||
if(ev->mode != XCB_NOTIFY_MODE_NORMAL
|
if(ev->mode != XCB_NOTIFY_MODE_NORMAL
|
||||||
|
@ -497,16 +499,22 @@ event_handle_enternotify(void *data __attribute__ ((unused)),
|
||||||
&& ev->root_y == globalconf.pointer_y))
|
&& ev->root_y == globalconf.pointer_y))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
wibox_t *wibox = wibox_getbywin(ev->event);
|
||||||
|
|
||||||
if((wibox = wibox_getbywin(ev->event))
|
if(wibox)
|
||||||
&& (w = widget_getbycoords(wibox->position, &wibox->widgets,
|
|
||||||
wibox->sw.geometry.width,
|
|
||||||
wibox->sw.geometry.height,
|
|
||||||
&ev->event_x, &ev->event_y)))
|
|
||||||
{
|
{
|
||||||
globalconf.pointer_x = ev->root_x;
|
if((w = widget_getbycoords(wibox->position, &wibox->widgets,
|
||||||
globalconf.pointer_y = ev->root_y;
|
wibox->sw.geometry.width,
|
||||||
event_handle_widget_motionnotify(wibox, &wibox->mouse_over, w);
|
wibox->sw.geometry.height,
|
||||||
|
&ev->event_x, &ev->event_y)))
|
||||||
|
{
|
||||||
|
globalconf.pointer_x = ev->root_x;
|
||||||
|
globalconf.pointer_y = ev->root_y;
|
||||||
|
event_handle_widget_motionnotify(wibox, &wibox->mouse_over, w);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(wibox->mouse_enter != LUA_REFNIL)
|
||||||
|
luaA_dofunction(globalconf.L, wibox->mouse_enter, 0, 0);
|
||||||
}
|
}
|
||||||
else if((c = client_getbytitlebarwin(ev->event))
|
else if((c = client_getbytitlebarwin(ev->event))
|
||||||
|| (c = client_getbywin(ev->event)))
|
|| (c = client_getbywin(ev->event)))
|
||||||
|
|
|
@ -102,6 +102,8 @@ typedef struct
|
||||||
luaA_ref widgets_table;
|
luaA_ref widgets_table;
|
||||||
/** Widget the mouse is over */
|
/** Widget the mouse is over */
|
||||||
widget_t *mouse_over;
|
widget_t *mouse_over;
|
||||||
|
/** Mouse over event handler */
|
||||||
|
luaA_ref mouse_enter, mouse_leave;
|
||||||
/** Need update */
|
/** Need update */
|
||||||
bool need_update;
|
bool need_update;
|
||||||
/** Cursor */
|
/** Cursor */
|
||||||
|
|
24
wibox.c
24
wibox.c
|
@ -467,6 +467,8 @@ wibox_delete(wibox_t **wibox)
|
||||||
simplewindow_wipe(&(*wibox)->sw);
|
simplewindow_wipe(&(*wibox)->sw);
|
||||||
button_array_wipe(&(*wibox)->buttons);
|
button_array_wipe(&(*wibox)->buttons);
|
||||||
luaL_unref(globalconf.L, LUA_REGISTRYINDEX, (*wibox)->widgets_table);
|
luaL_unref(globalconf.L, LUA_REGISTRYINDEX, (*wibox)->widgets_table);
|
||||||
|
luaL_unref(globalconf.L, LUA_REGISTRYINDEX, (*wibox)->mouse_enter);
|
||||||
|
luaL_unref(globalconf.L, LUA_REGISTRYINDEX, (*wibox)->mouse_leave);
|
||||||
widget_node_array_wipe(&(*wibox)->widgets);
|
widget_node_array_wipe(&(*wibox)->widgets);
|
||||||
p_delete(wibox);
|
p_delete(wibox);
|
||||||
}
|
}
|
||||||
|
@ -736,6 +738,8 @@ luaA_wibox_new(lua_State *L)
|
||||||
w->isvisible = true;
|
w->isvisible = true;
|
||||||
w->cursor = a_strdup("left_ptr");
|
w->cursor = a_strdup("left_ptr");
|
||||||
|
|
||||||
|
w->mouse_enter = w->mouse_leave = LUA_REFNIL;
|
||||||
|
|
||||||
for(i = 0; i <= reqs_nbr; i++)
|
for(i = 0; i <= reqs_nbr; i++)
|
||||||
xcolor_init_reply(reqs[i]);
|
xcolor_init_reply(reqs[i]);
|
||||||
|
|
||||||
|
@ -816,6 +820,8 @@ luaA_wibox_invalidate_byitem(lua_State *L, const void *item)
|
||||||
* \lfield position The position.
|
* \lfield position The position.
|
||||||
* \lfield ontop On top of other windows.
|
* \lfield ontop On top of other windows.
|
||||||
* \lfield cursor The mouse cursor.
|
* \lfield cursor The mouse cursor.
|
||||||
|
* \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
|
static int
|
||||||
luaA_wibox_index(lua_State *L)
|
luaA_wibox_index(lua_State *L)
|
||||||
|
@ -886,6 +892,18 @@ luaA_wibox_index(lua_State *L)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case A_TK_MOUSE_ENTER:
|
||||||
|
if((*wibox)->mouse_enter != LUA_REFNIL)
|
||||||
|
lua_rawgeti(L, LUA_REGISTRYINDEX, (*wibox)->mouse_enter);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
case A_TK_MOUSE_LEAVE:
|
||||||
|
if((*wibox)->mouse_leave != LUA_REFNIL)
|
||||||
|
lua_rawgeti(L, LUA_REGISTRYINDEX, (*wibox)->mouse_leave);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1082,6 +1100,12 @@ luaA_wibox_newindex(lua_State *L)
|
||||||
window_opacity_set((*wibox)->sw.window, d);
|
window_opacity_set((*wibox)->sw.window, d);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case A_TK_MOUSE_ENTER:
|
||||||
|
luaA_registerfct(L, 3, &(*wibox)->mouse_enter);
|
||||||
|
return 0;
|
||||||
|
case A_TK_MOUSE_LEAVE:
|
||||||
|
luaA_registerfct(L, 3, &(*wibox)->mouse_leave);
|
||||||
|
return 0;
|
||||||
default:
|
default:
|
||||||
switch((*wibox)->type)
|
switch((*wibox)->type)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue