Under the HKCU\Software\Wine\X11 Driver global or application-specific HKCU\Software\Wine\AppDefaults\app.exe\X11 Driver registry keys.
This option can be used to restore the old behavior with DPI awareness forced on every application, which some of them handled well enough even if not DPI aware otherwise.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57175
-- v3: win32u: Read AppCompatFlags DPI awareness overrides from the registry.
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/sysparams.c | 46 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-)
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 60113f2608e..00ba7122f01 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -4945,9 +4945,43 @@ static DWORD get_config_key( HKEY defkey, HKEY appkey, const char *name, return ERROR_FILE_NOT_FOUND; }
+static char *get_app_compat_flags( const WCHAR *appname ) +{ + char buffer[4096]; + KEY_VALUE_PARTIAL_INFORMATION *value = (void *)buffer; + WCHAR *value_str = NULL; + char *compat_flags; + HKEY hkey; + UINT i; + + if ((hkey = reg_open_hkcu_key( "Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" ))) + { + if ((query_reg_value( hkey, appname, value, sizeof(buffer) ) && value->Type == REG_SZ) || + /* Wine extension: set default application flag using the default key value */ + (query_reg_value( hkey, NULL, value, sizeof(buffer) ) && value->Type == REG_SZ)) + value_str = (WCHAR *)value->Data; + NtClose( hkey ); + } + + if (!value_str && (hkey = reg_open_ascii_key( NULL, "Registry\Machine\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" ))) + { + if ((query_reg_value( hkey, appname, value, sizeof(buffer) ) && value->Type == REG_SZ) || + /* Wine extension: set default application flag using the default key value */ + (query_reg_value( hkey, NULL, value, sizeof(buffer) ) && value->Type == REG_SZ)) + value_str = (WCHAR *)value->Data; + NtClose( hkey ); + } + + if (!value_str) return NULL; + if (!(compat_flags = calloc( 1, value->DataLength / sizeof(WCHAR) + 1 ))) return NULL; + for (i = 0; compat_flags && i < value->DataLength / sizeof(WCHAR); i++) compat_flags[i] = value_str[i]; + return compat_flags; +} + void sysparams_init(void) { WCHAR buffer[MAX_PATH+16], *p, *appname; + char *app_compat_flags = NULL; DWORD i, dispos, dpi_scaling; WCHAR layout[KL_NAMELENGTH]; pthread_mutexattr_t attr; @@ -5027,11 +5061,14 @@ void sysparams_init(void) for (i = 0; appname[i]; i++) buffer[i] = RtlDowncaseUnicodeChar( appname[i] ); buffer[i] = 0; appname = buffer; - memcpy( appname + i, x11driverW, sizeof(x11driverW) ); + + app_compat_flags = get_app_compat_flags( appname ); + if (app_compat_flags) TRACE( "Found %s AppCompatFlags %s\n", debugstr_w(appname), debugstr_a(app_compat_flags) );
/* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\X11 Driver */ if ((tmpkey = reg_open_hkcu_key( "Software\Wine\AppDefaults" ))) { + memcpy( appname + i, x11driverW, sizeof(x11driverW) ); appkey = reg_open_key( tmpkey, appname, lstrlenW( appname ) * sizeof(WCHAR) ); NtClose( tmpkey ); } @@ -5048,6 +5085,13 @@ void sysparams_init(void) decorated_mode = IS_OPTION_TRUE( buffer[0] );
#undef IS_OPTION_TRUE + + if (app_compat_flags) + { + if (strstr( app_compat_flags, "HIGHDPIAWARE" )) NtUserSetProcessDpiAwarenessContext( NTUSER_DPI_SYSTEM_AWARE, 0 ); + if (strstr( app_compat_flags, "DPIUNAWARE" )) NtUserSetProcessDpiAwarenessContext( NTUSER_DPI_UNAWARE, 0 ); + } + free( app_compat_flags ); }
static BOOL update_desktop_wallpaper(void)
v3: Rebased to skip the broken tests.