* Make the shell menus focus the parent before displaying themselves. Fixes keyboard focus when opening the start menu with the windows key.
NOTE: I put this in the focus manager for lack of a better place, but it may not be how Windows does it.

svn path=/trunk/; revision=65769
This commit is contained in:
David Quintana 2014-12-20 17:45:45 +00:00
parent 2dc90d89b4
commit cb546b4121
2 changed files with 24 additions and 0 deletions

View file

@ -163,6 +163,7 @@ CMenuFocusManager::CMenuFocusManager() :
m_isLButtonDown(FALSE),
m_movedSinceDown(FALSE),
m_windowAtDown(NULL),
m_PreviousForeground(NULL),
m_bandCount(0),
m_menuDepth(0)
{
@ -704,7 +705,14 @@ HRESULT CMenuFocusManager::UpdateFocus()
m_current = NULL;
if (!m_current || m_current->type != MenuPopupEntry)
{
SetMenuCapture(NULL);
if (old && old->type == MenuPopupEntry && m_PreviousForeground)
{
::SetForegroundWindow(m_PreviousForeground);
m_PreviousForeground = NULL;
}
}
if (m_current && m_current->type != TrackedMenuEntry)
{
@ -771,10 +779,24 @@ HRESULT CMenuFocusManager::UpdateFocus()
hr = topMenu->mb->GetSite(IID_PPV_ARG(IServiceProvider, &bandSite));
hr = bandSite->QueryService(SID_SMenuBandParent, IID_PPV_ARG(IOleWindow, &deskBar));
CComPtr<IOleWindow> deskBarSite;
hr = IUnknown_GetSite(deskBar, IID_PPV_ARG(IOleWindow, &deskBarSite));
// FIXME: Find the correct place for this
HWND hWndOwner;
deskBarSite->GetWindow(&hWndOwner);
m_PreviousForeground = ::GetForegroundWindow();
if (m_PreviousForeground != hWndOwner)
::SetForegroundWindow(hWndOwner);
else
m_PreviousForeground = NULL;
// Get the HWND of the top-level window
HWND hWndSite;
hr = deskBar->GetWindow(&hWndSite);
SetMenuCapture(hWndSite);
}
if (!m_parent || m_parent->type == MenuBarEntry)

View file

@ -81,6 +81,8 @@ private:
BOOL m_movedSinceDown;
HWND m_windowAtDown;
HWND m_PreviousForeground;
// TODO: make dynamic
#define MAX_RECURSE 20
StackEntry m_bandStack[MAX_RECURSE];