Introduction
Introduction Statistics Contact Development Disclaimer Help
tusing double-linked list in order to get correct prev focus handling - dwm - […
git clone git://src.adamsgaard.dk/dwm
Log
Files
Refs
README
LICENSE
---
commit 72707c2fae68f5eba6ea97cbf356bfb968c8a15d
parent 06dc514bc7327f1a2a35cb533bcf18715305da44
Author: [email protected] <unknown>
Date: Thu, 20 Jul 2006 16:54:20 +0200
using double-linked list in order to get correct prev focus handling
Diffstat:
M client.c | 46 +++++++++++++++++++++--------…
M config.mk | 10 +++++-----
M dwm.h | 3 ++-
M tag.c | 7 +++++++
4 files changed, 45 insertions(+), 21 deletions(-)
---
diff --git a/client.c b/client.c
t@@ -77,7 +77,6 @@ focusnext(Arg *arg)
c = getnext(clients, tsel);
if(c) {
higher(c);
- c->revert = sel;
focus(c);
}
}
t@@ -93,7 +92,11 @@ focusprev(Arg *arg)
if(sel->ismax)
togglemax(NULL);
- if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) {
+ if(!(c = getprev(sel->prev))) {
+ for(c = clients; c && c->next; c = c->next);
+ c = getprev(c);
+ }
+ if(c) {
higher(c);
focus(c);
}
t@@ -127,6 +130,8 @@ gravitate(Client *c, Bool invert)
int dx = 0, dy = 0;
switch(c->grav) {
+ default:
+ break;
case StaticGravity:
case NorthWestGravity:
case NorthGravity:
t@@ -143,11 +148,11 @@ gravitate(Client *c, Bool invert)
case SouthWestGravity:
dy = -(c->h);
break;
- default:
- break;
}
switch (c->grav) {
+ default:
+ break;
case StaticGravity:
case NorthWestGravity:
case WestGravity:
t@@ -164,8 +169,6 @@ gravitate(Client *c, Bool invert)
case SouthEastGravity:
dx = -(c->w + c->border);
break;
- default:
- break;
}
if(invert) {
t@@ -204,7 +207,6 @@ lower(Client *c)
void
manage(Window w, XWindowAttributes *wa)
{
- int diff;
Client *c;
Window trans;
XSetWindowAttributes twa;
t@@ -224,7 +226,7 @@ manage(Window w, XWindowAttributes *wa)
c->proto = getproto(c->win);
setsize(c);
XSelectInput(dpy, c->win,
- StructureNotifyMask | PropertyChangeMask | EnterWindow…
+ StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
XGetTransientForHint(dpy, c->win, &trans);
twa.override_redirect = 1;
twa.background_pixmap = ParentRelative;
t@@ -237,6 +239,8 @@ manage(Window w, XWindowAttributes *wa)
settags(c);
+ if(clients)
+ clients->prev = c;
c->next = clients;
clients = c;
t@@ -264,6 +268,7 @@ manage(Window w, XWindowAttributes *wa)
else {
XMapRaised(dpy, c->win);
XMapRaised(dpy, c->title);
+
}
}
t@@ -273,9 +278,15 @@ pop(Client *c)
Client **l;
for(l = &clients; *l && *l != c; l = &(*l)->next);
+ if(c->prev)
+ c->prev->next = c->next;
+ if(c->next)
+ c->next->prev = c->prev;
*l = c->next;
- c->next = clients; /* pop */
+ if(clients)
+ clients->prev = c;
+ c->next = clients;
clients = c;
arrange(NULL);
}
t@@ -439,13 +450,18 @@ unmanage(Client *c)
XDestroyWindow(dpy, c->title);
for(l = &clients; *l && *l != c; l = &(*l)->next);
+ if(c->prev)
+ c->prev->next = c->next;
+ if(c->next)
+ c->next->prev = c->prev;
*l = c->next;
- for(l = &clients; *l; l = &(*l)->next)
- if((*l)->revert == c)
- (*l)->revert = NULL;
- if(sel == c)
- sel = sel->revert ? sel->revert : clients;
-
+ if(sel == c) {
+ sel = getnext(c->next, tsel);
+ if(!sel)
+ sel = getprev(c->prev);
+ if(!sel)
+ sel = clients;
+ }
free(c);
XSync(dpy, False);
diff --git a/config.mk b/config.mk
t@@ -13,12 +13,12 @@ VERSION = 0.5
LIBS = -L${PREFIX}/lib -L/usr/lib -lc -L${X11LIB} -lX11
# Linux/BSD
-CFLAGS = -O3 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
- -DVERSION=\"${VERSION}\"
-LDFLAGS = ${LIBS}
-#CFLAGS = -g -Wall -O2 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
+#CFLAGS = -O3 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
# -DVERSION=\"${VERSION}\"
-#LDFLAGS = -g ${LIBS}
+#LDFLAGS = ${LIBS}
+CFLAGS = -g -Wall -O2 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
+ -DVERSION=\"${VERSION}\"
+LDFLAGS = -g ${LIBS}
# Solaris
diff --git a/dwm.h b/dwm.h
t@@ -76,7 +76,7 @@ struct Client {
Bool isfloat;
Bool ismax;
Client *next;
- Client *revert;
+ Client *prev;
Window win;
Window title;
};
t@@ -135,6 +135,7 @@ extern void appendtag(Arg *arg);
extern void dofloat(Arg *arg);
extern void dotile(Arg *arg);
extern Client *getnext(Client *c, unsigned int t);
+extern Client *getprev(Client *c);
extern void heretag(Arg *arg);
extern void replacetag(Arg *arg);
extern void settags(Client *c);
diff --git a/tag.c b/tag.c
t@@ -140,6 +140,13 @@ getnext(Client *c, unsigned int t)
return c;
}
+Client *
+getprev(Client *c)
+{
+ for(; c && !c->tags[tsel]; c = c->prev);
+ return c;
+}
+
void
heretag(Arg *arg)
{
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.