diff options
-rw-r--r-- | README.md | 12 | ||||
-rw-r--r-- | TODO | 5 | ||||
-rw-r--r-- | gpu-screen-recorder-overlay-daemon/main.c | 4 | ||||
-rw-r--r-- | include/Overlay.hpp | 11 | ||||
-rw-r--r-- | src/Overlay.cpp | 35 |
5 files changed, 58 insertions, 9 deletions
@@ -10,10 +10,12 @@ These are the dependencies needed to build GPU Screen Recorder overlay: * x11 (libx11, libxrandr, libxrender, libxfixes) * libglvnd (which provides libgl, libglx and libegl) -## Runtime dependencies -There are also additional dependencies needed at runtime: - -* Noto fonts - # Installation Run `sudo ./install.sh`. This will install gsr-overlay to `/usr/bin/gsr-overlay`. You can run meson commands manually to install gsr-overlay to another directory. + +# License +This software is licensed under GPL3.0-only. Files under `fonts/` directory are licensed under `SIL Open Font License`. + +# Screenshots +![](https://dec05eba.com/images/gsr-overlay-screenshot-front.webp) +![](https://dec05eba.com/images/gsr-overlay-screenshot-settings.webp)
\ No newline at end of file @@ -45,4 +45,7 @@ Restart replay on system start if monitor resolution changes. Show warning when selecting hevc/av1 on amd because of amd driver/ffmpeg bug. -Update gsr info and validate saved config when monitors update. The selected monitor/audio may no longer be available.
\ No newline at end of file +Update gsr info and validate saved config when monitors update. The selected monitor/audio may no longer be available. + +Have different modes. Overlay, window and side menu. Overlay can be used on x11, window and side menu can be used on both x11 and wayland. + Window mode should look similar to overlay.
\ No newline at end of file diff --git a/gpu-screen-recorder-overlay-daemon/main.c b/gpu-screen-recorder-overlay-daemon/main.c index bce9f2f..18234c2 100644 --- a/gpu-screen-recorder-overlay-daemon/main.c +++ b/gpu-screen-recorder-overlay-daemon/main.c @@ -40,6 +40,8 @@ static void sigterm_handler(int dummy) { } static const KeySym toggle_overlay_key = XK_Z; +static unsigned int toggle_overlay_modifiers = Mod1Mask; + static void grab_keys(Display *display) { unsigned int numlockmask = 0; KeyCode numlock_keycode = XKeysymToKeycode(display, XK_Num_Lock); @@ -57,7 +59,7 @@ static void grab_keys(Display *display) { Window root_window = DefaultRootWindow(display); unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask }; for(int i = 0; i < 4; ++i) { - XGrabKey(display, XKeysymToKeycode(display, toggle_overlay_key), Mod1Mask|modifiers[i], root_window, False, GrabModeAsync, GrabModeAsync); + XGrabKey(display, XKeysymToKeycode(display, toggle_overlay_key), toggle_overlay_modifiers|modifiers[i], root_window, False, GrabModeAsync, GrabModeAsync); } XSync(display, False); diff --git a/include/Overlay.hpp b/include/Overlay.hpp index bf3600f..fcc3781 100644 --- a/include/Overlay.hpp +++ b/include/Overlay.hpp @@ -11,6 +11,7 @@ #include <mglpp/graphics/Sprite.hpp> #include <mglpp/graphics/Rectangle.hpp> #include <mglpp/graphics/Text.hpp> +#include <mglpp/window/Event.hpp> namespace gsr { class DropdownButton; @@ -37,6 +38,8 @@ namespace gsr { void toggle_show(); bool is_open() const; private: + void process_key_bindings(mgl::Event &event); + void update_gsr_process_status(); void load_program_status(); @@ -53,6 +56,12 @@ namespace gsr { void on_press_start_stream(const std::string &id); bool update_compositor_texture(const mgl_monitor *monitor); private: + using KeyBindingCallback = std::function<void()>; + struct KeyBinding { + mgl::Event::KeyEvent key_event; + KeyBindingCallback callback; + }; + mgl::Window &window; std::string resources_path; GsrInfo gsr_info; @@ -80,5 +89,7 @@ namespace gsr { DropdownButton *stream_dropdown_button_ptr = nullptr; RecordingStatus recording_status = RecordingStatus::NONE; + + std::array<KeyBinding, 1> key_bindings; }; }
\ No newline at end of file diff --git a/src/Overlay.cpp b/src/Overlay.cpp index ece6030..cee40b7 100644 --- a/src/Overlay.cpp +++ b/src/Overlay.cpp @@ -199,6 +199,17 @@ namespace gsr { memset(&window_texture, 0, sizeof(window_texture)); load_program_status(); load_program_pid(); + + key_bindings[0].key_event.code = mgl::Keyboard::Z; + key_bindings[0].key_event.alt = true; + key_bindings[0].key_event.control = false; + key_bindings[0].key_event.shift = false; + key_bindings[0].key_event.system = false; + key_bindings[0].callback = [this]() { + while(!page_stack.empty()) { + page_stack.pop(); + } + }; } Overlay::~Overlay() { @@ -214,6 +225,24 @@ namespace gsr { // } } + static uint32_t key_event_to_bitmask(mgl::Event::KeyEvent key_event) { + return ((uint32_t)key_event.alt << (uint32_t)0) + | ((uint32_t)key_event.control << (uint32_t)1) + | ((uint32_t)key_event.shift << (uint32_t)2) + | ((uint32_t)key_event.system << (uint32_t)3); + } + + void Overlay::process_key_bindings(mgl::Event &event) { + if(event.type != mgl::Event::KeyReleased) + return; + + const uint32_t event_key_bitmask = key_event_to_bitmask(event.key); + for(const KeyBinding &key_binding : key_bindings) { + if(event.key.code == key_binding.key_event.code && event_key_bitmask == key_event_to_bitmask(key_binding.key_event)) + key_binding.callback(); + } + } + void Overlay::on_event(mgl::Event &event, mgl::Window &window) { if(!visible) return; @@ -224,6 +253,7 @@ namespace gsr { if(event.key.code == mgl::Keyboard::Escape) page_stack.pop(); } + //process_key_bindings(event); } void Overlay::draw(mgl::Window &window) { @@ -284,7 +314,6 @@ namespace gsr { top_bar_background.set_color(mgl::Color(0, 0, 0, 180)); //top_bar_text.set_color(get_theme().tint_color); top_bar_text.set_position((top_bar_background.get_position() + top_bar_background.get_size()*0.5f - top_bar_text.get_bounds().size*0.5f).floor()); - close_button_widget.set_position(mgl::vec2f(get_theme().window_width - close_button_widget.get_size().x - 50.0f, top_bar_background.get_size().y * 0.5f - close_button_widget.get_size().y * 0.5f).floor()); logo_sprite.set_height((int)(top_bar_background.get_size().y * 0.65f)); logo_sprite.set_position(mgl::vec2f( @@ -292,6 +321,8 @@ namespace gsr { top_bar_background.get_size().y * 0.5f - logo_sprite.get_size().y * 0.5f ).floor()); + close_button_widget.set_position(mgl::vec2f(get_theme().window_width - close_button_widget.get_size().x - logo_sprite.get_position().x, top_bar_background.get_size().y * 0.5f - close_button_widget.get_size().y * 0.5f).floor()); + while(!page_stack.empty()) { page_stack.pop(); } @@ -391,7 +422,7 @@ namespace gsr { ButtonMotionMask, GrabModeAsync, GrabModeAsync, None, default_cursor, CurrentTime); // TODO: This breaks global hotkeys - XGrabKeyboard(display, window.get_system_handle(), True, GrabModeAsync, GrabModeAsync, CurrentTime); + //XGrabKeyboard(display, window.get_system_handle(), True, GrabModeAsync, GrabModeAsync, CurrentTime); XSetInputFocus(display, window.get_system_handle(), RevertToParent, CurrentTime); XFlush(display); |