enhance movetoscreen function by computing new x/y/w/h with new screen infos

This commit is contained in:
Julien Danjou 2007-10-19 15:07:46 +02:00
parent cabfc67b87
commit 3afccadae2
1 changed files with 17 additions and 5 deletions

View File

@ -154,20 +154,32 @@ get_phys_screen(Display *disp, int screen)
void void
move_client_to_screen(Client *c, awesome_config *acf_new, Bool doresize) move_client_to_screen(Client *c, awesome_config *acf_new, Bool doresize)
{ {
int i; int i, old_screen = c->screen;
ScreenInfo *si; ScreenInfo *si, *si_old;
c->screen = acf_new->screen; c->screen = acf_new->screen;
p_realloc(&c->tags, acf_new->ntags); p_realloc(&c->tags, acf_new->ntags);
for(i = 0; i < acf_new->ntags; i++) for(i = 0; i < acf_new->ntags; i++)
c->tags[i] = acf_new->tags[i].selected; c->tags[i] = acf_new->tags[i].selected;
si = get_screen_info(c->display, c->screen, &acf_new->statusbar); si = get_screen_info(c->display, c->screen, NULL);
c->rx = si[c->screen].x_org; si_old = get_screen_info(c->display, old_screen, NULL);
c->ry = si[c->screen].y_org; /* 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) if(doresize)
resize(c, c->rx, c->ry, c->rw, c->rh, acf_new, True); resize(c, c->rx, c->ry, c->rw, c->rh, acf_new, True);
p_delete(&si); p_delete(&si);
p_delete(&si_old);
} }
/** Move mouse pointer to x_org and y_xorg of specified screen /** Move mouse pointer to x_org and y_xorg of specified screen