From b145d957e3809fd6c2d814c34c58234ade983bb0 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 8 Sep 2024 17:07:22 +0200 Subject: More --- README.md | 17 +- TODO | 9 +- depends/mglpp | 2 +- fonts/NotoSans-Bold.ttf | Bin 0 -> 616112 bytes fonts/NotoSans-Regular.ttf | Bin 0 -> 610392 bytes gpu-screen-recorder-overlay-daemon/main.c | 2 + include/GlobalHotkeys.hpp | 27 ++ include/GlobalHotkeysX11.hpp | 31 ++ include/GsrInfo.hpp | 4 + include/Overlay.hpp | 56 +++ include/Theme.hpp | 11 +- include/gui/CustomRendererWidget.hpp | 1 + include/gui/SettingsPage.hpp | 12 +- include/gui/Subsection.hpp | 24 ++ include/gui/Widget.hpp | 1 + meson.build | 15 +- src/GlobalHotkeysX11.cpp | 137 +++++++ src/GsrInfo.cpp | 8 + src/Overlay.cpp | 567 +++++++++++++++++++++++++++ src/Theme.cpp | 49 ++- src/gui/Button.cpp | 6 +- src/gui/ComboBox.cpp | 28 +- src/gui/CustomRendererWidget.cpp | 4 + src/gui/List.cpp | 20 +- src/gui/ScrollablePage.cpp | 1 + src/gui/SettingsPage.cpp | 115 +++--- src/gui/Subsection.cpp | 60 +++ src/main.cpp | 620 ++---------------------------- uninstall.sh | 1 + 29 files changed, 1141 insertions(+), 687 deletions(-) create mode 100644 fonts/NotoSans-Bold.ttf create mode 100644 fonts/NotoSans-Regular.ttf create mode 100644 include/GlobalHotkeys.hpp create mode 100644 include/GlobalHotkeysX11.hpp create mode 100644 include/Overlay.hpp create mode 100644 include/gui/Subsection.hpp create mode 100644 src/GlobalHotkeysX11.cpp create mode 100644 src/Overlay.cpp create mode 100644 src/gui/Subsection.cpp diff --git a/README.md b/README.md index cf3328c..e6c1a3d 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,19 @@ # GPU Screen Recorder Overlay -A fullscreen overlay UI for [GPU Screen Recorder](https://git.dec05eba.com/gpu-screen-recorder/about/), in the style of NVIDIA ShadowPlay. +A fullscreen overlay UI for [GPU Screen Recorder](https://git.dec05eba.com/gpu-screen-recorder/about/), in the style of ShadowPlay. # Dependencies -x11, xrandr, xrender, xfixes, opengl +GPU Screen Recorder overlay uses meson build system so you need to install `meson` to build GPU Screen Recorder overlay. + +## Build dependencies +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. \ No newline at end of file +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. diff --git a/TODO b/TODO index cbf9da5..488a707 100644 --- a/TODO +++ b/TODO @@ -24,6 +24,11 @@ Add support for window selection in capture. Add option to record the focused monitor. This works on wayland too when using kms capture since we can get cursor position without root and see which monitor (crtc) the cursor is on. -Add option to select hevc_10bit and av1_10bit. - For system startup dont allow default output/input audio, as that can change after startup. For example if default output is a bluetooth devices that gets connected after startup. + +Make hotkeys configurable. + +Move hotkey to gsr-overlay-daemon which should execute gpu-screen-recorder --info on start, write that output to /tmp/blabla (or $XDG_RUNTIME_DIR) and gsr-overlay + should read that tmp file. gsr-overlay should remove show/hide functions for overlay and run show on startup. + +Add scrollbar to scrollable page. diff --git a/depends/mglpp b/depends/mglpp index 685cd2d..8f6c5d2 160000 --- a/depends/mglpp +++ b/depends/mglpp @@ -1 +1 @@ -Subproject commit 685cd2d470b399a7aa82ae6a2942ffb0afefab9b +Subproject commit 8f6c5d220d3e4c250db4bf3022f99c38811b63fd diff --git a/fonts/NotoSans-Bold.ttf b/fonts/NotoSans-Bold.ttf new file mode 100644 index 0000000..785ef8a Binary files /dev/null and b/fonts/NotoSans-Bold.ttf differ diff --git a/fonts/NotoSans-Regular.ttf b/fonts/NotoSans-Regular.ttf new file mode 100644 index 0000000..bdc1ffa Binary files /dev/null and b/fonts/NotoSans-Regular.ttf differ diff --git a/gpu-screen-recorder-overlay-daemon/main.c b/gpu-screen-recorder-overlay-daemon/main.c index 53ca5ec..e243efe 100644 --- a/gpu-screen-recorder-overlay-daemon/main.c +++ b/gpu-screen-recorder-overlay-daemon/main.c @@ -2,6 +2,8 @@ #include #include #include +#include + #include #include diff --git a/include/GlobalHotkeys.hpp b/include/GlobalHotkeys.hpp new file mode 100644 index 0000000..020f5a5 --- /dev/null +++ b/include/GlobalHotkeys.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include +#include +#include + +namespace gsr { + struct Hotkey { + uint64_t key = 0; + uint32_t modifiers = 0; + }; + + using GlobalHotkeyCallback = std::function; + + class GlobalHotkeys { + public: + GlobalHotkeys() = default; + GlobalHotkeys(const GlobalHotkeys&) = delete; + GlobalHotkeys& operator=(const GlobalHotkeys&) = delete; + virtual ~GlobalHotkeys() = default; + + virtual bool bind_key_press(Hotkey hotkey, const std::string &id, GlobalHotkeyCallback callback) = 0; + virtual void unbind_key_press(const std::string &id) = 0; + virtual void unbind_all_keys() = 0; + virtual void poll_events() = 0; + }; +} \ No newline at end of file diff --git a/include/GlobalHotkeysX11.hpp b/include/GlobalHotkeysX11.hpp new file mode 100644 index 0000000..427e9f0 --- /dev/null +++ b/include/GlobalHotkeysX11.hpp @@ -0,0 +1,31 @@ +#pragma once + +#include "GlobalHotkeys.hpp" +#include +#include + +namespace gsr { + class GlobalHotkeysX11 : public GlobalHotkeys { + public: + GlobalHotkeysX11(); + GlobalHotkeysX11(const GlobalHotkeysX11&) = delete; + GlobalHotkeysX11& operator=(const GlobalHotkeysX11&) = delete; + ~GlobalHotkeysX11() override; + + bool bind_key_press(Hotkey hotkey, const std::string &id, GlobalHotkeyCallback callback) override; + void unbind_key_press(const std::string &id) override; + void unbind_all_keys() override; + void poll_events() override; + private: + void call_hotkey_callback(Hotkey hotkey) const; + private: + struct HotkeyData { + Hotkey hotkey; + GlobalHotkeyCallback callback; + }; + + Display *dpy = nullptr; + XEvent xev; + std::unordered_map bound_keys_by_id; + }; +} \ No newline at end of file diff --git a/include/GsrInfo.hpp b/include/GsrInfo.hpp index d90d72f..fb12cd4 100644 --- a/include/GsrInfo.hpp +++ b/include/GsrInfo.hpp @@ -10,7 +10,11 @@ namespace gsr { bool h264 = false; bool h264_software = false; bool hevc = false; + bool hevc_hdr = false; + bool hevc_10bit = false; bool av1 = false; + bool av1_hdr = false; + bool av1_10bit = false; bool vp8 = false; bool vp9 = false; }; diff --git a/include/Overlay.hpp b/include/Overlay.hpp new file mode 100644 index 0000000..de5fa79 --- /dev/null +++ b/include/Overlay.hpp @@ -0,0 +1,56 @@ +#pragma once + +#include "gui/PageStack.hpp" +#include "gui/CustomRendererWidget.hpp" +#include "GsrInfo.hpp" +#include "Config.hpp" +#include "window_texture.h" + +#include +#include +#include +#include +#include + +namespace gsr { + class Overlay { + public: + Overlay(mgl::Window &window, std::string resources_path, GsrInfo gsr_info, egl_functions egl_funcs, mgl::Color bg_color); + Overlay(const Overlay&) = delete; + Overlay& operator=(const Overlay&) = delete; + ~Overlay(); + + void on_event(mgl::Event &event, mgl::Window &window); + void draw(mgl::Window &window); + + void show(); + void hide(); + void toggle_show(); + bool is_open() const; + private: + bool update_compositor_texture(const mgl_monitor *monitor); + private: + mgl::Window &window; + std::string resources_path; + GsrInfo gsr_info; + egl_functions egl_funcs; + mgl::Color bg_color; + std::vector audio_devices; + mgl::Texture window_texture_texture; + mgl::Sprite window_texture_sprite; + mgl::Texture screenshot_texture; + mgl::Sprite screenshot_sprite; + mgl::Rectangle bg_screenshot_overlay; + WindowTexture window_texture; + gsr::PageStack page_stack; + mgl::Rectangle top_bar_background; + mgl::Text top_bar_text; + mgl::Sprite logo_sprite; + CustomRendererWidget close_button_widget; + bool close_button_pressed_inside = false; + bool visible = false; + uint64_t default_cursor = 0; + pid_t gpu_screen_recorder_process = -1; + std::optional config; + }; +} \ No newline at end of file diff --git a/include/Theme.hpp b/include/Theme.hpp index c70167b..df25268 100644 --- a/include/Theme.hpp +++ b/include/Theme.hpp @@ -32,11 +32,20 @@ namespace gsr { mgl::Texture settings_texture; mgl::Texture folder_texture; mgl::Texture up_arrow_texture; + mgl::Texture replay_button_texture; + mgl::Texture record_button_texture; + mgl::Texture stream_button_texture; + mgl::Texture close_texture; + mgl::Texture logo_texture; double double_click_timeout_seconds = 0.4; + + // Reloads fonts + bool set_window_size(mgl::vec2i window_size); }; - bool init_theme(const GsrInfo &gsr_info, mgl::vec2i window_size, const std::string &resources_path); + bool init_theme(const GsrInfo &gsr_info, const std::string &resources_path); void deinit_theme(); + Theme& get_theme(); } \ No newline at end of file diff --git a/include/gui/CustomRendererWidget.hpp b/include/gui/CustomRendererWidget.hpp index e16e532..20bfec8 100644 --- a/include/gui/CustomRendererWidget.hpp +++ b/include/gui/CustomRendererWidget.hpp @@ -15,6 +15,7 @@ namespace gsr { void draw(mgl::Window &window, mgl::vec2f offset) override; mgl::vec2f get_size() override; + void set_size(mgl::vec2f size); std::function draw_handler; // Return true to allow other widgets to handle events diff --git a/include/gui/SettingsPage.hpp b/include/gui/SettingsPage.hpp index 1ad4c67..b22506e 100644 --- a/include/gui/SettingsPage.hpp +++ b/include/gui/SettingsPage.hpp @@ -13,6 +13,7 @@ namespace gsr { class GsrPage; class PageStack; + class ScrollablePage; class SettingsPage : public StaticPage { public: @@ -31,7 +32,7 @@ namespace gsr { private: std::unique_ptr create_view_radio_button(); std::unique_ptr create_record_area_box(const GsrInfo &gsr_info); - std::unique_ptr create_record_area(const GsrInfo &gsr_info); + std::unique_ptr create_record_area(const GsrInfo &gsr_info); std::unique_ptr create_select_window(); std::unique_ptr create_area_width_entry(); std::unique_ptr create_area_height_entry(); @@ -39,14 +40,14 @@ namespace gsr { std::unique_ptr create_area_size_section(); std::unique_ptr create_restore_portal_session_checkbox(); std::unique_ptr create_restore_portal_session_section(); - std::unique_ptr create_capture_target(const GsrInfo &gsr_info); + std::unique_ptr create_capture_target(const GsrInfo &gsr_info); std::unique_ptr create_audio_track_selection_checkbox(const std::vector &audio_devices); std::unique_ptr