mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-01 07:15:27 +00:00
Flush window events in MMAL and DRM renderers
This commit is contained in:
parent
486c46781b
commit
ec7137e693
@ -317,6 +317,23 @@ bool DrmRenderer::initialize(PDECODER_PARAMETERS params)
|
||||
// CRTC modes below.
|
||||
SDL_Renderer* renderer = SDL_CreateRenderer(params->window, -1, SDL_RENDERER_SOFTWARE);
|
||||
if (renderer != nullptr) {
|
||||
// SDL_CreateRenderer() can end up having to recreate our window (SDL_RecreateWindow())
|
||||
// to ensure it's compatible with the renderer's OpenGL context. If that happens, we
|
||||
// can get spurious SDL_WINDOWEVENT events that will cause us to (again) recreate our
|
||||
// renderer. This can lead to an infinite to renderer recreation, so discard all
|
||||
// SDL_WINDOWEVENT events after SDL_CreateRenderer().
|
||||
Session* session = Session::get();
|
||||
if (session != nullptr) {
|
||||
// If we get here during a session, we need to synchronize with the event loop
|
||||
// to ensure we don't drop any important events.
|
||||
session->flushWindowEvents();
|
||||
}
|
||||
else {
|
||||
// If we get here prior to the start of a session, just pump and flush ourselves.
|
||||
SDL_PumpEvents();
|
||||
SDL_FlushEvent(SDL_WINDOWEVENT);
|
||||
}
|
||||
|
||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
|
||||
SDL_RenderClear(renderer);
|
||||
SDL_RenderPresent(renderer);
|
||||
|
@ -230,6 +230,23 @@ void MmalRenderer::setupBackground(PDECODER_PARAMETERS params)
|
||||
return;
|
||||
}
|
||||
|
||||
// SDL_CreateRenderer() can end up having to recreate our window (SDL_RecreateWindow())
|
||||
// to ensure it's compatible with the renderer's OpenGL context. If that happens, we
|
||||
// can get spurious SDL_WINDOWEVENT events that will cause us to (again) recreate our
|
||||
// renderer. This can lead to an infinite to renderer recreation, so discard all
|
||||
// SDL_WINDOWEVENT events after SDL_CreateRenderer().
|
||||
Session* session = Session::get();
|
||||
if (session != nullptr) {
|
||||
// If we get here during a session, we need to synchronize with the event loop
|
||||
// to ensure we don't drop any important events.
|
||||
session->flushWindowEvents();
|
||||
}
|
||||
else {
|
||||
// If we get here prior to the start of a session, just pump and flush ourselves.
|
||||
SDL_PumpEvents();
|
||||
SDL_FlushEvent(SDL_WINDOWEVENT);
|
||||
}
|
||||
|
||||
SDL_SetRenderDrawColor(m_BackgroundRenderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
|
||||
SDL_RenderClear(m_BackgroundRenderer);
|
||||
SDL_RenderPresent(m_BackgroundRenderer);
|
||||
|
Loading…
x
Reference in New Issue
Block a user