mouse: coords() get silent parameter
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
21223cabd9
commit
50690e7a48
|
@ -11,6 +11,7 @@ module("mouse")
|
||||||
|
|
||||||
--- Get or set the mouse coords.
|
--- Get or set the mouse coords.
|
||||||
-- @param coords_table None or a table with x and y keys as mouse coordinates.
|
-- @param coords_table None or a table with x and y keys as mouse coordinates.
|
||||||
|
-- @param silent Disable mouse::enter or mouse::leave events that could be triggered by the pointer when moving.
|
||||||
-- @return A table with mouse coordinates.
|
-- @return A table with mouse coordinates.
|
||||||
-- @name coords
|
-- @name coords
|
||||||
-- @class function
|
-- @class function
|
||||||
|
|
14
mouse.c
14
mouse.c
|
@ -199,9 +199,6 @@ luaA_mouse_pushstatus(lua_State *L, int x, int y, uint16_t mask)
|
||||||
/** Get or set the mouse coords.
|
/** Get or set the mouse coords.
|
||||||
* \param L The Lua VM state.
|
* \param L The Lua VM state.
|
||||||
* \return The number of elements pushed on stack.
|
* \return The number of elements pushed on stack.
|
||||||
* \luastack
|
|
||||||
* \lparam None or a table with x and y keys as mouse coordinates.
|
|
||||||
* \lreturn A table with mouse coordinates.
|
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
luaA_mouse_coords(lua_State *L)
|
luaA_mouse_coords(lua_State *L)
|
||||||
|
@ -211,11 +208,12 @@ luaA_mouse_coords(lua_State *L)
|
||||||
int16_t mouse_x, mouse_y;
|
int16_t mouse_x, mouse_y;
|
||||||
screen_t *screen;
|
screen_t *screen;
|
||||||
|
|
||||||
if(lua_gettop(L) == 1)
|
if(lua_gettop(L) >= 1)
|
||||||
{
|
{
|
||||||
xcb_window_t root;
|
xcb_window_t root;
|
||||||
|
|
||||||
luaA_checktable(L, 1);
|
luaA_checktable(L, 1);
|
||||||
|
bool ignore_enter_notify = (lua_gettop(L) == 2 && luaA_checkboolean(L, 2));
|
||||||
|
|
||||||
if(!mouse_query_pointer_root(&screen, &mouse_x, &mouse_y, NULL, &mask))
|
if(!mouse_query_pointer_root(&screen, &mouse_x, &mouse_y, NULL, &mask))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -225,7 +223,15 @@ luaA_mouse_coords(lua_State *L)
|
||||||
|
|
||||||
root = xutil_screen_get(globalconf.connection,
|
root = xutil_screen_get(globalconf.connection,
|
||||||
screen_array_indexof(&globalconf.screens, screen))->root;
|
screen_array_indexof(&globalconf.screens, screen))->root;
|
||||||
|
|
||||||
|
if(ignore_enter_notify)
|
||||||
|
client_ignore_enterleave_events();
|
||||||
|
|
||||||
mouse_warp_pointer(root, x, y);
|
mouse_warp_pointer(root, x, y);
|
||||||
|
|
||||||
|
if(ignore_enter_notify)
|
||||||
|
client_restore_enterleave_events();
|
||||||
|
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue