aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorPo Lu2024-02-24 10:01:57 +0800
committerPo Lu2024-02-24 10:01:57 +0800
commit8d5983aa78e36afa815325e7bce85a81d314e67b (patch)
tree527bb8591e412a07869f38beae0face9cdb3348e /java
parent65d4bf711055dc8d23cea9b2ec8a57cdbfa6cf05 (diff)
downloademacs-8d5983aa78e36afa815325e7bce85a81d314e67b.tar.gz
emacs-8d5983aa78e36afa815325e7bce85a81d314e67b.zip
Fix bug#69321
* java/org/gnu/emacs/EmacsWindow.java (onKeyDown, onKeyUp): Provide Right Alt (Alt Gr) masks to system keymap routines. (bug#69321)
Diffstat (limited to 'java')
-rw-r--r--java/org/gnu/emacs/EmacsWindow.java68
1 files changed, 48 insertions, 20 deletions
diff --git a/java/org/gnu/emacs/EmacsWindow.java b/java/org/gnu/emacs/EmacsWindow.java
index 427a1a92332..6e8bdaf7401 100644
--- a/java/org/gnu/emacs/EmacsWindow.java
+++ b/java/org/gnu/emacs/EmacsWindow.java
@@ -661,7 +661,7 @@ public final class EmacsWindow extends EmacsHandleObject
661 public void 661 public void
662 onKeyDown (int keyCode, KeyEvent event) 662 onKeyDown (int keyCode, KeyEvent event)
663 { 663 {
664 int state, state_1, num_lock_flag; 664 int state, state_1, extra_ignored;
665 long serial; 665 long serial;
666 String characters; 666 String characters;
667 667
@@ -682,23 +682,37 @@ public final class EmacsWindow extends EmacsHandleObject
682 682
683 state = eventModifiers (event); 683 state = eventModifiers (event);
684 684
685 /* Num Lock and Scroll Lock aren't supported by systems older than 685 /* Num Lock, Scroll Lock and Meta aren't supported by systems older
686 Android 3.0. */ 686 than Android 3.0. */
687 687
688 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) 688 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
689 num_lock_flag = (KeyEvent.META_NUM_LOCK_ON 689 extra_ignored = (KeyEvent.META_NUM_LOCK_ON
690 | KeyEvent.META_SCROLL_LOCK_ON); 690 | KeyEvent.META_SCROLL_LOCK_ON
691 | KeyEvent.META_META_MASK);
691 else 692 else
692 num_lock_flag = 0; 693 extra_ignored = 0;
693 694
694 /* Ignore meta-state understood by Emacs for now, or key presses 695 /* Ignore meta-state understood by Emacs for now, or key presses
695 such as Ctrl+C and Meta+C will not be recognized as an ASCII 696 such as Ctrl+C and Meta+C will not be recognized as ASCII key
696 key press event. */ 697 press events. */
697 698
698 state_1 699 state_1
699 = state & ~(KeyEvent.META_ALT_MASK | KeyEvent.META_CTRL_MASK 700 = state & ~(KeyEvent.META_ALT_MASK | KeyEvent.META_CTRL_MASK
700 | KeyEvent.META_SYM_ON | KeyEvent.META_META_MASK 701 | KeyEvent.META_SYM_ON | extra_ignored);
701 | num_lock_flag); 702
703 /* There's no distinction between Right Alt and Alt Gr on Android,
704 so restore META_ALT_RIGHT_ON if set in state to enable composing
705 characters. (bug#69321) */
706
707 if ((state & KeyEvent.META_ALT_RIGHT_ON) != 0)
708 {
709 state_1 |= KeyEvent.META_ALT_ON | KeyEvent.META_ALT_RIGHT_ON;
710
711 /* If Alt is also not depressed, remove its bit from the mask
712 reported to Emacs. */
713 if ((state & KeyEvent.META_ALT_LEFT_ON) == 0)
714 state &= ~KeyEvent.META_ALT_MASK;
715 }
702 716
703 synchronized (eventStrings) 717 synchronized (eventStrings)
704 { 718 {
@@ -719,29 +733,43 @@ public final class EmacsWindow extends EmacsHandleObject
719 public void 733 public void
720 onKeyUp (int keyCode, KeyEvent event) 734 onKeyUp (int keyCode, KeyEvent event)
721 { 735 {
722 int state, state_1, unicode_char, num_lock_flag; 736 int state, state_1, unicode_char, extra_ignored;
723 long time; 737 long time;
724 738
725 /* Compute the event's modifier mask. */ 739 /* Compute the event's modifier mask. */
726 state = eventModifiers (event); 740 state = eventModifiers (event);
727 741
728 /* Num Lock and Scroll Lock aren't supported by systems older than 742 /* Num Lock, Scroll Lock and Meta aren't supported by systems older
729 Android 3.0. */ 743 than Android 3.0. */
730 744
731 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) 745 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
732 num_lock_flag = (KeyEvent.META_NUM_LOCK_ON 746 extra_ignored = (KeyEvent.META_NUM_LOCK_ON
733 | KeyEvent.META_SCROLL_LOCK_ON); 747 | KeyEvent.META_SCROLL_LOCK_ON
748 | KeyEvent.META_META_MASK);
734 else 749 else
735 num_lock_flag = 0; 750 extra_ignored = 0;
736 751
737 /* Ignore meta-state understood by Emacs for now, or key presses 752 /* Ignore meta-state understood by Emacs for now, or key presses
738 such as Ctrl+C and Meta+C will not be recognized as an ASCII 753 such as Ctrl+C and Meta+C will not be recognized as ASCII key
739 key press event. */ 754 press events. */
740 755
741 state_1 756 state_1
742 = state & ~(KeyEvent.META_ALT_MASK | KeyEvent.META_CTRL_MASK 757 = state & ~(KeyEvent.META_ALT_MASK | KeyEvent.META_CTRL_MASK
743 | KeyEvent.META_SYM_ON | KeyEvent.META_META_MASK 758 | KeyEvent.META_SYM_ON | extra_ignored);
744 | num_lock_flag); 759
760 /* There's no distinction between Right Alt and Alt Gr on Android,
761 so restore META_ALT_RIGHT_ON if set in state to enable composing
762 characters. */
763
764 if ((state & KeyEvent.META_ALT_RIGHT_ON) != 0)
765 {
766 state_1 |= KeyEvent.META_ALT_ON | KeyEvent.META_ALT_RIGHT_ON;
767
768 /* If Alt is also not depressed, remove its bit from the mask
769 reported to Emacs. */
770 if ((state & KeyEvent.META_ALT_LEFT_ON) == 0)
771 state &= ~KeyEvent.META_ALT_MASK;
772 }
745 773
746 unicode_char = getEventUnicodeChar (event, state_1); 774 unicode_char = getEventUnicodeChar (event, state_1);
747 775