Preemptively unset WAYLAND_DISPLAY

This commit is contained in:
Robbert van der Helm
2023-02-25 15:22:23 +01:00
parent 3bab9c3d6b
commit a35cd8da50
6 changed files with 41 additions and 0 deletions
+11
View File
@@ -6,6 +6,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic
Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Changed
- Yabridge now preemptively unsets the `WAYLAND_DISPLAY` environment variable
when launching Wine. Upstream Wine currently does not yet have a Wayland
driver, but future versions may. When that happens yabridge's X11 window
embedding would otherwise suddenly start breaking spectacularly. This change
makes sure that Wine will keep using X11 even if Wayland support becomes
available at some point.
## [5.0.4] - 2023-02-23
### Fixed
+7
View File
@@ -174,6 +174,13 @@ void ProcessEnvironment::insert(const std::string& key,
variables_.push_back(key + "=" + value);
}
size_t ProcessEnvironment::erase(const std::string& key) {
return std::erase_if(variables_, [&key](const std::string& variable) {
return variable.starts_with(key) && variable.size() > key.size() &&
variable[key.size()] == '=';
});
}
char* const* ProcessEnvironment::make_environ() const {
recreated_environ_.clear();
+8
View File
@@ -101,6 +101,14 @@ class ProcessEnvironment {
*/
void insert(const std::string& key, const std::string& value);
/**
* Remove an environment variable from the environment. Returns the number
* of elements erased (to stay consistent with the STL map interface). This
* can be higher than 1 if the map contains duplicate or overwritten
* environment variables.
*/
size_t erase(const std::string& key);
/**
* Create an environ-like object from the updated environment that can be
* passed to the `exec*e()` functions. These pointers will be invalidated
+8
View File
@@ -70,6 +70,14 @@ ProcessEnvironment PluginInfo::create_host_env() const {
},
wine_prefix_);
// As of writing upstream Wine does not yet have a Wayland driver, but one
// is in the process of being merged. If this ever becomes enabled by
// default on distros, Wine could suddenly start using using Wayland instead
// of X11. This would break yabridge's embedding and drag-and-drop handling.
// So we'll preemptively avoid this by unsetting the `WAYLAND_DISPLAY`
// environment variable.
env.erase("WAYLAND_DISPLAY");
return env;
}
+3
View File
@@ -79,6 +79,9 @@ struct PluginInfo {
* `WINEPREFIX` was already set then nothing will be changed. Otherwise
* we'll set `WINEPREFIX` to the detected Wine prefix, or it will be left
* unset if we could not detect a prefix.
*
* This also unsets `WAYLAND_DISPLAY` so if Wine has been compiled with
* Wayland support, it won't suddenly start using that over X11.
*/
ProcessEnvironment create_host_env() const;
+4
View File
@@ -356,6 +356,10 @@ pub fn verify_wine_setup(config: &mut Config) -> Result<()> {
let wine_binary = env::var("WINELOADER").unwrap_or_else(|_| String::from("wine"));
let wine_version_output = Command::new(&wine_binary)
.arg("--version")
// NOTE: This mimics the setup used in `PluginInfo::create_host_env()`. The X11 window
// embedding will break when future Wine versions start defaulting to a native Wayland
// driver, so we'll prevent that from happening.
.env_remove("WAYLAND_DISPLAY")
.output()
.with_context(|| {
format!(