X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=main.c;h=26bec25b22f4bef1b6c6a7c8d7f0b5d27dcdb1b6;hb=9800518ae3505e54c0e52ea3d40050f279e722d6;hp=35a3a7858b725cf0ada66daa2a2d4839e503227e;hpb=47765f728614c348aa7dfc2eed6f754efc376922;p=dwm.git diff --git a/main.c b/main.c index 35a3a78..26bec25 100644 --- a/main.c +++ b/main.c @@ -20,7 +20,7 @@ int screen, sx, sy, sw, sh, wax, way, waw, wah; unsigned int bh, ntags; unsigned int bpos = BARPOS; unsigned int numlockmask = 0; -Atom dwmprops, wmatom[WMLast], netatom[NetLast]; +Atom wmatom[WMLast], netatom[NetLast]; Bool *seltags; Bool selscreen = True; Client *clients = NULL; @@ -42,7 +42,7 @@ cleanup(void) { close(STDIN_FILENO); while(stack) { unban(stack); - unmanage(stack, NormalState); + unmanage(stack); } if(dc.font.set) XFreeFontSet(dpy, dc.font.set); @@ -111,6 +111,24 @@ initfont(const char *fontstr) { dc.font.height = dc.font.ascent + dc.font.descent; } +static long +getstate(Window w) { + int format, status; + long result = -1; + unsigned char *p = NULL; + unsigned long n, extra; + Atom real; + + status = XGetWindowProperty(dpy, w, wmatom[WMState], 0L, 2L, False, wmatom[WMState], + &real, &format, &n, &extra, (unsigned char **)&p); + if(status != Success) + return -1; + if(n != 0) + result = *p; + XFree(p); + return result; +} + static void scan(void) { unsigned int i, num; @@ -123,7 +141,14 @@ scan(void) { if(!XGetWindowAttributes(dpy, wins[i], &wa) || wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1)) continue; - if(wa.map_state == IsViewable) + if(wa.map_state == IsViewable || getstate(wins[i]) == IconicState) + manage(wins[i], &wa); + } + for(i = 0; i < num; i++) { /* now the transients */ + if(!XGetWindowAttributes(dpy, wins[i], &wa)) + continue; + if(XGetTransientForHint(dpy, wins[i], &d1) + && (wa.map_state == IsViewable || getstate(wins[i]) == IconicState)) manage(wins[i], &wa); } } @@ -140,7 +165,6 @@ setup(void) { XSetWindowAttributes wa; /* init atoms */ - dwmprops = XInternAtom(dpy, "_DWM_PROPERTIES", False); wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False); wmatom[WMName] = XInternAtom(dpy, "WM_NAME", False); @@ -206,7 +230,6 @@ setup(void) { XSetFont(dpy, dc.gc, dc.font.xfont->fid); /* multihead support */ selscreen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); - getdwmprops(); } /* @@ -253,32 +276,6 @@ quit(const char *arg) { readin = running = False; } -void -updatebarpos(void) { - XEvent ev; - - wax = sx; - way = sy; - wah = sh; - waw = sw; - switch(bpos) { - default: - wah -= bh; - way += bh; - XMoveWindow(dpy, barwin, sx, sy); - break; - case BarBot: - wah -= bh; - XMoveWindow(dpy, barwin, sx, sy + wah); - break; - case BarOff: - XMoveWindow(dpy, barwin, sx, sy - bh); - break; - } - XSync(dpy, False); - while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); -} - /* 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 may call exit. @@ -329,7 +326,7 @@ main(int argc, char *argv[]) { xerrorxlib = XSetErrorHandler(xerror); XSync(dpy, False); setup(); - drawstatus(); + drawbar(); scan(); /* main event loop, also reads status text from stdin */ @@ -362,7 +359,7 @@ main(int argc, char *argv[]) { if(p > stext) strncpy(stext, p + 1, sizeof stext); } - drawstatus(); + drawbar(); } while(XPending(dpy)) { XNextEvent(dpy, &ev);