aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/w32inevt.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/w32inevt.c b/src/w32inevt.c
index 1b2b6624314..99e3ead3ae3 100644
--- a/src/w32inevt.c
+++ b/src/w32inevt.c
@@ -550,9 +550,10 @@ mouse_moved_to (int x, int y)
550 Right == 2 550 Right == 2
551 Others increase from there. */ 551 Others increase from there. */
552 552
553static int emacs_button_translation[NUM_MOUSE_BUTTONS] = 553#define NUM_TRANSLATED_MOUSE_BUTTONS 3
554static int emacs_button_translation[NUM_TRANSLATED_MOUSE_BUTTONS] =
554{ 555{
555 0, 2, 1, 3, 4, 556 0, 2, 1
556}; 557};
557 558
558static int 559static int
@@ -581,18 +582,16 @@ do_mouse_event (MOUSE_EVENT_RECORD *event,
581 /* Find out what button has changed state since the last button event. */ 582 /* Find out what button has changed state since the last button event. */
582 but_change = button_state ^ event->dwButtonState; 583 but_change = button_state ^ event->dwButtonState;
583 mask = 1; 584 mask = 1;
584 for (i = 0; i < NUM_MOUSE_BUTTONS; i++, mask <<= 1) 585 for (i = 0; mask; i++, mask <<= 1)
585 if (but_change & mask) 586 if (but_change & mask)
586 { 587 {
587 XSETINT (emacs_ev->code, emacs_button_translation[i]); 588 if (i < NUM_TRANSLATED_MOUSE_BUTTONS)
589 XSETINT (emacs_ev->code, emacs_button_translation[i]);
590 else
591 XSETINT (emacs_ev->code, i);
588 break; 592 break;
589 } 593 }
590 594
591 /* If the changed button is out of emacs' range (highly unlikely)
592 ignore this event. */
593 if (i == NUM_MOUSE_BUTTONS)
594 return 0;
595
596 button_state = event->dwButtonState; 595 button_state = event->dwButtonState;
597 emacs_ev->timestamp = GetTickCount (); 596 emacs_ev->timestamp = GetTickCount ();
598 emacs_ev->modifiers = w32_kbd_mods_to_emacs (event->dwControlKeyState, 0) | 597 emacs_ev->modifiers = w32_kbd_mods_to_emacs (event->dwControlKeyState, 0) |