diff --git a/config.mk b/config.mk index 1fd3de4e..3c128e63 100644 --- a/config.mk +++ b/config.mk @@ -15,6 +15,9 @@ X11LIB = /usr/X11R6/lib XINERAMALIBS = -lXinerama XINERAMAFLAGS = -DXINERAMA +# XRandR +XRANDRLIBS = -lXrandr + # freetype FREETYPELIBS = -lfontconfig -lXft FREETYPEINC = /usr/include/freetype2 @@ -23,7 +26,7 @@ FREETYPEINC = /usr/include/freetype2 # includes and libs INCS = -I${X11INC} -I${FREETYPEINC} -LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lm +LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${XRANDRLIBS} ${FREETYPELIBS} -lm # flags CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} diff --git a/instantwm.c b/instantwm.c index 1918f8ca..bf97568c 100644 --- a/instantwm.c +++ b/instantwm.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -448,11 +449,19 @@ void animateclient(Client *c, int x, int y, int w, int h, int frames, width = w ? w : c->w; height = h ? h : c->h; + XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, RootWindow(dpy, 0)); + short refresh_rate = XRRConfigCurrentRate(conf); + + // scale the framerate properly for !=60Hz displays + frames = frames * (refresh_rate / 60); + double usecs = (1 / (double)refresh_rate) * 1000000; + // halve frames if enough events are queried frames = frames / 1 + (XEventsQueued(dpy, QueuedAlready) > 50); // No animation if even more events are queried if (!frames || XEventsQueued(dpy, QueuedAlready) > 100) { + usecs = 0; if (resetpos) resize(c, c->x, c->y, width, height, 0); else @@ -487,7 +496,7 @@ void animateclient(Client *c, int x, int y, int w, int h, int frames, oldy + easeOutCubic(((double)time / frames)) * (y - oldy), width, height, 1); time++; - usleep(15000); + usleep(usecs); } } }