JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
selmon optimisation is needed
[dwm.git] / dwm.c
diff --git a/dwm.c b/dwm.c
index 32755cb..ac534a8 100644 (file)
--- 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))
@@ -847,7 +848,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 +1390,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