]> git.eshelyaron.com Git - emacs.git/commitdiff
(make_lispy_event): Remember last wheel direction.
authorYAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
Sun, 27 Sep 2009 04:40:41 +0000 (04:40 +0000)
committerYAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
Sun, 27 Sep 2009 04:40:41 +0000 (04:40 +0000)
(syms_of_keyboard) <wheel_syms>: Compute array size at compile time.

src/ChangeLog
src/keyboard.c

index a5c152509484f655dcf2f66c576fae477d2f71d1..1f485031ed47f2aac3f45912dfeaebeea26b041c 100644 (file)
@@ -1,3 +1,8 @@
+2009-09-27  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+       * keyboard.c (make_lispy_event): Remember last wheel direction.
+       (syms_of_keyboard) <wheel_syms>: Compute array size at compile time.
+
 2009-09-26  Glenn Morris  <rgm@gnu.org>
 
        * Makefile.in (MSDOS_SUPPORT) [MSDOS]: Remove unneeded '/' in
index 35c338cc74c3708fd07512beaf74172780799dd7..396f22fa7a127917f59f5182eb7e9d45aa130d68 100644 (file)
@@ -5953,6 +5953,7 @@ make_lispy_event (event)
             as a multiple of 1/8 characters.  */
          struct frame *f;
          int fuzz;
+         int symbol_num;
          int is_double;
 
          if (WINDOWP (event->frame_or_window))
@@ -5967,7 +5968,27 @@ make_lispy_event (event)
          else
            fuzz = double_click_fuzz / 8;
 
-         is_double = (last_mouse_button < 0
+         if (event->modifiers & up_modifier)
+           {
+             /* Emit a wheel-up event.  */
+             event->modifiers &= ~up_modifier;
+             symbol_num = 0;
+           }
+         else if (event->modifiers & down_modifier)
+           {
+             /* Emit a wheel-down event.  */
+             event->modifiers &= ~down_modifier;
+             symbol_num = 1;
+           }
+         else
+           /* Every wheel event should either have the down_modifier or
+              the up_modifier set.  */
+           abort ();
+
+          if (event->kind == HORIZ_WHEEL_EVENT)
+            symbol_num += 2;
+
+         is_double = (last_mouse_button == - (1 + symbol_num)
                       && (eabs (XINT (event->x) - last_mouse_x) <= fuzz)
                       && (eabs (XINT (event->y) - last_mouse_y) <= fuzz)
                       && button_down_time != 0
@@ -5990,33 +6011,9 @@ make_lispy_event (event)
 
          button_down_time = event->timestamp;
          /* Use a negative value to distinguish wheel from mouse button.  */
-         last_mouse_button = -1;
+         last_mouse_button = - (1 + symbol_num);
          last_mouse_x = XINT (event->x);
          last_mouse_y = XINT (event->y);
-       }
-
-       {
-         int symbol_num;
-
-         if (event->modifiers & up_modifier)
-           {
-             /* Emit a wheel-up event.  */
-             event->modifiers &= ~up_modifier;
-             symbol_num = 0;
-           }
-         else if (event->modifiers & down_modifier)
-           {
-             /* Emit a wheel-down event.  */
-             event->modifiers &= ~down_modifier;
-             symbol_num = 1;
-           }
-         else
-           /* Every wheel event should either have the down_modifier or
-              the up_modifier set.  */
-           abort ();
-
-          if (event->kind == HORIZ_WHEEL_EVENT)
-            symbol_num += 2;
 
          /* Get the symbol we should use for the wheel event.  */
          head = modify_event_symbol (symbol_num,
@@ -11898,7 +11895,9 @@ syms_of_keyboard ()
   staticpro (&button_down_location);
   mouse_syms = Fmake_vector (make_number (5), Qnil);
   staticpro (&mouse_syms);
-  wheel_syms = Fmake_vector (make_number (4), Qnil);
+  wheel_syms = Fmake_vector (make_number (sizeof (lispy_wheel_names)
+                                         / sizeof (lispy_wheel_names[0])),
+                            Qnil);
   staticpro (&wheel_syms);
 
   {