wayland: use mutexes to ensure that MwLLDestroyImpl never conflicts with wayland events.

This commit is contained in:
IoIxD
2026-01-03 18:27:34 -07:00
parent bed668b84a
commit a148b3bedf
2 changed files with 86 additions and 8 deletions

View File

@@ -16,6 +16,7 @@
#include <wayland-client.h>
#include <xkbcommon/xkbcommon.h>
#include <cairo/cairo.h>
#include <pthread.h>
MWDECL int MwLLWaylandCallInit(void);
@@ -191,6 +192,12 @@ struct _MwLLWayland {
struct _MwLLWaylandShmBuffer cursor;
struct _MwLLWaylandShmBuffer* icon;
/*
Events mutex. Any time a keyboard/mouse event happens, we try to lock this for 100 milliseconds, then give up if we can't do it. This is used in conjunction with some code in the MwLLDestroyImpl to make sure that destroy is NEVER interferes with an ongoing event.
IOI_XD: This sounds like a hilariously rare edge case, so it's almost funnier that this happened with 100% certainty for me and I spent day(s) trying to figure out what was happening. */
pthread_mutex_t eventsMutex;
cairo_surface_t* cs;
cairo_t* cairo;
};