[UnmapNotify] = unmapnotify
};
static Atom wmatom[WMLast], netatom[NetLast];
-static Bool otherwm;
static Bool running = True;
static Cursor cursor[CurLast];
static Display *dpy;
if(c->inch)
*h -= *h % c->inch;
/* restore base dimensions */
- *w += c->basew;
- *h += c->baseh;
- *w = MAX(*w, c->minw);
- *h = MAX(*h, c->minh);
+ *w = MAX(*w + c->basew, c->minw);
+ *h = MAX(*h + c->baseh, c->minh);
if(c->maxw)
*w = MIN(*w, c->maxw);
if(c->maxh)
void
checkotherwm(void) {
- otherwm = False;
xerrorxlib = XSetErrorHandler(xerrorstart);
/* this causes an error if some other window manager is running */
XSelectInput(dpy, DefaultRootWindow(dpy), SubstructureRedirectMask);
XSync(dpy, False);
- if(otherwm)
- die("dwm: another window manager is already running\n");
XSetErrorHandler(xerror);
XSync(dpy, False);
}
void
enternotify(XEvent *e) {
- Client *c;
Monitor *m;
XCrossingEvent *ev = &e->xcrossing;
unfocus(selmon->sel, True);
selmon = m;
}
- if((c = wintoclient(ev->window)))
- focus(c);
- else
- focus(NULL);
+ focus((wintoclient(ev->window)));
}
void
void
focusmon(const Arg *arg) {
- Monitor *m = NULL;
+ Monitor *m;
if(!mons->next)
return;
XFreeStringList(missing);
}
if(dc.font.set) {
- XFontSetExtents *font_extents;
XFontStruct **xfonts;
char **font_names;
dc.font.ascent = dc.font.descent = 0;
- font_extents = XExtentsOfFontSet(dc.font.set);
+ XExtentsOfFontSet(dc.font.set);
n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names);
for(i = 0, dc.font.ascent = 0, dc.font.descent = 0; i < n; i++) {
dc.font.ascent = MAX(dc.font.ascent, (*xfonts)->ascent);
void
manage(Window w, XWindowAttributes *wa) {
- static Client cz;
Client *c, *t = NULL;
Window trans = None;
XWindowChanges wc;
- if(!(c = malloc(sizeof(Client))))
+ if(!(c = calloc(1, sizeof(Client))))
die("fatal: could not malloc() %u bytes\n", sizeof(Client));
- *c = cz;
c->win = w;
updatetitle(c);
- if(XGetTransientForHint(dpy, w, &trans))
- t = wintoclient(trans);
- if(t) {
+ if(XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) {
c->mon = t->mon;
c->tags = t->tags;
}
c->h = c->oldh = wa->height;
c->oldbw = wa->border_width;
if(c->w == c->mon->mw && c->h == c->mon->mh) {
- c->isfloating = 1;
+ c->isfloating = True;
c->x = c->mon->mx;
c->y = c->mon->my;
c->bw = 0;
switch (ev->atom) {
default: break;
case XA_WM_TRANSIENT_FOR:
- XGetTransientForHint(dpy, c->win, &trans);
- if(!c->isfloating && (c->isfloating = (wintoclient(trans) != NULL)))
+ if(!c->isfloating && (XGetTransientForHint(dpy, c->win, &trans)) &&
+ (c->isfloating = (wintoclient(trans)) != NULL))
arrange(c->mon);
break;
case XA_WM_NORMAL_HINTS:
c->oldstate = c->isfloating;
c->oldbw = c->bw;
c->bw = 0;
- c->isfloating = 1;
+ c->isfloating = True;
resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
XRaiseWindow(dpy, c->win);
}
}
}
-
void
sigchld(int unused) {
if(signal(SIGCHLD, sigchld) == SIG_ERR)
* is already running. */
int
xerrorstart(Display *dpy, XErrorEvent *ee) {
- otherwm = True;
+ die("dwm: another window manager is already running\n");
return -1;
}