From aa699bf2a9ea6925c35386732423628a44ca93f4 Mon Sep 17 00:00:00 2001 From: David Quintana Date: Sun, 16 Mar 2014 09:28:51 +0000 Subject: [PATCH] [RSHELL] * Fix the hot tracking on the filebrowser menubar. Still does not handle switching menus while hovering, though. CORE-7586 svn path=/branches/shell-experiments/; revision=62514 --- base/shell/rshell/CMenuBand.cpp | 16 +++++++++++++--- base/shell/rshell/CMenuBand.h | 1 + base/shell/rshell/CMenuFocusManager.cpp | 8 +++++--- base/shell/rshell/CMenuToolbars.cpp | 9 ++++++++- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/base/shell/rshell/CMenuBand.cpp b/base/shell/rshell/CMenuBand.cpp index 5e0d71948b9..90b7e630714 100644 --- a/base/shell/rshell/CMenuBand.cpp +++ b/base/shell/rshell/CMenuBand.cpp @@ -61,7 +61,8 @@ CMenuBand::CMenuBand() : m_useBigIcons(FALSE), m_topLevelWindow(NULL), m_hotBar(NULL), - m_hotItem(-1) + m_hotItem(-1), + m_trackingPopup(FALSE) { m_focusManager = CMenuFocusManager::AcquireManager(); } @@ -513,7 +514,13 @@ HRESULT STDMETHODCALLTYPE CMenuBand::SetClient(IUnknown *punkClient) m_subMenuChild = NULL; if (!punkClient) return S_OK; - return punkClient->QueryInterface(IID_PPV_ARG(IMenuPopup, &m_subMenuChild)); + HRESULT hr = punkClient->QueryInterface(IID_PPV_ARG(IMenuPopup, &m_subMenuChild)); + m_trackingPopup = m_subMenuChild != NULL; + if (!m_trackingPopup) + { + if (m_staticToolbar) m_staticToolbar->OnPopupItemChanged(NULL, -1); + if (m_SFToolbar) m_SFToolbar->OnPopupItemChanged(NULL, -1); + } } HRESULT STDMETHODCALLTYPE CMenuBand::GetClient(IUnknown **ppunkClient) @@ -671,6 +678,7 @@ HRESULT CMenuBand::_TrackSubMenuUsingTrackPopupMenu(HMENU popup, INT x, INT y, R UINT flags = TPM_VERPOSANIMATION | TPM_VERTICAL | TPM_LEFTALIGN; + m_trackingPopup = TRUE; if (m_menuOwner) { ::TrackPopupMenuEx(popup, flags, x, y, m_menuOwner, ¶ms); @@ -679,6 +687,7 @@ HRESULT CMenuBand::_TrackSubMenuUsingTrackPopupMenu(HMENU popup, INT x, INT y, R { ::TrackPopupMenuEx(popup, flags, x, y, m_topLevelWindow, ¶ms); } + m_trackingPopup = FALSE; return S_OK; } @@ -691,7 +700,7 @@ HRESULT CMenuBand::_GetTopLevelWindow(HWND*topLevel) HRESULT CMenuBand::_OnHotItemChanged(CMenuToolbarBase * tb, INT id) { - if (m_subMenuChild && id == -1) + if (m_trackingPopup && id == -1) { return S_FALSE; } @@ -801,6 +810,7 @@ HRESULT CMenuBand::_OnPopupSubMenu(IMenuPopup * popup, POINTL * pAt, RECTL * pEx } if (m_staticToolbar) m_staticToolbar->OnPopupItemChanged(toolbar, item); if (m_SFToolbar) m_SFToolbar->OnPopupItemChanged(toolbar, item); + m_trackingPopup = popup != NULL; if (popup) { if (m_subMenuParent) diff --git a/base/shell/rshell/CMenuBand.h b/base/shell/rshell/CMenuBand.h index e8189e57597..93244fa1775 100644 --- a/base/shell/rshell/CMenuBand.h +++ b/base/shell/rshell/CMenuBand.h @@ -60,6 +60,7 @@ private: CMenuToolbarBase * m_hotBar; INT m_hotItem; + BOOL m_trackingPopup; public: CMenuBand(); diff --git a/base/shell/rshell/CMenuFocusManager.cpp b/base/shell/rshell/CMenuFocusManager.cpp index 6cab574cf21..46ba8baa4be 100644 --- a/base/shell/rshell/CMenuFocusManager.cpp +++ b/base/shell/rshell/CMenuFocusManager.cpp @@ -105,7 +105,7 @@ HRESULT CMenuFocusManager::PeekArray(CMenuBand ** pItem) *pItem = NULL; if (m_bandCount <= 0) - return E_FAIL; + return S_FALSE; *pItem = m_bandStack[m_bandCount - 1]; @@ -115,10 +115,10 @@ HRESULT CMenuFocusManager::PeekArray(CMenuBand ** pItem) CMenuFocusManager::CMenuFocusManager() : m_currentBand(NULL), m_currentFocus(NULL), - m_bandCount(0), m_mouseTrackDisabled(FALSE), m_lastMoveFlags(0), - m_lastMovePos(0) + m_lastMovePos(0), + m_bandCount(0) { m_threadId = GetCurrentThreadId(); } @@ -318,6 +318,8 @@ HRESULT CMenuFocusManager::UpdateFocus(CMenuBand * newBand) if (newBand == NULL) { + DisableMouseTrack(NULL, FALSE); + hr = RemoveHooks(m_currentFocus); m_currentFocus = NULL; m_currentBand = NULL; diff --git a/base/shell/rshell/CMenuToolbars.cpp b/base/shell/rshell/CMenuToolbars.cpp index 1427937d03d..83284261738 100644 --- a/base/shell/rshell/CMenuToolbars.cpp +++ b/base/shell/rshell/CMenuToolbars.cpp @@ -472,7 +472,10 @@ HRESULT CMenuToolbarBase::OnHotItemChanged(CMenuToolbarBase * toolbar, INT item) if (m_hotBar == this && !(m_toolbarFlags & SMINIT_VERTICAL)) { wasChecked = SendMessage(m_hwndToolbar, TB_ISBUTTONCHECKED, m_hotItem, 0); - SendMessage(m_hwndToolbar, TB_CHECKBUTTON, m_hotItem, FALSE); + if (wasChecked) + { + SendMessage(m_hwndToolbar, TB_CHECKBUTTON, m_hotItem, FALSE); + } } m_hotBar = toolbar; m_hotItem = item; @@ -486,6 +489,10 @@ HRESULT CMenuToolbarBase::OnHotItemChanged(CMenuToolbarBase * toolbar, INT item) HRESULT CMenuToolbarBase::OnPopupItemChanged(CMenuToolbarBase * toolbar, INT item) { + if (toolbar == NULL && m_popupBar == this) + { + SendMessage(m_hwndToolbar, TB_CHECKBUTTON, item, FALSE); + } m_popupBar = toolbar; m_popupItem = item; InvalidateDraw();