comparison src/event-Xt.c @ 444:576fb035e263 r21-2-37

Import from CVS: tag r21-2-37
author cvs
date Mon, 13 Aug 2007 11:36:19 +0200
parents abe6d1db359e
children 1ccc32a20af4
comparison
equal deleted inserted replaced
443:a8296e22da4e 444:576fb035e263
685 if (! ((type == KeyPress || type == KeyRelease) && 685 if (! ((type == KeyPress || type == KeyRelease) &&
686 x_key_is_modifier_p (keycode, d))) 686 x_key_is_modifier_p (keycode, d)))
687 { /* Not a modifier key */ 687 { /* Not a modifier key */
688 Bool key_event_p = (type == KeyPress || type == KeyRelease); 688 Bool key_event_p = (type == KeyPress || type == KeyRelease);
689 689
690 if (type == KeyPress && !xd->last_downkey) 690 if (type == ButtonPress
691 xd->last_downkey = keycode; 691 || (type == KeyPress
692 else if (type == ButtonPress || 692 && ((xd->last_downkey
693 (type == KeyPress && xd->last_downkey && 693 && ((keycode != xd->last_downkey
694 (keycode != xd->last_downkey || 694 || ev->xkey.time != xd->release_time)))
695 ev->xkey.time != xd->release_time))) 695 || (INTP (Vmodifier_keys_sticky_time)
696 && ev->xkey.time
697 > (xd->modifier_release_time
698 + XINT (Vmodifier_keys_sticky_time))))))
696 { 699 {
697 xd->need_to_add_mask = 0; 700 xd->need_to_add_mask = 0;
698 xd->last_downkey = 0; 701 xd->last_downkey = 0;
699 } 702 }
703 else if (type == KeyPress && !xd->last_downkey)
704 xd->last_downkey = keycode;
705
700 if (type == KeyPress) 706 if (type == KeyPress)
701 xd->release_time = 0; 707 xd->release_time = 0;
702 if (type == KeyPress || type == ButtonPress) 708 if (type == KeyPress || type == ButtonPress)
703 xd->down_mask = 0; 709 {
710 xd->down_mask = 0;
711 xd->modifier_release_time = 0;
712 }
704 713
705 if (key_event_p) 714 if (key_event_p)
706 ev->xkey.state |= xd->need_to_add_mask; 715 ev->xkey.state |= xd->need_to_add_mask;
707 else 716 else
708 ev->xbutton.state |= xd->need_to_add_mask; 717 ev->xbutton.state |= xd->need_to_add_mask;
720 Naturally, the designers of the X spec didn't see fit 729 Naturally, the designers of the X spec didn't see fit
721 to provide an obvious way to distinguish these cases. 730 to provide an obvious way to distinguish these cases.
722 So we assume that if the release and the next press 731 So we assume that if the release and the next press
723 occur at the same time, the key was actually auto- 732 occur at the same time, the key was actually auto-
724 repeated. Under Open-Windows, at least, this works. */ 733 repeated. Under Open-Windows, at least, this works. */
725 xd->release_time = key_event_p ? ev->xkey.time : ev->xbutton.time; 734 xd->modifier_release_time = xd->release_time
735 = key_event_p ? ev->xkey.time : ev->xbutton.time;
726 } 736 }
727 else /* Modifier key pressed */ 737 else /* Modifier key pressed */
728 { 738 {
729 int i; 739 int i;
730 KeySym *syms = &xd->x_keysym_map [(keycode - xd->x_keysym_map_min_code) * 740 KeySym *syms = &xd->x_keysym_map [(keycode - xd->x_keysym_map_min_code) *
738 748
739 if (xd->last_downkey) 749 if (xd->last_downkey)
740 { 750 {
741 xd->last_downkey = 0; 751 xd->last_downkey = 0;
742 xd->need_to_add_mask = 0; 752 xd->need_to_add_mask = 0;
753 }
754
755 if (xd->modifier_release_time
756 && INTP (Vmodifier_keys_sticky_time)
757 && (ev->xkey.time
758 > xd->modifier_release_time + XINT (Vmodifier_keys_sticky_time)))
759 {
760 xd->need_to_add_mask = 0;
761 xd->down_mask = 0;
743 } 762 }
744 763
745 #define FROB(mask) \ 764 #define FROB(mask) \
746 do { \ 765 do { \
747 if (type == KeyPress) \ 766 if (type == KeyPress) \
765 { \ 784 { \
766 xd->down_mask &= ~mask; \ 785 xd->down_mask &= ~mask; \
767 xd->need_to_add_mask |= mask; \ 786 xd->need_to_add_mask |= mask; \
768 } \ 787 } \
769 } \ 788 } \
789 xd->modifier_release_time = ev->xkey.time; \
770 } while (0) 790 } while (0)
771 791
772 for (i = 0; i < xd->x_keysym_map_keysyms_per_code; i++) 792 for (i = 0; i < xd->x_keysym_map_keysyms_per_code; i++)
773 switch (syms[i]) 793 switch (syms[i])
774 { 794 {