From b6bbae084aca05f9ad30a0f4eaf7784007c8b65a Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Thu, 6 Mar 2014 22:18:35 +0100 Subject: [PATCH] mouse.screen: Lie when we have no clue where the pointer is Signed-off-by: Uli Schlachter --- mouse.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mouse.c b/mouse.c index f12e3bfc..a78fc7a4 100644 --- a/mouse.c +++ b/mouse.c @@ -109,7 +109,16 @@ luaA_mouse_index(lua_State *L) return 0; 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); lua_pushnumber(L, screen_array_indexof(&globalconf.screens, screen) + 1);