summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/m_gui.h13
-rw-r--r--libs/win32/mir_core.libbin476778 -> 476778 bytes
-rw-r--r--libs/win64/mir_core.libbin481918 -> 481918 bytes
-rw-r--r--src/mir_core/src/CCtrlBase.cpp4
-rw-r--r--src/mir_core/src/CCtrlClc.cpp2
-rw-r--r--src/mir_core/src/CCtrlListBox.cpp15
-rw-r--r--src/mir_core/src/CCtrlListView.cpp32
-rw-r--r--src/mir_core/src/CCtrlTreeView.cpp38
-rw-r--r--src/mir_core/src/CDlgBase.cpp4
-rw-r--r--src/mir_core/src/mir_core.def8
-rw-r--r--src/mir_core/src/mir_core64.def8
11 files changed, 81 insertions, 43 deletions
diff --git a/include/m_gui.h b/include/m_gui.h
index f5ed8fb8e8..152abae62c 100644
--- a/include/m_gui.h
+++ b/include/m_gui.h
@@ -459,7 +459,10 @@ struct CContextMenuPos
{
const CCtrlBase *pCtrl;
POINT pt;
- INT_PTR iCurr; // int for list boxes, HTREEITEM for treeview
+ union {
+ int iCurr; // int for list boxes
+ HTREEITEM hItem;
+ };
};
class MIR_CORE_EXPORT CCtrlBase
@@ -686,7 +689,7 @@ public:
int GetItemType(HANDLE hItem) const;
HANDLE GetNextItem(HANDLE hItem, DWORD flags) const;
HANDLE GetSelection() const;
- HANDLE HitTest(int x, int y, DWORD *hitTest);
+ HANDLE HitTest(int x, int y, DWORD *hitTest) const;
void SelectItem(HANDLE hItem);
void SetBkColor(COLORREF clBack);
void SetCheck(HANDLE hItem, bool check);
@@ -1046,7 +1049,7 @@ public:
BOOL GetViewRect(RECT *prc) const;
void GetWorkAreas(INT nWorkAreas, LPRECT lprc) const;
BOOL HasGroup(int dwGroupId);
- int HitTest(LPLVHITTESTINFO pinfo);
+ int HitTest(LPLVHITTESTINFO pinfo) const;
int HitTestEx(LPLVHITTESTINFO pinfo);
int InsertColumn(int iCol, const LPLVCOLUMN pcol);
int InsertGroup(int index, PLVGROUP pgrp);
@@ -1102,7 +1105,7 @@ public:
int SortGroups(PFNLVGROUPCOMPARE pfnGroupCompare, LPVOID plv);
BOOL SortItems(PFNLVCOMPARE pfnCompare, LPARAM lParamSort);
BOOL SortItemsEx(PFNLVCOMPARE pfnCompare, LPARAM lParamSort);
- INT SubItemHitTest(LPLVHITTESTINFO pInfo);
+ INT SubItemHitTest(LPLVHITTESTINFO pInfo) const;
INT SubItemHitTestEx(LPLVHITTESTINFO plvhti);
BOOL Update(int iItem);
@@ -1215,7 +1218,7 @@ public:
HWND GetToolTips() const;
BOOL GetUnicodeFormat() const;
unsigned GetVisibleCount() const;
- HTREEITEM HitTest(TVHITTESTINFO *hti);
+ HTREEITEM HitTest(TVHITTESTINFO *hti) const;
HTREEITEM InsertItem(TVINSERTSTRUCT *tvis);
void Select(HTREEITEM hItem, DWORD flag);
void SelectDropTarget(HTREEITEM hItem);
diff --git a/libs/win32/mir_core.lib b/libs/win32/mir_core.lib
index 3bd5d7972e..672d3e0e09 100644
--- a/libs/win32/mir_core.lib
+++ b/libs/win32/mir_core.lib
Binary files differ
diff --git a/libs/win64/mir_core.lib b/libs/win64/mir_core.lib
index d0d240a72c..43cbc15592 100644
--- a/libs/win64/mir_core.lib
+++ b/libs/win64/mir_core.lib
Binary files differ
diff --git a/src/mir_core/src/CCtrlBase.cpp b/src/mir_core/src/CCtrlBase.cpp
index 4cb2bcdb40..800e8c693d 100644
--- a/src/mir_core/src/CCtrlBase.cpp
+++ b/src/mir_core/src/CCtrlBase.cpp
@@ -181,7 +181,9 @@ void CCtrlBase::GetCaretPos(CContextMenuPos &pos) const
{
pos.pCtrl = this;
pos.iCurr = -1;
- GetCursorPos(&pos.pt);
+
+ if (pos.pt.x == 0 && pos.pt.y == 0)
+ GetCursorPos(&pos.pt);
}
LRESULT CCtrlBase::CustomWndProc(UINT, WPARAM, LPARAM)
diff --git a/src/mir_core/src/CCtrlClc.cpp b/src/mir_core/src/CCtrlClc.cpp
index da007afe25..b5b439cdb7 100644
--- a/src/mir_core/src/CCtrlClc.cpp
+++ b/src/mir_core/src/CCtrlClc.cpp
@@ -130,7 +130,7 @@ HANDLE CCtrlClc::GetSelection() const
{ return (HANDLE)SendMessage(m_hwnd, CLM_GETSELECTION, 0, 0);
}
-HANDLE CCtrlClc::HitTest(int x, int y, DWORD *hitTest)
+HANDLE CCtrlClc::HitTest(int x, int y, DWORD *hitTest) const
{ return (HANDLE)SendMessage(m_hwnd, CLM_HITTEST, (WPARAM)hitTest, MAKELPARAM(x,y));
}
diff --git a/src/mir_core/src/CCtrlListBox.cpp b/src/mir_core/src/CCtrlListBox.cpp
index a4cbc3e796..34980c05a3 100644
--- a/src/mir_core/src/CCtrlListBox.cpp
+++ b/src/mir_core/src/CCtrlListBox.cpp
@@ -42,12 +42,15 @@ BOOL CCtrlListBox::OnCommand(HWND, WORD, WORD idCode)
void CCtrlListBox::GetCaretPos(CContextMenuPos &pos) const
{
pos.pCtrl = this;
- pos.iCurr = GetCurSel();
- if (pos.iCurr != -1) {
- RECT rc;
- GetItemRect(pos.iCurr, &rc);
- pos.pt.x = rc.left;
- pos.pt.y = rc.top;
+ if (pos.pt.x == 0 && pos.pt.y == 0) {
+ pos.iCurr = GetCurSel();
+ if (pos.iCurr != -1) {
+ RECT rc;
+ GetItemRect(pos.iCurr, &rc);
+ pos.pt.x = rc.left;
+ pos.pt.y = rc.top;
+ }
+ else CSuper::GetCaretPos(pos);
}
else CSuper::GetCaretPos(pos);
}
diff --git a/src/mir_core/src/CCtrlListView.cpp b/src/mir_core/src/CCtrlListView.cpp
index 090925d80e..0156aeab6e 100644
--- a/src/mir_core/src/CCtrlListView.cpp
+++ b/src/mir_core/src/CCtrlListView.cpp
@@ -152,14 +152,28 @@ LPARAM CCtrlListView::GetItemData(int iItem) const
void CCtrlListView::GetCaretPos(CContextMenuPos &pos) const
{
pos.pCtrl = this;
- pos.iCurr = GetSelectionMark();
- if (pos.iCurr != -1) {
- RECT rc;
- GetItemRect(pos.iCurr, &rc, TRUE);
- pos.pt.x = rc.left;
- pos.pt.y = rc.top;
+
+ // position is empty, let's fill it using selection
+ if (pos.pt.x == 0 && pos.pt.y == 0) {
+ pos.iCurr = GetSelectionMark();
+ if (pos.iCurr != -1) {
+ RECT rc;
+ GetItemRect(pos.iCurr, &rc, TRUE);
+ pos.pt.x = rc.left;
+ pos.pt.y = rc.top;
+ return;
+ }
+ }
+ // position is present, let's calculate current item
+ else {
+ LVHITTESTINFO hti;
+ hti.pt = pos.pt;
+ if (SubItemHitTest(&hti) != -1) {
+ pos.iCurr = hti.iItem;
+ return;
+ }
}
- else CSuper::GetCaretPos(pos);
+ CSuper::GetCaretPos(pos);
}
// classic api
@@ -337,7 +351,7 @@ void CCtrlListView::GetWorkAreas(INT nWorkAreas, LPRECT lprc) const
BOOL CCtrlListView::HasGroup(int dwGroupId)
{ return ListView_HasGroup(m_hwnd, dwGroupId);
}
-int CCtrlListView::HitTest(LPLVHITTESTINFO pinfo)
+int CCtrlListView::HitTest(LPLVHITTESTINFO pinfo) const
{ return ListView_HitTest(m_hwnd, pinfo);
}
int CCtrlListView::InsertColumn(int iCol, const LPLVCOLUMN pcol)
@@ -496,7 +510,7 @@ BOOL CCtrlListView::SortItems(PFNLVCOMPARE pfnCompare, LPARAM lParamSort)
BOOL CCtrlListView::SortItemsEx(PFNLVCOMPARE pfnCompare, LPARAM lParamSort)
{ return ListView_SortItemsEx(m_hwnd, pfnCompare, lParamSort);
}
-INT CCtrlListView::SubItemHitTest(LPLVHITTESTINFO pInfo)
+INT CCtrlListView::SubItemHitTest(LPLVHITTESTINFO pInfo) const
{ return ListView_SubItemHitTest(m_hwnd, pInfo);
}
BOOL CCtrlListView::Update(int iItem)
diff --git a/src/mir_core/src/CCtrlTreeView.cpp b/src/mir_core/src/CCtrlTreeView.cpp
index 565e5aee83..3edabcd61a 100644
--- a/src/mir_core/src/CCtrlTreeView.cpp
+++ b/src/mir_core/src/CCtrlTreeView.cpp
@@ -550,17 +550,33 @@ void CCtrlTreeView::Select(LIST<_TREEITEM> &selected)
void CCtrlTreeView::GetCaretPos(CContextMenuPos &pos) const
{
- HTREEITEM hItem = GetSelection();
- if (hItem != nullptr) {
- pos.pCtrl = this;
- pos.iCurr = (INT_PTR)hItem;
-
- RECT rc;
- GetItemRect(hItem, &rc, TRUE);
- pos.pt.x = rc.left;
- pos.pt.y = rc.top;
+ pos.pCtrl = this;
+
+ // position is empty, let's fill it using selection
+ if (pos.pt.x == 0 && pos.pt.y == 0) {
+ HTREEITEM hItem = GetSelection();
+ if (hItem != nullptr) {
+ pos.pCtrl = this;
+ pos.iCurr = (INT_PTR)hItem;
+
+ RECT rc;
+ GetItemRect(hItem, &rc, TRUE);
+ pos.pt.x = rc.left;
+ pos.pt.y = rc.top;
+ return;
+ }
}
- else CSuper::GetCaretPos(pos);
+ // position is present, let's calculate current item
+ else {
+ TVHITTESTINFO hti;
+ hti.pt = pos.pt;
+ if (HitTest(&hti) && (hti.flags & TVHT_ONITEM)) {
+ pos.hItem = hti.hItem;
+ return;
+ }
+ }
+
+ CSuper::GetCaretPos(pos);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -709,7 +725,7 @@ unsigned CCtrlTreeView::GetVisibleCount() const
{ return TreeView_GetVisibleCount(m_hwnd);
}
-HTREEITEM CCtrlTreeView::HitTest(TVHITTESTINFO *hti)
+HTREEITEM CCtrlTreeView::HitTest(TVHITTESTINFO *hti) const
{ return TreeView_HitTest(m_hwnd, hti);
}
diff --git a/src/mir_core/src/CDlgBase.cpp b/src/mir_core/src/CDlgBase.cpp
index 2b588dffc2..de23eec3d9 100644
--- a/src/mir_core/src/CDlgBase.cpp
+++ b/src/mir_core/src/CDlgBase.cpp
@@ -351,12 +351,12 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
case WM_CONTEXTMENU:
if (CCtrlBase *ctrl = FindControl(HWND(wParam))) {
- CContextMenuPos pos;
- ctrl->GetCaretPos(pos);
+ CContextMenuPos pos = {};
if (lParam != -1) {
pos.pt.x = GET_X_LPARAM(lParam);
pos.pt.y = GET_Y_LPARAM(lParam);
}
+ ctrl->GetCaretPos(pos);
ctrl->OnBuildMenu(&pos);
}
break;
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def
index dc0233e891..3441b0543f 100644
--- a/src/mir_core/src/mir_core.def
+++ b/src/mir_core/src/mir_core.def
@@ -697,9 +697,9 @@ mir_wstrcmpi @280
?GlobalDlgResizer@CDlgBase@@CAHPAUHWND__@@JPAUUTILRESIZECONTROL@@@Z @885 NONAME
?GlobalSubclassWndProc@CCtrlBase@@CGJPAUHWND__@@IIJ@Z @886 NONAME
?HasGroup@CCtrlListView@@QAEHH@Z @887 NONAME
-?HitTest@CCtrlClc@@QAEPAXHHPAK@Z @888 NONAME
-?HitTest@CCtrlListView@@QAEHPAUtagLVHITTESTINFO@@@Z @889 NONAME
-?HitTest@CCtrlTreeView@@QAEPAU_TREEITEM@@PAUtagTVHITTESTINFO@@@Z @890 NONAME
+?HitTest@CCtrlClc@@QBEPAXHHPAK@Z @888 NONAME
+?HitTest@CCtrlListView@@QBEHPAUtagLVHITTESTINFO@@@Z @889 NONAME
+?HitTest@CCtrlTreeView@@QBEPAU_TREEITEM@@PAUtagTVHITTESTINFO@@@Z @890 NONAME
?InsertColumn@CCtrlListView@@QAEHHQAUtagLVCOLUMNW@@@Z @891 NONAME
?InsertGroup@CCtrlListView@@QAEHHPAUtagLVGROUP@@@Z @892 NONAME
?InsertGroupSorted@CCtrlListView@@QAEXPAUtagLVINSERTGROUPSORTED@@@Z @893 NONAME
@@ -857,7 +857,7 @@ mir_wstrcmpi @280
?SortGroups@CCtrlListView@@QAEHP6GHHHPAX@Z0@Z @1056 NONAME
?SortItems@CCtrlListView@@QAEHP6GHJJJ@ZJ@Z @1057 NONAME
?SortItemsEx@CCtrlListView@@QAEHP6GHJJJ@ZJ@Z @1058 NONAME
-?SubItemHitTest@CCtrlListView@@QAEHPAUtagLVHITTESTINFO@@@Z @1059 NONAME
+?SubItemHitTest@CCtrlListView@@QBEHPAUtagLVHITTESTINFO@@@Z @1059 NONAME
?Subclass@CCtrlBase@@IAEXXZ @1060 NONAME
?ThemeDialogBackground@CDlgBase@@IAEXH@Z @1061 NONAME
?TranslateItem@CCtrlTreeView@@QAEXPAU_TREEITEM@@@Z @1062 NONAME
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def
index f7eea3fc43..392cfa2cda 100644
--- a/src/mir_core/src/mir_core64.def
+++ b/src/mir_core/src/mir_core64.def
@@ -697,9 +697,9 @@ mir_wstrcmpi @280
?GlobalDlgResizer@CDlgBase@@CAHPEAUHWND__@@_JPEAUUTILRESIZECONTROL@@@Z @885 NONAME
?GlobalSubclassWndProc@CCtrlBase@@CA_JPEAUHWND__@@I_K_J@Z @886 NONAME
?HasGroup@CCtrlListView@@QEAAHH@Z @887 NONAME
-?HitTest@CCtrlClc@@QEAAPEAXHHPEAK@Z @888 NONAME
-?HitTest@CCtrlListView@@QEAAHPEAUtagLVHITTESTINFO@@@Z @889 NONAME
-?HitTest@CCtrlTreeView@@QEAAPEAU_TREEITEM@@PEAUtagTVHITTESTINFO@@@Z @890 NONAME
+?HitTest@CCtrlClc@@QEBAPEAXHHPEAK@Z @888 NONAME
+?HitTest@CCtrlListView@@QEBAHPEAUtagLVHITTESTINFO@@@Z @889 NONAME
+?HitTest@CCtrlTreeView@@QEBAPEAU_TREEITEM@@PEAUtagTVHITTESTINFO@@@Z @890 NONAME
?InsertColumn@CCtrlListView@@QEAAHHQEAUtagLVCOLUMNW@@@Z @891 NONAME
?InsertGroup@CCtrlListView@@QEAAHHPEAUtagLVGROUP@@@Z @892 NONAME
?InsertGroupSorted@CCtrlListView@@QEAAXPEAUtagLVINSERTGROUPSORTED@@@Z @893 NONAME
@@ -857,7 +857,7 @@ mir_wstrcmpi @280
?SortGroups@CCtrlListView@@QEAAHP6AHHHPEAX@Z0@Z @1056 NONAME
?SortItems@CCtrlListView@@QEAAHP6AH_J00@Z0@Z @1057 NONAME
?SortItemsEx@CCtrlListView@@QEAAHP6AH_J00@Z0@Z @1058 NONAME
-?SubItemHitTest@CCtrlListView@@QEAAHPEAUtagLVHITTESTINFO@@@Z @1059 NONAME
+?SubItemHitTest@CCtrlListView@@QEBAHPEAUtagLVHITTESTINFO@@@Z @1059 NONAME
?Subclass@CCtrlBase@@IEAAXXZ @1060 NONAME
?ThemeDialogBackground@CDlgBase@@IEAAXH@Z @1061 NONAME
?TranslateItem@CCtrlTreeView@@QEAAXPEAU_TREEITEM@@@Z @1062 NONAME