X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=main.c;h=68f60c70c44f220a3cd8f4ee2acc772107303fcd;hb=d2dd58eabde15ebf0a2c4c61239d65543931ae04;hp=ba5e2e0a35cc9a2ae79f96f553234c1e48b97e34;hpb=5a5851bac2670624f30c84efe4129f0101f62255;p=dwm.git diff --git a/main.c b/main.c index ba5e2e0..68f60c7 100644 --- a/main.c +++ b/main.c @@ -17,13 +17,13 @@ /* extern */ -char stext[1024], mtext[32]; +char stext[256]; Bool *seltag; -int bx, by, bw, bh, bmw, masterd, screen, sx, sy, sw, sh, wax, way, waw, wah; +int bh, bmw, screen, sx, sy, sw, sh, wax, way, waw, wah; unsigned int master, nmaster, ntags, numlockmask; Atom wmatom[WMLast], netatom[NetLast]; Bool running = True; -Bool issel = True; +Bool selscreen = True; Client *clients = NULL; Client *sel = NULL; Client *stack = NULL; @@ -41,7 +41,7 @@ static void cleanup(void) { close(STDIN_FILENO); while(stack) { - resize(stack, True, TopLeft); + resize(stack, True); unmanage(stack); } if(dc.font.set) @@ -92,6 +92,7 @@ setup(void) { /* init atoms */ wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", 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, @@ -101,6 +102,7 @@ setup(void) { cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur); /* init modifier map */ + numlockmask = 0; modmap = XGetModifierMapping(dpy); for (i = 0; i < 8; i++) { for (j = 0; j < modmap->max_keypermod; j++) { @@ -120,12 +122,12 @@ setup(void) { seltag = emallocz(sizeof(Bool) * ntags); seltag[0] = True; /* style */ + dc.norm[ColBorder] = getcolor(NORMBORDERCOLOR); dc.norm[ColBG] = getcolor(NORMBGCOLOR); dc.norm[ColFG] = getcolor(NORMFGCOLOR); + dc.sel[ColBorder] = getcolor(SELBORDERCOLOR); dc.sel[ColBG] = getcolor(SELBGCOLOR); dc.sel[ColFG] = getcolor(SELFGCOLOR); - dc.status[ColBG] = getcolor(STATUSBGCOLOR); - dc.status[ColFG] = getcolor(STATUSFGCOLOR); setfont(FONT); /* geometry */ sx = sy = 0; @@ -133,24 +135,21 @@ setup(void) { sh = DisplayHeight(dpy, screen); master = MASTER; nmaster = NMASTER; - updatemodetext(); + bmw = textw(TILESYMBOL) > textw(FLOATSYMBOL) ? textw(TILESYMBOL) : textw(FLOATSYMBOL); /* bar */ - bx = sx; - by = sy; - 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), + barwin = XCreateWindow(dpy, root, sx, sy + (TOPBAR ? 0 : sh - bh), sw, bh, 0, + DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen), CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); XDefineCursor(dpy, barwin, cursor[CurNormal]); XMapRaised(dpy, barwin); strcpy(stext, "dwm-"VERSION); /* windowarea */ wax = sx; - way = sy + bh; + way = sy + (TOPBAR ? bh : 0); wah = sh - bh; waw = sw; /* pixmap for everything */ @@ -158,7 +157,7 @@ setup(void) { dc.gc = XCreateGC(dpy, root, 0, 0); XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); /* multihead support */ - issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); + selscreen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); } /* @@ -173,24 +172,6 @@ xerrorstart(Display *dsply, XErrorEvent *ee) { /* 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;