From 515577c8f9595b9726998de682629f16ad65e093 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sun, 5 Dec 2021 13:51:39 +0100 Subject: [PATCH] (Unix) Changed the fullscreen mode to SDL_WINDOW_FULLSCREEN_DESKTOP. Also removed the --windowed, --fullscreen-normal and --fullscreen-borderless command line options and menu entry. --- es-app/src/guis/GuiMenu.cpp | 19 -------------- es-app/src/main.cpp | 21 --------------- es-core/src/Platform.cpp | 2 +- es-core/src/Settings.cpp | 12 +-------- es-core/src/renderers/Renderer.cpp | 42 ++++++++++-------------------- 5 files changed, 16 insertions(+), 80 deletions(-) diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index 9f23fe566..a8555049b 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -878,25 +878,6 @@ void GuiMenu::openOtherOptions() } }); -#if defined(__unix__) - // Fullscreen mode. - auto fullscreen_mode = std::make_shared>( - mWindow, getHelpStyle(), "FULLSCREEN MODE", false); - std::vector screenmode; - screenmode.push_back("normal"); - screenmode.push_back("borderless"); - for (auto it = screenmode.cbegin(); it != screenmode.cend(); ++it) - fullscreen_mode->add(*it, *it, Settings::getInstance()->getString("FullscreenMode") == *it); - s->addWithLabel("FULLSCREEN MODE (REQUIRES RESTART)", fullscreen_mode); - s->addSaveFunc([fullscreen_mode, s] { - if (fullscreen_mode->getSelected() != - Settings::getInstance()->getString("FullscreenMode")) { - Settings::getInstance()->setString("FullscreenMode", fullscreen_mode->getSelected()); - s->setNeedsSaving(); - } - }); -#endif - #if defined(BUILD_VLC_PLAYER) // Video player. auto video_player = std::make_shared>( diff --git a/es-app/src/main.cpp b/es-app/src/main.cpp index 480f4652d..f0c6b9107 100644 --- a/es-app/src/main.cpp +++ b/es-app/src/main.cpp @@ -273,22 +273,6 @@ bool parseArgs(int argc, char* argv[]) Settings::getInstance()->setInt("ScreenRotate", rotate); ++i; } - // On Unix, enable settings for the fullscreen mode. - // On macOS and Windows only windowed mode is supported. - -#if defined(__unix__) - else if (strcmp(argv[i], "--windowed") == 0) { - Settings::getInstance()->setBool("Windowed", true); - } - else if (strcmp(argv[i], "--fullscreen-normal") == 0) { - Settings::getInstance()->setString("FullscreenMode", "normal"); - settingsNeedSaving = true; - } - else if (strcmp(argv[i], "--fullscreen-borderless") == 0) { - Settings::getInstance()->setString("FullscreenMode", "borderless"); - settingsNeedSaving = true; - } -#endif else if (strcmp(argv[i], "--vsync") == 0) { if (i >= argc - 1) { std::cerr << "Error: No VSync value supplied.\n"; @@ -360,11 +344,6 @@ bool parseArgs(int argc, char* argv[]) "Options:\n" " --display [index 1-4] Display/monitor to use\n" " --resolution [width] [height] Application resolution\n" -#if defined(__unix__) -" --windowed Windowed mode, should be combined with --resolution\n" -" --fullscreen-normal Normal fullscreen mode\n" -" --fullscreen-borderless Borderless fullscreen mode (always on top)\n" -#endif " --vsync [1/on or 0/off] Turn VSync on or off (default is on)\n" " --max-vram [size] Max VRAM to use (in mebibytes) before swapping\n" " --no-splash Don't show the splash screen during startup\n" diff --git a/es-core/src/Platform.cpp b/es-core/src/Platform.cpp index 8b54b08a7..cf2df359d 100644 --- a/es-core/src/Platform.cpp +++ b/es-core/src/Platform.cpp @@ -102,7 +102,7 @@ int launchGameUnix(const std::string& cmd_utf8, bool runInBackground) #if defined(_RPI_) // Hack to avoid that the application window occasionally loses focus when returning from - // a game, which only seems to happen on the Raspberry Pi. + // a game, which only seems to happen on Raspberry Pi OS 10. SDL_Delay(50); SDL_SetWindowInputFocus(Renderer::getSDLWindow()); #endif diff --git a/es-core/src/Settings.cpp b/es-core/src/Settings.cpp index 68814e5b3..60869faed 100644 --- a/es-core/src/Settings.cpp +++ b/es-core/src/Settings.cpp @@ -25,8 +25,7 @@ namespace // the in-program settings menu. Most can be set using command-line arguments, // but some are debug flags that are either hardcoded or set by internal debug // functions. - std::vector settingsSkipSaving - { + std::vector settingsSkipSaving{ // clang-format off // These options can be set using command-line arguments: "WindowWidth", // Set via --resolution [width] [height] @@ -35,9 +34,6 @@ namespace "IgnoreGamelist", // --ignore-gamelist "SplashScreen", // --no-splash "Debug", // --debug - #if !defined(_WIN64) - "Windowed", // --windowed - #endif "VSync", // --vsync [1/on or 0/off] "ForceFull", // --force-full "ForceKiosk", // --force-kiosk @@ -225,9 +221,6 @@ void Settings::setDefaults() mIntMap["MaxVRAM"] = {256, 256}; #endif mIntMap["DisplayIndex"] = {1, 1}; -#if defined(__unix__) - mStringMap["FullscreenMode"] = {"normal", "normal"}; -#endif #if defined(BUILD_VLC_PLAYER) mStringMap["VideoPlayer"] = {"ffmpeg", "ffmpeg"}; #endif @@ -275,9 +268,6 @@ void Settings::setDefaults() mBoolMap["IgnoreGamelist"] = {false, false}; mBoolMap["SplashScreen"] = {true, true}; mBoolMap["VSync"] = {true, true}; -#if !defined(_WIN64) - mBoolMap["Windowed"] = {false, false}; -#endif mIntMap["WindowWidth"] = {0, 0}; mIntMap["WindowHeight"] = {0, 0}; mIntMap["ScreenWidth"] = {0, 0}; diff --git a/es-core/src/renderers/Renderer.cpp b/es-core/src/renderers/Renderer.cpp index ccbc6e55d..c7996e6bf 100644 --- a/es-core/src/renderers/Renderer.cpp +++ b/es-core/src/renderers/Renderer.cpp @@ -172,23 +172,19 @@ namespace Renderer setupWindow(); #if defined(_WIN64) - // For Windows, always set the mode to windowed, as full screen mode seems to - // behave quite erratic. There may be a proper fix for this, but for now windowed - // mode seems to behave well and it's almost completely seamless, especially with - // a hidden taskbar. As well, setting SDL_WINDOW_BORDERLESS introduces issues too - // so unfortunately this needs to be avoided. + // For Windows, always set the mode to windowed as full screen mode seems to behave quite + // erratic. There may be a proper fix for this, but for now windowed mode seems to behave + // well and it's almost completely seamless, especially with a hidden taskbar. windowFlags = getWindowFlags(); #elif defined(__APPLE__) - // This seems to be the only full window mode that somehow works on macOS as a real - // fullscreen mode will do lots of weird stuff like preventing window switching - // or refusing to let emulators run at all. SDL_WINDOW_FULLSCREEN_DESKTOP almost - // works, but it "shuffles" windows when starting the emulator and won't return - // properly when the game has exited. With the current mode, the top menu is visible - // and hides that part of the ES window. Also, the splash screen is not displayed - // until the point where ES has almost completely finished loading. I'm not sure - // if anything can be done to improve these things as it's quite obvious that - // Apple has shipped a broken and/or dysfunctional window manager with their - // operating system. + // The SDL_WINDOW_BORDERLESS mode seems to be the only mode that somehow works on macOS + // as a real fullscreen mode will do lots of weird stuff like preventing window switching + // or refusing to let emulators run at all. SDL_WINDOW_FULLSCREEN_DESKTOP almost works, but + // it "shuffles" windows when starting the emulator and won't return properly when the game + // has exited. With SDL_WINDOW_BORDERLESS, the splash screen is not displayed until the + // point where ES-DE has almost completely finished loading. As well the emulator has to be + // configured to run in fullscreen mode or switching to its windows will not work when a + // game is launched. So there is room for improvement although it's acceptable for now. if (!userResolution) windowFlags = SDL_WINDOW_BORDERLESS | SDL_WINDOW_ALLOW_HIGHDPI | getWindowFlags(); else @@ -196,20 +192,10 @@ namespace Renderer // border to the window. windowFlags = SDL_WINDOW_ALLOW_HIGHDPI | getWindowFlags(); #else - if (Settings::getInstance()->getBool("Windowed")) { + if (!userResolution) + windowFlags = SDL_WINDOW_FULLSCREEN_DESKTOP | getWindowFlags(); + else windowFlags = getWindowFlags(); - } - else if (Settings::getInstance()->getString("FullscreenMode") == "borderless") { - if (!userResolution) - windowFlags = SDL_WINDOW_BORDERLESS | SDL_WINDOW_ALWAYS_ON_TOP | getWindowFlags(); - else - // If the user has changed the resolution from the command line, then add a - // border to the window and don't make it stay on top. - windowFlags = getWindowFlags(); - } - else { - windowFlags = SDL_WINDOW_FULLSCREEN | getWindowFlags(); - } #endif if ((sdlWindow =