Add Linux fullscreen support (#8)

Temporary workaround for RT64 not supporting full screen in Linux
This commit is contained in:
Reonu 2024-04-25 08:05:43 +01:00 committed by Mr-Wiseguy
parent 25a3837b37
commit dd1315e6eb
2 changed files with 25 additions and 3 deletions

View File

@ -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 ); window = SDL_CreateWindow("Zelda 64: Recompiled", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1600, 960, SDL_WINDOW_RESIZABLE );
#if defined(__linux__) #if defined(__linux__)
SetImageAsIcon("icons/512.png",window); 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 #endif
if (window == nullptr) { if (window == nullptr) {

View File

@ -200,6 +200,23 @@ void close_config_menu_impl() {
recomp::set_current_menu(recomp::Menu::Launcher); 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() { void close_config_menu() {
if (ultramodern::get_graphics_config() != new_options) { if (ultramodern::get_graphics_config() != new_options) {
prompt_context.open_prompt( prompt_context.open_prompt(
@ -208,7 +225,7 @@ void close_config_menu() {
"Apply", "Apply",
"Discard", "Discard",
[]() { []() {
ultramodern::set_graphics_config(new_options); apply_graphics_config();
graphics_model_handle.DirtyAllVariables(); graphics_model_handle.DirtyAllVariables();
close_config_menu_impl(); close_config_menu_impl();
}, },
@ -405,7 +422,7 @@ public:
recomp::register_event(listener, "apply_options", recomp::register_event(listener, "apply_options",
[](const std::string& param, Rml::Event& event) { [](const std::string& param, Rml::Event& event) {
graphics_model_handle.DirtyVariable("options_changed"); graphics_model_handle.DirtyVariable("options_changed");
ultramodern::set_graphics_config(new_options); apply_graphics_config();
}); });
recomp::register_event(listener, "config_keydown", recomp::register_event(listener, "config_keydown",
[](const std::string& param, Rml::Event& event) { [](const std::string& param, Rml::Event& event) {
@ -878,6 +895,6 @@ void recomp::update_supported_options() {
void recomp::toggle_fullscreen() { void recomp::toggle_fullscreen() {
new_options.wm_option = (new_options.wm_option == ultramodern::WindowMode::Windowed) ? ultramodern::WindowMode::Fullscreen : ultramodern::WindowMode::Windowed; 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"); graphics_model_handle.DirtyVariable("wm_option");
} }