screen.c: fix movetoscreen for different sized screens

Signed-off-by: Gregor Best <farhaven@googlemail.com>
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Gregor Best 2008-12-07 18:03:36 +01:00 committed by Julien Danjou
parent 39cd86f976
commit bc246c8b84
2 changed files with 51 additions and 66 deletions

View File

@ -705,7 +705,6 @@ client_resize(client_t *c, area_t geometry, bool hints)
values);
window_configure(c->win, geometry, c->border);
if(c->screen != new_screen)
screen_client_moveto(c, new_screen, true, false);
/* execute hook */
@ -1407,7 +1406,6 @@ luaA_client_newindex(lua_State *L)
{
i = luaL_checknumber(L, 3) - 1;
luaA_checkscreen(i);
if(i != (*c)->screen)
screen_client_moveto(*c, i, true, true);
}
break;

View File

@ -309,6 +309,9 @@ screen_client_moveto(client_t *c, int new_screen, bool dotag, bool doresize)
area_t from, to;
bool wasvisible = client_isvisible(c, c->screen);
if(new_screen == c->screen)
return;
c->screen = new_screen;
if(c->titlebar)
@ -326,74 +329,58 @@ screen_client_moveto(client_t *c, int new_screen, bool dotag, bool doresize)
tag_client(c, new_tags->tab[i]);
}
/* move and resize the windows */
if(doresize && old_screen != c->screen)
{
area_t new_geometry, new_f_geometry;
new_f_geometry = c->geometry;
if (!doresize)
return;
to = screen_area_get(c->screen,
NULL, NULL, false);
from = screen_area_get(old_screen,
NULL, NULL, false);
from = screen_area_get(old_screen, NULL, NULL, false);
to = screen_area_get(c->screen, NULL, NULL, false);
/* compute new coords in new screen */
new_f_geometry.x = (c->geometry.x - from.x) + to.x;
new_f_geometry.y = (c->geometry.y - from.y) + to.y;
/* check that new coords are still in the screen */
if(new_f_geometry.width > to.width)
new_f_geometry.width = to.width;
if(new_f_geometry.height > to.height)
new_f_geometry.height = to.height;
if(new_f_geometry.x + new_f_geometry.width >= to.x + to.width)
new_f_geometry.x = to.x + to.width - new_f_geometry.width - 2 * c->border;
if(new_f_geometry.y + new_f_geometry.height >= to.y + to.height)
new_f_geometry.y = to.y + to.height - new_f_geometry.height - 2 * c->border;
area_t new_geometry = c->geometry;
if(c->isfullscreen)
{
new_geometry = c->geometry;
new_geometry = to;
area_t new_f_geometry = c->geometries.fullscreen;
/* compute new coords in new screen */
new_geometry.x = (c->geometry.x - from.x) + to.x;
new_geometry.y = (c->geometry.y - from.y) + to.y;
new_f_geometry.x = to.x + new_f_geometry.x - from.x;
new_f_geometry.y = to.y + new_f_geometry.y - from.x;
/* check that new coords are still in the screen */
if(new_geometry.width > to.width)
new_geometry.width = to.width;
if(new_geometry.height > to.height)
new_geometry.height = to.height;
if(new_geometry.x + new_geometry.width >= to.x + to.width)
new_geometry.x = to.x + to.width - new_geometry.width - 2 * c->border;
if(new_geometry.y + new_geometry.height >= to.y + to.height)
new_geometry.y = to.y + to.height - new_geometry.height - 2 * c->border;
/* resize the client's original geometry if it doesn't fit the screen */
if (new_f_geometry.width > to.width)
new_f_geometry.width = to.width - 2 * c->border;
if (new_f_geometry.height > to.height)
new_f_geometry.height = to.height - 2 * c->border;
/* compute new coords for max in new screen */
c->geometries.fullscreen.x = (c->geometries.fullscreen.x - from.x) + to.x;
c->geometries.fullscreen.y = (c->geometries.fullscreen.y - from.y) + to.y;
/* make sure the client is still on the screen */
if (new_f_geometry.x + new_f_geometry.width > to.x + to.width)
new_f_geometry.x = to.x + to.width - new_f_geometry.width;
if (new_f_geometry.y + new_f_geometry.height > to.y + to.height)
new_f_geometry.y = to.y + to.height - new_f_geometry.height;
/* check that new coords are still in the screen */
if(c->geometries.fullscreen.width > to.width)
c->geometries.fullscreen.width = to.width;
if(c->geometries.fullscreen.height > to.height)
c->geometries.fullscreen.height = to.height;
if(c->geometries.fullscreen.x + c->geometries.fullscreen.width >= to.x + to.width)
c->geometries.fullscreen.x = to.x + to.width - c->geometries.fullscreen.width - 2 * c->border;
if(c->geometries.fullscreen.y + c->geometries.fullscreen.height >= to.y + to.height)
c->geometries.fullscreen.y = to.y + to.height - c->geometries.fullscreen.height - 2 * c->border;
client_resize(c, new_geometry, false);
c->geometries.fullscreen = new_f_geometry;
}
/* move to this new coords */
else
{
client_resize(c, new_f_geometry, false);
new_geometry.x = to.x + new_geometry.x - from.x;
new_geometry.y = to.y + new_geometry.y - from.y;
/* resize the client if it doesn't fit the new screen */
if(new_geometry.width > to.width)
new_geometry.width = to.width - 2 * c->border;
if(new_geometry.height > to.height)
new_geometry.height = to.height - 2 * c->border;
/* make sure the client is still on the screen */
if(new_geometry.x + new_geometry.width > to.x + to.width)
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;
}
/* move / resize the client */
client_resize(c, new_geometry, false);
if(wasvisible)
globalconf.screens[old_screen].need_arrange = true;
client_need_arrange(c);
}
}
}
/** Screen module.