To: vim-dev@vim.org Subject: Patch 6.1.346 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.346 Problem: The scroll wheel can only scroll the current window. Solution: Make the scroll wheel scroll the window that the mouse points to. (Daniel Elstner) Files: src/edit.c, src/gui.c, src/normal.c, src/term.c *** ../vim61.345/src/edit.c Mon Feb 17 21:06:47 2003 --- src/edit.c Mon Feb 17 20:53:42 2003 *************** *** 6551,6563 **** int up; { pos_T tpos; - undisplay_dollar(); tpos = curwin->w_cursor; ! if (mod_mask & MOD_MASK_SHIFT) scroll_redraw(up, (long)(curwin->w_botline - curwin->w_topline)); else scroll_redraw(up, 3L); if (!equal(curwin->w_cursor, tpos)) { start_arrow(&tpos); --- 6560,6602 ---- int up; { pos_T tpos; + # if defined(FEAT_GUI) && defined(FEAT_WINDOWS) + win_T *old_curwin; + # endif tpos = curwin->w_cursor; ! ! # if defined(FEAT_GUI) && defined(FEAT_WINDOWS) ! old_curwin = curwin; ! ! /* Currently the mouse coordinates are only known in the GUI. */ ! if (gui.in_use && mouse_row >= 0 && mouse_col >= 0) ! { ! int row, col; ! ! row = mouse_row; ! col = mouse_col; ! ! /* find the window at the pointer coordinates */ ! curwin = mouse_find_win(&row, &col); ! curbuf = curwin->w_buffer; ! } ! if (curwin == old_curwin) ! # endif ! undisplay_dollar(); ! ! if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) scroll_redraw(up, (long)(curwin->w_botline - curwin->w_topline)); else scroll_redraw(up, 3L); + + # if defined(FEAT_GUI) && defined(FEAT_WINDOWS) + curwin->w_redr_status = TRUE; + + curwin = old_curwin; + curbuf = curwin->w_buffer; + # endif + if (!equal(curwin->w_cursor, tpos)) { start_arrow(&tpos); *** ../vim61.345/src/gui.c Wed Feb 19 11:21:27 2003 --- src/gui.c Wed Feb 19 10:51:34 2003 *************** *** 2487,2494 **** static int prev_row = 0, prev_col = 0; static int prev_button = -1; static int num_clicks = 1; ! char_u string[6]; ! char_u button_char; int row, col; #ifdef FEAT_CLIPBOARD int checkfor; --- 2509,2516 ---- static int prev_row = 0, prev_col = 0; static int prev_button = -1; static int num_clicks = 1; ! char_u string[10]; ! enum key_extra button_char; int row, col; #ifdef FEAT_CLIPBOARD int checkfor; *************** *** 2519,2527 **** string[3] = CSI; string[4] = KS_EXTRA; ! string[5] = button_char; if (modifiers == 0) ! add_to_input_buf(string + 3, 3); else { string[0] = CSI; --- 2541,2558 ---- string[3] = CSI; string[4] = KS_EXTRA; ! string[5] = (int)button_char; ! ! /* Pass the pointer coordinates of the scroll event so that we ! * know which window to scroll. */ ! row = gui_xy2colrow(x, y, &col); ! string[6] = (char_u)(col / 128 + ' ' + 1); ! string[7] = (char_u)(col % 128 + ' ' + 1); ! string[8] = (char_u)(row / 128 + ' ' + 1); ! string[9] = (char_u)(row % 128 + ' ' + 1); ! if (modifiers == 0) ! add_to_input_buf(string + 3, 7); else { string[0] = CSI; *************** *** 2533,2539 **** string[2] |= MOD_MASK_CTRL; if (modifiers & MOUSE_ALT) string[2] |= MOD_MASK_ALT; ! add_to_input_buf(string, 6); } return; } --- 2564,2570 ---- string[2] |= MOD_MASK_CTRL; if (modifiers & MOUSE_ALT) string[2] |= MOD_MASK_ALT; ! add_to_input_buf(string, 10); } return; } *** ../vim61.345/src/normal.c Sun Feb 16 20:29:05 2003 --- src/normal.c Sun Feb 16 20:54:16 2003 *************** *** 3914,3919 **** --- 3920,3944 ---- nv_mousescroll(cap) cmdarg_T *cap; { + # if defined(FEAT_GUI) && defined(FEAT_WINDOWS) + win_T *old_curwin; + + old_curwin = curwin; + + /* Currently we only get the mouse coordinates in the GUI. */ + if (gui.in_use && mouse_row >= 0 && mouse_col >= 0) + { + int row, col; + + row = mouse_row; + col = mouse_col; + + /* find the window at the pointer coordinates */ + curwin = mouse_find_win(&row, &col); + curbuf = curwin->w_buffer; + } + # endif + if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) { (void)onepage(cap->arg ? FORWARD : BACKWARD, 1L); *************** *** 3924,3929 **** --- 3949,3961 ---- cap->count0 = 3; nv_scroll_line(cap); } + + # if defined(FEAT_GUI) && defined(FEAT_WINDOWS) + curwin->w_redr_status = TRUE; + + curwin = old_curwin; + curbuf = curwin->w_buffer; + # endif } /* *** ../vim61.345/src/term.c Sun Feb 16 21:22:22 2003 --- src/term.c Mon Feb 17 11:51:49 2003 *************** *** 3658,3664 **** #endif #ifdef FEAT_MOUSE # if !defined(UNIX) || defined(FEAT_MOUSE_XTERM) || defined(FEAT_GUI) ! char_u bytes[3]; int num_bytes; # endif int mouse_code = 0; /* init for GCC */ --- 3671,3677 ---- #endif #ifdef FEAT_MOUSE # if !defined(UNIX) || defined(FEAT_MOUSE_XTERM) || defined(FEAT_GUI) ! char_u bytes[4]; int num_bytes; # endif int mouse_code = 0; /* init for GCC */ *************** *** 3903,3908 **** --- 3916,3942 ---- /* We only get here when we have a complete termcode match */ #ifdef FEAT_MOUSE + # ifdef FEAT_GUI + /* + * Only in the GUI: Fetch the pointer coordinates of the scroll event + * so that we know which window to scroll later. + */ + if (gui.in_use + && key_name[0] == (int)KS_EXTRA + && (key_name[1] == (int)KE_X1MOUSE + || key_name[1] == (int)KE_X2MOUSE + || key_name[1] == (int)KE_MOUSEDOWN + || key_name[1] == (int)KE_MOUSEUP)) + { + num_bytes = get_bytes_from_buf(tp + slen, bytes, 4); + if (num_bytes == -1) /* not enough coordinates */ + return -1; + mouse_col = 128 * (bytes[0] - ' ' - 1) + bytes[1] - ' ' - 1; + mouse_row = 128 * (bytes[2] - ' ' - 1) + bytes[3] - ' ' - 1; + slen += num_bytes; + } + else + # endif /* * If it is a mouse click, get the coordinates. */ *** ../vim61.345/src/version.c Thu Feb 20 21:29:10 2003 --- src/version.c Thu Feb 20 21:31:05 2003 *************** *** 608,609 **** --- 612,615 ---- { /* Add new patch number below this line */ + /**/ + 346, /**/ -- ** Hello and Welcome to the Psychiatric Hotline ** If you are obsessive-compulsive, please press 1 repeatedly. If you are co-dependent, please ask someone to press 2. If you have multiple personalities, please press 3, 4, 5 and 6. If you are paranoid-delusional, we know who you are and what you want - just stay on the line so we can trace the call. If you are schizophrenic, listen carefully and a little voice will tell you which number to press next. If you are manic-depressive, it doesn't matter which number you press - no one will answer. If you suffer from panic attacks, push every button you can find. If you are sane, please hold on - we have the rest of humanity on the other line and they desparately want to ask you a few questions. /// 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 ///