Author: dquintana
Date: Sat Dec 20 17:45:45 2014
New Revision: 65769

URL: http://svn.reactos.org/svn/reactos?rev=65769&view=rev
Log:
[RSHELL]
* 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.

Modified:
    trunk/reactos/base/shell/rshell/CMenuFocusManager.cpp
    trunk/reactos/base/shell/rshell/CMenuFocusManager.h

Modified: trunk/reactos/base/shell/rshell/CMenuFocusManager.cpp
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/rshell/CMenuFocusManager.cpp?rev=65769&r1=65768&r2=65769&view=diff
==============================================================================
--- trunk/reactos/base/shell/rshell/CMenuFocusManager.cpp       [iso-8859-1] 
(original)
+++ trunk/reactos/base/shell/rshell/CMenuFocusManager.cpp       [iso-8859-1] 
Sat Dec 20 17:45:45 2014
@@ -163,6 +163,7 @@
     m_isLButtonDown(FALSE),
     m_movedSinceDown(FALSE),
     m_windowAtDown(NULL),
+    m_PreviousForeground(NULL),
     m_bandCount(0),
     m_menuDepth(0)
 {
@@ -704,7 +705,14 @@
         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 @@
             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)

Modified: trunk/reactos/base/shell/rshell/CMenuFocusManager.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/rshell/CMenuFocusManager.h?rev=65769&r1=65768&r2=65769&view=diff
==============================================================================
--- trunk/reactos/base/shell/rshell/CMenuFocusManager.h [iso-8859-1] (original)
+++ trunk/reactos/base/shell/rshell/CMenuFocusManager.h [iso-8859-1] Sat Dec 20 
17:45:45 2014
@@ -81,6 +81,8 @@
     BOOL m_movedSinceDown;
     HWND m_windowAtDown;
 
+    HWND m_PreviousForeground;
+
     // TODO: make dynamic
 #define MAX_RECURSE 20
     StackEntry m_bandStack[MAX_RECURSE];


Reply via email to