[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, .glSetSwapInterval = waylandGLSetSwapInterval,
.glSwapBuffers = waylandGLSwapBuffers, .glSwapBuffers = waylandGLSwapBuffers,
#endif #endif
.signalNextFrame = waylandSignalNextFrame,
.guestPointerUpdated = waylandGuestPointerUpdated, .guestPointerUpdated = waylandGuestPointerUpdated,
.setPointer = waylandSetPointer, .setPointer = waylandSetPointer,
.grabPointer = waylandGrabPointer, .grabPointer = waylandGrabPointer,

View File

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

View File

@ -27,6 +27,7 @@
#include "app.h" #include "app.h"
#include "common/debug.h" #include "common/debug.h"
#include "common/event.h"
// Surface-handling listeners. // Surface-handling listeners.
@ -114,3 +115,21 @@ bool waylandIsValidPointerPos(int x, int y)
{ {
return x >= 0 && x < wlWm.width && y >= 0 && y < wlWm.height; 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);
}