diff --git a/config.mk b/config.mk index 6ff31d7..4d714ce 100644 --- a/config.mk +++ b/config.mk @@ -12,6 +12,9 @@ X11LIB = /usr/X11R6/lib XINERAMALIBS = -lXinerama XINERAMAFLAGS = -DXINERAMA +# XRandR +XRANDRLIBS = -lXrandr + # freetype FREETYPELIBS = -lfontconfig -lXft FREETYPEINC = /usr/include/freetype2 @@ -20,7 +23,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_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\" $(XINERAMAFLAGS) diff --git a/instantmenu.c b/instantmenu.c index 5f3abd5..8e2eabb 100644 --- a/instantmenu.c +++ b/instantmenu.c @@ -15,6 +15,7 @@ #ifdef XINERAMA #include #endif +#include #include #include #include @@ -767,6 +768,14 @@ void animatesel() { int time; time = 0; drw_setscheme(drw, scheme[SchemeSel]); + + XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, RootWindow(dpy, 0)); + short refresh_rate = XRRConfigCurrentRate(conf); + + // scale the framerate properly for !=60Hz displays + framecount = framecount * (refresh_rate / 60); + double usecs = (1 / (double)refresh_rate) * 1000000; + while (time < framecount) { // bottom animation @@ -776,7 +785,7 @@ void animatesel() { drw_rect(drw, 0, sely + 4 - (easeOutQuint(((double)time/framecount)) * (sely + 4)), mw, (easeOutQuint(((double)time/framecount)) * sely), 1, 1, 0); drw_map(drw, win, 0, 0, mw, mh); time++; - usleep(19000); + usleep(usecs); } } @@ -795,13 +804,21 @@ void animaterect(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2) time = 0; double timefactor = 0; drw_setscheme(drw, scheme[SchemeSel]); + + XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, RootWindow(dpy, 0)); + short refresh_rate = XRRConfigCurrentRate(conf); + + // scale the framerate properly for !=60Hz displays + framecount = framecount * (refresh_rate / 60); + double usecs = (1 / (double)refresh_rate) * 1000000; + while (time < framecount) { timefactor = easeOutQuint((double)time/framecount); drw_rect(drw, x1 + (x2 - x1) * timefactor, y1 + (y2 - y1) * timefactor, w1 + (w2 - w1) * timefactor, h1 + (h2 - h1) * timefactor, 1, 1, 0); drw_map(drw, win, 0, 0, mw, mh); time++; - usleep(19000); + usleep(usecs); } }