Commit Graph

178 Commits

Author SHA1 Message Date
Frank Praznik 4d76c9cb46 video: wayland: Use wp-viewporter for fullscreen with non-native resolutions
Wayland doesn't support mode switching, however Wayland compositors can support the wp_viewporter protocol, which allows for the mapping of arbitrarily sized buffer regions to output surfaces.  Use this functionality, when available, for fullscreen output when using non-native display modes and/or when dealing with scaled desktops, which can incur significant overdraw without this extension.

This also allows for the exposure of arbitrarily sized, emulated display modes, which can be useful for legacy compatability.
2022-03-28 13:18:26 -04:00
Ryan C. Gordon 4fe7b2cbd1
static analysis: Fixed several complaints from codechecker.
There are still some pending Objective-C specific issues.

Reference issue #4600.
2022-03-24 11:00:43 -04:00
Charlie Birks 4b8d69a416 Avoid trying to use texture framebuffers on emscripten 2022-03-22 12:18:45 -07:00
Sam Lantinga 34fd83ca06 Don't try to hide foreign windows when destroying the SDL window representation
Fixes https://github.com/libsdl-org/SDL/issues/5432
2022-03-22 06:50:10 -07:00
Sam Lantinga e5f45455c9 Added a hint to mark a foreign window as usable with OpenGL
Fixes https://github.com/libsdl-org/SDL/issues/2942
2022-03-17 14:44:34 -07:00
Ethan Lee 0bf8ccfb60 video: Add a hint to allow Vulkan surfaces on foreign windows 2022-03-17 14:25:55 -07:00
Zach Reedy d14a126383
IME Composition Truncation + SDL_IsTextInputShown + SDL_ClearComposition (#5398)
* Fixes for IME Composition Truncation + Addition of SDL_ClearComposition, SDL_IsTextInputShown

* Fixed: Documentation and code style issues raised during code review.
2022-03-11 14:45:17 -08:00
Sylvain 45833a148d
Prevent shadowing static variable '_this' with local paramter '_this' of SDL_CreateWindowTexture 2022-03-09 15:33:45 +01:00
Sylvain a4a80c8607
Fix variable may be uninitialized when used here [-Wconditional-uninitialized] 2022-03-09 15:21:55 +01:00
Cameron Cawley 2f7b885df9 Fix 'potentially uninitialized local pointer variable' error in UWP builds 2022-02-28 09:04:33 -08:00
Ryan C. Gordon b946e31ec8 video: Allow unaccelerated SDL_HINT_FRAMEBUFFER_ACCELERATION renderers.
If the app requested a specific renderer, even if it's not the optimal path,
let them have it, because they might want to render with a specific GPU API
on top of the framebuffer pixels.

This fixes DosBox-X crashing on startup, which forces the hint to "opengl".
2022-02-23 09:36:06 -05:00
Ryan C. Gordon 60ddb74cfe video: rework how we prepare a texture framebuffer.
Now we see if we can create an SDL_Renderer, and if that renderer reports
itself as "accelerated," and added some initial heuristics to the OpenGL
renderer to make better decisions about what qualifies as "accelerated."

This adds some FIXMEs that might be merely hypothetical, and removes the
old OpenGL checks from the video subsystem that probably weren't meaningful
in modern times. This will definitely need to improve the existing list
in the GL renderer, to catch things like llvmpipe, etc.

Reference issue #4624.
2022-02-23 09:36:06 -05:00
pionere 60deadba59 re-use return value of SDL_SetError/WIN_SetErrorFromHRESULT/SDL_OutOfMemory 2022-01-28 20:40:19 -05:00
pionere ebdd536676 use SDL_InvalidParamError or SDL_assert instead of custom SDL_SetError 2022-01-28 20:40:19 -05:00
pionere e11ba0f5d9 do not load/unload opengl library when SDL_WINDOW_METAL flag is changed 2022-01-28 20:40:19 -05:00
Ryan C. Gordon 19ae71b2db
video: Don't add SDL_WINDOW_(METAL|OPENGL) to new windows if unsupported.
Fixes #4656.

(Better than the previous fix in 3044310518dbb2d4814b32c6521f332b8d69aae5.)
2022-01-27 11:49:15 -05:00
Ryan C. Gordon 3044310518 video: Don't add SDL_WINDOW_METAL to new windows if not using Cocoa or UIKit.
Fixes #4656.
2022-01-26 21:10:15 -05:00
Ryan C. Gordon f37e4a94d3
video: Don't check if we can use a "texture framebuffer" until needed.
This prevents SDL from making an OpenGL context and maybe throwing it away
immediately by default. It will now only do it when trying to request a
window framebuffer directly, or creating an SDL_Renderer with the "software"
backend, which makes that request itself.

The way SDL decides if it should use a "texture framebuffer" needs dramatic
updating, but this solves the immediate problem.

Reference Issue #4624.
2022-01-26 17:06:25 -05:00
Ethan Lee 8ceba27d62 video: Prefer Wayland over X11 2022-01-26 12:32:45 -05:00
Mathieu Eyraud 2a0cde8fd5 Always send SDL_WINDOWEVENT_SIZE_CHANGED when window is resized
SDL_WINDOWEVENT_SIZE_CHANGED is now sent even if the resulting size of the window does not match the requested size.
2022-01-16 08:49:48 -08:00
Sam Lantinga 120c76c84b Updated copyright for 2022 2022-01-03 09:40:21 -08:00
Ryan C. Gordon e4000c0284
video: SDL_GL_GetAttribute needs to operate on FBO 0.
If a different FBO is bound, this would return incorrect results.

Fixes #5082.
2021-12-31 10:32:39 -05:00
Erik Soma 71e3998d6c Make SDL_VideoInit cleanup when errors occur before video driver creation. 2021-12-17 18:55:49 -08:00
Sylvain 0445c13aae Remove 'malloc' from comment 2021-11-22 08:38:46 -08:00
Sam Lantinga 98c9836287 Don't clobber the error in SDL_ShowMessageBox() if one has been set at
the platform level

Fixes https://github.com/libsdl-org/SDL/issues/4760
2021-11-10 11:04:51 -08:00
Sam Lantinga 6c4b4ee7a6 Don't assert on API parameters
This causes lots of spam in test automation and it's not clear it's useful to developers. If we need this level of validation, we should add a log category for it.
2021-11-10 09:41:43 -08:00
Sam Lantinga fed857787a Update the orientation and display modes when the display settings change on Windows
Fixes https://github.com/libsdl-org/SDL/issues/1061
2021-11-10 08:47:39 -08:00
Sam Lantinga d2f756360e When making the window centered it should use windowed mode size since it doesn't affect fullscreen windows
Fixes bug https://github.com/libsdl-org/SDL/issues/4750
2021-11-09 11:55:02 -08:00
Sam Lantinga fd79607eb0 Added SDL_GetWindowMouseRect()
Also guarantee that we won't get mouse movement outside the confining area, even if the OS implementation allows it (e.g. macOS)
2021-11-08 21:34:48 -08:00
Ethan Lee 4b42c05ba1 video: Add SDL_SetWindowMouseRect.
This API and implementation comes from the Unreal Engine branch of SDL, which
originally called this "SDL_ConfineCursor".

Some minor cleanup and changes for consistency with the rest of SDL_video, but
there are two major changes:

1. The coordinate system has been changed so that `rect` is _window_ relative
   and not _screen_ relative, making it easier to implement without having
   global access to the display.
2. The UE version unset all rects when passing `NULL` as a parameter for
   `window`, this has been removed as it was an unused feature anyhow.

Currently this is only implemented for X, but can be supported on Wayland and
Windows at minimum too.
2021-11-08 14:16:54 -08:00
Cameron Cawley 25c71748ad Add a barebones RISC OS video driver 2021-10-30 21:25:01 -07:00
Cacodemon345 19dee1cd16
Add SDL_GetWindowICCProfile(). (#4314)
* Add SDL_GetWindowICCProfile

* Add new SDL display events

* Implement ICC profile change event for macOS

* Implement ICC profile notification for Windows

* Fix SDL_GetWindowICCProfile() for X11

* Fix compile errors
2021-10-21 17:37:20 -07:00
Sam Lantinga 1c5b3e0e16 Don't center the mouse when gaining focus unless we're using relative mode warping
This is necessary now that we actually change the mouse position when calling SDL_WarpMouseInWindow() in relative mode.
2021-10-15 18:12:18 -07:00
Lee Salzman 9fae8f7088 Treat empty SDL_VIDEODRIVER var to check all video drivers. 2021-08-30 05:00:51 +03:00
Sam Lantinga 629e9f820a Fixed return value of SDL_GetGrabbedWindow() when we have an internal grab because of mouse relative mode 2021-08-13 11:06:43 -07:00
Sam Lantinga 6aa1498b98 This assert wasn't correct, we set the internal grab for mouse relative mode as well. 2021-08-13 11:03:19 -07:00
Sam Lantinga 016b02f24c Fixed build, C89 doesn't allow non-constant static initializers 2021-08-10 12:17:37 -07:00
Sam Lantinga fcfd19db86 Added support for SDL_RENDERER_PRESENTVSYNC to the software renderer
This fixes https://github.com/libsdl-org/SDL/issues/4612
2021-08-10 12:02:59 -07:00
Sebastian Krzyszkowiak b3a989d0df video: Fix false positives in driver name comparison
Without this change, driver names don't get matched correctly;
for example "x" can get matched with "x11" since it only checks
whether the string matches up to the length of the requested
driver name.
2021-08-10 08:34:07 -07:00
Sam Lantinga 88674b4a0e Fixed build 2021-08-04 13:17:35 -07:00
Sam Lantinga c14813a879 Fixed spacing 2021-08-04 13:00:14 -07:00
Sam Lantinga 3cad447ee7 Only update the window size if setting the display mode succeeded 2021-08-04 12:57:51 -07:00
Daniel Gibson 0eb6f79190 SDL_SetWindowDisplayMode(): If already fullscreen, adjust window size
Otherwise only the display resolution is changed, but the SDL window size
(and for example the window-surface size) aren't adjusted accordingly
and thus don't fill the whole screen.
See #3313
2021-08-04 12:48:48 -07:00
Daniel Gibson 72d8128520 Improve SDL_CreateWindow() fullscreen support on Windows
.. and maybe other platforms as well (though X11 was not affected)?

The issue was that passing a higher resolution than the current desktop
resolution to SDL_CreateWindow() with SDL_WINDOW_FULLSCREEN didn't switch
to that resolution (even though it did switch to lower resolutions).

When creating a fullscreen window, window->fullscreen wasn't even set
at all (only zeroed out), setting it only happened if the user explicitly
called SDL_SetWindowDisplayMode(). So without that, SDL_CreateWindow()
-> SDL_UpdateFullscreenMode() -> SDL_GetWindowDisplayMode() used the
resolution from window->windowed.w/h which were limited to the desktop size
due to some weird combination of WIN_AdjustWindowRectWithStyle() and
WIN_WindowProc() being called after a call to SetWindowPos().

fixes #3313
2021-08-04 12:48:48 -07:00
Sam Lantinga 69518b9ecc Make sure we don't send a resize event while a window is being destroyed
This fixes https://github.com/libsdl-org/SDL/issues/3669
2021-07-29 17:09:24 -07:00
Sam Lantinga 8e35ff5cb3 By default minimize real fullscreen windows when they lose focus so the desktop video mode is restored.
This fixes https://github.com/libsdl-org/SDL/issues/4039
2021-07-28 14:20:29 -07:00
Ozkan Sezer d80ef3e5f5 SDL_VideoInit: silence 'may be used uninitialized' warning
src/video/SDL_video.c:475: warning: 'i' may be used uninitialized in this function
2021-07-26 22:51:24 +03:00
Luis Cáceres 5ec69285fa Support comma-separated lists in SDL_VIDEODRIVER 2021-07-26 15:14:54 -04:00
Sam Lantinga f1633127d1 Added a window flash operation to be explicit about window flash behavior 2021-07-24 13:42:19 -07:00
Sam Lantinga e1c3a25034 Changed SDL_FlashWindow() so it doesn't take a flash count, and added the hint SDL_HINT_WINDOW_FLASH_COUNT to control behavior on Windows 2021-07-24 12:11:27 -07:00