added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
This commit is contained in:
parent
7b6d5ff298
commit
8a6679b3b4
16
client.c
16
client.c
|
@ -230,13 +230,7 @@ manage(Window w, XWindowAttributes *wa)
|
||||||
DefaultVisual(dpy, screen),
|
DefaultVisual(dpy, screen),
|
||||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
|
CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
|
||||||
|
|
||||||
if(clients)
|
|
||||||
clients->prev = c;
|
|
||||||
c->next = clients;
|
|
||||||
clients = c;
|
|
||||||
|
|
||||||
grabbuttons(c, False);
|
grabbuttons(c, False);
|
||||||
|
|
||||||
if((tc = getclient(trans))) /* inherit tags */
|
if((tc = getclient(trans))) /* inherit tags */
|
||||||
for(i = 0; i < ntags; i++)
|
for(i = 0; i < ntags; i++)
|
||||||
c->tags[i] = tc->tags[i];
|
c->tags[i] = tc->tags[i];
|
||||||
|
@ -246,6 +240,9 @@ manage(Window w, XWindowAttributes *wa)
|
||||||
c->isfloat = trans
|
c->isfloat = trans
|
||||||
|| (c->maxw && c->minw &&
|
|| (c->maxw && c->minw &&
|
||||||
c->maxw == c->minw && c->maxh == c->minh);
|
c->maxw == c->minw && c->maxh == c->minh);
|
||||||
|
|
||||||
|
attach(c);
|
||||||
|
|
||||||
settitle(c);
|
settitle(c);
|
||||||
if(isvisible(c))
|
if(isvisible(c))
|
||||||
sel = c;
|
sel = c;
|
||||||
|
@ -407,12 +404,7 @@ unmanage(Client *c)
|
||||||
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
||||||
XDestroyWindow(dpy, c->twin);
|
XDestroyWindow(dpy, c->twin);
|
||||||
|
|
||||||
if(c->prev)
|
detach(c);
|
||||||
c->prev->next = c->next;
|
|
||||||
if(c->next)
|
|
||||||
c->next->prev = c->prev;
|
|
||||||
if(c == clients)
|
|
||||||
clients = c->next;
|
|
||||||
if(sel == c) {
|
if(sel == c) {
|
||||||
if(trans && (tc = getclient(trans)) && isvisible(tc))
|
if(trans && (tc = getclient(trans)) && isvisible(tc))
|
||||||
sel = tc;
|
sel = tc;
|
||||||
|
|
2
dwm.h
2
dwm.h
|
@ -127,6 +127,8 @@ extern void *erealloc(void *ptr, unsigned int size);
|
||||||
extern void spawn(Arg *arg);
|
extern void spawn(Arg *arg);
|
||||||
|
|
||||||
/* view.c */
|
/* view.c */
|
||||||
|
extern void attach(Client *c);
|
||||||
|
extern void detach(Client *c);
|
||||||
extern void dofloat(Arg *arg);
|
extern void dofloat(Arg *arg);
|
||||||
extern void dotile(Arg *arg);
|
extern void dotile(Arg *arg);
|
||||||
extern void focusnext(Arg *arg);
|
extern void focusnext(Arg *arg);
|
||||||
|
|
63
view.c
63
view.c
|
@ -8,6 +8,45 @@
|
||||||
|
|
||||||
void (*arrange)(Arg *) = DEFMODE;
|
void (*arrange)(Arg *) = DEFMODE;
|
||||||
|
|
||||||
|
void
|
||||||
|
attach(Client *c)
|
||||||
|
{
|
||||||
|
Client *first = getnext(clients);
|
||||||
|
|
||||||
|
if(!first) {
|
||||||
|
if(clients) {
|
||||||
|
for(first = clients; first->next; first = first->next);
|
||||||
|
first->next = c;
|
||||||
|
c->prev = first;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
clients = c;
|
||||||
|
}
|
||||||
|
else if(first == clients) {
|
||||||
|
c->next = clients;
|
||||||
|
clients->prev = c;
|
||||||
|
clients = c;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
first->prev->next = c;
|
||||||
|
c->prev = first->prev;
|
||||||
|
first->prev = c;
|
||||||
|
c->next = first;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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(Arg *arg)
|
dofloat(Arg *arg)
|
||||||
{
|
{
|
||||||
|
@ -228,26 +267,16 @@ view(Arg *arg)
|
||||||
void
|
void
|
||||||
zoom(Arg *arg)
|
zoom(Arg *arg)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c = sel;
|
||||||
|
|
||||||
if(!sel || (arrange != dotile) || sel->isfloat || sel->ismax)
|
if(!c || (arrange != dotile) || c->isfloat || c->ismax)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(sel == getnext(clients)) {
|
if(c == getnext(clients))
|
||||||
if((c = getnext(sel->next)))
|
if(!(c = getnext(c->next)))
|
||||||
sel = c;
|
|
||||||
else
|
|
||||||
return;
|
return;
|
||||||
}
|
detach(c);
|
||||||
|
attach(c);
|
||||||
/* pop */
|
focus(c);
|
||||||
sel->prev->next = sel->next;
|
|
||||||
if(sel->next)
|
|
||||||
sel->next->prev = sel->prev;
|
|
||||||
sel->prev = NULL;
|
|
||||||
clients->prev = sel;
|
|
||||||
sel->next = clients;
|
|
||||||
clients = sel;
|
|
||||||
focus(sel);
|
|
||||||
arrange(NULL);
|
arrange(NULL);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue