Author: dquintana
Date: Fri May 16 11:12:51 2014
New Revision: 63312
URL:
http://svn.reactos.org/svn/reactos?rev=63312&view=rev
Log:
[RSHELL]
* Fix shell menus closing when clicking on the frame/banner.
CORE-7586
Modified:
branches/shell-experiments/base/shell/rshell/CMenuFocusManager.cpp
branches/shell-experiments/base/shell/rshell/CMenuFocusManager.h
Modified: branches/shell-experiments/base/shell/rshell/CMenuFocusManager.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
==============================================================================
--- branches/shell-experiments/base/shell/rshell/CMenuFocusManager.cpp [iso-8859-1]
(original)
+++ branches/shell-experiments/base/shell/rshell/CMenuFocusManager.cpp [iso-8859-1] Fri
May 16 11:12:51 2014
@@ -212,13 +212,13 @@
{
::SetCapture(child);
m_captureHwnd = child;
- TRACE("MouseTrack is now capturing %p\n", child);
+ DbgPrint("MouseTrack is now capturing %p\n", child);
}
else
{
::ReleaseCapture();
m_captureHwnd = NULL;
- TRACE("MouseTrack is now off\n");
+ DbgPrint("MouseTrack is now off\n");
}
}
@@ -250,6 +250,40 @@
return S_FALSE;
}
+HRESULT CMenuFocusManager::IsTrackedWindowOrParent(HWND hWnd)
+{
+ for (int i = m_bandCount; --i >= 0;)
+ {
+ StackEntry& entry = m_bandStack[i];
+
+ if (entry.type != TrackedMenuEntry)
+ {
+ HRESULT hr = entry.mb->IsWindowOwner(hWnd);
+ if (FAILED_UNEXPECTEDLY(hr))
+ return hr;
+ if (hr == S_OK)
+ return S_OK;
+ if (entry.mb->_IsPopup() == S_OK)
+ {
+ CComPtr<IUnknown> site;
+ CComPtr<IOleWindow> pw;
+ hr = entry.mb->GetSite(IID_PPV_ARG(IUnknown, &site));
+ if (FAILED_UNEXPECTEDLY(hr))
+ continue;
+ hr = IUnknown_QueryService(site, SID_SMenuBandParent,
IID_PPV_ARG(IOleWindow, &pw));
+ if (FAILED_UNEXPECTEDLY(hr))
+ continue;
+
+ HWND hParent;
+ if (pw->GetWindow(&hParent) == S_OK && hParent == hWnd)
+ return S_OK;
+ }
+ }
+ }
+
+ return S_FALSE;
+}
+
LRESULT CMenuFocusManager::ProcessMouseMove(MSG* msg)
{
HWND child;
@@ -284,7 +318,7 @@
if (SendMessage(child, WM_USER_ISTRACKEDITEM, iHitTestResult, 0) == S_FALSE)
{
- TRACE("Hot item tracking detected a change (capture=%p)...\n",
m_captureHwnd);
+ DbgPrint("Hot item tracking detected a change (capture=%p /
cCapture=%p)...\n", m_captureHwnd, cCapture);
DisableMouseTrack(NULL, FALSE);
if (isTracking && iHitTestResult>=0 && m_current->type
== TrackedMenuEntry)
SendMessage(entry->hwnd, WM_CANCELMODE, 0, 0);
@@ -359,13 +393,13 @@
callNext = ProcessMouseMove(msg);
break;
case WM_INITMENUPOPUP:
- TRACE("WM_INITMENUPOPUP %p %p\n", msg->wParam, msg->lParam);
+ DbgPrint("WM_INITMENUPOPUP %p %p\n", msg->wParam,
msg->lParam);
m_selectedMenu = reinterpret_cast<HMENU>(msg->lParam);
m_selectedItem = -1;
m_selectedItemFlags = 0;
break;
case WM_MENUSELECT:
- TRACE("WM_MENUSELECT %p %p\n", msg->wParam, msg->lParam);
+ DbgPrint("WM_MENUSELECT %p %p\n", msg->wParam, msg->lParam);
m_selectedMenu = reinterpret_cast<HMENU>(msg->lParam);
m_selectedItem = GET_X_LPARAM(msg->wParam);
m_selectedItemFlags = HIWORD(msg->wParam);
@@ -415,7 +449,7 @@
{
HWND child = WindowFromPoint(pt);
- if (IsTrackedWindow(child) != S_OK)
+ if (IsTrackedWindowOrParent(child) != S_OK)
{
SetCapture(NULL);
m_current->mb->_MenuItemHotTrack(MPOS_FULLCANCEL);
@@ -476,12 +510,12 @@
{
if (m_current->type == TrackedMenuEntry)
{
- TRACE("Entering MSGFILTER hook...\n");
+ DbgPrint("Entering MSGFILTER hook...\n");
m_hMsgFilterHook = SetWindowsHookEx(WH_MSGFILTER, s_MsgFilterHook, NULL,
m_threadId);
}
else
{
- TRACE("Entering GETMESSAGE hook...\n");
+ DbgPrint("Entering GETMESSAGE hook...\n");
m_hGetMsgHook = SetWindowsHookEx(WH_GETMESSAGE, s_GetMsgHook, NULL, m_threadId);
}
return S_OK;
@@ -489,7 +523,7 @@
HRESULT CMenuFocusManager::RemoveHooks()
{
- TRACE("Removing all hooks...\n");
+ DbgPrint("Removing all hooks...\n");
if (m_hMsgFilterHook)
UnhookWindowsHookEx(m_hMsgFilterHook);
if (m_hGetMsgHook)
@@ -627,7 +661,7 @@
if (FAILED_UNEXPECTEDLY(hr))
return hr;
- TRACE("PushTrackedPopup %p\n", popup);
+ DbgPrint("PushTrackedPopup %p\n", popup);
m_selectedMenu = popup;
m_selectedItem = -1;
m_selectedItemFlags = 0;
Modified: branches/shell-experiments/base/shell/rshell/CMenuFocusManager.h
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
==============================================================================
--- branches/shell-experiments/base/shell/rshell/CMenuFocusManager.h [iso-8859-1]
(original)
+++ branches/shell-experiments/base/shell/rshell/CMenuFocusManager.h [iso-8859-1] Fri
May 16 11:12:51 2014
@@ -103,6 +103,7 @@
HRESULT RemoveHooks();
HRESULT UpdateFocus();
HRESULT IsTrackedWindow(HWND hWnd, StackEntry ** pentry = NULL);
+ HRESULT IsTrackedWindowOrParent(HWND hWnd);
void DisableMouseTrack(HWND parent, BOOL disableThis);
void SetCapture(HWND child);