comparison src/keyboard.c @ 96675:d45acf0c8d23

merging Emacs.app (NeXTstep port)
author Adrian Robert <Adrian.B.Robert@gmail.com>
date Tue, 15 Jul 2008 18:15:18 +0000
parents ddedcecb18ef
children 38b988607823
comparison
equal deleted inserted replaced
96674:ff312a846b25 96675:d45acf0c8d23
76 #include "w32term.h" 76 #include "w32term.h"
77 #endif /* HAVE_NTGUI */ 77 #endif /* HAVE_NTGUI */
78 78
79 #ifdef MAC_OS 79 #ifdef MAC_OS
80 #include "macterm.h" 80 #include "macterm.h"
81 #endif
82
83 #ifdef HAVE_NS
84 #include "nsterm.h"
85 extern Lisp_Object Qsuper;
81 #endif 86 #endif
82 87
83 #ifndef USE_CRT_DLL 88 #ifndef USE_CRT_DLL
84 extern int errno; 89 extern int errno;
85 #endif 90 #endif
4145 a window system. */ 4150 a window system. */
4146 abort (); 4151 abort ();
4147 #endif 4152 #endif
4148 } 4153 }
4149 4154
4150 #if defined (HAVE_X11) || defined (HAVE_NTGUI) || defined (MAC_OS) 4155 #if defined (HAVE_X11) || defined (HAVE_NTGUI) || defined (MAC_OS) \
4156 || defined (HAVE_NS)
4151 else if (event->kind == DELETE_WINDOW_EVENT) 4157 else if (event->kind == DELETE_WINDOW_EVENT)
4152 { 4158 {
4153 /* Make an event (delete-frame (FRAME)). */ 4159 /* Make an event (delete-frame (FRAME)). */
4154 obj = Fcons (event->frame_or_window, Qnil); 4160 obj = Fcons (event->frame_or_window, Qnil);
4155 obj = Fcons (Qdelete_frame, Fcons (obj, Qnil)); 4161 obj = Fcons (Qdelete_frame, Fcons (obj, Qnil));
4156 kbd_fetch_ptr = event + 1; 4162 kbd_fetch_ptr = event + 1;
4157 } 4163 }
4158 #endif 4164 #endif
4159 #if defined (HAVE_X11) || defined (HAVE_NTGUI) || defined (MAC_OS) 4165 #if defined (HAVE_X11) || defined (HAVE_NTGUI) || defined (MAC_OS) \
4166 || defined (HAVE_NS)
4160 else if (event->kind == ICONIFY_EVENT) 4167 else if (event->kind == ICONIFY_EVENT)
4161 { 4168 {
4162 /* Make an event (iconify-frame (FRAME)). */ 4169 /* Make an event (iconify-frame (FRAME)). */
4163 obj = Fcons (event->frame_or_window, Qnil); 4170 obj = Fcons (event->frame_or_window, Qnil);
4164 obj = Fcons (Qiconify_frame, Fcons (obj, Qnil)); 4171 obj = Fcons (Qiconify_frame, Fcons (obj, Qnil));
4177 /* The value doesn't matter here; only the type is tested. */ 4184 /* The value doesn't matter here; only the type is tested. */
4178 XSETBUFFER (obj, current_buffer); 4185 XSETBUFFER (obj, current_buffer);
4179 kbd_fetch_ptr = event + 1; 4186 kbd_fetch_ptr = event + 1;
4180 } 4187 }
4181 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \ 4188 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
4182 || defined (USE_GTK) 4189 || defined(HAVE_NS) || defined (USE_GTK)
4183 else if (event->kind == MENU_BAR_ACTIVATE_EVENT) 4190 else if (event->kind == MENU_BAR_ACTIVATE_EVENT)
4184 { 4191 {
4185 kbd_fetch_ptr = event + 1; 4192 kbd_fetch_ptr = event + 1;
4186 input_pending = readable_events (0); 4193 input_pending = readable_events (0);
4187 if (FRAME_LIVE_P (XFRAME (event->frame_or_window))) 4194 if (FRAME_LIVE_P (XFRAME (event->frame_or_window)))
4287 if (NILP (obj)) 4294 if (NILP (obj))
4288 { 4295 {
4289 obj = make_lispy_event (event); 4296 obj = make_lispy_event (event);
4290 4297
4291 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined(MAC_OS) \ 4298 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined(MAC_OS) \
4292 || defined (USE_GTK) 4299 || defined(HAVE_NS) || defined (USE_GTK)
4293 /* If this was a menu selection, then set the flag to inhibit 4300 /* If this was a menu selection, then set the flag to inhibit
4294 writing to last_nonmenu_event. Don't do this if the event 4301 writing to last_nonmenu_event. Don't do this if the event
4295 we're returning is (menu-bar), though; that indicates the 4302 we're returning is (menu-bar), though; that indicates the
4296 beginning of the menu sequence, and we might as well leave 4303 beginning of the menu sequence, and we might as well leave
4297 that as the `event with parameters' for this selection. */ 4304 that as the `event with parameters' for this selection. */
5641 5648
5642 /* Build the position as appropriate for this mouse click. */ 5649 /* Build the position as appropriate for this mouse click. */
5643 if (event->kind == MOUSE_CLICK_EVENT) 5650 if (event->kind == MOUSE_CLICK_EVENT)
5644 { 5651 {
5645 struct frame *f = XFRAME (event->frame_or_window); 5652 struct frame *f = XFRAME (event->frame_or_window);
5646 #if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK) 5653 #if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK) && ! defined (HAVE_NS)
5647 int row, column; 5654 int row, column;
5648 #endif 5655 #endif
5649 5656
5650 /* Ignore mouse events that were made on frame that 5657 /* Ignore mouse events that were made on frame that
5651 have been deleted. */ 5658 have been deleted. */
5652 if (! FRAME_LIVE_P (f)) 5659 if (! FRAME_LIVE_P (f))
5653 return Qnil; 5660 return Qnil;
5654 5661
5655 #if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK) 5662 #if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK) && ! defined (HAVE_NS)
5656 /* EVENT->x and EVENT->y are frame-relative pixel 5663 /* EVENT->x and EVENT->y are frame-relative pixel
5657 coordinates at this place. Under old redisplay, COLUMN 5664 coordinates at this place. Under old redisplay, COLUMN
5658 and ROW are set to frame relative glyph coordinates 5665 and ROW are set to frame relative glyph coordinates
5659 which are then used to determine whether this click is 5666 which are then used to determine whether this click is
5660 in a menu (non-toolkit version). */ 5667 in a menu (non-toolkit version). */
5710 Fcons (make_number (event->timestamp), 5717 Fcons (make_number (event->timestamp),
5711 Qnil)))); 5718 Qnil))));
5712 5719
5713 return Fcons (item, Fcons (position, Qnil)); 5720 return Fcons (item, Fcons (position, Qnil));
5714 } 5721 }
5715 #endif /* not USE_X_TOOLKIT && not USE_GTK */ 5722 #endif /* not USE_X_TOOLKIT && not USE_GTK && not HAVE_NS */
5716 5723
5717 position = make_lispy_position (f, &event->x, &event->y, 5724 position = make_lispy_position (f, &event->x, &event->y,
5718 event->timestamp); 5725 event->timestamp);
5719 } 5726 }
5720 #ifndef USE_TOOLKIT_SCROLL_BARS 5727 #ifndef USE_TOOLKIT_SCROLL_BARS
6090 Qnil))); 6097 Qnil)));
6091 } 6098 }
6092 #endif /* HAVE_MOUSE */ 6099 #endif /* HAVE_MOUSE */
6093 6100
6094 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \ 6101 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
6095 || defined (USE_GTK) 6102 || defined(HAVE_NS) || defined (USE_GTK)
6096 case MENU_BAR_EVENT: 6103 case MENU_BAR_EVENT:
6097 if (EQ (event->arg, event->frame_or_window)) 6104 if (EQ (event->arg, event->frame_or_window))
6098 /* This is the prefix key. We translate this to 6105 /* This is the prefix key. We translate this to
6099 `(menu_bar)' because the code in keyboard.c for menu 6106 `(menu_bar)' because the code in keyboard.c for menu
6100 events, which we use, relies on this. */ 6107 events, which we use, relies on this. */
7303 #endif /* not VMS */ 7310 #endif /* not VMS */
7304 7311
7305 void 7312 void
7306 handle_async_input () 7313 handle_async_input ()
7307 { 7314 {
7315 #ifdef BSD4_1
7316 extern int select_alarmed;
7317 #endif
7318
7308 interrupt_input_pending = 0; 7319 interrupt_input_pending = 0;
7309 7320
7310 while (1) 7321 while (1)
7311 { 7322 {
7312 int nread; 7323 int nread;
7315 UNBLOCK_INPUT will read it later; now, avoid infinite loop. 7326 UNBLOCK_INPUT will read it later; now, avoid infinite loop.
7316 0 means there was no keyboard input available. */ 7327 0 means there was no keyboard input available. */
7317 if (nread <= 0) 7328 if (nread <= 0)
7318 break; 7329 break;
7319 7330
7331 #ifdef BSD4_1
7332 select_alarmed = 1; /* Force the select emulator back to life */
7333 #endif
7320 } 7334 }
7321 } 7335 }
7322 7336
7323 #ifdef SIGIO /* for entire page */ 7337 #ifdef SIGIO /* for entire page */
7324 /* Note SIGIO has been undef'd if FIONREAD is missing. */ 7338 /* Note SIGIO has been undef'd if FIONREAD is missing. */
7333 /* USG systems forget handlers when they are used; 7347 /* USG systems forget handlers when they are used;
7334 must reestablish each time */ 7348 must reestablish each time */
7335 signal (signo, input_available_signal); 7349 signal (signo, input_available_signal);
7336 #endif /* USG */ 7350 #endif /* USG */
7337 7351
7352 #ifdef BSD4_1
7353 sigisheld (SIGIO);
7354 #endif
7355
7338 #ifdef SYNC_INPUT 7356 #ifdef SYNC_INPUT
7339 interrupt_input_pending = 1; 7357 interrupt_input_pending = 1;
7340 #else 7358 #else
7341 SIGNAL_THREAD_CHECK (signo); 7359 SIGNAL_THREAD_CHECK (signo);
7342 #endif 7360 #endif
7346 7364
7347 #ifndef SYNC_INPUT 7365 #ifndef SYNC_INPUT
7348 handle_async_input (); 7366 handle_async_input ();
7349 #endif 7367 #endif
7350 7368
7369 #ifdef BSD4_1
7370 sigfree ();
7371 #endif
7351 errno = old_errno; 7372 errno = old_errno;
7352 } 7373 }
7353 #endif /* SIGIO */ 7374 #endif /* SIGIO */
7354 7375
7355 /* Send ourselves a SIGIO. 7376 /* Send ourselves a SIGIO.
7973 { 7994 {
7974 /* We have to create a cachelist. */ 7995 /* We have to create a cachelist. */
7975 /* With the introduction of where_is_cache, the computation 7996 /* With the introduction of where_is_cache, the computation
7976 of equivalent key bindings is sufficiently fast that we 7997 of equivalent key bindings is sufficiently fast that we
7977 do not need to cache it here any more. */ 7998 do not need to cache it here any more. */
7978 /* CHECK_IMPURE (start); 7999 /*PENDING: under NS this effect does not hold, perhaps due to the
7979 XSETCDR (start, Fcons (Fcons (Qnil, Qnil), XCDR (start))); 8000 modifier-preference changes to where-is-internal.. */
7980 cachelist = XCAR (XCDR (start)); */ 8001 #ifdef HAVE_NS
8002 CHECK_IMPURE (start);
8003 XSETCDR (start, Fcons (Fcons (Qnil, Qnil), XCDR (start)));
8004 cachelist = XCAR (XCDR (start));
8005 #else
7981 cachelist = Fcons (Qnil, Qnil); 8006 cachelist = Fcons (Qnil, Qnil);
8007 #endif
7982 newcache = 1; 8008 newcache = 1;
7983 tem = AREF (item_properties, ITEM_PROPERTY_KEYEQ); 8009 tem = AREF (item_properties, ITEM_PROPERTY_KEYEQ);
7984 if (!NILP (keyhint)) 8010 if (!NILP (keyhint))
7985 { 8011 {
7986 XSETCAR (cachelist, XCAR (keyhint)); 8012 XSETCAR (cachelist, XCAR (keyhint));
8042 makes lmenu menus slow. */ 8068 makes lmenu menus slow. */
8043 if (SYMBOLP (def) 8069 if (SYMBOLP (def)
8044 && SYMBOLP (XSYMBOL (def)->function) 8070 && SYMBOLP (XSYMBOL (def)->function)
8045 && ! NILP (Fget (def, Qmenu_alias))) 8071 && ! NILP (Fget (def, Qmenu_alias)))
8046 def = XSYMBOL (def)->function; 8072 def = XSYMBOL (def)->function;
8073 #ifdef HAVE_NS
8074 /* prefer 'super' bindings */
8075 tem = Fwhere_is_internal (def, Qnil, Qsuper, Qt, Qt);
8076 #else
8047 tem = Fwhere_is_internal (def, Qnil, Qt, Qnil, Qt); 8077 tem = Fwhere_is_internal (def, Qnil, Qt, Qnil, Qt);
8078 #endif
8048 XSETCAR (cachelist, tem); 8079 XSETCAR (cachelist, tem);
8049 if (NILP (tem)) 8080 if (NILP (tem))
8050 { 8081 {
8051 XSETCDR (cachelist, Qnil); 8082 XSETCDR (cachelist, Qnil);
8052 chkcache = 0; 8083 chkcache = 0;
8075 8106
8076 tem = XCDR (cachelist); 8107 tem = XCDR (cachelist);
8077 if (newcache && !NILP (tem)) 8108 if (newcache && !NILP (tem))
8078 { 8109 {
8079 tem = concat2 (build_string (" "), tem); 8110 tem = concat2 (build_string (" "), tem);
8080 // tem = concat3 (build_string (" ("), tem, build_string (")")); 8111 /* tem = concat3 (build_string (" ("), tem, build_string (")")); */
8081 XSETCDR (cachelist, tem); 8112 XSETCDR (cachelist, tem);
8082 } 8113 }
8083 8114
8084 /* If we only want to precompute equivalent key bindings, stop here. */ 8115 /* If we only want to precompute equivalent key bindings, stop here. */
8085 if (notreal) 8116 if (notreal)