diff options
| author | Anselm R. Garbe <arg@suckless.org> | 2007-01-22 10:22:58 +0100 |
|---|---|---|
| committer | Anselm R. Garbe <arg@suckless.org> | 2007-01-22 10:22:58 +0100 |
| commit | b233089815367983e07939b2aabb999fdc359f91 (patch) | |
| tree | 5888837d10ed0359cfbdbadaa9bcf37d30f7a022 /client.c | |
| parent | leavenotify also don't needs the check (diff) | |
| download | dwm-b233089815367983e07939b2aabb999fdc359f91.tar.gz dwm-b233089815367983e07939b2aabb999fdc359f91.zip | |
applied Sanders all5.patch (thanks for your weekend session, Sander!)
Diffstat (limited to 'client.c')
| -rw-r--r-- | client.c | 68 |
1 files changed, 33 insertions, 35 deletions
| @@ -79,19 +79,14 @@ configure(Client *c) { | |||
| 79 | 79 | ||
| 80 | void | 80 | void |
| 81 | focus(Client *c) { | 81 | focus(Client *c) { |
| 82 | Client *old; | 82 | Client *old = sel; |
| 83 | 83 | ||
| 84 | if(!issel || (c && !isvisible(c))) | 84 | if(!issel || (c && !isvisible(c))) |
| 85 | return; | 85 | return; |
| 86 | if(!sel) | 86 | |
| 87 | sel = c; | 87 | if(old && old != c) { |
| 88 | else if(sel != c) { | 88 | grabbuttons(old, False); |
| 89 | old = sel; | 89 | XSetWindowBorder(dpy, old->win, dc.norm[ColBorder]); |
| 90 | sel = c; | ||
| 91 | if(old) { | ||
| 92 | grabbuttons(old, False); | ||
| 93 | XSetWindowBorder(dpy, old->win, dc.norm[ColBorder]); | ||
| 94 | } | ||
| 95 | } | 90 | } |
| 96 | if(c) { | 91 | if(c) { |
| 97 | detachstack(c); | 92 | detachstack(c); |
| @@ -103,6 +98,7 @@ focus(Client *c) { | |||
| 103 | } | 98 | } |
| 104 | else | 99 | else |
| 105 | XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); | 100 | XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); |
| 101 | sel = c; | ||
| 106 | drawstatus(); | 102 | drawstatus(); |
| 107 | } | 103 | } |
| 108 | 104 | ||
| @@ -134,20 +130,27 @@ manage(Window w, XWindowAttributes *wa) { | |||
| 134 | c = emallocz(sizeof(Client)); | 130 | c = emallocz(sizeof(Client)); |
| 135 | c->tags = emallocz(ntags * sizeof(Bool)); | 131 | c->tags = emallocz(ntags * sizeof(Bool)); |
| 136 | c->win = w; | 132 | c->win = w; |
| 137 | c->border = 0; | ||
| 138 | c->x = wa->x; | 133 | c->x = wa->x; |
| 139 | c->y = wa->y; | 134 | c->y = wa->y; |
| 140 | c->w = wa->width; | 135 | c->w = wa->width; |
| 141 | c->h = wa->height; | 136 | c->h = wa->height; |
| 142 | updatesizehints(c); | 137 | if(c->w == sw && c->h == sh) { |
| 143 | if(c->x + c->w + 2 * BORDERPX > sw) | 138 | c->border = 0; |
| 144 | c->x = sw - c->w - 2 * BORDERPX; | ||
| 145 | if(c->x < sx) | ||
| 146 | c->x = sx; | 139 | c->x = sx; |
| 147 | if(c->y + c->h + 2 * BORDERPX > sh) | 140 | c->y = sy; |
| 148 | c->y = sh - c->h - 2 * BORDERPX; | 141 | } |
| 149 | if(c->h != sh && c->y < bh) | 142 | else { |
| 150 | c->y = bh; | 143 | c->border = BORDERPX; |
| 144 | if(c->x < wax) | ||
| 145 | c->x = wax; | ||
| 146 | if(c->y < way) | ||
| 147 | c->y = way; | ||
| 148 | if(c->x + c->w + 2 * c->border > wax + waw) | ||
| 149 | c->x = wax + waw - c->w - 2 * c->border; | ||
| 150 | if(c->y + c->h + 2 * c->border > way + wah) | ||
| 151 | c->y = way + wah - c->h - 2 * c->border; | ||
| 152 | } | ||
| 153 | updatesizehints(c); | ||
| 151 | c->proto = getproto(c->win); | 154 | c->proto = getproto(c->win); |
| 152 | XSelectInput(dpy, c->win, | 155 | XSelectInput(dpy, c->win, |
| 153 | StructureNotifyMask | PropertyChangeMask | EnterWindowMask); | 156 | StructureNotifyMask | PropertyChangeMask | EnterWindowMask); |
| @@ -170,9 +173,7 @@ manage(Window w, XWindowAttributes *wa) { | |||
| 170 | } | 173 | } |
| 171 | 174 | ||
| 172 | void | 175 | void |
| 173 | resize(Client *c, Bool sizehints, Corner sticky) { | 176 | resize(Client *c, Bool sizehints) { |
| 174 | int bottom = c->y + c->h; | ||
| 175 | int right = c->x + c->w; | ||
| 176 | XWindowChanges wc; | 177 | XWindowChanges wc; |
| 177 | 178 | ||
| 178 | if(sizehints) { | 179 | if(sizehints) { |
| @@ -189,27 +190,24 @@ resize(Client *c, Bool sizehints, Corner sticky) { | |||
| 189 | if(c->maxh && c->h > c->maxh) | 190 | if(c->maxh && c->h > c->maxh) |
| 190 | c->h = c->maxh; | 191 | c->h = c->maxh; |
| 191 | } | 192 | } |
| 192 | if(sticky == TopRight || sticky == BotRight) | 193 | if(c->w == sw && c->h == sh) |
| 193 | c->x = right - c->w; | 194 | c->border = 0; |
| 194 | if(sticky == BotLeft || sticky == BotRight) | 195 | else |
| 195 | c->y = bottom - c->h; | 196 | c->border = BORDERPX; |
| 196 | /* offscreen appearance fixes */ | 197 | /* offscreen appearance fixes */ |
| 197 | if(c->x + c->w < sx) | 198 | if(c->x + c->w + 2 * c->border < sx) |
| 198 | c->x = sx; | 199 | c->x = sx; |
| 199 | if(c->y + c->h < bh) | 200 | if(c->y + c->h + 2 * c->border < sy) |
| 200 | c->y = bh; | 201 | c->y = sy; |
| 201 | if(c->x > sw) | 202 | if(c->x > sw) |
| 202 | c->x = sw - c->w; | 203 | c->x = sw - c->w - 2 * c->border; |
| 203 | if(c->y > sh) | 204 | if(c->y > sh) |
| 204 | c->y = sh - c->h; | 205 | c->y = sh - c->h - 2 * c->border; |
| 205 | wc.x = c->x; | 206 | wc.x = c->x; |
| 206 | wc.y = c->y; | 207 | wc.y = c->y; |
| 207 | wc.width = c->w; | 208 | wc.width = c->w; |
| 208 | wc.height = c->h; | 209 | wc.height = c->h; |
| 209 | if(c->w == sw && c->h == sh) | 210 | wc.border_width = c->border; |
| 210 | wc.border_width = 0; | ||
| 211 | else | ||
| 212 | wc.border_width = BORDERPX; | ||
| 213 | XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc); | 211 | XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc); |
| 214 | configure(c); | 212 | configure(c); |
| 215 | XSync(dpy, False); | 213 | XSync(dpy, False); |
