applied yiyus fgeom patch

This commit is contained in:
Anselm R Garbe 2008-04-27 18:22:52 +01:00
parent 858251de46
commit 7f70d90219
2 changed files with 41 additions and 35 deletions

View file

@ -35,8 +35,11 @@ Geom geoms[] = {
Layout layouts[] = { Layout layouts[] = {
/* symbol function isfloating */ /* symbol function isfloating */
{ "[]=", tilev, False }, /* first entry is default */ { "[]=", tilev, False }, /* first entry is default */
{ "<>=", tilev, True },
{ "[]|", tileh, False }, { "[]|", tileh, False },
{ "><>", floating, True }, { "<>|", tileh, True },
{ "><>", NULL, True },
{ "[m]", monocle, False },
{ "[M]", monocle, True }, { "[M]", monocle, True },
}; };

71
dwm.c
View file

@ -68,6 +68,7 @@ typedef struct Client Client;
struct Client { struct Client {
char name[256]; char name[256];
int x, y, w, h; int x, y, w, h;
int fx, fy, fw, fh;
int basew, baseh, incw, inch, maxw, maxh, minw, minh; int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int minax, maxax, minay, maxay; int minax, maxax, minay, maxay;
long flags; long flags;
@ -144,7 +145,6 @@ void *emallocz(unsigned int size);
void enternotify(XEvent *e); void enternotify(XEvent *e);
void eprint(const char *errstr, ...); void eprint(const char *errstr, ...);
void expose(XEvent *e); void expose(XEvent *e);
void floating(void); /* default floating layout */
void focus(Client *c); void focus(Client *c);
void focusin(XEvent *e); void focusin(XEvent *e);
void focusnext(const char *arg); void focusnext(const char *arg);
@ -286,13 +286,17 @@ arrange(void) {
Client *c; Client *c;
for(c = clients; c; c = c->next) for(c = clients; c; c = c->next)
if(isvisible(c)) if(isvisible(c)) {
unban(c); unban(c);
if(lt->isfloating || c->isfloating)
resize(c, c->fx, c->fy, c->fw, c->fh, True);
}
else else
ban(c); ban(c);
focus(NULL); focus(NULL);
lt->arrange(); if(lt->arrange)
lt->arrange();
restack(); restack();
} }
@ -360,7 +364,7 @@ buttonpress(XEvent *e) {
movemouse(c); movemouse(c);
} }
else if(ev->button == Button2) { else if(ev->button == Button2) {
if((floating != lt->arrange) && c->isfloating) if(!lt->isfloating && c->isfloating)
togglefloating(NULL); togglefloating(NULL);
else else
zoom(NULL); zoom(NULL);
@ -669,15 +673,6 @@ expose(XEvent *e) {
drawbar(); drawbar();
} }
void
floating(void) { /* default floating layout */
Client *c;
for(c = clients; c; c = c->next)
if(isvisible(c))
resize(c, c->x, c->y, c->w, c->h, True);
}
void void
focus(Client *c) { focus(Client *c) {
if(!c || (c && !isvisible(c))) if(!c || (c && !isvisible(c)))
@ -993,8 +988,8 @@ manage(Window w, XWindowAttributes *wa) {
/* geometry */ /* geometry */
c->x = wa->x; c->x = wa->x;
c->y = wa->y; c->y = wa->y;
c->w = wa->width; c->w = c->fw = wa->width;
c->h = wa->height; c->h = c->fh = wa->height;
c->oldbw = wa->border_width; c->oldbw = wa->border_width;
if(c->w == sw && c->h == sh) { if(c->w == sw && c->h == sh) {
c->x = sx; c->x = sx;
@ -1010,6 +1005,8 @@ manage(Window w, XWindowAttributes *wa) {
c->y = MAX(c->y, wy); c->y = MAX(c->y, wy);
c->bw = BORDERPX; c->bw = BORDERPX;
} }
c->fx = c->x;
c->fy = c->y;
wc.border_width = c->bw; wc.border_width = c->bw;
XConfigureWindow(dpy, w, CWBorderWidth, &wc); XConfigureWindow(dpy, w, CWBorderWidth, &wc);
@ -1105,8 +1102,11 @@ movemouse(Client *c) {
ny = wy + wh - c->h - 2 * c->bw; ny = wy + wh - c->h - 2 * c->bw;
if(!c->isfloating && !lt->isfloating && (abs(nx - c->x) > SNAP || abs(ny - c->y) > SNAP)) if(!c->isfloating && !lt->isfloating && (abs(nx - c->x) > SNAP || abs(ny - c->y) > SNAP))
togglefloating(NULL); togglefloating(NULL);
if((lt->isfloating) || c->isfloating) if(lt->isfloating || c->isfloating) {
c->fx = nx;
c->fy = ny;
resize(c, nx, ny, c->w, c->h, False); resize(c, nx, ny, c->w, c->h, False);
}
break; break;
} }
} }
@ -1261,10 +1261,16 @@ resizemouse(Client *c) {
XSync(dpy, False); XSync(dpy, False);
nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1); nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1); nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
if(!c->isfloating && !lt->isfloating && (abs(nw - c->w) > SNAP || abs(nh - c->h) > SNAP)) if(!c->isfloating && !lt->isfloating && (abs(nw - c->w) > SNAP || abs(nh - c->h) > SNAP)) {
c->fx = c->x;
c->fy = c->y;
togglefloating(NULL); togglefloating(NULL);
if((lt->isfloating) || c->isfloating) }
if((lt->isfloating) || c->isfloating) {
resize(c, c->x, c->y, nw, nh, True); resize(c, c->x, c->y, nw, nh, True);
c->fw = nw;
c->fh = nh;
}
break; break;
} }
} }
@ -1284,16 +1290,11 @@ restack(void) {
if(!lt->isfloating) { if(!lt->isfloating) {
wc.stack_mode = Below; wc.stack_mode = Below;
wc.sibling = barwin; wc.sibling = barwin;
if(!sel->isfloating) { for(c = stack; c; c = c->snext)
XConfigureWindow(dpy, sel->win, CWSibling|CWStackMode, &wc); if(!c->isfloating && isvisible(c)) {
wc.sibling = sel->win; XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
} wc.sibling = c->win;
for(c = nexttiled(clients); c; c = nexttiled(c->next)) { }
if(c == sel)
continue;
XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
wc.sibling = c->win;
}
} }
XSync(dpy, False); XSync(dpy, False);
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
@ -1841,6 +1842,8 @@ view(const char *arg) {
memcpy(seltags, tmp, TAGSZ); memcpy(seltags, tmp, TAGSZ);
arrange(); arrange();
} }
else
viewprevtag(NULL);
} }
void void
@ -1885,14 +1888,14 @@ void
zoom(const char *arg) { zoom(const char *arg) {
Client *c = sel; Client *c = sel;
if(!sel || lt->isfloating || sel->isfloating)
return;
if(c == nexttiled(clients)) if(c == nexttiled(clients))
if(!(c = nexttiled(c->next))) if(!c || !(c = nexttiled(c->next)))
return; return;
detach(c); if(!lt->isfloating && !sel->isfloating) {
attach(c); detach(c);
focus(c); attach(c);
focus(c);
}
arrange(); arrange();
} }