From c57208d1a820a9e11085844a00204e37a35a54cd Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 13 May 2017 12:02:40 +0200 Subject: [PATCH 1/3] client_resize(): Stop trying to force on screen The code here made sure that clients were not moved outside of the root window. However, that's not enough, because clients can still end up inside the root window, but outside of anything that is visible in some output. Thus, just remove this. Related-to: https://github.com/awesomeWM/awesome/issues/318 Signed-off-by: Uli Schlachter --- objects/client.c | 14 -------------- objects/screen.c | 14 -------------- objects/screen.h | 1 - 3 files changed, 29 deletions(-) diff --git a/objects/client.c b/objects/client.c index 1b4d9f6a..0ec571f9 100644 --- a/objects/client.c +++ b/objects/client.c @@ -1743,20 +1743,6 @@ client_resize_do(client_t *c, area_t geometry) bool client_resize(client_t *c, area_t geometry, bool honor_hints) { - area_t area; - - /* offscreen appearance fixes */ - area = display_area_get(); - - if(geometry.x > area.width) - geometry.x = area.width - geometry.width; - if(geometry.y > area.height) - geometry.y = area.height - geometry.height; - if(geometry.x + geometry.width < 0) - geometry.x = 0; - if(geometry.y + geometry.height < 0) - geometry.y = 0; - if (honor_hints) { /* We could get integer underflows in client_remove_titlebar_geometry() * without these checks here. diff --git a/objects/screen.c b/objects/screen.c index 4e50199b..533f578e 100644 --- a/objects/screen.c +++ b/objects/screen.c @@ -859,20 +859,6 @@ void screen_update_workarea(screen_t *screen) lua_pop(L, 1); } -/** Get display info. - * \return The display area. - */ -area_t -display_area_get(void) -{ - xcb_screen_t *s = globalconf.screen; - area_t area = { .x = 0, - .y = 0, - .width = s->width_in_pixels, - .height = s->height_in_pixels }; - return area; -} - /** Move a client to a virtual screen. * \param c The client to move. * \param new_screen The destination screen. diff --git a/objects/screen.h b/objects/screen.h index 45876062..e7d82805 100644 --- a/objects/screen.h +++ b/objects/screen.h @@ -52,7 +52,6 @@ screen_t *screen_getbycoord(int, int); bool screen_coord_in_screen(screen_t *, int, int); bool screen_area_in_screen(screen_t *, area_t); int screen_get_index(screen_t *); -area_t display_area_get(void); void screen_client_moveto(client_t *, screen_t *, bool); void screen_update_primary(void); void screen_update_workarea(screen_t *); From 1332288f9de1affaaad8d292816cdf1b17e645e7 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 13 May 2017 12:10:40 +0200 Subject: [PATCH 2/3] 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); From 498510e81067c719234f194863a6df2073201b14 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 13 May 2017 12:08:40 +0200 Subject: [PATCH 3/3] Add a new disposition to _multi_screen.lua Without the previous commit, this would make test-awful-client.lua fail. Signed-off-by: Uli Schlachter --- tests/_multi_screen.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/_multi_screen.lua b/tests/_multi_screen.lua index ddd578e5..fd10dfea 100644 --- a/tests/_multi_screen.lua +++ b/tests/_multi_screen.lua @@ -248,7 +248,7 @@ local dispositions = { end, }, - -- Corner case 2: Nothing at 0x0. + -- Corner case 2a: Nothing at 0x0. -- As some position may fallback to 0x0 this need to be tested often. It -- also caused issues such as #154 { @@ -270,6 +270,13 @@ local dispositions = { end }, + -- Corner case 2b: Still nothing at 0x0 + { + function() return { x = 0, y = 32, width = 32, height = 32, } end, + function() return { x = 32, y = 0, width = 32, height = 32, } end, + function() return { x = 64, y = 16, width = 32, height = 32, } end, + }, + -- Corner case 3: Many very small screens. -- On the embedded side of the compuverse, it is possible -- to buy 32x32 RGB OLED screens. They are usually used to display single