comparison src/keyboard.c @ 90729:6588c6259dfb

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 545-562) - Update from CVS - Update from erc--emacs--22 - Merge from gnus--rel--5.10 - erc-iswitchb: Temporarily enable iswitchb mode * gnus--rel--5.10 (patch 172-176) - Merge from emacs--devo--0 - Update from CVS - Update from CVS: lisp/legacy-gnus-agent.el: Add Copyright notice. Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-156
author Miles Bader <miles@gnu.org>
date Sat, 16 Dec 2006 01:29:26 +0000
parents f1d13e615070 130738a27be7
children bc10a33dd40b
comparison
equal deleted inserted replaced
90728:a65a92d83186 90729:6588c6259dfb
697 static void any_kboard_state P_ ((void)); 697 static void any_kboard_state P_ ((void));
698 static SIGTYPE interrupt_signal P_ ((int signalnum)); 698 static SIGTYPE interrupt_signal P_ ((int signalnum));
699 static void timer_start_idle P_ ((void)); 699 static void timer_start_idle P_ ((void));
700 static void timer_stop_idle P_ ((void)); 700 static void timer_stop_idle P_ ((void));
701 static void timer_resume_idle P_ ((void)); 701 static void timer_resume_idle P_ ((void));
702 static SIGTYPE handle_user_signal P_ ((int));
703 static char *find_user_signal_name P_ ((int));
704 static int store_user_signal_events P_ ((void));
702 705
703 /* Nonzero means don't try to suspend even if the operating system seems 706 /* Nonzero means don't try to suspend even if the operating system seems
704 to support it. */ 707 to support it. */
705 static int cannot_suspend; 708 static int cannot_suspend;
706 709
1433 val = Fprogn (args); 1436 val = Fprogn (args);
1434 return unbind_to (count, val); 1437 return unbind_to (count, val);
1435 } 1438 }
1436 1439
1437 /* If mouse has moved on some frame, return one of those frames. 1440 /* If mouse has moved on some frame, return one of those frames.
1438 Return 0 otherwise. */ 1441
1442 Return 0 otherwise.
1443
1444 If ignore_mouse_drag_p is non-zero, ignore (implicit) mouse movement
1445 after resizing the tool-bar window. */
1446
1447 int ignore_mouse_drag_p;
1439 1448
1440 static FRAME_PTR 1449 static FRAME_PTR
1441 some_mouse_moved () 1450 some_mouse_moved ()
1442 { 1451 {
1443 Lisp_Object tail, frame; 1452 Lisp_Object tail, frame;
1453
1454 if (ignore_mouse_drag_p)
1455 {
1456 //ignore_mouse_drag_p = 0;
1457 return 0;
1458 }
1444 1459
1445 FOR_EACH_FRAME (tail, frame) 1460 FOR_EACH_FRAME (tail, frame)
1446 { 1461 {
1447 if (XFRAME (frame)->mouse_moved) 1462 if (XFRAME (frame)->mouse_moved)
1448 return XFRAME (frame); 1463 return XFRAME (frame);
5587 } 5602 }
5588 else 5603 else
5589 double_click_count = 1; 5604 double_click_count = 1;
5590 button_down_time = event->timestamp; 5605 button_down_time = event->timestamp;
5591 *start_pos_ptr = Fcopy_alist (position); 5606 *start_pos_ptr = Fcopy_alist (position);
5607 ignore_mouse_drag_p = 0;
5592 } 5608 }
5593 5609
5594 /* Now we're releasing a button - check the co-ordinates to 5610 /* Now we're releasing a button - check the co-ordinates to
5595 see if this was a click or a drag. */ 5611 see if this was a click or a drag. */
5596 else if (event->modifiers & up_modifier) 5612 else if (event->modifiers & up_modifier)
5622 { 5638 {
5623 xdiff = XINT (event->x) - XINT (XCAR (down)); 5639 xdiff = XINT (event->x) - XINT (XCAR (down));
5624 ydiff = XINT (event->y) - XINT (XCDR (down)); 5640 ydiff = XINT (event->y) - XINT (XCDR (down));
5625 } 5641 }
5626 5642
5627 if (xdiff < double_click_fuzz && xdiff > - double_click_fuzz 5643 if (ignore_mouse_drag_p)
5628 && ydiff < double_click_fuzz && ydiff > - double_click_fuzz 5644 {
5645 event->modifiers |= click_modifier;
5646 ignore_mouse_drag_p = 0;
5647 }
5648 else if (xdiff < double_click_fuzz && xdiff > - double_click_fuzz
5649 && ydiff < double_click_fuzz && ydiff > - double_click_fuzz
5629 /* Maybe the mouse has moved a lot, caused scrolling, and 5650 /* Maybe the mouse has moved a lot, caused scrolling, and
5630 eventually ended up at the same screen position (but 5651 eventually ended up at the same screen position (but
5631 not buffer position) in which case it is a drag, not 5652 not buffer position) in which case it is a drag, not
5632 a click. */ 5653 a click. */
5633 /* FIXME: OTOH if the buffer position has changed 5654 /* FIXME: OTOH if the buffer position has changed
5946 return apply_modifiers (event->modifiers, event->arg); 5967 return apply_modifiers (event->modifiers, event->arg);
5947 return event->arg; 5968 return event->arg;
5948 5969
5949 case USER_SIGNAL_EVENT: 5970 case USER_SIGNAL_EVENT:
5950 /* A user signal. */ 5971 /* A user signal. */
5951 switch (event->code) 5972 if (event->code == 0)
5952 { 5973 return Qsignal;
5953 case 0: 5974 else
5954 return Qsignal; 5975 {
5955 #ifdef SIGUSR1 5976 char *name = find_user_signal_name (event->code);
5956 case SIGUSR1: 5977
5957 return intern ("usr1"); 5978 if (name)
5958 #endif 5979 return intern (name);
5959 #ifdef SIGUSR2 5980 else
5960 case SIGUSR2: 5981 return make_number (event->code);
5961 return intern ("usr2");
5962 #endif
5963 default:
5964 return make_number (event->code);
5965 } 5982 }
5966 5983
5967 case SAVE_SESSION_EVENT: 5984 case SAVE_SESSION_EVENT:
5968 return Qsave_session; 5985 return Qsave_session;
5969 5986
6796 read_avail_input (expected) 6813 read_avail_input (expected)
6797 int expected; 6814 int expected;
6798 { 6815 {
6799 register int i; 6816 register int i;
6800 int nread = 0; 6817 int nread = 0;
6818
6819 /* Store pending user signal events, if any. */
6820 if (store_user_signal_events ())
6821 expected = 0;
6801 6822
6802 if (read_socket_hook) 6823 if (read_socket_hook)
6803 { 6824 {
6804 int nr; 6825 int nr;
6805 struct input_event hold_quit; 6826 struct input_event hold_quit;
7018 #ifdef SIGIO 7039 #ifdef SIGIO
7019 handle_async_input (); 7040 handle_async_input ();
7020 #endif 7041 #endif
7021 } 7042 }
7022 7043
7044
7045
7046 /* User signal events. */
7047
7048 struct user_signal_info
7049 {
7050 /* Signal number. */
7051 int sig;
7052
7053 /* Name of the signal. */
7054 char *name;
7055
7056 /* Number of pending signals. */
7057 int npending;
7058
7059 struct user_signal_info *next;
7060 };
7061
7062 /* List of user signals. */
7063 static struct user_signal_info *user_signals = NULL;
7064
7065 void
7066 add_user_signal (sig, name)
7067 int sig;
7068 const char *name;
7069 {
7070 struct user_signal_info *p;
7071
7072 for (p = user_signals; p; p = p->next)
7073 if (p->sig == sig)
7074 /* Already added. */
7075 return;
7076
7077 p = xmalloc (sizeof (struct user_signal_info));
7078 p->sig = sig;
7079 p->name = xstrdup (name);
7080 p->npending = 0;
7081 p->next = user_signals;
7082 user_signals = p;
7083
7084 signal (sig, handle_user_signal);
7085 }
7086
7087 static SIGTYPE
7088 handle_user_signal (sig)
7089 int sig;
7090 {
7091 int old_errno = errno;
7092 struct user_signal_info *p;
7093
7094 #if defined (USG) && !defined (POSIX_SIGNALS)
7095 /* USG systems forget handlers when they are used;
7096 must reestablish each time */
7097 signal (sig, handle_user_signal);
7098 #endif
7099
7100 SIGNAL_THREAD_CHECK (sig);
7101
7102 for (p = user_signals; p; p = p->next)
7103 if (p->sig == sig)
7104 {
7105 p->npending++;
7106 #ifdef SIGIO
7107 if (interrupt_input)
7108 kill (getpid (), SIGIO);
7109 else
7110 #endif
7111 {
7112 /* Tell wait_reading_process_output that it needs to wake
7113 up and look around. */
7114 if (input_available_clear_time)
7115 EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0);
7116 }
7117 break;
7118 }
7119
7120 errno = old_errno;
7121 }
7122
7123 static char *
7124 find_user_signal_name (sig)
7125 int sig;
7126 {
7127 struct user_signal_info *p;
7128
7129 for (p = user_signals; p; p = p->next)
7130 if (p->sig == sig)
7131 return p->name;
7132
7133 return NULL;
7134 }
7135
7136 static int
7137 store_user_signal_events ()
7138 {
7139 struct user_signal_info *p;
7140 struct input_event buf;
7141 int nstored = 0;
7142
7143 for (p = user_signals; p; p = p->next)
7144 if (p->npending > 0)
7145 {
7146 SIGMASKTYPE mask;
7147
7148 if (nstored == 0)
7149 {
7150 bzero (&buf, sizeof buf);
7151 buf.kind = USER_SIGNAL_EVENT;
7152 buf.frame_or_window = selected_frame;
7153 }
7154 nstored += p->npending;
7155
7156 mask = sigblock (sigmask (p->sig));
7157 do
7158 {
7159 buf.code = 0;
7160 kbd_buffer_store_event (&buf);
7161 buf.code = p->sig;
7162 kbd_buffer_store_event (&buf);
7163 p->npending--;
7164 }
7165 while (p->npending > 0);
7166 sigsetmask (mask);
7167 }
7168
7169 return nstored;
7170 }
7023 7171
7024 7172
7025 static void menu_bar_item P_ ((Lisp_Object, Lisp_Object, Lisp_Object, void*)); 7173 static void menu_bar_item P_ ((Lisp_Object, Lisp_Object, Lisp_Object, void*));
7026 static Lisp_Object menu_bar_one_keymap_changed_items; 7174 static Lisp_Object menu_bar_one_keymap_changed_items;
7027 7175