From 4dd26698fcd0dc233b453535f3c59f4935105c94 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 13 Mar 2023 11:20:42 -0700 Subject: [PATCH] Added SDL_GetWindowParent() to get the parent of popup windows --- WhatsNew.txt | 1 + include/SDL3/SDL_video.h | 13 +++++++++++++ src/dynapi/SDL_dynapi.sym | 1 + src/dynapi/SDL_dynapi_overrides.h | 1 + src/dynapi/SDL_dynapi_procs.h | 1 + src/video/SDL_video.c | 7 +++++++ 6 files changed, 24 insertions(+) diff --git a/WhatsNew.txt b/WhatsNew.txt index 880ca0e42..ea88419aa 100644 --- a/WhatsNew.txt +++ b/WhatsNew.txt @@ -15,6 +15,7 @@ General: * Added SDL_GetSystemTheme() to return whether the system is using a dark or light color theme, and SDL_EVENT_SYSTEM_THEME_CHANGED is sent when this changes * Added SDL_GetDisplays() to return a list of connected displays * Added SDL_GetPrimaryDisplay() to get the instance ID of the primary display +* Added SDL_GetWindowParent() to get the parent of popup windows * Added SDL_CreateSurface() and SDL_CreateSurfaceFrom() which replace SDL_CreateRGBSurface*(), and can also be used to create YUV surfaces * Added SDL_GetJoysticks(), SDL_GetJoystickInstanceName(), SDL_GetJoystickInstancePath(), SDL_GetJoystickInstancePlayerIndex(), SDL_GetJoystickInstanceGUID(), SDL_GetJoystickInstanceVendor(), SDL_GetJoystickInstanceProduct(), SDL_GetJoystickInstanceProductVersion(), and SDL_GetJoystickInstanceType() to directly query the list of available joysticks * Added SDL_GetGamepads(), SDL_GetGamepadInstanceName(), SDL_GetGamepadInstancePath(), SDL_GetGamepadInstancePlayerIndex(), SDL_GetGamepadInstanceGUID(), SDL_GetGamepadInstanceVendor(), SDL_GetGamepadInstanceProduct(), SDL_GetGamepadInstanceProductVersion(), and SDL_GetGamepadInstanceType() to directly query the list of available gamepads diff --git a/include/SDL3/SDL_video.h b/include/SDL3/SDL_video.h index c11262566..ccf1251bf 100644 --- a/include/SDL3/SDL_video.h +++ b/include/SDL3/SDL_video.h @@ -711,6 +711,7 @@ extern DECLSPEC SDL_Window *SDLCALL SDL_CreateWindow(const char *title, int w, i * * \sa SDL_CreateWindow * \sa SDL_DestroyWindow + * \sa SDL_GetWindowParent */ extern DECLSPEC SDL_Window *SDLCALL SDL_CreatePopupWindow(SDL_Window *parent, int offset_x, int offset_y, int w, int h, Uint32 flags); @@ -765,6 +766,18 @@ extern DECLSPEC SDL_WindowID SDLCALL SDL_GetWindowID(SDL_Window *window); */ extern DECLSPEC SDL_Window *SDLCALL SDL_GetWindowFromID(SDL_WindowID id); +/** + * Get parent of a window. + * + * \param window the window to query + * \returns the parent of the window on success or NULL if the window has no parent. + * + * \since This function is available since SDL 3.0.0. + * + * \sa SDL_CreatePopupWindow + */ +extern DECLSPEC SDL_Window *SDLCALL SDL_GetWindowParent(SDL_Window *window); + /** * Get the window flags. * diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym index a9431a817..4b334c254 100644 --- a/src/dynapi/SDL_dynapi.sym +++ b/src/dynapi/SDL_dynapi.sym @@ -840,6 +840,7 @@ SDL3_0.0.0 { SDL_GetRenderWindowSize; SDL_GetSystemTheme; SDL_CreatePopupWindow; + SDL_GetWindowParent; # extra symbols go here (don't modify this line) local: *; }; diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h index 50d70af8e..0d4b3c9c7 100644 --- a/src/dynapi/SDL_dynapi_overrides.h +++ b/src/dynapi/SDL_dynapi_overrides.h @@ -867,3 +867,4 @@ #define SDL_GetRenderWindowSize SDL_GetRenderWindowSize_REAL #define SDL_GetSystemTheme SDL_GetSystemTheme_REAL #define SDL_CreatePopupWindow SDL_CreatePopupWindow_REAL +#define SDL_GetWindowParent SDL_GetWindowParent_REAL diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index 8bbde00e5..8945a1535 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -912,3 +912,4 @@ SDL_DYNAPI_PROC(int,SDL_GetRenderScale,(SDL_Renderer *a, float *b, float *c),(a, SDL_DYNAPI_PROC(int,SDL_GetRenderWindowSize,(SDL_Renderer *a, int *b, int *c),(a,b,c),return) SDL_DYNAPI_PROC(SDL_SystemTheme,SDL_GetSystemTheme,(void),(),return) SDL_DYNAPI_PROC(SDL_Window*,SDL_CreatePopupWindow,(SDL_Window *a, int b, int c, int d, int e, Uint32 f),(a,b,c,d,e,f),return) +SDL_DYNAPI_PROC(SDL_Window*,SDL_GetWindowParent,(SDL_Window *a),(a),return) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index ea1cf6cce..762eb7746 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -2191,6 +2191,13 @@ SDL_Window *SDL_GetWindowFromID(SDL_WindowID id) return NULL; } +SDL_Window *SDL_GetWindowParent(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, NULL); + + return window->parent; +} + Uint32 SDL_GetWindowFlags(SDL_Window *window) { CHECK_WINDOW_MAGIC(window, 0);