diff options
-rw-r--r-- | include/Overlay.hpp | 2 | ||||
-rw-r--r-- | src/Overlay.cpp | 34 |
2 files changed, 35 insertions, 1 deletions
diff --git a/include/Overlay.hpp b/include/Overlay.hpp index fa6630d..e693764 100644 --- a/include/Overlay.hpp +++ b/include/Overlay.hpp @@ -50,6 +50,7 @@ namespace gsr { private: void process_key_bindings(mgl::Event &event); + void update_notification_process_status(); void update_gsr_process_status(); void update_ui_recording_paused(); @@ -90,6 +91,7 @@ namespace gsr { bool visible = false; uint64_t default_cursor = 0; pid_t gpu_screen_recorder_process = -1; + pid_t notification_process = -1; std::optional<Config> config; DropdownButton *replay_dropdown_button_ptr = nullptr; DropdownButton *record_dropdown_button_ptr = nullptr; 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; |