Created
November 22, 2013 14:43
-
-
Save nocd5/7600961 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*** src/gui_w32.c Sun Aug 4 23:15:37 2013 | |
--- src/gui_w32.c.mod Fri Nov 22 23:29:22 2013 | |
*************** | |
*** 4241,4246 **** | |
--- 4241,4274 ---- | |
# 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 tabpage_T *s_tp = NULL; | |
+ static POINT s_pt = {0, 0}; | |
+ static HCURSOR s_hCursor = NULL; | |
+ | |
static LRESULT CALLBACK | |
tabline_wndproc( | |
HWND hwnd, | |
*************** | |
*** 4249,4254 **** | |
--- 4277,4350 ---- | |
LPARAM lParam) | |
{ | |
HandleMouseHide(uMsg, lParam); | |
+ | |
+ POINT pt; | |
+ tabpage_T *tp; | |
+ RECT rect; | |
+ int nCenter; | |
+ int idx0; | |
+ int idx1; | |
+ | |
+ switch (uMsg) | |
+ { | |
+ case WM_LBUTTONDOWN: | |
+ { | |
+ s_pt.x = GET_X_LPARAM(lParam); | |
+ s_pt.y = GET_Y_LPARAM(lParam); | |
+ s_tp = GetTabFromPoint(hwnd, s_pt); | |
+ if (s_tp != NULL) | |
+ { | |
+ SetCapture(hwnd); | |
+ s_hCursor = GetCursor(); /* backup default cursor */ | |
+ } | |
+ break; | |
+ } | |
+ case WM_MOUSEMOVE: | |
+ if (GetCapture() == hwnd | |
+ && (0 != (wParam & MK_LBUTTON))) | |
+ { | |
+ SetCursor(LoadCursor(NULL, IDC_SIZEWE)); | |
+ | |
+ pt.x = GET_X_LPARAM(lParam); | |
+ pt.y = s_pt.y; | |
+ if ( abs(pt.x - s_pt.x) > GetSystemMetrics(SM_CXDRAG) ) | |
+ { | |
+ tp = GetTabFromPoint(hwnd, pt); | |
+ if (s_tp != NULL && tp != NULL | |
+ && tp != s_tp) /* ignore if the same tabpage */ | |
+ { | |
+ idx0 = tabpage_index(s_tp) - 1; | |
+ | |
+ idx1 = tabpage_index(tp) - 1; | |
+ TabCtrl_GetItemRect(hwnd, idx1, &rect); | |
+ nCenter = rect.left + (rect.right - rect.left) / 2; | |
+ | |
+ /* move rightward & over the center | |
+ or move leftward & over the center */ | |
+ if ( ((idx0 < idx1) && (nCenter < pt.x)) | |
+ || ((idx1 < idx0) && (pt.x < nCenter)) ) | |
+ { | |
+ tabpage_move(idx1); | |
+ update_screen(0); | |
+ } | |
+ } | |
+ } | |
+ } | |
+ break; | |
+ case WM_LBUTTONUP: | |
+ { | |
+ if (GetCapture() == hwnd) | |
+ { | |
+ SetCursor(s_hCursor); | |
+ ReleaseCapture(); | |
+ s_tp = NULL; | |
+ } | |
+ break; | |
+ } | |
+ default: | |
+ break; | |
+ } | |
+ | |
return CallWindowProc(s_tabline_wndproc, hwnd, uMsg, wParam, lParam); | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment