applied anydot's 3 minor patches, thank you anydot

This commit is contained in:
Anselm R. Garbe 2007-05-29 11:35:20 +02:00
parent 492c6f10fc
commit 199a601611
4 changed files with 31 additions and 34 deletions

View File

@ -129,8 +129,8 @@ detach(Client *c) {
void void
focus(Client *c) { focus(Client *c) {
if(c && !isvisible(c)) if( !c && selscreen || c && !isvisible(c))
return; for(c = stack; c && !isvisible(c); c = c->snext);
if(sel && sel != c) { if(sel && sel != c) {
grabbuttons(sel, False); grabbuttons(sel, False);
XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]); XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
@ -152,14 +152,6 @@ focus(Client *c) {
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
} }
void
focustopvisible(void) {
Client *c;
for(c = stack; c && !isvisible(c); c = c->snext);
focus(c);
}
void void
killclient(const char *arg) { killclient(const char *arg) {
XEvent ev; XEvent ev;
@ -230,8 +222,7 @@ manage(Window w, XWindowAttributes *wa) {
XMoveWindow(dpy, w, c->x + 2 * sw, c->y); XMoveWindow(dpy, w, c->x + 2 * sw, c->y);
XMapWindow(dpy, w); XMapWindow(dpy, w);
setclientstate(c, NormalState); setclientstate(c, NormalState);
if(isvisible(c)) focus(c);
focus(c);
lt->arrange(); lt->arrange();
} }
@ -401,7 +392,7 @@ unmanage(Client *c) {
detach(c); detach(c);
detachstack(c); detachstack(c);
if(sel == c) if(sel == c)
focustopvisible(); focus(NULL);
XUngrabButton(dpy, AnyButton, AnyModifier, c->win); XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
setclientstate(c, WithdrawnState); setclientstate(c, WithdrawnState);
free(c->tags); free(c->tags);

3
dwm.h
View File

@ -100,8 +100,7 @@ Window root, barwin;
void attach(Client *c); /* attaches c to global client list */ void attach(Client *c); /* attaches c to global client list */
void configure(Client *c); /* send synthetic configure event */ void configure(Client *c); /* send synthetic configure event */
void detach(Client *c); /* detaches c from global client list */ void detach(Client *c); /* detaches c from global client list */
void focus(Client *c); /* focus c, c may be NULL */ void focus(Client *c); /* focus c if visible && !NULL, or focus top visible */
void focustopvisible(void); /* focus top visible window on stack */
void killclient(const char *arg); /* kill sel nicely */ void killclient(const char *arg); /* kill sel nicely */
void manage(Window w, XWindowAttributes *wa); /* manage new client */ void manage(Window w, XWindowAttributes *wa); /* manage new client */
void resize(Client *c, int x, int y, void resize(Client *c, int x, int y,

View File

@ -242,11 +242,11 @@ enternotify(XEvent *e) {
if(ev->mode != NotifyNormal || ev->detail == NotifyInferior) if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
return; return;
if((c = getclient(ev->window)) && isvisible(c)) if(c = getclient(ev->window))
focus(c); focus(c);
else if(ev->window == root) { else if(ev->window == root) {
selscreen = True; selscreen = True;
focustopvisible(); focus(NULL);
} }
} }

View File

@ -13,6 +13,22 @@ static unsigned int nlayouts = 0;
static unsigned int masterw = MASTERWIDTH; static unsigned int masterw = MASTERWIDTH;
static unsigned int nmaster = NMASTER; static unsigned int nmaster = NMASTER;
static void
ban(Client *c) {
if (c->isbanned)
return;
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
c->isbanned = True;
}
static void
unban(Client *c) {
if (!c->isbanned)
return;
XMoveWindow(dpy, c->win, c->x, c->y);
c->isbanned = False;
}
static void static void
tile(void) { tile(void) {
unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th; unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th;
@ -28,9 +44,7 @@ tile(void) {
for(i = 0, c = clients; c; c = c->next) for(i = 0, c = clients; c; c = c->next)
if(isvisible(c)) { if(isvisible(c)) {
if(c->isbanned) unban(c);
XMoveWindow(dpy, c->win, c->x, c->y);
c->isbanned = False;
if(c->isfloating) if(c->isfloating)
continue; continue;
c->ismax = False; c->ismax = False;
@ -60,12 +74,9 @@ tile(void) {
resize(c, nx, ny, nw, nh, False); resize(c, nx, ny, nw, nh, False);
i++; i++;
} }
else { else
c->isbanned = True; ban(c);
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); focus(NULL);
}
if(!sel || !isvisible(sel))
focustopvisible();
restack(); restack();
} }
@ -77,20 +88,16 @@ void
floating(void) { floating(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)) {
if(c->isbanned) if(c->isbanned)
XMoveWindow(dpy, c->win, c->x, c->y); XMoveWindow(dpy, c->win, c->x, c->y);
c->isbanned = False; c->isbanned = False;
resize(c, c->x, c->y, c->w, c->h, True); resize(c, c->x, c->y, c->w, c->h, True);
} }
else { else
c->isbanned = True; ban(c);
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); focus(NULL);
}
}
if(!sel || !isvisible(sel))
focustopvisible();
restack(); restack();
} }