aewl
changeset 708:a2d568a5cdb8
applied Sanders all5.patch (thanks for your weekend session, Sander!)
author | Anselm R. Garbe <arg@suckless.org> |
---|---|
date | Mon, 22 Jan 2007 10:22:58 +0100 |
parents | c3c57faef013 |
children | 6c2fcf88dd9f |
files | client.c dwm.h event.c main.c view.c |
diffstat | 5 files changed, 63 insertions(+), 71 deletions(-) [+] |
line diff
1.1 --- a/client.c Fri Jan 19 15:05:07 2007 +0100 1.2 +++ b/client.c Mon Jan 22 10:22:58 2007 +0100 1.3 @@ -79,19 +79,14 @@ 1.4 1.5 void 1.6 focus(Client *c) { 1.7 - Client *old; 1.8 + Client *old = sel; 1.9 1.10 if(!issel || (c && !isvisible(c))) 1.11 return; 1.12 - if(!sel) 1.13 - sel = c; 1.14 - else if(sel != c) { 1.15 - old = sel; 1.16 - sel = c; 1.17 - if(old) { 1.18 - grabbuttons(old, False); 1.19 - XSetWindowBorder(dpy, old->win, dc.norm[ColBorder]); 1.20 - } 1.21 + 1.22 + if(old && old != c) { 1.23 + grabbuttons(old, False); 1.24 + XSetWindowBorder(dpy, old->win, dc.norm[ColBorder]); 1.25 } 1.26 if(c) { 1.27 detachstack(c); 1.28 @@ -103,6 +98,7 @@ 1.29 } 1.30 else 1.31 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); 1.32 + sel = c; 1.33 drawstatus(); 1.34 } 1.35 1.36 @@ -134,20 +130,27 @@ 1.37 c = emallocz(sizeof(Client)); 1.38 c->tags = emallocz(ntags * sizeof(Bool)); 1.39 c->win = w; 1.40 - c->border = 0; 1.41 c->x = wa->x; 1.42 c->y = wa->y; 1.43 c->w = wa->width; 1.44 c->h = wa->height; 1.45 + if(c->w == sw && c->h == sh) { 1.46 + c->border = 0; 1.47 + c->x = sx; 1.48 + c->y = sy; 1.49 + } 1.50 + else { 1.51 + c->border = BORDERPX; 1.52 + if(c->x < wax) 1.53 + c->x = wax; 1.54 + if(c->y < way) 1.55 + c->y = way; 1.56 + if(c->x + c->w + 2 * c->border > wax + waw) 1.57 + c->x = wax + waw - c->w - 2 * c->border; 1.58 + if(c->y + c->h + 2 * c->border > way + wah) 1.59 + c->y = way + wah - c->h - 2 * c->border; 1.60 + } 1.61 updatesizehints(c); 1.62 - if(c->x + c->w + 2 * BORDERPX > sw) 1.63 - c->x = sw - c->w - 2 * BORDERPX; 1.64 - if(c->x < sx) 1.65 - c->x = sx; 1.66 - if(c->y + c->h + 2 * BORDERPX > sh) 1.67 - c->y = sh - c->h - 2 * BORDERPX; 1.68 - if(c->h != sh && c->y < bh) 1.69 - c->y = bh; 1.70 c->proto = getproto(c->win); 1.71 XSelectInput(dpy, c->win, 1.72 StructureNotifyMask | PropertyChangeMask | EnterWindowMask); 1.73 @@ -170,9 +173,7 @@ 1.74 } 1.75 1.76 void 1.77 -resize(Client *c, Bool sizehints, Corner sticky) { 1.78 - int bottom = c->y + c->h; 1.79 - int right = c->x + c->w; 1.80 +resize(Client *c, Bool sizehints) { 1.81 XWindowChanges wc; 1.82 1.83 if(sizehints) { 1.84 @@ -189,27 +190,24 @@ 1.85 if(c->maxh && c->h > c->maxh) 1.86 c->h = c->maxh; 1.87 } 1.88 - if(sticky == TopRight || sticky == BotRight) 1.89 - c->x = right - c->w; 1.90 - if(sticky == BotLeft || sticky == BotRight) 1.91 - c->y = bottom - c->h; 1.92 + if(c->w == sw && c->h == sh) 1.93 + c->border = 0; 1.94 + else 1.95 + c->border = BORDERPX; 1.96 /* offscreen appearance fixes */ 1.97 - if(c->x + c->w < sx) 1.98 + if(c->x + c->w + 2 * c->border < sx) 1.99 c->x = sx; 1.100 - if(c->y + c->h < bh) 1.101 - c->y = bh; 1.102 + if(c->y + c->h + 2 * c->border < sy) 1.103 + c->y = sy; 1.104 if(c->x > sw) 1.105 - c->x = sw - c->w; 1.106 + c->x = sw - c->w - 2 * c->border; 1.107 if(c->y > sh) 1.108 - c->y = sh - c->h; 1.109 + c->y = sh - c->h - 2 * c->border; 1.110 wc.x = c->x; 1.111 wc.y = c->y; 1.112 wc.width = c->w; 1.113 wc.height = c->h; 1.114 - if(c->w == sw && c->h == sh) 1.115 - wc.border_width = 0; 1.116 - else 1.117 - wc.border_width = BORDERPX; 1.118 + wc.border_width = c->border; 1.119 XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc); 1.120 configure(c); 1.121 XSync(dpy, False);
2.1 --- a/dwm.h Fri Jan 19 15:05:07 2007 +0100 2.2 +++ b/dwm.h Mon Jan 22 10:22:58 2007 +0100 2.3 @@ -44,10 +44,6 @@ 2.4 enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ 2.5 enum { ColBorder, ColFG, ColBG, ColLast }; /* color */ 2.6 2.7 -typedef enum { 2.8 - TopLeft, TopRight, BotLeft, BotRight 2.9 -} Corner; /* window corners */ 2.10 - 2.11 typedef union { 2.12 const char *cmd; 2.13 int i; 2.14 @@ -110,7 +106,7 @@ 2.15 extern Client *getclient(Window w); /* return client of w */ 2.16 extern void killclient(Arg *arg); /* kill c nicely */ 2.17 extern void manage(Window w, XWindowAttributes *wa); /* manage new client */ 2.18 -extern void resize(Client *c, Bool sizehints, Corner sticky); /* resize c*/ 2.19 +extern void resize(Client *c, Bool sizehints); /* resize c*/ 2.20 extern void updatesizehints(Client *c); /* update the size hint variables of c */ 2.21 extern void updatetitle(Client *c); /* update the name of c */ 2.22 extern void unmanage(Client *c); /* destroy c */
3.1 --- a/event.c Fri Jan 19 15:05:07 2007 +0100 3.2 +++ b/event.c Mon Jan 22 10:22:58 2007 +0100 3.3 @@ -35,14 +35,16 @@ 3.4 c->ismax = False; 3.5 XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui); 3.6 for(;;) { 3.7 - XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev); 3.8 + XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev); 3.9 switch (ev.type) { 3.10 case ButtonRelease: 3.11 - resize(c, True, TopLeft); 3.12 + resize(c, True); 3.13 XUngrabPointer(dpy, CurrentTime); 3.14 return; 3.15 + case ConfigureRequest: 3.16 case Expose: 3.17 - handler[Expose](&ev); 3.18 + case MapRequest: 3.19 + handler[ev.type](&ev); 3.20 break; 3.21 case MotionNotify: 3.22 XSync(dpy, False); 3.23 @@ -50,13 +52,13 @@ 3.24 c->y = ocy + (ev.xmotion.y - y1); 3.25 if(abs(wax + c->x) < SNAP) 3.26 c->x = wax; 3.27 - else if(abs((wax + waw) - (c->x + c->w)) < SNAP) 3.28 - c->x = wax + waw - c->w - 2 * BORDERPX; 3.29 + else if(abs((wax + waw) - (c->x + c->w + 2 * c->border)) < SNAP) 3.30 + c->x = wax + waw - c->w - 2 * c->border; 3.31 if(abs(way - c->y) < SNAP) 3.32 c->y = way; 3.33 - else if(abs((way + wah) - (c->y + c->h)) < SNAP) 3.34 - c->y = way + wah - c->h - 2 * BORDERPX; 3.35 - resize(c, False, TopLeft); 3.36 + else if(abs((way + wah) - (c->y + c->h + 2 * c->border)) < SNAP) 3.37 + c->y = way + wah - c->h - 2 * c->border; 3.38 + resize(c, False); 3.39 break; 3.40 } 3.41 } 3.42 @@ -66,7 +68,6 @@ 3.43 resizemouse(Client *c) { 3.44 int ocx, ocy; 3.45 int nw, nh; 3.46 - Corner sticky; 3.47 XEvent ev; 3.48 3.49 ocx = c->x; 3.50 @@ -75,30 +76,26 @@ 3.51 None, cursor[CurResize], CurrentTime) != GrabSuccess) 3.52 return; 3.53 c->ismax = False; 3.54 - XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h); 3.55 + XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1); 3.56 for(;;) { 3.57 - XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev); 3.58 + XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask , &ev); 3.59 switch(ev.type) { 3.60 case ButtonRelease: 3.61 - resize(c, True, TopLeft); 3.62 + resize(c, True); 3.63 XUngrabPointer(dpy, CurrentTime); 3.64 return; 3.65 + case ConfigureRequest: 3.66 case Expose: 3.67 - handler[Expose](&ev); 3.68 + case MapRequest: 3.69 + handler[ev.type](&ev); 3.70 break; 3.71 case MotionNotify: 3.72 XSync(dpy, False); 3.73 - if((nw = abs(ocx - ev.xmotion.x))) 3.74 - c->w = nw; 3.75 - if((nh = abs(ocy - ev.xmotion.y))) 3.76 - c->h = nh; 3.77 - c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w; 3.78 - c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h; 3.79 - if(ocx <= ev.xmotion.x) 3.80 - sticky = (ocy <= ev.xmotion.y) ? TopLeft : BotLeft; 3.81 - else 3.82 - sticky = (ocy <= ev.xmotion.y) ? TopRight : BotRight; 3.83 - resize(c, True, sticky); 3.84 + nw = ev.xmotion.x - ocx - 2 * c->border + 1; 3.85 + c->w = nw > 0 ? nw : 1; 3.86 + nh = ev.xmotion.y - ocy - 2 * c->border + 1; 3.87 + c->h = nh > 0 ? nh : 1; 3.88 + resize(c, True); 3.89 break; 3.90 } 3.91 } 3.92 @@ -194,7 +191,7 @@ 3.93 configure(c); 3.94 XSync(dpy, False); 3.95 if(c->isfloat) { 3.96 - resize(c, False, TopLeft); 3.97 + resize(c, False); 3.98 if(!isvisible(c)) 3.99 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); 3.100 } 3.101 @@ -234,7 +231,8 @@ 3.102 focus(c); 3.103 else if(ev->window == root) { 3.104 issel = True; 3.105 - focus(sel); 3.106 + for(c = stack; c && !isvisible(c); c = c->snext); 3.107 + focus(c); 3.108 } 3.109 } 3.110
4.1 --- a/main.c Fri Jan 19 15:05:07 2007 +0100 4.2 +++ b/main.c Mon Jan 22 10:22:58 2007 +0100 4.3 @@ -41,7 +41,7 @@ 4.4 cleanup(void) { 4.5 close(STDIN_FILENO); 4.6 while(stack) { 4.7 - resize(stack, True, TopLeft); 4.8 + resize(stack, True); 4.9 unmanage(stack); 4.10 } 4.11 if(dc.font.set)
5.1 --- a/view.c Fri Jan 19 15:05:07 2007 +0100 5.2 +++ b/view.c Mon Jan 22 10:22:58 2007 +0100 5.3 @@ -31,7 +31,7 @@ 5.4 c->w = c->rw; 5.5 c->h = c->rh; 5.6 } 5.7 - resize(c, True, TopLeft); 5.8 + resize(c, True); 5.9 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); 5.10 } 5.11 5.12 @@ -56,7 +56,7 @@ 5.13 5.14 for(c = clients; c; c = c->next) { 5.15 if(isvisible(c)) { 5.16 - resize(c, True, TopLeft); 5.17 + resize(c, True); 5.18 } 5.19 else 5.20 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); 5.21 @@ -84,7 +84,7 @@ 5.22 for(i = 0, c = clients; c; c = c->next) 5.23 if(isvisible(c)) { 5.24 if(c->isfloat) { 5.25 - resize(c, True, TopLeft); 5.26 + resize(c, True); 5.27 continue; 5.28 } 5.29 c->ismax = False; 5.30 @@ -105,7 +105,7 @@ 5.31 else /* fallback if th < bh */ 5.32 c->h = wah - 2 * BORDERPX; 5.33 } 5.34 - resize(c, False, TopLeft); 5.35 + resize(c, False); 5.36 i++; 5.37 } 5.38 else