mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-03-31 09:17:04 +09:00
Make hotkeys reconfigurable, faster hotkey startup time, fix some keyboard locale issues
This commit is contained in:
@@ -6,12 +6,14 @@
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
|
||||
#define GSR_CONFIG_FILE_VERSION 1
|
||||
|
||||
namespace gsr {
|
||||
struct SupportedCaptureOptions;
|
||||
|
||||
struct ConfigHotkey {
|
||||
int64_t keysym = 0;
|
||||
uint32_t modifiers = 0;
|
||||
int64_t key = 0; // Mgl key
|
||||
uint32_t modifiers = 0; // HotkeyModifier
|
||||
|
||||
bool operator==(const ConfigHotkey &other) const;
|
||||
bool operator!=(const ConfigHotkey &other) const;
|
||||
@@ -41,11 +43,12 @@ namespace gsr {
|
||||
};
|
||||
|
||||
struct MainConfig {
|
||||
int32_t config_file_version = 0;
|
||||
int32_t config_file_version = GSR_CONFIG_FILE_VERSION;
|
||||
bool software_encoding_warning_shown = false;
|
||||
std::string hotkeys_enable_option = "enable_hotkeys";
|
||||
std::string joystick_hotkeys_enable_option = "disable_hotkeys";
|
||||
std::string tint_color;
|
||||
ConfigHotkey show_hide_hotkey;
|
||||
};
|
||||
|
||||
struct YoutubeStreamConfig {
|
||||
@@ -69,7 +72,7 @@ namespace gsr {
|
||||
YoutubeStreamConfig youtube;
|
||||
TwitchStreamConfig twitch;
|
||||
CustomStreamConfig custom;
|
||||
ConfigHotkey start_stop_recording_hotkey;
|
||||
ConfigHotkey start_stop_hotkey;
|
||||
};
|
||||
|
||||
struct RecordConfig {
|
||||
@@ -79,8 +82,8 @@ namespace gsr {
|
||||
bool show_video_saved_notifications = true;
|
||||
std::string save_directory;
|
||||
std::string container = "mp4";
|
||||
ConfigHotkey start_stop_recording_hotkey;
|
||||
ConfigHotkey pause_unpause_recording_hotkey;
|
||||
ConfigHotkey start_stop_hotkey;
|
||||
ConfigHotkey pause_unpause_hotkey;
|
||||
};
|
||||
|
||||
struct ReplayConfig {
|
||||
@@ -93,8 +96,8 @@ namespace gsr {
|
||||
std::string save_directory;
|
||||
std::string container = "mp4";
|
||||
int32_t replay_time = 60;
|
||||
ConfigHotkey start_stop_recording_hotkey;
|
||||
ConfigHotkey save_recording_hotkey;
|
||||
ConfigHotkey start_stop_hotkey;
|
||||
ConfigHotkey save_hotkey;
|
||||
};
|
||||
|
||||
struct Config {
|
||||
|
||||
@@ -9,9 +9,20 @@ namespace mgl {
|
||||
}
|
||||
|
||||
namespace gsr {
|
||||
enum HotkeyModifier : uint32_t {
|
||||
HOTKEY_MOD_LSHIFT = 1 << 0,
|
||||
HOTKEY_MOD_RSHIFT = 1 << 1,
|
||||
HOTKEY_MOD_LCTRL = 1 << 2,
|
||||
HOTKEY_MOD_RCTRL = 1 << 3,
|
||||
HOTKEY_MOD_LALT = 1 << 4,
|
||||
HOTKEY_MOD_RALT = 1 << 5,
|
||||
HOTKEY_MOD_LSUPER = 1 << 6,
|
||||
HOTKEY_MOD_RSUPER = 1 << 7
|
||||
};
|
||||
|
||||
struct Hotkey {
|
||||
uint64_t key = 0;
|
||||
uint32_t modifiers = 0;
|
||||
uint32_t key = 0; // X11 keysym
|
||||
uint32_t modifiers = 0; // HotkeyModifier
|
||||
};
|
||||
|
||||
using GlobalHotkeyCallback = std::function<void(const std::string &id)>;
|
||||
|
||||
@@ -18,11 +18,13 @@ namespace gsr {
|
||||
~GlobalHotkeysLinux() override;
|
||||
|
||||
bool start();
|
||||
bool bind_action(const std::string &id, GlobalHotkeyCallback callback) override;
|
||||
bool bind_key_press(Hotkey hotkey, const std::string &id, GlobalHotkeyCallback callback) override;
|
||||
void unbind_all_keys() override;
|
||||
void poll_events() override;
|
||||
private:
|
||||
pid_t process_id = 0;
|
||||
int pipes[2];
|
||||
int read_pipes[2];
|
||||
int write_pipes[2];
|
||||
FILE *read_file = nullptr;
|
||||
std::unordered_map<std::string, GlobalHotkeyCallback> bound_actions_by_id;
|
||||
GrabType grab_type;
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "Config.hpp"
|
||||
#include "window_texture.h"
|
||||
#include "WindowUtils.hpp"
|
||||
#include "GlobalHotkeysLinux.hpp"
|
||||
#include "GlobalHotkeysJoystick.hpp"
|
||||
|
||||
#include <mglpp/window/Window.hpp>
|
||||
#include <mglpp/window/Event.hpp>
|
||||
@@ -42,8 +44,7 @@ namespace gsr {
|
||||
Overlay& operator=(const Overlay&) = delete;
|
||||
~Overlay();
|
||||
|
||||
void handle_events(gsr::GlobalHotkeys *global_hotkeys);
|
||||
void on_event(mgl::Event &event);
|
||||
void handle_events();
|
||||
// Returns false if not visible
|
||||
bool draw();
|
||||
|
||||
@@ -62,9 +63,12 @@ namespace gsr {
|
||||
|
||||
const Config& get_config() const;
|
||||
|
||||
std::function<void(const char *hotkey_option)> on_keyboard_hotkey_changed;
|
||||
std::function<void(const char *hotkey_option)> on_joystick_hotkey_changed;
|
||||
void unbind_all_keyboard_hotkeys();
|
||||
void rebind_all_keyboard_hotkeys();
|
||||
private:
|
||||
void handle_keyboard_mapping_event();
|
||||
void on_event(mgl::Event &event);
|
||||
|
||||
void xi_setup();
|
||||
void handle_xi_events();
|
||||
void process_key_bindings(mgl::Event &event);
|
||||
@@ -176,5 +180,10 @@ namespace gsr {
|
||||
|
||||
mgl::Clock show_overlay_clock;
|
||||
double show_overlay_timeout_seconds = 0.0;
|
||||
|
||||
std::unique_ptr<GlobalHotkeys> global_hotkeys = nullptr;
|
||||
std::unique_ptr<GlobalHotkeysJoystick> global_hotkeys_js = nullptr;
|
||||
Display *x11_mapping_display = nullptr;
|
||||
XEvent x11_mapping_xev;
|
||||
};
|
||||
}
|
||||
@@ -5,18 +5,32 @@
|
||||
#include "../Config.hpp"
|
||||
|
||||
#include <functional>
|
||||
#include <mglpp/window/Event.hpp>
|
||||
|
||||
namespace gsr {
|
||||
class Overlay;
|
||||
class GsrPage;
|
||||
class PageStack;
|
||||
class ScrollablePage;
|
||||
class Subsection;
|
||||
class RadioButton;
|
||||
class Button;
|
||||
class List;
|
||||
class CustomRendererWidget;
|
||||
|
||||
enum ConfigureHotkeyType {
|
||||
NONE,
|
||||
REPLAY_START_STOP,
|
||||
REPLAY_SAVE,
|
||||
RECORD_START_STOP,
|
||||
RECORD_PAUSE_UNPAUSE,
|
||||
STREAM_START_STOP,
|
||||
SHOW_HIDE
|
||||
};
|
||||
|
||||
class GlobalSettingsPage : public StaticPage {
|
||||
public:
|
||||
GlobalSettingsPage(const GsrInfo *gsr_info, Config &config, PageStack *page_stack);
|
||||
GlobalSettingsPage(Overlay *overlay, const GsrInfo *gsr_info, Config &config, PageStack *page_stack);
|
||||
GlobalSettingsPage(const GlobalSettingsPage&) = delete;
|
||||
GlobalSettingsPage& operator=(const GlobalSettingsPage&) = delete;
|
||||
|
||||
@@ -24,21 +38,39 @@ namespace gsr {
|
||||
void save();
|
||||
void on_navigate_away_from_page() override;
|
||||
|
||||
bool on_event(mgl::Event &event, mgl::Window &window, mgl::vec2f offset) override;
|
||||
|
||||
std::function<void(bool enable, int exit_status)> on_startup_changed;
|
||||
std::function<void(const char *reason)> on_click_exit_program_button;
|
||||
std::function<void(const char *hotkey_option)> on_keyboard_hotkey_changed;
|
||||
std::function<void(const char *hotkey_option)> on_joystick_hotkey_changed;
|
||||
private:
|
||||
void load_hotkeys();
|
||||
|
||||
std::unique_ptr<Subsection> create_appearance_subsection(ScrollablePage *parent_page);
|
||||
std::unique_ptr<Subsection> create_startup_subsection(ScrollablePage *parent_page);
|
||||
std::unique_ptr<RadioButton> create_enable_keyboard_hotkeys_button();
|
||||
std::unique_ptr<RadioButton> create_enable_joystick_hotkeys_button();
|
||||
std::unique_ptr<List> create_show_hide_hotkey_options();
|
||||
std::unique_ptr<List> create_replay_hotkey_options();
|
||||
std::unique_ptr<List> create_record_hotkey_options();
|
||||
std::unique_ptr<List> create_stream_hotkey_options();
|
||||
std::unique_ptr<List> create_hotkey_control_buttons();
|
||||
std::unique_ptr<Subsection> create_hotkey_subsection(ScrollablePage *parent_page);
|
||||
std::unique_ptr<Button> create_exit_program_button();
|
||||
std::unique_ptr<Button> create_go_back_to_old_ui_button();
|
||||
std::unique_ptr<Subsection> create_application_options_subsection(ScrollablePage *parent_page);
|
||||
std::unique_ptr<Subsection> create_application_info_subsection(ScrollablePage *parent_page);
|
||||
void add_widgets();
|
||||
|
||||
Button* configure_hotkey_get_button_by_active_type();
|
||||
ConfigHotkey* configure_hotkey_get_config_by_active_type();
|
||||
void for_each_config_hotkey(std::function<void(ConfigHotkey *config_hotkey)> callback);
|
||||
void configure_hotkey_start(ConfigureHotkeyType hotkey_type);
|
||||
void configure_hotkey_cancel();
|
||||
void configure_hotkey_stop_and_save();
|
||||
private:
|
||||
Overlay *overlay = nullptr;
|
||||
Config &config;
|
||||
const GsrInfo *gsr_info = nullptr;
|
||||
|
||||
@@ -48,5 +80,17 @@ namespace gsr {
|
||||
RadioButton *startup_radio_button_ptr = nullptr;
|
||||
RadioButton *enable_keyboard_hotkeys_radio_button_ptr = nullptr;
|
||||
RadioButton *enable_joystick_hotkeys_radio_button_ptr = nullptr;
|
||||
|
||||
Button *turn_replay_on_off_button_ptr = nullptr;
|
||||
Button *save_replay_button_ptr = nullptr;
|
||||
Button *start_stop_recording_button_ptr = nullptr;
|
||||
Button *pause_unpause_recording_button_ptr = nullptr;
|
||||
Button *start_stop_streaming_button_ptr = nullptr;
|
||||
Button *show_hide_button_ptr = nullptr;
|
||||
|
||||
ConfigHotkey configure_config_hotkey;
|
||||
ConfigureHotkeyType configure_hotkey_type = ConfigureHotkeyType::NONE;
|
||||
|
||||
CustomRendererWidget *hotkey_overlay_ptr = nullptr;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user