summaryrefslogtreecommitdiff
path: root/src/keyboard.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/keyboard.c')
-rw-r--r--src/keyboard.c117
1 files changed, 100 insertions, 17 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index 5cedd0572b2..b096424a615 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -521,7 +521,7 @@ Lisp_Object Qmake_frame_visible;
Lisp_Object Qselect_window;
Lisp_Object Qhelp_echo;
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
Lisp_Object Qmouse_fixup_help_message;
#endif
@@ -677,7 +677,7 @@ static Lisp_Object read_char_x_menu_prompt ();
static Lisp_Object read_char_minibuf_menu_prompt P_ ((int, int,
Lisp_Object *));
static Lisp_Object make_lispy_event P_ ((struct input_event *));
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
static Lisp_Object make_lispy_movement P_ ((struct frame *, Lisp_Object,
enum scroll_bar_part,
Lisp_Object, Lisp_Object,
@@ -1249,7 +1249,7 @@ cmd_error_internal (data, context)
/* Use user's specified output function if any. */
if (!NILP (Vcommand_error_function))
call3 (Vcommand_error_function, data,
- build_string (context ? context : ""),
+ context ? build_string (context) : empty_unibyte_string,
Vsignaling_function);
/* If the window system or terminal frame hasn't been initialized
yet, or we're not interactive, write the message to stderr and exit. */
@@ -1390,7 +1390,7 @@ DEFUN ("abort-recursive-edit", Fabort_recursive_edit, Sabort_recursive_edit, 0,
return Qnil;
}
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
/* Restore mouse tracking enablement. See Ftrack_mouse for the only use
of this function. */
@@ -1466,7 +1466,7 @@ some_mouse_moved ()
return 0;
}
-#endif /* HAVE_MOUSE */
+#endif /* HAVE_MOUSE || HAVE_GPM */
/* This is the actual command reading loop,
sans error-handling encapsulation. */
@@ -2388,7 +2388,7 @@ show_help_echo (help, window, object, pos, ok_to_overwrite_keystroke_echo)
return;
}
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
if (!noninteractive && STRINGP (help))
{
/* The mouse-fixup-help-message Lisp function can call
@@ -3640,7 +3640,7 @@ readable_events (flags)
return 1;
}
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
if (!(flags & READABLE_EVENTS_IGNORE_SQUEEZABLES)
&& !NILP (do_mouse_tracking) && some_mouse_moved ())
return 1;
@@ -3918,6 +3918,9 @@ discard_mouse_events ()
#ifdef WINDOWSNT
|| sp->kind == W32_SCROLL_BAR_CLICK_EVENT
#endif
+#ifdef HAVE_GPM
+ || sp->kind == GPM_CLICK_EVENT
+#endif
|| sp->kind == SCROLL_BAR_CLICK_EVENT)
{
sp->kind = NO_EVENT;
@@ -3992,7 +3995,7 @@ kbd_buffer_get_event (kbp, used_mouse_menu, end_time)
{
if (kbd_fetch_ptr != kbd_store_ptr)
break;
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
if (!NILP (do_mouse_tracking) && some_mouse_moved ())
break;
#endif
@@ -4014,7 +4017,7 @@ kbd_buffer_get_event (kbp, used_mouse_menu, end_time)
#endif /* SIGIO */
if (kbd_fetch_ptr != kbd_store_ptr)
break;
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
if (!NILP (do_mouse_tracking) && some_mouse_moved ())
break;
#endif
@@ -4250,7 +4253,7 @@ kbd_buffer_get_event (kbp, used_mouse_menu, end_time)
}
}
}
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
/* Try generating a mouse motion event. */
else if (!NILP (do_mouse_tracking) && some_mouse_moved ())
{
@@ -4291,7 +4294,7 @@ kbd_buffer_get_event (kbp, used_mouse_menu, end_time)
if (!NILP (x) && NILP (obj))
obj = make_lispy_movement (f, bar_window, part, x, y, time);
}
-#endif /* HAVE_MOUSE */
+#endif /* HAVE_MOUSE || HAVE GPM */
else
/* We were promised by the above while loop that there was
something for us to read! */
@@ -6008,13 +6011,73 @@ make_lispy_event (event)
}
#endif
+#ifdef HAVE_GPM
+ case GPM_CLICK_EVENT:
+ {
+ FRAME_PTR f = XFRAME (event->frame_or_window);
+ Lisp_Object head, position;
+ Lisp_Object *start_pos_ptr;
+ Lisp_Object start_pos;
+ int button = event->code;
+
+ if (button >= ASIZE (button_down_location))
+ {
+ button_down_location = larger_vector (button_down_location,
+ button + 1, Qnil);
+ mouse_syms = larger_vector (mouse_syms, button + 1, Qnil);
+ }
+
+ start_pos_ptr = &AREF (button_down_location, button);
+ start_pos = *start_pos_ptr;
+
+ position = make_lispy_position (f, &event->x, &event->y,
+ event->timestamp);
+
+ if (event->modifiers & down_modifier)
+ *start_pos_ptr = Fcopy_alist (position);
+ else if (event->modifiers & (up_modifier | drag_modifier))
+ {
+ if (!CONSP (start_pos))
+ return Qnil;
+ event->modifiers &= ~up_modifier;
+ }
+
+ head = modify_event_symbol (button,
+ event->modifiers,
+ Qmouse_click, Vlispy_mouse_stem,
+ NULL,
+ &mouse_syms,
+ XVECTOR (mouse_syms)->size);
+
+ if (event->modifiers & drag_modifier)
+ return Fcons (head,
+ Fcons (start_pos,
+ Fcons (position,
+ Qnil)));
+ else if (event->modifiers & double_modifier)
+ return Fcons (head,
+ Fcons (position,
+ Fcons (make_number (2),
+ Qnil)));
+ else if (event->modifiers & triple_modifier)
+ return Fcons (head,
+ Fcons (position,
+ Fcons (make_number (3),
+ Qnil)));
+ else
+ return Fcons (head,
+ Fcons (position,
+ Qnil));
+ }
+#endif /* HAVE_GPM */
+
/* The 'kind' field of the event is something we don't recognize. */
default:
abort ();
}
}
-#ifdef HAVE_MOUSE
+#if defined(HAVE_MOUSE) || defined(HAVE_GPM)
static Lisp_Object
make_lispy_movement (frame, bar_window, part, x, y, time)
@@ -6053,7 +6116,7 @@ make_lispy_movement (frame, bar_window, part, x, y, time)
}
}
-#endif /* HAVE_MOUSE */
+#endif /* HAVE_MOUSE || HAVE GPM */
/* Construct a switch frame event. */
static Lisp_Object
@@ -6865,8 +6928,28 @@ read_avail_input (expected)
if (n_to_read == 0)
return 0;
#else /* not MSDOS */
+#ifdef HAVE_GPM
+ if (term_gpm)
+ {
+ Gpm_Event event;
+ struct input_event hold_quit;
+ int gpm;
+
+ EVENT_INIT (hold_quit);
+ hold_quit.kind = NO_EVENT;
+
+ while (gpm = Gpm_GetEvent (&event), gpm == 1) {
+ nread += handle_one_term_event (&event, &hold_quit);
+ }
+ if (hold_quit.kind != NO_EVENT)
+ kbd_buffer_store_event (&hold_quit);
+ if (nread)
+ return nread;
+ }
+#endif /* HAVE_GPM */
#ifdef FIONREAD
- /* Find out how much input is available. */
+
+ /* Find out how much input is available. */
if (ioctl (input_fd, FIONREAD, &n_to_read) < 0)
/* Formerly simply reported no input, but that sometimes led to
a failure of Emacs to terminate.
@@ -11045,7 +11128,7 @@ init_keyboard ()
recent_keys_index = 0;
kbd_fetch_ptr = kbd_buffer;
kbd_store_ptr = kbd_buffer;
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
do_mouse_tracking = Qnil;
#endif
input_pending = 0;
@@ -11235,7 +11318,7 @@ syms_of_keyboard ()
Qmenu_bar = intern ("menu-bar");
staticpro (&Qmenu_bar);
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
Qmouse_fixup_help_message = intern ("mouse-fixup-help-message");
staticpro (&Qmouse_fixup_help_message);
#endif
@@ -11367,7 +11450,7 @@ syms_of_keyboard ()
defsubr (&Sread_key_sequence);
defsubr (&Sread_key_sequence_vector);
defsubr (&Srecursive_edit);
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
defsubr (&Strack_mouse);
#endif
defsubr (&Sinput_pending_p);