Commit Graph

461 Commits (6407e0cc37185997480ca66d90d4ec6d8b276481)

Author SHA1 Message Date
SDL Wiki Bot 05d18aab1c Sync SDL3 wiki -> header 2024-01-08 19:55:19 +00:00
Frank Praznik f7dd0f9491 wayland: Allow the creation of roleless window surfaces for custom application use
Allow for the creation of SDL windows with a roleless surface that applications can use for their own purposes, such as with a windowing protocol other than XDG toplevel.

The property `wayland.surface_role_custom` will create a window with a surface that SDL can render to and handles input for, but is not associated with a toplevel window, so applications can use it for their own, custom purposes (e.g. wlr_layer_shell).

A test/minimal example is included in tests/testwaylandcustom.c
2024-01-08 14:54:47 -05:00
Sam Lantinga 7eae08cfc4 Removed SDL_GL_BindTexture() and SDL_GL_UnbindTexture()
Now that we have the OpenGL texture properties, you can directly bind them yourself.

Fixes https://github.com/libsdl-org/SDL/issues/2124
2024-01-07 20:19:19 -08:00
Sam Lantinga 1a13dae219 Added constant definitions for SDL properties
Fixes https://github.com/libsdl-org/SDL/issues/8622
2024-01-07 16:59:41 -08:00
Sam Lantinga 21c80ac843 Added a practical example of confirm/cancel gamepad button handling 2024-01-04 22:51:43 -08:00
Frank Praznik 73d02184d7 docs: Add Wayland to the SysWM migration example
Wayland will be increasingly encountered going forward and needs to be handled by applications requesting window handles to initialize the Vulkan WSI and such, so include it in the migration example to reflect current best practices.
2024-01-04 14:59:14 -05:00
Sam Lantinga ebd7f9adbd Fixed warning C4245: 'initializing': conversion from 'int' to 'Uint32', signed/unsigned mismatch in SDL_video.c 2023-12-29 10:37:28 -08:00
Sam Lantinga 39e24e52c8 Fixed example of creating a window with properties 2023-12-28 16:35:31 -08:00
Sam Lantinga dc450ba908 Added an example of creating a window with position 2023-12-28 16:34:13 -08:00
Sam Lantinga ce4fe32ce3 Added documentation for getting the X11 display from an SDL window 2023-12-28 16:26:55 -08:00
Sam Lantinga 327d31a5d9 Added documentation for getting the NSWindow from an SDL window 2023-12-28 16:09:59 -08:00
Sam Lantinga 3976bbef2a Added documentation for getting the X11 window from an SDL window 2023-12-28 15:56:37 -08:00
Sylvain ffd82fb7c4 Add scaleMode to SDL_SoftStretch(), remove SDL_SoftStretchLinear(). 2023-12-22 09:13:21 -08:00
Sylvain 5dba04b29b Remove SDL_{Set,Get}SurfaceScale().
Add Scale parameter to SDL_BlitSurfaceScaled() and SDL_BlitSurfaceScaledUnchecked()
(see #8732)
2023-12-22 02:08:49 -08:00
Sam Lantinga 4bb5e1f0f9 Added migration notes for migrating Steam Input support from SDL2 to SDL3 2023-12-20 14:15:09 -08:00
Frank Praznik 4fd778119b video: Implement asynchronous windowing
SDL window size, state, and position functions have been considered immediate, with their effects assuming to have taken effect upon successful return of the function. However, several windowing systems handle these requests asynchronously, resulting in the functions blocking until the changes have taken effect, potentially for long periods of time. Additionally, some windowing systems treat these as requests, and can potentially deny or fulfill the request in a manner differently than the application expects, such as not allowing a window to be positioned or sized beyond desktop borders, prohibiting fullscreen, and so on.

With these changes, applications can make requests of the window manager that do not block, with the understanding that an associated event will be sent if the request is fulfilled. Currently, size, position, maximize, minimize, and fullscreen calls are handled as asynchronous requests, with events being returned if the request is honored. If the application requires that the change take effect immediately, it can call the new SDL_SyncWindow function, which will attempt to block until the request is fulfilled, or some arbitrary timeout period elapses, the duration of which depends not only on the windowing system, but on the operation requested as well (e.g. a 100ms timeout is fine for most X11 events, but maximizing a window can take considerably longer for some reason). There is also a new hint 'SDL_VIDEO_SYNC_ALL_WINDOW_OPS' that will mimic the old behavior by synchronizing after every window operation with, again, the understanding that using this may result in the associated calls blocking for a relatively long period.

The deferred model also results in the window size and position getters not reporting false coordinates anymore, as they only forward what the window manager reports vs allowing applications to set arbitrary values, and fullscreen enter/leave events that were initiated via the window manager update the window state appropriately, where they didn't before.

Care was taken to ensure that order of operations is maintained, and that requests are not ignored or dropped. This does require some implicit internal synchronization in the various backends if many requests are made in a short period, as some state and behavior depends on other bits of state that need to be known at that particular point in time, but this isn't something that typical applications will hit, unless they are sending a lot of window state in a short time as the tests do.

The automated tests developed to test the previous behavior also resulted in previously undefined behavior being defined and normalized across platforms, particularly when it comes to the sizing and positioning of windows when they are in a fixed-size state, such as maximized or fullscreen. Size and position requests made when the window is not in a movable or resizable state will be deferred until it can be applied, so no requests are lost. These changes fix another long-standing issue with renderers recreating maximized windows, where the original non-maximized size was lost, resulting in the window being restored to the wrong size. All automated video tests pass across all platforms.

Overall, the "make a request/get an event" model better reflects how most windowing systems work, and some backends avoid spending significant time blocking while waiting for operations to complete.
2023-12-07 10:26:19 -08:00
Sam Lantinga ecd56bb8f0 Removed SDL_GetErrorMsg(), trivially implemented in application code 2023-12-01 09:08:23 -08:00
SDL Wiki Bot 675423f096 Sync SDL3 wiki -> header 2023-12-01 06:39:09 +00:00
Ryan C. Gordon 1072b6e86e
docs: fixed typo 2023-11-30 10:08:23 -05:00
Ryan C. Gordon daa38dc793 touch: Replace GetNumTouchDevices/GetTouchDevice with a single function.
Now it returns an array and optional count, to match other SDL3 APIs.

SDL_GetTouchName() was replaced with a function that takes an instance ID
instead of an index, too.
2023-11-29 20:50:44 -05:00
Ryan C. Gordon dd47da8a5c gamepad: Replace GetNumMappings/GetMappingByIndex with a single function.
Now it returns an array and optional count, to match other SDL3 APIs.
2023-11-29 20:50:44 -05:00
Ryan C. Gordon dfee3f9e92 render: Replaced SDL_RenderFlush with SDL_FlushRenderer.
This uses the same `SDL_VerbNoun` format as the rest of SDL3, and also
adds stronger effort to invalidate cached state in the backend, so cooperation
improves with apps that are using lowlevel rendering APIs directly.

Fixes #367.
2023-11-29 14:24:26 -05:00
Ryan C. Gordon f32575dfab
docs: Convert everything to Unix-style endlines.
Fixes #8640.
2023-11-29 11:29:57 -05:00
Ryan C. Gordon 6ba90f7775 render: Batching is always enabled now!
Make sure your app uses SDL_RenderFlush() before it talks to D3D/OpenGL/etc!

Fixes #8584.
2023-11-23 20:37:52 -05:00
Sam Lantinga 81fc7ded78 Removed the window shape API for SDL 3.0
Fixes https://github.com/libsdl-org/SDL/issues/6654
Fixes https://github.com/libsdl-org/SDL/issues/6897
2023-11-22 14:11:10 -08:00
Sam Lantinga 5c8c3931f2 Removed outdated information about SDL_GetWindowWMInfo() 2023-11-16 09:56:16 -08:00
Sam Lantinga e0d0d140b2 Fixed SDL_GetWindowWMInfo() code example 2023-11-16 09:55:06 -08:00
Sam Lantinga e0c45c6c98 Renamed SDL_WINDOW_FOREIGN to SDL_WINDOW_EXTERNAL 2023-11-14 06:06:51 -08:00
Sam Lantinga 229b7b9d50 SDL_CreateWindowWithPosition() and SDL_CreateWindowFrom() have been replaced with SDL_CreateWindowWithProperties()
This is a more general interface that can be extended in the future as needed.
2023-11-14 06:06:51 -08:00
Sam Lantinga 1c4723ac66 SDL_CreateWindowFrom() now takes a set of properties that describe the native window and options. 2023-11-12 21:58:58 -08:00
Sam Lantinga 2991b9f6ac SDL now represents gamepad buttons as positional elements with a separate label
This gives applications and binding systems a clearer view of what the hardware is so they can make intelligent decisions about how to present things to the user.

Gamepad mappings continue to use abxy for the face buttons for simplicity and compatibility with earlier versions of SDL, however the "SDL_GAMECONTROLLER_USE_BUTTON_LABELS" hint no longer has any effect.

Fixes https://github.com/libsdl-org/SDL/issues/6117
2023-11-10 12:21:43 -08:00
Sam Lantinga fd4a2cce9e SDL_syswm.h has been removed and replaced with window properties 2023-11-08 12:01:48 -08:00
Sam Lantinga a1941fad6c Replaced SDL_RenderGetD3D11Device(), SDL_RenderGetD3D12Device(), and SDL_RenderGetD3D9Device() with renderer properties. 2023-11-08 12:01:48 -08:00
Ryan C. Gordon 2f92807087
vulkan: SDL_Vulkan_CreateSurface now accepts an app-provided allocator.
Fixes #3638.
2023-11-06 13:31:20 -05:00
Sam Lantinga 20cd789bab Improved migration documentation for the event memory change. 2023-11-05 21:20:48 -08:00
Sam Lantinga 70c149c88f Automatically clean up memory associated with events 2023-11-05 09:14:11 -08:00
SDL Wiki Bot ff3c20a799 Sync SDL3 wiki -> header 2023-11-05 14:11:05 +00:00
SDL Wiki Bot 17a0fe3a0c Sync SDL3 wiki -> header 2023-11-05 14:06:05 +00:00
SDL Wiki Bot 14d2471a8f Sync SDL3 wiki -> header 2023-11-05 14:04:05 +00:00
SDL Wiki Bot 2ad22eeeb5 Sync SDL3 wiki -> header 2023-11-05 14:02:06 +00:00
Sam Lantinga 75ea3a8d32 Dynamically allocate long text for SDL_EVENT_TEXT_INPUT events
This prevents input text from being split across Unicode combining or modifier characters, and in practice allocations will rarely happen.
2023-11-04 20:55:10 -07:00
Sam Lantinga 46b940d571 Updated documentation to note that the event callback is called on the same thread as the main iteration callback 2023-11-04 11:31:54 -07:00
Sam Lantinga 274da8561c Updated the migration guide to note that you can check the return value of SDL_AddEventWatch() 2023-11-04 10:42:28 -07:00
Ryan C. Gordon a19029e3c1
docs: Updated README-main-functions.md based on feedback. 2023-11-04 10:03:10 -04:00
Sam Lantinga 7e445da569 Added SDL_CleanupEvent()
This is used to free any dynamically allocated memory in events.
2023-11-04 06:47:24 -07:00
SDL Wiki Bot cf7e5bd0e8 Sync SDL3 wiki -> header 2023-11-03 15:41:14 +00:00
Ryan C. Gordon 853c28e624
docs: Added first draft of README-main-functions.md
Reference PR #8247.
2023-11-03 11:39:53 -04:00
Sam Lantinga ea02630143 More audio migration clarification 2023-11-03 00:28:05 -07:00
Sam Lantinga 14980b25a8 Clarify documentation for audio callback migration 2023-11-02 22:32:25 -07:00
Ryan C. Gordon 5b3a2c6df6
docs: Updated SDL_Vulkan_GetInstanceExtensions info in README-migration.md.
Reference PR #8457.
2023-11-02 14:57:13 -04:00