aboutsummaryrefslogtreecommitdiff
path: root/backends/events
diff options
context:
space:
mode:
authorThierry Crozat2017-07-27 21:05:27 +0100
committerThierry Crozat2017-07-27 21:05:44 +0100
commit00bbb73ce584ad262bccbf25c082d33627ba4911 (patch)
treec58077a091866d2aabb7908c6fb968d28cbb7250 /backends/events
parent013b09fa2845b060f7adf8eb737fd89b4810223c (diff)
downloadscummvm-rg350-00bbb73ce584ad262bccbf25c082d33627ba4911.tar.gz
scummvm-rg350-00bbb73ce584ad262bccbf25c082d33627ba4911.tar.bz2
scummvm-rg350-00bbb73ce584ad262bccbf25c082d33627ba4911.zip
SDL: Make sure we get the correct window size with SDL2
When updating or recreating the window, if we changed the window size at the same time we also toggle between OpenGL and non OpenGL mode, or toggle fullscreen mode, we may have a pending SDL resize event with the wrong size. So we need to make sure to append another one with the correct size to end up with the correct size. This fixes bug #9971.
Diffstat (limited to 'backends/events')
-rw-r--r--backends/events/sdl/sdl-events.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp
index 946a1af23f..fb5a4c9b09 100644
--- a/backends/events/sdl/sdl-events.cpp
+++ b/backends/events/sdl/sdl-events.cpp
@@ -589,7 +589,18 @@ bool SdlEventSource::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) {
_graphicsManager->notifyVideoExpose();
return false;
- case SDL_WINDOWEVENT_RESIZED:
+ // SDL2 documentation indicate that SDL_WINDOWEVENT_SIZE_CHANGED is sent either as a result
+ // of the size being changed by an external event (for example the user resizing the window
+ // or going fullscreen) or a call to the SDL API (for example SDL_SetWindowSize). On the
+ // other hand SDL_WINDOWEVENT_RESIZED is only sent for resize resulting from an external event,
+ // and is always preceded by a SDL_WINDOWEVENT_SIZE_CHANGED event.
+ // We need to handle the programmatic resize as well so that the graphics manager always know
+ // the current size. See comments in SdlWindow::createOrUpdateWindow for details of one case
+ // where we need to call SDL_SetWindowSize and we need the resulting event to be processed.
+ // However if the documentation is correct we can ignore SDL_WINDOWEVENT_RESIZED since when we
+ // get one we should always get a SDL_WINDOWEVENT_SIZE_CHANGED as well.
+ case SDL_WINDOWEVENT_SIZE_CHANGED:
+ //case SDL_WINDOWEVENT_RESIZED:
return handleResizeEvent(event, ev.window.data1, ev.window.data2);
default: