Compare commits

...

4 Commits
1.0.1 ... 1.0.2

8 changed files with 53 additions and 31 deletions

View File

@@ -27,7 +27,8 @@ namespace gsr {
mgl::vec2f get_size() override;
std::function<void(const std::string &text, const std::string &id)> on_selection_changed;
// Return false to revert the change
std::function<bool(const std::string &text, const std::string &id)> on_selection_changed;
private:
void update_if_dirty();
private:

View File

@@ -1,4 +1,4 @@
project('gsr-ui', ['c', 'cpp'], version : '1.0.1', default_options : ['warning_level=2', 'cpp_std=c++17'], subproject_dir : 'depends')
project('gsr-ui', ['c', 'cpp'], version : '1.0.2', default_options : ['warning_level=2', 'cpp_std=c++17'], subproject_dir : 'depends')
if get_option('buildtype') == 'debug'
add_project_arguments('-g3', language : ['c', 'cpp'])

View File

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

View File

@@ -470,8 +470,6 @@ namespace gsr {
notification_process = -1;
}
close_gpu_screen_recorder_output();
if(gpu_screen_recorder_process > 0) {
kill(gpu_screen_recorder_process, SIGINT);
int status;
@@ -482,6 +480,8 @@ namespace gsr {
gpu_screen_recorder_process = -1;
}
close_gpu_screen_recorder_output();
free(xi_input_xev);
free(xi_output_xev);
if(xi_display)
@@ -1306,12 +1306,18 @@ namespace gsr {
truncate_string(focused_window_name, 20);
std::string text;
switch(notification_type) {
case NotificationType::RECORD:
case NotificationType::RECORD: {
if(!config.record_config.show_video_saved_notifications)
return;
text = "Saved recording to '" + focused_window_name + "/" + video_filename + "'";
break;
case NotificationType::REPLAY:
}
case NotificationType::REPLAY: {
if(!config.replay_config.show_replay_saved_notifications)
return;
text = "Saved replay to '" + focused_window_name + "/" + video_filename + "'";
break;
}
case NotificationType::NONE:
case NotificationType::STREAM:
break;

View File

@@ -45,17 +45,21 @@ namespace gsr {
Window focused_window = None;
if(cap_type == WindowCaptureType::FOCUSED) {
// Atom type = None;
// int format = 0;
// unsigned long num_items = 0;
// unsigned long bytes_left = 0;
// unsigned char *data = NULL;
// XGetWindowProperty(dpy, DefaultRootWindow(dpy), net_active_window_atom, 0, 1, False, XA_WINDOW, &type, &format, &num_items, &bytes_left, &data);
Atom type = None;
int format = 0;
unsigned long num_items = 0;
unsigned long bytes_left = 0;
unsigned char *data = NULL;
XGetWindowProperty(dpy, DefaultRootWindow(dpy), net_active_window_atom, 0, 1, False, XA_WINDOW, &type, &format, &num_items, &bytes_left, &data);
// fprintf(stderr, "focused window: %p\n", (void*)data);
if(type == XA_WINDOW && num_items == 1 && data)
focused_window = *(Window*)data;
// if(type == XA_WINDOW && num_items == 1 && data)
// return *(Window*)data;
if(data)
XFree(data);
if(focused_window)
return focused_window;
int revert_to = 0;
XGetInputFocus(dpy, &focused_window, &revert_to);
@@ -72,7 +76,7 @@ namespace gsr {
static char* get_window_title(Display *dpy, Window window) {
const Atom net_wm_name_atom = XInternAtom(dpy, "_NET_WM_NAME", False);
const Atom wm_name_atom = XInternAtom(dpy, "_NET_WM_NAME", False);
const Atom wm_name_atom = XInternAtom(dpy, "WM_NAME", False);
const Atom utf8_string_atom = XInternAtom(dpy, "UTF8_STRING", False);
Atom type = None;
@@ -135,6 +139,7 @@ namespace gsr {
char *window_title = get_window_title(dpy, focused_window);
if(window_title) {
result = string_string(window_title);
XFree(window_title);
return result;
}

View File

@@ -55,6 +55,7 @@ namespace gsr {
get_color_theme().tint_color = mgl::Color(118, 185, 0);
else if(id == "intel")
get_color_theme().tint_color = mgl::Color(8, 109, 183);
return true;
};
list->add_widget(std::move(tint_color_radio_button));
return std::make_unique<Subsection>("Appearance", std::move(list), mgl::vec2f(parent_page->get_inner_size().x, 0.0f));
@@ -62,10 +63,11 @@ namespace gsr {
std::unique_ptr<Subsection> GlobalSettingsPage::create_startup_subsection(ScrollablePage *parent_page) {
auto list = std::make_unique<List>(List::Orientation::VERTICAL);
auto startup_radio_button = std::make_unique<RadioButton>(&get_theme().body_font, RadioButton::Orientation::VERTICAL);
list->add_widget(std::make_unique<Label>(&get_theme().body_font, "Start program on system startup?", get_color_theme().text_color));
auto startup_radio_button = std::make_unique<RadioButton>(&get_theme().body_font, RadioButton::Orientation::HORIZONTAL);
startup_radio_button_ptr = startup_radio_button.get();
startup_radio_button->add_item("Don't start this program on system startup", "dont_start_on_system_startup");
startup_radio_button->add_item("Start this program on system startup", "start_on_system_startup");
startup_radio_button->add_item("Yes", "start_on_system_startup");
startup_radio_button->add_item("No", "dont_start_on_system_startup");
startup_radio_button->on_selection_changed = [&](const std::string&, const std::string &id) {
bool enable = false;
if(id == "dont_start_on_system_startup")
@@ -73,13 +75,14 @@ namespace gsr {
else if(id == "start_on_system_startup")
enable = true;
else
return;
return false;
const char *args[] = { "systemctl", enable ? "enable" : "disable", "--user", "gpu-screen-recorder-ui", nullptr };
std::string stdout_str;
const int exit_status = exec_program_on_host_get_stdout(args, stdout_str);
if(on_startup_changed)
on_startup_changed(enable, exit_status);
return exit_status == 0;
};
list->add_widget(std::move(startup_radio_button));
return std::make_unique<Subsection>("Startup", std::move(list), mgl::vec2f(parent_page->get_inner_size().x, 0.0f));

View File

@@ -35,12 +35,12 @@ namespace gsr {
const bool mouse_inside = mgl::FloatRect(draw_pos, item_size).contains(mgl::vec2f(event.mouse_button.x, event.mouse_button.y));
if(mouse_inside) {
const size_t prev_selected_item = selected_item;
if(selected_item != i && on_selection_changed) {
if(!on_selection_changed(item.text.get_string(), item.id))
return false;
}
selected_item = i;
if(selected_item != prev_selected_item && on_selection_changed)
on_selection_changed(item.text.get_string(), item.id);
return false;
}
@@ -158,12 +158,12 @@ namespace gsr {
for(size_t i = 0; i < items.size(); ++i) {
auto &item = items[i];
if(item.id == id) {
const size_t prev_selected_item = selected_item;
if(trigger_event && (trigger_event_even_if_selection_not_changed || selected_item != i) && on_selection_changed) {
if(!on_selection_changed(item.text.get_string(), item.id))
break;
}
selected_item = i;
if(trigger_event && (trigger_event_even_if_selection_not_changed || selected_item != prev_selected_item) && on_selection_changed)
on_selection_changed(item.text.get_string(), item.id);
break;
}
}

View File

@@ -516,6 +516,7 @@ namespace gsr {
video_resolution_list_ptr->set_visible(!focused_selected && change_video_resolution_checkbox_ptr->is_checked());
change_video_resolution_checkbox_ptr->set_visible(!focused_selected);
restore_portal_session_list_ptr->set_visible(portal_selected);
return true;
};
change_video_resolution_checkbox_ptr->on_changed = [this](bool checked) {
@@ -530,6 +531,8 @@ namespace gsr {
if(estimated_file_size_ptr)
estimated_file_size_ptr->set_visible(custom_selected);
return true;
};
video_quality_box_ptr->on_selection_changed("", video_quality_box_ptr->get_selected_id());
@@ -705,6 +708,7 @@ namespace gsr {
framerate_mode_list_ptr->set_visible(advanced_view);
notifications_subsection_ptr->set_visible(advanced_view);
settings_scrollable_page_ptr->reset_scroll();
return true;
};
view_radio_button_ptr->on_selection_changed("Simple", "simple");
@@ -760,6 +764,7 @@ namespace gsr {
framerate_mode_list_ptr->set_visible(advanced_view);
notifications_subsection_ptr->set_visible(advanced_view);
settings_scrollable_page_ptr->reset_scroll();
return true;
};
view_radio_button_ptr->on_selection_changed("Simple", "simple");
}
@@ -860,6 +865,7 @@ namespace gsr {
container_list_ptr->set_visible(custom_option);
twitch_stream_key_entry_ptr->set_visible(twitch_option);
youtube_stream_key_entry_ptr->set_visible(youtube_option);
return true;
};
streaming_service_box_ptr->on_selection_changed("Twitch", "twitch");
@@ -872,6 +878,7 @@ namespace gsr {
framerate_mode_list_ptr->set_visible(advanced_view);
notifications_subsection_ptr->set_visible(advanced_view);
settings_scrollable_page_ptr->reset_scroll();
return true;
};
view_radio_button_ptr->on_selection_changed("Simple", "simple");
}