From d2b33acd153286ab8358c0028008d7c8650a3aa7 Mon Sep 17 00:00:00 2001 From: David Quintana Date: Fri, 21 Mar 2014 10:13:18 +0000 Subject: [PATCH] [RSHELL] * Improve behaviour when hovering and clicking on the menubar. It's still somewhat glitchy though. CORE-7586 svn path=/branches/shell-experiments/; revision=62539 --- base/shell/rshell/CMenuBand.cpp | 18 ++++++++++++++++++ base/shell/rshell/CMenuBand.h | 3 +++ base/shell/rshell/CMenuFocusManager.cpp | 14 +++++++++++--- base/shell/rshell/CMenuToolbars.cpp | 7 ++++++- 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/base/shell/rshell/CMenuBand.cpp b/base/shell/rshell/CMenuBand.cpp index a2060ccb37a..c0914628650 100644 --- a/base/shell/rshell/CMenuBand.cpp +++ b/base/shell/rshell/CMenuBand.cpp @@ -56,6 +56,9 @@ CMenuBand::CMenuBand() : m_site(NULL), m_psmc(NULL), m_subMenuChild(NULL), + m_subMenuParent(NULL), + m_childBand(NULL), + m_parentBand(NULL), m_hmenu(NULL), m_menuOwner(NULL), m_useBigIcons(FALSE), @@ -352,6 +355,10 @@ HRESULT STDMETHODCALLTYPE CMenuBand::ShowDW(BOOL fShow) if (FAILED_UNEXPECTEDLY(hr)) return hr; } + else if (m_parentBand) + { + m_parentBand->SetClient(NULL); + } if (fShow) hr = m_focusManager->PushMenu(this); @@ -490,6 +497,17 @@ HRESULT CMenuBand::_SetChildBand(CMenuBand * child) return S_OK; } +HRESULT CMenuBand::_SetParentBand(CMenuBand * parent) +{ + m_parentBand = parent; + return S_OK; +} + +HRESULT CMenuBand::_IsPopup() +{ + return m_subMenuParent ? S_OK : S_FALSE; +} + HRESULT STDMETHODCALLTYPE CMenuBand::SetClient(IUnknown *punkClient) { if (m_subMenuChild) diff --git a/base/shell/rshell/CMenuBand.h b/base/shell/rshell/CMenuBand.h index c4c7b577ef1..1c3f9ee30ed 100644 --- a/base/shell/rshell/CMenuBand.h +++ b/base/shell/rshell/CMenuBand.h @@ -48,6 +48,7 @@ private: CComPtr m_subMenuChild; CComPtr m_subMenuParent; CComPtr m_childBand; + CComPtr m_parentBand; UINT m_uId; UINT m_uIdAncestor; @@ -180,6 +181,8 @@ public: HRESULT _OnPopupSubMenu(IMenuPopup * popup, POINTL * pAt, RECTL * pExclude, CMenuToolbarBase * toolbar, INT item); HRESULT _DisableMouseTrack(BOOL bDisable); HRESULT _SetChildBand(CMenuBand * child); + HRESULT _SetParentBand(CMenuBand * parent); + HRESULT _IsPopup(); BOOL UseBigIcons() { diff --git a/base/shell/rshell/CMenuFocusManager.cpp b/base/shell/rshell/CMenuFocusManager.cpp index e066835a2b7..ca1a64dfe95 100644 --- a/base/shell/rshell/CMenuFocusManager.cpp +++ b/base/shell/rshell/CMenuFocusManager.cpp @@ -188,7 +188,9 @@ HRESULT CMenuFocusManager::IsTrackedWindow(HWND hWnd) return hr; if (hwnd == hWnd) - return S_OK; + { + return band->_IsPopup(); + } } return S_FALSE; @@ -232,10 +234,10 @@ LRESULT CMenuFocusManager::ProcessMouseMove(MSG* msg) if (m_currentMenu) SendMessage(m_currentFocus, WM_CANCELMODE, 0, 0); else - m_currentBand->_MenuItemHotTrack(MPOS_SELECTLEFT); + m_currentBand->_MenuItemHotTrack(MPOS_CANCELLEVEL); DbgPrint("Active popup cancelled, notifying of change...\n"); PostMessage(hwndToolbar, WM_USER_CHANGETRACKEDITEM, iHitTestResult, iHitTestResult); - return TRUE; + return FALSE; } } @@ -447,6 +449,7 @@ HRESULT CMenuFocusManager::PushMenu(CMenuBand * mb) if (mbParent) { mbParent->_SetChildBand(mb); + mb->_SetParentBand(mbParent); } return UpdateFocus(mb); @@ -457,6 +460,11 @@ HRESULT CMenuFocusManager::PopMenu(CMenuBand * mb) CMenuBand * mbc; HRESULT hr; + if (m_currentBand) + { + m_currentBand->_SetParentBand(NULL); + } + HWND newFocus; hr = mb->_GetTopLevelWindow(&newFocus); if (FAILED_UNEXPECTEDLY(hr)) diff --git a/base/shell/rshell/CMenuToolbars.cpp b/base/shell/rshell/CMenuToolbars.cpp index 3e8090e471d..49ddf49247c 100644 --- a/base/shell/rshell/CMenuToolbars.cpp +++ b/base/shell/rshell/CMenuToolbars.cpp @@ -1050,6 +1050,12 @@ HRESULT CMenuStaticToolbar::OnContextMenu(NMMOUSE * rclick) HRESULT CMenuStaticToolbar::OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *theResult) { HRESULT hr; + + if (m_isTracking) + { + return S_FALSE; + } + hr = CMenuToolbarBase::OnCommand(wParam, lParam, theResult); if (FAILED_UNEXPECTEDLY(hr)) return hr; @@ -1057,7 +1063,6 @@ HRESULT CMenuStaticToolbar::OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *the // in case the clicked item has a submenu, we do not need to execute the item if (hr == S_FALSE) { - DbgPrint("CMenuToolbarBase::OnCommand told us to cancel.\n"); return hr; }