diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-11-30 22:25:58 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-11-30 22:26:56 +0100 |
commit | 6cde892148e2643a3cd1ba80c3669bc035fc1fea (patch) | |
tree | 401a4927b79bb9bddfce977d5f51b0dca472f789 /src/Overlay.cpp | |
parent | f885ae67f13ab26dcc47d3fa9cc31ee2fea58c50 (diff) |
Use X11 global hotkeys on X11 when possible to prevent clashing with keys used by other applications
Diffstat (limited to 'src/Overlay.cpp')
-rw-r--r-- | src/Overlay.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/Overlay.cpp b/src/Overlay.cpp index f24c7d0..2a0d8f2 100644 --- a/src/Overlay.cpp +++ b/src/Overlay.cpp @@ -10,6 +10,7 @@ #include "../include/gui/Utils.hpp" #include "../include/gui/PageStack.hpp" #include "../include/WindowUtils.hpp" +#include "../include/GlobalHotkeys.hpp" #include <string.h> #include <assert.h> @@ -555,13 +556,17 @@ namespace gsr { } } - void Overlay::handle_events() { + void Overlay::handle_events(gsr::GlobalHotkeys *global_hotkeys) { if(!visible || !window) return; handle_xi_events(); while(window->poll_event(event)) { + if(global_hotkeys) { + if(!global_hotkeys->on_event(event)) + continue; + } on_event(event); } } @@ -910,7 +915,7 @@ namespace gsr { // The real cursor doesn't move when all devices are grabbed, so we create our own cursor and diplay that while grabbed xi_setup_fake_cursor(); - // We want to grab all devices to prevent any other application below from receiving events. + // We want to grab all devices to prevent any other application below the UI from receiving events. // Owlboy seems to use xi events and XGrabPointer doesn't prevent owlboy from receiving events. xi_grab_all_devices(); @@ -1005,10 +1010,16 @@ namespace gsr { } void Overlay::toggle_show() { - if(visible) - hide(); - else + if(visible) { + //hide(); + // We dont want to hide immediately because hide is called in event callback, in which it destroys the window. + // Instead remove all pages and wait until next iteration to close the UI (which happens when there are no pages to render). + while(!page_stack.empty()) { + page_stack.pop(); + } + } else { show(); + } } void Overlay::toggle_record() { @@ -1555,6 +1566,8 @@ namespace gsr { const int fdl = fcntl(gpu_screen_recorder_process_output_fd, F_GETFL); fcntl(gpu_screen_recorder_process_output_fd, F_SETFL, fdl | O_NONBLOCK); gpu_screen_recorder_process_output_file = fdopen(gpu_screen_recorder_process_output_fd, "r"); + if(gpu_screen_recorder_process_output_file) + gpu_screen_recorder_process_output_fd = -1; // TODO: Start recording after this notification has disappeared to make sure it doesn't show up in the video. // Make clear to the user that the recording starts after the notification is gone. |