mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-22 23:49:49 +01:00
Multiple improvements to the shutdown procedure
This commit is contained in:
parent
4203a61b69
commit
d413388761
7 changed files with 41 additions and 7 deletions
|
@ -16,6 +16,8 @@ int handleCritSignal(int signo, void* data) {
|
||||||
CCompositor::CCompositor() {
|
CCompositor::CCompositor() {
|
||||||
wlr_log_init(WLR_INFO, NULL);
|
wlr_log_init(WLR_INFO, NULL);
|
||||||
|
|
||||||
|
m_iHyprlandPID = getpid();
|
||||||
|
|
||||||
m_szInstanceSignature = GIT_COMMIT_HASH + std::string("_") + std::to_string(time(NULL));
|
m_szInstanceSignature = GIT_COMMIT_HASH + std::string("_") + std::to_string(time(NULL));
|
||||||
|
|
||||||
setenv("HYPRLAND_INSTANCE_SIGNATURE", m_szInstanceSignature.c_str(), true);
|
setenv("HYPRLAND_INSTANCE_SIGNATURE", m_szInstanceSignature.c_str(), true);
|
||||||
|
@ -27,6 +29,8 @@ CCompositor::CCompositor() {
|
||||||
|
|
||||||
Debug::log(LOG, "Instance Signature: %s", m_szInstanceSignature.c_str());
|
Debug::log(LOG, "Instance Signature: %s", m_szInstanceSignature.c_str());
|
||||||
|
|
||||||
|
Debug::log(LOG, "Hyprland PID: %i", m_iHyprlandPID);
|
||||||
|
|
||||||
Debug::log(LOG, "===== SYSTEM INFO: =====");
|
Debug::log(LOG, "===== SYSTEM INFO: =====");
|
||||||
|
|
||||||
logSystemInfo();
|
logSystemInfo();
|
||||||
|
@ -236,6 +240,17 @@ void CCompositor::cleanup() {
|
||||||
m_pLastFocus = nullptr;
|
m_pLastFocus = nullptr;
|
||||||
m_pLastWindow = nullptr;
|
m_pLastWindow = nullptr;
|
||||||
|
|
||||||
|
// accumulate all PIDs for killing, also request closing.
|
||||||
|
for (auto& w : m_vWindows) {
|
||||||
|
m_dProcessPIDsOnShutdown.push_back(w->getPID());
|
||||||
|
|
||||||
|
closeWindow(w.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
// end threads
|
||||||
|
g_pEventManager->m_tThread = std::thread();
|
||||||
|
HyprCtl::tThread = std::thread();
|
||||||
|
|
||||||
m_vWorkspaces.clear();
|
m_vWorkspaces.clear();
|
||||||
m_vWindows.clear();
|
m_vWindows.clear();
|
||||||
|
|
||||||
|
@ -254,6 +269,9 @@ void CCompositor::cleanup() {
|
||||||
wl_display_terminate(m_sWLDisplay);
|
wl_display_terminate(m_sWLDisplay);
|
||||||
|
|
||||||
m_bIsShuttingDown = true;
|
m_bIsShuttingDown = true;
|
||||||
|
|
||||||
|
g_pKeybindManager->spawn("sleep 5 && kill -9 " + std::to_string(m_iHyprlandPID)); // this is to prevent that random "freezing"
|
||||||
|
// the PID should not be reused.
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCompositor::startCompositor() {
|
void CCompositor::startCompositor() {
|
||||||
|
|
|
@ -101,6 +101,7 @@ public:
|
||||||
bool m_bDPMSStateON = true;
|
bool m_bDPMSStateON = true;
|
||||||
bool m_bUnsafeState = false; // unsafe state is when there is no monitors.
|
bool m_bUnsafeState = false; // unsafe state is when there is no monitors.
|
||||||
bool m_bIsShuttingDown = false;
|
bool m_bIsShuttingDown = false;
|
||||||
|
std::deque<uint64_t> m_dProcessPIDsOnShutdown; // stores PIDs of apps to kill later when shutting down
|
||||||
|
|
||||||
// ------------------------------------------------- //
|
// ------------------------------------------------- //
|
||||||
|
|
||||||
|
@ -172,7 +173,9 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initAllSignals();
|
void initAllSignals();
|
||||||
void setRandomSplash();
|
void setRandomSplash();
|
||||||
|
|
||||||
|
uint64_t m_iHyprlandPID = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -759,7 +759,7 @@ std::string getRequestFromThread(std::string rq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HyprCtl::startHyprCtlSocket() {
|
void HyprCtl::startHyprCtlSocket() {
|
||||||
std::thread([&]() {
|
tThread = std::thread([&]() {
|
||||||
const auto SOCKET = socket(AF_UNIX, SOCK_STREAM, 0);
|
const auto SOCKET = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||||
|
|
||||||
if (SOCKET < 0) {
|
if (SOCKET < 0) {
|
||||||
|
@ -806,5 +806,7 @@ void HyprCtl::startHyprCtlSocket() {
|
||||||
}
|
}
|
||||||
|
|
||||||
close(SOCKET);
|
close(SOCKET);
|
||||||
}).detach();
|
});
|
||||||
|
|
||||||
|
tThread.detach();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,8 @@ namespace HyprCtl {
|
||||||
|
|
||||||
inline std::ifstream requestStream;
|
inline std::ifstream requestStream;
|
||||||
|
|
||||||
|
inline std::thread tThread;
|
||||||
|
|
||||||
enum eHyprCtlOutputFormat {
|
enum eHyprCtlOutputFormat {
|
||||||
FORMAT_NORMAL = 0,
|
FORMAT_NORMAL = 0,
|
||||||
FORMAT_JSON
|
FORMAT_JSON
|
||||||
|
|
|
@ -62,6 +62,11 @@ int main(int argc, char** argv) {
|
||||||
Debug::log(LOG, "Hyprland reached the end.");
|
Debug::log(LOG, "Hyprland reached the end.");
|
||||||
|
|
||||||
wl_display_destroy_clients(g_pCompositor->m_sWLDisplay);
|
wl_display_destroy_clients(g_pCompositor->m_sWLDisplay);
|
||||||
|
|
||||||
|
// kill all clients
|
||||||
|
for (auto& c : g_pCompositor->m_dProcessPIDsOnShutdown)
|
||||||
|
kill(c, SIGKILL);
|
||||||
|
|
||||||
wl_display_destroy(g_pCompositor->m_sWLDisplay);
|
wl_display_destroy(g_pCompositor->m_sWLDisplay);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
|
@ -19,7 +19,7 @@ CEventManager::CEventManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEventManager::startThread() {
|
void CEventManager::startThread() {
|
||||||
std::thread([&]() {
|
m_tThread = std::thread([&]() {
|
||||||
const auto SOCKET = socket(AF_UNIX, SOCK_STREAM, 0);
|
const auto SOCKET = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||||
|
|
||||||
if (SOCKET < 0) {
|
if (SOCKET < 0) {
|
||||||
|
@ -101,13 +101,15 @@ void CEventManager::startThread() {
|
||||||
}
|
}
|
||||||
|
|
||||||
close(SOCKET);
|
close(SOCKET);
|
||||||
}).detach();
|
});
|
||||||
|
|
||||||
|
m_tThread.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEventManager::postEvent(const SHyprIPCEvent event, bool force) {
|
void CEventManager::postEvent(const SHyprIPCEvent event, bool force) {
|
||||||
|
|
||||||
if (m_bIgnoreEvents && !force) {
|
if ((m_bIgnoreEvents && !force) || g_pCompositor->m_bIsShuttingDown) {
|
||||||
Debug::log(WARN, "Suppressed (ignoreevents true) event of type %s, content: %s",event.event.c_str(), event.data.c_str());
|
Debug::log(WARN, "Suppressed (ignoreevents true / shutting down) event of type %s, content: %s",event.event.c_str(), event.data.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ public:
|
||||||
|
|
||||||
bool m_bIgnoreEvents = false;
|
bool m_bIgnoreEvents = false;
|
||||||
|
|
||||||
|
std::thread m_tThread;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::mutex eventQueueMutex;
|
std::mutex eventQueueMutex;
|
||||||
|
|
Loading…
Reference in a new issue