aboutsummaryrefslogtreecommitdiff
path: root/src/Overlay.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-10-27 02:00:09 +0200
committerdec05eba <dec05eba@protonmail.com>2024-10-27 02:00:09 +0200
commit28c437e90a3ad4660f44da8b8bf07008032d2bba (patch)
tree219a1057c2fb2ea43ea07d3a0d1b644178a60154 /src/Overlay.cpp
parentcfcee1a5d8e5068cdc5171b01beb9f9e6251e51e (diff)
Only have one notification process open at a time (kill previous one when showing new)
Diffstat (limited to 'src/Overlay.cpp')
-rw-r--r--src/Overlay.cpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/Overlay.cpp b/src/Overlay.cpp
index c0acad4..96e389b 100644
--- a/src/Overlay.cpp
+++ b/src/Overlay.cpp
@@ -210,6 +210,17 @@ namespace gsr {
Overlay::~Overlay() {
hide();
+
+ if(notification_process > 0) {
+ kill(notification_process, SIGKILL);
+ int status;
+ if(waitpid(notification_process, &status, 0) == -1) {
+ perror("waitpid failed");
+ /* Ignore... */
+ }
+ notification_process = -1;
+ }
+
if(gpu_screen_recorder_process > 0) {
kill(gpu_screen_recorder_process, SIGINT);
int status;
@@ -255,6 +266,7 @@ namespace gsr {
}
void Overlay::draw(mgl::Window &window) {
+ update_notification_process_status();
update_gsr_process_status();
if(!visible)
@@ -517,13 +529,33 @@ namespace gsr {
} else {
notification_args[9] = nullptr;
}
- exec_program_daemonized(notification_args);
+
+ if(notification_process > 0) {
+ kill(notification_process, SIGKILL);
+ int status = 0;
+ waitpid(gpu_screen_recorder_process, &status, 0);
+ }
+
+ notification_process = exec_program(notification_args);
}
bool Overlay::is_open() const {
return visible;
}
+ void Overlay::update_notification_process_status() {
+ if(notification_process <= 0)
+ return;
+
+ int status;
+ if(waitpid(gpu_screen_recorder_process, &status, WNOHANG) == 0) {
+ // Still running
+ return;
+ }
+
+ notification_process = -1;
+ }
+
void Overlay::update_gsr_process_status() {
if(gpu_screen_recorder_process <= 0)
return;