From a4e12b1ce08b468b5cdfed36cf4e5ee63a5144a7 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 1 Jul 2008 09:27:34 +0200 Subject: [PATCH] mouse: fix args for mouse.coords_set() Signed-off-by: Julien Danjou --- awesomerc.lua.in | 2 +- lib/awful.lua | 4 ++-- mouse.c | 32 ++++++++++++++++++++++---------- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/awesomerc.lua.in b/awesomerc.lua.in index ef89235ed..edcf595d8 100644 --- a/awesomerc.lua.in +++ b/awesomerc.lua.in @@ -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 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 - 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 diff --git a/lib/awful.lua b/lib/awful.lua index f449eaa58..bdca1657a 100644 --- a/lib/awful.lua +++ b/lib/awful.lua @@ -150,8 +150,7 @@ function P.screen.focus(i) s = cycle(screen.count(), s + i) screen.focus(s) -- Move the mouse on the screen - local screen_coords = screen.coords_get(s) - mouse.coords_set(screen_coords['x'], screen_coords['y']) + mouse.coords_set(screen.coords_get(s)) end --- Return a table with all visible tags @@ -333,6 +332,7 @@ function P.client.movetoscreen(c, s) end if s > sc then s = 1 elseif s < 1 then s = sc end sel:screen_set(s) + mouse.coords_set(screen.coords_get(s)) end end diff --git a/mouse.c b/mouse.c index 38d3d9c25..a93fbae97 100644 --- a/mouse.c +++ b/mouse.c @@ -990,23 +990,28 @@ luaA_mouse_coords_get(lua_State *L) lua_pushnumber(L, mouse_y); lua_setfield(L, -2, "y"); lua_newtable(L); - if (mask & XCB_BUTTON_MASK_1) { + if (mask & XCB_BUTTON_MASK_1) + { lua_pushnumber(L, 1); lua_rawseti(L, -2, ++i); } - if (mask & XCB_BUTTON_MASK_2) { + if (mask & XCB_BUTTON_MASK_2) + { lua_pushnumber(L, 2); lua_rawseti(L, -2, ++i); } - if (mask & XCB_BUTTON_MASK_3) { + if (mask & XCB_BUTTON_MASK_3) + { lua_pushnumber(L, 3); lua_rawseti(L, -2, ++i); } - if (mask & XCB_BUTTON_MASK_4) { + if (mask & XCB_BUTTON_MASK_4) + { lua_pushnumber(L, 4); lua_rawseti(L, -2, ++i); } - if (mask & XCB_BUTTON_MASK_5) { + if (mask & XCB_BUTTON_MASK_5) + { lua_pushnumber(L, 5); lua_rawseti(L, -2, ++i); } @@ -1018,17 +1023,24 @@ luaA_mouse_coords_get(lua_State *L) * \param L The Lua VM state. * * \luastack - * \lparam The x coordinate. - * \lparam The y coordinate. + * \lparam The x and y coordinate in a table. */ static int luaA_mouse_coords_set(lua_State *L) { - int x, y; + int x, y, mouse_x, mouse_y; xcb_window_t root; + uint16_t mask; - x = luaL_checknumber(L, 1); - y = luaL_checknumber(L, 2); + luaA_checktable(L, 1); + + 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; mouse_warp_pointer(root, x, y);