aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/sdl/sdl-window.cpp
AgeCommit message (Collapse)Author
2017-11-17SDL: Grab mouse when ScummVM is started in fullscreen modeColin Snover
2017-10-23SDL: Automatically grab mouse upon entering fullscreenColin Snover
Folks are confused about the new behaviour where the mouse is not restricted to the game area in fullscreen, which is understandable. This changes mouseIsGrabbed to use SDL directly in order to avoid making changes to the user preference in the _inputGrabState. Otherwise we'd either clobber the user's previous windowed mouse grab preference, or require maintaining a second variable just to track the original state, when we can have SDL do that for us.
2017-10-15BACKENDS: Fix missing mouse events when system cursor cannot be movedColin Snover
Normally with SDL, a mouse motion event will be sent after the system mouse cursor has been moved by a call to SDL_WarpMouseInWindow, but if the system cursor cannot be moved (e.g. because the window does not have mouse focus), games still need to receive these mouse events so they can successfully update the mouse position internally. Otherwise, games continue to think the mouse is still in the original position and will continue to try to perform whatever action is associated with that mouse position. Refs Trac#9689.
2017-10-15BACKENDS: Refactor OpenGL & SDL graphics backendsColin Snover
This patch refactors the OpenGL and SDL graphics backends, primarily to unify window scaling and mouse handling, and to fix coordinate mapping between the ScummVM window and the virtual game screen when they have different aspect ratios. Unified code for these two backends has been moved to a new header-only WindowedGraphicsManager class, so named because it contains code for managing graphics managers that interact with a windowing system and render virtual screens within a larger physical content window. The biggest behavioral change here is with the coordinate system mapping: Previously, mouse offsets were converted by mapping the whole space within the window as input to the virtual game screen without maintaining aspect ratio. This was done to prevent 'stickiness' when the mouse cursor was within the window but outside of the virtual game screen, but it caused noticeable distortion of mouse movement speed on the axis with blank space. Instead of introducing mouse speed distortion to prevent stickiness, this patch changes coordinate transformation to show the system cursor when the mouse moves outside of the virtual game screen when mouse grab is off, or by holding the mouse inside the virtual game screen (instead of the entire window) when mouse grab is on. This patch also improves some other properties of the GraphicsManager/PaletteManager interfaces: * Nullipotent operations (getWidth, getHeight, etc.) of the PaletteManager/GraphicsManager interfaces are now const * Methods marked `virtual` but not inherited by any subclass have been de-virtualized * Extra unnecessary calculations of hardware height in SurfaceSdlGraphicsManager have been removed * Methods have been renamed where appropriate for clarity (setWindowSize -> handleResize, etc.) * C++11 support improved with `override` specifier added on overridden virtual methods in subclasses (primarily to avoid myself accidentally creating new methods in the subclasses by changing types/names during refactoring) Additional refactoring can and should be done at some point to continue to deduplicate code between the OpenGL and SDL backends. Since the primary goal here was to improve the coordinate mapping, full refactoring of these backends was not completed here.
2017-10-15SDL: Accept signed values for mouse cursor warpingColin Snover
This matches the other ScummVM and SDL APIs for mouse warp.
2017-10-07BACKENDS: Fix window sizing of games that switch between multiple resolutionsColin Snover
2017-07-29SDL: Make the window size when exiting fullscreen workaround macOS specificBastien Bouclet
The call to SDL_SetWindowSize works around a macOS specific SDL2 bug. Fixes the window not restoring to its previous position when exiting fullscreen on Linux/X11.
2017-07-27SDL: Make sure we get the correct window size with SDL2Thierry Crozat
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.
2017-07-06SDL: Fix compilation with SDL1.2Colin Snover
2017-07-06SDL: Only recreate SDL2 window when necessaryColin Snover
Destroying and recreating the SDL window whenever the video mode changes in SDL2 is not necessary and causes several problems: 1. In windowed mode, the game window shifts position; 2. In fullscreen mode in macOS, every time the window is recreated, it causes the OS to play its switch-to-fullscreen animation again and emit system alert noises; 3. The window content flickers; and 4. The engine loses events from the old destroyed window. This patch changes the SDL backend code to avoid destroying and recreating the SDL window when using SDL2, except when switching OpenGL modes, since there is no way to change the OpenGL feature of a window. There are still some outstanding issues with OpenGL where window size ends up getting reset even though the user has resized it; this will probably need to be addressed at some point in another patch. Thanks to @bgK and @criezy for their feedback which made this patch much better. Co-Authored-By: Bastien Bouclet <bastien.bouclet@gmail.com>
2016-09-04SDL: Move mouse in SDL2 only when window has focus.Eugene Sandulenko
2015-03-01SDL: Call setupIcon for each window creation with SDL2.Johannes Schickel
This should make sure that the logo is properly set on Win32 with SDL2.
2015-02-18WINCE: Fix compilation.Johannes Schickel
2015-02-16WIN32: Add experimental SDL2 support.Johannes Schickel
Based on changes by aquadran.
2015-02-16SDL: Handle icon setup in SdlWindow.Johannes Schickel
2015-02-16SDL: Add basic abstraction class for the SDL window.Johannes Schickel