keep master ratio on resizecol -> arrange

This commit is contained in:
Anselm R. Garbe 2006-10-05 12:59:35 +02:00
parent 2583a7c0d1
commit 6fc8a63041
5 changed files with 20 additions and 24 deletions

View File

@ -37,8 +37,8 @@ static Key key[] = { \
{ MODKEY, XK_k, focusprev, { 0 } }, \ { MODKEY, XK_k, focusprev, { 0 } }, \
{ MODKEY, XK_Return, zoom, { 0 } }, \ { MODKEY, XK_Return, zoom, { 0 } }, \
{ MODKEY, XK_b, togglestackpos, { 0 } }, \ { MODKEY, XK_b, togglestackpos, { 0 } }, \
{ MODKEY, XK_g, resizecol, { .i = 20 } }, \ { MODKEY, XK_g, resizecol, { .i = 1 } }, \
{ MODKEY, XK_s, resizecol, { .i = -20 } }, \ { MODKEY, XK_s, resizecol, { .i = -1 } }, \
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \ { MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \ { MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
{ MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \ { MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \

View File

@ -31,8 +31,8 @@ static Key key[] = { \
{ MODKEY|ShiftMask, XK_Tab, focusprev, { 0 } }, \ { MODKEY|ShiftMask, XK_Tab, focusprev, { 0 } }, \
{ MODKEY, XK_Return, zoom, { 0 } }, \ { MODKEY, XK_Return, zoom, { 0 } }, \
{ MODKEY, XK_b, togglestackpos, { 0 } }, \ { MODKEY, XK_b, togglestackpos, { 0 } }, \
{ MODKEY, XK_g, resizecol, { .i = 20 } }, \ { MODKEY, XK_g, resizecol, { .i = 1 } }, \
{ MODKEY, XK_s, resizecol, { .i = -20 } }, \ { MODKEY, XK_s, resizecol, { .i = -1 } }, \
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \ { MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \ { MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
{ MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \ { MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \

6
dwm.h
View File

@ -101,8 +101,8 @@ struct Client {
extern const char *tags[]; /* all tags */ extern const char *tags[]; /* all tags */
extern char stext[1024]; /* status text */ extern char stext[1024]; /* status text */
extern int bx, by, bw, bh, bmw; /* bar geometry, bar mode label width */ extern int bx, by, bw, bh, bmw; /* bar geometry, bar mode label width */
extern int master, screen, sx, sy, sw, sh; /* screen geometry, master dimension*/ extern int screen, sx, sy, sw, sh; /* screen geometry */
extern unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */ extern unsigned int master, ntags, numlockmask; /* master percent, number of tags, dynamic lock mask */
extern void (*handler[LASTEvent])(XEvent *); /* event handler */ extern void (*handler[LASTEvent])(XEvent *); /* event handler */
extern void (*arrange)(Arg *); /* arrange function, indicates mode */ extern void (*arrange)(Arg *); /* arrange function, indicates mode */
extern Atom wmatom[WMLast], netatom[NetLast]; extern Atom wmatom[WMLast], netatom[NetLast];
@ -168,7 +168,7 @@ extern void dotile(Arg *arg); /* arranges all windows, arg is ignored */
extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */ extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */
extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */ extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */
extern Bool isvisible(Client *c); /* returns True if client is visible */ extern Bool isvisible(Client *c); /* returns True if client is visible */
extern void resizecol(Arg *arg); /* resizes the master dimension with arg's index value */ extern void resizecol(Arg *arg); /* resizes the master percent with arg's index value */
extern void restack(void); /* restores z layers of all clients */ extern void restack(void); /* restores z layers of all clients */
extern void togglestackpos(Arg *arg); /* toggles stack position */ extern void togglestackpos(Arg *arg); /* toggles stack position */
extern void togglemode(Arg *arg); /* toggles global arrange function (dotile/dofloat) */ extern void togglemode(Arg *arg); /* toggles global arrange function (dotile/dofloat) */

6
main.c
View File

@ -19,8 +19,8 @@
char stext[1024]; char stext[1024];
Bool *seltag; Bool *seltag;
int bx, by, bw, bh, bmw, master, screen, sx, sy, sw, sh; int bx, by, bw, bh, bmw, masterd, screen, sx, sy, sw, sh;
unsigned int ntags, numlockmask; unsigned int master, ntags, numlockmask;
Atom wmatom[WMLast], netatom[NetLast]; Atom wmatom[WMLast], netatom[NetLast];
Bool running = True; Bool running = True;
Bool issel = True; Bool issel = True;
@ -136,7 +136,7 @@ setup(void) {
sx = sy = 0; sx = sy = 0;
sw = DisplayWidth(dpy, screen); sw = DisplayWidth(dpy, screen);
sh = DisplayHeight(dpy, screen); sh = DisplayHeight(dpy, screen);
master = ((stackpos == StackBottom ? sh - bh : sw) * MASTER) / 100; master = MASTER;
bx = by = 0; bx = by = 0;
bw = sw; bw = sw;

24
view.c
View File

@ -4,8 +4,6 @@
*/ */
#include "dwm.h" #include "dwm.h"
#define MINDIM 100
/* static */ /* static */
static Client * static Client *
@ -106,6 +104,7 @@ dofloat(Arg *arg) {
void void
dotile(Arg *arg) { dotile(Arg *arg) {
int i, n, stackw, stackh, tw, th; int i, n, stackw, stackh, tw, th;
unsigned int md = ((stackpos == StackBottom ? sh - bh : sw) * master) / 100;
Client *c; Client *c;
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
@ -113,10 +112,10 @@ dotile(Arg *arg) {
if(stackpos == StackBottom) { if(stackpos == StackBottom) {
stackw = sw; stackw = sw;
stackh = sh - bh - master; stackh = sh - bh - md;
} }
else { else {
stackw = sw - master; stackw = sw - md;
stackh = sh - bh; stackh = sh - bh;
} }
@ -145,18 +144,18 @@ dotile(Arg *arg) {
switch(stackpos) { switch(stackpos) {
case StackLeft: case StackLeft:
case StackRight: case StackRight:
c->w = master - 2 * BORDERPX; c->w = md - 2 * BORDERPX;
c->h = sh - bh - 2 * BORDERPX; c->h = sh - bh - 2 * BORDERPX;
break; break;
case StackBottom: case StackBottom:
c->w = sw - 2 * BORDERPX; c->w = sw - 2 * BORDERPX;
c->h = master - 2 * BORDERPX; c->h = md - 2 * BORDERPX;
break; break;
} }
} }
else { /* tile window */ else { /* tile window */
if(stackpos == StackRight) if(stackpos == StackRight)
c->x += master; c->x += md;
if(th > bh) { if(th > bh) {
switch(stackpos) { switch(stackpos) {
case StackLeft: case StackLeft:
@ -166,7 +165,7 @@ dotile(Arg *arg) {
c->h = sh - c->y - 2 * BORDERPX; c->h = sh - c->y - 2 * BORDERPX;
break; break;
case StackBottom: case StackBottom:
c->y = sy + master + (i - 1) * th + bh; c->y = sy + md + (i - 1) * th + bh;
if(i + 1 == n) if(i + 1 == n)
c->h = sh - c->y - 2 * BORDERPX; c->h = sh - c->y - 2 * BORDERPX;
break; break;
@ -176,7 +175,7 @@ dotile(Arg *arg) {
} }
else { /* fallback if th < bh */ else { /* fallback if th < bh */
if(stackpos == StackBottom) if(stackpos == StackBottom)
c->y += master; c->y += md;
c->w = stackw - 2 * BORDERPX; c->w = stackw - 2 * BORDERPX;
c->h = stackh - 2 * BORDERPX; c->h = stackh - 2 * BORDERPX;
} }
@ -238,7 +237,6 @@ isvisible(Client *c) {
void void
resizecol(Arg *arg) { resizecol(Arg *arg) {
int s;
unsigned int n; unsigned int n;
Client *c; Client *c;
@ -248,14 +246,13 @@ resizecol(Arg *arg) {
if(!sel || sel->isfloat || n < 2 || (arrange == dofloat)) if(!sel || sel->isfloat || n < 2 || (arrange == dofloat))
return; return;
s = stackpos == StackBottom ? sh - bh : sw;
if(sel == getnext(clients)) { if(sel == getnext(clients)) {
if(master + arg->i > s - MINDIM || master + arg->i < MINDIM) if(master + arg->i > 95 || master + arg->i < 5)
return; return;
master += arg->i; master += arg->i;
} }
else { else {
if(master - arg->i > s - MINDIM || master - arg->i < MINDIM) if(master - arg->i > 95 || master - arg->i < 5)
return; return;
master -= arg->i; master -= arg->i;
} }
@ -321,7 +318,6 @@ togglestackpos(Arg *arg) {
stackpos = STACKPOS; stackpos = STACKPOS;
else else
stackpos = StackBottom; stackpos = StackBottom;
master = ((stackpos == StackBottom ? sh - bh : sw) * MASTER) / 100;
arrange(NULL); arrange(NULL);
} }