summaryrefslogtreecommitdiff
path: root/src/win32.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-09-30 15:12:21 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-09-30 15:12:21 +0300
commit4041ff10f50d4b6dc5c14b18f180b2738cbbadd0 (patch)
tree43eb1d7a768983857cb3c6473e127da2979c0a87 /src/win32.c
parentd27c0261cbbf77396e70c46c5fdb3745a85e48c0 (diff)
Windows: Initial/minimum window size vs. UI scale factor
Diffstat (limited to 'src/win32.c')
-rw-r--r--src/win32.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/win32.c b/src/win32.c
index 36043b53..5eb2a0d5 100644
--- a/src/win32.c
+++ b/src/win32.c
@@ -25,11 +25,28 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
25 25
26#define WIN32_LEAN_AND_MEAN 26#define WIN32_LEAN_AND_MEAN
27#include <Windows.h> 27#include <Windows.h>
28#include <d2d1.h>
28 29
29void setDPIAware_Win32(void) { 30void setDPIAware_Win32(void) {
30 SetProcessDPIAware(); 31 SetProcessDPIAware();
31} 32}
32 33
34float desktopDPI_Win32(void) {
35 /* Query Direct2D for the desktop DPI (not aware of which monitor, though). */
36 float ratio = 1.0f;
37 ID2D1Factory *d2dFactory = NULL;
38 HRESULT hr = D2D1CreateFactory(
39 D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory, NULL, (void **) &d2dFactory);
40 if (SUCCEEDED(hr)) {
41 FLOAT dpiX = 96;
42 FLOAT dpiY = 96;
43 ID2D1Factory_GetDesktopDpi(d2dFactory, &dpiX, &dpiY);
44 ratio = (float) (dpiX / 96.0);
45 ID2D1Factory_Release(d2dFactory);
46 }
47 return ratio;
48}
49
33void useExecutableIconResource_SDLWindow(SDL_Window *win) { 50void useExecutableIconResource_SDLWindow(SDL_Window *win) {
34 HINSTANCE handle = GetModuleHandle(NULL); 51 HINSTANCE handle = GetModuleHandle(NULL);
35 HICON icon = LoadIcon(handle, "IDI_ICON1"); 52 HICON icon = LoadIcon(handle, "IDI_ICON1");