comparison src/keyboard.c @ 36663:604d7fae62d1

(make_lispy_event): Avoid generating drag events if the mouse hasn't actually moved to another buffer position.
author Gerd Moellmann <gerd@gnu.org>
date Thu, 08 Mar 2001 14:01:24 +0000
parents 1890bad59762
children e976eee4983f
comparison
equal deleted inserted replaced
36662:b996b63f5b3b 36663:604d7fae62d1
4709 item = Qnil; 4709 item = Qnil;
4710 items = FRAME_MENU_BAR_ITEMS (f); 4710 items = FRAME_MENU_BAR_ITEMS (f);
4711 for (i = 0; i < XVECTOR (items)->size; i += 4) 4711 for (i = 0; i < XVECTOR (items)->size; i += 4)
4712 { 4712 {
4713 Lisp_Object pos, string; 4713 Lisp_Object pos, string;
4714 string = XVECTOR (items)->contents[i + 1]; 4714 string = AREF (items, i + 1);
4715 pos = XVECTOR (items)->contents[i + 3]; 4715 pos = AREF (items, i + 3);
4716 if (NILP (string)) 4716 if (NILP (string))
4717 break; 4717 break;
4718 if (column >= XINT (pos) 4718 if (column >= XINT (pos)
4719 && column < XINT (pos) + XSTRING (string)->size) 4719 && column < XINT (pos) + XSTRING (string)->size)
4720 { 4720 {
4721 item = XVECTOR (items)->contents[i]; 4721 item = AREF (items, i);
4722 break; 4722 break;
4723 } 4723 }
4724 } 4724 }
4725 4725
4726 /* ELisp manual 2.4b says (x y) are window relative but 4726 /* ELisp manual 2.4b says (x y) are window relative but
4808 Fcons (make_number (event->timestamp), 4808 Fcons (make_number (event->timestamp),
4809 Fcons (part, Qnil))))); 4809 Fcons (part, Qnil)))));
4810 } 4810 }
4811 #endif /* not USE_TOOLKIT_SCROLL_BARS */ 4811 #endif /* not USE_TOOLKIT_SCROLL_BARS */
4812 4812
4813 if (button >= XVECTOR (button_down_location)->size) 4813 if (button >= ASIZE (button_down_location))
4814 { 4814 {
4815 button_down_location = larger_vector (button_down_location, 4815 button_down_location = larger_vector (button_down_location,
4816 button + 1, Qnil); 4816 button + 1, Qnil);
4817 mouse_syms = larger_vector (mouse_syms, button + 1, Qnil); 4817 mouse_syms = larger_vector (mouse_syms, button + 1, Qnil);
4818 } 4818 }
4819 4819
4820 start_pos_ptr = &XVECTOR (button_down_location)->contents[button]; 4820 start_pos_ptr = &AREF (button_down_location, button);
4821
4822 start_pos = *start_pos_ptr; 4821 start_pos = *start_pos_ptr;
4823 *start_pos_ptr = Qnil; 4822 *start_pos_ptr = Qnil;
4824 4823
4825 is_double = (button == last_mouse_button 4824 is_double = (button == last_mouse_button
4826 && XINT (event->x) == last_mouse_x 4825 && XINT (event->x) == last_mouse_x
4853 4852
4854 /* Now we're releasing a button - check the co-ordinates to 4853 /* Now we're releasing a button - check the co-ordinates to
4855 see if this was a click or a drag. */ 4854 see if this was a click or a drag. */
4856 else if (event->modifiers & up_modifier) 4855 else if (event->modifiers & up_modifier)
4857 { 4856 {
4858 /* If we did not see a down before this up, 4857 /* If we did not see a down before this up, ignore the up.
4859 ignore the up. Probably this happened because 4858 Probably this happened because the down event chose a
4860 the down event chose a menu item. 4859 menu item. It would be an annoyance to treat the
4861 It would be an annoyance to treat the release 4860 release of the button that chose the menu item as a
4862 of the button that chose the menu item 4861 separate event. */
4863 as a separate event. */
4864 4862
4865 if (!CONSP (start_pos)) 4863 if (!CONSP (start_pos))
4866 return Qnil; 4864 return Qnil;
4867 4865
4868 event->modifiers &= ~up_modifier; 4866 event->modifiers &= ~up_modifier;
4875 /* The third element of every position should be the (x,y) 4873 /* The third element of every position should be the (x,y)
4876 pair. */ 4874 pair. */
4877 Lisp_Object down; 4875 Lisp_Object down;
4878 4876
4879 down = Fnth (make_number (2), start_pos); 4877 down = Fnth (make_number (2), start_pos);
4880 if (EQ (event->x, XCAR (down)) 4878 if (EQ (event->x, XCAR (down)) && EQ (event->y, XCDR (down)))
4881 && EQ (event->y, XCDR (down))) 4879 /* Mouse hasn't moved. */
4882 { 4880 event->modifiers |= click_modifier;
4883 event->modifiers |= click_modifier;
4884 }
4885 else 4881 else
4886 { 4882 {
4887 button_down_time = 0; 4883 Lisp_Object window1, window2, posn1, posn2;
4888 event->modifiers |= drag_modifier; 4884
4885 /* Avoid generating a drag event if the mouse
4886 hasn't actually moved off the buffer position. */
4887 window1 = Fnth (make_number (0), position);
4888 posn1 = Fnth (make_number (1), position);
4889 window2 = Fnth (make_number (0), start_pos);
4890 posn2 = Fnth (make_number (1), start_pos);
4891
4892 if (EQ (window1, window2) && EQ (posn1, posn2))
4893 event->modifiers |= click_modifier;
4894 else
4895 {
4896 button_down_time = 0;
4897 event->modifiers |= drag_modifier;
4898 }
4889 } 4899 }
4900
4890 /* Don't check is_double; treat this as multiple 4901 /* Don't check is_double; treat this as multiple
4891 if the down-event was multiple. */ 4902 if the down-event was multiple. */
4892 if (double_click_count > 1) 4903 if (double_click_count > 1)
4893 event->modifiers |= ((double_click_count > 2) 4904 event->modifiers |= ((double_click_count > 2)
4894 ? triple_modifier 4905 ? triple_modifier