diff --git a/include/SDL_video.h b/include/SDL_video.h index 0b1065dbb..c2f3e2f30 100644 --- a/include/SDL_video.h +++ b/include/SDL_video.h @@ -1046,6 +1046,27 @@ extern DECLSPEC int SDLCALL SDL_GetWindowBordersSize(SDL_Window * window, int *top, int *left, int *bottom, int *right); +/** + * Get the size of a window in pixels. + * + * This may differ from SDL_GetWindowSize() if we're rendering to a high-DPI + * drawable, i.e. the window was created with `SDL_WINDOW_ALLOW_HIGHDPI` on a + * platform with high-DPI support (Apple calls this "Retina"), and not + * disabled by the `SDL_HINT_VIDEO_HIGHDPI_DISABLED` hint. + * + * \param window the window from which the drawable size should be queried + * \param w a pointer to variable for storing the width in pixels, may be NULL + * \param h a pointer to variable for storing the height in pixels, may be + * NULL + * + * \since This function is available since SDL 2.26.0. + * + * \sa SDL_CreateWindow + * \sa SDL_GetWindowSize + */ +extern DECLSPEC void SDLCALL SDL_GetWindowSizeInPixels(SDL_Window * window, + int *w, int *h); + /** * Set the minimum size of a window's client area. * diff --git a/src/dynapi/SDL2.exports b/src/dynapi/SDL2.exports index cb05dcb45..1faa894dc 100644 --- a/src/dynapi/SDL2.exports +++ b/src/dynapi/SDL2.exports @@ -858,3 +858,4 @@ ++'_SDL_GetRectDisplayIndex'.'SDL2.dll'.'SDL_GetRectDisplayIndex' ++'_SDL_ResetHint'.'SDL2.dll'.'SDL_ResetHint' ++'_SDL_crc16'.'SDL2.dll'.'SDL_crc16' +++'_SDL_GetWindowSizeInPixels'.'SDL2.dll'.'SDL_GetWindowSizeInPixels' diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h index 97daae25d..cabb7cd84 100644 --- a/src/dynapi/SDL_dynapi_overrides.h +++ b/src/dynapi/SDL_dynapi_overrides.h @@ -884,3 +884,4 @@ #define SDL_GetRectDisplayIndex SDL_GetRectDisplayIndex_REAL #define SDL_ResetHint SDL_ResetHint_REAL #define SDL_crc16 SDL_crc16_REAL +#define SDL_GetWindowSizeInPixels SDL_GetWindowSizeInPixels_REAL diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index 5883ade16..9b6919ce5 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -967,3 +967,4 @@ SDL_DYNAPI_PROC(int,SDL_GetPointDisplayIndex,(const SDL_Point *a),(a),return) SDL_DYNAPI_PROC(int,SDL_GetRectDisplayIndex,(const SDL_Rect *a),(a),return) SDL_DYNAPI_PROC(SDL_bool,SDL_ResetHint,(const char *a),(a),return) SDL_DYNAPI_PROC(Uint16,SDL_crc16,(Uint16 a, const void *b, size_t c),(a,b,c),return) +SDL_DYNAPI_PROC(void,SDL_GetWindowSizeInPixels,(SDL_Window *a, int *b, int *c),(a,b,c),) diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index 5344d0a55..ae83009a5 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -308,7 +308,7 @@ D3D_ActivateRenderer(SDL_Renderer * renderer) int w, h; Uint32 window_flags = SDL_GetWindowFlags(window); - WIN_GetDrawableSize(window, &w, &h); + SDL_GetWindowSizeInPixels(window, &w, &h); data->pparams.BackBufferWidth = w; data->pparams.BackBufferHeight = h; if (window_flags & SDL_WINDOW_FULLSCREEN && (window_flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) { @@ -357,7 +357,7 @@ D3D_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) static int D3D_GetOutputSize(SDL_Renderer * renderer, int *w, int *h) { - WIN_GetDrawableSize(renderer->window, w, h); + SDL_GetWindowSizeInPixels(renderer->window, w, h); return 0; } @@ -1653,7 +1653,7 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) SDL_GetWindowWMInfo(window, &windowinfo); window_flags = SDL_GetWindowFlags(window); - WIN_GetDrawableSize(window, &w, &h); + SDL_GetWindowSizeInPixels(window, &w, &h); SDL_GetWindowDisplayMode(window, &fullscreen_mode); SDL_zero(pparams); diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c index cd3dab4a2..f7dfefee6 100644 --- a/src/render/direct3d11/SDL_render_d3d11.c +++ b/src/render/direct3d11/SDL_render_d3d11.c @@ -916,7 +916,7 @@ D3D11_CreateWindowSizeDependentResources(SDL_Renderer * renderer) #if defined(__WINRT__) SDL_GetWindowSize(renderer->window, &w, &h); #else - WIN_GetDrawableSize(renderer->window, &w, &h); + SDL_GetWindowSizeInPixels(renderer->window, &w, &h); #endif data->rotation = D3D11_GetCurrentRotation(); /* SDL_Log("%s: windowSize={%d,%d}, orientation=%d\n", __FUNCTION__, w, h, (int)data->rotation); */ @@ -1062,7 +1062,7 @@ D3D11_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) static int D3D11_GetOutputSize(SDL_Renderer * renderer, int *w, int *h) { - WIN_GetDrawableSize(renderer->window, w, h); + SDL_GetWindowSizeInPixels(renderer->window, w, h); return 0; } #endif diff --git a/src/render/direct3d12/SDL_render_d3d12.c b/src/render/direct3d12/SDL_render_d3d12.c index 397101974..5a7842aa0 100644 --- a/src/render/direct3d12/SDL_render_d3d12.c +++ b/src/render/direct3d12/SDL_render_d3d12.c @@ -513,7 +513,7 @@ D3D12_DestroyRenderer(SDL_Renderer * renderer) static int D3D12_GetOutputSize(SDL_Renderer *renderer, int *w, int *h) { - WIN_GetDrawableSize(renderer->window, w, h); + SDL_GetWindowSizeInPixels(renderer->window, w, h); return 0; } @@ -1267,7 +1267,7 @@ D3D12_CreateWindowSizeDependentResources(SDL_Renderer * renderer) /* The width and height of the swap chain must be based on the display's * non-rotated size. */ - WIN_GetDrawableSize(renderer->window, &w, &h); + SDL_GetWindowSizeInPixels(renderer->window, &w, &h); data->rotation = D3D12_GetCurrentRotation(); if (D3D12_IsDisplayRotated90Degrees(data->rotation)) { int tmp = w; diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 4ea7705e9..d3f0d83e2 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -227,6 +227,7 @@ struct SDL_VideoDevice void (*SetWindowMinimumSize) (_THIS, SDL_Window * window); void (*SetWindowMaximumSize) (_THIS, SDL_Window * window); int (*GetWindowBordersSize) (_THIS, SDL_Window * window, int *top, int *left, int *bottom, int *right); + void (*GetWindowSizeInPixels)(_THIS, SDL_Window *window, int *w, int *h); int (*SetWindowOpacity) (_THIS, SDL_Window * window, float opacity); int (*SetWindowModalFor) (_THIS, SDL_Window * modal_window, SDL_Window * parent_window); int (*SetWindowInputFocus) (_THIS, SDL_Window * window); diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 21c516265..881b06b9f 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -2366,6 +2366,28 @@ SDL_GetWindowBordersSize(SDL_Window * window, int *top, int *left, int *bottom, return _this->GetWindowBordersSize(_this, window, top, left, bottom, right); } +void +SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h) +{ + int filter; + + CHECK_WINDOW_MAGIC(window,); + + if (w == NULL) { + w = &filter; + } + + if (h == NULL) { + h = &filter; + } + + if (_this->GetWindowSizeInPixels) { + _this->GetWindowSizeInPixels(_this, window, w, h); + } else { + SDL_GetWindowSize(window, w, h); + } +} + void SDL_SetWindowMinimumSize(SDL_Window * window, int min_w, int min_h) { @@ -4096,7 +4118,7 @@ void SDL_GL_GetDrawableSize(SDL_Window * window, int *w, int *h) if (_this->GL_GetDrawableSize) { _this->GL_GetDrawableSize(_this, window, w, h); } else { - SDL_GetWindowSize(window, w, h); + SDL_GetWindowSizeInPixels(window, w, h); } } @@ -4791,7 +4813,7 @@ void SDL_Vulkan_GetDrawableSize(SDL_Window * window, int *w, int *h) if (_this->Vulkan_GetDrawableSize) { _this->Vulkan_GetDrawableSize(_this, window, w, h); } else { - SDL_GetWindowSize(window, w, h); + SDL_GetWindowSizeInPixels(window, w, h); } } @@ -4844,7 +4866,7 @@ void SDL_Metal_GetDrawableSize(SDL_Window * window, int *w, int *h) if (_this->Metal_GetDrawableSize) { _this->Metal_GetDrawableSize(_this, window, w, h); } else { - SDL_GetWindowSize(window, w, h); + SDL_GetWindowSizeInPixels(window, w, h); } } diff --git a/src/video/cocoa/SDL_cocoametalview.m b/src/video/cocoa/SDL_cocoametalview.m index ebdc921a1..c3f45279d 100644 --- a/src/video/cocoa/SDL_cocoametalview.m +++ b/src/video/cocoa/SDL_cocoametalview.m @@ -185,17 +185,7 @@ Cocoa_Metal_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h) } } else { /* Fall back to the viewport size. */ - NSRect viewport = [contentView bounds]; - if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) { - /* This gives us the correct viewport for a Retina-enabled view. */ - viewport = [contentView convertRectToBacking:viewport]; - } - if (w) { - *w = viewport.size.width; - } - if (h) { - *h = viewport.size.height; - } + SDL_GetWindowSizeInPixels(window, w, h); } }} diff --git a/src/video/cocoa/SDL_cocoaopengl.h b/src/video/cocoa/SDL_cocoaopengl.h index 9ac44ab5f..0f9b1c7f0 100644 --- a/src/video/cocoa/SDL_cocoaopengl.h +++ b/src/video/cocoa/SDL_cocoaopengl.h @@ -61,8 +61,6 @@ extern void Cocoa_GL_UnloadLibrary(_THIS); extern SDL_GLContext Cocoa_GL_CreateContext(_THIS, SDL_Window * window); extern int Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); -extern void Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, - int * w, int * h); extern int Cocoa_GL_SetSwapInterval(_THIS, int interval); extern int Cocoa_GL_GetSwapInterval(_THIS); extern int Cocoa_GL_SwapWindow(_THIS, SDL_Window * window); diff --git a/src/video/cocoa/SDL_cocoaopengl.m b/src/video/cocoa/SDL_cocoaopengl.m index 91319d5a7..8aab0c4cb 100644 --- a/src/video/cocoa/SDL_cocoaopengl.m +++ b/src/video/cocoa/SDL_cocoaopengl.m @@ -385,28 +385,6 @@ Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) return 0; }} -void -Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h) -{ @autoreleasepool -{ - SDL_WindowData *windata = (__bridge SDL_WindowData *) window->driverdata; - NSView *contentView = windata.sdlContentView; - NSRect viewport = [contentView bounds]; - - if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) { - /* This gives us the correct viewport for a Retina-enabled view. */ - viewport = [contentView convertRectToBacking:viewport]; - } - - if (w) { - *w = viewport.size.width; - } - - if (h) { - *h = viewport.size.height; - } -}} - int Cocoa_GL_SetSwapInterval(_THIS, int interval) { @autoreleasepool diff --git a/src/video/cocoa/SDL_cocoavideo.m b/src/video/cocoa/SDL_cocoavideo.m index 11a581b3c..b093e2efc 100644 --- a/src/video/cocoa/SDL_cocoavideo.m +++ b/src/video/cocoa/SDL_cocoavideo.m @@ -100,6 +100,7 @@ Cocoa_CreateDevice(void) device->SetWindowMinimumSize = Cocoa_SetWindowMinimumSize; device->SetWindowMaximumSize = Cocoa_SetWindowMaximumSize; device->SetWindowOpacity = Cocoa_SetWindowOpacity; + device->GetWindowSizeInPixels = Cocoa_GetWindowSizeInPixels; device->ShowWindow = Cocoa_ShowWindow; device->HideWindow = Cocoa_HideWindow; device->RaiseWindow = Cocoa_RaiseWindow; @@ -133,7 +134,6 @@ Cocoa_CreateDevice(void) device->GL_UnloadLibrary = Cocoa_GL_UnloadLibrary; device->GL_CreateContext = Cocoa_GL_CreateContext; device->GL_MakeCurrent = Cocoa_GL_MakeCurrent; - device->GL_GetDrawableSize = Cocoa_GL_GetDrawableSize; device->GL_SetSwapInterval = Cocoa_GL_SetSwapInterval; device->GL_GetSwapInterval = Cocoa_GL_GetSwapInterval; device->GL_SwapWindow = Cocoa_GL_SwapWindow; diff --git a/src/video/cocoa/SDL_cocoawindow.h b/src/video/cocoa/SDL_cocoawindow.h index ec25e1f57..cd76b0cd9 100644 --- a/src/video/cocoa/SDL_cocoawindow.h +++ b/src/video/cocoa/SDL_cocoawindow.h @@ -145,6 +145,7 @@ extern void Cocoa_SetWindowPosition(_THIS, SDL_Window * window); extern void Cocoa_SetWindowSize(_THIS, SDL_Window * window); extern void Cocoa_SetWindowMinimumSize(_THIS, SDL_Window * window); extern void Cocoa_SetWindowMaximumSize(_THIS, SDL_Window * window); +extern void Cocoa_GetWindowSizeInPixels(_THIS, SDL_Window * window, int *w, int *h); extern int Cocoa_SetWindowOpacity(_THIS, SDL_Window * window, float opacity); extern void Cocoa_ShowWindow(_THIS, SDL_Window * window); extern void Cocoa_HideWindow(_THIS, SDL_Window * window); diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index ad7d9e2af..bc7afce45 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -1941,6 +1941,24 @@ Cocoa_SetWindowMaximumSize(_THIS, SDL_Window * window) [windata.nswindow setContentMaxSize:maxSize]; }} +void +Cocoa_GetWindowSizeInPixels(_THIS, SDL_Window * window, int *w, int *h) +{ @autoreleasepool +{ + SDL_WindowData *windata = (__bridge SDL_WindowData *) window->driverdata; + NSView *contentView = windata.sdlContentView; + NSRect viewport = [contentView bounds]; + + if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) { + /* This gives us the correct viewport for a Retina-enabled view. */ + viewport = [contentView convertRectToBacking:viewport]; + } + + *w = viewport.size.width; + *h = viewport.size.height; +}} + + void Cocoa_ShowWindow(_THIS, SDL_Window * window) { @autoreleasepool diff --git a/src/video/emscripten/SDL_emscriptenopengles.c b/src/video/emscripten/SDL_emscriptenopengles.c index a450c8c89..10c6285cf 100644 --- a/src/video/emscripten/SDL_emscriptenopengles.c +++ b/src/video/emscripten/SDL_emscriptenopengles.c @@ -96,23 +96,6 @@ Emscripten_GLES_SwapWindow(_THIS, SDL_Window * window) return ret; } -void -Emscripten_GLES_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h) -{ - SDL_WindowData *data; - if (window->driverdata) { - data = (SDL_WindowData *) window->driverdata; - - if (w) { - *w = window->w * data->pixel_ratio; - } - - if (h) { - *h = window->h * data->pixel_ratio; - } - } -} - #endif /* SDL_VIDEO_DRIVER_EMSCRIPTEN && SDL_VIDEO_OPENGL_EGL */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/emscripten/SDL_emscriptenopengles.h b/src/video/emscripten/SDL_emscriptenopengles.h index 081b02fef..9d178f690 100644 --- a/src/video/emscripten/SDL_emscriptenopengles.h +++ b/src/video/emscripten/SDL_emscriptenopengles.h @@ -40,7 +40,6 @@ extern int Emscripten_GLES_LoadLibrary(_THIS, const char *path); extern SDL_GLContext Emscripten_GLES_CreateContext(_THIS, SDL_Window * window); extern int Emscripten_GLES_SwapWindow(_THIS, SDL_Window * window); extern int Emscripten_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); -extern void Emscripten_GLES_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h); #endif /* SDL_VIDEO_DRIVER_EMSCRIPTEN && SDL_VIDEO_OPENGL_EGL */ diff --git a/src/video/emscripten/SDL_emscriptenvideo.c b/src/video/emscripten/SDL_emscriptenvideo.c index 831af8e21..550031d3f 100644 --- a/src/video/emscripten/SDL_emscriptenvideo.c +++ b/src/video/emscripten/SDL_emscriptenvideo.c @@ -47,6 +47,7 @@ static int Emscripten_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * d static int Emscripten_CreateWindow(_THIS, SDL_Window * window); static void Emscripten_SetWindowSize(_THIS, SDL_Window * window); +static void Emscripten_GetWindowSizeInPixels(_THIS, SDL_Window * window, int *w, int *h); static void Emscripten_DestroyWindow(_THIS, SDL_Window * window); static void Emscripten_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen); static void Emscripten_PumpEvents(_THIS); @@ -101,6 +102,7 @@ Emscripten_CreateDevice(void) device->MinimizeWindow = Emscripten_MinimizeWindow; device->RestoreWindow = Emscripten_RestoreWindow; device->SetWindowMouseGrab = Emscripten_SetWindowMouseGrab;*/ + device->GetWindowSizeInPixels = Emscripten_GetWindowSizeInPixels; device->DestroyWindow = Emscripten_DestroyWindow; device->SetWindowFullscreen = Emscripten_SetWindowFullscreen; @@ -118,7 +120,6 @@ Emscripten_CreateDevice(void) device->GL_GetSwapInterval = Emscripten_GLES_GetSwapInterval; device->GL_SwapWindow = Emscripten_GLES_SwapWindow; device->GL_DeleteContext = Emscripten_GLES_DeleteContext; - device->GL_GetDrawableSize = Emscripten_GLES_GetDrawableSize; #endif device->free = Emscripten_DeleteDevice; @@ -307,6 +308,18 @@ static void Emscripten_SetWindowSize(_THIS, SDL_Window * window) } } + +static void +Emscripten_GetWindowSizeInPixels(_THIS, SDL_Window * window, int *w, int *h) +{ + SDL_WindowData *data; + if (window->driverdata) { + data = (SDL_WindowData *) window->driverdata; + *w = window->w * data->pixel_ratio; + *h = window->h * data->pixel_ratio; + } +} + static void Emscripten_DestroyWindow(_THIS, SDL_Window * window) { diff --git a/src/video/wayland/SDL_waylandopengles.c b/src/video/wayland/SDL_waylandopengles.c index 26626ee51..a0af3f5a4 100644 --- a/src/video/wayland/SDL_waylandopengles.c +++ b/src/video/wayland/SDL_waylandopengles.c @@ -197,23 +197,6 @@ Wayland_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) return ret; } -void -Wayland_GLES_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h) -{ - SDL_WindowData *data; - if (window->driverdata) { - data = (SDL_WindowData *) window->driverdata; - - if (w) { - *w = data->drawable_width; - } - - if (h) { - *h = data->drawable_height; - } - } -} - void Wayland_GLES_DeleteContext(_THIS, SDL_GLContext context) { diff --git a/src/video/wayland/SDL_waylandopengles.h b/src/video/wayland/SDL_waylandopengles.h index 1abd813df..b9500b9f1 100644 --- a/src/video/wayland/SDL_waylandopengles.h +++ b/src/video/wayland/SDL_waylandopengles.h @@ -42,7 +42,6 @@ extern int Wayland_GLES_SetSwapInterval(_THIS, int interval); extern int Wayland_GLES_GetSwapInterval(_THIS); extern int Wayland_GLES_SwapWindow(_THIS, SDL_Window * window); extern int Wayland_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); -extern void Wayland_GLES_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h); extern void Wayland_GLES_DeleteContext(_THIS, SDL_GLContext context); #endif /* SDL_waylandopengles_h_ */ diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c index 4642c0d8b..113ae6f6c 100644 --- a/src/video/wayland/SDL_waylandvideo.c +++ b/src/video/wayland/SDL_waylandvideo.c @@ -230,7 +230,6 @@ Wayland_CreateDevice(void) device->GL_SwapWindow = Wayland_GLES_SwapWindow; device->GL_GetSwapInterval = Wayland_GLES_GetSwapInterval; device->GL_SetSwapInterval = Wayland_GLES_SetSwapInterval; - device->GL_GetDrawableSize = Wayland_GLES_GetDrawableSize; device->GL_MakeCurrent = Wayland_GLES_MakeCurrent; device->GL_CreateContext = Wayland_GLES_CreateContext; device->GL_LoadLibrary = Wayland_GLES_LoadLibrary; @@ -257,6 +256,7 @@ Wayland_CreateDevice(void) device->SetWindowMaximumSize = Wayland_SetWindowMaximumSize; device->SetWindowModalFor = Wayland_SetWindowModalFor; device->SetWindowTitle = Wayland_SetWindowTitle; + device->GetWindowSizeInPixels = Wayland_GetWindowSizeInPixels; device->DestroyWindow = Wayland_DestroyWindow; device->SetWindowHitTest = Wayland_SetWindowHitTest; device->FlashWindow = Wayland_FlashWindow; @@ -274,7 +274,6 @@ Wayland_CreateDevice(void) device->Vulkan_UnloadLibrary = Wayland_Vulkan_UnloadLibrary; device->Vulkan_GetInstanceExtensions = Wayland_Vulkan_GetInstanceExtensions; device->Vulkan_CreateSurface = Wayland_Vulkan_CreateSurface; - device->Vulkan_GetDrawableSize = Wayland_Vulkan_GetDrawableSize; #endif device->free = Wayland_DeleteDevice; diff --git a/src/video/wayland/SDL_waylandvulkan.c b/src/video/wayland/SDL_waylandvulkan.c index 90b318fc8..f76efd094 100644 --- a/src/video/wayland/SDL_waylandvulkan.c +++ b/src/video/wayland/SDL_waylandvulkan.c @@ -132,22 +132,6 @@ SDL_bool Wayland_Vulkan_GetInstanceExtensions(_THIS, extensionsForWayland); } -void Wayland_Vulkan_GetDrawableSize(_THIS, SDL_Window *window, int *w, int *h) -{ - SDL_WindowData *data; - if (window->driverdata) { - data = (SDL_WindowData *) window->driverdata; - - if (w) { - *w = data->drawable_width; - } - - if (h) { - *h = data->drawable_height; - } - } -} - SDL_bool Wayland_Vulkan_CreateSurface(_THIS, SDL_Window *window, VkInstance instance, diff --git a/src/video/wayland/SDL_waylandvulkan.h b/src/video/wayland/SDL_waylandvulkan.h index c2b4c4f01..7ef4658bf 100644 --- a/src/video/wayland/SDL_waylandvulkan.h +++ b/src/video/wayland/SDL_waylandvulkan.h @@ -40,7 +40,6 @@ SDL_bool Wayland_Vulkan_GetInstanceExtensions(_THIS, SDL_Window *window, unsigned *count, const char **names); -void Wayland_Vulkan_GetDrawableSize(_THIS, SDL_Window *window, int *w, int *h); SDL_bool Wayland_Vulkan_CreateSurface(_THIS, SDL_Window *window, VkInstance instance, diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c index 8d5c70234..e203da8d3 100644 --- a/src/video/wayland/SDL_waylandwindow.c +++ b/src/video/wayland/SDL_waylandwindow.c @@ -2067,6 +2067,16 @@ void Wayland_SetWindowSize(_THIS, SDL_Window * window) } } +void Wayland_GetWindowSizeInPixels(_THIS, SDL_Window * window, int *w, int *h) +{ + SDL_WindowData *data; + if (window->driverdata) { + data = (SDL_WindowData *) window->driverdata; + *w = data->drawable_width; + *h = data->drawable_height; + } +} + void Wayland_SetWindowTitle(_THIS, SDL_Window * window) { SDL_WindowData *wind = window->driverdata; diff --git a/src/video/wayland/SDL_waylandwindow.h b/src/video/wayland/SDL_waylandwindow.h index 703ec53da..5413c95bd 100644 --- a/src/video/wayland/SDL_waylandwindow.h +++ b/src/video/wayland/SDL_waylandwindow.h @@ -127,6 +127,7 @@ extern int Wayland_CreateWindow(_THIS, SDL_Window *window); extern void Wayland_SetWindowSize(_THIS, SDL_Window * window); extern void Wayland_SetWindowMinimumSize(_THIS, SDL_Window * window); extern void Wayland_SetWindowMaximumSize(_THIS, SDL_Window * window); +extern void Wayland_GetWindowSizeInPixels(_THIS, SDL_Window * window, int *w, int *h); extern int Wayland_SetWindowModalFor(_THIS, SDL_Window * modal_window, SDL_Window * parent_window); extern void Wayland_SetWindowTitle(_THIS, SDL_Window * window); extern void Wayland_DestroyWindow(_THIS, SDL_Window *window); diff --git a/src/video/windows/SDL_windowsopengl.c b/src/video/windows/SDL_windowsopengl.c index 1f81917f3..c1df7f6b9 100644 --- a/src/video/windows/SDL_windowsopengl.c +++ b/src/video/windows/SDL_windowsopengl.c @@ -685,7 +685,6 @@ WIN_GL_CreateContext(_THIS, SDL_Window * window) _this->GL_UnloadLibrary = WIN_GLES_UnloadLibrary; _this->GL_CreateContext = WIN_GLES_CreateContext; _this->GL_MakeCurrent = WIN_GLES_MakeCurrent; - _this->GL_GetDrawableSize = WIN_GLES_GetDrawableSize; _this->GL_SetSwapInterval = WIN_GLES_SetSwapInterval; _this->GL_GetSwapInterval = WIN_GLES_GetSwapInterval; _this->GL_SwapWindow = WIN_GLES_SwapWindow; @@ -832,12 +831,6 @@ WIN_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) return 0; } -void -WIN_GL_GetDrawableSize(_THIS, SDL_Window *window, int *w, int *h) -{ - WIN_GetDrawableSize(window, w, h); -} - int WIN_GL_SetSwapInterval(_THIS, int interval) { diff --git a/src/video/windows/SDL_windowsopengl.h b/src/video/windows/SDL_windowsopengl.h index 36779aa4a..2dec0023a 100644 --- a/src/video/windows/SDL_windowsopengl.h +++ b/src/video/windows/SDL_windowsopengl.h @@ -71,7 +71,6 @@ extern int WIN_GL_SetupWindow(_THIS, SDL_Window * window); extern SDL_GLContext WIN_GL_CreateContext(_THIS, SDL_Window * window); extern int WIN_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); -extern void WIN_GL_GetDrawableSize(_THIS, SDL_Window *window, int *w, int *h); extern int WIN_GL_SetSwapInterval(_THIS, int interval); extern int WIN_GL_GetSwapInterval(_THIS); extern int WIN_GL_SwapWindow(_THIS, SDL_Window * window); diff --git a/src/video/windows/SDL_windowsopengles.c b/src/video/windows/SDL_windowsopengles.c index ff4c59418..1e2a4f620 100644 --- a/src/video/windows/SDL_windowsopengles.c +++ b/src/video/windows/SDL_windowsopengles.c @@ -41,7 +41,6 @@ WIN_GLES_LoadLibrary(_THIS, const char *path) { _this->GL_UnloadLibrary = WIN_GL_UnloadLibrary; _this->GL_CreateContext = WIN_GL_CreateContext; _this->GL_MakeCurrent = WIN_GL_MakeCurrent; - _this->GL_GetDrawableSize = WIN_GL_GetDrawableSize; _this->GL_SetSwapInterval = WIN_GL_SetSwapInterval; _this->GL_GetSwapInterval = WIN_GL_GetSwapInterval; _this->GL_SwapWindow = WIN_GL_SwapWindow; @@ -74,7 +73,6 @@ WIN_GLES_CreateContext(_THIS, SDL_Window * window) _this->GL_UnloadLibrary = WIN_GL_UnloadLibrary; _this->GL_CreateContext = WIN_GL_CreateContext; _this->GL_MakeCurrent = WIN_GL_MakeCurrent; - _this->GL_GetDrawableSize = WIN_GL_GetDrawableSize; _this->GL_SetSwapInterval = WIN_GL_SetSwapInterval; _this->GL_GetSwapInterval = WIN_GL_GetSwapInterval; _this->GL_SwapWindow = WIN_GL_SwapWindow; @@ -102,12 +100,6 @@ WIN_GLES_DeleteContext(_THIS, SDL_GLContext context) SDL_EGL_SwapWindow_impl(WIN) SDL_EGL_MakeCurrent_impl(WIN) -void -WIN_GLES_GetDrawableSize(_THIS, SDL_Window* window, int* w, int* h) -{ - WIN_GetDrawableSize(window, w, h); -} - int WIN_GLES_SetupWindow(_THIS, SDL_Window * window) { diff --git a/src/video/windows/SDL_windowsopengles.h b/src/video/windows/SDL_windowsopengles.h index e59c02ebd..b21c56f4f 100644 --- a/src/video/windows/SDL_windowsopengles.h +++ b/src/video/windows/SDL_windowsopengles.h @@ -39,7 +39,6 @@ extern int WIN_GLES_LoadLibrary(_THIS, const char *path); extern SDL_GLContext WIN_GLES_CreateContext(_THIS, SDL_Window * window); extern int WIN_GLES_SwapWindow(_THIS, SDL_Window * window); extern int WIN_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); -extern void WIN_GLES_GetDrawableSize(_THIS, SDL_Window* window, int* w, int* h); extern void WIN_GLES_DeleteContext(_THIS, SDL_GLContext context); extern int WIN_GLES_SetupWindow(_THIS, SDL_Window * window); diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c index 2b3f0a49e..0dc107bdf 100644 --- a/src/video/windows/SDL_windowsvideo.c +++ b/src/video/windows/SDL_windowsvideo.c @@ -180,6 +180,7 @@ WIN_CreateDevice(void) device->SetWindowPosition = WIN_SetWindowPosition; device->SetWindowSize = WIN_SetWindowSize; device->GetWindowBordersSize = WIN_GetWindowBordersSize; + device->GetWindowSizeInPixels = WIN_GetWindowSizeInPixels; device->SetWindowOpacity = WIN_SetWindowOpacity; device->ShowWindow = WIN_ShowWindow; device->HideWindow = WIN_HideWindow; @@ -221,7 +222,6 @@ WIN_CreateDevice(void) device->GL_UnloadLibrary = WIN_GL_UnloadLibrary; device->GL_CreateContext = WIN_GL_CreateContext; device->GL_MakeCurrent = WIN_GL_MakeCurrent; - device->GL_GetDrawableSize = WIN_GL_GetDrawableSize; device->GL_SetSwapInterval = WIN_GL_SetSwapInterval; device->GL_GetSwapInterval = WIN_GL_GetSwapInterval; device->GL_SwapWindow = WIN_GL_SwapWindow; @@ -233,7 +233,6 @@ WIN_CreateDevice(void) device->GL_UnloadLibrary = WIN_GLES_UnloadLibrary; device->GL_CreateContext = WIN_GLES_CreateContext; device->GL_MakeCurrent = WIN_GLES_MakeCurrent; - device->GL_GetDrawableSize = WIN_GLES_GetDrawableSize; device->GL_SetSwapInterval = WIN_GLES_SetSwapInterval; device->GL_GetSwapInterval = WIN_GLES_GetSwapInterval; device->GL_SwapWindow = WIN_GLES_SwapWindow; @@ -244,7 +243,6 @@ WIN_CreateDevice(void) device->Vulkan_UnloadLibrary = WIN_Vulkan_UnloadLibrary; device->Vulkan_GetInstanceExtensions = WIN_Vulkan_GetInstanceExtensions; device->Vulkan_CreateSurface = WIN_Vulkan_CreateSurface; - device->Vulkan_GetDrawableSize = WIN_GL_GetDrawableSize; #endif #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index eb536bbe4..991ef0ebe 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -773,6 +773,22 @@ WIN_GetWindowBordersSize(_THIS, SDL_Window * window, int *top, int *left, int *b #endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ } +void +WIN_GetWindowSizeInPixels(_THIS, SDL_Window * window, int *w, int *h) +{ + const SDL_WindowData *data = ((SDL_WindowData *)window->driverdata); + HWND hwnd = data->hwnd; + RECT rect; + + if (GetClientRect(hwnd, &rect)) { + *w = rect.right; + *h = rect.bottom; + } else { + *w = 0; + *h = 0; + } +} + void WIN_ShowWindow(_THIS, SDL_Window * window) { @@ -1402,25 +1418,6 @@ WIN_SetWindowOpacity(_THIS, SDL_Window * window, float opacity) #endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ } -/** - * Returns the drawable size in pixels (GetClientRect). - */ -void -WIN_GetDrawableSize(const SDL_Window *window, int *w, int *h) -{ - const SDL_WindowData *data = ((SDL_WindowData *)window->driverdata); - HWND hwnd = data->hwnd; - RECT rect; - - if (GetClientRect(hwnd, &rect)) { - *w = rect.right; - *h = rect.bottom; - } else { - *w = 0; - *h = 0; - } -} - /** * Convert a point in the client area from pixels to DPI-scaled points. * diff --git a/src/video/windows/SDL_windowswindow.h b/src/video/windows/SDL_windowswindow.h index c72707a98..6477530b9 100644 --- a/src/video/windows/SDL_windowswindow.h +++ b/src/video/windows/SDL_windowswindow.h @@ -81,6 +81,7 @@ extern void WIN_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon); extern void WIN_SetWindowPosition(_THIS, SDL_Window * window); extern void WIN_SetWindowSize(_THIS, SDL_Window * window); extern int WIN_GetWindowBordersSize(_THIS, SDL_Window * window, int *top, int *left, int *bottom, int *right); +extern void WIN_GetWindowSizeInPixels(_THIS, SDL_Window * window, int *width, int *height); extern int WIN_SetWindowOpacity(_THIS, SDL_Window * window, float opacity); extern void WIN_ShowWindow(_THIS, SDL_Window * window); extern void WIN_HideWindow(_THIS, SDL_Window * window); @@ -105,7 +106,6 @@ extern SDL_bool WIN_GetWindowWMInfo(_THIS, SDL_Window * window, extern void WIN_OnWindowEnter(_THIS, SDL_Window * window); extern void WIN_UpdateClipCursor(SDL_Window *window); extern int WIN_SetWindowHitTest(SDL_Window *window, SDL_bool enabled); -extern void WIN_GetDrawableSize(const SDL_Window *window, int *w, int *h); extern void WIN_ClientPointToSDL(const SDL_Window *window, int *w, int *h); extern void WIN_ClientPointFromSDL(const SDL_Window *window, int *w, int *h); extern void WIN_AcceptDragAndDrop(SDL_Window * window, SDL_bool accept);