removed initags -- we autoselect the first tag in each view instead

This commit is contained in:
anselm@anselm1 2008-02-28 20:02:57 +00:00
parent d99ec61482
commit f1719ac2de
2 changed files with 31 additions and 25 deletions

View File

@ -14,7 +14,6 @@
/* old */ /* old */
const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "nil", "6", "7", "8", "www" }; const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "nil", "6", "7", "8", "www" };
unsigned int vtags[LENGTH(tags)] = { 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 }; unsigned int vtags[LENGTH(tags)] = { 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 };
Bool initags[LENGTH(tags)] = { [0] = True, [5] = True };
Rule rules[] = { Rule rules[] = {
/* class:instance:title substr tags ref isfloating */ /* class:instance:title substr tags ref isfloating */

53
dwm.c
View File

@ -227,7 +227,6 @@ void (*handler[LASTEvent]) (XEvent *) = {
[UnmapNotify] = unmapnotify [UnmapNotify] = unmapnotify
}; };
Atom wmatom[WMLast], netatom[NetLast]; Atom wmatom[WMLast], netatom[NetLast];
Bool isxinerama = False;
Bool domwfact = True; Bool domwfact = True;
Bool dozoom = True; Bool dozoom = True;
Bool otherwm, readin; Bool otherwm, readin;
@ -246,6 +245,7 @@ Window root;
/* configuration, allows nested code to access above variables */ /* configuration, allows nested code to access above variables */
#include "config.h" #include "config.h"
#define TAGSZ (LENGTH(tags) * sizeof(Bool))
/* function implementations */ /* function implementations */
void void
@ -286,7 +286,7 @@ applyrules(Client *c) {
if(ch.res_name) if(ch.res_name)
XFree(ch.res_name); XFree(ch.res_name);
if(!matched) { if(!matched) {
memcpy(c->tags, seltags, sizeof initags); memcpy(c->tags, seltags, TAGSZ);
c->view = selview; c->view = selview;
} }
} }
@ -654,10 +654,8 @@ enternotify(XEvent *e) {
Client *c; Client *c;
XCrossingEvent *ev = &e->xcrossing; XCrossingEvent *ev = &e->xcrossing;
if(ev->mode != NotifyNormal || ev->detail == NotifyInferior) { if((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root)
if(!isxinerama || ev->window != root)
return; return;
}
if((c = getclient(ev->window))) if((c = getclient(ev->window)))
focus(c); focus(c);
else else
@ -1042,7 +1040,7 @@ manage(Window w, XWindowAttributes *wa) {
XWindowChanges wc; XWindowChanges wc;
c = emallocz(sizeof(Client)); c = emallocz(sizeof(Client));
c->tags = emallocz(sizeof initags); c->tags = emallocz(TAGSZ);
c->win = w; c->win = w;
applyrules(c); applyrules(c);
@ -1082,7 +1080,7 @@ manage(Window w, XWindowAttributes *wa) {
if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success)) if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success))
for(t = clients; t && t->win != trans; t = t->next); for(t = clients; t && t->win != trans; t = t->next);
if(t) if(t)
memcpy(c->tags, t->tags, sizeof initags); memcpy(c->tags, t->tags, TAGSZ);
if(!c->isfloating) if(!c->isfloating)
c->isfloating = (rettrans == Success) || c->isfixed; c->isfloating = (rettrans == Success) || c->isfixed;
attach(c); attach(c);
@ -1501,7 +1499,7 @@ setmwfact(const char *arg) {
void void
setup(void) { setup(void) {
unsigned int i; unsigned int i, j;
View *v; View *v;
XSetWindowAttributes wa; XSetWindowAttributes wa;
XineramaScreenInfo *info = NULL; XineramaScreenInfo *info = NULL;
@ -1519,10 +1517,10 @@ setup(void) {
cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur); cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
if((isxinerama = XineramaIsActive(dpy))) if(XineramaIsActive(dpy))
info = XineramaQueryScreens(dpy, &nviews); info = XineramaQueryScreens(dpy, &nviews);
#if defined(AIM_XINERAMA) #if defined(AIM_XINERAMA)
isxinerama = True;
nviews = 2; /* aim Xinerama */ nviews = 2; /* aim Xinerama */
#endif #endif
views = emallocz(nviews * sizeof(View)); views = emallocz(nviews * sizeof(View));
@ -1551,16 +1549,27 @@ nviews = 2; /* aim Xinerama */
blw = i; blw = i;
} }
seltags = emallocz(sizeof initags); seltags = emallocz(TAGSZ);
prevtags = emallocz(sizeof initags); prevtags = emallocz(TAGSZ);
memcpy(seltags, initags, sizeof initags);
memcpy(prevtags, initags, sizeof initags); /* check, if vtags need assistance, because there is only 1 view */
if(nviews == 1)
for(i = 0; i < LENGTH(tags); i++)
vtags[i] = 0;
for(i = 0; i < nviews; i++) { for(i = 0; i < nviews; i++) {
/* init geometry */ /* init geometry */
v = &views[i]; v = &views[i];
if(nviews != 1 && isxinerama) { /* select first tag in each view */
for(j = 0; j < LENGTH(tags); j++)
if(vtags[j] == i) {
seltags[j] = prevtags[j] = True;
break;
}
if(info) {
#if defined(AIM_XINERAMA) #if defined(AIM_XINERAMA)
v->w = DisplayWidth(dpy, screen) / 2; v->w = DisplayWidth(dpy, screen) / 2;
@ -1693,8 +1702,6 @@ tile(View *v) {
for(i = 0, c = mc = nexttiled(clients, v); c; c = nexttiled(c->next, v)) { for(i = 0, c = mc = nexttiled(clients, v); c; c = nexttiled(c->next, v)) {
if(i == 0) { /* master */ if(i == 0) { /* master */
nx = v->wax;
ny = v->way;
nw = mw - 2 * c->border; nw = mw - 2 * c->border;
nh = v->wah - 2 * c->border; nh = v->wah - 2 * c->border;
} }
@ -1908,9 +1915,9 @@ view(const char *arg) {
tmp[i] = (NULL == arg); tmp[i] = (NULL == arg);
tmp[idxoftag(arg)] = True; tmp[idxoftag(arg)] = True;
if(memcmp(seltags, tmp, sizeof initags) != 0) { if(memcmp(seltags, tmp, TAGSZ) != 0) {
memcpy(prevtags, seltags, sizeof initags); memcpy(prevtags, seltags, TAGSZ);
memcpy(seltags, tmp, sizeof initags); memcpy(seltags, tmp, TAGSZ);
arrange(); arrange();
} }
} }
@ -1934,9 +1941,9 @@ void
viewprevtag(const char *arg) { viewprevtag(const char *arg) {
static Bool tmp[LENGTH(tags)]; static Bool tmp[LENGTH(tags)];
memcpy(tmp, seltags, sizeof initags); memcpy(tmp, seltags, TAGSZ);
memcpy(seltags, prevtags, sizeof initags); memcpy(seltags, prevtags, TAGSZ);
memcpy(prevtags, tmp, sizeof initags); memcpy(prevtags, tmp, TAGSZ);
arrange(); arrange();
} }