diff options
| author | arg@10ksloc.org <unknown> | 2006-07-19 11:31:04 +0200 |
|---|---|---|
| committer | arg@10ksloc.org <unknown> | 2006-07-19 11:31:04 +0200 |
| commit | c53980cddcee8afd13ea793134ed3ddf5dbef0e3 (patch) | |
| tree | 44d98af7d722ffabac12eb271b81a74f9bd49834 | |
| parent | changed CFLAGs (diff) | |
| download | dwm-c53980cddcee8afd13ea793134ed3ddf5dbef0e3.tar.gz dwm-c53980cddcee8afd13ea793134ed3ddf5dbef0e3.zip | |
applied Sanders resize patch, fixed lower bug
| -rw-r--r-- | client.c | 10 | ||||
| -rw-r--r-- | dwm.h | 5 | ||||
| -rw-r--r-- | event.c | 39 | ||||
| -rw-r--r-- | main.c | 2 | ||||
| -rw-r--r-- | tag.c | 6 |
5 files changed, 43 insertions, 19 deletions
| @@ -267,7 +267,7 @@ maximize(Arg *arg) | |||
| 267 | *sel->w = sw - 2 * sel->border; | 267 | *sel->w = sw - 2 * sel->border; |
| 268 | *sel->h = sh - 2 * sel->border - bh; | 268 | *sel->h = sh - 2 * sel->border - bh; |
| 269 | higher(sel); | 269 | higher(sel); |
| 270 | resize(sel, False); | 270 | resize(sel, False, TopLeft); |
| 271 | } | 271 | } |
| 272 | 272 | ||
| 273 | void | 273 | void |
| @@ -283,9 +283,11 @@ pop(Client *c) | |||
| 283 | } | 283 | } |
| 284 | 284 | ||
| 285 | void | 285 | void |
| 286 | resize(Client *c, Bool inc) | 286 | resize(Client *c, Bool inc, Corner sticky) |
| 287 | { | 287 | { |
| 288 | XConfigureEvent e; | 288 | XConfigureEvent e; |
| 289 | int right = *c->x + *c->w; | ||
| 290 | int bottom = *c->y + *c->h; | ||
| 289 | 291 | ||
| 290 | if(inc) { | 292 | if(inc) { |
| 291 | if(c->incw) | 293 | if(c->incw) |
| @@ -305,6 +307,10 @@ resize(Client *c, Bool inc) | |||
| 305 | *c->w = c->maxw; | 307 | *c->w = c->maxw; |
| 306 | if(c->maxh && *c->h > c->maxh) | 308 | if(c->maxh && *c->h > c->maxh) |
| 307 | *c->h = c->maxh; | 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 | resizetitle(c); | 314 | resizetitle(c); |
| 309 | XSetWindowBorderWidth(dpy, c->win, 1); | 315 | XSetWindowBorderWidth(dpy, c->win, 1); |
| 310 | XMoveResizeWindow(dpy, c->win, *c->x, *c->y, *c->w, *c->h); | 316 | XMoveResizeWindow(dpy, c->win, *c->x, *c->y, *c->w, *c->h); |
| @@ -25,6 +25,7 @@ enum { Tscratch, Tdev, Twww, Twork, TLast }; | |||
| 25 | /********** CUSTOMIZE **********/ | 25 | /********** CUSTOMIZE **********/ |
| 26 | 26 | ||
| 27 | typedef union Arg Arg; | 27 | typedef union Arg Arg; |
| 28 | typedef enum Corner Corner; | ||
| 28 | typedef struct DC DC; | 29 | typedef struct DC DC; |
| 29 | typedef struct Client Client; | 30 | typedef struct Client Client; |
| 30 | typedef struct Fnt Fnt; | 31 | typedef struct Fnt Fnt; |
| @@ -43,6 +44,8 @@ enum { WMProtocols, WMDelete, WMLast }; | |||
| 43 | /* cursor */ | 44 | /* cursor */ |
| 44 | enum { CurNormal, CurResize, CurMove, CurLast }; | 45 | enum { CurNormal, CurResize, CurMove, CurLast }; |
| 45 | 46 | ||
| 47 | enum Corner { TopLeft, TopRight, BottomLeft, BottomRight }; | ||
| 48 | |||
| 46 | struct Fnt { | 49 | struct Fnt { |
| 47 | int ascent; | 50 | int ascent; |
| 48 | int descent; | 51 | int descent; |
| @@ -121,7 +124,7 @@ extern void lower(Client *c); | |||
| 121 | extern void manage(Window w, XWindowAttributes *wa); | 124 | extern void manage(Window w, XWindowAttributes *wa); |
| 122 | extern void maximize(Arg *arg); | 125 | extern void maximize(Arg *arg); |
| 123 | extern void pop(Client *c); | 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 | extern void setgeom(Client *c); | 128 | extern void setgeom(Client *c); |
| 126 | extern void setsize(Client *c); | 129 | extern void setsize(Client *c); |
| 127 | extern void settitle(Client *c); | 130 | extern void settitle(Client *c); |
| @@ -79,7 +79,7 @@ movemouse(Client *c) | |||
| 79 | XSync(dpy, False); | 79 | XSync(dpy, False); |
| 80 | *c->x = ocx + (ev.xmotion.x - x1); | 80 | *c->x = ocx + (ev.xmotion.x - x1); |
| 81 | *c->y = ocy + (ev.xmotion.y - y1); | 81 | *c->y = ocy + (ev.xmotion.y - y1); |
| 82 | resize(c, False); | 82 | resize(c, False, TopLeft); |
| 83 | break; | 83 | break; |
| 84 | case ButtonRelease: | 84 | case ButtonRelease: |
| 85 | XUngrabPointer(dpy, CurrentTime); | 85 | XUngrabPointer(dpy, CurrentTime); |
| @@ -93,6 +93,7 @@ resizemouse(Client *c) | |||
| 93 | { | 93 | { |
| 94 | XEvent ev; | 94 | XEvent ev; |
| 95 | int ocx, ocy; | 95 | int ocx, ocy; |
| 96 | Corner sticky; | ||
| 96 | 97 | ||
| 97 | ocx = *c->x; | 98 | ocx = *c->x; |
| 98 | ocy = *c->y; | 99 | ocy = *c->y; |
| @@ -113,7 +114,18 @@ resizemouse(Client *c) | |||
| 113 | *c->h = abs(ocy - ev.xmotion.y); | 114 | *c->h = abs(ocy - ev.xmotion.y); |
| 114 | *c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - *c->w; | 115 | *c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - *c->w; |
| 115 | *c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - *c->h; | 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 | break; | 129 | break; |
| 118 | case ButtonRelease: | 130 | case ButtonRelease: |
| 119 | XUngrabPointer(dpy, CurrentTime); | 131 | XUngrabPointer(dpy, CurrentTime); |
| @@ -153,24 +165,27 @@ buttonpress(XEvent *e) | |||
| 153 | } | 165 | } |
| 154 | } | 166 | } |
| 155 | else if((c = getclient(ev->window))) { | 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 | switch(ev->button) { | 168 | switch(ev->button) { |
| 164 | default: | 169 | default: |
| 165 | break; | 170 | break; |
| 166 | case Button1: | 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 | break; | 180 | break; |
| 169 | case Button2: | 181 | case Button2: |
| 170 | lower(c); | 182 | lower(c); |
| 171 | break; | 183 | break; |
| 172 | case Button3: | 184 | case Button3: |
| 173 | resizemouse(c); | 185 | if(arrange == dofloat || c->isfloat) { |
| 186 | higher(c); | ||
| 187 | resizemouse(c); | ||
| 188 | } | ||
| 174 | break; | 189 | break; |
| 175 | } | 190 | } |
| 176 | } | 191 | } |
| @@ -197,7 +212,7 @@ configurerequest(XEvent *e) | |||
| 197 | if(ev->value_mask & CWBorderWidth) | 212 | if(ev->value_mask & CWBorderWidth) |
| 198 | c->border = 1; | 213 | c->border = 1; |
| 199 | gravitate(c, False); | 214 | gravitate(c, False); |
| 200 | resize(c, True); | 215 | resize(c, True, TopLeft); |
| 201 | } | 216 | } |
| 202 | 217 | ||
| 203 | wc.x = ev->x; | 218 | wc.x = ev->x; |
| @@ -24,7 +24,7 @@ static void | |||
| 24 | cleanup() | 24 | cleanup() |
| 25 | { | 25 | { |
| 26 | while(sel) { | 26 | while(sel) { |
| 27 | resize(sel, True); | 27 | resize(sel, True, TopLeft); |
| 28 | unmanage(sel); | 28 | unmanage(sel); |
| 29 | } | 29 | } |
| 30 | XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); | 30 | XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); |
| @@ -45,7 +45,7 @@ dofloat(Arg *arg) | |||
| 45 | for(c = clients; c; c = c->next) { | 45 | for(c = clients; c; c = c->next) { |
| 46 | setgeom(c); | 46 | setgeom(c); |
| 47 | if(c->tags[tsel]) { | 47 | if(c->tags[tsel]) { |
| 48 | resize(c, True); | 48 | resize(c, True, TopLeft); |
| 49 | } | 49 | } |
| 50 | else | 50 | else |
| 51 | ban(c); | 51 | ban(c); |
| @@ -81,7 +81,7 @@ dotile(Arg *arg) | |||
| 81 | if(c->tags[tsel]) { | 81 | if(c->tags[tsel]) { |
| 82 | if(c->isfloat) { | 82 | if(c->isfloat) { |
| 83 | higher(c); | 83 | higher(c); |
| 84 | resize(c, True); | 84 | resize(c, True, TopLeft); |
| 85 | continue; | 85 | continue; |
| 86 | } | 86 | } |
| 87 | if(n == 1) { | 87 | if(n == 1) { |
| @@ -102,7 +102,7 @@ dotile(Arg *arg) | |||
| 102 | *c->w = w - 2 * c->border; | 102 | *c->w = w - 2 * c->border; |
| 103 | *c->h = h - 2 * c->border; | 103 | *c->h = h - 2 * c->border; |
| 104 | } | 104 | } |
| 105 | resize(c, False); | 105 | resize(c, False, TopLeft); |
| 106 | i++; | 106 | i++; |
| 107 | } | 107 | } |
| 108 | else | 108 | else |
