core: cleanup environment on exit (#5941)

This commit is contained in:
Ikalco 2024-05-08 12:11:08 -05:00 committed by GitHub
parent d1ad490cda
commit 6a988d9276
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 30 additions and 1 deletions

View file

@ -341,6 +341,28 @@ void CCompositor::removeAllSignals() {
removeWLSignal(&Events::listen_sessionActive); removeWLSignal(&Events::listen_sessionActive);
} }
void CCompositor::cleanEnvironment() {
// in compositor constructor
unsetenv("WAYLAND_DISPLAY");
// in startCompositor
unsetenv("HYPRLAND_INSTANCE_SIGNATURE");
// in main
unsetenv("HYPRLAND_CMD");
unsetenv("XDG_BACKEND");
unsetenv("XDG_CURRENT_DESKTOP");
if (m_sWLRSession) {
const auto CMD =
#ifdef USES_SYSTEMD
"systemctl --user unset-environment DISPLAY WAYLAND_DISPLAY HYPRLAND_INSTANCE_SIGNATURE XDG_CURRENT_DESKTOP QT_QPA_PLATFORMTHEME && hash "
"dbus-update-activation-environment 2>/dev/null && "
#endif
"dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP HYPRLAND_INSTANCE_SIGNATURE QT_QPA_PLATFORMTHEME";
g_pKeybindManager->spawn(CMD);
}
}
void CCompositor::cleanup() { void CCompositor::cleanup() {
if (!m_sWLDisplay || m_bIsShuttingDown) if (!m_sWLDisplay || m_bIsShuttingDown)
return; return;
@ -358,6 +380,8 @@ void CCompositor::cleanup() {
Systemd::SdNotify(0, "STOPPING=1"); Systemd::SdNotify(0, "STOPPING=1");
#endif #endif
cleanEnvironment();
// unload all remaining plugins while the compositor is // unload all remaining plugins while the compositor is
// still in a normal working state. // still in a normal working state.
g_pPluginSystem->unloadAllPlugins(); g_pPluginSystem->unloadAllPlugins();

View file

@ -191,6 +191,7 @@ class CCompositor {
private: private:
void initAllSignals(); void initAllSignals();
void removeAllSignals(); void removeAllSignals();
void cleanEnvironment();
void setRandomSplash(); void setRandomSplash();
void initManagers(eManagersInitStage stage); void initManagers(eManagersInitStage stage);
void prepareFallbackOutput(); void prepareFallbackOutput();

View file

@ -27,7 +27,11 @@ CHyprXWaylandManager::CHyprXWaylandManager() {
#endif #endif
} }
CHyprXWaylandManager::~CHyprXWaylandManager() {} CHyprXWaylandManager::~CHyprXWaylandManager() {
#ifndef NO_XWAYLAND
unsetenv("DISPLAY");
#endif
}
wlr_surface* CHyprXWaylandManager::getWindowSurface(PHLWINDOW pWindow) { wlr_surface* CHyprXWaylandManager::getWindowSurface(PHLWINDOW pWindow) {
if (pWindow->m_bIsX11) if (pWindow->m_bIsX11)