Move motion time check to the top of each MotionNotify block (and

eliminate from ButtonRelease); further limits the amount of work done
outside the threshold, notably mousefunc_sweep_calc,
screen_find_xinerama and client_snapcalc.
This commit is contained in:
okan 2014-09-18 13:56:58 +00:00
parent 8fd0f43ec2
commit cbc7f76074

View File

@ -90,18 +90,17 @@ mousefunc_client_resize(struct client_ctx *cc, union arg *arg)
switch (ev.type) { switch (ev.type) {
case MotionNotify: case MotionNotify:
/* not more than 60 times / second */
if ((ev.xmotion.time - ltime) <= (1000 / 60))
continue;
ltime = ev.xmotion.time;
mousefunc_sweep_calc(cc, x, y, mousefunc_sweep_calc(cc, x, y,
ev.xmotion.x_root, ev.xmotion.y_root); ev.xmotion.x_root, ev.xmotion.y_root);
/* don't resize more than 60 times / second */
if ((ev.xmotion.time - ltime) > (1000 / 60)) {
ltime = ev.xmotion.time;
client_resize(cc, 1); client_resize(cc, 1);
mousefunc_sweep_draw(cc); mousefunc_sweep_draw(cc);
}
break; break;
case ButtonRelease: case ButtonRelease:
if (ltime)
client_resize(cc, 1); client_resize(cc, 1);
XUnmapWindow(X_Dpy, sc->menuwin); XUnmapWindow(X_Dpy, sc->menuwin);
XReparentWindow(X_Dpy, sc->menuwin, sc->rootwin, 0, 0); XReparentWindow(X_Dpy, sc->menuwin, sc->rootwin, 0, 0);
@ -143,6 +142,11 @@ mousefunc_client_move(struct client_ctx *cc, union arg *arg)
switch (ev.type) { switch (ev.type) {
case MotionNotify: case MotionNotify:
/* not more than 60 times / second */
if ((ev.xmotion.time - ltime) <= (1000 / 60))
continue;
ltime = ev.xmotion.time;
cc->geom.x = ev.xmotion.x_root - px - cc->bwidth; cc->geom.x = ev.xmotion.x_root - px - cc->bwidth;
cc->geom.y = ev.xmotion.y_root - py - cc->bwidth; cc->geom.y = ev.xmotion.y_root - py - cc->bwidth;
@ -156,14 +160,9 @@ mousefunc_client_move(struct client_ctx *cc, union arg *arg)
cc->geom.y + cc->geom.h + (cc->bwidth * 2), cc->geom.y + cc->geom.h + (cc->bwidth * 2),
xine.y, xine.y + xine.h, sc->snapdist); xine.y, xine.y + xine.h, sc->snapdist);
/* don't move more than 60 times / second */
if ((ev.xmotion.time - ltime) > (1000 / 60)) {
ltime = ev.xmotion.time;
client_move(cc); client_move(cc);
}
break; break;
case ButtonRelease: case ButtonRelease:
if (ltime)
client_move(cc); client_move(cc);
xu_ptr_ungrab(); xu_ptr_ungrab();
return; return;