applied Sanders resize patch, fixed lower bug
c53980cd
5 file(s) · +43 −19
| 267 | 267 | *sel->w = sw - 2 * sel->border; |
|
| 268 | 268 | *sel->h = sh - 2 * sel->border - bh; |
|
| 269 | 269 | higher(sel); |
|
| 270 | - | resize(sel, False); |
|
| 270 | + | resize(sel, False, TopLeft); |
|
| 271 | 271 | } |
|
| 272 | 272 | ||
| 273 | 273 | void |
|
| 283 | 283 | } |
|
| 284 | 284 | ||
| 285 | 285 | void |
|
| 286 | - | resize(Client *c, Bool inc) |
|
| 286 | + | resize(Client *c, Bool inc, Corner sticky) |
|
| 287 | 287 | { |
|
| 288 | 288 | XConfigureEvent e; |
|
| 289 | + | int right = *c->x + *c->w; |
|
| 290 | + | int bottom = *c->y + *c->h; |
|
| 289 | 291 | ||
| 290 | 292 | if(inc) { |
|
| 291 | 293 | if(c->incw) |
|
| 305 | 307 | *c->w = c->maxw; |
|
| 306 | 308 | if(c->maxh && *c->h > c->maxh) |
|
| 307 | 309 | *c->h = c->maxh; |
|
| 310 | + | if(sticky == TopRight || sticky == BottomRight) |
|
| 311 | + | *c->x = right - *c->w; |
|
| 312 | + | if(sticky == BottomLeft || sticky == BottomRight) |
|
| 313 | + | *c->y = bottom - *c->h; |
|
| 308 | 314 | resizetitle(c); |
|
| 309 | 315 | XSetWindowBorderWidth(dpy, c->win, 1); |
|
| 310 | 316 | XMoveResizeWindow(dpy, c->win, *c->x, *c->y, *c->w, *c->h); |
|
| 25 | 25 | /********** CUSTOMIZE **********/ |
|
| 26 | 26 | ||
| 27 | 27 | typedef union Arg Arg; |
|
| 28 | + | typedef enum Corner Corner; |
|
| 28 | 29 | typedef struct DC DC; |
|
| 29 | 30 | typedef struct Client Client; |
|
| 30 | 31 | typedef struct Fnt Fnt; |
|
| 42 | 43 | ||
| 43 | 44 | /* cursor */ |
|
| 44 | 45 | enum { CurNormal, CurResize, CurMove, CurLast }; |
|
| 46 | + | ||
| 47 | + | enum Corner { TopLeft, TopRight, BottomLeft, BottomRight }; |
|
| 45 | 48 | ||
| 46 | 49 | struct Fnt { |
|
| 47 | 50 | int ascent; |
|
| 121 | 124 | extern void manage(Window w, XWindowAttributes *wa); |
|
| 122 | 125 | extern void maximize(Arg *arg); |
|
| 123 | 126 | extern void pop(Client *c); |
|
| 124 | - | extern void resize(Client *c, Bool inc); |
|
| 127 | + | extern void resize(Client *c, Bool inc, Corner sticky); |
|
| 125 | 128 | extern void setgeom(Client *c); |
|
| 126 | 129 | extern void setsize(Client *c); |
|
| 127 | 130 | extern void settitle(Client *c); |
|
| 79 | 79 | XSync(dpy, False); |
|
| 80 | 80 | *c->x = ocx + (ev.xmotion.x - x1); |
|
| 81 | 81 | *c->y = ocy + (ev.xmotion.y - y1); |
|
| 82 | - | resize(c, False); |
|
| 82 | + | resize(c, False, TopLeft); |
|
| 83 | 83 | break; |
|
| 84 | 84 | case ButtonRelease: |
|
| 85 | 85 | XUngrabPointer(dpy, CurrentTime); |
|
| 93 | 93 | { |
|
| 94 | 94 | XEvent ev; |
|
| 95 | 95 | int ocx, ocy; |
|
| 96 | + | Corner sticky; |
|
| 96 | 97 | ||
| 97 | 98 | ocx = *c->x; |
|
| 98 | 99 | ocy = *c->y; |
|
| 113 | 114 | *c->h = abs(ocy - ev.xmotion.y); |
|
| 114 | 115 | *c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - *c->w; |
|
| 115 | 116 | *c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - *c->h; |
|
| 116 | - | resize(c, True); |
|
| 117 | + | if(ocx <= ev.xmotion.x) { |
|
| 118 | + | if(ocy <= ev.xmotion.y) |
|
| 119 | + | sticky = TopLeft; |
|
| 120 | + | else |
|
| 121 | + | sticky = BottomLeft; |
|
| 122 | + | } else { |
|
| 123 | + | if(ocy <= ev.xmotion.y) |
|
| 124 | + | sticky = TopRight; |
|
| 125 | + | else |
|
| 126 | + | sticky = BottomRight; |
|
| 127 | + | } |
|
| 128 | + | resize(c, True, sticky); |
|
| 117 | 129 | break; |
|
| 118 | 130 | case ButtonRelease: |
|
| 119 | 131 | XUngrabPointer(dpy, CurrentTime); |
|
| 153 | 165 | } |
|
| 154 | 166 | } |
|
| 155 | 167 | else if((c = getclient(ev->window))) { |
|
| 156 | - | if(arrange == dotile && !c->isfloat) { |
|
| 157 | - | if((ev->state & ControlMask) && (ev->button == Button1)) |
|
| 158 | - | zoom(NULL); |
|
| 159 | - | return; |
|
| 160 | - | } |
|
| 161 | - | /* floating windows */ |
|
| 162 | - | higher(c); |
|
| 163 | 168 | switch(ev->button) { |
|
| 164 | 169 | default: |
|
| 165 | 170 | break; |
|
| 166 | 171 | case Button1: |
|
| 167 | - | movemouse(c); |
|
| 172 | + | if(arrange == dotile && !c->isfloat) { |
|
| 173 | + | if((ev->state & ControlMask) && (ev->button == Button1)) |
|
| 174 | + | zoom(NULL); |
|
| 175 | + | } |
|
| 176 | + | else { |
|
| 177 | + | higher(c); |
|
| 178 | + | movemouse(c); |
|
| 179 | + | } |
|
| 168 | 180 | break; |
|
| 169 | 181 | case Button2: |
|
| 170 | 182 | lower(c); |
|
| 171 | 183 | break; |
|
| 172 | 184 | case Button3: |
|
| 173 | - | resizemouse(c); |
|
| 185 | + | if(arrange == dofloat || c->isfloat) { |
|
| 186 | + | higher(c); |
|
| 187 | + | resizemouse(c); |
|
| 188 | + | } |
|
| 174 | 189 | break; |
|
| 175 | 190 | } |
|
| 176 | 191 | } |
|
| 197 | 212 | if(ev->value_mask & CWBorderWidth) |
|
| 198 | 213 | c->border = 1; |
|
| 199 | 214 | gravitate(c, False); |
|
| 200 | - | resize(c, True); |
|
| 215 | + | resize(c, True, TopLeft); |
|
| 201 | 216 | } |
|
| 202 | 217 | ||
| 203 | 218 | wc.x = ev->x; |
|
| 24 | 24 | cleanup() |
|
| 25 | 25 | { |
|
| 26 | 26 | while(sel) { |
|
| 27 | - | resize(sel, True); |
|
| 27 | + | resize(sel, True, TopLeft); |
|
| 28 | 28 | unmanage(sel); |
|
| 29 | 29 | } |
|
| 30 | 30 | XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); |
| 45 | 45 | for(c = clients; c; c = c->next) { |
|
| 46 | 46 | setgeom(c); |
|
| 47 | 47 | if(c->tags[tsel]) { |
|
| 48 | - | resize(c, True); |
|
| 48 | + | resize(c, True, TopLeft); |
|
| 49 | 49 | } |
|
| 50 | 50 | else |
|
| 51 | 51 | ban(c); |
|
| 81 | 81 | if(c->tags[tsel]) { |
|
| 82 | 82 | if(c->isfloat) { |
|
| 83 | 83 | higher(c); |
|
| 84 | - | resize(c, True); |
|
| 84 | + | resize(c, True, TopLeft); |
|
| 85 | 85 | continue; |
|
| 86 | 86 | } |
|
| 87 | 87 | if(n == 1) { |
|
| 102 | 102 | *c->w = w - 2 * c->border; |
|
| 103 | 103 | *c->h = h - 2 * c->border; |
|
| 104 | 104 | } |
|
| 105 | - | resize(c, False); |
|
| 105 | + | resize(c, False, TopLeft); |
|
| 106 | 106 | i++; |
|
| 107 | 107 | } |
|
| 108 | 108 | else |
|