diff --git a/objects/client.c b/objects/client.c index e58d2b26f..7f39eaed5 100644 --- a/objects/client.c +++ b/objects/client.c @@ -795,7 +795,10 @@ client_resize_do(client_t *c, area_t geometry, bool force_notice, bool honor_hin lua_State *L = globalconf_get_lua_State(); bool send_notice = force_notice; bool hide_titlebars = c->fullscreen; - screen_t *new_screen = screen_getbycoord(geometry.x, geometry.y); + + screen_t *new_screen = c->screen; + if(!screen_coord_in_screen(new_screen, geometry.x, geometry.y)) + new_screen = screen_getbycoord(geometry.x, geometry.y); if (honor_hints) geometry = client_apply_size_hints(c, geometry); diff --git a/objects/screen.c b/objects/screen.c index 5f3af3549..5f7ab3902 100644 --- a/objects/screen.c +++ b/objects/screen.c @@ -285,8 +285,7 @@ screen_scan(void) screen_scan_x11(); } -/** Return the Xinerama screen number where the coordinates belongs to. - * \param screen The logical screen number. +/** Return the first screen number where the coordinates belong to. * \param x X coordinate * \param y Y coordinate * \return Screen pointer or screen param if no match or no multi-head. @@ -295,14 +294,26 @@ screen_t * screen_getbycoord(int x, int y) { foreach(s, globalconf.screens) - if((x < 0 || (x >= (*s)->geometry.x && x < (*s)->geometry.x + (*s)->geometry.width)) - && (y < 0 || (y >= (*s)->geometry.y && y < (*s)->geometry.y + (*s)->geometry.height))) + if(screen_coord_in_screen(*s, x, y)) return *s; /* No screen found, let's be creative. */ return globalconf.screens.tab[0]; } +/** Are the given coordinates in a given screen? + * \param screen The logical screen number. + * \param x X coordinate + * \param y Y coordinate + * \return True if the X/Y coordinates are in the given screen. + */ +bool +screen_coord_in_screen(screen_t *s, int x, int y) +{ + return (x < 0 || (x >= s->geometry.x && x < s->geometry.x + s->geometry.width)) + && (y < 0 || (y >= s->geometry.y && y < s->geometry.y + s->geometry.height)); +} + /** Get screens info. * \param screen Screen. * \param strut Honor windows strut. diff --git a/objects/screen.h b/objects/screen.h index 1e1e4c7cc..009c64d4d 100644 --- a/objects/screen.h +++ b/objects/screen.h @@ -43,6 +43,7 @@ ARRAY_FUNCS(screen_t *, screen, DO_NOTHING) void screen_class_setup(lua_State *L); void screen_scan(void); screen_t *screen_getbycoord(int, int); +bool screen_coord_in_screen(screen_t *, int, int); int screen_get_index(screen_t *); area_t display_area_get(void); void screen_client_moveto(client_t *, screen_t *, bool);