Permalink
Browse files

Windows: Use system API to toggle fullscreen.

Instead of having a special Host API for Windows only.
  • Loading branch information...
unknownbrackets committed Jul 30, 2017
1 parent f8213a9 commit 626102e84aaded47380bfd779794e3bfa600c2b7
Showing with 26 additions and 14 deletions.
  1. +0 −1 Core/Host.h
  2. +1 −6 UI/GameSettingsScreen.cpp
  3. +0 −4 Windows/WindowsHost.cpp
  4. +0 −2 Windows/WindowsHost.h
  5. +8 −0 Windows/main.cpp
  6. +17 −1 ext/native/base/PCMain.cpp
View
@@ -38,7 +38,6 @@ class Host {
virtual void InitSound() = 0;
virtual void UpdateSound() {}
virtual void GoFullscreen(bool) {}
virtual void ShutdownSound() = 0;
virtual void PollControllers() {}
virtual void ToggleDebugConsoleVisibility() {}
@@ -972,12 +972,7 @@ UI::EventReturn GameSettingsScreen::OnReloadCheats(UI::EventParams &e) {
}
UI::EventReturn GameSettingsScreen::OnFullscreenChange(UI::EventParams &e) {
#if defined(USING_WIN_UI) || defined(USING_QT_UI)
host->GoFullscreen(g_Config.bFullScreen);
#else
// SDL, basically.
System_SendMessage("toggle_fullscreen", "");
#endif
System_SendMessage("toggle_fullscreen", g_Config.bFullScreen ? "1" : "0");
return UI::EVENT_DONE;
}
View
@@ -360,10 +360,6 @@ bool WindowsHost::CreateDesktopShortcut(std::string argumentPath, std::string ga
return false;
}
void WindowsHost::GoFullscreen(bool viewFullscreen) {
MainWindow::SendToggleFullscreen(viewFullscreen);
}
void WindowsHost::ToggleDebugConsoleVisibility() {
MainWindow::ToggleDebugConsoleVisibility();
}
View
@@ -66,8 +66,6 @@ class WindowsHost : public Host {
void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) override;
void GoFullscreen(bool) override;
std::shared_ptr<KeyboardDevice> keyboard;
GraphicsContext *GetGraphicsContext() { return gfx_; }
View
@@ -263,6 +263,14 @@ void System_SendMessage(const char *command, const char *parameter) {
MainWindow::BrowseAndBoot("");
} else if (!strcmp(command, "bgImage_browse")) {
MainWindow::BrowseBackground();
} else if (!strcmp(command, "toggle_fullscreen")) {
bool flag = !g_Config.bFullScreen;
if (strcmp(parameter, "0") == 0) {
flag = false;
} else if (strcmp(parameter, "1") == 0) {
flag = true;
}
MainWindow::SendToggleFullscreen(flag);
}
}
View
@@ -66,6 +66,7 @@ GlobalUIState GetUIState();
static SDL_Window* g_Screen = NULL;
static bool g_ToggleFullScreenNextFrame = false;
static int g_ToggleFullScreenType;
static int g_QuitRequested = 0;
static int g_DesktopWidth = 0;
@@ -248,6 +249,14 @@ void Vibrate(int length_ms) {
void System_SendMessage(const char *command, const char *parameter) {
if (!strcmp(command, "toggle_fullscreen")) {
g_ToggleFullScreenNextFrame = true;
if (strcmp(parameter, "1") == 0) {
g_ToggleFullScreenType = 1;
} else if (strcmp(parameter, "0") == 0) {
g_ToggleFullScreenType = 0;
} else {
// Just toggle.
g_ToggleFullScreenType = -1;
}
} else if (!strcmp(command, "finish")) {
// Do a clean exit
g_QuitRequested = true;
@@ -391,7 +400,14 @@ void ToggleFullScreenIfFlagSet() {
g_ToggleFullScreenNextFrame = false;
Uint32 window_flags = SDL_GetWindowFlags(g_Screen);
SDL_SetWindowFullscreen(g_Screen, window_flags ^ SDL_WINDOW_FULLSCREEN_DESKTOP);
if (g_ToggleFullScreenType == -1) {
window_flags ^= SDL_WINDOW_FULLSCREEN_DESKTOP;
} else if (g_ToggleFullScreenType == 1) {
window_flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
} else {
window_flags &= ~SDL_WINDOW_FULLSCREEN_DESKTOP;
}
SDL_SetWindowFullscreen(g_Screen, window_flags);
}
}

0 comments on commit 626102e

Please sign in to comment.