[SHELL32]
authorGiannis Adamopoulos <gadamopoulos@reactos.org>
Sat, 20 Aug 2016 22:05:12 +0000 (22:05 +0000)
committerGiannis Adamopoulos <gadamopoulos@reactos.org>
Sat, 20 Aug 2016 22:05:12 +0000 (22:05 +0000)
- CMenuBand: Do not open the context menu on mouse down but on mouse up.
- Patch by Joachim Henze (reactosfanboy)
CORE-10830

svn path=/trunk/; revision=72401

reactos/dll/win32/shell32/shellmenu/CMenuBand.cpp
reactos/dll/win32/shell32/shellmenu/CMenuBand.h
reactos/dll/win32/shell32/shellmenu/CMenuFocusManager.cpp
reactos/dll/win32/shell32/shellmenu/CMenuFocusManager.h
reactos/dll/win32/shell32/shellmenu/CMenuToolbars.cpp
reactos/dll/win32/shell32/shellmenu/CMenuToolbars.h

index 56d0edf..8826da9 100644 (file)
@@ -1132,12 +1132,12 @@ HRESULT CMenuBand::_MenuBarMouseDown(HWND hwnd, INT item, BOOL isLButton)
     return S_OK;
 }
 
-HRESULT CMenuBand::_MenuBarMouseUp(HWND hwnd, INT item)
+HRESULT CMenuBand::_MenuBarMouseUp(HWND hwnd, INT item, BOOL isLButton)
 {
     if (m_staticToolbar && m_staticToolbar->IsWindowOwner(hwnd) == S_OK)
-        m_staticToolbar->MenuBarMouseUp(item);
+        m_staticToolbar->MenuBarMouseUp(item, isLButton);
     if (m_SFToolbar && m_SFToolbar->IsWindowOwner(hwnd) == S_OK)
-        m_SFToolbar->MenuBarMouseUp(item);
+        m_SFToolbar->MenuBarMouseUp(item, isLButton);
     return S_OK;
 }
 
index e187b6f..ac064f5 100644 (file)
@@ -199,7 +199,7 @@ public:
     HRESULT _IsTracking();
     HRESULT _KillPopupTimers();
     HRESULT _MenuBarMouseDown(HWND hwnd, INT item, BOOL isLButton);
-    HRESULT _MenuBarMouseUp(HWND hwnd, INT item);
+    HRESULT _MenuBarMouseUp(HWND hwnd, INT item, BOOL isLButton);
     HRESULT _HasSubMenu();
 
     HRESULT AdjustForTheme(BOOL bFlatStyle);
index d8443e4..5b65bc3 100644 (file)
@@ -185,7 +185,6 @@ CMenuFocusManager::CMenuFocusManager() :
     m_selectedMenu(NULL),
     m_selectedItem(0),
     m_selectedItemFlags(0),
-    m_isLButtonDown(FALSE),
     m_movedSinceDown(FALSE),
     m_windowAtDown(NULL),
     m_PreviousForeground(NULL),
@@ -323,10 +322,7 @@ LRESULT CMenuFocusManager::ProcessMouseMove(MSG* msg)
     POINT pt2 = { GET_X_LPARAM(msg->lParam), GET_Y_LPARAM(msg->lParam) };
     ClientToScreen(msg->hwnd, &pt2);
 
-    // Don't do anything if the mouse has not been moved
     POINT pt = msg->pt;
-    if (pt.x == m_ptPrev.x && pt.y == m_ptPrev.y)
-        return TRUE;
 
     // Don't do anything if another window is capturing the mouse.
     HWND cCapture = ::GetCapture();
@@ -342,7 +338,7 @@ LRESULT CMenuFocusManager::ProcessMouseMove(MSG* msg)
     StackEntry * entry = NULL;
     if (IsTrackedWindow(child, &entry) == S_OK)
     {
-        TRACE("MouseMove %d\n", m_isLButtonDown);
+        TRACE("MouseMove");
     }
 
     BOOL isTracking = FALSE;
@@ -426,8 +422,6 @@ LRESULT CMenuFocusManager::ProcessMouseDown(MSG* msg, BOOL isLButton)
         return TRUE;
     }
 
-    TRACE("MouseDown %d\n", m_isLButtonDown);
-
     if (entry->type == MenuBarEntry)
     {
         if (entry != m_current)
@@ -451,16 +445,15 @@ LRESULT CMenuFocusManager::ProcessMouseDown(MSG* msg, BOOL isLButton)
 
     msg->message = WM_NULL;
 
-    m_isLButtonDown = TRUE;
     m_movedSinceDown = FALSE;
     m_windowAtDown = child;
 
-    TRACE("MouseDown end %d\n", m_isLButtonDown);
+    TRACE("MouseDown end\n");
 
     return TRUE;
 }
 
-LRESULT CMenuFocusManager::ProcessMouseUp(MSG* msg)
+LRESULT CMenuFocusManager::ProcessMouseUp(MSG* msg, BOOL isLButton)
 {
     HWND child;
     int iHitTestResult = -1;
@@ -472,11 +465,6 @@ LRESULT CMenuFocusManager::ProcessMouseUp(MSG* msg)
     if (cCapture && cCapture != m_captureHwnd && m_current->type != TrackedMenuEntry)
         return TRUE;
 
-    if (!m_isLButtonDown)
-        return TRUE;
-
-    m_isLButtonDown = FALSE;
-
     POINT pt = msg->pt;
 
     child = WindowFromPoint(pt);
@@ -485,8 +473,6 @@ LRESULT CMenuFocusManager::ProcessMouseUp(MSG* msg)
     if (IsTrackedWindow(child, &entry) != S_OK)
         return TRUE;
 
-    TRACE("MouseUp %d\n", m_isLButtonDown);
-
     if (entry)
     {
         ScreenToClient(child, &pt);
@@ -495,7 +481,7 @@ LRESULT CMenuFocusManager::ProcessMouseUp(MSG* msg)
         if (iHitTestResult >= 0)
         {
             TRACE("MouseUp send %d\n", iHitTestResult);
-            entry->mb->_MenuBarMouseUp(child, iHitTestResult);
+            entry->mb->_MenuBarMouseUp(child, iHitTestResult, isLButton);
         }
     }
 
@@ -595,9 +581,6 @@ LRESULT CMenuFocusManager::GetMsgHook(INT nCode, WPARAM hookWParam, LPARAM hookL
             isLButton = TRUE;
             TRACE("LB\n");
 
-            // fallthrough;
-        case WM_NCRBUTTONDOWN:
-        case WM_RBUTTONDOWN:
             if (m_menuBar && m_current->type == MenuPopupEntry)
             {
                 POINT pt = msg->pt;
@@ -623,10 +606,15 @@ LRESULT CMenuFocusManager::GetMsgHook(INT nCode, WPARAM hookWParam, LPARAM hookL
 
             ProcessMouseDown(msg, isLButton);
 
+            break;
+        case WM_NCRBUTTONUP:
+        case WM_RBUTTONUP:
+            ProcessMouseUp(msg, isLButton);
             break;
         case WM_NCLBUTTONUP:
         case WM_LBUTTONUP:
-            ProcessMouseUp(msg);
+            isLButton = TRUE;
+            ProcessMouseUp(msg, isLButton);
             break;
         case WM_MOUSEMOVE:
             callNext = ProcessMouseMove(msg);
index 80ced7f..d74ed12 100644 (file)
@@ -117,7 +117,7 @@ private:
 
     LRESULT ProcessMouseMove(MSG* msg);
     LRESULT ProcessMouseDown(MSG* msg, BOOL isLButton);
-    LRESULT ProcessMouseUp(MSG* msg);
+    LRESULT ProcessMouseUp(MSG* msg, BOOL isLButton);
 public:
     HRESULT PushMenuBar(CMenuBand * mb);
     HRESULT PushMenuPopup(CMenuBand * mb);
index 2440d14..7e6410f 100644 (file)
@@ -827,8 +827,6 @@ HRESULT CMenuToolbarBase::MenuBarMouseDown(INT iIndex, BOOL isLButton)
     TBBUTTON btn;
 
     GetButton(iIndex, &btn);
-    if (!isLButton)
-        return ProcessContextMenu(btn.idCommand);
 
     if ((m_initFlags & SMINIT_VERTICAL) 
         || m_popupBar
@@ -841,7 +839,7 @@ HRESULT CMenuToolbarBase::MenuBarMouseDown(INT iIndex, BOOL isLButton)
     return ProcessClick(btn.idCommand);
 }
 
-HRESULT CMenuToolbarBase::MenuBarMouseUp(INT iIndex)
+HRESULT CMenuToolbarBase::MenuBarMouseUp(INT iIndex, BOOL isLButton)
 {
     TBBUTTON btn;
 
@@ -851,7 +849,11 @@ HRESULT CMenuToolbarBase::MenuBarMouseUp(INT iIndex)
         return S_OK;
 
     GetButton(iIndex, &btn);
-    return ProcessClick(btn.idCommand);
+
+    if (isLButton)
+        return ProcessClick(btn.idCommand);
+    else
+        return ProcessContextMenu(btn.idCommand);
 }
 
 HRESULT CMenuToolbarBase::PrepareExecuteItem(INT iItem)
index 3e9311a..fcbd628 100644 (file)
@@ -97,7 +97,7 @@ public:
     HRESULT KillPopupTimer();
 
     HRESULT MenuBarMouseDown(INT iIndex, BOOL isLButton);
-    HRESULT MenuBarMouseUp(INT iIndex);
+    HRESULT MenuBarMouseUp(INT iIndex, BOOL isLButton);
     HRESULT ProcessClick(INT iItem);
     HRESULT ProcessContextMenu(INT iItem);
     HRESULT BeforeCancelPopup();