From 1332288f9de1affaaad8d292816cdf1b17e645e7 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 13 May 2017 12:10:40 +0200 Subject: [PATCH] screen_client_moveto: Make sure client ends up on target screen This function tried to move the client to its new screen based on shifting around its current geometry. However, it assumed that the client was actually visible on its current screen, which is not always the case. Fix this by just forcing the client into its new screen if our moving approach does not work. This also reverts commit d5e365804ca7823799fbfc85691d12d39e52cd70 which is no longer necessary. This commit only hid the issue (partly). Fixes: https://github.com/awesomeWM/awesome/issues/318 Signed-off-by: Uli Schlachter --- objects/screen.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/objects/screen.c b/objects/screen.c index 533f578e..9ed3db96 100644 --- a/objects/screen.c +++ b/objects/screen.c @@ -914,22 +914,24 @@ screen_client_moveto(client_t *c, screen_t *new_screen, bool doresize) new_geometry.x = to.x + to.width - new_geometry.width; if(new_geometry.y + new_geometry.height > to.y + to.height) new_geometry.y = to.y + to.height - new_geometry.height; + if(!screen_area_in_screen(new_screen, new_geometry)) + { + /* If all else fails, force the client to end up on screen. */ + new_geometry.x = to.x; + new_geometry.y = to.y; + } /* move / resize the client */ client_resize(c, new_geometry, false); - /* Emit signal, but only in case the call to client_resize had not changed - * it already. */ - if(old_screen != c->screen) - { - luaA_object_push(L, c); - if(old_screen != NULL) - luaA_object_push(L, old_screen); - else - lua_pushnil(L); - luaA_object_emit_signal(L, -2, "property::screen", 1); - lua_pop(L, 1); - } + /* emit signal */ + luaA_object_push(L, c); + if(old_screen != NULL) + luaA_object_push(L, old_screen); + else + lua_pushnil(L); + luaA_object_emit_signal(L, -2, "property::screen", 1); + lua_pop(L, 1); if(had_focus) client_focus(c);