summaryrefslogtreecommitdiff
path: root/src/Compositor.cpp
diff options
context:
space:
mode:
authorIkalco <73481042+ikalco@users.noreply.github.com>2024-07-24 12:07:36 -0500
committerGitHub <noreply@github.com>2024-07-24 19:07:36 +0200
commit3e543d2ce8ba64abb4d226dbb88c4513474501cf (patch)
treed340935c65520e293a73623c148219993e38779b /src/Compositor.cpp
parent735e3c6c56d22059ee6340c0327e4b5a9154f013 (diff)
core: Properly shutdown wl display (#7018)
* correctly destroy wayland globals * properly shutdown and cleanup hyprland * appease the nitpick gods and some comments
Diffstat (limited to 'src/Compositor.cpp')
-rw-r--r--src/Compositor.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index 7caaa98a..36f483fd 100644
--- a/src/Compositor.cpp
+++ b/src/Compositor.cpp
@@ -43,7 +43,7 @@ int handleCritSignal(int signo, void* data) {
Debug::log(LOG, "Hyprland received signal {}", signo);
if (signo == SIGTERM || signo == SIGINT || signo == SIGKILL)
- g_pCompositor->cleanup();
+ g_pCompositor->stopCompositor();
return 0;
}
@@ -193,7 +193,8 @@ CCompositor::CCompositor() {
}
CCompositor::~CCompositor() {
- cleanup();
+ if (!m_bIsShuttingDown)
+ cleanup();
}
void CCompositor::setRandomSplash() {
@@ -432,8 +433,16 @@ void CCompositor::cleanEnvironment() {
}
}
+void CCompositor::stopCompositor() {
+ Debug::log(LOG, "Hyprland is stopping!");
+
+ // this stops the wayland loop, wl_display_run
+ wl_display_terminate(m_sWLDisplay);
+ m_bIsShuttingDown = true;
+}
+
void CCompositor::cleanup() {
- if (!m_sWLDisplay || m_bIsShuttingDown)
+ if (!m_sWLDisplay)
return;
signal(SIGABRT, SIG_DFL);
@@ -507,13 +516,8 @@ void CCompositor::cleanup() {
if (m_critSigSource)
wl_event_source_remove(m_critSigSource);
- wl_event_loop_destroy(m_sWLEventLoop);
- wl_display_terminate(m_sWLDisplay);
- m_sWLDisplay = nullptr;
-
- std::string waylandSocket = std::string{getenv("XDG_RUNTIME_DIR")} + "/" + m_szWLDisplaySocket;
- std::filesystem::remove(waylandSocket);
- std::filesystem::remove(waylandSocket + ".lock");
+ // this frees all wayland resources, including sockets
+ wl_display_destroy(m_sWLDisplay);
}
void CCompositor::initManagers(eManagersInitStage stage) {