X-Git-Url: https://jasonwoof.com/gitweb/?p=dwm.git;a=blobdiff_plain;f=dwm.c;h=b1f77cc343d6d92b0fc640c1db2300698b6aeebb;hp=32755cb79a4df6755b79c2ab9d2140fe2729d7b3;hb=aa9f2be24ea9ea6d9419cad1975bf34c5b64b6e5;hpb=210378f19833c739f3d2e4acaca55fccb29c57f7 diff --git a/dwm.c b/dwm.c index 32755cb..b1f77cc 100644 --- a/dwm.c +++ b/dwm.c @@ -41,6 +41,7 @@ #endif /* XINERAMA */ /* macros */ +#define D if(1) #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask)) #define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH)) @@ -814,6 +815,10 @@ void focus(Client *c) { if(!c || !ISVISIBLE(c)) for(c = selmon->stack; c && !ISVISIBLE(c); c = c->snext); + if(c && c == selmon->sel) { + D fprintf(stderr, "focus, optimising focus away\n"); + return; + } if(selmon->sel) unfocus(selmon->sel); if(c) { @@ -847,7 +852,8 @@ focusmon(const Arg *arg) { if(!mons->next) return; - m = dirtomon(arg->i); + if((m = dirtomon(arg->i)) == selmon) + return; unfocus(selmon->sel); selmon = m; focus(NULL); @@ -1388,12 +1394,27 @@ restack(Monitor *m) { void run(void) { XEvent ev; - + static const char *evname[LASTEvent] = { + [ButtonPress] = "buttonpress", + [ConfigureRequest] = "configurerequest", + [ConfigureNotify] = "configurenotify", + [DestroyNotify] = "destroynotify", + [EnterNotify] = "enternotify", + [Expose] = "expose", + [FocusIn] = "focusin", + [KeyPress] = "keypress", + [MappingNotify] = "mappingnotify", + [MapRequest] = "maprequest", + [PropertyNotify] = "propertynotify", + [UnmapNotify] = "unmapnotify" + }; /* main event loop */ XSync(dpy, False); - while(running && !XNextEvent(dpy, &ev)) + while(running && !XNextEvent(dpy, &ev)) { + D fprintf(stderr, "run event %s %ld\n", evname[ev.type], ev.xany.window); if(handler[ev.type]) handler[ev.type](&ev); /* call handler */ + } } void