SDL/docs
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
..
README-android.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
README-cmake.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
README-contributing.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
README-dynapi.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
README-emscripten.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
README-gdk.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
README-git.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
README-hg.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
README-highdpi.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
README-ios.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
README-kmsbsd.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
README-linux.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
README-macos.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
README-main-functions.md Sync SDL3 wiki -> header 2023-12-01 06:39:09 +00:00
README-migration.md video: Implement asynchronous windowing 2023-12-07 10:26:19 -08:00
README-n3ds.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
README-ngage.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
README-platforms.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
README-porting.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
README-ps2.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
README-psp.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
README-raspberrypi.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
README-riscos.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
README-touch.md touch: Replace GetNumTouchDevices/GetTouchDevice with a single function. 2023-11-29 20:50:44 -05:00
README-versions.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
README-visualc.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
README-vita.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
README-wayland.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
README-windows.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
README-winrt.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
README.md docs: Convert everything to Unix-style endlines. 2023-11-29 11:29:57 -05:00
doxyfile docs: Fix doxyfile 2023-02-19 10:01:33 -08:00
release_checklist.md Updated release_checklist.md for SDL 3.0 2023-01-04 23:47:01 -08:00

README.md

Simple DirectMedia Layer

https://www.libsdl.org/

Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D. It is used by video playback software, emulators, and popular games including Valve's award winning catalog and many Humble Bundle games.

SDL officially supports Windows, macOS, Linux, iOS, and Android. Support for other platforms may be found in the source code.

SDL is written in C, works natively with C++, and there are bindings available for several other languages, including C# and Python.

This library is distributed under the zlib license, which can be found in the file "LICENSE.txt".

The best way to learn how to use SDL is to check out the header files in the "include" subdirectory and the programs in the "test" subdirectory. The header files and test programs are well commented and always up to date.

More documentation and FAQs are available online at the wiki

If you need help with the library, or just want to discuss SDL related issues, you can join the SDL Discourse, which can be used as a web forum or a mailing list, at your preference.

If you want to report bugs or contribute patches, please submit them to our bug tracker

Enjoy!

Sam Lantinga mailto:slouken@libsdl.org