diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-11-24 19:13:35 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-11-24 19:13:35 +0100 |
commit | 3468554eb3ddeac3cbf079ad6ebf3c8a39efc2f2 (patch) | |
tree | a0dbccbb6926716f180300afe8fa1e36d3fd3d2a | |
parent | 734280f3042a1b2d08764599d1decdee2d4d3132 (diff) |
Allow running the ui on Wayland through XWayland
-rw-r--r-- | README.md | 1 | ||||
m--------- | depends/mglpp | 0 | ||||
-rw-r--r-- | include/gui/SettingsPage.hpp | 14 | ||||
-rw-r--r-- | src/gui/SettingsPage.cpp | 41 | ||||
-rw-r--r-- | src/main.cpp | 13 |
5 files changed, 40 insertions, 29 deletions
@@ -2,6 +2,7 @@ # 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.\ +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.\ You can report an issue by emailing the issue to dec05eba@protonmail.com. diff --git a/depends/mglpp b/depends/mglpp -Subproject 84a6eb51b0c54e8f2c5134ff9e3baf39f5da77c +Subproject 9800cff631f1a82ee87005aabdefb3f5da7fadb diff --git a/include/gui/SettingsPage.hpp b/include/gui/SettingsPage.hpp index 29f6c1a..f18ff65 100644 --- a/include/gui/SettingsPage.hpp +++ b/include/gui/SettingsPage.hpp @@ -84,20 +84,20 @@ namespace gsr { std::unique_ptr<Widget> create_settings(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<ComboBox> create_container_box(); std::unique_ptr<List> create_container_section(); std::unique_ptr<Entry> create_replay_time_entry(); std::unique_ptr<List> create_replay_time(); - std::unique_ptr<RadioButton> create_start_replay_automatically(); - std::unique_ptr<CheckBox> create_save_replay_in_game_folder(); + std::unique_ptr<RadioButton> create_start_replay_automatically(const GsrInfo &gsr_info); + std::unique_ptr<CheckBox> create_save_replay_in_game_folder(const GsrInfo &gsr_info); std::unique_ptr<Label> create_estimated_file_size(); void update_estimated_file_size(); - std::unique_ptr<CheckBox> create_save_recording_in_game_folder(); - void add_replay_widgets(); - void add_record_widgets(); + std::unique_ptr<CheckBox> create_save_recording_in_game_folder(const GsrInfo &gsr_info); + void add_replay_widgets(const GsrInfo &gsr_info); + void add_record_widgets(const GsrInfo &gsr_info); std::unique_ptr<ComboBox> create_streaming_service_box(); 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<ComboBox> create_stream_container_box(); 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_common(RecordOptions &record_options, const GsrInfo &gsr_info); diff --git a/src/gui/SettingsPage.cpp b/src/gui/SettingsPage.cpp index 949e31a..79f6c52 100644 --- a/src/gui/SettingsPage.cpp +++ b/src/gui/SettingsPage.cpp @@ -42,7 +42,7 @@ namespace gsr { add_widget(std::move(content_page)); add_widgets(gsr_info); - add_page_specific_widgets(); + add_page_specific_widgets(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) { case Type::REPLAY: - add_replay_widgets(); + add_replay_widgets(gsr_info); break; case Type::RECORD: - add_record_widgets(); + add_record_widgets(gsr_info); break; case Type::STREAM: - add_stream_widgets(); + add_stream_widgets(gsr_info); break; } } @@ -622,18 +622,23 @@ namespace gsr { 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); 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 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"); turn_on_replay_automatically_mode_ptr = radiobutton.get(); return radiobutton; } - std::unique_ptr<CheckBox> SettingsPage::create_save_replay_in_game_folder() { - auto checkbox = std::make_unique<CheckBox>(&get_theme().body_font, "Save video in a folder with the name of the game"); + std::unique_ptr<CheckBox> SettingsPage::create_save_replay_in_game_folder(const GsrInfo &gsr_info) { + 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(); return checkbox; } @@ -654,7 +659,7 @@ namespace gsr { 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_data_list = std::make_unique<List>(List::Orientation::HORIZONTAL); 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))); auto general_list = std::make_unique<List>(List::Orientation::VERTICAL); - general_list->add_widget(create_start_replay_automatically()); - general_list->add_widget(create_save_replay_in_game_folder()); + general_list->add_widget(create_start_replay_automatically(gsr_info)); + 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))); 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() { - auto checkbox = std::make_unique<CheckBox>(&get_theme().body_font, "Save video in a folder with the name of the game"); + std::unique_ptr<CheckBox> SettingsPage::create_save_recording_in_game_folder(const GsrInfo &gsr_info) { + 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(); 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); file_list->add_widget(create_save_directory("Directory to save the video:")); 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))); 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))); auto checkboxes_list = std::make_unique<List>(List::Orientation::VERTICAL); @@ -818,7 +825,7 @@ namespace gsr { 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); streaming_info_list->add_widget(create_streaming_service_section()); streaming_info_list->add_widget(create_stream_key_section()); diff --git a/src/main.cpp b/src/main.cpp index be2e50d..cded01c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -56,6 +56,11 @@ int main(void) { 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; // TODO: Show the error in ui gsr::GsrInfoExitStatus gsr_info_exit_status = gsr::get_gpu_screen_recorder_info(&gsr_info); @@ -64,10 +69,8 @@ int main(void) { exit(1); } - if(gsr_info.system_info.display_server == gsr::DisplayServer::WAYLAND) { - fprintf(stderr, "error: Wayland is currently not supported\n"); - exit(1); - } + if(gsr_info.system_info.display_server == gsr::DisplayServer::WAYLAND) + fprintf(stderr, "warning: Wayland support is experimental and requires XWayland. Things may not work as expected.\n"); std::string resources_path; if(access("sibs-build", F_OK) == 0) { @@ -80,7 +83,6 @@ int main(void) { #endif } - mgl::Init init; mgl_context *context = mgl_get_context(); egl_functions egl_funcs; @@ -198,6 +200,7 @@ int main(void) { overlay.reset(); gsr::deinit_theme(); gsr::deinit_color_theme(); + mgl_deinit(); return 0; } |