Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #633 from magcius/wip/input-focus-fix
Fix input focus issues
  • Loading branch information
delroth committed Jul 16, 2014
2 parents 30e4366 + 44307c9 commit 8cf21cd
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 2 deletions.
1 change: 1 addition & 0 deletions Source/Core/Core/Host.h
Expand Up @@ -23,6 +23,7 @@
// The host can be just a command line app that opens a window, or a full blown debugger
// interface.

bool Host_UIHasFocus();
bool Host_RendererHasFocus();
void Host_ConnectWiimote(int wm_idx, bool connect);
void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height);
Expand Down
24 changes: 23 additions & 1 deletion Source/Core/DolphinWX/Frame.cpp
Expand Up @@ -753,7 +753,29 @@ void CFrame::OnRenderWindowSizeRequest(int width, int height)

bool CFrame::RendererHasFocus()
{
// RendererHasFocus should return true any time any one of our
if (m_RenderParent == nullptr)
return false;
#ifdef _WIN32
if (m_RenderParent->GetParent()->GetHWND() == GetForegroundWindow())
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.
//
// wxGetActiveWindow() returns the current wxWindow which has
Expand Down
1 change: 1 addition & 0 deletions Source/Core/DolphinWX/Frame.h
Expand Up @@ -138,6 +138,7 @@ class CFrame : public CRenderFrame
void OnRenderParentClose(wxCloseEvent& event);
void OnRenderParentMove(wxMoveEvent& event);
bool RendererHasFocus();
bool UIHasFocus();
void DoFullscreen(bool bF);
void ToggleDisplayMode (bool bFullscreen);
void UpdateWiiMenuChoice(wxMenuItem *WiiMenuItem=nullptr);
Expand Down
5 changes: 5 additions & 0 deletions Source/Core/DolphinWX/Main.cpp
Expand Up @@ -678,6 +678,11 @@ void Host_SetWiiMoteConnectionState(int _State)
main_frame->GetEventHandler()->AddPendingEvent(event);
}

bool Host_UIHasFocus()
{
return main_frame->UIHasFocus();
}

bool Host_RendererHasFocus()
{
return main_frame->RendererHasFocus();
Expand Down
5 changes: 5 additions & 0 deletions Source/Core/DolphinWX/MainAndroid.cpp
Expand Up @@ -98,6 +98,11 @@ void Host_SetStartupDebuggingParameters()
{
}

bool Host_UIHasFocus()
{
return true;
}

bool Host_RendererHasFocus()
{
return true;
Expand Down
5 changes: 5 additions & 0 deletions Source/Core/DolphinWX/MainNoGUI.cpp
Expand Up @@ -95,6 +95,11 @@ void Host_SetStartupDebuggingParameters()
StartUp.bBootToPause = false;
}

bool Host_UIHasFocus()
{
return false;
}

bool Host_RendererHasFocus()
{
return rendererHasFocus;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/InputCommon/ControllerInterface/Device.cpp
Expand Up @@ -84,7 +84,7 @@ bool Device::Control::InputGateOn()
{
if (SConfig::GetInstance().m_BackgroundInput)
return true;
else if (Host_RendererHasFocus())
else if (Host_RendererHasFocus() || Host_UIHasFocus())
return true;
else
return false;
Expand Down

0 comments on commit 8cf21cd

Please sign in to comment.