home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 6.1.324 < prev    next >
Encoding:
Internet Message Format  |  2003-02-15  |  10.1 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.1.324
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=ISO-8859-1
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 6.1.324
  11. Problem:    Crash when dragging a vertical separator when <LeftMouse> is
  12.         remapped to jump to another window.
  13. Solution:   Pass the window pointer to the function doing the dragging instead
  14.         of always using the current window. (Daniel Elstner)
  15.         Also fix that starting a drag changes window focus.
  16. Files:        src/normal.c, src/proto/window.pro, src/ui.c, src/vim.h,
  17.         src/window.c
  18.  
  19.  
  20. *** ../vim61.323/src/normal.c    Sun Feb 16 19:41:35 2003
  21. --- src/normal.c    Sun Feb 16 17:10:13 2003
  22. ***************
  23. *** 2413,2418 ****
  24. --- 2419,2428 ----
  25.       oap->motion_type = MCHAR;
  26.       }
  27.   
  28. +     /* When releasing the button let jump_to_mouse() know. */
  29. +     if (!is_click && !is_drag)
  30. +     jump_flags |= MOUSE_RELEASED;
  31.       /*
  32.        * JUMP!
  33.        */
  34. *** ../vim61.323/src/proto/window.pro    Sun Jul 21 21:47:39 2002
  35. --- src/proto/window.pro    Thu Feb 13 20:30:06 2003
  36. ***************
  37. *** 24,31 ****
  38.   void win_setheight __ARGS((int height));
  39.   void win_setwidth __ARGS((int width));
  40.   void win_setminheight __ARGS((void));
  41. ! void win_drag_status_line __ARGS((int offset));
  42. ! void win_drag_vsep_line __ARGS((int offset));
  43.   void win_comp_scroll __ARGS((win_T *wp));
  44.   void command_height __ARGS((long old_p_ch));
  45.   void last_status __ARGS((int morewin));
  46. --- 24,31 ----
  47.   void win_setheight __ARGS((int height));
  48.   void win_setwidth __ARGS((int width));
  49.   void win_setminheight __ARGS((void));
  50. ! void win_drag_status_line __ARGS((win_T *dragwin, int offset));
  51. ! void win_drag_vsep_line __ARGS((win_T *dragwin, int offset));
  52.   void win_comp_scroll __ARGS((win_T *wp));
  53.   void command_height __ARGS((long old_p_ch));
  54.   void last_status __ARGS((int morewin));
  55. *** ../vim61.323/src/ui.c    Mon Jan  6 10:16:31 2003
  56. --- src/ui.c    Thu Feb 13 20:19:00 2003
  57. ***************
  58. *** 2207,2216 ****
  59.   #endif
  60.       static int    prev_row = -1;
  61.       static int    prev_col = -1;
  62. ! #ifdef FEAT_CMDWIN
  63. !     static int  drag_prev_win = FALSE;    /* dragging status line above
  64. !                        command-line window */
  65. ! #endif
  66.   
  67.       win_T    *wp, *old_curwin;
  68.       pos_T    old_cursor;
  69. --- 2208,2215 ----
  70.   #endif
  71.       static int    prev_row = -1;
  72.       static int    prev_col = -1;
  73. !     static win_T *dragwin = NULL;    /* window being dragged */
  74. !     static int    did_drag = FALSE;    /* drag was noticed */
  75.   
  76.       win_T    *wp, *old_curwin;
  77.       pos_T    old_cursor;
  78. ***************
  79. *** 2225,2230 ****
  80. --- 2224,2239 ----
  81.       mouse_past_bottom = FALSE;
  82.       mouse_past_eol = FALSE;
  83.   
  84. +     if (flags & MOUSE_RELEASED)
  85. +     {
  86. +     /* On button release we may change window focus if positioned on a
  87. +      * status line and no dragging happened. */
  88. +     if (dragwin != NULL && !did_drag)
  89. +         flags &= ~(MOUSE_FOCUS | MOUSE_DID_MOVE);
  90. +     dragwin = NULL;
  91. +     did_drag = FALSE;
  92. +     }
  93.       if ((flags & MOUSE_DID_MOVE)
  94.           && prev_row == mouse_row
  95.           && prev_col == mouse_col)
  96. ***************
  97. *** 2282,2297 ****
  98. --- 2291,2313 ----
  99.   #else
  100.       wp = firstwin;
  101.   #endif
  102. +     dragwin = NULL;
  103.       /*
  104.        * winpos and height may change in win_enter()!
  105.        */
  106.       if (row >= wp->w_height)        /* In (or below) status line */
  107. +     {
  108.           on_status_line = row - wp->w_height + 1;
  109. +         dragwin = wp;
  110. +     }
  111.       else
  112.           on_status_line = 0;
  113.   #ifdef FEAT_VERTSPLIT
  114.       if (col >= wp->w_width)        /* In separator line */
  115. +     {
  116.           on_sep_line = col - wp->w_width + 1;
  117. +         dragwin = wp;
  118. +     }
  119.       else
  120.           on_sep_line = 0;
  121.   
  122. ***************
  123. *** 2333,2351 ****
  124.       }
  125.   #endif
  126.   #ifdef FEAT_CMDWIN
  127. -     drag_prev_win = FALSE;
  128.       if (cmdwin_type != 0 && wp != curwin)
  129.       {
  130.           /* A click outside the command-line window: Use modeless
  131.            * selection if possible.  Allow dragging the status line of the
  132.            * window just above the command-line window. */
  133. !         if (wp == curwin->w_prev)
  134. !         drag_prev_win = TRUE;
  135. !         else
  136.           on_status_line = 0;
  137.           on_sep_line = 0;
  138.   # ifdef FEAT_CLIPBOARD
  139. !         if (drag_prev_win)
  140.           return IN_STATUS_LINE;
  141.           return IN_OTHER_WIN;
  142.   # else
  143. --- 2349,2369 ----
  144.       }
  145.   #endif
  146.   #ifdef FEAT_CMDWIN
  147.       if (cmdwin_type != 0 && wp != curwin)
  148.       {
  149.           /* A click outside the command-line window: Use modeless
  150.            * selection if possible.  Allow dragging the status line of the
  151.            * window just above the command-line window. */
  152. !         if (wp != curwin->w_prev)
  153. !         {
  154.           on_status_line = 0;
  155. +         dragwin = NULL;
  156. +         }
  157. + # ifdef FEAT_VERTSPLIT
  158.           on_sep_line = 0;
  159. + # endif
  160.   # ifdef FEAT_CLIPBOARD
  161. !         if (on_status_line)
  162.           return IN_STATUS_LINE;
  163.           return IN_OTHER_WIN;
  164.   # else
  165. ***************
  166. *** 2356,2362 ****
  167.       }
  168.   #endif
  169.   #ifdef FEAT_WINDOWS
  170. !     win_enter(wp, TRUE);            /* can make wp invalid! */
  171.   # ifdef CHECK_DOUBLE_CLICK
  172.       /* set topline, to be able to check for double click ourselves */
  173.       if (curwin != old_curwin)
  174. --- 2374,2384 ----
  175.       }
  176.   #endif
  177.   #ifdef FEAT_WINDOWS
  178. !     /* Only change window focus when not clicking on or dragging the
  179. !      * status line.  Do change focus when releasing the mouse button
  180. !      * (MOUSE_FOCUS was set above if we dragged first). */
  181. !     if (dragwin == NULL || (flags & MOUSE_RELEASED))
  182. !         win_enter(wp, TRUE);        /* can make wp invalid! */
  183.   # ifdef CHECK_DOUBLE_CLICK
  184.       /* set topline, to be able to check for double click ourselves */
  185.       if (curwin != old_curwin)
  186. ***************
  187. *** 2394,2422 ****
  188.       else if (on_status_line && which_button == MOUSE_LEFT)
  189.       {
  190.   #ifdef FEAT_WINDOWS
  191. !     wp = curwin;
  192. ! # ifdef FEAT_CMDWIN
  193. !     if (cmdwin_type != 0 && drag_prev_win && curwin->w_prev != NULL)
  194. !         /* Drag the status line of the window above the command-line
  195. !          * window. */
  196. !         curwin = curwin->w_prev;
  197. ! # endif
  198. !     /* Drag the status line */
  199. !     count = row - curwin->w_winrow - curwin->w_height + 1 - on_status_line;
  200. !     win_drag_status_line(count);
  201. ! # ifdef FEAT_CMDWIN
  202. !     curwin = wp;
  203. ! # endif
  204.   #endif
  205.       return IN_STATUS_LINE;            /* Cursor didn't move */
  206.       }
  207.   #ifdef FEAT_VERTSPLIT
  208.       else if (on_sep_line && which_button == MOUSE_LEFT)
  209.       {
  210. !     /* Drag the separator column */
  211. !     count = col - curwin->w_wincol - curwin->w_width + 1 - on_sep_line;
  212. !     win_drag_vsep_line(count);
  213.       return IN_SEP_LINE;            /* Cursor didn't move */
  214.       }
  215.   #endif
  216. --- 2416,2443 ----
  217.       else if (on_status_line && which_button == MOUSE_LEFT)
  218.       {
  219.   #ifdef FEAT_WINDOWS
  220. !     if (dragwin != NULL)
  221. !         {
  222. !         /* Drag the status line */
  223. !         count = row - dragwin->w_winrow - dragwin->w_height + 1
  224. !                                  - on_status_line;
  225. !         win_drag_status_line(dragwin, count);
  226. !         did_drag |= count;
  227. !     }
  228.   #endif
  229.       return IN_STATUS_LINE;            /* Cursor didn't move */
  230.       }
  231.   #ifdef FEAT_VERTSPLIT
  232.       else if (on_sep_line && which_button == MOUSE_LEFT)
  233.       {
  234. !     if (dragwin != NULL)
  235. !     {
  236. !         /* Drag the separator column */
  237. !         count = col - dragwin->w_wincol - dragwin->w_width + 1
  238. !                                 - on_sep_line;
  239. !         win_drag_vsep_line(dragwin, count);
  240. !         did_drag |= count;
  241. !     }
  242.       return IN_SEP_LINE;            /* Cursor didn't move */
  243.       }
  244.   #endif
  245. *** ../vim61.323/src/vim.h    Sun Jan  5 22:14:46 2003
  246. --- src/vim.h    Sun Feb 16 15:57:09 2003
  247. ***************
  248. *** 1388,1393 ****
  249. --- 1392,1398 ----
  250.   # define MOUSE_DID_MOVE        0x04    /* only act when mouse has moved */
  251.   # define MOUSE_SETPOS        0x08    /* only set current mouse position */
  252.   # define MOUSE_MAY_STOP_VIS    0x10    /* may stop Visual mode */
  253. + # define MOUSE_RELEASED        0x20    /* button was released */
  254.   
  255.   # if defined(UNIX) && defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
  256.   #  define CHECK_DOUBLE_CLICK 1    /* Checking for double clicks ourselves. */
  257. *** ../vim61.323/src/window.c    Sun Feb  2 21:43:36 2003
  258. --- src/window.c    Thu Feb 13 20:22:57 2003
  259. ***************
  260. *** 3820,3829 ****
  261.   #ifdef FEAT_MOUSE
  262.   
  263.   /*
  264. !  * Status line of curwin is dragged "offset" lines down (negative is up).
  265.    */
  266.       void
  267. ! win_drag_status_line(offset)
  268.       int        offset;
  269.   {
  270.       frame_T    *curfr;
  271. --- 3827,3837 ----
  272.   #ifdef FEAT_MOUSE
  273.   
  274.   /*
  275. !  * Status line of dragwin is dragged "offset" lines down (negative is up).
  276.    */
  277.       void
  278. ! win_drag_status_line(dragwin, offset)
  279. !     win_T    *dragwin;
  280.       int        offset;
  281.   {
  282.       frame_T    *curfr;
  283. ***************
  284. *** 3833,3839 ****
  285.       int        up;    /* if TRUE, drag status line up, otherwise down */
  286.       int        n;
  287.   
  288. !     fr = curwin->w_frame;
  289.       curfr = fr;
  290.       if (fr != topframe)        /* more than one window */
  291.       {
  292. --- 3841,3847 ----
  293.       int        up;    /* if TRUE, drag status line up, otherwise down */
  294.       int        n;
  295.   
  296. !     fr = dragwin->w_frame;
  297.       curfr = fr;
  298.       if (fr != topframe)        /* more than one window */
  299.       {
  300. ***************
  301. *** 3950,3959 ****
  302.   
  303.   #ifdef FEAT_VERTSPLIT
  304.   /*
  305. !  * Separator line of curwin is dragged "offset" lines right (negative is left).
  306.    */
  307.       void
  308. ! win_drag_vsep_line(offset)
  309.       int        offset;
  310.   {
  311.       frame_T    *curfr;
  312. --- 3958,3968 ----
  313.   
  314.   #ifdef FEAT_VERTSPLIT
  315.   /*
  316. !  * Separator line of dragwin is dragged "offset" lines right (negative is left).
  317.    */
  318.       void
  319. ! win_drag_vsep_line(dragwin, offset)
  320. !     win_T    *dragwin;
  321.       int        offset;
  322.   {
  323.       frame_T    *curfr;
  324. ***************
  325. *** 3962,3968 ****
  326.       int        left;    /* if TRUE, drag separator line left, otherwise right */
  327.       int        n;
  328.   
  329. !     fr = curwin->w_frame;
  330.       if (fr == topframe)        /* only one window (cannot happe?) */
  331.       return;
  332.       curfr = fr;
  333. --- 3971,3977 ----
  334.       int        left;    /* if TRUE, drag separator line left, otherwise right */
  335.       int        n;
  336.   
  337. !     fr = dragwin->w_frame;
  338.       if (fr == topframe)        /* only one window (cannot happe?) */
  339.       return;
  340.       curfr = fr;
  341. *** ../vim61.323/src/version.c    Sun Feb 16 20:14:02 2003
  342. --- src/version.c    Sun Feb 16 20:26:22 2003
  343. ***************
  344. *** 608,609 ****
  345. --- 612,615 ----
  346.   {   /* Add new patch number below this line */
  347. + /**/
  348. +     324,
  349.   /**/
  350.  
  351. -- 
  352. hundred-and-one symptoms of being an internet addict:
  353. 263. You have more e-mail addresses than shorts.
  354.  
  355.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  356. ///          Creator of Vim - Vi IMproved -- http://www.Vim.org          \\\
  357. \\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
  358.  \\\     Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///
  359.