comparison src/event-Xt.c @ 78:c7528f8e288d r20-0b34

Import from CVS: tag r20-0b34
author cvs
date Mon, 13 Aug 2007 09:05:42 +0200
parents c0c698873ce1
children 1ce6082ce73f
comparison
equal deleted inserted replaced
77:6cb4f478e7bc 78:c7528f8e288d
597 597
598 /************************************************************************/ 598 /************************************************************************/
599 /* X to Emacs event conversion */ 599 /* X to Emacs event conversion */
600 /************************************************************************/ 600 /************************************************************************/
601 601
602 #if (defined(sun) || defined(__sun)) && defined(__GNUC__)
603 # define SUNOS_GCC_L0_BUG
604 #endif
605
606 #ifdef SUNOS_GCC_L0_BUG
607 static void
608 x_to_emacs_keysym_sunos_bug (Lisp_Object *return_value_sunos_bug, /* #### */
609 XKeyPressedEvent *event, int simple_p)
610 #else /* !SUNOS_GCC_L0_BUG */
611 static Lisp_Object 602 static Lisp_Object
612 x_to_emacs_keysym (XKeyPressedEvent *event, int simple_p) 603 x_to_emacs_keysym (XKeyPressedEvent *event, int simple_p)
613 #endif /* !SUNOS_GCC_L0_BUG */
614 /* simple_p means don't try too hard (ASCII only) */ 604 /* simple_p means don't try too hard (ASCII only) */
615 { 605 {
616 char *name; 606 char *name;
617 KeySym keysym = 0; 607 KeySym keysym = 0;
618 /* Apparently it's necessary to specify a dummy here (rather than 608 /* Apparently it's necessary to specify a dummy here (rather than
623 int len; 613 int len;
624 char buffer[64]; 614 char buffer[64];
625 char *bufptr = buffer; 615 char *bufptr = buffer;
626 int bufsiz = sizeof (buffer); 616 int bufsiz = sizeof (buffer);
627 Status status; 617 Status status;
628 #endif
629
630 #ifdef SUNOS_GCC_L0_BUG
631 # define return(lose) \
632 do {*return_value_sunos_bug = (lose); goto return_it; } while (0)
633 #endif 618 #endif
634 619
635 #ifdef HAVE_XIM 620 #ifdef HAVE_XIM
636 #ifdef XIM_MOTIF 621 #ifdef XIM_MOTIF
637 #define LOOKUPSTRING \ 622 #define LOOKUPSTRING \
706 XEVENT (emacs_event)->event.key.modifiers = 0; 691 XEVENT (emacs_event)->event.key.modifiers = 0;
707 XEVENT (emacs_event)->event.key.keysym = make_char (ch); 692 XEVENT (emacs_event)->event.key.keysym = make_char (ch);
708 enqueue_Xt_dispatch_event (emacs_event); 693 enqueue_Xt_dispatch_event (emacs_event);
709 } 694 }
710 Lstream_close (XLSTREAM (instream)); 695 Lstream_close (XLSTREAM (instream));
711 return (Qnil); 696 return Qnil;
712 } 697 }
713 case XLookupNone: return (Qnil); 698 case XLookupNone: return Qnil;
714 case XBufferOverflow: 699 case XBufferOverflow:
715 bufptr = alloca (len+1); 700 bufptr = alloca (len+1);
716 bufsiz = len+1; 701 bufsiz = len+1;
717 LOOKUPSTRING; 702 LOOKUPSTRING;
718 goto check_status; 703 goto check_status;
722 #endif /* HAVE_XIM */ 707 #endif /* HAVE_XIM */
723 708
724 if (keysym >= XK_exclam && keysym <= XK_asciitilde) 709 if (keysym >= XK_exclam && keysym <= XK_asciitilde)
725 /* We must assume that the X keysym numbers for the ASCII graphic 710 /* We must assume that the X keysym numbers for the ASCII graphic
726 characters are the same as their ASCII codes. */ 711 characters are the same as their ASCII codes. */
727 return (make_char (keysym)); 712 return make_char (keysym);
728 713
729 switch (keysym) 714 switch (keysym)
730 { 715 {
731 /* These would be handled correctly by the default case, but by 716 /* These would be handled correctly by the default case, but by
732 special-casing them here we don't garbage a string or call intern(). 717 special-casing them here we don't garbage a string or call intern().
733 */ 718 */
734 case XK_BackSpace: return (QKbackspace); 719 case XK_BackSpace: return QKbackspace;
735 case XK_Tab: return (QKtab); 720 case XK_Tab: return QKtab;
736 case XK_Linefeed: return (QKlinefeed); 721 case XK_Linefeed: return QKlinefeed;
737 case XK_Return: return (QKreturn); 722 case XK_Return: return QKreturn;
738 case XK_Escape: return (QKescape); 723 case XK_Escape: return QKescape;
739 case XK_space: return (QKspace); 724 case XK_space: return QKspace;
740 case XK_Delete: return (QKdelete); 725 case XK_Delete: return QKdelete;
741 case 0: return (Qnil); 726 case 0: return Qnil;
742 default: 727 default:
743 if (simple_p) return (Qnil); 728 if (simple_p) return Qnil;
744 /* #### without return_value_sunos_bug, %l0 (GCC struct return pointer)
745 * #### gets roached (top 8 bits cleared) around this call.
746 */
747 /* !!#### not Mule-ized */ 729 /* !!#### not Mule-ized */
748 name = XKeysymToString (keysym); 730 name = XKeysymToString (keysym);
749 if (!name || !name[0]) /* this shouldn't happen... */ 731 if (!name || !name[0]) /* this shouldn't happen... */
750 { 732 {
751 char buf [255]; 733 char buf [255];
752 sprintf (buf, "unknown_keysym_0x%X", (int) keysym); 734 sprintf (buf, "unknown_keysym_0x%X", (int) keysym);
753 return (KEYSYM (buf)); 735 return KEYSYM (buf);
754 } 736 }
755 /* If it's got a one-character name, that's good enough. */ 737 /* If it's got a one-character name, that's good enough. */
756 if (!name[1]) return (make_char (name[0])); 738 if (!name[1]) return make_char (name[0]);
757 739
758 /* If it's in the "Keyboard" character set, downcase it. 740 /* If it's in the "Keyboard" character set, downcase it.
759 The case of those keysyms is too totally random for us to 741 The case of those keysyms is too totally random for us to
760 force anyone to remember them. 742 force anyone to remember them.
761 The case of the other character sets is significant, however. 743 The case of the other character sets is significant, however.
770 } else { 752 } else {
771 *s2 = tolower (* (unsigned char *) s1); 753 *s2 = tolower (* (unsigned char *) s1);
772 } 754 }
773 } 755 }
774 *s2 = 0; 756 *s2 = 0;
775 return (KEYSYM (buf)); 757 return KEYSYM (buf);
776 } 758 }
777 return (KEYSYM (name)); 759 return KEYSYM (name);
778 } 760 }
779 #ifdef SUNOS_GCC_L0_BUG 761 }
780 # undef return
781 return_it:
782 return;
783 #endif
784 }
785
786 #ifdef SUNOS_GCC_L0_BUG
787 /* #### */
788 static Lisp_Object
789 x_to_emacs_keysym (XKeyPressedEvent *event, int simple_p)
790 {
791 Lisp_Object return_value_sunos_bug;
792 x_to_emacs_keysym_sunos_bug (&return_value_sunos_bug, event, simple_p);
793 return (return_value_sunos_bug);
794 }
795 #endif
796 762
797 static void 763 static void
798 set_last_server_timestamp (struct device *d, XEvent *x_event) 764 set_last_server_timestamp (struct device *d, XEvent *x_event)
799 { 765 {
800 Time t; 766 Time t;