Commit Graph

226 Commits

Author SHA1 Message Date
Sylvain ddad901c0d
Remove unneeded semicolon 2022-11-17 10:43:45 +01:00
Sam Lantinga fcc994e132 ensure that SDL2 does not set conflicting window flags (thanks @pionere!) 2022-11-16 17:40:32 -08:00
Sylvain 1d7966df15
Remove un-needed check for NULL pointer. They were previously checked just before. 2022-11-16 21:27:16 +01:00
ulatekh ec58a817ef Fixes made in response to running a static code analyzer under MS Windows.
Most of these are probably harmless, but the changes to SDL_immdevice.c and SDL_pixels.c appear to have fixed genuine bugs.

SDL_audiocvt.c: By separating the calculation of the divisor, I got rid of the suspicion that dividing a double by an integer led to loss of precision.
SDL_immdevice.c: Added a missing test, one that could have otherwise led to dereferencing a null pointer.
SDL_events.c, SDL_gamecontroller.c, SDL_joystick.c, SDL_malloc.c, SDL_video.c: Made it clear the return values weren't used.
SDL_hidapi_shield.c: The size is zero, so nothing bad would have happened, but the SDL_memset() was still being given an address outside of the array's range.
SDL_dinputjoystick.c: Initialize local data, just in case IDirectInputDevice8_GetProperty() isn't guaranteed to write to it.
SDL_render_sw.c: drawstate.viewport could be null (as seen on line 691).
SDL.c: SDL_MostSignificantBitIndex32() could return -1, though I don't know if you want to cope with that (what I did) or SDL_assert() that it can't happen.
SDL_hints.c: Replaced boolean tests on pointer values with comparisons to NULL.
SDL_pixels.c: Looks like the switch is genuinely missing a break!
SDL_rect_impl.h: The MacOS static checker pointed out issues with the X comparisons that were handled by assertions; I added assertions for the Y comparisons.
SDL_yuv.c, SDL_windowskeyboard.c, SDL_windowswindow.c: Checked error-result returns.
2022-11-16 12:43:20 -05:00
Sam Lantinga 70656b133c Don't recreate the window when creating a Metal renderer on an OpenGL window.
It turns out that we can safely create a Metal view on an existing window, and that avoids issues with the window being recreated with the wrong orientation in iOS 16.

Fixes https://github.com/libsdl-org/SDL/issues/6289
2022-11-15 10:21:07 -08:00
pionere dad8df3ed1 video: check graphics flags the same way in SDL_RecreateWindow as in SDL_CreateWindow
- single check to validate the graphics flags
- check it before tearing down the window
2022-11-14 07:53:41 -08:00
pionere 5f2a1231dd video: check graphics flags the same way as the type flags 2022-11-13 08:31:50 -08:00
pionere 22354b4142 video: simplify window-type check in SDL_CreateWindow 2022-11-12 07:18:04 -08:00
pionere d09edcbcac video: sync Metal_CreateView with GL_CreateContext and Vulkan_CreateSurface
no need to check if _this->Metal_CreateView, since it is already checked in Re(create)Window
2022-11-11 04:58:40 -08:00
pionere b71d927429 video: add NOT_AN_OPENGL_WINDOW define (similar to NOT_A_VULKAN_WINDOW) 2022-11-11 04:58:40 -08:00
pionere 36c6ed4b6f video: add SDL_DllNotSupported
- add SDL_DllNotSupported and use it to sync the behavior of SDL_GL_LoadLibrary with SDL_Vulkan_LoadLibrary
2022-11-11 02:53:30 -08:00
pionere 29cafa9c94 add SDL_ContextNotSupported and validate flags in SDL_RecreateWindow similar to SDL_CreateWindow 2022-11-10 06:56:24 -08:00
Ryan C. Gordon 1008cc8e5f
video: Add some braces to match SDL coding style. 2022-11-09 12:55:27 -05:00
pionere ac3349faaf solve FIXMEs in SDL_video.c 2022-11-09 12:54:07 -05:00
Ryan C. Gordon 9e8d2f3948
video: Don't use texture framebuffer on Windows Subsystem for Linux.
Reference Issue #6333.
2022-10-27 13:54:53 -04:00
Pierre Wendling f9785702a6 N3DS: Deduce screen from window's display.
This removes the need for a dedicated window creation flag.
2022-10-10 08:50:59 -07:00
Pierre Wendling 655275378d N3DS port (squashed)
A dedicated renderer using Citro3D would likely allow for better
much better graphical performances.
2022-10-10 08:50:59 -07:00
Sylvain eac3d6d3c0
SDL_video.c: fix variable 'i' may be uninitialized when used here "_this->name = bootstrap[i]->name;" 2022-10-04 10:46:42 +02:00
Sam Lantinga 9e3c4b9f32 Use the correct platform defines 2022-10-03 17:50:01 -07:00
Ryan C. Gordon a2c5757356
video: check for "software" with SDL_HINT_FRAMEBUFFER_ACCELERATION.
We check for this value elsewhere but not in SDL_CreateWindowFramebuffer.
2022-09-27 22:04:06 -04:00
Sam Lantinga d744aafb05 Added support for simulated vsync in the renderer
This kicks in if the platform doesn't support vsync directly, or if the present fails for some reason (e.g. minimized on some platforms)

Fixes https://github.com/libsdl-org/SDL/issues/5134
2022-09-16 07:44:40 -07:00
Frank Praznik 69e4c770f3 video: Make the mode switching function a NOP if mode switching is disabled
Instead of wrapping individual calls to SDL_SetDisplayModeForDisplay(), just check the flag in the function itself and make it a NOP that cannot fail if the flag is set. Silences some errant "SDL video driver doesn't support changing display mode" log errors.
2022-09-09 08:17:27 -07:00
Ozkan Sezer 5ffede35d9 Fix https://github.com/libsdl-org/SDL/issues/6191 2022-09-06 19:56:29 +03:00
Noel Berry 00452e47fa
Adding SDL_GetWindowSizeInPixels for window size in pixels (#6112) 2022-08-24 11:25:13 -07:00
Frank Praznik cc9cc2028d video: Add video device quirk flags and apply them to the video subsystem
Add quirk flags to the video device struct and add flags to allow video backend drivers to disable mode switching and disable unsetting the fullscreen mode when minimizing a window. As certain platforms can have multiple video backends compiled in at once, #ifdefs, as used by other platforms, aren't suitable as different backends on the same platform may not need the same quirks.

This replaces the formerly dedicated 'disable_display_mode_switching' boolean as additional quirks are needed by the Wayland backend.  Helper functions have also been added to simplify reading the flag states.
2022-08-15 11:16:20 -07:00
Sam Lantinga 7530bd74b3 Fix right, bottom computation in `SDL_GetClosestPointOnRect` which should be exclusive, not inclusive 2022-08-08 11:26:55 -07:00
Sam Lantinga 98bac00dcc Add `SDL_GetPointDisplayIndex` and `SDL_GetRectDisplayIndex` and re-implement `SDL_GetWindowDisplayIndex` in terms of `SDL_GetRectDisplayIndex`
- This allows looking up the display index for an arbitrary location rather than requiring an active window to do so.

- This change also reimplements the fallback display lookup that found the display with center closest to the window's center to instead find the display rect edge
  closest to the window center (this was done in the almost identical display lookup used in SDL_windowsmodes.c, which now uses `SDL_GetPointDisplayIndex`). In
  practice this should almost never be hit as it requires the window's center to not be enclosed by any display rect.
2022-08-08 11:26:52 -07:00
Adam Butcher 0bcbdfe2bd video: dummy: Support evdev psuedo-device with no video. 2022-08-08 08:31:04 -07:00
Shootfast 60d1944e46 SDL_video: Added SDL_GL_FLOATBUFFERS to allow Cocoa GL contexts to use EDR 2022-08-02 15:45:30 -07:00
Francisco Javier Trujillo Mata 46f95a7a5f Create dummy PS2 Video driver 2022-08-02 11:40:31 -07:00
Ryan C. Gordon 20a76b0e3e
video: removed unused devindex argument from bootstrap's create method. 2022-07-26 00:19:52 -04:00
Dean Herbert 6bcde52d88 Further adjust implementation of `Cocoa_GetWindowDisplayIndex`
As discussed in PR review, there may be an off-chance that the index
returned doesn't match up with SDL's display indexing.

This change ensures that the indices match and adds a safety check for
off-screen windows.
2022-07-24 09:25:16 -07:00
rohlem b085c18251 make SDL_SetTextInputRect take a pointer to const
The documentation doesn't state that the argument is ever modified,
and no implementation does so currently.
This is a non-breaking change to guarantee as much to callers.
2022-07-04 09:38:01 -07:00
chalonverse f317d619cc
Xbox GDKX support (#5869)
* Xbox GDK support (14 squashed commits)

* Added basic keyboard testing

* Update readme

* Code review fixes

* Fixed issue where controller add/removal wasn't working (since the device notification events don't work on Xbox, have to use the joystick thread to poll XInput)
2022-07-01 13:59:14 -07:00
chalonverse 3b191580c3
Windows GDK Support (#5830)
* Added GDK

* Simplfied checks in SDL_config_wingdk.h

* Added testgdk sample

* Added GDK readme

* Fixed error in merge of SDL_windows.h

* Additional GDK fixes

* OpenWatcom should not export _SDL_GDKGetTaskQueue

* Formatting fixes

* Moved initialization code into SDL_GDKRunApp
2022-06-27 10:19:39 -07:00
Eric Wasylishen ab81a559f4 Windows DPI scaling/highdpi support
Adds hint "SDL_WINDOWS_DPI_SCALING" which can be set to "1" to
change the SDL coordinate system units to be DPI-scaled points, rather
than pixels everywhere.

This means windows will be appropriately sized, even when created on
high-DPI displays with scaling.

e.g. requesting a 640x480 window from SDL, on a display with 125%
scaling in Windows display settings, will create a window with an
800x600 client area (in pixels).

Setting this to "1" implicitly requests process DPI awareness
(setting SDL_WINDOWS_DPI_AWARENESS is unnecessary),
and forces SDL_WINDOW_ALLOW_HIGHDPI on all windows.
2022-06-11 14:19:01 -07:00
Sam Lantinga 5669743a43 Make sure SDL_CaptureMouse() is only called on the main thread
Windows handles mouse capture on a per-thread basis, and capture must be done on the thread used to create a window.

Fixes https://github.com/libsdl-org/SDL/issues/5577
2022-05-19 09:52:47 -07:00
Sam Lantinga 0e6d4baa6b Fixed compile warning on gcc 11 2022-05-19 01:23:24 -07:00
Sam Lantinga e19a9a7931 Fixed a message box getting the mouse capture state out of sync 2022-05-18 15:34:07 -07:00
Cameron Cawley 0cca71a846 Use SDLCALL for callbacks in public APIs 2022-05-18 15:01:27 -07:00
Sam Lantinga 06aca7edaa Fixed warping back into the window when gaining focus with warp relative mode enabled 2022-05-18 10:10:51 -07:00
Alexander Kanavin adac3bd1e2 video: restore ability to disable fb accel via hint
Somewhere in code refactoring between .20 and .22 this check
was lost, and so the hint had no effect anymore.
2022-05-04 08:35:13 -07:00
Michael Fitzmayer fbd230bb6c
Add support for the Nokia N-Gage (#5597)
* Add initial support for the Nokia N-Gage

* N-Gage: disable clipping for the time being, issue needs to be resolved later

* Move va_copy definition to SDL_internal.h

* Move stdlib.h include to SDL_config_ngage.h, much cleaner this way

* Remove redundant include, add HAVE_STDLIB_H

* Revert "N-Gage: disable clipping for the time being, issue needs to be resolved later"

This reverts commit 4f5f0fc36cc7f34fad05e45671dfa7b8dc32fd51.

* N-Gage: fix clipping issue by providing proper math functions
2022-05-03 08:51:49 -07:00
Mirko Galimberti 76afb8583b Introduces Cocoa_GetWindowDisplayIndex. This enable a proper management for dpi when switching between retina and non-retina displays. 2022-04-26 09:51:31 -07:00
Frank Praznik 2b52946143 video: Don't minimize fullscreen windows on focus loss by default when mode switching is disabled
When mode switching is disabled in a video backend, fullscreen windows are basically just fullscreen desktop windows with different internal scaling.  As no mode switching occurs, there's no need to minimize them on focus loss by default.  This can still be overridden by explicitly setting the internal hint for minimizing on focus loss.

This has the side effect of fixing a bug on GNOME, where, when a fullscreen Wayland window has it's focus lost and restored via alt+tab followed by switching back to windowed mode, the top portion of the window won't end up being obstructed by GNOME's top bar.
2022-04-18 09:39:25 -07:00
Sam Lantinga 254fcc90eb Revert "video: Prefer Wayland over X11"
This reverts commit 8ceba27d62.

SDL Wayland support is stable, but there are a number of issues with third-party software (NVIDIA drivers, libwayland event overflow, libdecor not handling plugin load failures, Steam overlay not working with Wayland, etc.) that make it better to default to X11 at this time.

Games which would like to prefer wayland when available can use the following code before SDL_Init():
	SDL_SetHint(SDL_HINT_VIDEODRIVER, "wayland,x11");

Fixes https://github.com/libsdl-org/SDL/issues/5527
2022-04-18 09:03:14 -07:00
Ryan C. Gordon c1336b21ed hints: Make SDL_VIDEODRIVER and SDL_AUDIODRIVER formal hints.
They were just environment variables before.

Fixes #5528.
2022-04-17 11:31:55 -07:00
pionere 01b14e14e6 avoid NullPointer in SDL_GL_MakeCurrent 2022-04-15 08:30:33 -04:00
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