]> git.armaanb.net Git - dwm.git/commitdiff
applied Hiltjo's resize/move limitation
authorAnselm R Garbe <garbeam@gmail.com>
Mon, 11 Aug 2014 05:24:29 +0000 (07:24 +0200)
committerAnselm R Garbe <garbeam@gmail.com>
Mon, 11 Aug 2014 05:24:29 +0000 (07:24 +0200)
"Limit the amount of updates when resizing or moving a window in floating
mode to 60 times per second. This makes resizing and moving alot smoother
and by limiting it it also uses alot less resources on my machine.

LICENSE
dwm.c

diff --git a/LICENSE b/LICENSE
index dc2326a1e75c0c1ac5f8a468f7da154127714575..4fbb67ecdaeee544e3d698c83d38624116334c65 100644 (file)
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,7 @@
 MIT/X Consortium License
 
 © 2006-2014 Anselm R Garbe <anselm@garbe.us>
+© 2010-2014 Hiltjo Posthuma <hiltjo@codemadness.org>
 © 2007-2011 Peter Hartlich <sgkkr at hartlich dot com>
 © 2010-2011 Connor Lane Smith <cls@lubutu.com>
 © 2006-2009 Jukka Salmi <jukka at salmi dot ch>
diff --git a/dwm.c b/dwm.c
index ffc8864472ee9608afa80c402d8c53a0088939ff..f896170c043fcccefe0d11330ca49f379bf29650 100644 (file)
--- a/dwm.c
+++ b/dwm.c
@@ -1123,6 +1123,7 @@ movemouse(const Arg *arg) {
        Client *c;
        Monitor *m;
        XEvent ev;
+       Time lasttime = 0;
 
        if(!(c = selmon->sel))
                return;
@@ -1145,6 +1146,10 @@ movemouse(const Arg *arg) {
                        handler[ev.type](&ev);
                        break;
                case MotionNotify:
+                       if ((ev.xmotion.time - lasttime) <= (1000 / 60))
+                               continue;
+                       lasttime = ev.xmotion.time;
+
                        nx = ocx + (ev.xmotion.x - x);
                        ny = ocy + (ev.xmotion.y - y);
                        if(nx >= selmon->wx && nx <= selmon->wx + selmon->ww
@@ -1264,11 +1269,11 @@ resizeclient(Client *c, int x, int y, int w, int h) {
 
 void
 resizemouse(const Arg *arg) {
-       int ocx, ocy;
-       int nw, nh;
+       int ocx, ocy, nw, nh;
        Client *c;
        Monitor *m;
        XEvent ev;
+       Time lasttime = 0;
 
        if(!(c = selmon->sel))
                return;
@@ -1290,6 +1295,10 @@ resizemouse(const Arg *arg) {
                        handler[ev.type](&ev);
                        break;
                case MotionNotify:
+                       if ((ev.xmotion.time - lasttime) <= (1000 / 60))
+                               continue;
+                       lasttime = ev.xmotion.time;
+
                        nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
                        nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
                        if(c->mon->wx + nw >= selmon->wx && c->mon->wx + nw <= selmon->wx + selmon->ww