diff --git a/client.c b/client.c index da26105b4..70ac1f0d0 100644 --- a/client.c +++ b/client.c @@ -421,7 +421,7 @@ manage(Display *disp, DC *drawcontext, Window w, XWindowAttributes *wa, awesome_ } else { - ScreenInfo *si = get_display_info(disp, c->screen, awesomeconf->statusbar); + ScreenInfo *si = get_display_info(disp, c->screen, &awesomeconf->statusbar); if(c->x + c->w + 2 * c->border > si->x_org + si->width) c->x = c->rx = si->x_org + si->width - c->w - 2 * c->border; @@ -469,6 +469,7 @@ resize(Client * c, int x, int y, int w, int h, Bool sizehints) { double dx, dy, max, min, ratio; XWindowChanges wc; + ScreenInfo *si; if(sizehints) { @@ -513,10 +514,15 @@ resize(Client * c, int x, int y, int w, int h, Bool sizehints) if(w <= 0 || h <= 0) return; /* offscreen appearance fixes */ - if(x > DisplayWidth(c->display, c->screen)) - x = DisplayWidth(c->display, c->screen) - w - 2 * c->border; - if(y > DisplayHeight(c->display, c->screen)) - y = DisplayHeight(c->display, c->screen) - h - 2 * c->border; + if(XineramaIsActive(c->display)) + si = get_display_info(c->display, DefaultScreen(c->display), NULL); + else + si = get_display_info(c->display, c->screen, NULL); + if(x > si->width) + x = si->width - w - 2 * c->border; + if(y > si->height) + y = si->height - h - 2 * c->border; + XFree(si); if(x + w + 2 * c->border < 0) x = 0; if(y + h + 2 * c->border < 0) @@ -531,6 +537,8 @@ resize(Client * c, int x, int y, int w, int h, Bool sizehints) XConfigureWindow(c->display, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc); configure(c); XSync(c->display, False); + if(XineramaIsActive(c->display)) + c->screen = get_screen_bycoord(c->display, c->x, c->y); } } diff --git a/event.c b/event.c index b161768a8..6faf174b1 100644 --- a/event.c +++ b/event.c @@ -54,20 +54,25 @@ getclient(Window w) static void movemouse(Client * c, awesome_config *awesomeconf) { - int x1, y1, ocx, ocy, di, nx, ny; + int x1, y1, ocx, ocy, di, nx, ny, real_screen; unsigned int dui; Window dummy; XEvent ev; ScreenInfo *si; - si = get_screen_info(c->display, c->screen, &awesomeconf->statusbar, &x1); + if(XineramaIsActive(c->display)) + real_screen = DefaultScreen(c->display); + else + real_screen = awesomeconf->screen; + + si = get_display_info(c->display, real_screen, NULL); ocx = nx = c->x; ocy = ny = c->y; - if(XGrabPointer(c->display, RootWindow(c->display, c->screen), False, MOUSEMASK, GrabModeAsync, GrabModeAsync, + if(XGrabPointer(c->display, RootWindow(c->display, real_screen), False, MOUSEMASK, GrabModeAsync, GrabModeAsync, None, dc[c->screen].cursor[CurMove], CurrentTime) != GrabSuccess) return; - XQueryPointer(c->display, RootWindow(c->display, c->screen), &dummy, &dummy, &x1, &y1, &di, &di, &dui); + XQueryPointer(c->display, RootWindow(c->display, real_screen), &dummy, &dummy, &x1, &y1, &di, &di, &dui); for(;;) { XMaskEvent(c->display, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev); @@ -85,14 +90,14 @@ movemouse(Client * c, awesome_config *awesomeconf) XSync(c->display, False); nx = ocx + (ev.xmotion.x - x1); ny = ocy + (ev.xmotion.y - y1); - if(abs(si[c->screen].x_org + nx) < awesomeconf->snap) - nx = si[c->screen].x_org; - else if(abs((si[c->screen].x_org + si[c->screen].width) - (nx + c->w + 2 * c->border)) < awesomeconf->snap) - nx = si[c->screen].x_org + si[c->screen].width - c->w - 2 * c->border; - if(abs(si[c->screen].y_org - ny) < awesomeconf->snap) - ny = si[c->screen].y_org; - else if(abs((si[c->screen].y_org + si[c->screen].height) - (ny + c->h + 2 * c->border)) < awesomeconf->snap) - ny = si[c->screen].y_org + si[c->screen].height - c->h - 2 * c->border; + if(abs(si->x_org + nx) < awesomeconf->snap) + nx = si->x_org; + else if(abs((si->x_org + si->width) - (nx + c->w + 2 * c->border)) < awesomeconf->snap) + nx = si->x_org + si->width - c->w - 2 * c->border; + if(abs(si->y_org - ny) < awesomeconf->snap) + ny = si->y_org; + else if(abs((si->y_org + si->height) - (ny + c->h + 2 * c->border)) < awesomeconf->snap) + ny = si->y_org + si->height - c->h - 2 * c->border; resize(c, nx, ny, c->w, c->h, False); break; }