Document that video and input functions should be called on the main thread.

This is a hard requirement on Apple platforms and while most other platforms don't have a concept of main thread, all video and input functions should be called on the same thread.
This commit is contained in:
Sam Lantinga
2024-12-05 09:45:32 -08:00
parent fffa6c7a2b
commit bc4185c685
7 changed files with 407 additions and 103 deletions

View File

@@ -139,6 +139,8 @@ typedef Uint32 SDL_MouseButtonFlags;
*
* \returns true if a mouse is connected, false otherwise.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.1.3.
*
* \sa SDL_GetMice
@@ -159,6 +161,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_HasMouse(void);
* call SDL_GetError() for more information. This should be freed
* with SDL_free() when it is no longer needed.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.1.3.
*
* \sa SDL_GetMouseNameForID
@@ -175,6 +179,8 @@ extern SDL_DECLSPEC SDL_MouseID * SDLCALL SDL_GetMice(int *count);
* \returns the name of the selected mouse, or NULL on failure; call
* SDL_GetError() for more information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.1.3.
*
* \sa SDL_GetMice
@@ -186,6 +192,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetMouseNameForID(SDL_MouseID insta
*
* \returns the window with mouse focus.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.1.3.
*/
extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void);
@@ -214,6 +222,8 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void);
* \returns a 32-bit bitmask of the button state that can be bitwise-compared
* against the SDL_BUTTON_MASK(X) macro.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.1.3.
*
* \sa SDL_GetGlobalMouseState
@@ -248,6 +258,8 @@ extern SDL_DECLSPEC SDL_MouseButtonFlags SDLCALL SDL_GetMouseState(float *x, flo
* \returns a 32-bit bitmask of the button state that can be bitwise-compared
* against the SDL_BUTTON_MASK(X) macro.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.1.3.
*
* \sa SDL_CaptureMouse
@@ -282,6 +294,8 @@ extern SDL_DECLSPEC SDL_MouseButtonFlags SDLCALL SDL_GetGlobalMouseState(float *
* \returns a 32-bit bitmask of the button state that can be bitwise-compared
* against the SDL_BUTTON_MASK(X) macro.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.1.3.
*
* \sa SDL_GetMouseState
@@ -304,6 +318,8 @@ extern SDL_DECLSPEC SDL_MouseButtonFlags SDLCALL SDL_GetRelativeMouseState(float
* \param x the x coordinate within the window.
* \param y the y coordinate within the window.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.1.3.
*
* \sa SDL_WarpMouseGlobal
@@ -327,6 +343,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window,
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.1.3.
*
* \sa SDL_WarpMouseInWindow
@@ -348,6 +366,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WarpMouseGlobal(float x, float y);
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.1.3.
*
* \sa SDL_GetWindowRelativeMouseMode
@@ -360,6 +380,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowRelativeMouseMode(SDL_Window *wind
* \param window the window to query.
* \returns true if relative mode is enabled for a window or false otherwise.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.1.3.
*
* \sa SDL_SetWindowRelativeMouseMode
@@ -406,6 +428,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowRelativeMouseMode(SDL_Window *wind
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.1.3.
*
* \sa SDL_GetGlobalMouseState
@@ -447,6 +471,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_CaptureMouse(bool enabled);
* \returns a new cursor with the specified parameters on success or NULL on
* failure; call SDL_GetError() for more information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.1.3.
*
* \sa SDL_CreateColorCursor
@@ -478,6 +504,8 @@ extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateCursor(const Uint8 * data,
* \returns the new cursor on success or NULL on failure; call SDL_GetError()
* for more information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.1.3.
*
* \sa SDL_CreateCursor
@@ -496,6 +524,8 @@ extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateColorCursor(SDL_Surface *surf
* \returns a cursor on success or NULL on failure; call SDL_GetError() for
* more information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.1.3.
*
* \sa SDL_DestroyCursor
@@ -514,6 +544,8 @@ extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.1.3.
*
* \sa SDL_GetCursor
@@ -528,6 +560,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetCursor(SDL_Cursor *cursor);
*
* \returns the active cursor or NULL if there is no mouse.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.1.3.
*
* \sa SDL_SetCursor
@@ -543,6 +577,8 @@ extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_GetCursor(void);
* \returns the default cursor on success or NULL on failuree; call
* SDL_GetError() for more information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.1.3.
*/
extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_GetDefaultCursor(void);
@@ -555,6 +591,8 @@ extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_GetDefaultCursor(void);
*
* \param cursor the cursor to free.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.1.3.
*
* \sa SDL_CreateColorCursor
@@ -569,6 +607,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_DestroyCursor(SDL_Cursor *cursor);
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.1.3.
*
* \sa SDL_CursorVisible
@@ -582,6 +622,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ShowCursor(void);
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.1.3.
*
* \sa SDL_CursorVisible
@@ -595,6 +637,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_HideCursor(void);
* \returns `true` if the cursor is being shown, or `false` if the cursor is
* hidden.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.1.3.
*
* \sa SDL_HideCursor