summaryrefslogtreecommitdiff
path: root/src/keyboard.c
diff options
context:
space:
mode:
authorGeoff Voelker <voelker@cs.washington.edu>1997-09-03 00:31:17 +0000
committerGeoff Voelker <voelker@cs.washington.edu>1997-09-03 00:31:17 +0000
commit8bb2a692bbcbb8a2152b42c4a127387a28658609 (patch)
tree6f872cc4844aba951c78414c2cab04aa49158b7d /src/keyboard.c
parent1a176a3acd2bcd50013eed6c8c4cddf026b3fdaf (diff)
downloademacs-8bb2a692bbcbb8a2152b42c4a127387a28658609.tar.gz
(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/keyboard.c')
-rw-r--r--src/keyboard.c121
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;
/* Symbols to denote kinds of events. */
Lisp_Object Qfunction_key;
Lisp_Object Qmouse_click;
+#ifdef WINDOWSNT
+Lisp_Object Qmouse_wheel;
+#endif
/* Lisp_Object Qmouse_movement; - also an event header */
/* Properties of event headers. */
@@ -2629,6 +2632,28 @@ kbd_buffer_store_event (event)
}
}
+/* Discard any mouse events in the event buffer by setting them to
+ no_event. */
+void
+discard_mouse_events ()
+{
+ struct input_event *sp;
+ for (sp = kbd_fetch_ptr; sp != kbd_store_ptr; sp++)
+ {
+ if (sp == kbd_buffer + KBD_BUFFER_SIZE)
+ sp = kbd_buffer;
+
+ if (sp->kind == mouse_click
+#ifdef WINDOWSNT
+ || sp->kind == w32_scroll_bar_click
+#endif
+ || sp->kind == scroll_bar_click)
+ {
+ sp->kind = no_event;
+ }
+ }
+}
+
/* Read one event from the event buffer, waiting if necessary.
The value is a Lisp object representing the event.
The value is nil for an event that should be ignored,
@@ -2795,7 +2820,7 @@ kbd_buffer_get_event (kbp, used_mouse_menu)
XSETBUFFER (obj, current_buffer);
kbd_fetch_ptr = event + 1;
}
-#ifdef USE_X_TOOLKIT
+#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
else if (event->kind == menu_bar_activate_event)
{
kbd_fetch_ptr = event + 1;
@@ -2810,6 +2835,8 @@ kbd_buffer_get_event (kbp, used_mouse_menu)
(They shouldn't otherwise be found in the buffer,
but on some machines it appears they do show up
even without MULTI_KBOARD.) */
+ /* On Windows NT/9X, no_event is used to delete extraneous
+ mouse events during a popup-menu call. */
else if (event->kind == no_event)
kbd_fetch_ptr = event + 1;
@@ -3220,6 +3247,9 @@ timer_check (do_it_now)
static Lisp_Object accent_key_syms;
static Lisp_Object func_key_syms;
static Lisp_Object mouse_syms;
+#ifdef WINDOWSNT
+static Lisp_Object mouse_wheel_syms;
+#endif
/* This is a list of keysym codes for special "accent" characters.
It parallels lispy_accent_keys. */
@@ -3639,6 +3669,20 @@ static char *lispy_mouse_names[] =
"mouse-1", "mouse-2", "mouse-3", "mouse-4", "mouse-5"
};
+#ifdef WINDOWSNT
+/* mouse-wheel events are generated by the wheel on devices such as
+ the MS Intellimouse. The wheel sits in between the left and right
+ mouse buttons, and is typically used to scroll or zoom the window
+ underneath the pointer. mouse-wheel events specify the object on
+ which they operate, and a delta corresponding to the amount and
+ direction that the wheel is rotated. Clicking the mouse-wheel
+ generates a mouse-2 event. */
+static char *lispy_mouse_wheel_names[] =
+{
+ "mouse-wheel"
+};
+#endif /* WINDOWSNT */
+
/* Scroll bar parts. */
Lisp_Object Qabove_handle, Qhandle, Qbelow_handle;
Lisp_Object Qup, Qdown;
@@ -4069,8 +4113,68 @@ make_lispy_event (event)
Qnil));
}
}
-#endif
+ case mouse_wheel:
+ {
+ int part;
+ FRAME_PTR f = XFRAME (event->frame_or_window);
+ Lisp_Object window;
+ Lisp_Object posn;
+ Lisp_Object head, position;
+ int row, column;
+
+ /* Ignore mouse events that were made on frame that
+ have been deleted. */
+ if (! FRAME_LIVE_P (f))
+ return Qnil;
+ pixel_to_glyph_coords (f, XINT (event->x), XINT (event->y),
+ &column, &row, NULL, 1);
+ window = window_from_coordinates (f, column, row, &part);
+
+ if (!WINDOWP (window))
+ {
+ window = event->frame_or_window;
+ posn = Qnil;
+ }
+ else
+ {
+ int pixcolumn, pixrow;
+ column -= XINT (XWINDOW (window)->left);
+ row -= XINT (XWINDOW (window)->top);
+ glyph_to_pixel_coords (f, column, row, &pixcolumn, &pixrow);
+ XSETINT (event->x, pixcolumn);
+ XSETINT (event->y, pixrow);
+
+ if (part == 1)
+ posn = Qmode_line;
+ else if (part == 2)
+ posn = Qvertical_line;
+ else
+ XSETINT (posn,
+ buffer_posn_from_coords (XWINDOW (window),
+ column, row));
+ }
+ {
+ Lisp_Object head, position;
+
+ position
+ = Fcons (window,
+ Fcons (posn,
+ Fcons (Fcons (event->x, event->y),
+ Fcons (make_number (event->timestamp),
+ Qnil))));
+
+ head = modify_event_symbol (0, event->modifiers,
+ Qmouse_wheel, Qnil,
+ lispy_mouse_wheel_names,
+ &mouse_wheel_syms, 1);
+ return Fcons (head,
+ Fcons (position,
+ Fcons (make_number (event->code),
+ Qnil)));
+ }
+ }
+#endif /* WINDOWSNT */
#endif /* HAVE_MOUSE */
#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
@@ -7704,7 +7808,7 @@ See also `current-input-mode'.")
stop_polling ();
#endif
-#ifndef MSDOS
+#ifndef DOS_NT
/* this causes startup screen to be restored and messes with the mouse */
reset_sys_modes ();
#endif
@@ -7743,7 +7847,7 @@ See also `current-input-mode'.")
/* Don't let this value be out of range. */
quit_char = XINT (quit) & (meta_key ? 0377 : 0177);
-#ifndef MSDOS
+#ifndef DOS_NT
init_sys_modes ();
#endif
@@ -7970,6 +8074,10 @@ syms_of_keyboard ()
staticpro (&Qfunction_key);
Qmouse_click = intern ("mouse-click");
staticpro (&Qmouse_click);
+#ifdef WINDOWSNT
+ Qmouse_wheel = intern ("mouse-wheel");
+ staticpro (&Qmouse_wheel);
+#endif
Qmenu_enable = intern ("menu-enable");
staticpro (&Qmenu_enable);
@@ -8062,6 +8170,11 @@ syms_of_keyboard ()
mouse_syms = Qnil;
staticpro (&mouse_syms);
+#ifdef WINDOWSNT
+ mouse_wheel_syms = Qnil;
+ staticpro (&mouse_wheel_syms);
+#endif
+
unread_switch_frame = Qnil;
staticpro (&unread_switch_frame);