Fix tab dragging issues

Fix tab dragging issues related to switching off TCS_BUTTONS under multi-line tabs mode (per AngryGamer's suggestions)

Fix #6274, fix #6273, fix #4339, close #6278
This commit is contained in:
balagansky 2019-10-27 18:33:20 -07:00 committed by Don HO
parent b5322b1043
commit 8e361c5dca
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
1 changed files with 18 additions and 13 deletions

View File

@ -586,6 +586,15 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
case WM_LBUTTONDOWN : case WM_LBUTTONDOWN :
{ {
if (::GetWindowLongPtr(_hSelf, GWL_STYLE) & TCS_BUTTONS)
{
int nTab = getTabIndexAt(LOWORD(lParam), HIWORD(lParam));
if (nTab != -1 && nTab != static_cast<int32_t>(::SendMessage(_hSelf, TCM_GETCURSEL, 0, 0)))
{
setActiveTab(nTab);
}
}
if (_drawTabCloseButton) if (_drawTabCloseButton)
{ {
int xPos = LOWORD(lParam); int xPos = LOWORD(lParam);
@ -643,16 +652,11 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
} }
else if (++_dragCount > 2) else if (++_dragCount > 2)
{ {
int tabFocused = static_cast<int32_t>(::SendMessage(_hSelf, TCM_GETCURFOCUS, 0, 0));
int tabSelected = static_cast<int32_t>(::SendMessage(_hSelf, TCM_GETCURSEL, 0, 0)); int tabSelected = static_cast<int32_t>(::SendMessage(_hSelf, TCM_GETCURSEL, 0, 0));
// make sure the tab they are moving is active. if (tabSelected >= 0)
if (tabFocused != tabSelected)
{ {
setActiveTab(tabFocused); _nSrcTab = _nTabDragged = tabSelected;
}
_nSrcTab = _nTabDragged = tabFocused;
_isDragging = true; _isDragging = true;
// TLS_BUTTONS is already captured on Windows and will break on ::SetCapture // TLS_BUTTONS is already captured on Windows and will break on ::SetCapture
@ -663,6 +667,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
} }
} }
} }
}
POINT p; POINT p;
p.x = LOWORD(lParam); p.x = LOWORD(lParam);