summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ui/window.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/ui/window.c b/src/ui/window.c
index 419e6a0a..c0e8fdad 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -38,6 +38,7 @@ 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>
41#endif 42#endif
42#if defined (iPlatformApple) && !defined (iPlatformIOS) 43#if defined (iPlatformApple) && !defined (iPlatformIOS)
43# include "macos.h" 44# include "macos.h"
@@ -491,10 +492,26 @@ static void updateRootSize_Window_(iWindow *d) {
491} 492}
492 493
493static float pixelRatio_Window_(const iWindow *d) { 494static float pixelRatio_Window_(const iWindow *d) {
495#if defined (iPlatformMsys)
496 /* Query Direct2D for the desktop DPI (not aware of which monitor, though). */ {
497 float ratio = 1.0f;
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
494 int dx, x; 510 int dx, x;
495 SDL_GetRendererOutputSize(d->render, &dx, NULL); 511 SDL_GetRendererOutputSize(d->render, &dx, NULL);
496 SDL_GetWindowSize(d->win, &x, NULL); 512 SDL_GetWindowSize(d->win, &x, NULL);
497 return (float) dx / (float) x; 513 return (float) dx / (float) x;
514#endif
498} 515}
499 516
500static void drawBlank_Window_(iWindow *d) { 517static void drawBlank_Window_(iWindow *d) {
@@ -778,7 +795,13 @@ iInt2 rootSize_Window(const iWindow *d) {
778} 795}
779 796
780iInt2 coord_Window(const iWindow *d, int x, int y) { 797iInt2 coord_Window(const iWindow *d, int x, int y) {
798#if defined (iPlatformMsys)
799 /* On Windows, surface coordinates are in pixels. */
800 return init_I2(x, y);
801#else
802 /* Coordinates are in points. */
781 return mulf_I2(init_I2(x, y), d->pixelRatio); 803 return mulf_I2(init_I2(x, y), d->pixelRatio);
804#endif
782} 805}
783 806
784iInt2 mouseCoord_Window(const iWindow *d) { 807iInt2 mouseCoord_Window(const iWindow *d) {