mouse.screen: Lie when we have no clue where the pointer is

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2014-03-06 22:18:35 +01:00
parent 8cf48d1fe8
commit b6bbae084a
1 changed files with 10 additions and 1 deletions

11
mouse.c
View File

@ -109,7 +109,16 @@ luaA_mouse_index(lua_State *L)
return 0; return 0;
if (!mouse_query_pointer_root(&mouse_x, &mouse_y, NULL, NULL)) if (!mouse_query_pointer_root(&mouse_x, &mouse_y, NULL, NULL))
return 0; {
/* Nothing ever handles mouse.screen being nil. Lying is better than
* having lots of lua errors in this case.
*/
if (globalconf.focus.client)
lua_pushnumber(L, screen_array_indexof(&globalconf.screens, globalconf.focus.client->screen) + 1);
else
lua_pushnumber(L, 1);
return 1;
}
screen = screen_getbycoord(mouse_x, mouse_y); screen = screen_getbycoord(mouse_x, mouse_y);
lua_pushnumber(L, screen_array_indexof(&globalconf.screens, screen) + 1); lua_pushnumber(L, screen_array_indexof(&globalconf.screens, screen) + 1);