From b7e056c74d6c157d04cbb79bbb7660a169662c53 Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Sun, 4 Jan 2015 17:09:56 +0100 Subject: [PATCH] Host: Add Host_RendererIsFullscreen(). --- Source/Core/Core/Host.h | 1 + Source/Core/DolphinQt/Host.cpp | 5 +++++ Source/Core/DolphinWX/Frame.h | 2 +- Source/Core/DolphinWX/Main.cpp | 5 +++++ Source/Core/DolphinWX/MainAndroid.cpp | 5 +++++ Source/Core/DolphinWX/MainNoGUI.cpp | 9 ++++++++- Source/Core/DolphinWX/X11Utils.cpp | 7 ++++++- Source/Core/DolphinWX/X11Utils.h | 2 +- Source/UnitTests/TestUtils/StubHost.cpp | 1 + 9 files changed, 33 insertions(+), 4 deletions(-) diff --git a/Source/Core/Core/Host.h b/Source/Core/Core/Host.h index 3bb2ec76b1..2ca0195fa4 100644 --- a/Source/Core/Core/Host.h +++ b/Source/Core/Core/Host.h @@ -25,6 +25,7 @@ bool Host_UIHasFocus(); bool Host_RendererHasFocus(); +bool Host_RendererIsFullscreen(); void Host_ConnectWiimote(int wm_idx, bool connect); void Host_Message(int Id); void Host_NotifyMapLoaded(); diff --git a/Source/Core/DolphinQt/Host.cpp b/Source/Core/DolphinQt/Host.cpp index 1969dad4fd..6868f40f8e 100644 --- a/Source/Core/DolphinQt/Host.cpp +++ b/Source/Core/DolphinQt/Host.cpp @@ -48,6 +48,11 @@ bool Host_UIHasFocus() return g_main_window->isActiveWindow(); } +bool Host_RendererIsFullscreen() +{ + return false; // TODO +} + void Host_RequestFullscreen(bool enable) { // TODO diff --git a/Source/Core/DolphinWX/Frame.h b/Source/Core/DolphinWX/Frame.h index 94c54cbfef..0c9c7bc280 100644 --- a/Source/Core/DolphinWX/Frame.h +++ b/Source/Core/DolphinWX/Frame.h @@ -119,6 +119,7 @@ public: void OnRenderParentMove(wxMoveEvent& event); bool RendererHasFocus(); bool UIHasFocus(); + bool RendererIsFullscreen(); void DoFullscreen(bool bF); void ToggleDisplayMode (bool bFullscreen); void UpdateWiiMenuChoice(wxMenuItem *WiiMenuItem=nullptr); @@ -329,7 +330,6 @@ private: void OnGameListCtrl_ItemActivated(wxListEvent& event); void OnRenderParentResize(wxSizeEvent& event); - bool RendererIsFullscreen(); void StartGame(const std::string& filename); void OnChangeColumnsVisible(wxCommandEvent& event); diff --git a/Source/Core/DolphinWX/Main.cpp b/Source/Core/DolphinWX/Main.cpp index 2d3a322dfa..dcb200059a 100644 --- a/Source/Core/DolphinWX/Main.cpp +++ b/Source/Core/DolphinWX/Main.cpp @@ -572,6 +572,11 @@ bool Host_RendererHasFocus() return main_frame->RendererHasFocus(); } +bool Host_RendererIsFullscreen() +{ + return main_frame->RendererIsFullscreen(); +} + void Host_ConnectWiimote(int wm_idx, bool connect) { CFrame::ConnectWiimote(wm_idx, connect); diff --git a/Source/Core/DolphinWX/MainAndroid.cpp b/Source/Core/DolphinWX/MainAndroid.cpp index 533dd90c30..0d9d4428ce 100644 --- a/Source/Core/DolphinWX/MainAndroid.cpp +++ b/Source/Core/DolphinWX/MainAndroid.cpp @@ -94,6 +94,11 @@ bool Host_RendererHasFocus() return true; } +bool Host_RendererIsFullscreen() +{ + return false; +} + void Host_ConnectWiimote(int wm_idx, bool connect) {} void Host_SetWiiMoteConnectionState(int _State) {} diff --git a/Source/Core/DolphinWX/MainNoGUI.cpp b/Source/Core/DolphinWX/MainNoGUI.cpp index be3d9a7df3..8d6d0282a6 100644 --- a/Source/Core/DolphinWX/MainNoGUI.cpp +++ b/Source/Core/DolphinWX/MainNoGUI.cpp @@ -26,6 +26,7 @@ #include "VideoCommon/VideoBackendBase.h" static bool rendererHasFocus = true; +static bool rendererIsFullscreen = false; static bool running = true; class Platform @@ -89,6 +90,11 @@ bool Host_RendererHasFocus() return rendererHasFocus; } +bool Host_RendererIsFullscreen() +{ + return rendererIsFullscreen; +} + void Host_ConnectWiimote(int wm_idx, bool connect) {} void Host_SetWiiMoteConnectionState(int _State) {} @@ -158,7 +164,7 @@ class PlatformX11 : public Platform if (fullscreen) { - X11Utils::ToggleFullscreen(dpy, win); + rendererIsFullscreen = X11Utils::ToggleFullscreen(dpy, win); #if defined(HAVE_XRANDR) && HAVE_XRANDR XRRConfig->ToggleDisplayMode(True); #endif @@ -246,6 +252,7 @@ class PlatformX11 : public Platform (unsigned int *)&SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowWidth, (unsigned int *)&SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowHeight, &borderDummy, &depthDummy); + rendererIsFullscreen = false; } usleep(100000); } diff --git a/Source/Core/DolphinWX/X11Utils.cpp b/Source/Core/DolphinWX/X11Utils.cpp index 6a666692a2..03973b1aba 100644 --- a/Source/Core/DolphinWX/X11Utils.cpp +++ b/Source/Core/DolphinWX/X11Utils.cpp @@ -24,7 +24,7 @@ extern char **environ; namespace X11Utils { -void ToggleFullscreen(Display *dpy, Window win) +bool ToggleFullscreen(Display *dpy, Window win) { // Init X event structure for _NET_WM_STATE_FULLSCREEN client message XEvent event; @@ -38,7 +38,12 @@ void ToggleFullscreen(Display *dpy, Window win) // Send the event if (!XSendEvent(dpy, DefaultRootWindow(dpy), False, SubstructureRedirectMask | SubstructureNotifyMask, &event)) + { ERROR_LOG(VIDEO, "Failed to switch fullscreen/windowed mode."); + return false; + } + + return true; } void InhibitScreensaver(Display *dpy, Window win, bool suspend) diff --git a/Source/Core/DolphinWX/X11Utils.h b/Source/Core/DolphinWX/X11Utils.h index b68a1babe6..0a62e3027b 100644 --- a/Source/Core/DolphinWX/X11Utils.h +++ b/Source/Core/DolphinWX/X11Utils.h @@ -34,7 +34,7 @@ namespace X11Utils { -void ToggleFullscreen(Display *dpy, Window win); +bool ToggleFullscreen(Display *dpy, Window win); #if defined(HAVE_WX) && HAVE_WX Window XWindowFromHandle(void *Handle); Display *XDisplayFromHandle(void *Handle); diff --git a/Source/UnitTests/TestUtils/StubHost.cpp b/Source/UnitTests/TestUtils/StubHost.cpp index 2e8839ea67..a4d75cdca7 100644 --- a/Source/UnitTests/TestUtils/StubHost.cpp +++ b/Source/UnitTests/TestUtils/StubHost.cpp @@ -22,6 +22,7 @@ void Host_RequestFullscreen(bool) {} void Host_SetStartupDebuggingParameters() {} bool Host_UIHasFocus() { return false; } bool Host_RendererHasFocus() { return false; } +bool Host_RendererIsFullscreen() { return false; } void Host_ConnectWiimote(int, bool) {} void Host_SetWiiMoteConnectionState(int) {} void Host_ShowVideoConfig(void*, const std::string&, const std::string&) {}