mouse: fix args for mouse.coords_set()

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-07-01 09:27:34 +02:00
parent eae75c8cef
commit a4e12b1ce0
3 changed files with 25 additions and 13 deletions

View File

@ -346,7 +346,7 @@ function hook_arrange(screen)
if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
if table.maxn(m_c.buttons) == 0 then if table.maxn(m_c.buttons) == 0 then
mouse.coords_set(c_c.x + 5, c_c.y + 5) mouse.coords_set({ x = c_c.x + 5, y = c_c.y + 5})
end end
end end
end end

View File

@ -150,8 +150,7 @@ function P.screen.focus(i)
s = cycle(screen.count(), s + i) s = cycle(screen.count(), s + i)
screen.focus(s) screen.focus(s)
-- Move the mouse on the screen -- Move the mouse on the screen
local screen_coords = screen.coords_get(s) mouse.coords_set(screen.coords_get(s))
mouse.coords_set(screen_coords['x'], screen_coords['y'])
end end
--- Return a table with all visible tags --- Return a table with all visible tags
@ -333,6 +332,7 @@ function P.client.movetoscreen(c, s)
end end
if s > sc then s = 1 elseif s < 1 then s = sc end if s > sc then s = 1 elseif s < 1 then s = sc end
sel:screen_set(s) sel:screen_set(s)
mouse.coords_set(screen.coords_get(s))
end end
end end

32
mouse.c
View File

@ -990,23 +990,28 @@ luaA_mouse_coords_get(lua_State *L)
lua_pushnumber(L, mouse_y); lua_pushnumber(L, mouse_y);
lua_setfield(L, -2, "y"); lua_setfield(L, -2, "y");
lua_newtable(L); lua_newtable(L);
if (mask & XCB_BUTTON_MASK_1) { if (mask & XCB_BUTTON_MASK_1)
{
lua_pushnumber(L, 1); lua_pushnumber(L, 1);
lua_rawseti(L, -2, ++i); lua_rawseti(L, -2, ++i);
} }
if (mask & XCB_BUTTON_MASK_2) { if (mask & XCB_BUTTON_MASK_2)
{
lua_pushnumber(L, 2); lua_pushnumber(L, 2);
lua_rawseti(L, -2, ++i); lua_rawseti(L, -2, ++i);
} }
if (mask & XCB_BUTTON_MASK_3) { if (mask & XCB_BUTTON_MASK_3)
{
lua_pushnumber(L, 3); lua_pushnumber(L, 3);
lua_rawseti(L, -2, ++i); lua_rawseti(L, -2, ++i);
} }
if (mask & XCB_BUTTON_MASK_4) { if (mask & XCB_BUTTON_MASK_4)
{
lua_pushnumber(L, 4); lua_pushnumber(L, 4);
lua_rawseti(L, -2, ++i); lua_rawseti(L, -2, ++i);
} }
if (mask & XCB_BUTTON_MASK_5) { if (mask & XCB_BUTTON_MASK_5)
{
lua_pushnumber(L, 5); lua_pushnumber(L, 5);
lua_rawseti(L, -2, ++i); lua_rawseti(L, -2, ++i);
} }
@ -1018,17 +1023,24 @@ luaA_mouse_coords_get(lua_State *L)
* \param L The Lua VM state. * \param L The Lua VM state.
* *
* \luastack * \luastack
* \lparam The x coordinate. * \lparam The x and y coordinate in a table.
* \lparam The y coordinate.
*/ */
static int static int
luaA_mouse_coords_set(lua_State *L) luaA_mouse_coords_set(lua_State *L)
{ {
int x, y; int x, y, mouse_x, mouse_y;
xcb_window_t root; xcb_window_t root;
uint16_t mask;
x = luaL_checknumber(L, 1); luaA_checktable(L, 1);
y = luaL_checknumber(L, 2);
root = xutil_screen_get(globalconf.connection, globalconf.default_screen)->root;
if(!mouse_query_pointer(root, &mouse_x, &mouse_y, &mask))
return 0;
x = luaA_getopt_number(L, 1, "x", mouse_x);
y = luaA_getopt_number(L, 1, "y", mouse_y);
root = xutil_screen_get(globalconf.connection, globalconf.default_screen)->root; root = xutil_screen_get(globalconf.connection, globalconf.default_screen)->root;
mouse_warp_pointer(root, x, y); mouse_warp_pointer(root, x, y);