Commit Graph

1347 Commits

Author SHA1 Message Date
Sam Lantinga
b546db2f85 Only watch for display connect/disconnect events while the video subsystem is initialized 2020-10-09 12:58:28 -07:00
Ryan C. Gordon
b79832ba11 cocoa: Cut and paste from HTML strikes again! 2020-10-08 21:11:09 -04:00
Ozkan Sezer
19aaa2944d Fix https://bugzilla.libsdl.org/show_bug.cgi?id=5306
(Also see: https://bugzilla.libsdl.org/show_bug.cgi?id=4822)

Building the current tree against 10.8 SDK, clang emits the following warning:
src/video/cocoa/SDL_cocoawindow.m:1846:27: warning: instance method '-isOperatingSystemAtLeastVersion:' not found (return type defaults to 'id') [-Wobjc-method-access]
            ![processInfo isOperatingSystemAtLeastVersion:version]) {
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/MacOSX10.8.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSProcessInfo.h:20:12: note: receiver is instance of class declared here
@interface NSProcessInfo : NSObject {
           ^
1 warning generated.

isOperatingSystemAtLeastVersion is an 10.10 thing.
2020-10-09 04:00:00 +03:00
Ozkan Sezer
69fbd60d25 Fix https://bugzilla.libsdl.org/show_bug.cgi?id=4877#c2
loadNibNamed:owner:topLevelObjects is available on 10.8 and newer.
There is an issue report here about an app failing to function on
10.7 and earlier: https://discourse.libsdl.org/t/28179
2020-10-09 04:00:00 +03:00
Sam Lantinga
bd14f2676c Removed unused variable 2020-10-08 16:58:34 -07:00
Ozkan Sezer
d86a746542 SDL_video.c: fix whitespace 2020-10-09 02:55:00 +03:00
Sam Lantinga
76980e30f2 Added events for dynamically connecting and disconnecting displays, with an iOS implementation 2020-10-08 16:42:20 -07:00
Sam Lantinga
cd703b5628 Fixed whitespace 2020-10-08 16:41:48 -07:00
Ryan C. Gordon
77c9d73b63 Removed SDL_AndroidOpenURL, added SDL_OpenURL.
Still needs to be wired into Xcode and Visual Studio projects.
2020-10-05 11:30:33 -04:00
Sylvain Becker
cd6670bff3 SDL_Surface refcount: fix memory leak when blitting between stack'ed surfaces
(see bug 5226)
2020-10-02 10:48:27 +02:00
Manuel Alfayate Corchete
78c274cb5d kmsdrm: merge patches from Ozkan Sezer for removing c-99'isms and raising libgbm version reqeriments. 2020-09-26 19:18:09 +02:00
Sylvain Becker
955f3184f9 Fixed bug 5239 - Play audio on Android while backgrounded (Thanks Superfury)
Add hint SDL_HINT_ANDROID_BLOCK_ON_PAUSE_PAUSEAUDIO not to pause audio when
the app goes to background.
(It requires SDL_ANDROID_BLOCK_ON_PAUSE as "Non blocking")
2020-09-25 10:14:42 +02:00
Cameron Gutman
9a769da04a X11: Remove our X11 error callback in X11_DeleteDevice()
If we don't remove it, we will infinitely recurse if X11_CreateDevice() is
called again and orig_x11_errhandler becomes X11_SafetyNetErrHandler().
2020-09-07 20:10:50 -07:00
Manuel Alfayate Corchete
9c342e76dd kmsdrm: merge heap buffer overflow and cursor creation patches from meyraud705. 2020-09-13 21:41:10 +02:00
Manuel Alfayate Corchete
0cb9bfa502 kmsdrm: less excessive error checkhing 2020-09-12 15:58:47 +02:00
Manuel Alfayate Corchete
5bed30dd61 kmsdrm: also do pending modeseting in SwapWindowDoubleBuffered(). 2020-09-12 04:56:55 +02:00
Manuel Alfayate Corchete
9e9227add3 kmsdrm: reimplement modesetting for fullscreen window scaling and AR-correction. 2020-09-12 04:52:56 +02:00
Manuel Alfayate Corchete
4575c6942a kmsdrm: delete ununsed variable. 2020-09-12 02:36:02 +02:00
Manuel Alfayate Corchete
01b0cf1c90 Backed out changeset 4a45d1a30d25
kmsdrm: Fake KMSDRM_SetDisplayMode() is needed for some programs after all.
2020-09-12 00:47:00 +02:00
Manuel Alfayate Corchete
7b67654872 kmsdrm: don't fool SDL into thinking that changing the physical videomode is done. 2020-09-12 00:16:08 +02:00
Manuel Alfayate Corchete
a6d182d326 kmsdrm: no need to reconnect/reactivate things in SwapWindowDoubleBuffered(). 2020-09-11 23:47:26 +02:00
Manuel Alfayate Corchete
47e2d0304e kmsdrm: greatly improve comments in SwapBuffersFenced() for future reference. 2020-09-10 23:26:02 +02:00
Ryan C. Gordon
3c6004feb7 kmsdrm: Choose how to swap buffers based on EGL extension availability. 2020-09-10 15:07:23 -04:00
Ryan C. Gordon
c7e761f872 kmsdrm: Patched to compile if EGL headers lack EGL_ANDROID_native_fence_sync. 2020-09-10 15:05:55 -04:00
Ryan C. Gordon
224aa45b59 kmsdrm: Implement GL_DefaultProfileConfig for Raspberry Pi compatibility.
If we think this might be a Raspberry Pi device, default to ES2. Otherwise,
accept SDL's higher-level defaults.
2020-09-10 15:04:35 -04:00
Ryan C. Gordon
092162ede7 video: Set up default before calling GL_DefaultProfileConfig().
This way, the implementation can opt to do nothing to accept SDL's defaults.
2020-09-10 15:02:51 -04:00
Ryan C. Gordon
e758dd53dc egl: Make SDL_EGL_HasExtension() available outside of SDL_egl.c. 2020-09-10 15:02:00 -04:00
Manuel Alfayate Corchete
055cad49b6 kmsdrm: no need to re-connect/reactivate things in SwapWindow() anymore because we use a dumb buffer on KMS buffers destruction now. 2020-09-10 02:15:53 +02:00
Manuel Alfayate Corchete
351219bfd8 kmsdrm: On VideoQuit(), only destroy dumb buffer if it exists. 2020-09-09 03:18:26 +02:00
Sam Lantinga
8709f67ebc Fixed bug 5215 - Fixing filenames passed to dlopen for OpenBSD
Brad Smith

Attached is a patch to use the proper filenames when trying to dlopen the respective shared libraries on OpenBSD.
2020-09-08 08:42:30 -07:00
Cameron Gutman
1b6de9a987 Fix SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH=1 on Metal windows
SDL_cocoametalview was consuming the first click rather than passing it
through to the SDLView underneath which overrides [NSView acceptsFirstMouse]
based on the user's SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH preference.
2020-09-05 15:01:45 -07:00
Manuel Alfayate Corchete
244d0ad854 kmsdrm: Tell SDL that mouse has entered the window via artificial event. Fixes sticky mouse in Scummvm. 2020-09-08 15:30:45 +02:00
Manuel Alfayate Corchete
550e153365 kmsdrm: No need to test for display driverdata when freeing a plane. 2020-09-08 02:42:32 +02:00
Manuel Alfayate Corchete
6e03fab982 kmsdrm: add temporary RPI4_COMPAT define to try RPI4+current Rasbian compatibility. 2020-09-07 23:15:33 +02:00
Manuel Alfayate Corchete
0f807fd607 kmsdrm: use a black dumb buffer for keeping the PRIMARY PLANE occupied when we destroy the KMS buffers, instead of using the TTY buffer, to avoid flickering. 2020-09-07 22:54:15 +02:00
Sylvain Becker
ebc12a2fd2 SDL_Surface refcount: destination surface keep track of surfaces
that are mapped to it and automatically invalidate them when it is freed

- refcount is kept so that an external application can still create a reference
to SDL_Surface.

- lock_data was un-used and is now renamed and used as a list keep track of the blitmap
2020-09-07 18:50:30 +02:00
Manuel Alfayate Corchete
cce6c60518 kmsdrm: fix errors when trying to free up videomode driverdata pointers on quit. 2020-09-07 01:33:04 +02:00
Manuel Alfayate Corchete
9501b1c698 kmsdrm: fix scaling for SDL_WINDOW_FULLSCREEN windows. 2020-09-07 00:18:13 +02:00
Manuel Alfayate Corchete
daa752b10e kmsdrm: fix first frame display: no need to wait for SwapWindow() for EGL surface creation. 2020-09-06 23:19:54 +02:00
Manuel Alfayate Corchete
68ac9349aa kmsdrm: more coherent returns for SwapWindow. 2020-09-06 12:48:39 +02:00
Manuel Alfayate Corchete
d3d9d432ac kmsdrm: Remove debug printfs in SwapWindow. 2020-09-06 12:17:27 +02:00
Manuel Alfayate Corchete
d7aebbd58f kmsdrm: Don't create surfaces until EGL context is available. 2020-09-06 12:08:22 +02:00
Manuel Alfayate Corchete
f4e02a5c1b kmsdrm: Do NOT modify window size manually from the backend: doing so caused renderer scaling params miscalculation. 2020-08-31 19:17:17 +02:00
Manuel Alfayate Corchete
c09d1cee95 kmsdrm: Apply window reconfiguration in SetWindowSize(), too. 2020-08-28 23:04:00 +02:00
Manuel Alfayate Corchete
31b1794534 kmsdrm: use PLANE and CRTC to do hardware-driven window scaling and AR-correction. 2020-08-28 22:38:26 +02:00
Manuel Alfayate Corchete
fe3f97961b kmsdrm: unload EGL and GL lib only if using them. 2020-08-26 01:37:30 +02:00
Manuel Alfayate Corchete
9b43464d81 kmsdrm: Add programmer credits to the Atomic KMSDRM driver. 2020-08-25 16:30:23 +02:00
Manuel Alfayate Corchete
9316a8d979 kmsdrm: move FENCE FD props setting to SwapWindow(), where it belongs. 2020-08-25 16:18:49 +02:00
Manuel Alfayate Corchete
3f38009b2f kmsdrm: comment out atomic commit fast-debugging printf. 2020-08-25 15:40:36 +02:00
Manuel Alfayate Corchete
0d16761cbe kmsdrm: fix segfault on quit beacuse of freed _this->egl_data. 2020-08-25 05:53:13 +02:00
Manuel Alfayate Corchete
d43e666eed kmsdrm: Buffer management refactoring. Fixes for compatibility with more video drivers. 2020-08-25 04:05:36 +02:00
Manuel Alfayate Corchete
eade05ca03 kmsdrm: Finetune integer type usage. Add some comments. 2020-08-24 12:51:20 +02:00
Manuel Alfayate Corchete
a76f176361 kmsdrm: Move cursor plane setup and freeing to MouseInit() and MouseQuit(), for better consistency. 2020-08-24 01:10:11 +02:00
Manuel Alfayate Corchete
0d593d7ead kmsdrm: Add error control to plane prop setting function. Do most plane prop setting with a single function. 2020-08-23 23:44:07 +02:00
Manuel Alfayate Corchete
e06e9c35c8 kmsdrm: move cursor-related atomic helper functions and related struct typedefs to the SDL_kmsdrmmouse unit. 2020-08-23 11:26:55 +02:00
Manuel Alfayate Corchete
0b7b7721b9 kmsdrm: remove redundant function, use drm_atomic_setbuffers() for disconnecting planes instead. 2020-08-23 03:13:50 +02:00
Manuel Alfayate Corchete
16c04f266a kmsdrm: Init cursor surface on SetCursor() ONLY. Removal of dynamic modeset because it causes A LOT of problems with some kernel video drivers. Some refactoring and cleanups. 2020-08-23 02:58:57 +02:00
Manuel Alfayate Corchete
0d0ba111ae kmsdrm: correct parameter name. 2020-08-19 01:34:56 +02:00
Manuel Alfayate Corchete
5d32eda956 kmsdrm: implement smarter surface recreation function to be used in videomode changes. Other minor arrangements. 2020-08-19 01:31:22 +02:00
Manuel Alfayate Corchete
f79da81721 kmsdrm: free all connector, crtc and plane memory on KMSDRM_VideoQuit(). 2020-08-18 01:52:15 +02:00
Manuel Alfayate Corchete
92cb9192e3 kmsdrm: move hardware cursor functionality to the ATOMIC interface. Disconnect the display plane from the GBM surface buffers before destroying the GBM surface. 2020-08-17 18:35:04 +02:00
Tudor Brindus
c094332825 wayland: defer pointer confine creation until pointer unlock
It is a protocol error to attempt to create a pointer confine (i.e.
`SDL_SetWindowGrab`) while a locked pointer is active, and vice-versa.
Instead of aborting due to a protocol error, this commit makes SDL
gracefully downgrade locked pointers to confines when appropriate.
2020-07-21 13:14:24 -04:00
Manuel Alfayate Corchete
c437729b21 kmsdrm: separate requests in different functions so we only need one atomic commit for everything, as expected by atomic design. 2020-08-08 14:27:55 +02:00
Manuel Alfayate Corchete
3b9f1073c6 kmsdrm: wait for possible pending atomic commits before destroying surfaces, and before restoring video on quit. Move messages to the SDL_Log* functions. 2020-08-07 11:53:04 +02:00
Manuel Alfayate Corchete
96c99693a2 kmsdrm: wait for pending atomic commits before restoring videomode and crtc->buffer on VideoQuit, and simplify double-buffer SwapWindow() implementation. 2020-08-06 01:36:56 +02:00
Manuel Alfayate Corchete
09692b6170 kmsdrm: move videomode restoration on VideoQuit() to using the atomic interface instead of the legacy drmModeSetCrtc() function. Refactoring of get_plane_id(). 2020-08-05 18:55:22 +02:00
Manuel Alfayate Corchete
fc722b2d21 kmsdrm: free memory for plane, crtc and connector property tables on VideoQuit. 2020-08-05 15:28:51 +02:00
Manuel Alfayate Corchete
2d69ce08ba kmsdrm: double and triple buffered versions of SwapWindow() are now both reimplemented in atomic pageflipping versions, and can be selected via SDL_VIDEO_DOUBLE_BUFFER env variable. 2020-08-05 02:06:59 +02:00
Manuel Alfayate Corchete
8996ee1786 kmsdrm: update SwapWindow fn, moving it to triple-buffer. 2020-08-03 22:24:49 +02:00
Ryan C. Gordon
ea171c0564 winrt: Another attempt at getting this to compile.
IntPtr isn't a POD type like I thought, so hopefully we can just construct
one that works out? C++/CX is so weird.
2020-08-01 18:58:42 -04:00
Manuel Alfayate Corchete
b131661c6d kmsdrm: rewrite the new SwapWindow() fn to avoid tearing. Double-buffer only for now. 2020-08-01 18:23:34 +02:00
Ryan C. Gordon
282e4c65bf winrt: Patched to compile...?
Microsoft's C++/CX is weird, no idea if this will actually fix it.  :/
2020-07-31 19:42:23 -04:00
Manuel Alfayate Corchete
1a5503ce9f kmsdrm: Moved to the ATOMIC KMS/DRM interface for buffer swapping, leaving DRM-legacy behind. 2020-07-28 21:11:25 +02:00
RALOVICH, Kristof
c7eb557d89 kmsdrm: do not leak drmModeConnector
Previously conn was leaked on the success path (when available was
set to SDL_TRUE).
2020-07-20 10:09:07 -07:00
Manuel Alfayate Corchete
412b21b0e8 Rename the gbm device struct from gbm to gbm_dev for better readabilty. 2020-07-20 11:42:23 +02:00
RALOVICH, Kristof
155fdc7ac0 kmsdrm: settle with first card that has a connected connector
Previously the first card with non-empty connectors, encoders
and crtcs would be selected, however KMSDRM_VideoInit could still reject
it if the connector was not connected. This allow finding the first card
(in a multi GPU setup) that is actually connected to a display.
2020-07-19 21:48:17 -04:00
RALOVICH, Kristof
b78b88f7fb kmsdrm: fix typo 2020-07-19 21:46:41 -04:00
Manuel Alfayate Corchete
75fe4b14e3 Added comment about window creation behaviour in KMSDRM. 2020-07-19 19:53:57 +02:00
Manuel Alfayate Corchete
2f660c4fdd Delete windata variable no longer needed in KMSDR_SetDisplayMode(). 2020-07-19 19:11:02 +02:00
Manuel Alfayate Corchete
3a1d7d9c9a Surfaces have to be recreated immediately from KMSDRM_SetDisplayMode(). 2020-07-19 19:09:15 +02:00
Manuel Alfayate Corchete
b6a818b6a2 Fix SDL_Window recreation: drmModeSetCrtc() has to be called everytime the EGL and GBM surfaces are recreated. 2020-07-19 18:45:29 +02:00
Sam Lantinga
71e9df99c7 Fixed bug 5231 - Fix for hardware cursor: size and alpha-premultiplication.
Manuel Alfayate Corchete

I noticed pt2-clone had problems with it's optional hardware mouse on the KMSDRM backend: cursor had a transparent block around it.
So I was investigating and it seems that a GBM cursor needs it's pixels to be alpha-premultiplied instead of straight-alpha.
A
lso, I was previously relying on "manual testing" for the cursor size, but it's far better to use whatever the DRM driver recommends via drmGetCap(): any working driver should make a size recommendation via drmGetCap(), so that's what we use now. I took this decision because I found out that the AMDGPU driver reported working cursor sizes that would appear garbled on screen, and only the recommended cursor size works.
2020-07-19 08:55:01 -07:00
Ryan C. Gordon
b5affd12e6 Patched to compile. 2020-07-16 13:28:59 -04:00
Ryan C. Gordon
3b38e61a7d winrt: Fix casting a pointer to int.
Fixes Bugzilla #5202.
2020-07-16 13:25:50 -04:00
Ryan C. Gordon
8babda2c20 egl: SDL_EGL_LoadLibaryOnly() shouldn't set _this->gl_config.driver_loaded = 1
This is handled in in the higher-level SDL_GL_LoadLibrary().

All uses of SDL_EGL_LoadLibrary (which calls the Only version) are just
target-specific wrappers for their own GL_LoadLibrary hook, with two
exceptions which now handle driver_loaded correctly (although it's
questionable if these init-if-no-one-did-it-correctly-already code blocks
should exist at all, fwiw).

Fixes Bugzilla #5190.
2020-07-16 13:18:19 -04:00
M Stoeckl
a78b9763f1 Reuse Wayland connection from availability check 2020-07-14 19:18:16 -04:00
M Stoeckl
8669a87f05 Reuse X11 connection from availability check
Instead of creating an X11 connection to test that X11 is available,
closing the connection, and then reconnecting for real, use the same
connection to handle both cases.

The X11 connection retry delay mechanism in the case where X11 is
dynamically loaded has been removed. It was only necessary to avoid
authetnication token reuse from the XOpenDisplay call that used to
exist in X11_Available. Now that this call is only made once, it
is no longer needed.

Also drop unused and inapplicable code from a comment.
***
2020-07-14 21:13:27 -04:00
M Stoeckl
052a13738d Merge VideoBootStrap::available into VideoBootStrap::create
The two are only ever called together, and combining them makes it possible
to eliminate redundant symbol loading and redundant attempts to connect
to a display server.
2020-07-12 19:11:15 -04:00
Sylvain Beucler
e594a6738a emscripten: Introduce SDL_HINT_EMSCRIPTEN_ASYNCIFY
See https://github.com/emscripten-core/emscripten/issues/10746

and

https://github.com/emscripten-ports/SDL2/pull/112

Fixes Bugzilla #4997.
2020-06-27 16:25:47 -04:00
Sylvain Beucler
01af7b0254 emscripten: support pseudo-synchronous screen refresh and events update using asyncify 2020-06-27 16:22:50 -04:00
Ryan C. Gordon
694fea8ad8 video: Make SDL_CreateWindow use SDL_Init(SDL_INIT_VIDEO), not SDL_VideoInit.
Otherwise, the video subsystem won't deinitialize during SDL_Quit().

Fixes Bugzilla #5067.
2020-06-26 21:37:29 -04:00
Ryan C. Gordon
1947ca7028 video: Changed SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS to default to FALSE.
Fixes Bugzilla #5106.  (and probably many others, too!)
2020-06-26 20:16:43 -04:00
Sam Lantinga
ce293eed8d Fixed bug 5208 - Fix libGL loading on OpenBSD 2020-06-23 10:12:24 -07:00
Sam Lantinga
b9f55b6d80 Fixed bug 5199 - Fix KMSDRM_CreateWindow() segfault when starting L?VE2D engine.
Manuel Alfayate Corchete

This small patch fixes the KMSDRM_CreateSurfaces() call in KMSDRM_CreateWindow(), that was segfaulting deeper into SDL internals because the windata->viddata pointer wasn't set before the KMSDRM_CreateSurfaces() call.
So that's what this small patch does.

Now, L?VE2D works perfectly well on the Raspberry Pi 3, instead of just segfaulting.
2020-06-19 10:37:14 -07:00
James Legg
f1d5ced167 x11: Fix spurious keyboard focus events 2020-06-17 12:48:40 +01:00
Sam Lantinga
48989e2a87 Reverted comment change in previous commit 2020-06-17 08:47:27 -07:00
Sam Lantinga
a7ff6e9615 Fixed overflow in surface pitch calculation 2020-06-17 08:44:45 -07:00
Sam Lantinga
20aada0efc Fixed bug 5170 - Build fails when using Visual Studio 2017 with Windows 10 SDK 10.0.19041.0 in uwp
JackBoosY

In src/video/winrt/SDL_winrtgamebar.cpp line 55:

    virtual HRESULT STDMETHODCALLTYPE add_VisibilityChanged(
        __FIEventHandler_1_IInspectable *handler,
        Windows::Foundation::EventRegistrationToken *token) = 0;

The macro __FIEventHandler_1_IInspectable defined in windows.fondation.h(Windows10 SDK 10.0.17763.0) line 3576:
#define __FIVector_1_Windows__CFoundation__CPoint ABI::Windows::Foundation::Collections::__FIVector_1_Windows__CFoundation__CPoint_t

but no longer exists in Windows 10 SDK 10.0.19041.0.
After searching this macro in the sdk include path, I found that it was defined in many header files. But it should be replaced in windows.system.h .
2020-06-10 09:38:43 -07:00
Sam Lantinga
44f50c647e Fixed bug 5171 - PollEvent impacts performance in 2.0.12
On some systems, GetClipCursor() impacts performance when called frequently, so only call it every once in a while to make sure we haven't lost our capture.
2020-06-09 21:47:41 -07:00
Sam Lantinga
511a9702fc Fixed whitespace 2020-06-09 21:43:00 -07:00