aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Config.cpp41
-rw-r--r--src/GsrInfo.cpp2
-rw-r--r--src/Overlay.cpp20
-rw-r--r--src/gui/SettingsPage.cpp7
4 files changed, 60 insertions, 10 deletions
diff --git a/src/Config.cpp b/src/Config.cpp
index 4deaaf4..a9c8843 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -5,6 +5,7 @@
#include <limits.h>
#include <inttypes.h>
#include <libgen.h>
+#include <iostream>
#define FORMAT_I32 "%" PRIi32
#define FORMAT_I64 "%" PRIi64
@@ -13,6 +14,14 @@
#define CONFIG_FILE_VERSION 1
namespace gsr {
+ bool ConfigHotkey::operator==(const ConfigHotkey &other) const {
+ return keysym == other.keysym && modifiers == other.modifiers;
+ }
+
+ bool ConfigHotkey::operator!=(const ConfigHotkey &other) const {
+ return !operator==(other);
+ }
+
Config::Config(const SupportedCaptureOptions &capture_options) {
const std::string default_save_directory = get_videos_dir();
@@ -141,6 +150,38 @@ namespace gsr {
};
}
+ bool Config::operator==(const Config &other) {
+ const auto config_options = get_config_options(*this);
+ const auto config_options_other = get_config_options(const_cast<Config&>(other));
+ for(auto it : config_options) {
+ auto it_other = config_options_other.find(it.first);
+ if(it_other == config_options_other.end() || it_other->second.index() != it.second.index())
+ return false;
+
+ if(std::holds_alternative<bool*>(it.second)) {
+ if(*std::get<bool*>(it.second) != *std::get<bool*>(it_other->second))
+ return false;
+ } else if(std::holds_alternative<std::string*>(it.second)) {
+ if(*std::get<std::string*>(it.second) != *std::get<std::string*>(it_other->second))
+ return false;
+ } else if(std::holds_alternative<int32_t*>(it.second)) {
+ if(*std::get<int32_t*>(it.second) != *std::get<int32_t*>(it_other->second))
+ return false;
+ } else if(std::holds_alternative<ConfigHotkey*>(it.second)) {
+ if(*std::get<ConfigHotkey*>(it.second) != *std::get<ConfigHotkey*>(it_other->second))
+ return false;
+ } else if(std::holds_alternative<std::vector<std::string>*>(it.second)) {
+ if(*std::get<std::vector<std::string>*>(it.second) != *std::get<std::vector<std::string>*>(it_other->second))
+ return false;
+ }
+ }
+ return true;
+ }
+
+ bool Config::operator!=(const Config &other) {
+ return !operator==(other);
+ }
+
std::optional<Config> read_config(const SupportedCaptureOptions &capture_options) {
std::optional<Config> config;
diff --git a/src/GsrInfo.cpp b/src/GsrInfo.cpp
index c35ccfb..6665dc9 100644
--- a/src/GsrInfo.cpp
+++ b/src/GsrInfo.cpp
@@ -209,8 +209,6 @@ namespace gsr {
capture_options.window = true;
else if(line == "focused")
capture_options.focused = true;
- else if(line == "screen")
- capture_options.screen = true;
else if(line == "portal")
capture_options.portal = true;
else {
diff --git a/src/Overlay.cpp b/src/Overlay.cpp
index 628a862..3d6a603 100644
--- a/src/Overlay.cpp
+++ b/src/Overlay.cpp
@@ -906,6 +906,10 @@ namespace gsr {
button->on_click = [this](const std::string &id) {
if(id == "settings") {
auto replay_settings_page = std::make_unique<SettingsPage>(SettingsPage::Type::REPLAY, &gsr_info, config, &page_stack);
+ replay_settings_page->on_config_changed = [this]() {
+ if(recording_status == RecordingStatus::REPLAY)
+ show_notification("Replay settings have been modified.\nYou may need to restart replay to apply the changes.", 5.0, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::REPLAY);
+ };
page_stack.push(std::move(replay_settings_page));
} else if(id == "save") {
on_press_save_replay();
@@ -927,6 +931,10 @@ namespace gsr {
button->on_click = [this](const std::string &id) {
if(id == "settings") {
auto record_settings_page = std::make_unique<SettingsPage>(SettingsPage::Type::RECORD, &gsr_info, config, &page_stack);
+ record_settings_page->on_config_changed = [this]() {
+ if(recording_status == RecordingStatus::RECORD)
+ show_notification("Recording settings have been modified.\nYou may need to restart recording to apply the changes.", 5.0, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::RECORD);
+ };
page_stack.push(std::move(record_settings_page));
} else if(id == "pause") {
toggle_pause();
@@ -946,6 +954,10 @@ namespace gsr {
button->on_click = [this](const std::string &id) {
if(id == "settings") {
auto stream_settings_page = std::make_unique<SettingsPage>(SettingsPage::Type::STREAM, &gsr_info, config, &page_stack);
+ stream_settings_page->on_config_changed = [this]() {
+ if(recording_status == RecordingStatus::STREAM)
+ show_notification("Streaming settings have been modified.\nYou may need to restart streaming to apply the changes.", 5.0, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::STREAM);
+ };
page_stack.push(std::move(stream_settings_page));
} else if(id == "start") {
on_press_start_stream();
@@ -1318,7 +1330,7 @@ namespace gsr {
show_notification("Replay stopped", 3.0, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::REPLAY);
} else {
fprintf(stderr, "Warning: gpu-screen-recorder (%d) exited with exit status %d\n", (int)gpu_screen_recorder_process, exit_code);
- show_notification("Replay stopped because of an error", 3.0, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::REPLAY);
+ show_notification("Replay stopped because of an error. Verify if settings are correct", 3.0, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::REPLAY);
}
break;
}
@@ -1334,7 +1346,7 @@ namespace gsr {
show_notification("Streaming has stopped", 3.0, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::STREAM);
} else {
fprintf(stderr, "Warning: gpu-screen-recorder (%d) exited with exit status %d\n", (int)gpu_screen_recorder_process, exit_code);
- show_notification("Streaming stopped because of an error", 3.0, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::STREAM);
+ show_notification("Streaming stopped because of an error. Verify if settings are correct", 3.0, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::STREAM);
}
break;
}
@@ -1399,7 +1411,7 @@ namespace gsr {
}
} else {
fprintf(stderr, "Warning: gpu-screen-recorder (%d) exited with exit status %d\n", (int)gpu_screen_recorder_process, exit_code);
- show_notification("Failed to start/save recording", 3.0, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::RECORD);
+ show_notification("Failed to start/save recording. Verify if settings are correct", 3.0, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::RECORD);
}
}
@@ -1574,8 +1586,6 @@ namespace gsr {
// TODO: Also check x11 window when enabled (check if capture_target is a decminal/hex number)
if(capture_target == "focused") {
return capture_options.focused;
- } else if(capture_target == "screen") {
- return capture_options.screen;
} else if(capture_target == "portal") {
return capture_options.portal;
} else {
diff --git a/src/gui/SettingsPage.cpp b/src/gui/SettingsPage.cpp
index 28821d1..7613d11 100644
--- a/src/gui/SettingsPage.cpp
+++ b/src/gui/SettingsPage.cpp
@@ -64,9 +64,6 @@ namespace gsr {
// record_area_box->add_item("Window", "window");
if(capture_options.focused)
record_area_box->add_item("Follow focused window", "focused");
- // Do we really need this? it's only available on nvidia x11
- //if(capture_options.screen)
- // record_area_box->add_item("All monitors", "screen");
for(const auto &monitor : capture_options.monitors) {
char name[256];
snprintf(name, sizeof(name), "Monitor %s (%dx%d)", monitor.name.c_str(), monitor.size.x, monitor.size.y);
@@ -896,6 +893,7 @@ namespace gsr {
}
void SettingsPage::save() {
+ Config prev_config = config;
switch(type) {
case Type::REPLAY:
save_replay();
@@ -908,6 +906,9 @@ namespace gsr {
break;
}
save_config(config);
+
+ if(on_config_changed && config != prev_config)
+ on_config_changed();
}
static const std::string* get_application_audio_by_name_case_insensitive(const std::vector<std::string> &application_audio, const std::string &name) {