diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-04-21 15:59:28 +0200 |
|---|---|---|
| committer | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-04-21 15:59:28 +0200 |
| commit | 422eaad4201fe1902f037898e98d8651925b9c13 (patch) | |
| tree | bac4f175fff3f8aacea17d627f4841edfdca5280 /src/Compositor.cpp | |
| parent | 66b5c5a1437f81e9cea94e1a27e48fbf74d8a56d (diff) | |
handle term and int signals and cleanup
Diffstat (limited to 'src/Compositor.cpp')
| -rw-r--r-- | src/Compositor.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp index f4da7caf..2ed12112 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -100,7 +100,12 @@ CCompositor::CCompositor() { } CCompositor::~CCompositor() { + cleanupExit(); +} +void handleCritSignal(int signo) { + g_pCompositor->cleanupExit(); + exit(signo); } void CCompositor::initAllSignals() { @@ -123,6 +128,24 @@ void CCompositor::initAllSignals() { addWLSignal(&m_sWLRInhibitMgr->events.activate, &Events::listen_InhibitActivate, m_sWLRInhibitMgr, "InhibitMgr"); addWLSignal(&m_sWLRInhibitMgr->events.deactivate, &Events::listen_InhibitDeactivate, m_sWLRInhibitMgr, "InhibitMgr"); addWLSignal(&m_sWLRPointerConstraints->events.new_constraint, &Events::listen_newConstraint, m_sWLRPointerConstraints, "PointerConstraints"); + + signal(SIGINT, handleCritSignal); + signal(SIGTERM, handleCritSignal); +} + +void CCompositor::cleanupExit() { + if (!m_sWLDisplay) + return; + + if (g_pXWaylandManager->m_sWLRXWayland) { + wlr_xwayland_destroy(g_pXWaylandManager->m_sWLRXWayland); + g_pXWaylandManager->m_sWLRXWayland = nullptr; + } + + wl_display_destroy_clients(m_sWLDisplay); + wl_display_destroy(m_sWLDisplay); + + m_sWLDisplay = nullptr; } void CCompositor::startCompositor() { |
