in do_mouseinput(), deal with clicks of the first mouse button again;

oddly, ncurses built without --enable-ext-mouse needs this, but ncurses
built with --enable-ext-mouse doesn't


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4112 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2007-05-29 17:01:12 +00:00
parent 14aa37c692
commit 3a504709b7
2 changed files with 30 additions and 24 deletions

View File

@ -1,3 +1,9 @@
2007-05-29 David Lawrence Ramsey <pooka109@gmail.com>
* winio.c (do_mouseinput): Deal with clicks of the first mouse
button again. Oddly, ncurses built without --enable-ext-mouse
needs this, but ncurses built with --enable-ext-mouse doesn't.
2007-05-25 David Lawrence Ramsey <pooka109@gmail.com> 2007-05-25 David Lawrence Ramsey <pooka109@gmail.com>
* configure.ac, nano.c (main): Replace the current hackish check * configure.ac, nano.c (main): Replace the current hackish check
@ -21,7 +27,7 @@
Fix processing of mouse events so that those we don't handle are Fix processing of mouse events so that those we don't handle are
ignored instead of being erroneously passed through. ignored instead of being erroneously passed through.
* winio.c (do_mouseinput): Simplify handling of mouse events * winio.c (do_mouseinput): Simplify handling of mouse events
involving the first mouse button. involving the first mouse button by only dealing with releases.
* winio.c (do_mouseinput): Improve mouse wheel support to only * winio.c (do_mouseinput): Improve mouse wheel support to only
move the cursor if we're in the edit window or on the statusbar. move the cursor if we're in the edit window or on the statusbar.

View File

@ -1622,17 +1622,17 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *kbinput_len)
#ifndef DISABLE_MOUSE #ifndef DISABLE_MOUSE
/* Handle any mouse events that may have occurred. We currently handle /* Handle any mouse events that may have occurred. We currently handle
* releases of the first mouse button. If allow_shortcuts is TRUE, * releases/clicks of the first mouse button. If allow_shortcuts is
* releasing on a visible shortcut will put back the keystroke * TRUE, releasing/clicking on a visible shortcut will put back the
* associated with that shortcut. If NCURSES_MOUSE_VERSION is at least * keystroke associated with that shortcut. If NCURSES_MOUSE_VERSION is
* 2, we also currently handle presses of the fourth mouse button * at least 2, we also currently handle presses of the fourth mouse
* (upward rolls of the mouse wheel) by putting back the keystrokes to * button (upward rolls of the mouse wheel) by putting back the
* move up, and presses of the fifth mouse button (downward rolls of the * keystrokes to move up, and presses of the fifth mouse button
* mouse wheel) by putting back the keystrokes to move down. Return -1 * (downward rolls of the mouse wheel) by putting back the keystrokes to
* on error, 0 if the mouse event needs to be handled, 1 if it's been * move down. Return -1 on error, 0 if the mouse event needs to be
* handled by putting back keystrokes that need to be handled. or 2 if * handled, 1 if it's been handled by putting back keystrokes that need
* the mouse event is ignored. Assume that KEY_MOUSE has already been * to be handled. or 2 if it's been ignored. Assume that KEY_MOUSE has
* read in. */ * already been read in. */
int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts) int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
{ {
MEVENT mevent; MEVENT mevent;
@ -1648,13 +1648,13 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
*mouse_x = mevent.x; *mouse_x = mevent.x;
*mouse_y = mevent.y; *mouse_y = mevent.y;
/* Handle releases of the first mouse button. */ /* Handle clicks/releases of the first mouse button. */
if (mevent.bstate & BUTTON1_RELEASED) { if (mevent.bstate & (BUTTON1_RELEASED | BUTTON1_CLICKED)) {
/* If we're allowing shortcuts, the current shortcut list is /* If we're allowing shortcuts, the current shortcut list is
* being displayed on the last two lines of the screen, and the * being displayed on the last two lines of the screen, and the
* first mouse button was pressed inside it, we need to figure * first mouse button was released on/clicked inside it, we need
* out which shortcut was clicked and put back the equivalent * to figure out which shortcut was released on/clicked and put
* keystroke(s) for it. */ * back the equivalent keystroke(s) for it. */
if (allow_shortcuts && !ISSET(NO_HELP) && if (allow_shortcuts && !ISSET(NO_HELP) &&
wmouse_trafo(bottomwin, mouse_y, mouse_x, FALSE)) { wmouse_trafo(bottomwin, mouse_y, mouse_x, FALSE)) {
int i; int i;
@ -1670,7 +1670,7 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
/* The actual shortcut we released on, starting at the /* The actual shortcut we released on, starting at the
* first one in the current shortcut list. */ * first one in the current shortcut list. */
/* Ignore releases of the first mouse button on the /* Ignore releases/clicks of the first mouse button on the
* statusbar. */ * statusbar. */
if (*mouse_y == 0) if (*mouse_y == 0)
return 2; return 2;
@ -1702,20 +1702,20 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
/* Calculate the x-coordinate relative to the beginning of /* Calculate the x-coordinate relative to the beginning of
* the shortcut list in bottomwin, and add it to j. j * the shortcut list in bottomwin, and add it to j. j
* should now be the index in the shortcut list of the * should now be the index in the shortcut list of the
* shortcut we released on. */ * shortcut we released/clicked on. */
j = (*mouse_x / i) * 2 + j; j = (*mouse_x / i) * 2 + j;
/* Adjust j if we released on the last two shortcuts. */ /* Adjust j if we released on the last two shortcuts. */
if ((j >= currslen) && (*mouse_x % i < COLS % i)) if ((j >= currslen) && (*mouse_x % i < COLS % i))
j -= 2; j -= 2;
/* Ignore releases of the first mouse button beyond the last /* Ignore releases/clicks of the first mouse button beyond
* shortcut. */ * the last shortcut. */
if (j >= currslen) if (j >= currslen)
return 2; return 2;
/* Go through the shortcut list to determine which shortcut /* Go through the shortcut list to determine which shortcut
* we released on. */ * we released/clicked on. */
s = currshortcut; s = currshortcut;
for (; j > 0; j--) for (; j > 0; j--)
@ -1732,8 +1732,8 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
return 1; return 1;
} }
} else } else
/* Handle releases of the first mouse button that aren't on /* Handle releases/clicks of the first mouse button that
* the current shortcut list elsewhere. */ * aren't on the current shortcut list elsewhere. */
return 0; return 0;
} }
#if NCURSES_MOUSE_VERSION >= 2 #if NCURSES_MOUSE_VERSION >= 2