-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
1,052 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
diff --git a/windows/colorbutton.cpp b/windows/colorbutton.cpp | ||
index c1ba6954e..7f63110ed 100644 | ||
--- a/windows/colorbutton.cpp | ||
+++ b/windows/colorbutton.cpp | ||
@@ -61,7 +61,9 @@ static BOOL onWM_NOTIFY(uiControl *c, HWND hwnd, NMHDR *nmhdr, LRESULT *lResult) | ||
ID2D1SolidColorBrush *brush; | ||
uiWindowsSizing sizing; | ||
int x, y; | ||
+ float dpi_x, dpi_y; | ||
HRESULT hr; | ||
+ D2D1_MATRIX_3X2_F dm; | ||
|
||
if (nmhdr->code != NM_CUSTOMDRAW) | ||
return FALSE; | ||
@@ -73,6 +75,13 @@ static BOOL onWM_NOTIFY(uiControl *c, HWND hwnd, NMHDR *nmhdr, LRESULT *lResult) | ||
rt = makeHDCRenderTarget(nm->hdc, &client); | ||
rt->BeginDraw(); | ||
|
||
+ // scale Direct2D's rendering to be in pixels instead of DIPs | ||
+ 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); | ||
+ | ||
uiWindowsGetSizing(b->hwnd, &sizing); | ||
x = 3; // should be enough | ||
y = 3; | ||
diff --git a/windows/init.cpp b/windows/init.cpp | ||
index c91929f9c..608346298 100644 | ||
--- a/windows/init.cpp | ||
+++ b/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) |
Oops, something went wrong.