0
0
mirror of https://github.com/vim/vim.git synced 2025-10-06 05:44:14 -04:00

patch 8.0.1211: cannot reorder tab pages with drag & drop

Problem:    Cannot reorder tab pages with drag & drop.
Solution:   Support drag & drop for GTK and MS-Windows. (Ken Takata, Masamichi
            Abe)
This commit is contained in:
Bram Moolenaar
2017-10-22 15:36:14 +02:00
parent f8e8c0643b
commit ca05aa24af
3 changed files with 126 additions and 1 deletions

View File

@@ -8151,6 +8151,34 @@ initialise_tabline(void)
# endif
}
/*
* Get tabpage_T from POINT.
*/
static tabpage_T *
GetTabFromPoint(
HWND hWnd,
POINT pt)
{
tabpage_T *ptp = NULL;
if (gui_mch_showing_tabline())
{
TCHITTESTINFO htinfo;
htinfo.pt = pt;
/* ignore if a window under cusor is not tabcontrol. */
if (s_tabhwnd == hWnd)
{
int idx = TabCtrl_HitTest(s_tabhwnd, &htinfo);
if (idx != -1)
ptp = find_tabpage(idx + 1);
}
}
return ptp;
}
static POINT s_pt = {0, 0};
static HCURSOR s_hCursor = NULL;
static LRESULT CALLBACK
tabline_wndproc(
HWND hwnd,
@@ -8158,7 +8186,73 @@ tabline_wndproc(
WPARAM wParam,
LPARAM lParam)
{
POINT pt;
tabpage_T *tp;
RECT rect;
int nCenter;
int idx0;
int idx1;
HandleMouseHide(uMsg, lParam);
switch (uMsg)
{
case WM_LBUTTONDOWN:
{
s_pt.x = GET_X_LPARAM(lParam);
s_pt.y = GET_Y_LPARAM(lParam);
SetCapture(hwnd);
s_hCursor = GetCursor(); /* backup default cursor */
break;
}
case WM_MOUSEMOVE:
if (GetCapture() == hwnd
&& ((wParam & MK_LBUTTON)) != 0)
{
pt.x = GET_X_LPARAM(lParam);
pt.y = s_pt.y;
if (abs(pt.x - s_pt.x) > GetSystemMetrics(SM_CXDRAG))
{
SetCursor(LoadCursor(NULL, IDC_SIZEWE));
tp = GetTabFromPoint(hwnd, pt);
if (tp != NULL)
{
idx0 = tabpage_index(curtab) - 1;
idx1 = tabpage_index(tp) - 1;
TabCtrl_GetItemRect(hwnd, idx1, &rect);
nCenter = rect.left + (rect.right - rect.left) / 2;
/* Check if the mouse cursor goes over the center of
* the next tab to prevent "flickering". */
if ((idx0 < idx1) && (nCenter < pt.x))
{
tabpage_move(idx1 + 1);
update_screen(0);
}
else if ((idx1 < idx0) && (pt.x < nCenter))
{
tabpage_move(idx1);
update_screen(0);
}
}
}
}
break;
case WM_LBUTTONUP:
{
if (GetCapture() == hwnd)
{
SetCursor(s_hCursor);
ReleaseCapture();
}
break;
}
default:
break;
}
return CallWindowProc(s_tabline_wndproc, hwnd, uMsg, wParam, lParam);
}
#endif