-/*
- * There's no way to check accesses to destroyed windows, thus
- * those cases are ignored (especially on UnmapNotify's).
- * Other types of errors call Xlib's default error handler, which
- * calls exit().
- */
-int
-error_handler(Display *dpy, XErrorEvent *error)
-{
- if(error->error_code == BadWindow
- || (error->request_code == X_SetInputFocus
- && error->error_code == BadMatch)
- || (error->request_code == X_PolyText8
- && error->error_code == BadDrawable)
- || (error->request_code == X_PolyFillRectangle
- && error->error_code == BadDrawable)
- || (error->request_code == X_PolySegment
- && error->error_code == BadDrawable)
- || (error->request_code == X_ConfigureWindow
- && error->error_code == BadMatch)
- || (error->request_code == X_GrabKey
- && error->error_code == BadAccess))
- return 0;
- fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n",
- error->request_code, error->error_code);
- return x_error_handler(dpy, error); /* may call exit() */
+ /* init atoms */
+ wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
+ wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
+ wmatom[WMName] = XInternAtom(dpy, "WM_NAME", False);
+ wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
+ netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
+ netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
+ XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
+ PropModeReplace, (unsigned char *) netatom, NetLast);
+ /* init cursors */
+ cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
+ cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
+ cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
+ /* init modifier map */
+ modmap = XGetModifierMapping(dpy);
+ for (i = 0; i < 8; i++)
+ for (j = 0; j < modmap->max_keypermod; j++) {
+ if(modmap->modifiermap[i * modmap->max_keypermod + j]
+ == XKeysymToKeycode(dpy, XK_Num_Lock))
+ numlockmask = (1 << i);
+ }
+ XFreeModifiermap(modmap);
+ /* select for events */
+ wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
+ | EnterWindowMask | LeaveWindowMask | StructureNotifyMask;
+ wa.cursor = cursor[CurNormal];
+ XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
+ XSelectInput(dpy, root, wa.event_mask);
+ grabkeys();
+ compileregs();
+ for(ntags = 0; tags[ntags]; ntags++);
+ seltags = emallocz(sizeof(Bool) * ntags);
+ seltags[0] = True;
+ /* geometry */
+ sx = sy = 0;
+ sw = DisplayWidth(dpy, screen);
+ sh = DisplayHeight(dpy, screen);
+ initstyle();
+ initlayouts();
+ initbar();
+ /* multihead support */
+ selscreen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);