From 138d991cf21757161e8d6ab0bc0aef1289e8b676 Mon Sep 17 00:00:00 2001 From: pallaswept Date: Fri, 9 May 2025 13:10:55 +0000 Subject: [PATCH] Signal Handling and Fix for Closing --- main.cpp | 21 +++++++++++++++++++++ qt/OpenRGBDialog/OpenRGBDialog.cpp | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index fec295b1..29de1f17 100644 --- a/main.cpp +++ b/main.cpp @@ -31,6 +31,10 @@ io_connect_t macUSPCIO_driver_connection; #include "macutils.h" #endif +#ifdef __linux__ +#include +#endif + using namespace std::chrono_literals; /******************************************************************************************\ @@ -168,6 +172,19 @@ void InstallWinRing0() } #endif +/******************************************************************************************\ +* * +* Linux signal handler * +* * +\******************************************************************************************/ +#ifdef __linux__ +void sigHandler(int s) +{ + std::signal(s, SIG_DFL); + qApp->quit(); +} +#endif + /******************************************************************************************\ * * * main * @@ -288,6 +305,10 @@ int main(int argc, char* argv[]) } LOG_TRACE("[main] Ready to exec() the dialog"); +#ifdef __linux__ + std::signal(SIGINT, sigHandler); + std::signal(SIGTERM, sigHandler); +#endif exitval = a.exec(); } else diff --git a/qt/OpenRGBDialog/OpenRGBDialog.cpp b/qt/OpenRGBDialog/OpenRGBDialog.cpp index c5b64c0d..0608bccd 100644 --- a/qt/OpenRGBDialog/OpenRGBDialog.cpp +++ b/qt/OpenRGBDialog/OpenRGBDialog.cpp @@ -639,7 +639,7 @@ void OpenRGBDialog::closeEvent(QCloseEvent *event) { ResourceManager::get()->WaitForDeviceDetection(); - if (IsMinimizeOnClose() && !this->isHidden()) + if (IsMinimizeOnClose() && !this->isHidden() && event->spontaneous()) { #ifdef __APPLE__ MacUtils::ToggleApplicationDocklessState(false);