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
+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;