Compare commits

..

5 Commits

Author SHA1 Message Date
dec05eba
8bf6e533c5 1.10.2 2026-01-20 18:45:56 +01:00
dec05eba
902fc7f6a9 Force h264 for rumble/kick 2026-01-20 18:45:32 +01:00
dec05eba
794064a8b8 Fix incorrect region captured on wayland when using monitor scaling and without letting x11 scale monitors 2026-01-20 18:31:29 +01:00
dec05eba
e44b2ec528 1.10.1 2026-01-19 22:26:40 +01:00
dec05eba
5f484bd82c Add hotkey for region/window recording 2026-01-19 22:26:03 +01:00
18 changed files with 514 additions and 309 deletions

4
TODO
View File

@@ -255,3 +255,7 @@ Make it possible to resize webcam box from top left, top right and bottom left a
The flatpak version can for some get stuck at shutdown when instant replay is running. It only happens in the flatpak version and only when instant replay is running and it happens always. Manual SIGINT on gsr-ui stops gsr-ui properly, so why does it fail when shutting down the computer when the systemd stop signal is SIGINT? Maybe its related to the flatpak version being launched through gsr-gtk. I cant personally reproduce it.
Redesign the UI to allow capturing multiple video sources. Move webcam to capture sources as well then. Maybe design the UI to work more like obs studio then, where you start recording and then add sources at capture time, with a preview.
Add option to choose video container (either flv or mpegts) for youtube livestreaming.
Get wayland cursor position for region selector, otherwise the start position before the cursor moves is off.

View File

@@ -129,6 +129,8 @@ namespace gsr {
std::string container = "mp4";
ConfigHotkey start_stop_hotkey;
ConfigHotkey pause_unpause_hotkey;
ConfigHotkey start_stop_region_hotkey;
ConfigHotkey start_stop_window_hotkey;
};
struct ReplayConfig {

View File

@@ -1,44 +1,23 @@
#pragma once
#include "CursorTracker.hpp"
#include <stdint.h>
#include <vector>
struct wl_display;
struct wl_registry;
struct wl_output;
struct zxdg_output_manager_v1;
struct zxdg_output_v1;
namespace gsr {
struct WaylandOutput {
uint32_t wl_name;
struct wl_output *output;
struct zxdg_output_v1 *xdg_output;
mgl::vec2i pos;
mgl::vec2i size;
int32_t transform;
std::string name;
};
class CursorTrackerWayland : public CursorTracker {
public:
CursorTrackerWayland(const char *card_path);
CursorTrackerWayland(const char *card_path, struct wl_display *wayland_dpy);
CursorTrackerWayland(const CursorTrackerWayland&) = delete;
CursorTrackerWayland& operator=(const CursorTrackerWayland&) = delete;
~CursorTrackerWayland();
void update() override;
std::optional<CursorInfo> get_latest_cursor_info() override;
std::vector<WaylandOutput> monitors;
struct zxdg_output_manager_v1 *xdg_output_manager = nullptr;
private:
void clear_monitors();
void set_monitor_outputs_from_xdg_output(struct wl_display *dpy);
private:
int drm_fd = -1;
mgl::vec2i latest_cursor_position; // Position of the cursor within the monitor
int latest_crtc_id = -1;
struct wl_display *wayland_dpy = nullptr;
};
}

View File

@@ -24,6 +24,8 @@
#include <array>
struct wl_display;
namespace gsr {
class DropdownButton;
class GlobalHotkeys;
@@ -49,6 +51,12 @@ namespace gsr {
ERROR,
};
enum class RecordForceType {
NONE,
REGION,
WINDOW
};
enum class ScreenshotForceType {
NONE,
REGION,
@@ -74,7 +82,7 @@ namespace gsr {
void show();
void hide_next_frame();
void toggle_show();
void toggle_record();
void toggle_record(RecordForceType force_type);
void toggle_pause();
void toggle_stream();
void toggle_replay();
@@ -151,11 +159,14 @@ namespace gsr {
void on_press_save_replay_1_min_replay();
void on_press_save_replay_10_min_replay();
bool on_press_start_replay(bool disable_notification, bool finished_selection);
void on_press_start_record(bool finished_selection);
void on_press_start_record(bool finished_selection, RecordForceType force_type);
void on_press_start_stream(bool finished_selection);
void on_press_take_screenshot(bool finished_selection, ScreenshotForceType force_type);
bool update_compositor_texture(const Monitor &monitor);
void add_region_command(std::vector<const char*> &args, char *region_str, int region_str_size);
void add_common_gpu_screen_recorder_args(std::vector<const char*> &args, const RecordOptions &record_options, const std::vector<std::string> &audio_tracks, const std::string &video_bitrate, const char *region, char *region_str, int region_str_size, const std::string &region_area_option);
std::string get_capture_target(const std::string &capture_target, const SupportedCaptureOptions &capture_options);
void force_window_on_top();
@@ -244,6 +255,8 @@ namespace gsr {
Display *x11_dpy = nullptr;
XEvent x11_mapping_xev;
struct wl_display *wayland_dpy = nullptr;
mgl::Clock replay_save_clock;
bool replay_save_show_notification = false;
ReplayStartupMode replay_startup_mode = ReplayStartupMode::TURN_ON_AT_SYSTEM_STARTUP;

View File

@@ -7,6 +7,8 @@
#include <X11/Xlib.h>
struct wl_display;
namespace gsr {
struct Region {
mgl::vec2i pos;
@@ -28,7 +30,7 @@ namespace gsr {
bool poll_events();
bool take_selection();
bool take_canceled();
Region get_selection() const;
Region get_selection(Display *x11_dpy, struct wl_display *wayland_dpy) const;
private:
void on_button_press(const void *de);
void on_button_release(const void *de);

View File

@@ -6,6 +6,8 @@
#include <optional>
#include <X11/Xlib.h>
struct wl_display;
namespace gsr {
enum class WindowCaptureType {
FOCUSED,
@@ -13,8 +15,8 @@ namespace gsr {
};
struct Monitor {
mgl::vec2i position;
mgl::vec2i size;
mgl::vec2i position; // Logical position on Wayland
mgl::vec2i size; // Logical size on Wayland
std::string name;
};
@@ -30,6 +32,7 @@ namespace gsr {
std::string get_window_manager_name(Display *display);
bool is_compositor_running(Display *dpy, int screen);
std::vector<Monitor> get_monitors(Display *dpy);
std::vector<Monitor> get_monitors_wayland(struct wl_display *dpy);
void xi_grab_all_mouse_devices(Display *dpy);
void xi_ungrab_all_mouse_devices(Display *dpy);
void xi_warp_all_mouse_devices(Display *dpy, mgl::vec2i position);

View File

@@ -26,6 +26,8 @@ namespace gsr {
REPLAY_SAVE_10_MIN,
RECORD_START_STOP,
RECORD_PAUSE_UNPAUSE,
RECORD_START_STOP_REGION,
RECORD_START_STOP_WINDOW,
STREAM_START_STOP,
TAKE_SCREENSHOT,
TAKE_SCREENSHOT_REGION,
@@ -61,6 +63,7 @@ namespace gsr {
std::unique_ptr<List> create_replay_hotkey_options();
std::unique_ptr<List> create_replay_partial_save_hotkey_options();
std::unique_ptr<List> create_record_hotkey_options();
std::unique_ptr<List> create_record_hotkey_window_region_options();
std::unique_ptr<List> create_stream_hotkey_options();
std::unique_ptr<List> create_screenshot_hotkey_options();
std::unique_ptr<List> create_screenshot_region_hotkey_options();
@@ -100,6 +103,8 @@ namespace gsr {
Button *save_replay_10_min_button_ptr = nullptr;
Button *start_stop_recording_button_ptr = nullptr;
Button *pause_unpause_recording_button_ptr = nullptr;
Button *start_stop_recording_region_button_ptr = nullptr;
Button *start_stop_recording_window_button_ptr = nullptr;
Button *start_stop_streaming_button_ptr = nullptr;
Button *take_screenshot_button_ptr = nullptr;
Button *take_screenshot_region_button_ptr = nullptr;

View File

@@ -1,4 +1,4 @@
project('gsr-ui', ['c', 'cpp'], version : '1.10.0', default_options : ['warning_level=2', 'cpp_std=c++17'], subproject_dir : 'depends')
project('gsr-ui', ['c', 'cpp'], version : '1.10.2', default_options : ['warning_level=2', 'cpp_std=c++17'], subproject_dir : 'depends')
add_project_arguments('-D_FILE_OFFSET_BITS=64', language : ['c', 'cpp'])

View File

@@ -1,7 +1,7 @@
[package]
name = "gsr-ui"
type = "executable"
version = "1.10.0"
version = "1.10.2"
platforms = ["posix"]
[lang.cpp]

View File

@@ -145,6 +145,8 @@ namespace gsr {
record_config.start_stop_hotkey = {mgl::Keyboard::F9, HOTKEY_MOD_LALT};
record_config.pause_unpause_hotkey = {mgl::Keyboard::F7, HOTKEY_MOD_LALT};
record_config.start_stop_region_hotkey = {mgl::Keyboard::F9, HOTKEY_MOD_LCTRL};
record_config.start_stop_window_hotkey = {mgl::Keyboard::F9, HOTKEY_MOD_LSHIFT};
replay_config.start_stop_hotkey = {mgl::Keyboard::F10, HOTKEY_MOD_LALT | HOTKEY_MOD_LSHIFT};
replay_config.save_hotkey = {mgl::Keyboard::F10, HOTKEY_MOD_LALT};
@@ -262,6 +264,8 @@ namespace gsr {
{"record.container", &config.record_config.container},
{"record.start_stop_hotkey", &config.record_config.start_stop_hotkey},
{"record.pause_unpause_hotkey", &config.record_config.pause_unpause_hotkey},
{"record.start_stop_region_hotkey", &config.record_config.start_stop_region_hotkey},
{"record.start_stop_window_hotkey", &config.record_config.start_stop_window_hotkey},
{"replay.record_options.record_area_option", &config.replay_config.record_options.record_area_option},
{"replay.record_options.record_area_width", &config.replay_config.record_options.record_area_width},

View File

@@ -1,11 +1,10 @@
#include "../../include/CursorTracker/CursorTrackerWayland.hpp"
#include "../../include/WindowUtils.hpp"
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
#include <wayland-client.h>
#include "xdg-output-unstable-v1-client-protocol.h"
namespace gsr {
static const int MAX_CONNECTORS = 32;
@@ -136,177 +135,14 @@ namespace gsr {
}
// Name is the crtc name. TODO: verify if this works on all wayland compositors
static const WaylandOutput* get_wayland_monitor_by_name(const std::vector<WaylandOutput> &monitors, const std::string &name) {
for(const WaylandOutput &monitor : monitors) {
static const Monitor* get_wayland_monitor_by_name(const std::vector<Monitor> &monitors, const std::string &name) {
for(const Monitor &monitor : monitors) {
if(monitor.name == name)
return &monitor;
}
return nullptr;
}
static WaylandOutput* get_wayland_monitor_by_output(CursorTrackerWayland &cursor_tracker_wayland, struct wl_output *output) {
for(WaylandOutput &monitor : cursor_tracker_wayland.monitors) {
if(monitor.output == output)
return &monitor;
}
return nullptr;
}
static void output_handle_geometry(void *data, struct wl_output *wl_output,
int32_t x, int32_t y, int32_t phys_width, int32_t phys_height,
int32_t subpixel, const char *make, const char *model,
int32_t transform) {
(void)wl_output;
(void)phys_width;
(void)phys_height;
(void)subpixel;
(void)make;
(void)model;
CursorTrackerWayland *cursor_tracker_wayland = (CursorTrackerWayland*)data;
WaylandOutput *monitor = get_wayland_monitor_by_output(*cursor_tracker_wayland, wl_output);
if(!monitor)
return;
monitor->pos.x = x;
monitor->pos.y = y;
monitor->transform = transform;
}
static void output_handle_mode(void *data, struct wl_output *wl_output, uint32_t flags, int32_t width, int32_t height, int32_t refresh) {
(void)wl_output;
(void)flags;
(void)refresh;
CursorTrackerWayland *cursor_tracker_wayland = (CursorTrackerWayland*)data;
WaylandOutput *monitor = get_wayland_monitor_by_output(*cursor_tracker_wayland, wl_output);
if(!monitor)
return;
monitor->size.x = width;
monitor->size.y = height;
}
static void output_handle_done(void *data, struct wl_output *wl_output) {
(void)data;
(void)wl_output;
}
static void output_handle_scale(void* data, struct wl_output *wl_output, int32_t factor) {
(void)data;
(void)wl_output;
(void)factor;
}
static void output_handle_name(void *data, struct wl_output *wl_output, const char *name) {
(void)wl_output;
CursorTrackerWayland *cursor_tracker_wayland = (CursorTrackerWayland*)data;
WaylandOutput *monitor = get_wayland_monitor_by_output(*cursor_tracker_wayland, wl_output);
if(!monitor)
return;
monitor->name = name;
}
static void output_handle_description(void *data, struct wl_output *wl_output, const char *description) {
(void)data;
(void)wl_output;
(void)description;
}
static const struct wl_output_listener output_listener = {
output_handle_geometry,
output_handle_mode,
output_handle_done,
output_handle_scale,
output_handle_name,
output_handle_description,
};
static void registry_add_object(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version) {
(void)version;
CursorTrackerWayland *cursor_tracker_wayland = (CursorTrackerWayland*)data;
if(strcmp(interface, wl_output_interface.name) == 0) {
if(version < 4) {
fprintf(stderr, "Warning: wl output interface version is < 4, expected >= 4\n");
return;
}
struct wl_output *output = (struct wl_output*)wl_registry_bind(registry, name, &wl_output_interface, 4);
cursor_tracker_wayland->monitors.push_back(
WaylandOutput{
name,
output,
nullptr,
mgl::vec2i{0, 0},
mgl::vec2i{0, 0},
0,
""
});
wl_output_add_listener(output, &output_listener, cursor_tracker_wayland);
} else if(strcmp(interface, zxdg_output_manager_v1_interface.name) == 0) {
if(version < 1) {
fprintf(stderr, "Warning: xdg output interface version is < 1, expected >= 1\n");
return;
}
if(cursor_tracker_wayland->xdg_output_manager) {
zxdg_output_manager_v1_destroy(cursor_tracker_wayland->xdg_output_manager);
cursor_tracker_wayland->xdg_output_manager = NULL;
}
cursor_tracker_wayland->xdg_output_manager = (struct zxdg_output_manager_v1*)wl_registry_bind(registry, name, &zxdg_output_manager_v1_interface, 1);
}
}
static void registry_remove_object(void *data, struct wl_registry *registry, uint32_t name) {
(void)data;
(void)registry;
(void)name;
// TODO: Remove output
}
static struct wl_registry_listener registry_listener = {
registry_add_object,
registry_remove_object,
};
static void xdg_output_logical_position(void *data, struct zxdg_output_v1 *zxdg_output_v1, int32_t x, int32_t y) {
(void)zxdg_output_v1;
WaylandOutput *monitor = (WaylandOutput*)data;
monitor->pos.x = x;
monitor->pos.y = y;
}
static void xdg_output_handle_logical_size(void *data, struct zxdg_output_v1 *xdg_output, int32_t width, int32_t height) {
(void)data;
(void)xdg_output;
(void)width;
(void)height;
}
static void xdg_output_handle_done(void *data, struct zxdg_output_v1 *xdg_output) {
(void)data;
(void)xdg_output;
}
static void xdg_output_handle_name(void *data, struct zxdg_output_v1 *xdg_output, const char *name) {
(void)data;
(void)xdg_output;
(void)name;
}
static void xdg_output_handle_description(void *data, struct zxdg_output_v1 *xdg_output, const char *description) {
(void)data;
(void)xdg_output;
(void)description;
}
static const struct zxdg_output_v1_listener xdg_output_listener = {
xdg_output_logical_position,
xdg_output_handle_logical_size,
xdg_output_handle_done,
xdg_output_handle_name,
xdg_output_handle_description,
};
/* Returns nullptr if not found */
static drm_connector* get_drm_connector_by_crtc_id(drm_connectors *connectors, uint32_t crtc_id) {
for(int i = 0; i < connectors->num_connectors; ++i) {
@@ -390,7 +226,7 @@ namespace gsr {
drmModeFreeResources(resources);
}
CursorTrackerWayland::CursorTrackerWayland(const char *card_path) {
CursorTrackerWayland::CursorTrackerWayland(const char *card_path, struct wl_display *wayland_dpy) : wayland_dpy(wayland_dpy) {
drm_fd = open(card_path, O_RDONLY);
if(drm_fd <= 0) {
fprintf(stderr, "Error: CursorTrackerWayland: failed to open %s\n", card_path);
@@ -402,7 +238,6 @@ namespace gsr {
}
CursorTrackerWayland::~CursorTrackerWayland() {
clear_monitors();
if(drm_fd > 0)
close(drm_fd);
}
@@ -465,80 +300,19 @@ namespace gsr {
drmModeFreePlaneResources(planes);
}
void CursorTrackerWayland::set_monitor_outputs_from_xdg_output(struct wl_display *dpy) {
if(!xdg_output_manager) {
fprintf(stderr, "Warning: CursorTrackerWayland::set_monitor_outputs_from_xdg_output: zxdg_output_manager not found. Registered monitor positions might be incorrect\n");
return;
}
for(WaylandOutput &monitor : monitors) {
monitor.xdg_output = zxdg_output_manager_v1_get_xdg_output(xdg_output_manager, monitor.output);
zxdg_output_v1_add_listener(monitor.xdg_output, &xdg_output_listener, &monitor);
}
// Fetch xdg_output
wl_display_roundtrip(dpy);
}
void CursorTrackerWayland::clear_monitors() {
for(WaylandOutput &monitor : monitors) {
if(monitor.output) {
wl_output_destroy(monitor.output);
monitor.output = nullptr;
}
if(monitor.xdg_output) {
zxdg_output_v1_destroy(monitor.xdg_output);
monitor.xdg_output = nullptr;
}
}
monitors.clear();
}
std::optional<CursorInfo> CursorTrackerWayland::get_latest_cursor_info() {
if(drm_fd <= 0 || latest_crtc_id == -1)
if(drm_fd <= 0 || latest_crtc_id == -1 || !wayland_dpy)
return std::nullopt;
std::string monitor_name = get_monitor_name_from_crtc_id(drm_fd, latest_crtc_id);
if(monitor_name.empty())
return std::nullopt;
struct wl_display *dpy = wl_display_connect(nullptr);
if(!dpy) {
fprintf(stderr, "Error: CursorTrackerWayland::get_latest_cursor_info: failed to connect to the wayland server\n");
const std::vector<Monitor> wayland_monitors = get_monitors_wayland(wayland_dpy);
const Monitor *wayland_monitor = get_wayland_monitor_by_name(wayland_monitors, monitor_name);
if(!wayland_monitor)
return std::nullopt;
}
clear_monitors();
struct wl_registry *registry = wl_display_get_registry(dpy);
wl_registry_add_listener(registry, &registry_listener, this);
// Fetch globals
wl_display_roundtrip(dpy);
// Fetch wl_output
wl_display_roundtrip(dpy);
set_monitor_outputs_from_xdg_output(dpy);
mgl::vec2i cursor_position = latest_cursor_position;
const WaylandOutput *wayland_monitor = get_wayland_monitor_by_name(monitors, monitor_name);
if(!wayland_monitor) {
clear_monitors();
return std::nullopt;
}
cursor_position = wayland_monitor->pos + latest_cursor_position;
clear_monitors();
if(xdg_output_manager) {
zxdg_output_manager_v1_destroy(xdg_output_manager);
xdg_output_manager = nullptr;
}
wl_registry_destroy(registry);
wl_display_disconnect(dpy);
return CursorInfo{ cursor_position, std::move(monitor_name) };
return CursorInfo{ wayland_monitor->position + latest_cursor_position, std::move(monitor_name) };
}
}

View File

@@ -39,6 +39,9 @@
#include <X11/extensions/XInput2.h>
#include <X11/extensions/shapeconst.h>
#include <X11/Xcursor/Xcursor.h>
#include <wayland-client.h>
#include <mglpp/system/Rect.hpp>
#include <mglpp/window/Event.hpp>
#include <mglpp/system/Utf8.hpp>
@@ -323,7 +326,7 @@ namespace gsr {
config_hotkey_to_hotkey(overlay->get_config().record_config.start_stop_hotkey),
"record", [overlay](const std::string &id) {
fprintf(stderr, "pressed %s\n", id.c_str());
overlay->toggle_record();
overlay->toggle_record(RecordForceType::NONE);
});
global_hotkeys->bind_key_press(
@@ -333,6 +336,20 @@ namespace gsr {
overlay->toggle_pause();
});
global_hotkeys->bind_key_press(
config_hotkey_to_hotkey(overlay->get_config().record_config.start_stop_region_hotkey),
"record_region", [overlay](const std::string &id) {
fprintf(stderr, "pressed %s\n", id.c_str());
overlay->toggle_record(RecordForceType::REGION);
});
global_hotkeys->bind_key_press(
config_hotkey_to_hotkey(overlay->get_config().record_config.start_stop_window_hotkey),
"record_window", [overlay](const std::string &id) {
fprintf(stderr, "pressed %s\n", id.c_str());
overlay->toggle_record(RecordForceType::WINDOW);
});
global_hotkeys->bind_key_press(
config_hotkey_to_hotkey(overlay->get_config().streaming_config.start_stop_hotkey),
"stream", [overlay](const std::string &id) {
@@ -441,7 +458,7 @@ namespace gsr {
global_hotkeys_js->bind_action("toggle_record", [overlay](const std::string &id) {
fprintf(stderr, "pressed %s\n", id.c_str());
overlay->toggle_record();
overlay->toggle_record(RecordForceType::NONE);
});
global_hotkeys_js->bind_action("toggle_replay", [overlay](const std::string &id) {
@@ -473,6 +490,14 @@ namespace gsr {
top_bar_background({0.0f, 0.0f}),
close_button_widget({0.0f, 0.0f})
{
if(this->gsr_info.system_info.display_server == DisplayServer::WAYLAND) {
wayland_dpy = wl_display_connect(nullptr);
if(!wayland_dpy)
fprintf(stderr, "Warning: failed to connect to the wayland server\n");
} else {
wayland_dpy = nullptr;
}
gsr_icon_path = this->resources_path + "images/gpu_screen_recorder_logo.png";
key_bindings[0].key_event.code = mgl::Keyboard::Escape;
@@ -516,7 +541,7 @@ namespace gsr {
cursor_tracker = std::make_unique<CursorTrackerX11>((Display*)mgl_get_context()->connection);
else if(this->gsr_info.system_info.display_server == DisplayServer::WAYLAND) {
if(!this->gsr_info.gpu_info.card_path.empty())
cursor_tracker = std::make_unique<CursorTrackerWayland>(this->gsr_info.gpu_info.card_path.c_str());
cursor_tracker = std::make_unique<CursorTrackerWayland>(this->gsr_info.gpu_info.card_path.c_str(), wayland_dpy);
if(!config.main_config.wayland_warning_shown) {
config.main_config.wayland_warning_shown = true;
@@ -568,6 +593,9 @@ namespace gsr {
if(x11_dpy)
XCloseDisplay(x11_dpy);
if(wayland_dpy)
wl_display_disconnect(wayland_dpy);
}
void Overlay::xi_setup() {
@@ -1285,7 +1313,7 @@ namespace gsr {
} else if(id == "pause") {
toggle_pause();
} else if(id == "start") {
on_press_start_record(false);
on_press_start_record(false, RecordForceType::NONE);
}
};
button->set_item_enabled("pause", false);
@@ -1529,8 +1557,8 @@ namespace gsr {
}
}
void Overlay::toggle_record() {
on_press_start_record(false);
void Overlay::toggle_record(RecordForceType force_type) {
on_press_start_record(false, force_type);
}
void Overlay::toggle_pause() {
@@ -2493,8 +2521,8 @@ namespace gsr {
return result;
}
static void add_region_command(std::vector<const char*> &args, char *region_str, int region_str_size, const RegionSelector &region_selector) {
Region region = region_selector.get_selection();
void Overlay::add_region_command(std::vector<const char*> &args, char *region_str, int region_str_size) {
Region region = region_selector.get_selection(x11_dpy, wayland_dpy);
if(region.size.x <= 32 && region.size.y <= 32) {
region.size.x = 0;
region.size.y = 0;
@@ -2504,7 +2532,7 @@ namespace gsr {
args.push_back(region_str);
}
static void add_common_gpu_screen_recorder_args(std::vector<const char*> &args, const RecordOptions &record_options, const std::vector<std::string> &audio_tracks, const std::string &video_bitrate, const char *region, char *region_str, int region_str_size, const RegionSelector &region_selector) {
void Overlay::add_common_gpu_screen_recorder_args(std::vector<const char*> &args, const RecordOptions &record_options, const std::vector<std::string> &audio_tracks, const std::string &video_bitrate, const char *region, char *region_str, int region_str_size, const std::string &region_area_option) {
if(record_options.video_quality == "custom") {
args.push_back("-bm");
args.push_back("cbr");
@@ -2515,7 +2543,7 @@ namespace gsr {
args.push_back(record_options.video_quality.c_str());
}
if(record_options.record_area_option == "focused" || record_options.change_video_resolution) {
if(region_area_option == "focused" || record_options.change_video_resolution) {
args.push_back("-s");
args.push_back(region);
}
@@ -2535,8 +2563,8 @@ namespace gsr {
args.push_back("yes");
}
if(record_options.record_area_option == "region")
add_region_command(args, region_str, region_str_size, region_selector);
if(region_area_option == "region")
add_region_command(args, region_str, region_str_size);
}
static bool validate_capture_target(const std::string &capture_target, const SupportedCaptureOptions &capture_options) {
@@ -2892,7 +2920,7 @@ namespace gsr {
}
char region_str[128];
add_common_gpu_screen_recorder_args(args, config.replay_config.record_options, audio_tracks, video_bitrate, size, region_str, sizeof(region_str), region_selector);
add_common_gpu_screen_recorder_args(args, config.replay_config.record_options, audio_tracks, video_bitrate, size, region_str, sizeof(region_str), config.replay_config.record_options.record_area_option);
if(gsr_info.system_info.gsr_version >= GsrVersion{5, 4, 0}) {
args.push_back("-ro");
@@ -2941,7 +2969,7 @@ namespace gsr {
return true;
}
void Overlay::on_press_start_record(bool finished_selection) {
void Overlay::on_press_start_record(bool finished_selection, RecordForceType force_type) {
if(region_selector.is_started() || window_selector.is_started())
return;
@@ -3043,27 +3071,40 @@ namespace gsr {
update_upause_status();
std::string record_area_option;
switch(force_type) {
case RecordForceType::NONE:
record_area_option = config.record_config.record_options.record_area_option;
break;
case RecordForceType::REGION:
record_area_option = "region";
break;
case RecordForceType::WINDOW:
record_area_option = gsr_info.system_info.display_server == DisplayServer::X11 ? "window" : "portal";
break;
}
const SupportedCaptureOptions capture_options = get_supported_capture_options(gsr_info);
recording_capture_target = get_capture_target(config.record_config.record_options.record_area_option, capture_options);
if(!validate_capture_target(config.record_config.record_options.record_area_option, capture_options)) {
recording_capture_target = get_capture_target(record_area_option, capture_options);
if(!validate_capture_target(record_area_option, capture_options)) {
char err_msg[256];
snprintf(err_msg, sizeof(err_msg), "Failed to start recording, capture target \"%s\" is invalid.\nPlease change capture target in settings", recording_capture_target.c_str());
show_notification(err_msg, notification_error_timeout_seconds, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::RECORD, nullptr, NotificationLevel::ERROR);
return;
}
if(config.record_config.record_options.record_area_option == "region" && !finished_selection) {
if(record_area_option == "region" && !finished_selection) {
start_region_capture = true;
on_region_selected = [this]() {
on_press_start_record(true);
on_region_selected = [this, force_type]() {
on_press_start_record(true, force_type);
};
return;
}
if(config.record_config.record_options.record_area_option == "window" && !finished_selection) {
if(record_area_option == "window" && !finished_selection) {
start_window_capture = true;
on_window_selected = [this]() {
on_press_start_record(true);
on_window_selected = [this, force_type]() {
on_press_start_record(true, force_type);
};
return;
}
@@ -3083,10 +3124,10 @@ namespace gsr {
char size[64];
size[0] = '\0';
if(config.record_config.record_options.record_area_option == "focused")
if(record_area_option == "focused")
snprintf(size, sizeof(size), "%dx%d", (int)config.record_config.record_options.record_area_width, (int)config.record_config.record_options.record_area_height);
if(config.record_config.record_options.record_area_option != "focused" && config.record_config.record_options.change_video_resolution)
if(record_area_option != "focused" && config.record_config.record_options.change_video_resolution)
snprintf(size, sizeof(size), "%dx%d", (int)config.record_config.record_options.video_width, (int)config.record_config.record_options.video_height);
const std::string capture_source_arg = compose_capture_source_arg(recording_capture_target, config.record_config.record_options);
@@ -3106,7 +3147,7 @@ namespace gsr {
};
char region_str[128];
add_common_gpu_screen_recorder_args(args, config.record_config.record_options, audio_tracks, video_bitrate, size, region_str, sizeof(region_str), region_selector);
add_common_gpu_screen_recorder_args(args, config.record_config.record_options, audio_tracks, video_bitrate, size, region_str, sizeof(region_str), record_area_option);
args.push_back(nullptr);
@@ -3139,7 +3180,7 @@ namespace gsr {
show_notification(msg, short_notification_timeout_seconds, get_color_theme().tint_color, get_color_theme().tint_color, NotificationType::RECORD, recording_capture_target.c_str());
}
if(config.record_config.record_options.record_area_option == "portal")
if(record_area_option == "portal")
hide_ui = true;
// TODO: This will be incorrect if the user uses portal capture, as capture wont start until the user has
@@ -3160,7 +3201,6 @@ namespace gsr {
url += "rtmp://rtmp.rumble.com/live/";
url += config.streaming_config.rumble.stream_key;
} else if(config.streaming_config.streaming_service == "kick") {
fprintf(stderr, "kick: %s, %s\n", config.streaming_config.kick.stream_url.c_str(), config.streaming_config.kick.stream_key.c_str());
url += config.streaming_config.kick.stream_url;
if(!url.empty() && url.back() != '/')
url += "/";
@@ -3278,6 +3318,10 @@ namespace gsr {
choose_video_codec_and_container_with_fallback(gsr_info, &video_codec, &container, &encoder);
const std::string url = streaming_get_url(config);
if(config.streaming_config.streaming_service == "rumble" || config.streaming_config.streaming_service == "kick") {
fprintf(stderr, "Info: forcing video codec to h264 as rumble/kick supports only h264\n");
video_codec = "h264";
}
char size[64];
size[0] = '\0';
@@ -3304,7 +3348,7 @@ namespace gsr {
};
char region_str[128];
add_common_gpu_screen_recorder_args(args, config.streaming_config.record_options, audio_tracks, video_bitrate, size, region_str, sizeof(region_str), region_selector);
add_common_gpu_screen_recorder_args(args, config.streaming_config.record_options, audio_tracks, video_bitrate, size, region_str, sizeof(region_str), config.streaming_config.record_options.record_area_option);
if(gsr_info.system_info.gsr_version >= GsrVersion{5, 4, 0}) {
args.push_back("-ro");
@@ -3436,7 +3480,7 @@ namespace gsr {
char region_str[128];
if(record_area_option == "region")
add_region_command(args, region_str, sizeof(region_str), region_selector);
add_region_command(args, region_str, sizeof(region_str));
args.push_back(nullptr);

View File

@@ -166,6 +166,62 @@ namespace gsr {
return ((uint32_t)color.a << 24) | (((uint32_t)color.r * color.a / 0xFF) << 16) | (((uint32_t)color.g * color.a / 0xFF) << 8) | ((uint32_t)color.b * color.a / 0xFF);
}
static const Monitor* get_monitor_by_region_center(const std::vector<Monitor> &monitors, Region region) {
const mgl::vec2i center = {region.pos.x + region.size.x / 2, region.pos.y + region.size.y / 2};
for(const Monitor &monitor : monitors) {
if(center.x >= monitor.position.x && center.x <= monitor.position.x + monitor.size.x
&& center.y >= monitor.position.y && center.y <= monitor.position.y + monitor.size.y)
{
return &monitor;
}
}
return nullptr;
}
// Name is the x11 name. TODO: verify if this works on all wayland compositors
static const Monitor* get_wayland_monitor_by_name(const std::vector<Monitor> &monitors, const std::string &name) {
for(const Monitor &monitor : monitors) {
if(monitor.name == name)
return &monitor;
}
return nullptr;
}
static mgl::vec2d to_vec2d(mgl::vec2i v) {
return { (double)v.x, (double)v.y };
}
static Region x11_region_to_wayland_region(Display *dpy, struct wl_display *wayland_dpy, Region x11_region) {
const std::vector<Monitor> x11_monitors = get_monitors(dpy);
const Monitor *x11_selected_monitor = get_monitor_by_region_center(x11_monitors, x11_region);
if(!x11_selected_monitor) {
fprintf(stderr, "Warning: RegionSelector: failed to get x11 monitor\n");
return x11_region;
}
const std::vector<Monitor> wayland_monitors = get_monitors_wayland(wayland_dpy);
const Monitor *wayland_monitor = get_wayland_monitor_by_name(wayland_monitors, x11_selected_monitor->name);
if(!wayland_monitor) {
fprintf(stderr, "Warning: RegionSelector: failed to get wayland monitor\n");
return x11_region;
}
const mgl::vec2d region_relative_pos = {
(double)(x11_region.pos.x - x11_selected_monitor->position.x) / (double)x11_selected_monitor->size.x,
(double)(x11_region.pos.y - x11_selected_monitor->position.y) / (double)x11_selected_monitor->size.y,
};
const mgl::vec2d region_relative_size = {
(double)x11_region.size.x / (double)x11_selected_monitor->size.x,
(double)x11_region.size.y / (double)x11_selected_monitor->size.y,
};
return Region {
wayland_monitor->position + (region_relative_pos * to_vec2d(wayland_monitor->size)).to_vec2i(),
(region_relative_size * to_vec2d(wayland_monitor->size)).to_vec2i(),
};
}
RegionSelector::RegionSelector() {
}
@@ -385,8 +441,11 @@ namespace gsr {
return result;
}
Region RegionSelector::get_selection() const {
return region;
Region RegionSelector::get_selection(Display *x11_dpy, struct wl_display *wayland_dpy) const {
Region returned_region = region;
if(is_wayland && x11_dpy && wayland_dpy)
returned_region = x11_region_to_wayland_region(x11_dpy, wayland_dpy, returned_region);
return returned_region;
}
void RegionSelector::on_button_press(const void *de) {

View File

@@ -8,6 +8,9 @@
#include <X11/extensions/shapeconst.h>
#include <X11/extensions/Xrandr.h>
#include <wayland-client.h>
#include "xdg-output-unstable-v1-client-protocol.h"
#include <mglpp/system/Utf8.hpp>
extern "C" {
@@ -23,6 +26,209 @@ extern "C" {
#define MAX_PROPERTY_VALUE_LEN 4096
namespace gsr {
struct WaylandOutput {
uint32_t wl_name;
struct wl_output *output;
struct zxdg_output_v1 *xdg_output;
mgl::vec2i pos;
mgl::vec2i size;
int32_t transform;
std::string name;
};
struct Wayland {
std::vector<WaylandOutput> outputs;
struct zxdg_output_manager_v1 *xdg_output_manager = nullptr;
};
static WaylandOutput* get_wayland_monitor_by_output(Wayland &wayland, struct wl_output *output) {
for(WaylandOutput &monitor : wayland.outputs) {
if(monitor.output == output)
return &monitor;
}
return nullptr;
}
static void output_handle_geometry(void *data, struct wl_output *wl_output,
int32_t x, int32_t y, int32_t phys_width, int32_t phys_height,
int32_t subpixel, const char *make, const char *model,
int32_t transform) {
(void)wl_output;
(void)phys_width;
(void)phys_height;
(void)subpixel;
(void)make;
(void)model;
Wayland *wayland = (Wayland*)data;
WaylandOutput *monitor = get_wayland_monitor_by_output(*wayland, wl_output);
if(!monitor)
return;
monitor->pos.x = x;
monitor->pos.y = y;
monitor->transform = transform;
}
static void output_handle_mode(void *data, struct wl_output *wl_output, uint32_t flags, int32_t width, int32_t height, int32_t refresh) {
(void)wl_output;
(void)flags;
(void)refresh;
Wayland *wayland = (Wayland*)data;
WaylandOutput *monitor = get_wayland_monitor_by_output(*wayland, wl_output);
if(!monitor)
return;
monitor->size.x = width;
monitor->size.y = height;
}
static void output_handle_done(void *data, struct wl_output *wl_output) {
(void)data;
(void)wl_output;
}
static void output_handle_scale(void* data, struct wl_output *wl_output, int32_t factor) {
(void)data;
(void)wl_output;
(void)factor;
}
static void output_handle_name(void *data, struct wl_output *wl_output, const char *name) {
(void)wl_output;
Wayland *wayland = (Wayland*)data;
WaylandOutput *monitor = get_wayland_monitor_by_output(*wayland, wl_output);
if(!monitor)
return;
monitor->name = name;
}
static void output_handle_description(void *data, struct wl_output *wl_output, const char *description) {
(void)data;
(void)wl_output;
(void)description;
}
static const struct wl_output_listener output_listener = {
output_handle_geometry,
output_handle_mode,
output_handle_done,
output_handle_scale,
output_handle_name,
output_handle_description,
};
static void registry_add_object(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version) {
(void)version;
Wayland *wayland = (Wayland*)data;
if(strcmp(interface, wl_output_interface.name) == 0) {
if(version < 4) {
fprintf(stderr, "Warning: wl output interface version is < 4, expected >= 4\n");
return;
}
struct wl_output *output = (struct wl_output*)wl_registry_bind(registry, name, &wl_output_interface, 4);
wayland->outputs.push_back(
WaylandOutput{
name,
output,
nullptr,
mgl::vec2i{0, 0},
mgl::vec2i{0, 0},
0,
""
});
wl_output_add_listener(output, &output_listener, wayland);
} else if(strcmp(interface, zxdg_output_manager_v1_interface.name) == 0) {
if(version < 1) {
fprintf(stderr, "Warning: xdg output interface version is < 1, expected >= 1\n");
return;
}
if(wayland->xdg_output_manager) {
zxdg_output_manager_v1_destroy(wayland->xdg_output_manager);
wayland->xdg_output_manager = NULL;
}
wayland->xdg_output_manager = (struct zxdg_output_manager_v1*)wl_registry_bind(registry, name, &zxdg_output_manager_v1_interface, 1);
}
}
static void registry_remove_object(void *data, struct wl_registry *registry, uint32_t name) {
(void)data;
(void)registry;
(void)name;
// TODO: Remove output
}
static struct wl_registry_listener registry_listener = {
registry_add_object,
registry_remove_object,
};
static void xdg_output_logical_position(void *data, struct zxdg_output_v1 *zxdg_output_v1, int32_t x, int32_t y) {
(void)zxdg_output_v1;
WaylandOutput *monitor = (WaylandOutput*)data;
monitor->pos.x = x;
monitor->pos.y = y;
}
static void xdg_output_handle_logical_size(void *data, struct zxdg_output_v1 *xdg_output, int32_t width, int32_t height) {
(void)xdg_output;
WaylandOutput *monitor = (WaylandOutput*)data;
monitor->size.x = width;
monitor->size.y = height;
}
static void xdg_output_handle_done(void *data, struct zxdg_output_v1 *xdg_output) {
(void)data;
(void)xdg_output;
}
static void xdg_output_handle_name(void *data, struct zxdg_output_v1 *xdg_output, const char *name) {
(void)data;
(void)xdg_output;
(void)name;
}
static void xdg_output_handle_description(void *data, struct zxdg_output_v1 *xdg_output, const char *description) {
(void)data;
(void)xdg_output;
(void)description;
}
static const struct zxdg_output_v1_listener xdg_output_listener = {
xdg_output_logical_position,
xdg_output_handle_logical_size,
xdg_output_handle_done,
xdg_output_handle_name,
xdg_output_handle_description,
};
static const int transform_90 = 1;
static const int transform_270 = 3;
static void transform_monitors(Wayland &wayland) {
for(WaylandOutput &output : wayland.outputs) {
if(output.transform == transform_90 || output.transform == transform_270)
std::swap(output.size.x, output.size.y);
}
}
static void set_monitor_outputs_from_xdg_output(Wayland &wayland, struct wl_display *dpy) {
if(!wayland.xdg_output_manager) {
fprintf(stderr, "Warning: WindowUtils::set_monitor_outputs_from_xdg_output: zxdg_output_manager not found. Registered monitor positions might be incorrect\n");
return;
}
for(WaylandOutput &monitor : wayland.outputs) {
monitor.xdg_output = zxdg_output_manager_v1_get_xdg_output(wayland.xdg_output_manager, monitor.output);
zxdg_output_v1_add_listener(monitor.xdg_output, &xdg_output_listener, &monitor);
}
// Fetch xdg_output
wl_display_roundtrip(dpy);
}
static unsigned char* window_get_property(Display *dpy, Window window, Atom property_type, const char *property_name, unsigned int *property_size) {
Atom ret_property_type = None;
int ret_format = 0;
@@ -519,6 +725,47 @@ namespace gsr {
return monitors;
}
std::vector<Monitor> get_monitors_wayland(struct wl_display *dpy) {
Wayland wayland;
struct wl_registry *registry = wl_display_get_registry(dpy);
wl_registry_add_listener(registry, &registry_listener, &wayland);
// Fetch globals
wl_display_roundtrip(dpy);
// Fetch wl_output
wl_display_roundtrip(dpy);
transform_monitors(wayland);
set_monitor_outputs_from_xdg_output(wayland, dpy);
std::vector<Monitor> monitors;
for(WaylandOutput &output : wayland.outputs) {
monitors.push_back(Monitor{output.pos, output.size, std::move(output.name)});
if(output.output) {
wl_output_destroy(output.output);
output.output = nullptr;
}
if(output.xdg_output) {
zxdg_output_v1_destroy(output.xdg_output);
output.xdg_output = nullptr;
}
}
wayland.outputs.clear();
if(wayland.xdg_output_manager) {
zxdg_output_manager_v1_destroy(wayland.xdg_output_manager);
wayland.xdg_output_manager = nullptr;
}
wl_registry_destroy(registry);
return monitors;
}
static bool device_is_mouse(const XIDeviceInfo *dev) {
for(int i = 0; i < dev->num_classes; ++i) {
if(dev->classes[i]->type == XIMasterPointer || dev->classes[i]->type == XISlavePointer)

View File

@@ -304,6 +304,36 @@ namespace gsr {
return list;
}
std::unique_ptr<List> GlobalSettingsPage::create_record_hotkey_window_region_options() {
auto list = std::make_unique<List>(List::Orientation::HORIZONTAL, List::Alignment::CENTER);
list->add_widget(std::make_unique<Label>(&get_theme().body_font, "Start/stop recording a region:", get_color_theme().text_color));
auto start_stop_recording_region_button = std::make_unique<Button>(&get_theme().body_font, "", mgl::vec2f(0.0f, 0.0f), mgl::Color(0, 0, 0, 120));
start_stop_recording_region_button_ptr = start_stop_recording_region_button.get();
list->add_widget(std::move(start_stop_recording_region_button));
char str[128];
if(gsr_info->system_info.display_server == DisplayServer::X11)
snprintf(str, sizeof(str), "Start/stop recording a window:");
else
snprintf(str, sizeof(str), "Start/stop recording with desktop portal:");
list->add_widget(std::make_unique<Label>(&get_theme().body_font, str, get_color_theme().text_color));
auto start_stop_recording_window_button = std::make_unique<Button>(&get_theme().body_font, "", mgl::vec2f(0.0f, 0.0f), mgl::Color(0, 0, 0, 120));
start_stop_recording_window_button_ptr = start_stop_recording_window_button.get();
list->add_widget(std::move(start_stop_recording_window_button));
start_stop_recording_region_button_ptr->on_click = [this] {
configure_hotkey_start(ConfigureHotkeyType::RECORD_START_STOP_REGION);
};
start_stop_recording_window_button_ptr->on_click = [this] {
configure_hotkey_start(ConfigureHotkeyType::RECORD_START_STOP_WINDOW);
};
return list;
}
std::unique_ptr<List> GlobalSettingsPage::create_stream_hotkey_options() {
auto list = std::make_unique<List>(List::Orientation::HORIZONTAL, List::Alignment::CENTER);
@@ -375,17 +405,9 @@ namespace gsr {
auto clear_hotkeys_button = std::make_unique<Button>(&get_theme().body_font, "Clear hotkeys", mgl::vec2f(0.0f, 0.0f), mgl::Color(0, 0, 0, 120));
clear_hotkeys_button->on_click = [this] {
config.streaming_config.start_stop_hotkey = {mgl::Keyboard::Unknown, 0};
config.record_config.start_stop_hotkey = {mgl::Keyboard::Unknown, 0};
config.record_config.pause_unpause_hotkey = {mgl::Keyboard::Unknown, 0};
config.replay_config.start_stop_hotkey = {mgl::Keyboard::Unknown, 0};
config.replay_config.save_hotkey = {mgl::Keyboard::Unknown, 0};
config.replay_config.save_1_min_hotkey = {mgl::Keyboard::Unknown, 0};
config.replay_config.save_10_min_hotkey = {mgl::Keyboard::Unknown, 0};
config.screenshot_config.take_screenshot_hotkey = {mgl::Keyboard::Unknown, 0};
config.screenshot_config.take_screenshot_region_hotkey = {mgl::Keyboard::Unknown, 0};
config.screenshot_config.take_screenshot_window_hotkey = {mgl::Keyboard::Unknown, 0};
config.main_config.show_hide_hotkey = {mgl::Keyboard::Unknown, 0};
for_each_config_hotkey([&](ConfigHotkey *config_hotkey_item) {
*config_hotkey_item = {mgl::Keyboard::Unknown, 0};
});
load_hotkeys();
overlay->rebind_all_keyboard_hotkeys();
};
@@ -424,6 +446,7 @@ namespace gsr {
list_ptr->add_widget(create_replay_hotkey_options());
list_ptr->add_widget(create_replay_partial_save_hotkey_options());
list_ptr->add_widget(create_record_hotkey_options());
list_ptr->add_widget(create_record_hotkey_window_region_options());
list_ptr->add_widget(create_stream_hotkey_options());
list_ptr->add_widget(create_screenshot_hotkey_options());
list_ptr->add_widget(create_screenshot_region_hotkey_options());
@@ -595,6 +618,8 @@ namespace gsr {
start_stop_recording_button_ptr->set_text(config.record_config.start_stop_hotkey.to_string());
pause_unpause_recording_button_ptr->set_text(config.record_config.pause_unpause_hotkey.to_string());
start_stop_recording_region_button_ptr->set_text(config.record_config.start_stop_region_hotkey.to_string());
start_stop_recording_window_button_ptr->set_text(config.record_config.start_stop_window_hotkey.to_string());
start_stop_streaming_button_ptr->set_text(config.streaming_config.start_stop_hotkey.to_string());
@@ -679,6 +704,10 @@ namespace gsr {
return start_stop_recording_button_ptr;
case ConfigureHotkeyType::RECORD_PAUSE_UNPAUSE:
return pause_unpause_recording_button_ptr;
case ConfigureHotkeyType::RECORD_START_STOP_REGION:
return start_stop_recording_region_button_ptr;
case ConfigureHotkeyType::RECORD_START_STOP_WINDOW:
return start_stop_recording_window_button_ptr;
case ConfigureHotkeyType::STREAM_START_STOP:
return start_stop_streaming_button_ptr;
case ConfigureHotkeyType::TAKE_SCREENSHOT:
@@ -709,6 +738,10 @@ namespace gsr {
return &config.record_config.start_stop_hotkey;
case ConfigureHotkeyType::RECORD_PAUSE_UNPAUSE:
return &config.record_config.pause_unpause_hotkey;
case ConfigureHotkeyType::RECORD_START_STOP_REGION:
return &config.record_config.start_stop_region_hotkey;
case ConfigureHotkeyType::RECORD_START_STOP_WINDOW:
return &config.record_config.start_stop_window_hotkey;
case ConfigureHotkeyType::STREAM_START_STOP:
return &config.streaming_config.start_stop_hotkey;
case ConfigureHotkeyType::TAKE_SCREENSHOT:
@@ -727,8 +760,12 @@ namespace gsr {
ConfigHotkey *config_hotkeys[] = {
&config.replay_config.start_stop_hotkey,
&config.replay_config.save_hotkey,
&config.replay_config.save_1_min_hotkey,
&config.replay_config.save_10_min_hotkey,
&config.record_config.start_stop_hotkey,
&config.record_config.pause_unpause_hotkey,
&config.record_config.start_stop_region_hotkey,
&config.record_config.start_stop_window_hotkey,
&config.streaming_config.start_stop_hotkey,
&config.screenshot_config.take_screenshot_hotkey,
&config.screenshot_config.take_screenshot_region_hotkey,
@@ -772,6 +809,15 @@ namespace gsr {
case ConfigureHotkeyType::RECORD_PAUSE_UNPAUSE:
hotkey_configure_action_name = "Pause/unpause recording";
break;
case ConfigureHotkeyType::RECORD_START_STOP_REGION:
hotkey_configure_action_name = "Start/stop recording a region";
break;
case ConfigureHotkeyType::RECORD_START_STOP_WINDOW:
if(gsr_info->system_info.display_server == DisplayServer::X11)
hotkey_configure_action_name = "Start/stop recording a window";
else
hotkey_configure_action_name = "Start/stop recording with desktop portal";
break;
case ConfigureHotkeyType::STREAM_START_STOP:
hotkey_configure_action_name = "Start/stop streaming";
break;

View File

@@ -228,6 +228,7 @@ namespace gsr {
if(!it->mjpeg_setups.empty())
webcam_video_format_box_ptr->add_item("Motion-JPEG", "mjpeg");
webcam_video_format_box_ptr->set_selected_item("auto");
webcam_video_format_box_ptr->set_selected_item(get_current_record_options().webcam_video_format);
selected_camera = *it;
@@ -551,6 +552,7 @@ namespace gsr {
Subsection *audio_subsection = dynamic_cast<Subsection*>(child_widget.get());
List *audio_track_section_items_list_ptr = dynamic_cast<List*>(audio_subsection->get_inner_widget());
List *audio_input_list_ptr = dynamic_cast<List*>(audio_track_section_items_list_ptr->get_child_widget_by_index(2));
CheckBox *application_audio_invert_checkbox_ptr = dynamic_cast<CheckBox*>(audio_track_section_items_list_ptr->get_child_widget_by_index(3));
List *application_audio_warning_list_ptr = dynamic_cast<List*>(audio_track_section_items_list_ptr->get_child_widget_by_index(4));
int num_output_devices = 0;
@@ -576,7 +578,7 @@ namespace gsr {
return true;
});
application_audio_warning_list_ptr->set_visible(num_output_devices > 0 && num_application_audio > 0);
application_audio_warning_list_ptr->set_visible(num_output_devices > 0 && (num_application_audio > 0 || application_audio_invert_checkbox_ptr->is_checked()));
return true;
});
}
@@ -668,6 +670,9 @@ namespace gsr {
std::unique_ptr<CheckBox> SettingsPage::create_application_audio_invert_checkbox() {
auto application_audio_invert_checkbox = std::make_unique<CheckBox>(&get_theme().body_font, "Record audio from all applications except the selected ones");
application_audio_invert_checkbox->set_checked(false);
application_audio_invert_checkbox->on_changed = [this](bool) {
update_application_audio_warning_visibility();
};
return application_audio_invert_checkbox;
}
@@ -1741,6 +1746,8 @@ namespace gsr {
record_options.use_led_indicator = led_indicator_checkbox_ptr->is_checked();
record_options.low_power_mode = low_power_mode_checkbox_ptr->is_checked();
// TODO: Set selected_camera_setup properly when updating and shit
if(selected_camera_setup.has_value())
webcam_box_size = clamp_keep_aspect_ratio(selected_camera_setup->resolution.to_vec2f(), webcam_box_size);

View File

@@ -56,7 +56,7 @@ static void rpc_add_commands(gsr::Rpc *rpc, gsr::Overlay *overlay) {
rpc->add_handler("toggle-record", [overlay](const std::string &name) {
fprintf(stderr, "rpc command executed: %s\n", name.c_str());
overlay->toggle_record();
overlay->toggle_record(gsr::RecordForceType::NONE);
});
rpc->add_handler("toggle-pause", [overlay](const std::string &name) {
@@ -64,6 +64,16 @@ static void rpc_add_commands(gsr::Rpc *rpc, gsr::Overlay *overlay) {
overlay->toggle_pause();
});
rpc->add_handler("toggle-record-region", [overlay](const std::string &name) {
fprintf(stderr, "rpc command executed: %s\n", name.c_str());
overlay->toggle_record(gsr::RecordForceType::REGION);
});
rpc->add_handler("toggle-record-window", [overlay](const std::string &name) {
fprintf(stderr, "rpc command executed: %s\n", name.c_str());
overlay->toggle_record(gsr::RecordForceType::WINDOW);
});
rpc->add_handler("toggle-stream", [overlay](const std::string &name) {
fprintf(stderr, "rpc command executed: %s\n", name.c_str());
overlay->toggle_stream();

View File

@@ -52,6 +52,10 @@ static void usage(void) {
printf(" Start/stop recording.\n");
printf(" toggle-pause\n");
printf(" Pause/unpause recording. Only applies to regular recording.\n");
printf(" toggle-record-region\n");
printf(" Start/stop recording a region.\n");
printf(" toggle-record-window\n");
printf(" Start/stop recording a window (or desktop portal on Wayland).\n");
printf(" toggle-stream\n");
printf(" Start/stop streaming.\n");
printf(" toggle-replay\n");
@@ -80,6 +84,8 @@ static bool is_valid_command(const char *command) {
"toggle-show",
"toggle-record",
"toggle-pause",
"toggle-record-region",
"toggle-record-window",
"toggle-stream",
"toggle-replay",
"replay-save",