mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-07 20:06:00 +01:00
handle term and int signals and cleanup
This commit is contained in:
parent
66b5c5a143
commit
422eaad420
3 changed files with 25 additions and 2 deletions
|
@ -100,7 +100,12 @@ CCompositor::CCompositor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
CCompositor::~CCompositor() {
|
CCompositor::~CCompositor() {
|
||||||
|
cleanupExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleCritSignal(int signo) {
|
||||||
|
g_pCompositor->cleanupExit();
|
||||||
|
exit(signo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCompositor::initAllSignals() {
|
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.activate, &Events::listen_InhibitActivate, m_sWLRInhibitMgr, "InhibitMgr");
|
||||||
addWLSignal(&m_sWLRInhibitMgr->events.deactivate, &Events::listen_InhibitDeactivate, 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");
|
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() {
|
void CCompositor::startCompositor() {
|
||||||
|
|
|
@ -66,6 +66,7 @@ public:
|
||||||
std::list<CWindow*> m_lWindowsFadingOut;
|
std::list<CWindow*> m_lWindowsFadingOut;
|
||||||
|
|
||||||
void startCompositor();
|
void startCompositor();
|
||||||
|
void cleanupExit();
|
||||||
|
|
||||||
wlr_surface* m_pLastFocus = nullptr;
|
wlr_surface* m_pLastFocus = nullptr;
|
||||||
CWindow* m_pLastWindow = nullptr;
|
CWindow* m_pLastWindow = nullptr;
|
||||||
|
|
|
@ -22,8 +22,7 @@ int main(int argc, char** argv) {
|
||||||
// If we are here it means we got yote.
|
// If we are here it means we got yote.
|
||||||
Debug::log(LOG, "Hyprland reached the end.");
|
Debug::log(LOG, "Hyprland reached the end.");
|
||||||
|
|
||||||
wl_display_destroy_clients(g_pCompositor->m_sWLDisplay);
|
g_pCompositor->cleanupExit();
|
||||||
wl_display_destroy(g_pCompositor->m_sWLDisplay);
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue