From 341e7e9d8ff6c77d7eaba4d47e56044203ee80e2 Mon Sep 17 00:00:00 2001 From: Gerik Kubiak Date: Mon, 16 Mar 2015 20:28:17 -0700 Subject: [PATCH 1/4] Added the ability to pause the emulator by moving the mouse outside the window. --- Source/Core/Core/ConfigManager.cpp | 2 ++ Source/Core/Core/ConfigManager.h | 2 ++ Source/Core/DolphinWX/Frame.cpp | 27 +++++++++++++++++++++++++++ Source/Core/DolphinWX/FrameTools.cpp | 16 +++++++++------- 4 files changed, 40 insertions(+), 7 deletions(-) diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index 6fc09c46d5..225fe04a00 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -242,6 +242,7 @@ void SConfig::SaveInterfaceSettings(IniFile& ini) interface->Set("ShowLogConfigWindow", m_InterfaceLogConfigWindow); interface->Set("ExtendedFPSInfo", m_InterfaceExtendedFPSInfo); interface->Set("ThemeName40", m_LocalCoreStartupParameter.theme_name); + interface->Set("PauseOnFocusLost", m_PauseOnFocusLost); } void SConfig::SaveHotkeySettings(IniFile& ini) @@ -464,6 +465,7 @@ void SConfig::LoadInterfaceSettings(IniFile& ini) interface->Get("ShowLogConfigWindow", &m_InterfaceLogConfigWindow, false); interface->Get("ExtendedFPSInfo", &m_InterfaceExtendedFPSInfo, false); interface->Get("ThemeName40", &m_LocalCoreStartupParameter.theme_name, "Clean"); + interface->Get("PauseOnFocusLost", &m_PauseOnFocusLost, false); } void SConfig::LoadHotkeySettings(IniFile& ini) diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h index 80f0523208..cac39cbb31 100644 --- a/Source/Core/Core/ConfigManager.h +++ b/Source/Core/Core/ConfigManager.h @@ -103,6 +103,8 @@ struct SConfig : NonCopyable bool m_DumpFramesSilent; bool m_ShowInputDisplay; + bool m_PauseOnFocusLost; + // DSP settings bool m_DSPEnableJIT; bool m_DSPCaptureLog; diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index ff82e1cd65..3678d349c5 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -1121,6 +1121,33 @@ 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) { diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index 31d366a55a..b61f093c18 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -1073,13 +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_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); m_RenderParent->Bind(wxEVT_SIZE, &CFrame::OnRenderParentResize, this); } From 88fb8edf8e9a253c7163e6aad893e2af4c857978 Mon Sep 17 00:00:00 2001 From: Gerik Kubiak Date: Mon, 16 Mar 2015 21:31:13 -0700 Subject: [PATCH 2/4] Change behavior so emulation is paused when window focus is lost. --- Source/Core/DolphinWX/Frame.cpp | 56 ++++++++++++++-------------- Source/Core/DolphinWX/Frame.h | 2 + Source/Core/DolphinWX/FrameTools.cpp | 18 ++++----- 3 files changed, 40 insertions(+), 36 deletions(-) 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); } From 0a28f7de13a8f3330d8f9a574149ea131a8ca411 Mon Sep 17 00:00:00 2001 From: Gerik Kubiak Date: Mon, 16 Mar 2015 22:13:27 -0700 Subject: [PATCH 3/4] Added checkbox under Config > Interface. --- Source/Core/DolphinWX/ConfigMain.cpp | 8 ++++++++ Source/Core/DolphinWX/ConfigMain.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/Source/Core/DolphinWX/ConfigMain.cpp b/Source/Core/DolphinWX/ConfigMain.cpp index a6a252dc82..881ac768a0 100644 --- a/Source/Core/DolphinWX/ConfigMain.cpp +++ b/Source/Core/DolphinWX/ConfigMain.cpp @@ -154,6 +154,7 @@ EVT_SLIDER(ID_VOLUME, CConfigMain::AudioSettingsChanged) EVT_CHECKBOX(ID_INTERFACE_CONFIRMSTOP, CConfigMain::DisplaySettingsChanged) EVT_CHECKBOX(ID_INTERFACE_USEPANICHANDLERS, CConfigMain::DisplaySettingsChanged) EVT_CHECKBOX(ID_INTERFACE_ONSCREENDISPLAYMESSAGES, CConfigMain::DisplaySettingsChanged) +EVT_CHECKBOX(ID_INTERFACE_PAUSEONFOCUSLOST, CConfigMain::DisplaySettingsChanged) EVT_CHOICE(ID_INTERFACE_LANG, CConfigMain::DisplaySettingsChanged) EVT_BUTTON(ID_HOTKEY_CONFIG, CConfigMain::DisplaySettingsChanged) @@ -354,6 +355,7 @@ void CConfigMain::InitializeGUIValues() ConfirmStop->SetValue(startup_params.bConfirmStop); UsePanicHandlers->SetValue(startup_params.bUsePanicHandlers); OnScreenDisplayMessages->SetValue(startup_params.bOnScreenDisplayMessages); + PauseOnFocusLost->SetValue(SConfig::GetInstance().m_PauseOnFocusLost); // need redesign for (unsigned int i = 0; i < sizeof(langIds) / sizeof(wxLanguage); i++) { @@ -486,6 +488,7 @@ void CConfigMain::InitializeGUITooltips() ConfirmStop->SetToolTip(_("Show a confirmation box before stopping a game.")); UsePanicHandlers->SetToolTip(_("Show a message box when a potentially serious error has occurred.\nDisabling this may avoid annoying and non-fatal messages, but it may result in major crashes having no explanation at all.")); OnScreenDisplayMessages->SetToolTip(_("Display messages over the emulation screen area.\nThese messages include memory card writes, video backend and CPU information, and JIT cache clearing.")); + PauseOnFocusLost->SetToolTip(_("Pauses the emulator when focus is taken away from the emulation screen.")); InterfaceLang->SetToolTip(_("Change the language of the user interface.\nRequires restart.")); @@ -577,6 +580,7 @@ void CConfigMain::CreateGUIControls() ConfirmStop = new wxCheckBox(DisplayPage, ID_INTERFACE_CONFIRMSTOP, _("Confirm on Stop")); UsePanicHandlers = new wxCheckBox(DisplayPage, ID_INTERFACE_USEPANICHANDLERS, _("Use Panic Handlers")); OnScreenDisplayMessages = new wxCheckBox(DisplayPage, ID_INTERFACE_ONSCREENDISPLAYMESSAGES, _("On-Screen Display Messages")); + PauseOnFocusLost = new wxCheckBox(DisplayPage, ID_INTERFACE_PAUSEONFOCUSLOST, _("Pause on Focus Lost")); wxBoxSizer* sInterface = new wxBoxSizer(wxHORIZONTAL); sInterface->Add(TEXT_BOX(DisplayPage, _("Language:")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); @@ -623,6 +627,7 @@ void CConfigMain::CreateGUIControls() sbInterface->Add(ConfirmStop, 0, wxALL, 5); sbInterface->Add(UsePanicHandlers, 0, wxALL, 5); sbInterface->Add(OnScreenDisplayMessages, 0, wxALL, 5); + sbInterface->Add(PauseOnFocusLost, 0, wxALL, 5); sbInterface->Add(scInterface, 0, wxEXPAND | wxALL, 5); sbInterface->Add(sInterface, 0, wxEXPAND | wxALL, 5); sDisplayPage = new wxBoxSizer(wxVERTICAL); @@ -938,6 +943,9 @@ void CConfigMain::DisplaySettingsChanged(wxCommandEvent& event) SConfig::GetInstance().m_LocalCoreStartupParameter.bOnScreenDisplayMessages = OnScreenDisplayMessages->IsChecked(); SetEnableAlert(OnScreenDisplayMessages->IsChecked()); break; + case ID_INTERFACE_PAUSEONFOCUSLOST: + SConfig::GetInstance().m_PauseOnFocusLost = PauseOnFocusLost->IsChecked(); + break; case ID_INTERFACE_LANG: if (SConfig::GetInstance().m_InterfaceLanguage != langIds[InterfaceLang->GetSelection()]) SuccessAlertT("You must restart Dolphin in order for the change to take effect."); diff --git a/Source/Core/DolphinWX/ConfigMain.h b/Source/Core/DolphinWX/ConfigMain.h index f542187ac5..e2c48a7fb2 100644 --- a/Source/Core/DolphinWX/ConfigMain.h +++ b/Source/Core/DolphinWX/ConfigMain.h @@ -99,6 +99,7 @@ private: ID_INTERFACE_CONFIRMSTOP, ID_INTERFACE_USEPANICHANDLERS, ID_INTERFACE_ONSCREENDISPLAYMESSAGES, + ID_INTERFACE_PAUSEONFOCUSLOST, ID_INTERFACE_LANG, ID_HOTKEY_CONFIG, @@ -170,6 +171,7 @@ private: wxCheckBox* ConfirmStop; wxCheckBox* UsePanicHandlers; wxCheckBox* OnScreenDisplayMessages; + wxCheckBox* PauseOnFocusLost; wxChoice* InterfaceLang; wxButton* HotkeyConfig; From ae4e8b63587ab2c7377bac120c63e3bb7e386b7d Mon Sep 17 00:00:00 2001 From: Gerik Kubiak Date: Tue, 17 Mar 2015 12:14:14 -0700 Subject: [PATCH 4/4] Changed screen to window. Moved UpdateGUI to a more general scope. --- Source/Core/DolphinWX/ConfigMain.cpp | 2 +- Source/Core/DolphinWX/Frame.cpp | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Source/Core/DolphinWX/ConfigMain.cpp b/Source/Core/DolphinWX/ConfigMain.cpp index 881ac768a0..fa666eae71 100644 --- a/Source/Core/DolphinWX/ConfigMain.cpp +++ b/Source/Core/DolphinWX/ConfigMain.cpp @@ -488,7 +488,7 @@ void CConfigMain::InitializeGUITooltips() ConfirmStop->SetToolTip(_("Show a confirmation box before stopping a game.")); UsePanicHandlers->SetToolTip(_("Show a message box when a potentially serious error has occurred.\nDisabling this may avoid annoying and non-fatal messages, but it may result in major crashes having no explanation at all.")); OnScreenDisplayMessages->SetToolTip(_("Display messages over the emulation screen area.\nThese messages include memory card writes, video backend and CPU information, and JIT cache clearing.")); - PauseOnFocusLost->SetToolTip(_("Pauses the emulator when focus is taken away from the emulation screen.")); + PauseOnFocusLost->SetToolTip(_("Pauses the emulator when focus is taken away from the emulation window.")); InterfaceLang->SetToolTip(_("Change the language of the user interface.\nRequires restart.")); diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index f96aa04267..b21bbd866d 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -1188,8 +1188,6 @@ void CFrame::OnFocusChange(wxFocusEvent& event) if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor) m_RenderParent->SetCursor(wxCURSOR_BLANK); } - UpdateGUI(); - } else { @@ -1200,8 +1198,8 @@ void CFrame::OnFocusChange(wxFocusEvent& event) m_RenderParent->SetCursor(wxNullCursor); Core::UpdateTitle(); } - UpdateGUI(); } + UpdateGUI(); } }