DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

commit 9de73b40a9a417f19aa150175081eb4d233a34f5
parent 96896dcd4d7164628305ee17d3414e88faba0b39
Author: falkTX <falktx@falktx.com>
Date:   Tue, 12 Jul 2022 10:36:24 +0100

Dont lockup in puglX11UpdateWithoutExposures

Signed-off-by: falkTX <falktx@falktx.com>

Diffstat:
Mdgl/src/WindowPrivateData.cpp | 10++++++++--
Mdgl/src/pugl.cpp | 20++++++++++++++++----
2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/dgl/src/WindowPrivateData.cpp b/dgl/src/WindowPrivateData.cpp @@ -787,7 +787,10 @@ const void* Window::PrivateData::getClipboard(size_t& dataSize) #ifdef DGL_USING_X11 // wait for type request, clipboardTypeId must be != 0 to be valid while (clipboardTypeId == 0 && waitingForClipboardData) - puglX11UpdateWithoutExposures(appData->world); + { + if (puglX11UpdateWithoutExposures(appData->world) != PUGL_SUCCESS) + break; + } #endif if (clipboardTypeId == 0) @@ -800,7 +803,10 @@ const void* Window::PrivateData::getClipboard(size_t& dataSize) #ifdef DGL_USING_X11 // wait for actual data (assumes offer was accepted) while (waitingForClipboardData) - puglX11UpdateWithoutExposures(appData->world); + { + if (puglX11UpdateWithoutExposures(appData->world) != PUGL_SUCCESS) + break; + } #endif if (clipboardTypeId == 0) diff --git a/dgl/src/pugl.cpp b/dgl/src/pugl.cpp @@ -588,10 +588,22 @@ void puglWin32ShowCentered(PuglView* const view) PuglStatus puglX11UpdateWithoutExposures(PuglWorld* const world) { - world->impl->dispatchingEvents = true; - const PuglStatus st = dispatchX11Events(world); - world->impl->dispatchingEvents = false; - return st; + const bool wasDispatchingEvents = world->impl->dispatchingEvents; + world->impl->dispatchingEvents = true; + PuglStatus st = PUGL_SUCCESS; + + const double startTime = puglGetTime(world); + const double endTime = startTime + 0.03; + + for (double t = startTime; !st && t < endTime; t = puglGetTime(world)) + { + if (!(st = pollX11Socket(world, endTime - t))) { + st = dispatchX11Events(world); + } + } + + world->impl->dispatchingEvents = wasDispatchingEvents; + return st; } // --------------------------------------------------------------------------------------------------------------------