Skip to content

Commit

Permalink
Add remaining diffs
Browse files Browse the repository at this point in the history
  • Loading branch information
petabyt committed Nov 28, 2024
1 parent 9eb24a8 commit 009ae83
Show file tree
Hide file tree
Showing 4 changed files with 1,052 additions and 0 deletions.
41 changes: 41 additions & 0 deletions extras/204.diff
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)
Loading

0 comments on commit 009ae83

Please sign in to comment.