To: vim-dev@vim.org Subject: Patch 6.1.324 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.324 Problem: Crash when dragging a vertical separator when is remapped to jump to another window. Solution: Pass the window pointer to the function doing the dragging instead of always using the current window. (Daniel Elstner) Also fix that starting a drag changes window focus. Files: src/normal.c, src/proto/window.pro, src/ui.c, src/vim.h, src/window.c *** ../vim61.323/src/normal.c Sun Feb 16 19:41:35 2003 --- src/normal.c Sun Feb 16 17:10:13 2003 *************** *** 2413,2418 **** --- 2419,2428 ---- oap->motion_type = MCHAR; } + /* When releasing the button let jump_to_mouse() know. */ + if (!is_click && !is_drag) + jump_flags |= MOUSE_RELEASED; + /* * JUMP! */ *** ../vim61.323/src/proto/window.pro Sun Jul 21 21:47:39 2002 --- src/proto/window.pro Thu Feb 13 20:30:06 2003 *************** *** 24,31 **** void win_setheight __ARGS((int height)); void win_setwidth __ARGS((int width)); void win_setminheight __ARGS((void)); ! void win_drag_status_line __ARGS((int offset)); ! void win_drag_vsep_line __ARGS((int offset)); void win_comp_scroll __ARGS((win_T *wp)); void command_height __ARGS((long old_p_ch)); void last_status __ARGS((int morewin)); --- 24,31 ---- void win_setheight __ARGS((int height)); void win_setwidth __ARGS((int width)); void win_setminheight __ARGS((void)); ! void win_drag_status_line __ARGS((win_T *dragwin, int offset)); ! void win_drag_vsep_line __ARGS((win_T *dragwin, int offset)); void win_comp_scroll __ARGS((win_T *wp)); void command_height __ARGS((long old_p_ch)); void last_status __ARGS((int morewin)); *** ../vim61.323/src/ui.c Mon Jan 6 10:16:31 2003 --- src/ui.c Thu Feb 13 20:19:00 2003 *************** *** 2207,2216 **** #endif static int prev_row = -1; static int prev_col = -1; ! #ifdef FEAT_CMDWIN ! static int drag_prev_win = FALSE; /* dragging status line above ! command-line window */ ! #endif win_T *wp, *old_curwin; pos_T old_cursor; --- 2208,2215 ---- #endif static int prev_row = -1; static int prev_col = -1; ! static win_T *dragwin = NULL; /* window being dragged */ ! static int did_drag = FALSE; /* drag was noticed */ win_T *wp, *old_curwin; pos_T old_cursor; *************** *** 2225,2230 **** --- 2224,2239 ---- mouse_past_bottom = FALSE; mouse_past_eol = FALSE; + if (flags & MOUSE_RELEASED) + { + /* On button release we may change window focus if positioned on a + * status line and no dragging happened. */ + if (dragwin != NULL && !did_drag) + flags &= ~(MOUSE_FOCUS | MOUSE_DID_MOVE); + dragwin = NULL; + did_drag = FALSE; + } + if ((flags & MOUSE_DID_MOVE) && prev_row == mouse_row && prev_col == mouse_col) *************** *** 2282,2297 **** --- 2291,2313 ---- #else wp = firstwin; #endif + dragwin = NULL; /* * winpos and height may change in win_enter()! */ if (row >= wp->w_height) /* In (or below) status line */ + { on_status_line = row - wp->w_height + 1; + dragwin = wp; + } else on_status_line = 0; #ifdef FEAT_VERTSPLIT if (col >= wp->w_width) /* In separator line */ + { on_sep_line = col - wp->w_width + 1; + dragwin = wp; + } else on_sep_line = 0; *************** *** 2333,2351 **** } #endif #ifdef FEAT_CMDWIN - drag_prev_win = FALSE; if (cmdwin_type != 0 && wp != curwin) { /* A click outside the command-line window: Use modeless * selection if possible. Allow dragging the status line of the * window just above the command-line window. */ ! if (wp == curwin->w_prev) ! drag_prev_win = TRUE; ! else on_status_line = 0; on_sep_line = 0; # ifdef FEAT_CLIPBOARD ! if (drag_prev_win) return IN_STATUS_LINE; return IN_OTHER_WIN; # else --- 2349,2369 ---- } #endif #ifdef FEAT_CMDWIN if (cmdwin_type != 0 && wp != curwin) { /* A click outside the command-line window: Use modeless * selection if possible. Allow dragging the status line of the * window just above the command-line window. */ ! if (wp != curwin->w_prev) ! { on_status_line = 0; + dragwin = NULL; + } + # ifdef FEAT_VERTSPLIT on_sep_line = 0; + # endif # ifdef FEAT_CLIPBOARD ! if (on_status_line) return IN_STATUS_LINE; return IN_OTHER_WIN; # else *************** *** 2356,2362 **** } #endif #ifdef FEAT_WINDOWS ! win_enter(wp, TRUE); /* can make wp invalid! */ # ifdef CHECK_DOUBLE_CLICK /* set topline, to be able to check for double click ourselves */ if (curwin != old_curwin) --- 2374,2384 ---- } #endif #ifdef FEAT_WINDOWS ! /* Only change window focus when not clicking on or dragging the ! * status line. Do change focus when releasing the mouse button ! * (MOUSE_FOCUS was set above if we dragged first). */ ! if (dragwin == NULL || (flags & MOUSE_RELEASED)) ! win_enter(wp, TRUE); /* can make wp invalid! */ # ifdef CHECK_DOUBLE_CLICK /* set topline, to be able to check for double click ourselves */ if (curwin != old_curwin) *************** *** 2394,2422 **** else if (on_status_line && which_button == MOUSE_LEFT) { #ifdef FEAT_WINDOWS ! wp = curwin; ! # ifdef FEAT_CMDWIN ! if (cmdwin_type != 0 && drag_prev_win && curwin->w_prev != NULL) ! /* Drag the status line of the window above the command-line ! * window. */ ! curwin = curwin->w_prev; ! # endif ! /* Drag the status line */ ! count = row - curwin->w_winrow - curwin->w_height + 1 - on_status_line; ! win_drag_status_line(count); ! ! # ifdef FEAT_CMDWIN ! curwin = wp; ! # endif #endif return IN_STATUS_LINE; /* Cursor didn't move */ } #ifdef FEAT_VERTSPLIT else if (on_sep_line && which_button == MOUSE_LEFT) { ! /* Drag the separator column */ ! count = col - curwin->w_wincol - curwin->w_width + 1 - on_sep_line; ! win_drag_vsep_line(count); return IN_SEP_LINE; /* Cursor didn't move */ } #endif --- 2416,2443 ---- else if (on_status_line && which_button == MOUSE_LEFT) { #ifdef FEAT_WINDOWS ! if (dragwin != NULL) ! { ! /* Drag the status line */ ! count = row - dragwin->w_winrow - dragwin->w_height + 1 ! - on_status_line; ! win_drag_status_line(dragwin, count); ! did_drag |= count; ! } #endif return IN_STATUS_LINE; /* Cursor didn't move */ } #ifdef FEAT_VERTSPLIT else if (on_sep_line && which_button == MOUSE_LEFT) { ! if (dragwin != NULL) ! { ! /* Drag the separator column */ ! count = col - dragwin->w_wincol - dragwin->w_width + 1 ! - on_sep_line; ! win_drag_vsep_line(dragwin, count); ! did_drag |= count; ! } return IN_SEP_LINE; /* Cursor didn't move */ } #endif *** ../vim61.323/src/vim.h Sun Jan 5 22:14:46 2003 --- src/vim.h Sun Feb 16 15:57:09 2003 *************** *** 1388,1393 **** --- 1392,1398 ---- # define MOUSE_DID_MOVE 0x04 /* only act when mouse has moved */ # define MOUSE_SETPOS 0x08 /* only set current mouse position */ # define MOUSE_MAY_STOP_VIS 0x10 /* may stop Visual mode */ + # define MOUSE_RELEASED 0x20 /* button was released */ # if defined(UNIX) && defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) # define CHECK_DOUBLE_CLICK 1 /* Checking for double clicks ourselves. */ *** ../vim61.323/src/window.c Sun Feb 2 21:43:36 2003 --- src/window.c Thu Feb 13 20:22:57 2003 *************** *** 3820,3829 **** #ifdef FEAT_MOUSE /* ! * Status line of curwin is dragged "offset" lines down (negative is up). */ void ! win_drag_status_line(offset) int offset; { frame_T *curfr; --- 3827,3837 ---- #ifdef FEAT_MOUSE /* ! * Status line of dragwin is dragged "offset" lines down (negative is up). */ void ! win_drag_status_line(dragwin, offset) ! win_T *dragwin; int offset; { frame_T *curfr; *************** *** 3833,3839 **** int up; /* if TRUE, drag status line up, otherwise down */ int n; ! fr = curwin->w_frame; curfr = fr; if (fr != topframe) /* more than one window */ { --- 3841,3847 ---- int up; /* if TRUE, drag status line up, otherwise down */ int n; ! fr = dragwin->w_frame; curfr = fr; if (fr != topframe) /* more than one window */ { *************** *** 3950,3959 **** #ifdef FEAT_VERTSPLIT /* ! * Separator line of curwin is dragged "offset" lines right (negative is left). */ void ! win_drag_vsep_line(offset) int offset; { frame_T *curfr; --- 3958,3968 ---- #ifdef FEAT_VERTSPLIT /* ! * Separator line of dragwin is dragged "offset" lines right (negative is left). */ void ! win_drag_vsep_line(dragwin, offset) ! win_T *dragwin; int offset; { frame_T *curfr; *************** *** 3962,3968 **** int left; /* if TRUE, drag separator line left, otherwise right */ int n; ! fr = curwin->w_frame; if (fr == topframe) /* only one window (cannot happe?) */ return; curfr = fr; --- 3971,3977 ---- int left; /* if TRUE, drag separator line left, otherwise right */ int n; ! fr = dragwin->w_frame; if (fr == topframe) /* only one window (cannot happe?) */ return; curfr = fr; *** ../vim61.323/src/version.c Sun Feb 16 20:14:02 2003 --- src/version.c Sun Feb 16 20:26:22 2003 *************** *** 608,609 **** --- 612,615 ---- { /* Add new patch number below this line */ + /**/ + 324, /**/ -- hundred-and-one symptoms of being an internet addict: 263. You have more e-mail addresses than shorts. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///