[hackers] dwm: new tip (= 733)

From: Anselm R. Garbe <arg_AT_suckless.org>
Date: Tue, 06 Feb 2007 15:30:02 +0100

changeset: 733:1950833a5614
tag: tip
user: Anselm R. Garbe <arg_AT_suckless.org>
date: Tue Feb 06 15:29:19 2007 +0100
files: client.c
description:
yet another fix

changeset: 732:a642068c4834
user: Anselm R. Garbe <arg_AT_suckless.org>
date: Tue Feb 06 15:28:25 2007 +0100
files: client.c
description:
simplification

changeset: 731:29c9b557ed95
user: Anselm R. Garbe <arg_AT_suckless.org>
date: Tue Feb 06 15:22:13 2007 +0100
files: client.c dwm.h
description:
implemented aspect ratio support of windows

diff -r 8997e28553a8 -r 1950833a5614 client.c
--- a/client.c Mon Feb 05 11:19:46 2007 +0100
+++ b/client.c Tue Feb 06 15:29:19 2007 +0100
@@ -184,15 +184,12 @@ manage(Window w, XWindowAttributes *wa)
 
 void
 resize(Client *c, Bool sizehints) {
+ float actual, dx, dy, max, min;
         XWindowChanges wc;
 
         if(c->w <= 0 || c->h <= 0)
                 return;
         if(sizehints) {
- if(c->incw)
- c->w -= (c->w - c->basew) % c->incw;
- if(c->inch)
- c->h -= (c->h - c->baseh) % c->inch;
                 if(c->minw && c->w < c->minw)
                         c->w = c->minw;
                 if(c->minh && c->h < c->minh)
@@ -201,6 +198,32 @@ resize(Client *c, Bool sizehints) {
                         c->w = c->maxw;
                 if(c->maxh && c->h > c->maxh)
                         c->h = c->maxh;
+ /* inspired by algorithm from fluxbox */
+ if(c->minay > 0 && c->maxay && (c->h - c->baseh) > 0) {
+ dx = (float)(c->w - c->basew);
+ dy = (float)(c->h - c->baseh);
+ min = (float)(c->minax) / (float)(c->minay);
+ max = (float)(c->maxax) / (float)(c->maxay);
+ actual = dx / dy;
+ if(max > 0 && min > 0 && actual > 0) {
+ if(actual < min) {
+ dy = (dx * min + dy) / (min * min + 1);
+ dx = dy * min;
+ c->w = (int)dx + c->basew;
+ c->h = (int)dy + c->baseh;
+ }
+ else if(actual > max) {
+ dy = (dx * min + dy) / (max * max + 1);
+ dx = dy * min;
+ c->w = (int)dx + c->basew;
+ c->h = (int)dy + c->baseh;
+ }
+ }
+ }
+ if(c->incw)
+ c->w -= (c->w - c->basew) % c->incw;
+ if(c->inch)
+ c->h -= (c->h - c->baseh) % c->inch;
         }
         if(c->w == sw && c->h == sh)
                 c->border = 0;
@@ -257,6 +280,14 @@ updatesizehints(Client *c) {
         }
         else
                 c->minw = c->minh = 0;
+ if(c->flags & PAspect) {
+ c->minax = size.min_aspect.x;
+ c->minay = size.min_aspect.y;
+ c->maxax = size.max_aspect.x;
+ c->maxay = size.max_aspect.y;
+ }
+ else
+ c->minax = c->minay = c->maxax = c->maxay = 0;
         c->isfixed = (c->maxw && c->minw && c->maxh && c->minh &&
                                 c->maxw == c->minw && c->maxh == c->minh);
 }
diff -r 8997e28553a8 -r 1950833a5614 dwm.h
--- a/dwm.h Mon Feb 05 11:19:46 2007 +0100
+++ b/dwm.h Tue Feb 06 15:29:19 2007 +0100
@@ -73,6 +73,7 @@ struct Client {
         int x, y, w, h;
         int rx, ry, rw, rh; /* revert geometry */
         int basew, baseh, incw, inch, maxw, maxh, minw, minh;
+ int minax, minay, maxax, maxay;
         long flags;
         unsigned int border;
         Bool isfloat, isfixed, ismax;
Received on Tue Feb 06 2007 - 15:30:03 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:54:56 UTC