comparison src/event-Xt.c @ 371:cc15677e0335 r21-2b1

Import from CVS: tag r21-2b1
author cvs
date Mon, 13 Aug 2007 11:03:08 +0200
parents a4f53d9b3154
children 6240c7796c7a
comparison
equal deleted inserted replaced
370:bd866891f083 371:cc15677e0335
767 static Lisp_Object 767 static Lisp_Object
768 x_to_emacs_keysym (XKeyPressedEvent *event, int simple_p) 768 x_to_emacs_keysym (XKeyPressedEvent *event, int simple_p)
769 /* simple_p means don't try too hard (ASCII only) */ 769 /* simple_p means don't try too hard (ASCII only) */
770 { 770 {
771 KeySym keysym = 0; 771 KeySym keysym = 0;
772 772
773 #ifdef HAVE_XIM 773 #ifdef HAVE_XIM
774 int len; 774 int len;
775 /* Some implementations of XmbLookupString don't return 775 char buffer[64];
776 XBufferOverflow correctly, so increase the size of the xim input
777 buffer from 64 to the more reasonable size 513, as Emacs has done.
778 From Kenichi Handa. */
779 char buffer[513];
780 char *bufptr = buffer; 776 char *bufptr = buffer;
781 int bufsiz = sizeof (buffer); 777 int bufsiz = sizeof (buffer);
782 Status status; 778 Status status;
783 #ifdef XIM_XLIB 779 #ifdef XIM_XLIB
784 XIC xic = FRAME_X_XIC (x_any_window_to_frame 780 XIC xic = FRAME_X_XIC (x_any_window_to_frame
796 { 792 {
797 /* Apparently it's necessary to specify a dummy here (rather 793 /* Apparently it's necessary to specify a dummy here (rather
798 than passing in 0) to avoid crashes on German IRIX */ 794 than passing in 0) to avoid crashes on German IRIX */
799 char dummy[256]; 795 char dummy[256];
800 XLookupString (event, dummy, 200, &keysym, 0); 796 XLookupString (event, dummy, 200, &keysym, 0);
801 return (IsModifierKey (keysym) || keysym == XK_Mode_switch ) 797 return x_keysym_to_emacs_keysym (keysym, simple_p);
802 ? Qnil : x_keysym_to_emacs_keysym (keysym, simple_p);
803 } 798 }
804 #endif /* ! XIM_MOTIF */ 799 #endif /* ! XIM_MOTIF */
805 800
806 #ifdef HAVE_XIM 801 #ifdef HAVE_XIM
807 Lookup_String: /* Come-From XBufferOverflow */ 802 Lookup_String: /* Come-From XBufferOverflow */
846 841
847 switch (status) 842 switch (status)
848 { 843 {
849 case XLookupKeySym: 844 case XLookupKeySym:
850 case XLookupBoth: 845 case XLookupBoth:
851 return (IsModifierKey (keysym) || keysym == XK_Mode_switch ) 846 return x_keysym_to_emacs_keysym (keysym, simple_p);
852 ? Qnil : x_keysym_to_emacs_keysym (keysym, simple_p);
853 847
854 case XLookupChars: 848 case XLookupChars:
855 { 849 {
856 /* Generate multiple emacs events */ 850 /* Generate multiple emacs events */
857 struct device *d = get_device_from_display (event->display); 851 struct device *d = get_device_from_display (event->display);
987 981
988 if (key_event_p) 982 if (key_event_p)
989 { 983 {
990 Lisp_Object keysym; 984 Lisp_Object keysym;
991 XKeyEvent *ev = &x_event->xkey; 985 XKeyEvent *ev = &x_event->xkey;
986 KeyCode keycode = ev->keycode;
987
988 if (x_key_is_modifier_p (keycode, d)) /* it's a modifier key */
989 return 0;
990
992 /* This used to compute the frame from the given X window and 991 /* This used to compute the frame from the given X window and
993 store it here, but we really don't care about the frame. */ 992 store it here, but we really don't care about the frame. */
994 emacs_event->channel = DEVICE_CONSOLE (d); 993 emacs_event->channel = DEVICE_CONSOLE (d);
995 keysym = x_to_emacs_keysym (&x_event->xkey, 0); 994 keysym = x_to_emacs_keysym (&x_event->xkey, 0);
996 995
997 /* If the emacs keysym is nil, then that means that the X 996 /* If the emacs keysym is nil, then that means that the
998 keysym was either a Modifier or NoSymbol, which 997 X keysym was NoSymbol, which probably means that
999 probably means that we're in the midst of reading a 998 we're in the midst of reading a Multi_key sequence,
1000 Multi_key sequence, or a "dead" key prefix, or XIM 999 or a "dead" key prefix, or XIM input. Ignore it. */
1001 input. Ignore it. */
1002 if (NILP (keysym)) 1000 if (NILP (keysym))
1003 return 0; 1001 return 0;
1004 1002
1005 /* More Caps_Lock garbage: Caps_Lock should *only* add the 1003 /* More Caps_Lock garbage: Caps_Lock should *only* add the
1006 shift modifier to two-case keys (that is, A-Z and 1004 shift modifier to two-case keys (that is, A-Z and
1121 unsigned long size, dtype; 1119 unsigned long size, dtype;
1122 Lisp_Object l_type = Qnil, l_data = Qnil; 1120 Lisp_Object l_type = Qnil, l_data = Qnil;
1123 Lisp_Object l_dndlist = Qnil, l_item = Qnil; 1121 Lisp_Object l_dndlist = Qnil, l_item = Qnil;
1124 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 1122 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
1125 1123
1124 GCPRO4 (l_type, l_data, l_dndlist, l_item);
1125
1126 if (! frame) 1126 if (! frame)
1127 return 0; /* not for us */ 1127 return 0; /* not for us */
1128
1129 GCPRO4 (l_type, l_data, l_dndlist, l_item);
1130
1131 XSETFRAME (emacs_event->channel, frame); 1128 XSETFRAME (emacs_event->channel, frame);
1132 1129
1133 emacs_event->event_type = misc_user_event; 1130 emacs_event->event_type = misc_user_event;
1134 emacs_event->timestamp = DEVICE_X_LAST_SERVER_TIMESTAMP (d); 1131 emacs_event->timestamp = DEVICE_X_LAST_SERVER_TIMESTAMP (d);
1135 1132
2038 unselect_filedesc (infd); 2035 unselect_filedesc (infd);
2039 #ifdef HAVE_GPM 2036 #ifdef HAVE_GPM
2040 /* On a stream device (ie: noninteractive), bad things can happen. */ 2037 /* On a stream device (ie: noninteractive), bad things can happen. */
2041 if (EQ (CONSOLE_TYPE (con), Qtty)) { 2038 if (EQ (CONSOLE_TYPE (con), Qtty)) {
2042 mousefd = CONSOLE_TTY_MOUSE_FD (con); 2039 mousefd = CONSOLE_TTY_MOUSE_FD (con);
2043 if (mousefd >= 0 && filedesc_to_what_closure[mousefd] ) { 2040 if (mousefd >= 0) {
2044 unselect_filedesc (mousefd); 2041 unselect_filedesc (mousefd);
2045 } 2042 }
2046 } 2043 }
2047 #endif 2044 #endif
2048 } 2045 }
2805 2802
2806 /* Originally called XAllocNamedColor() here. */ 2803 /* Originally called XAllocNamedColor() here. */
2807 if ((d = get_device_from_display_1(dpy))) { 2804 if ((d = get_device_from_display_1(dpy))) {
2808 visual = DEVICE_X_VISUAL(d); 2805 visual = DEVICE_X_VISUAL(d);
2809 if (colormap != DEVICE_X_COLORMAP(d)) { 2806 if (colormap != DEVICE_X_COLORMAP(d)) {
2810 XtAppWarningMsg(the_app_con, "weirdColormap", "cvtStringToPixel", 2807 XtAppWarningMsg(the_app_con, "wierdColormap", "cvtStringToPixel",
2811 "XtToolkitWarning", 2808 "XtToolkitWarning",
2812 "The colormap passed to cvtStringToPixel doesn't match the one registered to the device.\n", 2809 "The colormap passed to cvtStringToPixel doesn't match the one registerd to the device.\n",
2813 NULL, 0); 2810 NULL, 0);
2814 status = XAllocNamedColor(dpy, colormap, (char*)str, &screenColor, &exactColor); 2811 status = XAllocNamedColor(dpy, colormap, (char*)str, &screenColor, &exactColor);
2815 } else { 2812 } else {
2816 status = XParseColor (dpy, colormap, (char*)str, &screenColor); 2813 status = XParseColor (dpy, colormap, (char*)str, &screenColor);
2817 if (status) { 2814 if (status) {