about summary refs log tree commit diff stats
path: root/main.c
Commit message (Collapse)AuthorAgeFilesLines
* removed a bunch of lines through making function signatures more consistent ↵Anselm R. Garbe2006-09-121-19/+11
| | | | with my style ( { does not belong to a new line, if function args are single-lined)
* applied Christof Musik's multihead patch for a pathologic cornercaseAnselm R. Garbe2006-09-121-1/+2
|
* fixed some other comments, now also the code side seems to be at a level to ↵Anselm R. Garbe2006-09-111-2/+2
| | | | be reviewed by experienced programmers
* using a global stack for focus recovery on arrange() - seems to work greatAnselm R. Garbe2006-09-071-0/+1
|
* small fixAnselm R. Garbe2006-09-061-0/+1
|
* applied Sanders max_and_focus.patchAnselm R. Garbe2006-09-041-0/+1
|
* trying a different configurationAnselm R. Garbe2006-08-251-3/+3
|
* fixed typoAnselm R. Garbe2006-08-251-1/+1
|
* removed a bunch of lines, made mode symbols configurableAnselm R. Garbe2006-08-251-1/+1
|
* new color stuff/new rendering stuffAnselm R. Garbe2006-08-251-5/+9
|
* back to 3 colorsAnselm R. Garbe2006-08-251-4/+3
|
* 3->4 colorsAnselm R. Garbe2006-08-241-3/+4
|
* changing tag indicator through underlineAnselm R. Garbe2006-08-241-0/+1
|
* removed a blank lineAnselm R. Garbe2006-08-231-1/+0
|
* separated setup stuff into main.c:setup() - this makes main() more readableAnselm R. Garbe2006-08-231-86/+95
|
* rearranged getprotoAnselm R. Garbe2006-08-221-6/+5
|
* removed winprop (merged into getproto)Anselm R. Garbe2006-08-221-27/+7
|
* removed DEFTAGAnselm R. Garbe2006-08-221-1/+1
|
* small renamings of two static functionsAnselm R.Garbe2006-08-211-2/+2
|
* small changes to dwm.1, rearranged order within main event loopAnselm R.Garbe2006-08-211-4/+4
|
* corrected order of cleanup code Anselm R.Garbe2006-08-161-1/+1
|
* we close stdin as wellAnselm R.Garbe2006-08-161-3/+4
|
* extended cleanupAnselm R.Garbe2006-08-151-0/+7
|
* applied jk_to_tab patchAnselm R.Garbe2006-08-151-2/+1
|
* changed main event loopAnselm R.Garbe2006-08-151-10/+7
|
* removed NUMLOCKMASK, added dynamically calculated numlockmask insteadAnselm R.Garbe2006-08-141-7/+19
|
* changed order of selecting input at root windowAnselm R.Garbe2006-08-141-4/+4
|
* removed unneecessary crapAnselm R.Garbe2006-08-141-1/+0
|
* some other small fixesAnselm R.Garbe2006-08-141-8/+8
|
* removed ungrabkeys again (because of sander's mail)Anselm R.Garbe2006-08-141-1/+0
|
* implemented ungrabkeys() which is called in cleanup()Anselm R.Garbe2006-08-141-0/+1
|
* supplying NULL args in selectAnselm R.Garbe2006-08-141-1/+1
|
* reducing ConnectionNumber calls to a bare minimumAnselm R.Garbe2006-08-141-4/+5
|
* implemented viewextend and added M-S-C-n shortcuts for extending the current ↵Anselm R.Garbe2006-08-111-3/+3
| | | | view... updated man page (works great!) nice feature
* implement multi-tag selection through button3 click on the specific tagAnselm R.Garbe2006-08-111-1/+3
|
* prepared 0.8 0.8Anselm R.Garbe2006-08-101-0/+1
|
* readded border color, this sucks leastAnselm R.Garbe2006-08-101-0/+1
|
* removed unnecessary border colorAnselm R.Garbe2006-08-101-1/+0
|
* removed NET_ACTIVE_WINDOW handlingAnselm R.Garbe2006-08-081-1/+0
|
* implemented NET_ACTIVE_WINDOW supportAnselm R.Garbe2006-08-081-0/+1
|
* applied Sanders tiny patchesAnselm R.Garbe2006-08-081-1/+2
|
* small fix of a commentarg@10ksloc.org2006-08-071-1/+1
|
* changed getproto, maybe that might fix the killclient issue reported on the listarg@10ksloc.org2006-08-071-2/+3
|
* slight fixarg@10ksloc.org2006-08-051-3/+2
|
* switched to regexp matching for Rulesarg@10ksloc.org2006-08-041-0/+1
|
* removed TLast tag enum, now tags is simple defined as char *[] array, the ↵arg@10ksloc.org2006-08lass="w"> NULL; if(XQueryTree(dpy, root, &d1, &d2, &wins, &num)) { for(i = 0; i < num; i++) { if(!XGetWindowAttributes(dpy, wins[i], &wa)) continue; if(wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1)) continue; if(wa.map_state == IsViewable) manage(wins[i], &wa); } } if(wins) XFree(wins); } static void setup() { int i, j; unsigned int mask; Window w; XModifierKeymap *modmap; XSetWindowAttributes wa; /* init atoms */ wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", 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); 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); } } XFree(modmap); wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask | EnterWindowMask | LeaveWindowMask; wa.cursor = cursor[CurNormal]; XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa); grabkeys(); initrregs(); for(ntags = 0; tags[ntags]; ntags++); seltag = emallocz(sizeof(Bool) * ntags); seltag[0] = True; /* style */ dc.norm[ColBG] = getcolor(NORMBGCOLOR); dc.norm[ColFG] = getcolor(NORMFGCOLOR); dc.sel[ColBG] = getcolor(SELBGCOLOR); dc.sel[ColFG] = getcolor(SELFGCOLOR); dc.status[ColBG] = getcolor(STATUSBGCOLOR); dc.status[ColFG] = getcolor(STATUSFGCOLOR); setfont(FONT); bmw = textw(FLOATSYMBOL) > textw(TILESYMBOL) ? textw(FLOATSYMBOL) : textw(TILESYMBOL); sx = sy = 0; sw = DisplayWidth(dpy, screen); sh = DisplayHeight(dpy, screen); mw = (sw * MASTERW) / 100; bx = by = 0; bw = sw; dc.h = bh = dc.font.height + 2; wa.override_redirect = 1; wa.background_pixmap = ParentRelative; wa.event_mask = ButtonPressMask | ExposureMask; barwin = XCreateWindow(dpy, root, bx, by, bw, bh, 0, DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen), CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); XDefineCursor(dpy, barwin, cursor[CurNormal]); XMapRaised(dpy, barwin); dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen)); dc.gc = XCreateGC(dpy, root, 0, 0); XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); strcpy(stext, "dwm-"VERSION); } /* * Startup Error handler to check if another window manager * is already running. */ static int xerrorstart(Display *dsply, XErrorEvent *ee) { otherwm = True; return -1; } /* extern */ int getproto(Window w) { int i, format, protos, status; unsigned long extra, res; Atom *protocols, real; protos = 0; status = XGetWindowProperty(dpy, w, wmatom[WMProtocols], 0L, 20L, False, XA_ATOM, &real, &format, &res, &extra, (unsigned char **)&protocols); if(status != Success || protocols == 0) return protos; for(i = 0; i < res; i++) if(protocols[i] == wmatom[WMDelete]) protos |= PROTODELWIN; free(protocols); return protos; } void sendevent(Window w, Atom a, long value) { XEvent e; e.type = ClientMessage; e.xclient.window = w; e.xclient.message_type = a; e.xclient.format = 32; e.xclient.data.l[0] = value; e.xclient.data.l[1] = CurrentTime; XSendEvent(dpy, w, False, NoEventMask, &e); XSync(dpy, False); } void quit(Arg *arg) { readin = running = False; } /* * There's no way to check accesses to destroyed windows, thus those cases are * ignored (especially on UnmapNotify's). Other types of errors call Xlibs * default error handler, which calls exit(). */ int xerror(Display *dpy, XErrorEvent *ee) { if(ee->error_code == BadWindow || (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch) || (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable) || (ee->request_code == X_PolyFillRectangle && ee->error_code == BadDrawable) || (ee->request_code == X_PolySegment && ee->error_code == BadDrawable) || (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch) || (ee->request_code == X_GrabKey && ee->error_code == BadAccess)) return 0; fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n", ee->request_code, ee->error_code); return xerrorxlib(dpy, ee); /* may call exit() */ } int main(int argc, char *argv[]) { int r, xfd; fd_set rd; if(argc == 2 && !strncmp("-v", argv[1], 3)) { fputs("dwm-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout); exit(EXIT_SUCCESS); } else if(argc != 1) eprint("usage: dwm [-v]\n"); dpy = XOpenDisplay(0); if(!dpy) eprint("dwm: cannot open display\n"); xfd = ConnectionNumber(dpy); screen = DefaultScreen(dpy); root = RootWindow(dpy, screen); otherwm = False; XSetErrorHandler(xerrorstart); /* this causes an error if some other window manager is running */ XSelectInput(dpy, root, SubstructureRedirectMask); XSync(dpy, False); if(otherwm) eprint("dwm: another window manager is already running\n"); XSync(dpy, False); XSetErrorHandler(NULL); xerrorxlib = XSetErrorHandler(xerror); XSync(dpy, False); setup(); drawstatus(); scan(); /* main event loop, also reads status text from stdin */ XSync(dpy, False); procevent(); readin = True; while(running) { FD_ZERO(&rd); if(readin) FD_SET(STDIN_FILENO, &rd); FD_SET(xfd, &rd); r = select(xfd + 1, &rd, NULL, NULL, NULL); if((r == -1) && (errno == EINTR)) continue; if(r > 0) { if(readin && FD_ISSET(STDIN_FILENO, &rd)) { readin = NULL != fgets(stext, sizeof(stext), stdin); if(readin) stext[strlen(stext) - 1] = 0; else strcpy(stext, "broken pipe"); drawstatus(); } } else if(r < 0) eprint("select failed\n"); procevent(); } cleanup(); XCloseDisplay(dpy); return 0; }