X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=dwm.c;h=66daba3ab4335f000492c390a7a905449e11f8c3;hb=4426032450777e63ac9a8967cd67382497954c51;hp=11f229382b4e7f5dda78914a78597753de07384a;hpb=c2737b7b9317743e3430c71bc0a9afcc6b0f70f7;p=dwm.git diff --git a/dwm.c b/dwm.c index 11f2293..66daba3 100644 --- a/dwm.c +++ b/dwm.c @@ -117,7 +117,6 @@ typedef struct { } Regs; typedef struct { - int monitor; Window barwin; int sx, sy, sw, sh, wax, way, wah, waw; Bool *seltags; @@ -1164,11 +1163,13 @@ void movemouse(Client *c) { int x1, y1, ocx, ocy, di, nx, ny; unsigned int dui; + Monitor *m; Window dummy; XEvent ev; ocx = nx = c->x; ocy = ny = c->y; + m = &monitors[c->monitor]; if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, None, cursor[CurMove], CurrentTime) != GrabSuccess) return; @@ -1188,7 +1189,6 @@ movemouse(Client *c) { XSync(dpy, False); nx = ocx + (ev.xmotion.x - x1); ny = ocy + (ev.xmotion.y - y1); - Monitor *m = &monitors[monitorat()]; if(abs(m->wax - nx) < SNAP) nx = m->wax; else if(abs((m->wax + m->waw) - (nx + c->w + 2 * c->border)) < SNAP) @@ -1197,11 +1197,10 @@ movemouse(Client *c) { ny = m->way; else if(abs((m->way + m->wah) - (ny + c->h + 2 * c->border)) < SNAP) ny = m->way + m->wah - c->h - 2 * c->border; - if((monitors[selmonitor].layout->arrange != floating) && (abs(nx - c->x) > SNAP || abs(ny - c->y) > SNAP)) + if((m->layout->arrange != floating) && (abs(nx - c->x) > SNAP || abs(ny - c->y) > SNAP)) togglefloating(NULL); - if((monitors[selmonitor].layout->arrange == floating) || c->isfloating) + if((m->layout->arrange == floating) || c->isfloating) resize(c, nx, ny, c->w, c->h, False); - memcpy(c->tags, monitors[monitorat()].seltags, sizeof initags); break; } } @@ -1264,9 +1263,10 @@ reapply(const char *arg) { void resize(Client *c, int x, int y, int w, int h, Bool sizehints) { + Monitor *m; XWindowChanges wc; - //Monitor scr = monitors[monitorat()]; -// c->monitor = monitorat(); + + m = &monitors[c->monitor]; if(sizehints) { /* set minimum possible */ @@ -1308,17 +1308,14 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) { } if(w <= 0 || h <= 0) return; - /* TODO: offscreen appearance fixes */ - /* - if(x > scr.sw) - x = scr.sw - w - 2 * c->border; - if(y > scr.sh) - y = scr.sh - h - 2 * c->border; - if(x + w + 2 * c->border < scr.sx) - x = scr.sx; - if(y + h + 2 * c->border < scr.sy) - y = scr.sy; - */ + if(x > m->sw) + x = m->sw - w - 2 * c->border; + if(y > m->sh) + y = m->sh - h - 2 * c->border; + if(x + w + 2 * c->border < m->sx) + x = m->sx; + if(y + h + 2 * c->border < m->sy) + y = m->sy; if(c->x != x || c->y != y || c->w != w || c->h != h) { c->x = wc.x = x; c->y = wc.y = y; @@ -1335,10 +1332,12 @@ void resizemouse(Client *c) { int ocx, ocy; int nw, nh; + Monitor *m; XEvent ev; ocx = c->x; ocy = c->y; + m = &monitors[c->monitor]; if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, None, cursor[CurResize], CurrentTime) != GrabSuccess) return; @@ -1363,9 +1362,9 @@ resizemouse(Client *c) { nw = 1; if((nh = ev.xmotion.y - ocy - 2 * c->border + 1) <= 0) nh = 1; - if((monitors[selmonitor].layout->arrange != floating) && (abs(nw - c->w) > SNAP || abs(nh - c->h) > SNAP)) + if((m->layout->arrange != floating) && (abs(nw - c->w) > SNAP || abs(nh - c->h) > SNAP)) togglefloating(NULL); - if((monitors[selmonitor].layout->arrange == floating) || c->isfloating) + if((m->layout->arrange == floating) || c->isfloating) resize(c, c->x, c->y, nw, nh, True); break; } @@ -1600,8 +1599,6 @@ setup(void) { /* init geometry */ m = &monitors[i]; - m->monitor = i; - if (mcount != 1 && isxinerama) { m->sx = info[i].x_org; m->sy = info[i].y_org; @@ -2012,11 +2009,11 @@ viewprevtag(const char *arg) { void zoom(const char *arg) { - Client *c; + Client *c = sel; if(!sel || !dozoom || sel->isfloating) return; - if((c = sel) == nexttiled(clients, c->monitor)) + if(c == nexttiled(clients, c->monitor)) if(!(c = nexttiled(c->next, c->monitor))) return; detach(c);