diff options
Diffstat (limited to 'src/libui_sdl/libui/windows')
-rw-r--r-- | src/libui_sdl/libui/windows/areadraw.cpp | 10 | ||||
-rw-r--r-- | src/libui_sdl/libui/windows/areaevents.cpp | 2 | ||||
-rw-r--r-- | src/libui_sdl/libui/windows/areautil.cpp | 1 | ||||
-rw-r--r-- | src/libui_sdl/libui/windows/draw.cpp | 7 | ||||
-rw-r--r-- | src/libui_sdl/libui/windows/init.cpp | 2 |
5 files changed, 20 insertions, 2 deletions
diff --git a/src/libui_sdl/libui/windows/areadraw.cpp b/src/libui_sdl/libui/windows/areadraw.cpp index 0bdf58a..a9ad477 100644 --- a/src/libui_sdl/libui/windows/areadraw.cpp +++ b/src/libui_sdl/libui/windows/areadraw.cpp @@ -26,6 +26,16 @@ static HRESULT doPaint(uiArea *a, ID2D1RenderTarget *rt, RECT *clip) rt->BeginDraw(); + { + float dpi_x, dpi_y; + D2D1_MATRIX_3X2_F dm; + rt->GetDpi(&dpi_x, &dpi_y); + ZeroMemory(&dm, sizeof (D2D1_MATRIX_3X2_F)); + dm._11 = 96.f/dpi_x; + dm._22 = 96.f/dpi_y; + rt->SetTransform(&dm); + } + if (a->scrolling) { ZeroMemory(&scrollTransform, sizeof (D2D1_MATRIX_3X2_F)); scrollTransform._11 = 1; diff --git a/src/libui_sdl/libui/windows/areaevents.cpp b/src/libui_sdl/libui/windows/areaevents.cpp index 842f2d7..d65b11d 100644 --- a/src/libui_sdl/libui/windows/areaevents.cpp +++ b/src/libui_sdl/libui/windows/areaevents.cpp @@ -101,7 +101,7 @@ static void areaMouseEvent(uiArea *a, int down, int up, WPARAM wParam, LPARAM l xpix = (double) GET_X_LPARAM(lParam); ypix = (double) GET_Y_LPARAM(lParam); // these are in pixels; we need points - pixelsToDIP(a, &xpix, &ypix); + //pixelsToDIP(a, &xpix, &ypix); me.X = xpix; me.Y = ypix; if (a->scrolling) { diff --git a/src/libui_sdl/libui/windows/areautil.cpp b/src/libui_sdl/libui/windows/areautil.cpp index 9dc72fb..212ea42 100644 --- a/src/libui_sdl/libui/windows/areautil.cpp +++ b/src/libui_sdl/libui/windows/areautil.cpp @@ -14,6 +14,7 @@ void loadAreaSize(uiArea *a, ID2D1RenderTarget *rt, double *width, double *heigh size = realGetSize(rt); *width = size.width; *height = size.height; + dipToPixels(a, width, height); } } diff --git a/src/libui_sdl/libui/windows/draw.cpp b/src/libui_sdl/libui/windows/draw.cpp index 65f2535..11a777d 100644 --- a/src/libui_sdl/libui/windows/draw.cpp +++ b/src/libui_sdl/libui/windows/draw.cpp @@ -560,6 +560,13 @@ void uiDrawBitmapDraw(uiDrawContext* c, uiDrawBitmap* bmp, uiRect* srcrect, uiRe D2D_RECT_F _srcrect = D2D1::RectF(srcrect->X, srcrect->Y, srcrect->X+srcrect->Width, srcrect->Y+srcrect->Height); D2D_RECT_F _dstrect = D2D1::RectF(dstrect->X, dstrect->Y, dstrect->X+dstrect->Width, dstrect->Y+dstrect->Height); + float dpix, dpiy; + c->rt->GetDpi(&dpix, &dpiy); + _srcrect.left = (_srcrect.left * 96.0f) / dpix; + _srcrect.top = (_srcrect.top * 96.0f) / dpiy; + _srcrect.right = (_srcrect.right * 96.0f) / dpix; + _srcrect.bottom = (_srcrect.bottom * 96.0f) / dpiy; + c->rt->DrawBitmap(bmp->bmp, &_dstrect, 1.0f, filter ? D2D1_BITMAP_INTERPOLATION_MODE_LINEAR : D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, &_srcrect); } diff --git a/src/libui_sdl/libui/windows/init.cpp b/src/libui_sdl/libui/windows/init.cpp index 2287416..5b4fe1d 100644 --- a/src/libui_sdl/libui/windows/init.cpp +++ b/src/libui_sdl/libui/windows/init.cpp @@ -70,7 +70,7 @@ const char *uiInit(uiInitOptions *o) if ((si.dwFlags & STARTF_USESHOWWINDOW) != 0) nCmdShow = si.wShowWindow; - // LONGTERM set DPI awareness + SetProcessDPIAware(); hDefaultIcon = LoadIconW(NULL, IDI_APPLICATION); if (hDefaultIcon == NULL) |