From dd1315e6eb25c9e8f91303728d619698e62d7568 Mon Sep 17 00:00:00 2001 From: Reonu Date: Thu, 25 Apr 2024 08:05:43 +0100 Subject: [PATCH] Add Linux fullscreen support (#8) Temporary workaround for RT64 not supporting full screen in Linux --- src/main/main.cpp | 5 +++++ src/ui/ui_config.cpp | 23 ++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/main/main.cpp b/src/main/main.cpp index 74768bc..cd9057a 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -111,6 +111,11 @@ ultramodern::WindowHandle create_window(ultramodern::gfx_callbacks_t::gfx_data_t window = SDL_CreateWindow("Zelda 64: Recompiled", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1600, 960, SDL_WINDOW_RESIZABLE ); #if defined(__linux__) SetImageAsIcon("icons/512.png",window); + if (ultramodern::get_graphics_config().wm_option == ultramodern::WindowMode::Fullscreen) { // TODO: Remove once RT64 gets native fullscreen support on Linux + SDL_SetWindowFullscreen(window,SDL_WINDOW_FULLSCREEN_DESKTOP); + } else { + SDL_SetWindowFullscreen(window,0); + } #endif if (window == nullptr) { diff --git a/src/ui/ui_config.cpp b/src/ui/ui_config.cpp index 28624d4..94e909b 100644 --- a/src/ui/ui_config.cpp +++ b/src/ui/ui_config.cpp @@ -200,6 +200,23 @@ void close_config_menu_impl() { recomp::set_current_menu(recomp::Menu::Launcher); } } + +// TODO: Remove once RT64 gets native fullscreen support on Linux +#if defined(__linux__) +extern SDL_Window* window; +#endif + +void apply_graphics_config(void) { + ultramodern::set_graphics_config(new_options); +#if defined(__linux__) // TODO: Remove once RT64 gets native fullscreen support on Linux + if (new_options.wm_option == ultramodern::WindowMode::Fullscreen) { + SDL_SetWindowFullscreen(window,SDL_WINDOW_FULLSCREEN_DESKTOP); + } else { + SDL_SetWindowFullscreen(window,0); + } +#endif +} + void close_config_menu() { if (ultramodern::get_graphics_config() != new_options) { prompt_context.open_prompt( @@ -208,7 +225,7 @@ void close_config_menu() { "Apply", "Discard", []() { - ultramodern::set_graphics_config(new_options); + apply_graphics_config(); graphics_model_handle.DirtyAllVariables(); close_config_menu_impl(); }, @@ -405,7 +422,7 @@ public: recomp::register_event(listener, "apply_options", [](const std::string& param, Rml::Event& event) { graphics_model_handle.DirtyVariable("options_changed"); - ultramodern::set_graphics_config(new_options); + apply_graphics_config(); }); recomp::register_event(listener, "config_keydown", [](const std::string& param, Rml::Event& event) { @@ -878,6 +895,6 @@ void recomp::update_supported_options() { void recomp::toggle_fullscreen() { new_options.wm_option = (new_options.wm_option == ultramodern::WindowMode::Windowed) ? ultramodern::WindowMode::Fullscreen : ultramodern::WindowMode::Windowed; - ultramodern::set_graphics_config(new_options); + apply_graphics_config(); graphics_model_handle.DirtyVariable("wm_option"); }