diff options
| author | Anthony <Helios747@users.noreply.github.com> | 2016-10-29 00:35:18 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-10-29 00:35:18 -0500 |
| commit | 41563c55cd56cbdaf245cf4ee26ca49a27861395 (patch) | |
| tree | 1f786af4aac6fb453ec53491af17e10e0896df65 /Source/Core/DolphinWX/Frame.cpp | |
| parent | 26902d89e89de46d43adf11a194ea1ef84b9f4da (diff) | |
| parent | ee201455a8810803a9966b951815143786a0767d (diff) | |
Merge pull request #4394 from aldelaro5/fix-focus-detection-linux
Fix window focus detection on Linux (rebase from #3843)
Diffstat (limited to 'Source/Core/DolphinWX/Frame.cpp')
| -rw-r--r-- | Source/Core/DolphinWX/Frame.cpp | 71 |
1 files changed, 9 insertions, 62 deletions
diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 5978dfc49d..a07586ad9c 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -504,18 +504,25 @@ void CFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) // Events void CFrame::OnActive(wxActivateEvent& event) { + m_bRendererHasFocus = (event.GetActive() && event.GetEventObject() == m_RenderFrame); if (Core::GetState() == Core::CORE_RUN || Core::GetState() == Core::CORE_PAUSE) { - if (event.GetActive() && event.GetEventObject() == m_RenderFrame) + if (m_bRendererHasFocus) { if (SConfig::GetInstance().bRenderToMain) m_RenderParent->SetFocus(); + if (SConfig::GetInstance().m_PauseOnFocusLost && Core::GetState() == Core::CORE_PAUSE) + DoPause(); + if (SConfig::GetInstance().bHideCursor && Core::GetState() == Core::CORE_RUN) m_RenderParent->SetCursor(wxCURSOR_BLANK); } else { + if (SConfig::GetInstance().m_PauseOnFocusLost && Core::GetState() == Core::CORE_RUN) + DoPause(); + if (SConfig::GetInstance().bHideCursor) m_RenderParent->SetCursor(wxNullCursor); } @@ -769,38 +776,7 @@ bool CFrame::RendererHasFocus() { if (m_RenderParent == nullptr) return false; -#ifdef _WIN32 - HWND window = GetForegroundWindow(); - if (window == nullptr) - return false; - - if (m_RenderFrame->GetHWND() == window) - return true; -#else - wxWindow* window = wxWindow::FindFocus(); - if (window == nullptr) - return false; - // Why these different cases? - if (m_RenderParent == window || m_RenderParent == window->GetParent() || - m_RenderParent->GetParent() == window->GetParent()) - { - return true; - } -#endif - return false; -} - -bool CFrame::UIHasFocus() -{ - // UIHasFocus should return true any time any one of our UI - // windows has the focus, including any dialogs or other windows. - // - // wxWindow::FindFocus() returns the current wxWindow which has - // focus. If it's not one of our windows, then it will return - // null. - - wxWindow* focusWindow = wxWindow::FindFocus(); - return (focusWindow != nullptr); + return m_bRendererHasFocus; } void CFrame::OnGameListCtrlItemActivated(wxListEvent& WXUNUSED(event)) @@ -1139,35 +1115,6 @@ void CFrame::OnMouse(wxMouseEvent& event) event.Skip(); } -void CFrame::OnFocusChange(wxFocusEvent& event) -{ - if (SConfig::GetInstance().m_PauseOnFocusLost && Core::IsRunningAndStarted()) - { - if (RendererHasFocus()) - { - if (Core::GetState() == Core::CORE_PAUSE) - { - Core::SetState(Core::CORE_RUN); - if (SConfig::GetInstance().bHideCursor) - m_RenderParent->SetCursor(wxCURSOR_BLANK); - } - } - else - { - if (Core::GetState() == Core::CORE_RUN) - { - Core::SetState(Core::CORE_PAUSE); - if (SConfig::GetInstance().bHideCursor) - m_RenderParent->SetCursor(wxNullCursor); - Core::UpdateTitle(); - } - } - UpdateGUI(); - } - - event.Skip(); -} - void CFrame::DoFullscreen(bool enable_fullscreen) { if (g_Config.bExclusiveMode && Core::GetState() == Core::CORE_PAUSE) |
