diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-09-30 15:12:21 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-09-30 15:12:21 +0300 |
commit | 4041ff10f50d4b6dc5c14b18f180b2738cbbadd0 (patch) | |
tree | 43eb1d7a768983857cb3c6473e127da2979c0a87 /src/ui/window.c | |
parent | d27c0261cbbf77396e70c46c5fdb3745a85e48c0 (diff) |
Windows: Initial/minimum window size vs. UI scale factor
Diffstat (limited to 'src/ui/window.c')
-rw-r--r-- | src/ui/window.c | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/src/ui/window.c b/src/ui/window.c index c0e8fdad..7d368f42 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -38,7 +38,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
38 | #include "../gmutil.h" | 38 | #include "../gmutil.h" |
39 | #if defined (iPlatformMsys) | 39 | #if defined (iPlatformMsys) |
40 | # include "../win32.h" | 40 | # include "../win32.h" |
41 | # include <d2d1.h> | ||
42 | #endif | 41 | #endif |
43 | #if defined (iPlatformApple) && !defined (iPlatformIOS) | 42 | #if defined (iPlatformApple) && !defined (iPlatformIOS) |
44 | # include "macos.h" | 43 | # include "macos.h" |
@@ -493,19 +492,8 @@ static void updateRootSize_Window_(iWindow *d) { | |||
493 | 492 | ||
494 | static float pixelRatio_Window_(const iWindow *d) { | 493 | static float pixelRatio_Window_(const iWindow *d) { |
495 | #if defined (iPlatformMsys) | 494 | #if defined (iPlatformMsys) |
496 | /* Query Direct2D for the desktop DPI (not aware of which monitor, though). */ { | 495 | iUnused(d); |
497 | float ratio = 1.0f; | 496 | return desktopDPI_Win32(); |
498 | ID2D1Factory *d2dFactory = NULL; | ||
499 | HRESULT hr = D2D1CreateFactory( | ||
500 | D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory, NULL, (void **) &d2dFactory); | ||
501 | if (SUCCEEDED(hr)) { | ||
502 | FLOAT dpiX = 96; | ||
503 | FLOAT dpiY = 96; | ||
504 | ID2D1Factory_GetDesktopDpi(d2dFactory, &dpiX, &dpiY); | ||
505 | ratio = (float) (dpiX / 96.0); | ||
506 | ID2D1Factory_Release(d2dFactory); | ||
507 | } | ||
508 | } | ||
509 | #else | 497 | #else |
510 | int dx, x; | 498 | int dx, x; |
511 | SDL_GetRendererOutputSize(d->render, &dx, NULL); | 499 | SDL_GetRendererOutputSize(d->render, &dx, NULL); |
@@ -556,7 +544,8 @@ void init_Window(iWindow *d, iRect rect) { | |||
556 | if (left_Rect(rect) >= 0 || top_Rect(rect) >= 0) { | 544 | if (left_Rect(rect) >= 0 || top_Rect(rect) >= 0) { |
557 | SDL_SetWindowPosition(d->win, left_Rect(rect), top_Rect(rect)); | 545 | SDL_SetWindowPosition(d->win, left_Rect(rect), top_Rect(rect)); |
558 | } | 546 | } |
559 | SDL_SetWindowMinimumSize(d->win, 400, 250); | 547 | const iInt2 minSize = init_I2(400, 250); |
548 | SDL_SetWindowMinimumSize(d->win, minSize.x, minSize.y); | ||
560 | SDL_SetWindowTitle(d->win, "Lagrange"); | 549 | SDL_SetWindowTitle(d->win, "Lagrange"); |
561 | /* Some info. */ { | 550 | /* Some info. */ { |
562 | SDL_RendererInfo info; | 551 | SDL_RendererInfo info; |
@@ -578,6 +567,7 @@ void init_Window(iWindow *d, iRect rect) { | |||
578 | d->pixelRatio = pixelRatio_Window_(d); | 567 | d->pixelRatio = pixelRatio_Window_(d); |
579 | setPixelRatio_Metrics(d->pixelRatio * d->uiScale); | 568 | setPixelRatio_Metrics(d->pixelRatio * d->uiScale); |
580 | #if defined (iPlatformMsys) | 569 | #if defined (iPlatformMsys) |
570 | SDL_SetWindowMinimumSize(d->win, minSize.x * d->pixelRatio, minSize.y * d->pixelRatio); | ||
581 | useExecutableIconResource_SDLWindow(d->win); | 571 | useExecutableIconResource_SDLWindow(d->win); |
582 | #endif | 572 | #endif |
583 | #if defined (iPlatformLinux) | 573 | #if defined (iPlatformLinux) |