Mercurial > emacs
comparison src/keyboard.c @ 80980:51a9e0fd18ae
(Qmouse_fixup_help_message)
(make_lispy_movement, tracking_off, Ftrack_mouse, some_mouse_moved)
(show_help_echo, readable_events, kbd_buffer_get_event, init_keyboard):
Extend HAVE_MOUSE ifdefs to HAVE_GPM_H.
(make_lispy_event): Add case GPM_CLICK_EVENT.
(read_avail_input): Handle mouse input.
author | Nick Roberts <nickrob@snap.net.nz> |
---|---|
date | Sun, 20 May 2007 02:29:50 +0000 |
parents | da21c991a6d5 |
children | 677a47b3c116 |
comparison
equal
deleted
inserted
replaced
80979:3d81d0b44577 | 80980:51a9e0fd18ae |
---|---|
519 Lisp_Object Qiconify_frame; | 519 Lisp_Object Qiconify_frame; |
520 Lisp_Object Qmake_frame_visible; | 520 Lisp_Object Qmake_frame_visible; |
521 Lisp_Object Qselect_window; | 521 Lisp_Object Qselect_window; |
522 Lisp_Object Qhelp_echo; | 522 Lisp_Object Qhelp_echo; |
523 | 523 |
524 #ifdef HAVE_MOUSE | 524 #if defined (HAVE_MOUSE) || defined (HAVE_GPM) |
525 Lisp_Object Qmouse_fixup_help_message; | 525 Lisp_Object Qmouse_fixup_help_message; |
526 #endif | 526 #endif |
527 | 527 |
528 /* Symbols to denote kinds of events. */ | 528 /* Symbols to denote kinds of events. */ |
529 Lisp_Object Qfunction_key; | 529 Lisp_Object Qfunction_key; |
675 Lisp_Object, int *)); | 675 Lisp_Object, int *)); |
676 static Lisp_Object read_char_x_menu_prompt (); | 676 static Lisp_Object read_char_x_menu_prompt (); |
677 static Lisp_Object read_char_minibuf_menu_prompt P_ ((int, int, | 677 static Lisp_Object read_char_minibuf_menu_prompt P_ ((int, int, |
678 Lisp_Object *)); | 678 Lisp_Object *)); |
679 static Lisp_Object make_lispy_event P_ ((struct input_event *)); | 679 static Lisp_Object make_lispy_event P_ ((struct input_event *)); |
680 #ifdef HAVE_MOUSE | 680 #if defined (HAVE_MOUSE) || defined (HAVE_GPM) |
681 static Lisp_Object make_lispy_movement P_ ((struct frame *, Lisp_Object, | 681 static Lisp_Object make_lispy_movement P_ ((struct frame *, Lisp_Object, |
682 enum scroll_bar_part, | 682 enum scroll_bar_part, |
683 Lisp_Object, Lisp_Object, | 683 Lisp_Object, Lisp_Object, |
684 unsigned long)); | 684 unsigned long)); |
685 #endif | 685 #endif |
1388 | 1388 |
1389 error ("No recursive edit is in progress"); | 1389 error ("No recursive edit is in progress"); |
1390 return Qnil; | 1390 return Qnil; |
1391 } | 1391 } |
1392 | 1392 |
1393 #ifdef HAVE_MOUSE | 1393 #if defined (HAVE_MOUSE) || defined (HAVE_GPM) |
1394 | 1394 |
1395 /* Restore mouse tracking enablement. See Ftrack_mouse for the only use | 1395 /* Restore mouse tracking enablement. See Ftrack_mouse for the only use |
1396 of this function. */ | 1396 of this function. */ |
1397 | 1397 |
1398 static Lisp_Object | 1398 static Lisp_Object |
1464 } | 1464 } |
1465 | 1465 |
1466 return 0; | 1466 return 0; |
1467 } | 1467 } |
1468 | 1468 |
1469 #endif /* HAVE_MOUSE */ | 1469 #endif /* HAVE_MOUSE || HAVE_GPM */ |
1470 | 1470 |
1471 /* This is the actual command reading loop, | 1471 /* This is the actual command reading loop, |
1472 sans error-handling encapsulation. */ | 1472 sans error-handling encapsulation. */ |
1473 | 1473 |
1474 static int read_key_sequence P_ ((Lisp_Object *, int, Lisp_Object, | 1474 static int read_key_sequence P_ ((Lisp_Object *, int, Lisp_Object, |
2386 | 2386 |
2387 if (!STRINGP (help)) | 2387 if (!STRINGP (help)) |
2388 return; | 2388 return; |
2389 } | 2389 } |
2390 | 2390 |
2391 #ifdef HAVE_MOUSE | 2391 #if defined (HAVE_MOUSE) || defined (HAVE_GPM) |
2392 if (!noninteractive && STRINGP (help)) | 2392 if (!noninteractive && STRINGP (help)) |
2393 { | 2393 { |
2394 /* The mouse-fixup-help-message Lisp function can call | 2394 /* The mouse-fixup-help-message Lisp function can call |
2395 mouse_position_hook, which resets the mouse_moved flags. | 2395 mouse_position_hook, which resets the mouse_moved flags. |
2396 This causes trouble if we are trying to read a mouse motion | 2396 This causes trouble if we are trying to read a mouse motion |
3638 } | 3638 } |
3639 else | 3639 else |
3640 return 1; | 3640 return 1; |
3641 } | 3641 } |
3642 | 3642 |
3643 #ifdef HAVE_MOUSE | 3643 #if defined (HAVE_MOUSE) || defined (HAVE_GPM) |
3644 if (!(flags & READABLE_EVENTS_IGNORE_SQUEEZABLES) | 3644 if (!(flags & READABLE_EVENTS_IGNORE_SQUEEZABLES) |
3645 && !NILP (do_mouse_tracking) && some_mouse_moved ()) | 3645 && !NILP (do_mouse_tracking) && some_mouse_moved ()) |
3646 return 1; | 3646 return 1; |
3647 #endif | 3647 #endif |
3648 if (single_kboard) | 3648 if (single_kboard) |
3990 /* Wait until there is input available. */ | 3990 /* Wait until there is input available. */ |
3991 for (;;) | 3991 for (;;) |
3992 { | 3992 { |
3993 if (kbd_fetch_ptr != kbd_store_ptr) | 3993 if (kbd_fetch_ptr != kbd_store_ptr) |
3994 break; | 3994 break; |
3995 #ifdef HAVE_MOUSE | 3995 #if defined (HAVE_MOUSE) || defined (HAVE_GPM) |
3996 if (!NILP (do_mouse_tracking) && some_mouse_moved ()) | 3996 if (!NILP (do_mouse_tracking) && some_mouse_moved ()) |
3997 break; | 3997 break; |
3998 #endif | 3998 #endif |
3999 | 3999 |
4000 /* If the quit flag is set, then read_char will return | 4000 /* If the quit flag is set, then read_char will return |
4012 #ifdef SIGIO | 4012 #ifdef SIGIO |
4013 gobble_input (0); | 4013 gobble_input (0); |
4014 #endif /* SIGIO */ | 4014 #endif /* SIGIO */ |
4015 if (kbd_fetch_ptr != kbd_store_ptr) | 4015 if (kbd_fetch_ptr != kbd_store_ptr) |
4016 break; | 4016 break; |
4017 #ifdef HAVE_MOUSE | 4017 #if defined (HAVE_MOUSE) || defined (HAVE_GPM) |
4018 if (!NILP (do_mouse_tracking) && some_mouse_moved ()) | 4018 if (!NILP (do_mouse_tracking) && some_mouse_moved ()) |
4019 break; | 4019 break; |
4020 #endif | 4020 #endif |
4021 if (end_time) | 4021 if (end_time) |
4022 { | 4022 { |
4248 clear_event (event); | 4248 clear_event (event); |
4249 kbd_fetch_ptr = event + 1; | 4249 kbd_fetch_ptr = event + 1; |
4250 } | 4250 } |
4251 } | 4251 } |
4252 } | 4252 } |
4253 #ifdef HAVE_MOUSE | 4253 #if defined (HAVE_MOUSE) || defined (HAVE_GPM) |
4254 /* Try generating a mouse motion event. */ | 4254 /* Try generating a mouse motion event. */ |
4255 else if (!NILP (do_mouse_tracking) && some_mouse_moved ()) | 4255 else if (!NILP (do_mouse_tracking) && some_mouse_moved ()) |
4256 { | 4256 { |
4257 FRAME_PTR f = some_mouse_moved (); | 4257 FRAME_PTR f = some_mouse_moved (); |
4258 Lisp_Object bar_window; | 4258 Lisp_Object bar_window; |
4289 /* If we didn't decide to make a switch-frame event, go ahead and | 4289 /* If we didn't decide to make a switch-frame event, go ahead and |
4290 return a mouse-motion event. */ | 4290 return a mouse-motion event. */ |
4291 if (!NILP (x) && NILP (obj)) | 4291 if (!NILP (x) && NILP (obj)) |
4292 obj = make_lispy_movement (f, bar_window, part, x, y, time); | 4292 obj = make_lispy_movement (f, bar_window, part, x, y, time); |
4293 } | 4293 } |
4294 #endif /* HAVE_MOUSE */ | 4294 #endif /* HAVE_MOUSE || HAVE GPM */ |
4295 else | 4295 else |
4296 /* We were promised by the above while loop that there was | 4296 /* We were promised by the above while loop that there was |
4297 something for us to read! */ | 4297 something for us to read! */ |
4298 abort (); | 4298 abort (); |
4299 | 4299 |
6006 Fcons (Fvector (2, spec), | 6006 Fcons (Fvector (2, spec), |
6007 Fcons (event->arg, Qnil))); | 6007 Fcons (event->arg, Qnil))); |
6008 } | 6008 } |
6009 #endif | 6009 #endif |
6010 | 6010 |
6011 case GPM_CLICK_EVENT: | |
6012 { | |
6013 FRAME_PTR f = XFRAME (event->frame_or_window); | |
6014 Lisp_Object head, position; | |
6015 Lisp_Object *start_pos_ptr; | |
6016 Lisp_Object start_pos; | |
6017 int button = event->code; | |
6018 | |
6019 if (button >= ASIZE (button_down_location)) | |
6020 { | |
6021 button_down_location = larger_vector (button_down_location, | |
6022 button + 1, Qnil); | |
6023 mouse_syms = larger_vector (mouse_syms, button + 1, Qnil); | |
6024 } | |
6025 | |
6026 start_pos_ptr = &AREF (button_down_location, button); | |
6027 start_pos = *start_pos_ptr; | |
6028 | |
6029 position = make_lispy_position (f, &event->x, &event->y, | |
6030 event->timestamp); | |
6031 | |
6032 if (event->modifiers & down_modifier) | |
6033 *start_pos_ptr = Fcopy_alist (position); | |
6034 else if (event->modifiers & (up_modifier | drag_modifier)) | |
6035 { | |
6036 if (!CONSP (start_pos)) | |
6037 return Qnil; | |
6038 event->modifiers &= ~up_modifier; | |
6039 } | |
6040 | |
6041 head = modify_event_symbol (button, | |
6042 event->modifiers, | |
6043 Qmouse_click, Vlispy_mouse_stem, | |
6044 NULL, | |
6045 &mouse_syms, | |
6046 XVECTOR (mouse_syms)->size); | |
6047 | |
6048 if (event->modifiers & drag_modifier) | |
6049 return Fcons (head, | |
6050 Fcons (start_pos, | |
6051 Fcons (position, | |
6052 Qnil))); | |
6053 else if (event->modifiers & double_modifier) | |
6054 return Fcons (head, | |
6055 Fcons (position, | |
6056 Fcons (make_number (2), | |
6057 Qnil))); | |
6058 else if (event->modifiers & triple_modifier) | |
6059 return Fcons (head, | |
6060 Fcons (position, | |
6061 Fcons (make_number (3), | |
6062 Qnil))); | |
6063 else | |
6064 return Fcons (head, | |
6065 Fcons (position, | |
6066 Qnil)); | |
6067 } | |
6068 | |
6011 /* The 'kind' field of the event is something we don't recognize. */ | 6069 /* The 'kind' field of the event is something we don't recognize. */ |
6012 default: | 6070 default: |
6013 abort (); | 6071 abort (); |
6014 } | 6072 } |
6015 } | 6073 } |
6863 #ifdef MSDOS | 6921 #ifdef MSDOS |
6864 n_to_read = dos_keysns (); | 6922 n_to_read = dos_keysns (); |
6865 if (n_to_read == 0) | 6923 if (n_to_read == 0) |
6866 return 0; | 6924 return 0; |
6867 #else /* not MSDOS */ | 6925 #else /* not MSDOS */ |
6926 #ifdef HAVE_GPM_H | |
6927 if (term_gpm) | |
6928 { | |
6929 Gpm_Event event; | |
6930 struct input_event hold_quit; | |
6931 int gpm; | |
6932 | |
6933 EVENT_INIT (hold_quit); | |
6934 hold_quit.kind = NO_EVENT; | |
6935 | |
6936 while (gpm = Gpm_GetEvent (&event), gpm == 1) { | |
6937 nread += handle_one_term_event (&event, &hold_quit); | |
6938 } | |
6939 if (hold_quit.kind != NO_EVENT) | |
6940 kbd_buffer_store_event (&hold_quit); | |
6941 if (nread) | |
6942 return nread; | |
6943 } | |
6944 #endif /* HAVE_GPM_H */ | |
6868 #ifdef FIONREAD | 6945 #ifdef FIONREAD |
6869 /* Find out how much input is available. */ | 6946 |
6947 /* Find out how much input is available. */ | |
6870 if (ioctl (input_fd, FIONREAD, &n_to_read) < 0) | 6948 if (ioctl (input_fd, FIONREAD, &n_to_read) < 0) |
6871 /* Formerly simply reported no input, but that sometimes led to | 6949 /* Formerly simply reported no input, but that sometimes led to |
6872 a failure of Emacs to terminate. | 6950 a failure of Emacs to terminate. |
6873 SIGHUP seems appropriate if we can't reach the terminal. */ | 6951 SIGHUP seems appropriate if we can't reach the terminal. */ |
6874 /* ??? Is it really right to send the signal just to this process | 6952 /* ??? Is it really right to send the signal just to this process |
11043 EMACS_SET_SECS_USECS (timer_idleness_start_time, -1, -1); | 11121 EMACS_SET_SECS_USECS (timer_idleness_start_time, -1, -1); |
11044 total_keys = 0; | 11122 total_keys = 0; |
11045 recent_keys_index = 0; | 11123 recent_keys_index = 0; |
11046 kbd_fetch_ptr = kbd_buffer; | 11124 kbd_fetch_ptr = kbd_buffer; |
11047 kbd_store_ptr = kbd_buffer; | 11125 kbd_store_ptr = kbd_buffer; |
11048 #ifdef HAVE_MOUSE | 11126 #if defined (HAVE_MOUSE) || defined (HAVE_GPM) |
11049 do_mouse_tracking = Qnil; | 11127 do_mouse_tracking = Qnil; |
11050 #endif | 11128 #endif |
11051 input_pending = 0; | 11129 input_pending = 0; |
11052 interrupt_input_blocked = 0; | 11130 interrupt_input_blocked = 0; |
11053 interrupt_input_pending = 0; | 11131 interrupt_input_pending = 0; |
11233 Qvertical_scroll_bar = intern ("vertical-scroll-bar"); | 11311 Qvertical_scroll_bar = intern ("vertical-scroll-bar"); |
11234 staticpro (&Qvertical_scroll_bar); | 11312 staticpro (&Qvertical_scroll_bar); |
11235 Qmenu_bar = intern ("menu-bar"); | 11313 Qmenu_bar = intern ("menu-bar"); |
11236 staticpro (&Qmenu_bar); | 11314 staticpro (&Qmenu_bar); |
11237 | 11315 |
11238 #ifdef HAVE_MOUSE | 11316 #if defined (HAVE_MOUSE) || defined (HAVE_GPM) |
11239 Qmouse_fixup_help_message = intern ("mouse-fixup-help-message"); | 11317 Qmouse_fixup_help_message = intern ("mouse-fixup-help-message"); |
11240 staticpro (&Qmouse_fixup_help_message); | 11318 staticpro (&Qmouse_fixup_help_message); |
11241 #endif | 11319 #endif |
11242 | 11320 |
11243 Qabove_handle = intern ("above-handle"); | 11321 Qabove_handle = intern ("above-handle"); |
11365 defsubr (&Scurrent_idle_time); | 11443 defsubr (&Scurrent_idle_time); |
11366 defsubr (&Sevent_convert_list); | 11444 defsubr (&Sevent_convert_list); |
11367 defsubr (&Sread_key_sequence); | 11445 defsubr (&Sread_key_sequence); |
11368 defsubr (&Sread_key_sequence_vector); | 11446 defsubr (&Sread_key_sequence_vector); |
11369 defsubr (&Srecursive_edit); | 11447 defsubr (&Srecursive_edit); |
11370 #ifdef HAVE_MOUSE | 11448 #if defined (HAVE_MOUSE) || defined (HAVE_GPM) |
11371 defsubr (&Strack_mouse); | 11449 defsubr (&Strack_mouse); |
11372 #endif | 11450 #endif |
11373 defsubr (&Sinput_pending_p); | 11451 defsubr (&Sinput_pending_p); |
11374 defsubr (&Scommand_execute); | 11452 defsubr (&Scommand_execute); |
11375 defsubr (&Srecent_keys); | 11453 defsubr (&Srecent_keys); |