[hackers] [dwm] interactive resizals allow display dimensions again || Anselm R Garbe

From: <hg_AT_suckless.org>
Date: Thu, 2 Jul 2009 17:30:07 +0000 (UTC)

changeset: 1443:dabe14ecb5e9
tag: tip
user: Anselm R Garbe <anselm_AT_garbe.us>
date: Thu Jul 02 18:30:01 2009 +0100
files: dwm.c
description:
interactive resizals allow display dimensions again

diff -r dfbdc1947270 -r dabe14ecb5e9 dwm.c
--- a/dwm.c Thu Jul 02 16:48:54 2009 +0100
+++ b/dwm.c Thu Jul 02 18:30:01 2009 +0100
@@ -148,7 +148,7 @@
 
 /* function declarations */
 static void applyrules(Client *c);
-static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h);
+static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact);
 static void arrange(void);
 static void attach(Client *c);
 static void attachstack(Client *c);
@@ -194,7 +194,7 @@
 static Monitor *pointertomon(int x, int y);
 static void propertynotify(XEvent *e);
 static void quit(const Arg *arg);
-static void resize(Client *c, int x, int y, int w, int h);
+static void resize(Client *c, int x, int y, int w, int h, Bool interact);
 static void resizemouse(const Arg *arg);
 static void restack(Monitor *m);
 static void run(void);
@@ -298,7 +298,7 @@
 }
 
 Bool
-applysizehints(Client *c, int *x, int *y, int *w, int *h) {
+applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact) {
         Bool baseismin;
         Monitor *m = c->mon;
 
@@ -306,14 +306,26 @@
         *w = MAX(1, *w);
         *h = MAX(1, *h);
 
- if(*x > m->mx + m->mw)
- *x = m->mx + m->mw - WIDTH(c);
- if(*y > m->my + m->mh)
- *y = m->my + m->mh - HEIGHT(c);
- if(*x + *w + 2 * c->bw < m->mx)
- *x = m->mx;
- if(*y + *h + 2 * c->bw < m->my)
- *y = m->my;
+ if(interact) {
+ if(*x > sw)
+ *x = sw - WIDTH(c);
+ if(*y > sh)
+ *y = sh - HEIGHT(c);
+ if(*x + *w + 2 * c->bw < 0)
+ *x = 0;
+ if(*y + *h + 2 * c->bw < 0)
+ *y = 0;
+ }
+ else {
+ if(*x > m->mx + m->mw)
+ *x = m->mx + m->mw - WIDTH(c);
+ if(*y > m->my + m->mh)
+ *y = m->my + m->mh - HEIGHT(c);
+ if(*x + *w + 2 * c->bw < m->mx)
+ *x = m->mx;
+ if(*y + *h + 2 * c->bw < m->my)
+ *y = m->my;
+ }
         if(*h < bh)
                 *h = bh;
         if(*w < bh)
@@ -1120,7 +1132,7 @@
         Client *c;
 
         for(c = nexttiled(m->clients); c; c = nexttiled(c->next))
- resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw);
+ resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, False);
 }
 
 void
@@ -1166,7 +1178,7 @@
                                         togglefloating(NULL);
                         }
                         if(!lt[selmon->sellt]->arrange || c->isfloating)
- resize(c, nx, ny, c->w, c->h);
+ resize(c, nx, ny, c->w, c->h, True);
                         break;
                 }
         }
@@ -1235,10 +1247,10 @@
 }
 
 void
-resize(Client *c, int x, int y, int w, int h) {
+resize(Client *c, int x, int y, int w, int h, Bool interact) {
         XWindowChanges wc;
 
- if(applysizehints(c, &x, &y, &w, &h)) {
+ if(applysizehints(c, &x, &y, &w, &h, interact)) {
                 c->x = wc.x = x;
                 c->y = wc.y = y;
                 c->w = wc.width = w;
@@ -1286,7 +1298,7 @@
                                         togglefloating(NULL);
                         }
                         if(!lt[selmon->sellt]->arrange || c->isfloating)
- resize(c, c->x, c->y, nw, nh);
+ resize(c, c->x, c->y, nw, nh, True);
                         break;
                 }
         }
@@ -1484,7 +1496,7 @@
         if(ISVISIBLE(c)) { /* show clients top down */
                 XMoveWindow(dpy, c->win, c->x, c->y);
                 if(!lt[c->mon->sellt]->arrange || c->isfloating)
- resize(c, c->x, c->y, c->w, c->h);
+ resize(c, c->x, c->y, c->w, c->h, False);
                 showhide(c->snext);
         }
         else { /* hide clients bottom up */
@@ -1554,7 +1566,7 @@
         /* master */
         c = nexttiled(m->clients);
         mw = m->mfact * m->ww;
- resize(c, m->wx, m->wy, (n == 1 ? m->ww : mw) - 2 * c->bw, m->wh - 2 * c->bw);
+ resize(c, m->wx, m->wy, (n == 1 ? m->ww : mw) - 2 * c->bw, m->wh - 2 * c->bw, False);
 
         if(--n == 0)
                 return;
@@ -1569,7 +1581,7 @@
 
         for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
                 resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
- ? m->wy + m->wh - y - 2 * c->bw : h - 2 * c->bw));
+ ? m->wy + m->wh - y - 2 * c->bw : h - 2 * c->bw), False);
                 if(h != m->wh)
                         y = c->y + HEIGHT(c);
         }
@@ -1589,7 +1601,8 @@
                 return;
         selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed;
         if(selmon->sel->isfloating)
- resize(selmon->sel, selmon->sel->x, selmon->sel->y, selmon->sel->w, selmon->sel->h);
+ resize(selmon->sel, selmon->sel->x, selmon->sel->y,
+ selmon->sel->w, selmon->sel->h, False);
         arrange();
 }
 
Received on Thu Jul 02 2009 - 17:30:07 UTC

This archive was generated by hypermail 2.2.0 : Thu Jul 02 2009 - 17:36:05 UTC