/[emacs]/emacs/src/keyboard.c
ViewVC logotype

Diff of /emacs/src/keyboard.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.747 by lektu, Mon May 26 22:55:45 2003 UTC revision 1.748 by jasonr, Sun Jun 1 21:40:38 2003 UTC
# Line 547  Lisp_Object Qhelp_echo; Line 547  Lisp_Object Qhelp_echo;
547  /* Symbols to denote kinds of events.  */  /* Symbols to denote kinds of events.  */
548  Lisp_Object Qfunction_key;  Lisp_Object Qfunction_key;
549  Lisp_Object Qmouse_click;  Lisp_Object Qmouse_click;
550  #if defined(WINDOWSNT) || defined(MAC_OSX)  #if defined(MAC_OSX)
551  Lisp_Object Qmouse_wheel;  Lisp_Object Qmouse_wheel;
552  #endif  #endif
553  #ifdef WINDOWSNT  #ifdef WINDOWSNT
# Line 3737  discard_mouse_events () Line 3737  discard_mouse_events ()
3737          sp = kbd_buffer;          sp = kbd_buffer;
3738    
3739        if (sp->kind == MOUSE_CLICK_EVENT        if (sp->kind == MOUSE_CLICK_EVENT
3740              || sp->kind == WHEEL_EVENT
3741  #ifdef WINDOWSNT  #ifdef WINDOWSNT
3742            || sp->kind == W32_SCROLL_BAR_CLICK_EVENT            || sp->kind == W32_SCROLL_BAR_CLICK_EVENT
3743  #endif  #endif
# Line 4436  timer_check (do_it_now) Line 4437  timer_check (do_it_now)
4437  static Lisp_Object accent_key_syms;  static Lisp_Object accent_key_syms;
4438  static Lisp_Object func_key_syms;  static Lisp_Object func_key_syms;
4439  static Lisp_Object mouse_syms;  static Lisp_Object mouse_syms;
4440  #if defined(WINDOWSNT) || defined(MAC_OSX)  static Lisp_Object wheel_syms;
4441    #if defined(MAC_OSX)
4442  static Lisp_Object mouse_wheel_syms;  static Lisp_Object mouse_wheel_syms;
4443  #endif  #endif
4444  static Lisp_Object drag_n_drop_syms;  static Lisp_Object drag_n_drop_syms;
# Line 4892  static char *iso_lispy_function_keys[] = Line 4894  static char *iso_lispy_function_keys[] =
4894    
4895  Lisp_Object Vlispy_mouse_stem;  Lisp_Object Vlispy_mouse_stem;
4896    
4897  #if defined(WINDOWSNT) || defined(MAC_OSX)  static char *lispy_wheel_names[] =
4898    {
4899      "wheel-up", "wheel-down"
4900    };
4901    
4902    #if defined(MAC_OSX)
4903  /* mouse-wheel events are generated by the wheel on devices such as  /* mouse-wheel events are generated by the wheel on devices such as
4904     the MS Intellimouse.  The wheel sits in between the left and right     the MS Intellimouse.  The wheel sits in between the left and right
4905     mouse buttons, and is typically used to scroll or zoom the window     mouse buttons, and is typically used to scroll or zoom the window
# Line 4905  static char *lispy_mouse_wheel_names[] = Line 4912  static char *lispy_mouse_wheel_names[] =
4912    "mouse-wheel"    "mouse-wheel"
4913  };  };
4914    
4915  #endif /* WINDOWSNT */  #endif /* MAC_OSX */
4916    
4917  /* drag-n-drop events are generated when a set of selected files are  /* drag-n-drop events are generated when a set of selected files are
4918     dragged from another application and dropped onto an Emacs window.  */     dragged from another application and dropped onto an Emacs window.  */
# Line 5416  make_lispy_event (event) Line 5423  make_lispy_event (event)
5423          }          }
5424        }        }
5425    
5426        case WHEEL_EVENT:
5427          {
5428            Lisp_Object position;
5429            Lisp_Object window;
5430            Lisp_Object head;
5431            
5432            position = Qnil;
5433            /* Build the position as appropriate for this mouse click.  */
5434            enum window_part part;
5435            struct frame *f = XFRAME (event->frame_or_window);
5436            Lisp_Object posn;
5437            Lisp_Object string_info = Qnil;
5438            int row, column;
5439            int wx, wy;
5440    
5441            /* Ignore wheel events that were made on frame that have been
5442               deleted.  */
5443            if (! FRAME_LIVE_P (f))
5444              return Qnil;
5445            
5446            /* EVENT->x and EVENT->y are frame-relative pixel
5447               coordinates at this place.  Under old redisplay, COLUMN
5448               and ROW are set to frame relative glyph coordinates
5449               which are then used to determine whether this click is
5450               in a menu (non-toolkit version).  */
5451            pixel_to_glyph_coords (f, XINT (event->x), XINT (event->y),
5452                                   &column, &row, NULL, 1);
5453    
5454            /* Set `window' to the window under frame pixel coordinates
5455               event->x/event->y.  */
5456            window = window_from_coordinates (f, XINT (event->x),
5457                                              XINT (event->y),
5458                                              &part, &wx, &wy, 0);
5459    
5460            if (!WINDOWP (window))
5461              {
5462                window = event->frame_or_window;
5463                posn = Qnil;
5464              }
5465            else
5466              {
5467                /* It's a click in window window at frame coordinates
5468                   event->x/ event->y.  */
5469                struct window *w = XWINDOW (window);
5470            
5471                /* Set event coordinates to window-relative coordinates
5472                   for constructing the Lisp event below.  */
5473                XSETINT (event->x, wx);
5474                XSETINT (event->y, wy);
5475            
5476                if (part == ON_MODE_LINE || part == ON_HEADER_LINE)
5477                  {
5478                    /* Mode line or header line.  Look for a string under
5479                       the mouse that may have a `local-map' property.  */
5480                    Lisp_Object string;
5481                    int charpos;
5482                    
5483                    posn = part == ON_MODE_LINE ? Qmode_line : Qheader_line;
5484                    string = mode_line_string (w, wx, wy, part, &charpos);
5485                    if (STRINGP (string))
5486                      string_info = Fcons (string, make_number (charpos));
5487                  }
5488                else if (part == ON_VERTICAL_BORDER)
5489                  posn = Qvertical_line;
5490                else if (part == ON_LEFT_MARGIN || part == ON_RIGHT_MARGIN)
5491                  {
5492                    int charpos;
5493                    Lisp_Object object = marginal_area_string (w, wx, wy, part,
5494                                                               &charpos);
5495                    posn = (part == ON_LEFT_MARGIN) ? Qleft_margin : Qright_margin;
5496                    if (STRINGP (object))
5497                      string_info = Fcons (object, make_number (charpos));
5498                  }
5499                else
5500                  {
5501                    Lisp_Object object;
5502                    struct display_pos p;
5503                    buffer_posn_from_coords (w, &wx, &wy, &object, &p);
5504                    posn = make_number (CHARPOS (p.pos));
5505                    if (STRINGP (object))
5506                      string_info
5507                        = Fcons (object,
5508                                 make_number (CHARPOS (p.string_pos)));
5509                  }
5510              }
5511            
5512            position
5513              = Fcons (window,
5514                       Fcons (posn,
5515                              Fcons (Fcons (event->x, event->y),
5516                                     Fcons (make_number (event->timestamp),
5517                                            (NILP (string_info)
5518                                             ? Qnil
5519                                             : Fcons (string_info, Qnil))))));
5520    
5521            /* Set double or triple modifiers to indicate the wheel speed.  */
5522            {
5523              /* On window-system frames, use the value of
5524                 double-click-fuzz as is.  On other frames, interpret it
5525                 as a multiple of 1/8 characters.  */
5526              struct frame *f;
5527              int fuzz;
5528              int is_double;
5529    
5530              if (WINDOWP (event->frame_or_window))
5531                f = XFRAME (XWINDOW (event->frame_or_window)->frame);
5532              else if (FRAMEP (event->frame_or_window))
5533                f = XFRAME (event->frame_or_window);
5534              else
5535                abort ();
5536    
5537              if (FRAME_WINDOW_P (f))
5538                fuzz = double_click_fuzz;
5539              else
5540                fuzz = double_click_fuzz / 8;
5541    
5542              is_double = (last_mouse_button < 0
5543                           && (abs (XINT (event->x) - last_mouse_x) <= fuzz)
5544                           && (abs (XINT (event->y) - last_mouse_y) <= fuzz)
5545                           && button_down_time != 0
5546                           && (EQ (Vdouble_click_time, Qt)
5547                               || (INTEGERP (Vdouble_click_time)
5548                                   && ((int)(event->timestamp - button_down_time)
5549                                       < XINT (Vdouble_click_time)))));
5550              if (is_double)
5551                {
5552                  double_click_count++;
5553                  event->modifiers |= ((double_click_count > 2)
5554                                       ? triple_modifier
5555                                       : double_modifier);
5556                }
5557              else
5558                {
5559                  double_click_count = 1;
5560                  event->modifiers |= click_modifier;
5561                }
5562            
5563              button_down_time = event->timestamp;
5564              /* Use a negative value to distinguish wheel from mouse button.  */
5565              last_mouse_button = -1;
5566              last_mouse_x = XINT (event->x);
5567              last_mouse_y = XINT (event->y);
5568            }
5569            
5570            {
5571              int symbol_num;
5572            
5573              if (event->modifiers & up_modifier)
5574                {
5575                  /* Emit a wheel-up event.  */
5576                  event->modifiers &= ~up_modifier;
5577                  symbol_num = 0;
5578                }
5579              else if (event->modifiers & down_modifier)
5580                {
5581                  /* Emit a wheel-down event.  */
5582                  event->modifiers &= ~down_modifier;
5583                  symbol_num = 1;
5584                }
5585              else
5586                /* Every wheel event should either have the down_modifier or
5587                   the up_modifier set.  */
5588                abort ();
5589            
5590              /* Get the symbol we should use for the wheel event.  */
5591              head = modify_event_symbol (symbol_num,
5592                                          event->modifiers,
5593                                          Qmouse_click,
5594                                          Qnil,
5595                                          lispy_wheel_names,
5596                                          &wheel_syms,
5597                                          ASIZE (wheel_syms));
5598            }
5599            
5600            if (event->modifiers & (double_modifier | triple_modifier))
5601              return Fcons (head,
5602                            Fcons (position,
5603                                   Fcons (make_number (double_click_count),
5604                                          Qnil)));
5605            else
5606              return Fcons (head,
5607                            Fcons (position,
5608                                   Qnil));
5609          }
5610    
5611    
5612  #ifdef USE_TOOLKIT_SCROLL_BARS  #ifdef USE_TOOLKIT_SCROLL_BARS
5613    
5614        /* We don't have down and up events if using toolkit scroll bars,        /* We don't have down and up events if using toolkit scroll bars,
# Line 10675  syms_of_keyboard () Line 10868  syms_of_keyboard ()
10868    staticpro (&Qfunction_key);    staticpro (&Qfunction_key);
10869    Qmouse_click = intern ("mouse-click");    Qmouse_click = intern ("mouse-click");
10870    staticpro (&Qmouse_click);    staticpro (&Qmouse_click);
10871  #if defined(WINDOWSNT) || defined(MAC_OSX)  #if defined(MAC_OSX)
10872    Qmouse_wheel = intern ("mouse-wheel");    Qmouse_wheel = intern ("mouse-wheel");
10873    staticpro (&Qmouse_wheel);    staticpro (&Qmouse_wheel);
10874  #endif  #endif
# Line 10793  syms_of_keyboard () Line 10986  syms_of_keyboard ()
10986    staticpro (&button_down_location);    staticpro (&button_down_location);
10987    mouse_syms = Fmake_vector (make_number (1), Qnil);    mouse_syms = Fmake_vector (make_number (1), Qnil);
10988    staticpro (&mouse_syms);    staticpro (&mouse_syms);
10989      wheel_syms = Fmake_vector (make_number (2), Qnil);
10990      staticpro (&wheel_syms);
10991    
10992    {    {
10993      int i;      int i;
# Line 10827  syms_of_keyboard () Line 11022  syms_of_keyboard ()
11022    func_key_syms = Qnil;    func_key_syms = Qnil;
11023    staticpro (&func_key_syms);    staticpro (&func_key_syms);
11024    
11025  #if defined(WINDOWSNT) || defined(MAC_OSX)  #if defined(MAC_OSX)
11026    mouse_wheel_syms = Qnil;    mouse_wheel_syms = Qnil;
11027    staticpro (&mouse_wheel_syms);    staticpro (&mouse_wheel_syms);
11028    drag_n_drop_syms = Qnil;    drag_n_drop_syms = Qnil;

Legend:
Removed from v.1.747  
changed lines
  Added in v.1.748

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26