This solution was introduced in !7901, but it still open without any review. More info in the original MR. Also I should note that GTK uses XDG_DATA_DIRS and XDG_HOME_DIRS environment variables to locate icon themes and MIME information.
This solution fixes: https://bugs.winehq.org/show_bug.cgi?id=49987 and https://bugs.winehq.org/show_bug.cgi?id=58023
-- v4: ntdll: Treat XDG_DATA_DIRS as special env variable
From: Louis Lenders xerox.xerox2000x@gmail.com
--- dlls/ntdll/unix/env.c | 5 ++++- dlls/ntdll/unix/loader.c | 8 ++++++++ dlls/ntdll/unix/unix_private.h | 1 + programs/winemenubuilder/winemenubuilder.c | 5 +---- 4 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c index 9edb69dd519..a132560ef2e 100644 --- a/dlls/ntdll/unix/env.c +++ b/dlls/ntdll/unix/env.c @@ -345,6 +345,7 @@ static BOOL is_special_env_var( const char *var ) STARTS_WITH( var, "TMP=" ) || STARTS_WITH( var, "QT_" ) || STARTS_WITH( var, "VK_" ) || + STARTS_WITH( var, "XDG_DATA_DIRS" ) || STARTS_WITH( var, "XDG_SESSION_TYPE=" )); }
@@ -363,7 +364,8 @@ static BOOL is_dynamic_env_var( const char *var ) STARTS_WITH( var, "WINEUSERNAME=" ) || STARTS_WITH( var, "WINEPRELOADRESERVE=" ) || STARTS_WITH( var, "WINELOADERNOEXEC=" ) || - STARTS_WITH( var, "WINESERVERSOCKET=" )); + STARTS_WITH( var, "WINESERVERSOCKET=" ) || + STARTS_WITH( var, "WINEXDG_DATA_DIRS=" )); }
/****************************************************************** @@ -1112,6 +1114,7 @@ static void add_dynamic_environment( WCHAR **env, SIZE_T *pos, SIZE_T *size ) } else append_envW( env, pos, size, "WINEUNIXCP", NULL ); append_envA( env, pos, size, "WINEUSERLOCALE", user_locale ); + append_envA( env, pos, size, "WINEXDG_DATA_DIRS", xdg_data_dirs ); append_envA( env, pos, size, "SystemDrive", "C:" ); append_envA( env, pos, size, "SystemRoot", "C:\windows" ); } diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index 4e40e09ecf2..1b5927f4a8c 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -165,6 +165,7 @@ const char *wineloader = NULL; const char **dll_paths = NULL; const char **system_dll_paths = NULL; const char *user_name = NULL; +const char *xdg_data_dirs = NULL; SECTION_IMAGE_INFORMATION main_image_info = { NULL };
/* die on a fatal error; use only during initialization */ @@ -443,6 +444,12 @@ static void set_config_dir(void) } }
+static void set_xdg_dirs(void) +{ + xdg_data_dirs = getenv( "XDG_DATA_DIRS" ); + if (!xdg_data_dirs) xdg_data_dirs = strdup( "/usr/local/share/:/usr/share/" ); +} + static void init_paths(void) { Dl_info info; @@ -467,6 +474,7 @@ static void init_paths(void) set_system_dll_path(); set_home_dir(); set_config_dir(); + set_xdg_dirs(); }
diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index a735e54d9ff..ac6d87ea8e1 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -181,6 +181,7 @@ extern const char *build_dir; extern const char *config_dir; extern const char *wineloader; extern const char *user_name; +extern const char *xdg_data_dirs; extern const char **dll_paths; extern const char **system_dll_paths; extern pthread_key_t teb_key; diff --git a/programs/winemenubuilder/winemenubuilder.c b/programs/winemenubuilder/winemenubuilder.c index e881408ef9f..05c426bcffd 100644 --- a/programs/winemenubuilder/winemenubuilder.c +++ b/programs/winemenubuilder/winemenubuilder.c @@ -1706,10 +1706,7 @@ static BOOL build_native_mime_types(struct list *mime_types) WCHAR *dirs, *dir, *dos_name, *ctx, *p; BOOL ret;
- if (_wgetenv( L"XDG_DATA_DIRS" )) - dirs = xwcsdup( _wgetenv( L"XDG_DATA_DIRS" )); - else - dirs = xwcsdup( L"/usr/local/share/:/usr/share/" ); + dirs = xwcsdup( _wgetenv( L"WINEXDG_DATA_DIRS" ));
ret = add_mimes(xdg_data_dir, mime_types); if (ret)
This merge request was closed by Alexandre Julliard.
Duplicate of !7901.
On Mon Jul 7 18:06:31 2025 +0000, Alexandre Julliard wrote:
Duplicate of !7901.
Sorry, I've created this merge request to pay reviewers attention to !7901. Actually, I don't think Louis Lenders will continue to improve his solution (if it's needed), due to his long inactivity. So, if its possible please review his solution, and I'll try to improve it.