Mercurial > vim
comparison src/gui_w32.c @ 12666:856a840679e3 v8.0.1211
patch 8.0.1211: cannot reorder tab pages with drag & drop
commit https://github.com/vim/vim/commit/ca05aa24af88836f8aa792360b3780589f294981
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Oct 22 15:36:14 2017 +0200
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)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 22 Oct 2017 15:45:04 +0200 |
parents | e9028055f6d6 |
children | 637096f179c4 |
comparison
equal
deleted
inserted
replaced
12665:8240ec5ce9c7 | 12666:856a840679e3 |
---|---|
8149 # ifdef USE_SYSMENU_FONT | 8149 # ifdef USE_SYSMENU_FONT |
8150 set_tabline_font(); | 8150 set_tabline_font(); |
8151 # endif | 8151 # endif |
8152 } | 8152 } |
8153 | 8153 |
8154 /* | |
8155 * Get tabpage_T from POINT. | |
8156 */ | |
8157 static tabpage_T * | |
8158 GetTabFromPoint( | |
8159 HWND hWnd, | |
8160 POINT pt) | |
8161 { | |
8162 tabpage_T *ptp = NULL; | |
8163 | |
8164 if (gui_mch_showing_tabline()) | |
8165 { | |
8166 TCHITTESTINFO htinfo; | |
8167 htinfo.pt = pt; | |
8168 /* ignore if a window under cusor is not tabcontrol. */ | |
8169 if (s_tabhwnd == hWnd) | |
8170 { | |
8171 int idx = TabCtrl_HitTest(s_tabhwnd, &htinfo); | |
8172 if (idx != -1) | |
8173 ptp = find_tabpage(idx + 1); | |
8174 } | |
8175 } | |
8176 return ptp; | |
8177 } | |
8178 | |
8179 static POINT s_pt = {0, 0}; | |
8180 static HCURSOR s_hCursor = NULL; | |
8181 | |
8154 static LRESULT CALLBACK | 8182 static LRESULT CALLBACK |
8155 tabline_wndproc( | 8183 tabline_wndproc( |
8156 HWND hwnd, | 8184 HWND hwnd, |
8157 UINT uMsg, | 8185 UINT uMsg, |
8158 WPARAM wParam, | 8186 WPARAM wParam, |
8159 LPARAM lParam) | 8187 LPARAM lParam) |
8160 { | 8188 { |
8189 POINT pt; | |
8190 tabpage_T *tp; | |
8191 RECT rect; | |
8192 int nCenter; | |
8193 int idx0; | |
8194 int idx1; | |
8195 | |
8161 HandleMouseHide(uMsg, lParam); | 8196 HandleMouseHide(uMsg, lParam); |
8197 | |
8198 switch (uMsg) | |
8199 { | |
8200 case WM_LBUTTONDOWN: | |
8201 { | |
8202 s_pt.x = GET_X_LPARAM(lParam); | |
8203 s_pt.y = GET_Y_LPARAM(lParam); | |
8204 SetCapture(hwnd); | |
8205 s_hCursor = GetCursor(); /* backup default cursor */ | |
8206 break; | |
8207 } | |
8208 case WM_MOUSEMOVE: | |
8209 if (GetCapture() == hwnd | |
8210 && ((wParam & MK_LBUTTON)) != 0) | |
8211 { | |
8212 pt.x = GET_X_LPARAM(lParam); | |
8213 pt.y = s_pt.y; | |
8214 if (abs(pt.x - s_pt.x) > GetSystemMetrics(SM_CXDRAG)) | |
8215 { | |
8216 SetCursor(LoadCursor(NULL, IDC_SIZEWE)); | |
8217 | |
8218 tp = GetTabFromPoint(hwnd, pt); | |
8219 if (tp != NULL) | |
8220 { | |
8221 idx0 = tabpage_index(curtab) - 1; | |
8222 idx1 = tabpage_index(tp) - 1; | |
8223 | |
8224 TabCtrl_GetItemRect(hwnd, idx1, &rect); | |
8225 nCenter = rect.left + (rect.right - rect.left) / 2; | |
8226 | |
8227 /* Check if the mouse cursor goes over the center of | |
8228 * the next tab to prevent "flickering". */ | |
8229 if ((idx0 < idx1) && (nCenter < pt.x)) | |
8230 { | |
8231 tabpage_move(idx1 + 1); | |
8232 update_screen(0); | |
8233 } | |
8234 else if ((idx1 < idx0) && (pt.x < nCenter)) | |
8235 { | |
8236 tabpage_move(idx1); | |
8237 update_screen(0); | |
8238 } | |
8239 } | |
8240 } | |
8241 } | |
8242 break; | |
8243 case WM_LBUTTONUP: | |
8244 { | |
8245 if (GetCapture() == hwnd) | |
8246 { | |
8247 SetCursor(s_hCursor); | |
8248 ReleaseCapture(); | |
8249 } | |
8250 break; | |
8251 } | |
8252 default: | |
8253 break; | |
8254 } | |
8255 | |
8162 return CallWindowProc(s_tabline_wndproc, hwnd, uMsg, wParam, lParam); | 8256 return CallWindowProc(s_tabline_wndproc, hwnd, uMsg, wParam, lParam); |
8163 } | 8257 } |
8164 #endif | 8258 #endif |
8165 | 8259 |
8166 #if defined(FEAT_OLE) || defined(FEAT_EVAL) || defined(PROTO) | 8260 #if defined(FEAT_OLE) || defined(FEAT_EVAL) || defined(PROTO) |