[client] wayland: implement signalNextFrame with frame callbacks

This commit is contained in:
Quantum 2021-07-31 04:01:51 -04:00 committed by Geoffrey McRae
parent 3043296e52
commit a213ee960a
3 changed files with 21 additions and 0 deletions

View file

@ -164,6 +164,7 @@ struct LG_DisplayServerOps LGDS_Wayland =
.glSetSwapInterval = waylandGLSetSwapInterval,
.glSwapBuffers = waylandGLSwapBuffers,
#endif
.signalNextFrame = waylandSignalNextFrame,
.guestPointerUpdated = waylandGuestPointerUpdated,
.setPointer = waylandSetPointer,
.grabPointer = waylandGrabPointer,

View file

@ -289,3 +289,4 @@ void waylandWindowFree(void);
void waylandWindowUpdateScale(void);
void waylandSetWindowSize(int x, int y);
bool waylandIsValidPointerPos(int x, int y);
void waylandSignalNextFrame(LGEvent * event);

View file

@ -27,6 +27,7 @@
#include "app.h"
#include "common/debug.h"
#include "common/event.h"
// Surface-handling listeners.
@ -114,3 +115,21 @@ bool waylandIsValidPointerPos(int x, int y)
{
return x >= 0 && x < wlWm.width && y >= 0 && y < wlWm.height;
}
static void frameHandler(void * opaque, struct wl_callback * callback, unsigned int data)
{
LGEvent * event = opaque;
lgSignalEvent(event);
wl_callback_destroy(callback);
}
static const struct wl_callback_listener frame_listener = {
.done = frameHandler,
};
void waylandSignalNextFrame(LGEvent * event)
{
struct wl_callback * callback = wl_surface_frame(wlWm.surface);
if (callback)
wl_callback_add_listener(callback, &frame_listener, event);
}