Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=41275
A version of this patch has been in Wine Staging since March 2020.
-- v3: winemenubuilder: Skip desktop integration for certain associations.
From: Alex Henrie alexhenrie24@gmail.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=41275 --- loader/wine.inf.in | 6 +++ programs/winemenubuilder/winemenubuilder.c | 43 +++++++++++++++++++--- 2 files changed, 44 insertions(+), 5 deletions(-)
diff --git a/loader/wine.inf.in b/loader/wine.inf.in index 1f5138051c9..463d83c2b4b 100644 --- a/loader/wine.inf.in +++ b/loader/wine.inf.in @@ -321,6 +321,12 @@ HKCR,http\shell\open\command,,2,"""%11%\winebrowser.exe"" ""%1""" HKCR,https\shell\open\command,,2,"""%11%\winebrowser.exe"" ""%1""" HKCR,mailto\shell\open\command,,2,"""%11%\winebrowser.exe"" ""%1"""
+HKCU,Software\Wine\FileOpenNoIntegration,"ieframe",,"ieframe.dll" +HKCU,Software\Wine\FileOpenNoIntegration,"iexplore",,"iexplore.exe" +HKCU,Software\Wine\FileOpenNoIntegration,"notepad",,"notepad.exe" +HKCU,Software\Wine\FileOpenNoIntegration,"winebrowser",,"winebrowser.exe" +HKCU,Software\Wine\FileOpenNoIntegration,"wordpad",,"wordpad.exe" + [ContentIndex] HKLM,System\CurrentControlSet\Control\ContentIndex\Language\Neutral,"WBreakerClass",,"{369647e0-17b0-11ce-9950-00aa004bbb1f}" HKLM,System\CurrentControlSet\Control\ContentIndex\Language\Neutral,"StemmerClass",,"" diff --git a/programs/winemenubuilder/winemenubuilder.c b/programs/winemenubuilder/winemenubuilder.c index 1579ca8dafa..ef280954b67 100644 --- a/programs/winemenubuilder/winemenubuilder.c +++ b/programs/winemenubuilder/winemenubuilder.c @@ -1974,6 +1974,35 @@ static BOOL is_extension_banned(LPCWSTR extension) return FALSE; }
+static BOOL on_exclude_list(const WCHAR *command) +{ + static const WCHAR FileOpenNoIntegrationW[] = L"Software\Wine\FileOpenNoIntegration"; + HKEY key; + WCHAR program_name[MAX_PATH], *pattern_to_exclude; + DWORD len = ARRAY_SIZE(program_name); + DWORD i = 0; + + if (RegOpenKeyExW(HKEY_CURRENT_USER, FileOpenNoIntegrationW, 0, KEY_QUERY_VALUE, &key) != ERROR_SUCCESS) + return FALSE; + + while (RegEnumValueW(key, i, program_name, &len, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) + { + pattern_to_exclude = reg_get_valW(HKEY_CURRENT_USER, FileOpenNoIntegrationW, program_name); + if (wcsstr(command, pattern_to_exclude)) + { + heap_free(pattern_to_exclude); + RegCloseKey(key); + return TRUE; + } + heap_free(pattern_to_exclude); + len = ARRAY_SIZE(program_name); + i++; + } + + RegCloseKey(key); + return FALSE; +} + static WCHAR *get_special_mime_type(LPCWSTR extension) { if (!wcsicmp(extension, L".lnk")) @@ -2054,6 +2083,15 @@ static BOOL generate_associations(const WCHAR *packages_dir, const WCHAR *applic WCHAR *mimeProgId = NULL; struct rb_string_entry *entry;
+ commandW = assoc_query(ASSOCSTR_COMMAND, extensionW, L"open"); + if (commandW == NULL) + /* no command => no application is associated */ + goto end; + + if (on_exclude_list(commandW)) + /* command is on the exclude list => desktop integration is not desirable */ + goto end; + wcslwr(extensionW); friendlyDocNameW = assoc_query(ASSOCSTR_FRIENDLYDOCNAME, extensionW, NULL);
@@ -2093,11 +2131,6 @@ static BOOL generate_associations(const WCHAR *packages_dir, const WCHAR *applic hasChanged = TRUE; }
- commandW = assoc_query(ASSOCSTR_COMMAND, extensionW, L"open"); - if (commandW == NULL) - /* no command => no application is associated */ - goto end; - executableW = assoc_query(ASSOCSTR_EXECUTABLE, extensionW, L"open"); if (executableW) openWithIcon = compute_native_identifier(0, executableW, NULL);
Alexandre Julliard (@julliard) commented about loader/wine.inf.in:
HKCR,https\shell\open\command,,2,"""%11%\winebrowser.exe"" ""%1""" HKCR,mailto\shell\open\command,,2,"""%11%\winebrowser.exe"" ""%1"""
+HKCU,Software\Wine\FileOpenNoIntegration,"ieframe",,"ieframe.dll" +HKCU,Software\Wine\FileOpenNoIntegration,"iexplore",,"iexplore.exe" +HKCU,Software\Wine\FileOpenNoIntegration,"notepad",,"notepad.exe" +HKCU,Software\Wine\FileOpenNoIntegration,"winebrowser",,"winebrowser.exe" +HKCU,Software\Wine\FileOpenNoIntegration,"wordpad",,"wordpad.exe"
Wine configuration keys should never be created from wine.inf. These keys are meant to be set by users to change behavior from the defaults, but the default behavior shouldn't require any configuration. Moreover, it must be possible to get back to the default by deleting the config keys.