added some new convenience functions

keyboard
Anselm R. Garbe 18 years ago
parent 5d9146ff37
commit 30af19d442
  1. 49
      client.c
  2. 5
      dwm.h
  3. 5
      tile.c
  4. 11
      view.c

@ -9,13 +9,6 @@
/* static */ /* static */
static void
detachstack(Client *c) {
Client **tc;
for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
*tc = c->snext;
}
static void static void
grabbuttons(Client *c, Bool focused) { grabbuttons(Client *c, Bool focused) {
XUngrabButton(dpy, AnyButton, AnyModifier, c->win); XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
@ -67,6 +60,20 @@ xerrordummy(Display *dsply, XErrorEvent *ee) {
/* extern */ /* extern */
void
attach(Client *c) {
if(clients)
clients->prev = c;
c->next = clients;
clients = c;
}
void
attachstack(Client *c) {
c->snext = stack;
stack = c;
}
void void
configure(Client *c) { configure(Client *c) {
XConfigureEvent ce; XConfigureEvent ce;
@ -85,6 +92,24 @@ configure(Client *c) {
XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ce); XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ce);
} }
void
detach(Client *c) {
if(c->prev)
c->prev->next = c->next;
if(c->next)
c->next->prev = c->prev;
if(c == clients)
clients = c->next;
c->next = c->prev = NULL;
}
void
detachstack(Client *c) {
Client **tc;
for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
*tc = c->snext;
}
void void
focus(Client *c) { focus(Client *c) {
if(c && !isvisible(c)) if(c && !isvisible(c))
@ -95,8 +120,7 @@ focus(Client *c) {
} }
if(c) { if(c) {
detachstack(c); detachstack(c);
c->snext = stack; attachstack(c);
stack = c;
grabbuttons(c, True); grabbuttons(c, True);
} }
sel = c; sel = c;
@ -189,11 +213,8 @@ manage(Window w, XWindowAttributes *wa) {
settags(c, t); settags(c, t);
if(!c->isfloat) if(!c->isfloat)
c->isfloat = (t != 0) || c->isfixed; c->isfloat = (t != 0) || c->isfixed;
if(clients) attach(c);
clients->prev = c; attachstack(c);
c->next = clients;
c->snext = stack;
stack = clients = c;
c->isbanned = True; c->isbanned = True;
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
XMapWindow(dpy, c->win); XMapWindow(dpy, c->win);

@ -99,7 +99,11 @@ extern Display *dpy;
extern Window root, barwin; extern Window root, barwin;
/* client.c */ /* client.c */
extern void attach(Client *c); /* attaches c to global client list */
extern void attachstack(Client *c); /* attaches client to stack */
extern void configure(Client *c); /* send synthetic configure event */ extern void configure(Client *c); /* send synthetic configure event */
extern void detach(Client *c); /* detaches c from global client list */
extern void detachstack(Client *c); /* detaches client from stack */
extern void focus(Client *c); /* focus c, c may be NULL */ extern void focus(Client *c); /* focus c, c may be NULL */
extern Client *getclient(Window w); /* return client of w */ extern Client *getclient(Window w); /* return client of w */
extern Bool isprotodel(Client *c); /* returns True if c->win supports wmatom[WMDelete] */ extern Bool isprotodel(Client *c); /* returns True if c->win supports wmatom[WMDelete] */
@ -144,7 +148,6 @@ extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 *
extern void spawn(Arg *arg); /* forks a new subprocess with to arg's cmd */ extern void spawn(Arg *arg); /* forks a new subprocess with to arg's cmd */
/* view.c */ /* view.c */
extern void detach(Client *c); /* detaches c from global client list */
extern void dofloat(void); /* arranges all windows floating */ extern void dofloat(void); /* arranges all windows floating */
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 */

@ -125,10 +125,7 @@ zoom(Arg *arg) {
if(!(c = nextmanaged(c->next))) if(!(c = nextmanaged(c->next)))
return; return;
detach(c); detach(c);
if(clients) attach(c);
clients->prev = c;
c->next = clients;
clients = c;
focus(c); focus(c);
arrange(); arrange();
} }

@ -7,17 +7,6 @@
void (*arrange)(void) = DEFMODE; void (*arrange)(void) = DEFMODE;
void
detach(Client *c) {
if(c->prev)
c->prev->next = c->next;
if(c->next)
c->next->prev = c->prev;
if(c == clients)
clients = c->next;
c->next = c->prev = NULL;
}
void void
dofloat(void) { dofloat(void) {
Client *c; Client *c;

Loading…
Cancel
Save