From 6d3606074a6838b906044cca2542b0fbc615212a Mon Sep 17 00:00:00 2001 From: AngryGamer Date: Mon, 17 Jun 2019 15:17:41 -0700 Subject: [PATCH] Fix tab dragging issues under WINE and ReactOS Fix tab dragging issues on both multiline and single line mode under WINE and ReactOS. Fix #4885, close #5792 --- PowerEditor/src/WinControls/TabBar/TabBar.cpp | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/PowerEditor/src/WinControls/TabBar/TabBar.cpp b/PowerEditor/src/WinControls/TabBar/TabBar.cpp index 98c00fdb1..200ba1d4f 100644 --- a/PowerEditor/src/WinControls/TabBar/TabBar.cpp +++ b/PowerEditor/src/WinControls/TabBar/TabBar.cpp @@ -153,7 +153,8 @@ void TabBar::activateAt(int index) const { if (getCurrentTabIndex() != index) { - // TCS_BUTTONS needs both set or two tabs can appear selected + // TCM_SETCURFOCUS is busted on WINE/ReactOS for single line (non-TCS_BUTTONS) tabs... + // We need it on Windows for multi-line tabs or multiple tabs can appear pressed. if (::GetWindowLongPtr(_hSelf, GWL_STYLE) & TCS_BUTTONS) { ::SendMessage(_hSelf, TCM_SETCURFOCUS, index, 0); @@ -654,8 +655,9 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara _nSrcTab = _nTabDragged = tabFocused; _isDragging = true; - // ::SetCapture is required for normal non-TLS_BUTTONS. - if (!(::GetWindowLongPtr(_hSelf, GWL_STYLE) & TCS_BUTTONS)) + // TLS_BUTTONS is already captured on Windows and will break on ::SetCapture + // However, this is not the case for WINE/ReactOS and must ::SetCapture + if (::GetCapture() != _hSelf) { ::SetCapture(hwnd); } @@ -774,10 +776,16 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara int xPos = LOWORD(lParam); int yPos = HIWORD(lParam); int currentTabOn = getTabIndexAt(xPos, yPos); - if (_isDragging) + if (_isDragging) { if (::GetCapture() == _hSelf) + { ::ReleaseCapture(); + } + else + { + _isDragging = false; + } notify(_isDraggingInside?TCN_TABDROPPED:TCN_TABDROPPEDOUTSIDE, currentTabOn); return TRUE; @@ -1140,14 +1148,15 @@ void TabBarPlus::draggingCursor(POINT screenPoint) void TabBarPlus::setActiveTab(int tabIndex) { - ::SendMessage(_hSelf, TCM_SETCURFOCUS, tabIndex, 0); - - // the TCS_BUTTONS style does not automatically send TCM_SETCURSEL & TCN_SELCHANGE + // TCM_SETCURFOCUS is busted on WINE/ReactOS for single line (non-TCS_BUTTONS) tabs... + // We need it on Windows for multi-line tabs or multiple tabs can appear pressed. if (::GetWindowLongPtr(_hSelf, GWL_STYLE) & TCS_BUTTONS) { - ::SendMessage(_hSelf, TCM_SETCURSEL, tabIndex, 0); - notify(TCN_SELCHANGE, tabIndex); + ::SendMessage(_hSelf, TCM_SETCURFOCUS, tabIndex, 0); } + + ::SendMessage(_hSelf, TCM_SETCURSEL, tabIndex, 0); + notify(TCN_SELCHANGE, tabIndex); } void TabBarPlus::exchangeTabItemData(int oldTab, int newTab)