[client] x11: don't allow window manager events to skew cal timing

This commit is contained in:
Geoffrey McRae 2021-08-07 03:39:11 +10:00
parent e5a138d854
commit ec56b2760a
2 changed files with 8 additions and 1 deletions

View File

@ -674,6 +674,8 @@ static int x11EventThread(void * unused)
case ConfigureNotify: case ConfigureNotify:
{ {
atomic_store(&x11.lastWMEvent, microtime());
int x, y; int x, y;
/* the window may have been re-parented so we need to translate to /* the window may have been re-parented so we need to translate to
@ -707,6 +709,7 @@ static int x11EventThread(void * unused)
case Expose: case Expose:
{ {
atomic_store(&x11.lastWMEvent, microtime());
app_invalidateWindow(false); app_invalidateWindow(false);
break; break;
} }
@ -1227,7 +1230,9 @@ static bool x11WaitFrame(void)
lastmsc = msc; lastmsc = msc;
/* adjustments if we are still seeing odd skips */ /* adjustments if we are still seeing odd skips */
if (delay > 0 && deltamsc > 1) const uint64_t lastWMEvent = atomic_load(&x11.lastWMEvent);
const uint64_t eventDelta = ust > lastWMEvent ? ust - lastWMEvent : 0;
if (delay > 0 && deltamsc > 1 && eventDelta > 1000000UL)
{ {
/* only adjust if the last skip was less then 1s ago */ /* only adjust if the last skip was less then 1s ago */
static uint64_t lastSkip = 0; static uint64_t lastSkip = 0;

View File

@ -40,6 +40,8 @@ struct X11DSState
Window window; Window window;
XVisualInfo * visual; XVisualInfo * visual;
_Atomic(uint64_t) lastWMEvent;
int xpresentOp; int xpresentOp;
bool jitRender; bool jitRender;
_Atomic(uint64_t) presentMsc, presentUst; _Atomic(uint64_t) presentMsc, presentUst;