diff options
| author | Anselm R. Garbe <arg@suckless.org> | 2007-02-16 16:38:40 +0100 |
|---|---|---|
| committer | Anselm R. Garbe <arg@suckless.org> | 2007-02-16 16:38:40 +0100 |
| commit | 6e22ccf7b1602b33624692eefd51b6398ffa5454 (patch) | |
| tree | 98989e7a667a63908c72769e9d79b0f888864c88 /client.c | |
| parent | removed getnext/getprev, redundant (diff) | |
| download | dwm-6e22ccf7b1602b33624692eefd51b6398ffa5454.tar.gz dwm-6e22ccf7b1602b33624692eefd51b6398ffa5454.zip | |
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Diffstat (limited to 'client.c')
| -rw-r--r-- | client.c | 81 |
1 files changed, 44 insertions, 37 deletions
| @@ -158,6 +158,7 @@ void | |||
| 158 | manage(Window w, XWindowAttributes *wa) { | 158 | manage(Window w, XWindowAttributes *wa) { |
| 159 | Client *c, *t; | 159 | Client *c, *t; |
| 160 | Window trans; | 160 | Window trans; |
| 161 | XWindowChanges wc; | ||
| 161 | 162 | ||
| 162 | c = emallocz(sizeof(Client)); | 163 | c = emallocz(sizeof(Client)); |
| 163 | c->tags = emallocz(ntags * sizeof(Bool)); | 164 | c->tags = emallocz(ntags * sizeof(Bool)); |
| @@ -187,7 +188,10 @@ manage(Window w, XWindowAttributes *wa) { | |||
| 187 | StructureNotifyMask | PropertyChangeMask | EnterWindowMask); | 188 | StructureNotifyMask | PropertyChangeMask | EnterWindowMask); |
| 188 | XGetTransientForHint(dpy, c->win, &trans); | 189 | XGetTransientForHint(dpy, c->win, &trans); |
| 189 | grabbuttons(c, False); | 190 | grabbuttons(c, False); |
| 191 | wc.border_width = c->border; | ||
| 192 | XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); | ||
| 190 | XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]); | 193 | XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]); |
| 194 | configure(c); /* propagates border_width, if size doesn't change */ | ||
| 191 | updatetitle(c); | 195 | updatetitle(c); |
| 192 | t = getclient(trans); | 196 | t = getclient(trans); |
| 193 | settags(c, t); | 197 | settags(c, t); |
| @@ -198,7 +202,8 @@ manage(Window w, XWindowAttributes *wa) { | |||
| 198 | c->next = clients; | 202 | c->next = clients; |
| 199 | c->snext = stack; | 203 | c->snext = stack; |
| 200 | stack = clients = c; | 204 | stack = clients = c; |
| 201 | ban(c); | 205 | c->isbanned = True; |
| 206 | XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); | ||
| 202 | XMapWindow(dpy, c->win); | 207 | XMapWindow(dpy, c->win); |
| 203 | setclientstate(c, NormalState); | 208 | setclientstate(c, NormalState); |
| 204 | if(isvisible(c)) | 209 | if(isvisible(c)) |
| @@ -207,25 +212,25 @@ manage(Window w, XWindowAttributes *wa) { | |||
| 207 | } | 212 | } |
| 208 | 213 | ||
| 209 | void | 214 | void |
| 210 | resize(Client *c, Bool sizehints) { | 215 | resize(Client *c, int x, int y, int w, int h, Bool sizehints) { |
| 211 | float actual, dx, dy, max, min; | 216 | float actual, dx, dy, max, min; |
| 212 | XWindowChanges wc; | 217 | XWindowChanges wc; |
| 213 | 218 | ||
| 214 | if(c->w <= 0 || c->h <= 0) | 219 | if(w <= 0 || h <= 0) |
| 215 | return; | 220 | return; |
| 216 | if(sizehints) { | 221 | if(sizehints) { |
| 217 | if(c->minw && c->w < c->minw) | 222 | if(c->minw && w < c->minw) |
| 218 | c->w = c->minw; | 223 | w = c->minw; |
| 219 | if(c->minh && c->h < c->minh) | 224 | if(c->minh && h < c->minh) |
| 220 | c->h = c->minh; | 225 | h = c->minh; |
| 221 | if(c->maxw && c->w > c->maxw) | 226 | if(c->maxw && w > c->maxw) |
| 222 | c->w = c->maxw; | 227 | w = c->maxw; |
| 223 | if(c->maxh && c->h > c->maxh) | 228 | if(c->maxh && h > c->maxh) |
| 224 | c->h = c->maxh; | 229 | h = c->maxh; |
| 225 | /* inspired by algorithm from fluxbox */ | 230 | /* inspired by algorithm from fluxbox */ |
| 226 | if(c->minay > 0 && c->maxay && (c->h - c->baseh) > 0) { | 231 | if(c->minay > 0 && c->maxay && (h - c->baseh) > 0) { |
| 227 | dx = (float)(c->w - c->basew); | 232 | dx = (float)(w - c->basew); |
| 228 | dy = (float)(c->h - c->baseh); | 233 | dy = (float)(h - c->baseh); |
| 229 | min = (float)(c->minax) / (float)(c->minay); | 234 | min = (float)(c->minax) / (float)(c->minay); |
| 230 | max = (float)(c->maxax) / (float)(c->maxay); | 235 | max = (float)(c->maxax) / (float)(c->maxay); |
| 231 | actual = dx / dy; | 236 | actual = dx / dy; |
| @@ -233,43 +238,45 @@ resize(Client *c, Bool sizehints) { | |||
| 233 | if(actual < min) { | 238 | if(actual < min) { |
| 234 | dy = (dx * min + dy) / (min * min + 1); | 239 | dy = (dx * min + dy) / (min * min + 1); |
| 235 | dx = dy * min; | 240 | dx = dy * min; |
| 236 | c->w = (int)dx + c->basew; | 241 | w = (int)dx + c->basew; |
| 237 | c->h = (int)dy + c->baseh; | 242 | h = (int)dy + c->baseh; |
| 238 | } | 243 | } |
| 239 | else if(actual > max) { | 244 | else if(actual > max) { |
| 240 | dy = (dx * min + dy) / (max * max + 1); | 245 | dy = (dx * min + dy) / (max * max + 1); |
| 241 | dx = dy * min; | 246 | dx = dy * min; |
| 242 | c->w = (int)dx + c->basew; | 247 | w = (int)dx + c->basew; |
| 243 | c->h = (int)dy + c->baseh; | 248 | h = (int)dy + c->baseh; |
| 244 | } | 249 | } |
| 245 | } | 250 | } |
| 246 | } | 251 | } |
| 247 | if(c->incw) | 252 | if(c->incw) |
| 248 | c->w -= (c->w - c->basew) % c->incw; | 253 | w -= (w - c->basew) % c->incw; |
| 249 | if(c->inch) | 254 | if(c->inch) |
| 250 | c->h -= (c->h - c->baseh) % c->inch; | 255 | h -= (h - c->baseh) % c->inch; |
| 251 | } | 256 | } |
| 252 | if(c->w == sw && c->h == sh) | 257 | if(w == sw && h == sh) |
| 253 | c->border = 0; | 258 | c->border = 0; |
| 254 | else | 259 | else |
| 255 | c->border = BORDERPX; | 260 | c->border = BORDERPX; |
| 256 | /* offscreen appearance fixes */ | 261 | /* offscreen appearance fixes */ |
| 257 | if(c->x > sw) | 262 | if(x > sw) |
| 258 | c->x = sw - c->w - 2 * c->border; | 263 | x = sw - w - 2 * c->border; |
| 259 | if(c->y > sh) | 264 | if(y > sh) |
| 260 | c->y = sh - c->h - 2 * c->border; | 265 | y = sh - h - 2 * c->border; |
| 261 | if(c->x + c->w + 2 * c->border < sx) | 266 | if(x + w + 2 * c->border < sx) |
| 262 | c->x = sx; | 267 | x = sx; |
| 263 | if(c->y + c->h + 2 * c->border < sy) | 268 | if(y + h + 2 * c->border < sy) |
| 264 | c->y = sy; | 269 | y = sy; |
| 265 | wc.x = c->x; | 270 | if(c->x != x || c->y != y || c->w != w || c->h != h) { |
| 266 | wc.y = c->y; | 271 | c->x = wc.x = x; |
| 267 | wc.width = c->w; | 272 | c->y = wc.y = y; |
| 268 | wc.height = c->h; | 273 | c->w = wc.width = w; |
| 269 | wc.border_width = c->border; | 274 | c->h = wc.height = h; |
| 270 | XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc); | 275 | wc.border_width = c->border; |
| 271 | configure(c); | 276 | XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc); |
| 272 | XSync(dpy, False); | 277 | configure(c); |
| 278 | XSync(dpy, False); | ||
| 279 | } | ||
| 273 | } | 280 | } |
| 274 | 281 | ||
| 275 | void | 282 | void |
