mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-04-24 10:39:51 +09:00
Add option to start replay when power supply is connected
This commit is contained in:
2
TODO
2
TODO
@@ -87,3 +87,5 @@ gsr ui window has _NET_WM_STATE _NET_WM_STATE_ABOVE, not _NET_WM_STATE_FULLSCREE
|
|||||||
For replay on fullscreen detect focused fullscreen window by checking if the window size is the same as the monitor size instead of _NET_WM_STATE_FULLSCREEN.
|
For replay on fullscreen detect focused fullscreen window by checking if the window size is the same as the monitor size instead of _NET_WM_STATE_FULLSCREEN.
|
||||||
|
|
||||||
Add audio devices/app refresh button.
|
Add audio devices/app refresh button.
|
||||||
|
|
||||||
|
Play camera shutter sound when saving recording. When another sound when starting recording.
|
||||||
|
|||||||
@@ -59,7 +59,9 @@ namespace gsr {
|
|||||||
void update_notification_process_status();
|
void update_notification_process_status();
|
||||||
void update_gsr_process_status();
|
void update_gsr_process_status();
|
||||||
|
|
||||||
|
void replay_status_update_status();
|
||||||
void update_focused_fullscreen_status();
|
void update_focused_fullscreen_status();
|
||||||
|
void update_power_supply_status();
|
||||||
|
|
||||||
void update_ui_recording_paused();
|
void update_ui_recording_paused();
|
||||||
void update_ui_recording_unpaused();
|
void update_ui_recording_unpaused();
|
||||||
@@ -117,7 +119,8 @@ namespace gsr {
|
|||||||
RecordingStatus recording_status = RecordingStatus::NONE;
|
RecordingStatus recording_status = RecordingStatus::NONE;
|
||||||
bool paused = false;
|
bool paused = false;
|
||||||
|
|
||||||
mgl::Clock focused_fullscreen_clock;
|
mgl::Clock replay_status_update_clock;
|
||||||
|
std::string power_supply_online_filepath;
|
||||||
|
|
||||||
std::array<KeyBinding, 1> key_bindings;
|
std::array<KeyBinding, 1> key_bindings;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
@@ -30,7 +31,7 @@ extern "C" {
|
|||||||
namespace gsr {
|
namespace gsr {
|
||||||
static const mgl::Color bg_color(0, 0, 0, 100);
|
static const mgl::Color bg_color(0, 0, 0, 100);
|
||||||
static const double force_window_on_top_timeout_seconds = 1.0;
|
static const double force_window_on_top_timeout_seconds = 1.0;
|
||||||
static const double focused_window_fullscreen_check_timeout_seconds = 1.0;
|
static const double replay_status_update_check_timeout_seconds = 1.0;
|
||||||
|
|
||||||
static bool window_has_atom(Display *dpy, Window window, Atom atom) {
|
static bool window_has_atom(Display *dpy, Window window, Atom atom) {
|
||||||
Atom type;
|
Atom type;
|
||||||
@@ -291,6 +292,28 @@ namespace gsr {
|
|||||||
return XGetSelectionOwner(dpy, prop_atom) != None;
|
return XGetSelectionOwner(dpy, prop_atom) != None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string get_power_supply_online_filepath() {
|
||||||
|
std::string result;
|
||||||
|
if(access("/sys/class/power_supply/ADP1/online", F_OK) == 0)
|
||||||
|
result = "/sys/class/power_supply/ADP1/online";
|
||||||
|
else if(access("/sys/class/power_supply/AC/online", F_OK) == 0)
|
||||||
|
result = "/sys/class/power_supply/AC/online";
|
||||||
|
else if(access("/sys/class/power_supply/ACAD/online", F_OK) == 0)
|
||||||
|
result = "/sys/class/power_supply/ACAD/online";
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool power_supply_is_connected(const char *power_supply_online_filepath) {
|
||||||
|
int fd = open(power_supply_online_filepath, O_RDONLY);
|
||||||
|
if(fd == -1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
char buf[1];
|
||||||
|
const bool is_connected = read(fd, buf, 1) == 1 && buf[0] == '1';
|
||||||
|
close(fd);
|
||||||
|
return is_connected;
|
||||||
|
}
|
||||||
|
|
||||||
Overlay::Overlay(std::string resources_path, GsrInfo gsr_info, egl_functions egl_funcs) :
|
Overlay::Overlay(std::string resources_path, GsrInfo gsr_info, egl_functions egl_funcs) :
|
||||||
resources_path(std::move(resources_path)),
|
resources_path(std::move(resources_path)),
|
||||||
gsr_info(gsr_info),
|
gsr_info(gsr_info),
|
||||||
@@ -320,6 +343,8 @@ namespace gsr {
|
|||||||
const std::string notify_bg_color_str = color_to_hex_str(get_color_theme().tint_color);
|
const std::string notify_bg_color_str = color_to_hex_str(get_color_theme().tint_color);
|
||||||
setenv("GSR_NOTIFY_BG_COLOR", notify_bg_color_str.c_str(), true);
|
setenv("GSR_NOTIFY_BG_COLOR", notify_bg_color_str.c_str(), true);
|
||||||
|
|
||||||
|
power_supply_online_filepath = get_power_supply_online_filepath();
|
||||||
|
|
||||||
if(config.replay_config.turn_on_replay_automatically_mode == "turn_on_at_system_startup")
|
if(config.replay_config.turn_on_replay_automatically_mode == "turn_on_at_system_startup")
|
||||||
on_press_start_replay(true);
|
on_press_start_replay(true);
|
||||||
}
|
}
|
||||||
@@ -389,7 +414,7 @@ namespace gsr {
|
|||||||
bool Overlay::draw() {
|
bool Overlay::draw() {
|
||||||
update_notification_process_status();
|
update_notification_process_status();
|
||||||
update_gsr_process_status();
|
update_gsr_process_status();
|
||||||
update_focused_fullscreen_status();
|
replay_status_update_status();
|
||||||
|
|
||||||
if(!visible)
|
if(!visible)
|
||||||
return false;
|
return false;
|
||||||
@@ -854,11 +879,16 @@ namespace gsr {
|
|||||||
recording_status = RecordingStatus::NONE;
|
recording_status = RecordingStatus::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overlay::update_focused_fullscreen_status() {
|
void Overlay::replay_status_update_status() {
|
||||||
if(focused_fullscreen_clock.get_elapsed_time_seconds() < focused_window_fullscreen_check_timeout_seconds)
|
if(replay_status_update_clock.get_elapsed_time_seconds() < replay_status_update_check_timeout_seconds)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
focused_fullscreen_clock.restart();
|
replay_status_update_clock.restart();
|
||||||
|
update_focused_fullscreen_status();
|
||||||
|
update_power_supply_status();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Overlay::update_focused_fullscreen_status() {
|
||||||
if(config.replay_config.turn_on_replay_automatically_mode != "turn_on_at_fullscreen")
|
if(config.replay_config.turn_on_replay_automatically_mode != "turn_on_at_fullscreen")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -878,6 +908,19 @@ namespace gsr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Overlay::update_power_supply_status() {
|
||||||
|
if(config.replay_config.turn_on_replay_automatically_mode != "turn_on_at_power_supply_connected")
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(recording_status == RecordingStatus::NONE) {
|
||||||
|
if(power_supply_online_filepath.empty() || power_supply_is_connected(power_supply_online_filepath.c_str()))
|
||||||
|
on_press_start_replay(true);
|
||||||
|
} else if(recording_status == RecordingStatus::REPLAY) {
|
||||||
|
if(!power_supply_online_filepath.empty() && !power_supply_is_connected(power_supply_online_filepath.c_str()))
|
||||||
|
on_press_start_replay(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Overlay::update_ui_recording_paused() {
|
void Overlay::update_ui_recording_paused() {
|
||||||
if(!visible || recording_status != RecordingStatus::RECORD)
|
if(!visible || recording_status != RecordingStatus::RECORD)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -664,6 +664,7 @@ namespace gsr {
|
|||||||
radiobutton->add_item("Don't turn on replay automatically", "dont_turn_on_automatically");
|
radiobutton->add_item("Don't turn on replay automatically", "dont_turn_on_automatically");
|
||||||
radiobutton->add_item("Turn on replay at system startup", "turn_on_at_system_startup");
|
radiobutton->add_item("Turn on replay at system startup", "turn_on_at_system_startup");
|
||||||
radiobutton->add_item("Turn on replay when starting a fullscreen application", "turn_on_at_fullscreen");
|
radiobutton->add_item("Turn on replay when starting a fullscreen application", "turn_on_at_fullscreen");
|
||||||
|
radiobutton->add_item("Turn on replay when power supply is connected", "turn_on_at_power_supply_connected");
|
||||||
turn_on_replay_automatically_mode_ptr = radiobutton.get();
|
turn_on_replay_automatically_mode_ptr = radiobutton.get();
|
||||||
return radiobutton;
|
return radiobutton;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user