Adding SDL_GetWindowSizeInPixels for window size in pixels (#6112)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754
diff --git a/include/SDL_video.h b/include/SDL_video.h
index 0b1065d..c2f3e2f 100644
--- a/include/SDL_video.h
+++ b/include/SDL_video.h
@@ -1047,6 +1047,27 @@ extern DECLSPEC int SDLCALL SDL_GetWindowBordersSize(SDL_Window * window,
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.
*
* \param window the window to change
diff --git a/src/dynapi/SDL2.exports b/src/dynapi/SDL2.exports
index cb05dcb..1faa894 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 97daae2..cabb7cd 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 5883ade..9b6919c 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 5344d0a..ae83009 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 cd3dab4..f7dfefe 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 3971019..5a7842a 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 4ea7705..d3f0d83 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 21c5162..881b06b 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -2367,6 +2367,28 @@ SDL_GetWindowBordersSize(SDL_Window * window, int *top, int *left, int *bottom,
}
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)
{
CHECK_WINDOW_MAGIC(window,);
@@ -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 ebdc921..c3f4527 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 9ac44ab..0f9b1c7 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 91319d5..8aab0c4 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 11a581b..b093e2e 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 ec25e1f..cd76b0c 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 ad7d9e2..bc7afce 100644
--- a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -1942,6 +1942,24 @@ Cocoa_SetWindowMaximumSize(_THIS, SDL_Window * window)
}}
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 a450c8c..10c6285 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 081b02f..9d178f6 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 831af8e..550031d 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 26626ee..a0af3f5 100644
--- a/src/video/wayland/SDL_waylandopengles.c
+++ b/src/video/wayland/SDL_waylandopengles.c
@@ -198,23 +198,6 @@ Wayland_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
}
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)
{
SDL_EGL_DeleteContext(_this, context);
diff --git a/src/video/wayland/SDL_waylandopengles.h b/src/video/wayland/SDL_waylandopengles.h
index 1abd813..b9500b9 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 4642c0d..113ae6f 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 90b318f..f76efd0 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 c2b4c4f..7ef4658 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 8d5c702..e203da8 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 703ec53..5413c95 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 1f81917..c1df7f6 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 36779aa..2dec002 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 ff4c594..1e2a4f6 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 e59c02e..b21c56f 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 2b3f0a4..0dc107b 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 eb536bb..991ef0e 100644
--- a/src/video/windows/SDL_windowswindow.c
+++ b/src/video/windows/SDL_windowswindow.c
@@ -774,6 +774,22 @@ WIN_GetWindowBordersSize(_THIS, SDL_Window * window, int *top, int *left, int *b
}
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)
{
DWORD style;
@@ -1403,25 +1419,6 @@ WIN_SetWindowOpacity(_THIS, SDL_Window * window, float opacity)
}
/**
- * 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.
*
* No-op if DPI scaling is not enabled.
diff --git a/src/video/windows/SDL_windowswindow.h b/src/video/windows/SDL_windowswindow.h
index c72707a..6477530 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);