From 3afccadae203821fb15d930225258e5d92d2bb80 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Fri, 19 Oct 2007 15:07:46 +0200 Subject: [PATCH] enhance movetoscreen function by computing new x/y/w/h with new screen infos --- screen.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/screen.c b/screen.c index d44847bd4..a86f39b20 100644 --- a/screen.c +++ b/screen.c @@ -154,20 +154,32 @@ get_phys_screen(Display *disp, int screen) void move_client_to_screen(Client *c, awesome_config *acf_new, Bool doresize) { - int i; - ScreenInfo *si; + int i, old_screen = c->screen; + ScreenInfo *si, *si_old; c->screen = acf_new->screen; p_realloc(&c->tags, acf_new->ntags); for(i = 0; i < acf_new->ntags; i++) c->tags[i] = acf_new->tags[i].selected; - si = get_screen_info(c->display, c->screen, &acf_new->statusbar); - c->rx = si[c->screen].x_org; - c->ry = si[c->screen].y_org; + si = get_screen_info(c->display, c->screen, NULL); + si_old = get_screen_info(c->display, old_screen, NULL); + /* compute new coords in new screen */ + c->rx -= si_old[old_screen].x_org + si[c->screen].x_org; + c->ry -= si_old[old_screen].y_org + si[c->screen].y_org; + /* check that new coords are still in the screen */ + if(c->rw > si[c->screen].width) + c->rw = si[c->screen].width; + if(c->rh > si[c->screen].height) + c->rh = si[c->screen].height; + if(c->rx >= si[c->screen].x_org + si[c->screen].width) + c->rx = si[c->screen].x_org - c->rw; + if(c->ry >= si[c->screen].y_org + si[c->screen].height) + c->ry = si[c->screen].y_org - c->rh; if(doresize) resize(c, c->rx, c->ry, c->rw, c->rh, acf_new, True); p_delete(&si); + p_delete(&si_old); } /** Move mouse pointer to x_org and y_xorg of specified screen