diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 3678d349c5..f96aa04267 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -1121,33 +1121,6 @@ void CFrame::OnKeyUp(wxKeyEvent& event) void CFrame::OnMouse(wxMouseEvent& event) { - if (SConfig::GetInstance().m_PauseOnFocusLost && - event.GetEventObject() == (wxObject*)m_RenderParent) - { - if (event.Leaving()) - { - if (Core::GetState() == Core::CORE_RUN) - { - Core::SetState(Core::CORE_PAUSE); - if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor) - m_RenderParent->SetCursor(wxNullCursor); - Core::UpdateTitle(); - } - UpdateGUI(); - } - else if (event.Entering()) - { - if (Core::GetState() == Core::CORE_PAUSE) - { - Core::SetState(Core::CORE_RUN); - if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor) - m_RenderParent->SetCursor(wxCURSOR_BLANK); - } - UpdateGUI(); - } - } - - // next handlers are all for FreeLook, so we don't need to check them if disabled if (!g_Config.bFreeLook) { @@ -1203,6 +1176,35 @@ void CFrame::OnMouse(wxMouseEvent& event) event.Skip(); } +void CFrame::OnFocusChange(wxFocusEvent& event) +{ + if (SConfig::GetInstance().m_PauseOnFocusLost) + { + if (RendererHasFocus()) + { + if (Core::GetState() == Core::CORE_PAUSE) + { + Core::SetState(Core::CORE_RUN); + if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor) + m_RenderParent->SetCursor(wxCURSOR_BLANK); + } + UpdateGUI(); + + } + else + { + if (Core::GetState() == Core::CORE_RUN) + { + Core::SetState(Core::CORE_PAUSE); + if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor) + m_RenderParent->SetCursor(wxNullCursor); + Core::UpdateTitle(); + } + UpdateGUI(); + } + } +} + void CFrame::DoFullscreen(bool enable_fullscreen) { if (g_Config.bExclusiveMode && Core::GetState() == Core::CORE_PAUSE) diff --git a/Source/Core/DolphinWX/Frame.h b/Source/Core/DolphinWX/Frame.h index e1a7eabfd7..aaad7b0e6c 100644 --- a/Source/Core/DolphinWX/Frame.h +++ b/Source/Core/DolphinWX/Frame.h @@ -334,6 +334,8 @@ private: void OnMouse(wxMouseEvent& event); // Mouse + void OnFocusChange(wxFocusEvent& event); + void OnHostMessage(wxCommandEvent& event); void OnMemcard(wxCommandEvent& event); // Misc diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index b61f093c18..65689012dd 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -1073,15 +1073,15 @@ void CFrame::StartGame(const std::string& filename) m_RenderParent->SetFocus(); - wxTheApp->Bind(wxEVT_KEY_DOWN, &CFrame::OnKeyDown, this); - wxTheApp->Bind(wxEVT_KEY_UP, &CFrame::OnKeyUp, this); - wxTheApp->Bind(wxEVT_RIGHT_DOWN, &CFrame::OnMouse, this); - wxTheApp->Bind(wxEVT_RIGHT_UP, &CFrame::OnMouse, this); - wxTheApp->Bind(wxEVT_MIDDLE_DOWN, &CFrame::OnMouse, this); - wxTheApp->Bind(wxEVT_MIDDLE_UP, &CFrame::OnMouse, this); - wxTheApp->Bind(wxEVT_MOTION, &CFrame::OnMouse, this); - wxTheApp->Bind(wxEVT_ENTER_WINDOW, &CFrame::OnMouse, this); - wxTheApp->Bind(wxEVT_LEAVE_WINDOW, &CFrame::OnMouse, this); + wxTheApp->Bind(wxEVT_KEY_DOWN, &CFrame::OnKeyDown, this); + wxTheApp->Bind(wxEVT_KEY_UP, &CFrame::OnKeyUp, this); + wxTheApp->Bind(wxEVT_RIGHT_DOWN, &CFrame::OnMouse, this); + wxTheApp->Bind(wxEVT_RIGHT_UP, &CFrame::OnMouse, this); + wxTheApp->Bind(wxEVT_MIDDLE_DOWN, &CFrame::OnMouse, this); + wxTheApp->Bind(wxEVT_MIDDLE_UP, &CFrame::OnMouse, this); + wxTheApp->Bind(wxEVT_MOTION, &CFrame::OnMouse, this); + wxTheApp->Bind(wxEVT_SET_FOCUS, &CFrame::OnFocusChange, this); + wxTheApp->Bind(wxEVT_KILL_FOCUS, &CFrame::OnFocusChange, this); m_RenderParent->Bind(wxEVT_SIZE, &CFrame::OnRenderParentResize, this); }