Allow Qt to borrow DRM master from SDL to update the UI

This commit is contained in:
Cameron Gutman
2024-09-23 22:15:31 -05:00
parent 6d023c2dfa
commit 054e334066
2 changed files with 54 additions and 1 deletions

View File

@@ -51,6 +51,7 @@ int getSdlFdEntryIndex(bool unused)
return -1;
}
// Returns true if the final SDL FD was removed
bool removeSdlFd(int fd)
{
SDL_AtomicLock(&g_FdTableLock);
@@ -73,6 +74,28 @@ bool removeSdlFd(int fd)
return false;
}
// Returns the previous master FD or -1 if none
int takeMasterFromSdlFd()
{
int fd = -1;
// Since all SDL FDs are actually dups of each other
// we can take master from any one of them.
SDL_AtomicLock(&g_FdTableLock);
int fdIndex = getSdlFdEntryIndex(false);
if (fdIndex != -1) {
fd = g_SdlDrmMasterFds[fdIndex];
}
SDL_AtomicUnlock(&g_FdTableLock);
if (fd >= 0 && drmDropMaster(fd) == 0) {
return fd;
}
else {
return -1;
}
}
int openHook(const char *funcname, const char *pathname, int flags, va_list va)
{
int fd;