Add SDL_WindowID type for SDL_Window id

This commit is contained in:
Sylvain 2023-01-04 10:27:28 +01:00 committed by Sam Lantinga
parent 86c6376140
commit 6863f0b2d8
5 changed files with 22 additions and 17 deletions

View File

@ -858,3 +858,5 @@ The following functions have been renamed:
* SDL_GetPointDisplayIndex() => SDL_GetDisplayIndexForPoint() * SDL_GetPointDisplayIndex() => SDL_GetDisplayIndexForPoint()
* SDL_GetRectDisplayIndex() => SDL_GetDisplayIndexForRect() * SDL_GetRectDisplayIndex() => SDL_GetDisplayIndexForRect()
SDL_Window id type is named SDL_WindowID

View File

@ -230,7 +230,7 @@ typedef struct SDL_WindowEvent
{ {
Uint32 type; /**< ::SDL_WINDOWEVENT_* */ Uint32 type; /**< ::SDL_WINDOWEVENT_* */
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
Uint32 windowID; /**< The associated window */ SDL_WindowID windowID;/**< The associated window */
Sint32 data1; /**< event dependent data */ Sint32 data1; /**< event dependent data */
Sint32 data2; /**< event dependent data */ Sint32 data2; /**< event dependent data */
} SDL_WindowEvent; } SDL_WindowEvent;
@ -242,7 +242,7 @@ typedef struct SDL_KeyboardEvent
{ {
Uint32 type; /**< ::SDL_KEYDOWN or ::SDL_KEYUP */ Uint32 type; /**< ::SDL_KEYDOWN or ::SDL_KEYUP */
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
Uint32 windowID; /**< The window with keyboard focus, if any */ SDL_WindowID windowID;/**< The window with keyboard focus, if any */
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
Uint8 repeat; /**< Non-zero if this is a key repeat */ Uint8 repeat; /**< Non-zero if this is a key repeat */
Uint8 padding2; Uint8 padding2;
@ -258,7 +258,7 @@ typedef struct SDL_TextEditingEvent
{ {
Uint32 type; /**< ::SDL_TEXTEDITING */ Uint32 type; /**< ::SDL_TEXTEDITING */
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
Uint32 windowID; /**< The window with keyboard focus, if any */ SDL_WindowID windowID; /**< The window with keyboard focus, if any */
char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */ char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */
Sint32 start; /**< The start cursor of selected editing text */ Sint32 start; /**< The start cursor of selected editing text */
Sint32 length; /**< The length of selected editing text */ Sint32 length; /**< The length of selected editing text */
@ -272,7 +272,7 @@ typedef struct SDL_TextEditingExtEvent
{ {
Uint32 type; /**< ::SDL_TEXTEDITING_EXT */ Uint32 type; /**< ::SDL_TEXTEDITING_EXT */
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
Uint32 windowID; /**< The window with keyboard focus, if any */ SDL_WindowID windowID; /**< The window with keyboard focus, if any */
char* text; /**< The editing text, which should be freed with SDL_free(), and will not be NULL */ char* text; /**< The editing text, which should be freed with SDL_free(), and will not be NULL */
Sint32 start; /**< The start cursor of selected editing text */ Sint32 start; /**< The start cursor of selected editing text */
Sint32 length; /**< The length of selected editing text */ Sint32 length; /**< The length of selected editing text */
@ -286,7 +286,7 @@ typedef struct SDL_TextInputEvent
{ {
Uint32 type; /**< ::SDL_TEXTINPUT */ Uint32 type; /**< ::SDL_TEXTINPUT */
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
Uint32 windowID; /**< The window with keyboard focus, if any */ SDL_WindowID windowID; /**< The window with keyboard focus, if any */
char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */ char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */
} SDL_TextInputEvent; } SDL_TextInputEvent;
@ -297,7 +297,7 @@ typedef struct SDL_MouseMotionEvent
{ {
Uint32 type; /**< ::SDL_MOUSEMOTION */ Uint32 type; /**< ::SDL_MOUSEMOTION */
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
Uint32 windowID; /**< The window with mouse focus, if any */ SDL_WindowID windowID;/**< The window with mouse focus, if any */
SDL_MouseID which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ SDL_MouseID which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
Uint32 state; /**< The current button state */ Uint32 state; /**< The current button state */
float x; /**< X coordinate, relative to window */ float x; /**< X coordinate, relative to window */
@ -313,7 +313,7 @@ typedef struct SDL_MouseButtonEvent
{ {
Uint32 type; /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */ Uint32 type; /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
Uint32 windowID; /**< The window with mouse focus, if any */ SDL_WindowID windowID;/**< The window with mouse focus, if any */
SDL_MouseID which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ SDL_MouseID which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
Uint8 button; /**< The mouse button index */ Uint8 button; /**< The mouse button index */
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
@ -330,7 +330,7 @@ typedef struct SDL_MouseWheelEvent
{ {
Uint32 type; /**< ::SDL_MOUSEWHEEL */ Uint32 type; /**< ::SDL_MOUSEWHEEL */
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
Uint32 windowID; /**< The window with mouse focus, if any */ SDL_WindowID windowID;/**< The window with mouse focus, if any */
SDL_MouseID which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ SDL_MouseID which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
float x; /**< The amount scrolled horizontally, positive to the right and negative to the left */ float x; /**< The amount scrolled horizontally, positive to the right and negative to the left */
float y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */ float y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */
@ -509,7 +509,7 @@ typedef struct SDL_TouchFingerEvent
float dx; /**< Normalized in the range -1...1 */ float dx; /**< Normalized in the range -1...1 */
float dy; /**< Normalized in the range -1...1 */ float dy; /**< Normalized in the range -1...1 */
float pressure; /**< Normalized in the range 0...1 */ float pressure; /**< Normalized in the range 0...1 */
Uint32 windowID; /**< The window underneath the finger, if any */ SDL_WindowID windowID;/**< The window underneath the finger, if any */
} SDL_TouchFingerEvent; } SDL_TouchFingerEvent;
@ -523,7 +523,7 @@ typedef struct SDL_DropEvent
Uint32 type; /**< ::SDL_DROPBEGIN or ::SDL_DROPFILE or ::SDL_DROPTEXT or ::SDL_DROPCOMPLETE */ Uint32 type; /**< ::SDL_DROPBEGIN or ::SDL_DROPFILE or ::SDL_DROPTEXT or ::SDL_DROPCOMPLETE */
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
char *file; /**< The file name, which should be freed with SDL_free(), is NULL on begin/complete */ char *file; /**< The file name, which should be freed with SDL_free(), is NULL on begin/complete */
Uint32 windowID; /**< The window that was dropped on, if any */ SDL_WindowID windowID;/**< The window that was dropped on, if any */
} SDL_DropEvent; } SDL_DropEvent;
@ -564,7 +564,7 @@ typedef struct SDL_UserEvent
{ {
Uint32 type; /**< ::SDL_USEREVENT through ::SDL_LASTEVENT-1 */ Uint32 type; /**< ::SDL_USEREVENT through ::SDL_LASTEVENT-1 */
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
Uint32 windowID; /**< The associated window if any */ SDL_WindowID windowID;/**< The associated window if any */
Sint32 code; /**< User defined event code */ Sint32 code; /**< User defined event code */
void *data1; /**< User defined data pointer */ void *data1; /**< User defined data pointer */
void *data2; /**< User defined data pointer */ void *data2; /**< User defined data pointer */

View File

@ -39,6 +39,9 @@
extern "C" { extern "C" {
#endif #endif
typedef Uint32 SDL_WindowID;
/** /**
* \brief The structure that defines a display mode * \brief The structure that defines a display mode
* *
@ -743,7 +746,7 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindowFrom(const void *data);
* *
* \sa SDL_GetWindowFromID * \sa SDL_GetWindowFromID
*/ */
extern DECLSPEC Uint32 SDLCALL SDL_GetWindowID(SDL_Window * window); extern DECLSPEC SDL_WindowID SDLCALL SDL_GetWindowID(SDL_Window * window);
/** /**
* Get a window from a stored ID. * Get a window from a stored ID.
@ -759,7 +762,7 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetWindowID(SDL_Window * window);
* *
* \sa SDL_GetWindowID * \sa SDL_GetWindowID
*/ */
extern DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromID(Uint32 id); extern DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromID(SDL_WindowID id);
/** /**
* Get the window flags. * Get the window flags.

View File

@ -69,7 +69,7 @@ typedef struct SDL_WindowUserData
struct SDL_Window struct SDL_Window
{ {
const void *magic; const void *magic;
Uint32 id; SDL_WindowID id;
char *title; char *title;
SDL_Surface *icon; SDL_Surface *icon;
int x, y; int x, y;
@ -349,7 +349,7 @@ struct SDL_VideoDevice
SDL_Window *windows; SDL_Window *windows;
SDL_Window *grabbed_window; SDL_Window *grabbed_window;
Uint8 window_magic; Uint8 window_magic;
Uint32 next_object_id; SDL_WindowID next_object_id;
char *clipboard_text; char *clipboard_text;
char *primary_selection_text; char *primary_selection_text;
SDL_bool setting_display_mode; SDL_bool setting_display_mode;

View File

@ -1990,7 +1990,7 @@ SDL_HasWindows(void)
return _this && _this->windows != NULL; return _this && _this->windows != NULL;
} }
Uint32 SDL_WindowID
SDL_GetWindowID(SDL_Window *window) SDL_GetWindowID(SDL_Window *window)
{ {
CHECK_WINDOW_MAGIC(window, 0); CHECK_WINDOW_MAGIC(window, 0);
@ -1999,7 +1999,7 @@ SDL_GetWindowID(SDL_Window *window)
} }
SDL_Window * SDL_Window *
SDL_GetWindowFromID(Uint32 id) SDL_GetWindowFromID(SDL_WindowID id)
{ {
SDL_Window *window; SDL_Window *window;