Allow running the ui on Wayland through XWayland

This commit is contained in:
dec05eba
2024-11-24 19:13:35 +01:00
parent 734280f304
commit 3468554eb3
5 changed files with 41 additions and 30 deletions

View File

@@ -2,6 +2,7 @@
# GPU Screen Recorder UI # GPU Screen Recorder UI
A fullscreen overlay UI for [GPU Screen Recorder](https://git.dec05eba.com/gpu-screen-recorder/about/) in the style of ShadowPlay.\ A fullscreen overlay UI for [GPU Screen Recorder](https://git.dec05eba.com/gpu-screen-recorder/about/) in the style of ShadowPlay.\
The application is currently primarly designed for X11 but it can run on Wayland as well through XWayland, with some caveats because of Wayland limitations.\
Note: This software is still in early alpha. Expect bugs, and please report any if you experience them. Some are already known, but it doesn't hurt to report them anyways.\ Note: This software is still in early alpha. Expect bugs, and please report any if you experience them. Some are already known, but it doesn't hurt to report them anyways.\
You can report an issue by emailing the issue to dec05eba@protonmail.com. You can report an issue by emailing the issue to dec05eba@protonmail.com.

View File

@@ -84,20 +84,20 @@ namespace gsr {
std::unique_ptr<Widget> create_settings(const GsrInfo &gsr_info); std::unique_ptr<Widget> create_settings(const GsrInfo &gsr_info);
void add_widgets(const GsrInfo &gsr_info); void add_widgets(const GsrInfo &gsr_info);
void add_page_specific_widgets(); void add_page_specific_widgets(const GsrInfo &gsr_info);
std::unique_ptr<List> create_save_directory(const char *label); std::unique_ptr<List> create_save_directory(const char *label);
std::unique_ptr<ComboBox> create_container_box(); std::unique_ptr<ComboBox> create_container_box();
std::unique_ptr<List> create_container_section(); std::unique_ptr<List> create_container_section();
std::unique_ptr<Entry> create_replay_time_entry(); std::unique_ptr<Entry> create_replay_time_entry();
std::unique_ptr<List> create_replay_time(); std::unique_ptr<List> create_replay_time();
std::unique_ptr<RadioButton> create_start_replay_automatically(); std::unique_ptr<RadioButton> create_start_replay_automatically(const GsrInfo &gsr_info);
std::unique_ptr<CheckBox> create_save_replay_in_game_folder(); std::unique_ptr<CheckBox> create_save_replay_in_game_folder(const GsrInfo &gsr_info);
std::unique_ptr<Label> create_estimated_file_size(); std::unique_ptr<Label> create_estimated_file_size();
void update_estimated_file_size(); void update_estimated_file_size();
std::unique_ptr<CheckBox> create_save_recording_in_game_folder(); std::unique_ptr<CheckBox> create_save_recording_in_game_folder(const GsrInfo &gsr_info);
void add_replay_widgets(); void add_replay_widgets(const GsrInfo &gsr_info);
void add_record_widgets(); void add_record_widgets(const GsrInfo &gsr_info);
std::unique_ptr<ComboBox> create_streaming_service_box(); std::unique_ptr<ComboBox> create_streaming_service_box();
std::unique_ptr<List> create_streaming_service_section(); std::unique_ptr<List> create_streaming_service_section();
@@ -105,7 +105,7 @@ namespace gsr {
std::unique_ptr<List> create_stream_url_section(); std::unique_ptr<List> create_stream_url_section();
std::unique_ptr<ComboBox> create_stream_container_box(); std::unique_ptr<ComboBox> create_stream_container_box();
std::unique_ptr<List> create_stream_container_section(); std::unique_ptr<List> create_stream_container_section();
void add_stream_widgets(); void add_stream_widgets(const GsrInfo &gsr_info);
void load_audio_tracks(const RecordOptions &record_options, const GsrInfo &gsr_info); void load_audio_tracks(const RecordOptions &record_options, const GsrInfo &gsr_info);
void load_common(RecordOptions &record_options, const GsrInfo &gsr_info); void load_common(RecordOptions &record_options, const GsrInfo &gsr_info);

View File

@@ -42,7 +42,7 @@ namespace gsr {
add_widget(std::move(content_page)); add_widget(std::move(content_page));
add_widgets(gsr_info); add_widgets(gsr_info);
add_page_specific_widgets(); add_page_specific_widgets(gsr_info);
load(gsr_info); load(gsr_info);
} }
@@ -550,16 +550,16 @@ namespace gsr {
} }
} }
void SettingsPage::add_page_specific_widgets() { void SettingsPage::add_page_specific_widgets(const GsrInfo &gsr_info) {
switch(type) { switch(type) {
case Type::REPLAY: case Type::REPLAY:
add_replay_widgets(); add_replay_widgets(gsr_info);
break; break;
case Type::RECORD: case Type::RECORD:
add_record_widgets(); add_record_widgets(gsr_info);
break; break;
case Type::STREAM: case Type::STREAM:
add_stream_widgets(); add_stream_widgets(gsr_info);
break; break;
} }
} }
@@ -622,18 +622,23 @@ namespace gsr {
return replay_time_list; return replay_time_list;
} }
std::unique_ptr<RadioButton> SettingsPage::create_start_replay_automatically() { std::unique_ptr<RadioButton> SettingsPage::create_start_replay_automatically(const GsrInfo &gsr_info) {
char fullscreen_text[256];
snprintf(fullscreen_text, sizeof(fullscreen_text), "Turn on replay when starting a fullscreen application%s", gsr_info.system_info.display_server == DisplayServer::X11 ? "" : " (X11 only)");
auto radiobutton = std::make_unique<RadioButton>(&get_theme().body_font, RadioButton::Orientation::VERTICAL); auto radiobutton = std::make_unique<RadioButton>(&get_theme().body_font, RadioButton::Orientation::VERTICAL);
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(fullscreen_text, "turn_on_at_fullscreen");
radiobutton->add_item("Turn on replay when power supply is connected", "turn_on_at_power_supply_connected"); 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;
} }
std::unique_ptr<CheckBox> SettingsPage::create_save_replay_in_game_folder() { std::unique_ptr<CheckBox> SettingsPage::create_save_replay_in_game_folder(const GsrInfo &gsr_info) {
auto checkbox = std::make_unique<CheckBox>(&get_theme().body_font, "Save video in a folder with the name of the game"); char text[256];
snprintf(text, sizeof(text), "Save video in a folder with the name of the game%s", gsr_info.system_info.display_server == DisplayServer::X11 ? "" : " (X11 only)");
auto checkbox = std::make_unique<CheckBox>(&get_theme().body_font, text);
save_replay_in_game_folder_ptr = checkbox.get(); save_replay_in_game_folder_ptr = checkbox.get();
return checkbox; return checkbox;
} }
@@ -654,7 +659,7 @@ namespace gsr {
estimated_file_size_ptr->set_text(buffer); estimated_file_size_ptr->set_text(buffer);
} }
void SettingsPage::add_replay_widgets() { void SettingsPage::add_replay_widgets(const GsrInfo &gsr_info) {
auto file_info_list = std::make_unique<List>(List::Orientation::VERTICAL); auto file_info_list = std::make_unique<List>(List::Orientation::VERTICAL);
auto file_info_data_list = std::make_unique<List>(List::Orientation::HORIZONTAL); auto file_info_data_list = std::make_unique<List>(List::Orientation::HORIZONTAL);
file_info_data_list->add_widget(create_save_directory("Directory to save replays:")); file_info_data_list->add_widget(create_save_directory("Directory to save replays:"));
@@ -665,8 +670,8 @@ namespace gsr {
settings_list_ptr->add_widget(std::make_unique<Subsection>("File info", std::move(file_info_list), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f))); settings_list_ptr->add_widget(std::make_unique<Subsection>("File info", std::move(file_info_list), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f)));
auto general_list = std::make_unique<List>(List::Orientation::VERTICAL); auto general_list = std::make_unique<List>(List::Orientation::VERTICAL);
general_list->add_widget(create_start_replay_automatically()); general_list->add_widget(create_start_replay_automatically(gsr_info));
general_list->add_widget(create_save_replay_in_game_folder()); general_list->add_widget(create_save_replay_in_game_folder(gsr_info));
settings_list_ptr->add_widget(std::make_unique<Subsection>("General", std::move(general_list), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f))); settings_list_ptr->add_widget(std::make_unique<Subsection>("General", std::move(general_list), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f)));
auto checkboxes_list = std::make_unique<List>(List::Orientation::VERTICAL); auto checkboxes_list = std::make_unique<List>(List::Orientation::VERTICAL);
@@ -711,20 +716,22 @@ namespace gsr {
}; };
} }
std::unique_ptr<CheckBox> SettingsPage::create_save_recording_in_game_folder() { std::unique_ptr<CheckBox> SettingsPage::create_save_recording_in_game_folder(const GsrInfo &gsr_info) {
auto checkbox = std::make_unique<CheckBox>(&get_theme().body_font, "Save video in a folder with the name of the game"); char text[256];
snprintf(text, sizeof(text), "Save video in a folder with the name of the game%s", gsr_info.system_info.display_server == DisplayServer::X11 ? "" : " (X11 only)");
auto checkbox = std::make_unique<CheckBox>(&get_theme().body_font, text);
save_recording_in_game_folder_ptr = checkbox.get(); save_recording_in_game_folder_ptr = checkbox.get();
return checkbox; return checkbox;
} }
void SettingsPage::add_record_widgets() { void SettingsPage::add_record_widgets(const GsrInfo &gsr_info) {
auto file_list = std::make_unique<List>(List::Orientation::HORIZONTAL); auto file_list = std::make_unique<List>(List::Orientation::HORIZONTAL);
file_list->add_widget(create_save_directory("Directory to save the video:")); file_list->add_widget(create_save_directory("Directory to save the video:"));
file_list->add_widget(create_container_section()); file_list->add_widget(create_container_section());
settings_list_ptr->add_widget(std::make_unique<Subsection>("File info", std::move(file_list), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f))); settings_list_ptr->add_widget(std::make_unique<Subsection>("File info", std::move(file_list), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f)));
auto general_list = std::make_unique<List>(List::Orientation::VERTICAL); auto general_list = std::make_unique<List>(List::Orientation::VERTICAL);
general_list->add_widget(create_save_recording_in_game_folder()); general_list->add_widget(create_save_recording_in_game_folder(gsr_info));
settings_list_ptr->add_widget(std::make_unique<Subsection>("General", std::move(general_list), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f))); settings_list_ptr->add_widget(std::make_unique<Subsection>("General", std::move(general_list), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f)));
auto checkboxes_list = std::make_unique<List>(List::Orientation::VERTICAL); auto checkboxes_list = std::make_unique<List>(List::Orientation::VERTICAL);
@@ -818,7 +825,7 @@ namespace gsr {
return container_list; return container_list;
} }
void SettingsPage::add_stream_widgets() { void SettingsPage::add_stream_widgets(const GsrInfo&) {
auto streaming_info_list = std::make_unique<List>(List::Orientation::HORIZONTAL); auto streaming_info_list = std::make_unique<List>(List::Orientation::HORIZONTAL);
streaming_info_list->add_widget(create_streaming_service_section()); streaming_info_list->add_widget(create_streaming_service_section());
streaming_info_list->add_widget(create_stream_key_section()); streaming_info_list->add_widget(create_stream_key_section());

View File

@@ -56,6 +56,11 @@ int main(void) {
signal(SIGINT, sigint_handler); signal(SIGINT, sigint_handler);
if(mgl_init() != 0) {
fprintf(stderr, "error: failed to initialize mgl. Either failed to connec to the X11 server or failed to setup opengl\n");
exit(1);
}
gsr::GsrInfo gsr_info; gsr::GsrInfo gsr_info;
// TODO: Show the error in ui // TODO: Show the error in ui
gsr::GsrInfoExitStatus gsr_info_exit_status = gsr::get_gpu_screen_recorder_info(&gsr_info); gsr::GsrInfoExitStatus gsr_info_exit_status = gsr::get_gpu_screen_recorder_info(&gsr_info);
@@ -64,10 +69,8 @@ int main(void) {
exit(1); exit(1);
} }
if(gsr_info.system_info.display_server == gsr::DisplayServer::WAYLAND) { if(gsr_info.system_info.display_server == gsr::DisplayServer::WAYLAND)
fprintf(stderr, "error: Wayland is currently not supported\n"); fprintf(stderr, "warning: Wayland support is experimental and requires XWayland. Things may not work as expected.\n");
exit(1);
}
std::string resources_path; std::string resources_path;
if(access("sibs-build", F_OK) == 0) { if(access("sibs-build", F_OK) == 0) {
@@ -80,7 +83,6 @@ int main(void) {
#endif #endif
} }
mgl::Init init;
mgl_context *context = mgl_get_context(); mgl_context *context = mgl_get_context();
egl_functions egl_funcs; egl_functions egl_funcs;
@@ -198,6 +200,7 @@ int main(void) {
overlay.reset(); overlay.reset();
gsr::deinit_theme(); gsr::deinit_theme();
gsr::deinit_color_theme(); gsr::deinit_color_theme();
mgl_deinit();
return 0; return 0;
} }