diff options
| author | Geoff Voelker | 1997-09-03 00:31:17 +0000 |
|---|---|---|
| committer | Geoff Voelker | 1997-09-03 00:31:17 +0000 |
| commit | 07de30b9dee8067af7b250923610affc625a8853 (patch) | |
| tree | dad99c86900da6152731a5ac1f8cab9730273a67 /src | |
| parent | 0969b893b01477765bf5589f8695b52805506bb1 (diff) | |
| download | emacs-07de30b9dee8067af7b250923610affc625a8853.tar.gz emacs-07de30b9dee8067af7b250923610affc625a8853.zip | |
(kbd_buffer_get_event) [WINDOWSNT]: Support
menu_bar_activate_event.
(set-input-mode) [DOS_NT]: Do not invoke reset and init sys modes.
(Qmouse_wheel) [WINDOWSNT]: New variable.
(discard_mouse_events): New function.
(mouse_wheel_syms) [WINDOWSNT]: New variable.
(lispy_mouse_wheel_names) [WINDOWSNT]: New variable.
(make_lispy_event) [WINDOWSNT]: Make mouse-wheel events.
(syms_of_keyboard) [WINDOWSNT]: Define Qmouse_wheel and
mouse_wheel_syms.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keyboard.c | 121 |
1 files changed, 117 insertions, 4 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index 1d0e36964ae..4c872016eb5 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -444,6 +444,9 @@ Lisp_Object Qmake_frame_visible; | |||
| 444 | /* Symbols to denote kinds of events. */ | 444 | /* Symbols to denote kinds of events. */ |
| 445 | Lisp_Object Qfunction_key; | 445 | Lisp_Object Qfunction_key; |
| 446 | Lisp_Object Qmouse_click; | 446 | Lisp_Object Qmouse_click; |
| 447 | #ifdef WINDOWSNT | ||
| 448 | Lisp_Object Qmouse_wheel; | ||
| 449 | #endif | ||
| 447 | /* Lisp_Object Qmouse_movement; - also an event header */ | 450 | /* Lisp_Object Qmouse_movement; - also an event header */ |
| 448 | 451 | ||
| 449 | /* Properties of event headers. */ | 452 | /* Properties of event headers. */ |
| @@ -2629,6 +2632,28 @@ kbd_buffer_store_event (event) | |||
| 2629 | } | 2632 | } |
| 2630 | } | 2633 | } |
| 2631 | 2634 | ||
| 2635 | /* Discard any mouse events in the event buffer by setting them to | ||
| 2636 | no_event. */ | ||
| 2637 | void | ||
| 2638 | discard_mouse_events () | ||
| 2639 | { | ||
| 2640 | struct input_event *sp; | ||
| 2641 | for (sp = kbd_fetch_ptr; sp != kbd_store_ptr; sp++) | ||
| 2642 | { | ||
| 2643 | if (sp == kbd_buffer + KBD_BUFFER_SIZE) | ||
| 2644 | sp = kbd_buffer; | ||
| 2645 | |||
| 2646 | if (sp->kind == mouse_click | ||
| 2647 | #ifdef WINDOWSNT | ||
| 2648 | || sp->kind == w32_scroll_bar_click | ||
| 2649 | #endif | ||
| 2650 | || sp->kind == scroll_bar_click) | ||
| 2651 | { | ||
| 2652 | sp->kind = no_event; | ||
| 2653 | } | ||
| 2654 | } | ||
| 2655 | } | ||
| 2656 | |||
| 2632 | /* Read one event from the event buffer, waiting if necessary. | 2657 | /* Read one event from the event buffer, waiting if necessary. |
| 2633 | The value is a Lisp object representing the event. | 2658 | The value is a Lisp object representing the event. |
| 2634 | The value is nil for an event that should be ignored, | 2659 | The value is nil for an event that should be ignored, |
| @@ -2795,7 +2820,7 @@ kbd_buffer_get_event (kbp, used_mouse_menu) | |||
| 2795 | XSETBUFFER (obj, current_buffer); | 2820 | XSETBUFFER (obj, current_buffer); |
| 2796 | kbd_fetch_ptr = event + 1; | 2821 | kbd_fetch_ptr = event + 1; |
| 2797 | } | 2822 | } |
| 2798 | #ifdef USE_X_TOOLKIT | 2823 | #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) |
| 2799 | else if (event->kind == menu_bar_activate_event) | 2824 | else if (event->kind == menu_bar_activate_event) |
| 2800 | { | 2825 | { |
| 2801 | kbd_fetch_ptr = event + 1; | 2826 | kbd_fetch_ptr = event + 1; |
| @@ -2810,6 +2835,8 @@ kbd_buffer_get_event (kbp, used_mouse_menu) | |||
| 2810 | (They shouldn't otherwise be found in the buffer, | 2835 | (They shouldn't otherwise be found in the buffer, |
| 2811 | but on some machines it appears they do show up | 2836 | but on some machines it appears they do show up |
| 2812 | even without MULTI_KBOARD.) */ | 2837 | even without MULTI_KBOARD.) */ |
| 2838 | /* On Windows NT/9X, no_event is used to delete extraneous | ||
| 2839 | mouse events during a popup-menu call. */ | ||
| 2813 | else if (event->kind == no_event) | 2840 | else if (event->kind == no_event) |
| 2814 | kbd_fetch_ptr = event + 1; | 2841 | kbd_fetch_ptr = event + 1; |
| 2815 | 2842 | ||
| @@ -3220,6 +3247,9 @@ timer_check (do_it_now) | |||
| 3220 | static Lisp_Object accent_key_syms; | 3247 | static Lisp_Object accent_key_syms; |
| 3221 | static Lisp_Object func_key_syms; | 3248 | static Lisp_Object func_key_syms; |
| 3222 | static Lisp_Object mouse_syms; | 3249 | static Lisp_Object mouse_syms; |
| 3250 | #ifdef WINDOWSNT | ||
| 3251 | static Lisp_Object mouse_wheel_syms; | ||
| 3252 | #endif | ||
| 3223 | 3253 | ||
| 3224 | /* This is a list of keysym codes for special "accent" characters. | 3254 | /* This is a list of keysym codes for special "accent" characters. |
| 3225 | It parallels lispy_accent_keys. */ | 3255 | It parallels lispy_accent_keys. */ |
| @@ -3639,6 +3669,20 @@ static char *lispy_mouse_names[] = | |||
| 3639 | "mouse-1", "mouse-2", "mouse-3", "mouse-4", "mouse-5" | 3669 | "mouse-1", "mouse-2", "mouse-3", "mouse-4", "mouse-5" |
| 3640 | }; | 3670 | }; |
| 3641 | 3671 | ||
| 3672 | #ifdef WINDOWSNT | ||
| 3673 | /* mouse-wheel events are generated by the wheel on devices such as | ||
| 3674 | the MS Intellimouse. The wheel sits in between the left and right | ||
| 3675 | mouse buttons, and is typically used to scroll or zoom the window | ||
| 3676 | underneath the pointer. mouse-wheel events specify the object on | ||
| 3677 | which they operate, and a delta corresponding to the amount and | ||
| 3678 | direction that the wheel is rotated. Clicking the mouse-wheel | ||
| 3679 | generates a mouse-2 event. */ | ||
| 3680 | static char *lispy_mouse_wheel_names[] = | ||
| 3681 | { | ||
| 3682 | "mouse-wheel" | ||
| 3683 | }; | ||
| 3684 | #endif /* WINDOWSNT */ | ||
| 3685 | |||
| 3642 | /* Scroll bar parts. */ | 3686 | /* Scroll bar parts. */ |
| 3643 | Lisp_Object Qabove_handle, Qhandle, Qbelow_handle; | 3687 | Lisp_Object Qabove_handle, Qhandle, Qbelow_handle; |
| 3644 | Lisp_Object Qup, Qdown; | 3688 | Lisp_Object Qup, Qdown; |
| @@ -4069,8 +4113,68 @@ make_lispy_event (event) | |||
| 4069 | Qnil)); | 4113 | Qnil)); |
| 4070 | } | 4114 | } |
| 4071 | } | 4115 | } |
| 4072 | #endif | 4116 | case mouse_wheel: |
| 4117 | { | ||
| 4118 | int part; | ||
| 4119 | FRAME_PTR f = XFRAME (event->frame_or_window); | ||
| 4120 | Lisp_Object window; | ||
| 4121 | Lisp_Object posn; | ||
| 4122 | Lisp_Object head, position; | ||
| 4123 | int row, column; | ||
| 4124 | |||
| 4125 | /* Ignore mouse events that were made on frame that | ||
| 4126 | have been deleted. */ | ||
| 4127 | if (! FRAME_LIVE_P (f)) | ||
| 4128 | return Qnil; | ||
| 4129 | pixel_to_glyph_coords (f, XINT (event->x), XINT (event->y), | ||
| 4130 | &column, &row, NULL, 1); | ||
| 4131 | window = window_from_coordinates (f, column, row, &part); | ||
| 4132 | |||
| 4133 | if (!WINDOWP (window)) | ||
| 4134 | { | ||
| 4135 | window = event->frame_or_window; | ||
| 4136 | posn = Qnil; | ||
| 4137 | } | ||
| 4138 | else | ||
| 4139 | { | ||
| 4140 | int pixcolumn, pixrow; | ||
| 4141 | column -= XINT (XWINDOW (window)->left); | ||
| 4142 | row -= XINT (XWINDOW (window)->top); | ||
| 4143 | glyph_to_pixel_coords (f, column, row, &pixcolumn, &pixrow); | ||
| 4144 | XSETINT (event->x, pixcolumn); | ||
| 4145 | XSETINT (event->y, pixrow); | ||
| 4146 | |||
| 4147 | if (part == 1) | ||
| 4148 | posn = Qmode_line; | ||
| 4149 | else if (part == 2) | ||
| 4150 | posn = Qvertical_line; | ||
| 4151 | else | ||
| 4152 | XSETINT (posn, | ||
| 4153 | buffer_posn_from_coords (XWINDOW (window), | ||
| 4154 | column, row)); | ||
| 4155 | } | ||
| 4073 | 4156 | ||
| 4157 | { | ||
| 4158 | Lisp_Object head, position; | ||
| 4159 | |||
| 4160 | position | ||
| 4161 | = Fcons (window, | ||
| 4162 | Fcons (posn, | ||
| 4163 | Fcons (Fcons (event->x, event->y), | ||
| 4164 | Fcons (make_number (event->timestamp), | ||
| 4165 | Qnil)))); | ||
| 4166 | |||
| 4167 | head = modify_event_symbol (0, event->modifiers, | ||
| 4168 | Qmouse_wheel, Qnil, | ||
| 4169 | lispy_mouse_wheel_names, | ||
| 4170 | &mouse_wheel_syms, 1); | ||
| 4171 | return Fcons (head, | ||
| 4172 | Fcons (position, | ||
| 4173 | Fcons (make_number (event->code), | ||
| 4174 | Qnil))); | ||
| 4175 | } | ||
| 4176 | } | ||
| 4177 | #endif /* WINDOWSNT */ | ||
| 4074 | #endif /* HAVE_MOUSE */ | 4178 | #endif /* HAVE_MOUSE */ |
| 4075 | 4179 | ||
| 4076 | #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) | 4180 | #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) |
| @@ -7704,7 +7808,7 @@ See also `current-input-mode'.") | |||
| 7704 | stop_polling (); | 7808 | stop_polling (); |
| 7705 | #endif | 7809 | #endif |
| 7706 | 7810 | ||
| 7707 | #ifndef MSDOS | 7811 | #ifndef DOS_NT |
| 7708 | /* this causes startup screen to be restored and messes with the mouse */ | 7812 | /* this causes startup screen to be restored and messes with the mouse */ |
| 7709 | reset_sys_modes (); | 7813 | reset_sys_modes (); |
| 7710 | #endif | 7814 | #endif |
| @@ -7743,7 +7847,7 @@ See also `current-input-mode'.") | |||
| 7743 | /* Don't let this value be out of range. */ | 7847 | /* Don't let this value be out of range. */ |
| 7744 | quit_char = XINT (quit) & (meta_key ? 0377 : 0177); | 7848 | quit_char = XINT (quit) & (meta_key ? 0377 : 0177); |
| 7745 | 7849 | ||
| 7746 | #ifndef MSDOS | 7850 | #ifndef DOS_NT |
| 7747 | init_sys_modes (); | 7851 | init_sys_modes (); |
| 7748 | #endif | 7852 | #endif |
| 7749 | 7853 | ||
| @@ -7970,6 +8074,10 @@ syms_of_keyboard () | |||
| 7970 | staticpro (&Qfunction_key); | 8074 | staticpro (&Qfunction_key); |
| 7971 | Qmouse_click = intern ("mouse-click"); | 8075 | Qmouse_click = intern ("mouse-click"); |
| 7972 | staticpro (&Qmouse_click); | 8076 | staticpro (&Qmouse_click); |
| 8077 | #ifdef WINDOWSNT | ||
| 8078 | Qmouse_wheel = intern ("mouse-wheel"); | ||
| 8079 | staticpro (&Qmouse_wheel); | ||
| 8080 | #endif | ||
| 7973 | 8081 | ||
| 7974 | Qmenu_enable = intern ("menu-enable"); | 8082 | Qmenu_enable = intern ("menu-enable"); |
| 7975 | staticpro (&Qmenu_enable); | 8083 | staticpro (&Qmenu_enable); |
| @@ -8062,6 +8170,11 @@ syms_of_keyboard () | |||
| 8062 | mouse_syms = Qnil; | 8170 | mouse_syms = Qnil; |
| 8063 | staticpro (&mouse_syms); | 8171 | staticpro (&mouse_syms); |
| 8064 | 8172 | ||
| 8173 | #ifdef WINDOWSNT | ||
| 8174 | mouse_wheel_syms = Qnil; | ||
| 8175 | staticpro (&mouse_wheel_syms); | ||
| 8176 | #endif | ||
| 8177 | |||
| 8065 | unread_switch_frame = Qnil; | 8178 | unread_switch_frame = Qnil; |
| 8066 | staticpro (&unread_switch_frame); | 8179 | staticpro (&unread_switch_frame); |
| 8067 | 8180 | ||