Module: wine
Branch: master
Commit: feda122578890c28d3b02bed1c4d9ec91098f05b
URL: https://gitlab.winehq.org/wine/wine/-/commit/feda122578890c28d3b02bed1c4d9e…
Author: Bernhard Übelacker <bernhardu(a)mailbox.org>
Date: Mon Nov 20 14:35:38 2023 +0100
notepad: Use GetDesktopWindow() when main window is not yet created.
Commit 100504d2f5 introduced using GetDpiForWindow().
Unfortunately NOTEPAD_LoadSettingFromRegistry is executed when
the main window is not yet created, resulting in
having Globals.lfFont.lfHeight=0.
This is later stored in the registry in iPointSize=0.
In a fresh wine prefix there are not yet registry values created,
therefore the first run of notepad does not show this problem,
and iPointSize is saved with a sane value to the registry.
Having Globals.lfFont.lfHeight=0 manifests for example
in cups PDF prints being a single empty page.
The check of point_size for having a non-zero value should also fix
wine prefixes which have already a stored registry value of iPointSize=0.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55852
---
programs/notepad/main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/programs/notepad/main.c b/programs/notepad/main.c
index 7d961086821..69ab5215304 100644
--- a/programs/notepad/main.c
+++ b/programs/notepad/main.c
@@ -280,9 +280,9 @@ static VOID NOTEPAD_LoadSettingFromRegistry(void)
size = sizeof(DWORD);
if(RegQueryValueExW(hkey, value_iPointSize, 0, &type, (LPBYTE)&point_size, &size) == ERROR_SUCCESS)
- if(type == REG_DWORD)
+ if(type == REG_DWORD && point_size)
/* The value is stored as 10 * twips */
- Globals.lfFont.lfHeight = -MulDiv(abs(point_size), GetDpiForWindow(Globals.hMainWnd), 720);
+ Globals.lfFont.lfHeight = -MulDiv(abs(point_size), GetDpiForWindow(GetDesktopWindow()), 720);
size = sizeof(Globals.lfFont.lfFaceName);
if(RegQueryValueExW(hkey, value_lfFaceName, 0, &type, (LPBYTE)&data_helper, &size) == ERROR_SUCCESS)