From 7cf87f48d0ea8c050e6043ff800688f2b03f98c3 Mon Sep 17 00:00:00 2001 From: Reonu Date: Wed, 24 Apr 2024 23:23:28 +0100 Subject: [PATCH] Add Linux fullscreen support --- src/main/main.cpp | 7 ++++++- src/ui/ui_config.cpp | 23 ++++++++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/main/main.cpp b/src/main/main.cpp index 74768bc..084071e 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -109,8 +109,13 @@ SDL_Window* window; 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__) +#if defined(__linux__) // TODO: Remove once RT64 gets native fullscreen support on Linux SetImageAsIcon("icons/512.png",window); + if (ultramodern::get_graphics_config().wm_option == ultramodern::WindowMode::Fullscreen) { + SDL_SetWindowFullscreen(window,SDL_WINDOW_FULLSCREEN_DESKTOP); + } else { + SDL_SetWindowFullscreen(window,SDL_WINDOW_BORDERLESS); + } #endif if (window == nullptr) { diff --git a/src/ui/ui_config.cpp b/src/ui/ui_config.cpp index af84d84..56cd1d3 100644 --- a/src/ui/ui_config.cpp +++ b/src/ui/ui_config.cpp @@ -185,6 +185,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,SDL_WINDOW_BORDERLESS); + } +#endif +} + void close_config_menu() { if (ultramodern::get_graphics_config() != new_options) { prompt_context.open_prompt( @@ -193,7 +210,7 @@ void close_config_menu() { "Apply", "Discard", []() { - ultramodern::set_graphics_config(new_options); + apply_graphics_config(); graphics_model_handle.DirtyAllVariables(); close_config_menu_impl(); }, @@ -328,7 +345,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) { @@ -779,6 +796,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"); }