Commit Graph

11075 Commits

Author SHA1 Message Date
Sam Lantinga
c709385856 Enable events for external X11 windows
Fixes https://github.com/libsdl-org/SDL/issues/3825
Fixes https://github.com/libsdl-org/SDL/issues/5142
Fixes https://github.com/libsdl-org/SDL/issues/9503
2024-08-04 09:07:19 -07:00
Sam Lantinga
ef6521aee7 testnative: print events with --info event 2024-08-04 09:07:19 -07:00
Sam Lantinga
6f6f4fbfd3 Updated X11 event debugging 2024-08-04 09:07:19 -07:00
Frank Praznik
ca2c9f680b video: Support multiple video driver entries having the same name string
Allow multiple bootstrap entries for a single video driver with the same name, which internally allows preferential and fallback init conditions while hiding the implementation details from applications (e.g. applications will just see "wayland", regardless of whether it's using the preferred or fallback driver list entry).

If a driver is requested, all instances of it in the list will be tried before reporting failure, and client applications programmatically enumerating the video drivers will be presented with a deduplicated list of entries.
2024-08-03 06:55:24 -07:00
Joshua Ashton
ab916a959e video: Only prefer Wayland if fifo-v1 and commit-timing-v1 are available
Wayland has a myriad of unresolved problems regarding surface suspension
blocking forever in QueuePresent/SwapBuffers when occludedand the FIFO
(vsync) implementation being fundamentally broken leading to reduced
GPU-bound performance and 'barcoding' frametimes due to swapchain
starvation.

There are two protocols used to solve these two problems together --
fifo-v1 and commit-timing-v1, which implement the commit queue on the
compositor side, and a timestamp that frames are intended to be
displayed for/discarded respectfully.

To avoid severe performance regressions for developers targeting SDL3,
only pick Wayland as the default backend when these two protocols are
supported -- otherwise fallback to X11/XWayland.

We do this by having two VideoBootStraps, one which is tests the
preferred case, "wayland_preferred" (ie. if fifo-v1 + commit-timing-v1
are available init time), and the fallback, which is just "wayland",
the same name as before, which does no such tests.
Thus, forcing with SDL_VIDEO_DRIVER=wayland will go onto the fallback
option, and pick Wayland always, as usual, so there is no behaviour
change.

In the case that X11/XWayland is not available (ie. no DISPLAY), we will
still fallback to using Wayland without these protocols available.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2024-08-03 06:55:24 -07:00
Susko3
e3cf20e1cc Remove createSDLMainRunnable() in favour of main() to fix multiple issues when providing custom main/runnable code (#10434)
This allows managed applications (eg. Java, C#) to override main() to their liking.
2024-08-03 06:34:38 -07:00
Sam Lantinga
2c0fcf27e8 Don't use alloca() in a loop, we might overflow the stack. 2024-08-02 21:38:29 -07:00
Sam Lantinga
f7c8d66ccb Use the convenience function SDL_GetWindowFromEvent() 2024-08-02 20:36:35 -07:00
Sam Lantinga
8d748d64e8 Fixed compiler warning building for macOS 2024-08-02 20:27:33 -07:00
Anonymous Maarten
f57c597c60 Added SDL_GetWindowFromEvent 2024-08-03 02:37:11 +00:00
Sam Lantinga
79f4de9f7e Use SDL_PROP_APP_METADATA_IDENTIFIER_STRING for the app ID 2024-08-02 19:36:31 -07:00
Sam Lantinga
cea71fbfcc SDL_cocoakeyboard: Fix errant semicolons in sendPendingKey and clearPendingKey definitions
- These are ignored by Clang but produce a warning: "semicolon before method body is ignored"
2024-08-02 18:55:30 -07:00
Sam Lantinga
2c1d40a9eb Added an error message when SDL_GetWindowFromID() fails 2024-08-02 18:43:24 -07:00
Sam Lantinga
50492e1d03 Change the text input defaults to match the natural input experience 2024-08-02 14:49:37 -07:00
Sam Lantinga
81f8e6aba6 Added SDL_StartTextInputWithProperties()
This allows you to customize the text input so you can have numeric text entry, hidden passwords, etc.

Fixes https://github.com/libsdl-org/SDL/issues/7101
Fixes https://github.com/libsdl-org/SDL/issues/7965
Fixes https://github.com/libsdl-org/SDL/issues/9439
2024-08-02 14:49:37 -07:00
Sam Lantinga
31ed3665ad Added support for high-DPI cursors and icons
Fixes https://github.com/libsdl-org/SDL/issues/9838
2024-08-01 13:48:28 -07:00
Sam Lantinga
94d9229ce2 Added SDL_AddSurfaceAlternateImage(), SDL_SurfaceHasAlternateImages(), SDL_GetSurfaceImages() and SDL_RemoveSurfaceAlternateImages()
These functions allow you to create surfaces with alternate high DPI content, and will be used for high DPI icon and cursor support.
2024-08-01 13:48:28 -07:00
Sam Lantinga
b8dc97c577 Use SDL_PremultiplySurfaceAlpha() when creating NSImages 2024-08-01 13:48:28 -07:00
Sam Lantinga
b8f3cd0a10 Added SDL_CursorData for internal cursor data 2024-08-01 13:48:28 -07:00
Sam Lantinga
22ffb487d0 Added SDL_ScaleSurface() 2024-08-01 13:48:28 -07:00
Sam Lantinga
15f68a86ff Group the blit copy flags to simplify code 2024-08-01 13:48:28 -07:00
Ozkan Sezer
7d27a97402 d3d12.h, d3d12sdklayers.h: fix build against older mingw-w64 versions.
Fixes: https://github.com/libsdl-org/SDL/issues/10452 .
2024-08-01 21:45:02 +03:00
Dragon-Baroque
808c312b2a Support SDL_EVENT_DROP_FILE in Windows with IDropTarget instead of WM_DROPFILES
Support SDL_EVENT_DROP_TEXT in Windows

  src/video/windows/SDL_windowsvideo.c + .h
    Connect      to COM WIN_CoInitialize   + OLE OleInitialize   in WIN_VideoInit
    Disconnect from COM WIN_CoUninitialize + OLE OleUninitialize in WIN_VideoQuit
  src/video/windows/SDL_windowswindow.c + .h
    Create / Destroy IDropTarget or use fallback WM_DROPFILES
      depending on OleInitialize success in WIN_VideoInit
    Handle text/uri-list, text/plain;charset=utf-8, CF_UNICODE_TEXT, CF_TEXT, CF_HDROP
    Call terminating WIN_AcceptDragAndDrop from WIN_DestroyWindow ( CleanupVideoData )
2024-08-01 07:17:17 -07:00
Ethan Lee
efefc4a1f3 d3d12: Move platform-specific includes/defines to SDL_d3d12.h 2024-07-31 23:34:31 -07:00
Sam Lantinga
a5f18048b2 Extend the 9-grid functions to handle a non-uniform grid layout (thanks @zaun!)
Fixes https://github.com/libsdl-org/SDL/issues/10389
2024-07-31 22:36:39 -07:00
Sam Lantinga
445983fc79 Remove D3D12 call hacks now that we have a good set of D3D12 headers 2024-07-31 19:10:13 -07:00
Sam Lantinga
de30400a7b Fixed uninitialized variable warning 2024-07-31 18:54:45 -07:00
Sam Lantinga
1954ac407f Don't mix keyboard and mouse raw input timestamps
We want to keep mouse timestamps consistently using the same interval, and it's helpful to know when multiple keyboard events come in at the same time.
2024-07-31 18:54:45 -07:00
Ethan Lee
55e9a8ca45 d3d12: Import DirectX-Headers, use local d3d12.h in SDL_render.
This avoids lots of build issues with the various D3D12 headers out there (MinGW, old Windows SDKs, etc) and also opens the door for WSL2 libd3d12.so support.

Note that the build system has not been changed; technically _all_ platforms now have d3d12.h but we should only enable the backend when it's actually expected to work.
2024-07-31 18:41:17 -07:00
Sam Lantinga
c5a99f1515 Fixed detecting wrapping Windows message time
It's possible to get message times out of order when processing the Windows message queue, so this passes those times through unchanged, while still detecting when the message tick wraps.
2024-07-31 16:36:47 -07:00
Ryan C. Gordon
364bbd545d audio: SDL_ClosestAudioFormats now favors float32 and native byte order.
Fixes #9581.
2024-07-31 07:19:15 -07:00
Sami Kyöstilä
80f5f0b1fb android: Fix activity pause/resume with external graphics context
This patch fixes two issues with pausing and resuming the Android
activity when an external graphics context[1] is used:

1. When pausing, don't wait for the EGL context to be backed up if a
   context wasn't created in the first place.

2. When resuming, don't recreate the EGL surface unless one was
   requested by the user when originally creating the window.

[1] SDL_PROP_WINDOW_CREATE_EXTERNAL_GRAPHICS_CONTEXT_BOOLEAN
2024-07-30 20:15:42 -07:00
Sam Lantinga
89de8e2110 Fixed infinite loop searching for matching video modes (thanks @Synt4xErr0r4!) 2024-07-30 17:29:21 -07:00
Anonymous Maarten
c7a1876536 SDL_test: use mutex based on SDL_AtomicInt in memory tracking
SDL_Mutex or SDL_SpinLock cannot be used as these use SDL_malloc internally.

ff
2024-07-30 20:56:19 +00:00
Anonymous Maarten
4c00433b69 SDL_test: format tracked allocation names during report generation 2024-07-30 20:56:19 +00:00
Sami Kyöstilä
b881e19896 android: Update window/surface pointers on change
When the native window or surface backing the SDL window changes, e.g.,
when the activity is resumed, we should also update the corresponding
window pointer properties (SDL_PROP_WINDOW_ANDROID_{WINDOW,SURFACE}
_POINTER) so that they remain in sync.
2024-07-30 09:27:53 -07:00
Sam Lantinga
f039b2290a Added logging for life cycle events 2024-07-30 07:52:13 -07:00
Sam Lantinga
de209c81d1 Fixed macOS build 2024-07-29 17:38:59 -07:00
Sam Lantinga
9fac7d7eb0 metal: set the shader input type based on the colorspace, not the pixel format
Fixes https://github.com/libsdl-org/SDL/issues/10402
2024-07-29 17:18:45 -07:00
Sam Lantinga
61e78830d0 Revert "Revert "Fixed warning: result of comparison of constant 9223372035 with expression of type '__kernel_old_time_t' (aka 'long') is always true""
This reverts commit 8caebf823a.
2024-07-29 14:45:03 -07:00
Sam Lantinga
8caebf823a Revert "Fixed warning: result of comparison of constant 9223372035 with expression of type '__kernel_old_time_t' (aka 'long') is always true"
This reverts commit 299d181984.
2024-07-29 14:44:02 -07:00
Sam Lantinga
0a924b185d Fixed crash with joystick rumble after disconnection
This prevents continuing a rumble after the first one fails, and fixes a long standing crash issue if rumble is started immediately before the controller is disconnected.

Thanks to @AntTheAlchemist for the key bug report that showed what was happening here.

Fixes https://github.com/libsdl-org/SDL/issues/10422
2024-07-29 13:35:58 -07:00
Sam Lantinga
67b973b5fa Fixed whitespace 2024-07-29 12:52:11 -07:00
Ryan C. Gordon
614a88ca3b SDL_IOFromFile: Apple targets no longer use the app bundle's resources dir.
Fixes #8403.
2024-07-29 15:44:51 -04:00
Sam Lantinga
299d181984 Fixed warning: result of comparison of constant 9223372035 with expression of type '__kernel_old_time_t' (aka 'long') is always true 2024-07-29 12:04:08 -07:00
Sam Lantinga
930d83aed2 Fixed warning: implicit conversion loses integer precision: 'VkDeviceSize' (aka 'unsigned long long') to 'size_t' (aka 'unsigned int') 2024-07-29 12:01:53 -07:00
Sam Lantinga
c4582a6536 Fixed warning building on tvOS 2024-07-29 11:56:28 -07:00
Sam Lantinga
062caeaa4b Fixed Android build with audio disabled
These functions are called by the Android event code regardless of whether audio is enabled

Fixes https://github.com/libsdl-org/SDL/issues/10418
2024-07-29 10:40:10 -07:00
Frank Praznik
51cccf3fa2 video: Disable relative warp emulation when warping the cursor after a fullscreen transition
Otherwise, relative mode can be accidentally activated if the cursor is hidden.
2024-07-29 12:46:48 -04:00
Sam Lantinga
5637cd009a Don't assert or change window draggable state if SDL isn't managing hit testing
Fixes an assert if the application has set up its own hit testing on macOS
2024-07-29 09:15:55 -07:00