From 3043296e52a33720d0295ff756efbf305ab115d9 Mon Sep 17 00:00:00 2001
From: Quantum <quantum2048@gmail.com>
Date: Sat, 31 Jul 2021 03:58:53 -0400
Subject: [PATCH] [client] ds: add optional method signalNextFrame(LGEvent)

This method takes an LGEvent and signals it when the next frame should be
rendered in time for the next vblank.

We will be using this to render imgui at screen refresh rate, but this could
potentially be used later to implement a better form of vsync for supported
display servers.

This must be invoked before swapping buffers.
---
 client/include/interface/displayserver.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/client/include/interface/displayserver.h b/client/include/interface/displayserver.h
index 49590e2b..8af237c1 100644
--- a/client/include/interface/displayserver.h
+++ b/client/include/interface/displayserver.h
@@ -101,6 +101,8 @@ typedef void (* LG_ClipboardReplyFn)(void * opaque, const LG_ClipboardData type,
 typedef struct LG_DSGLContext
   * LG_DSGLContext;
 
+typedef struct LGEvent LGEvent;
+
 struct LG_DisplayServerOps
 {
   /* called before options are parsed, useful for registering options */
@@ -147,6 +149,12 @@ struct LG_DisplayServerOps
   void (*glSwapBuffers)(void);
 #endif
 
+  /* Signals event when the next frame should be rendered in time for the next vblank.
+   * This must be invoked on the render thread before swapping buffers.
+   * If used, the render thread MUST wait for event before rendering the next frame.
+   * This is optional and a display server may choose to not implement it. */
+  void (*signalNextFrame)(LGEvent * event);
+
   /* dm specific cursor implementations */
   void (*guestPointerUpdated)(double x, double y, double localX, double localY);
   void (*setPointer)(LG_DSPointer pointer);