mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-03-31 09:17:04 +09:00
Only have one notification process open at a time (kill previous one when showing new)
This commit is contained in:
@@ -50,6 +50,7 @@ namespace gsr {
|
|||||||
private:
|
private:
|
||||||
void process_key_bindings(mgl::Event &event);
|
void process_key_bindings(mgl::Event &event);
|
||||||
|
|
||||||
|
void update_notification_process_status();
|
||||||
void update_gsr_process_status();
|
void update_gsr_process_status();
|
||||||
|
|
||||||
void update_ui_recording_paused();
|
void update_ui_recording_paused();
|
||||||
@@ -90,6 +91,7 @@ namespace gsr {
|
|||||||
bool visible = false;
|
bool visible = false;
|
||||||
uint64_t default_cursor = 0;
|
uint64_t default_cursor = 0;
|
||||||
pid_t gpu_screen_recorder_process = -1;
|
pid_t gpu_screen_recorder_process = -1;
|
||||||
|
pid_t notification_process = -1;
|
||||||
std::optional<Config> config;
|
std::optional<Config> config;
|
||||||
DropdownButton *replay_dropdown_button_ptr = nullptr;
|
DropdownButton *replay_dropdown_button_ptr = nullptr;
|
||||||
DropdownButton *record_dropdown_button_ptr = nullptr;
|
DropdownButton *record_dropdown_button_ptr = nullptr;
|
||||||
|
|||||||
@@ -210,6 +210,17 @@ namespace gsr {
|
|||||||
|
|
||||||
Overlay::~Overlay() {
|
Overlay::~Overlay() {
|
||||||
hide();
|
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) {
|
if(gpu_screen_recorder_process > 0) {
|
||||||
kill(gpu_screen_recorder_process, SIGINT);
|
kill(gpu_screen_recorder_process, SIGINT);
|
||||||
int status;
|
int status;
|
||||||
@@ -255,6 +266,7 @@ namespace gsr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Overlay::draw(mgl::Window &window) {
|
void Overlay::draw(mgl::Window &window) {
|
||||||
|
update_notification_process_status();
|
||||||
update_gsr_process_status();
|
update_gsr_process_status();
|
||||||
|
|
||||||
if(!visible)
|
if(!visible)
|
||||||
@@ -517,13 +529,33 @@ namespace gsr {
|
|||||||
} else {
|
} else {
|
||||||
notification_args[9] = nullptr;
|
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 {
|
bool Overlay::is_open() const {
|
||||||
return visible;
|
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() {
|
void Overlay::update_gsr_process_status() {
|
||||||
if(gpu_screen_recorder_process <= 0)
|
if(gpu_screen_recorder_process <= 0)
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user