1 /*
2 * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
69 /*
70 * Two osf keys are not defined in standard keysym.h,
71 * /Xm/VirtKeys.h, or HPkeysym.h, so I added them below.
72 * I found them in /usr/openwin/lib/X11/XKeysymDB
73 */
74 #ifndef osfXK_Prior
75 #define osfXK_Prior 0x1004FF55
76 #endif
77 #ifndef osfXK_Next
78 #define osfXK_Next 0x1004FF56
79 #endif
80
81 jfieldID windowID;
82 jfieldID drawStateID;
83 jfieldID targetID;
84 jfieldID graphicsConfigID;
85
86 extern jobject currentX11InputMethodInstance;
87 extern Boolean awt_x11inputmethod_lookupString(XKeyPressedEvent *, KeySym *);
88 Boolean awt_UseType4Patch = False;
89 /* how about HEADLESS */
90 Boolean awt_ServerDetected = False;
91 Boolean awt_XKBDetected = False;
92 Boolean awt_IsXsun = False;
93 Boolean awt_UseXKB = False;
94
95 typedef struct KEYMAP_ENTRY {
96 jint awtKey;
97 KeySym x11Key;
98 Boolean mapsToUnicodeChar;
99 jint keyLocation;
100 } KeymapEntry;
101
102 /* NB: XK_R? keysyms are for Type 4 keyboards.
103 * The corresponding XK_F? keysyms are for Type 5
104 *
105 * Note: this table must be kept in sorted order, since it is traversed
106 * according to both Java keycode and X keysym. There are a number of
107 * keycodes that map to more than one corresponding keysym, and we need
108 * to choose the right one. Unfortunately, there are some keysyms that
109 * can map to more than one keycode, depending on what kind of keyboard
889 event->xkey.keycode, 0);
890 }else{
891 *keysym = keycodeToKeysym(event->xkey.display,
892 event->xkey.keycode, 1);
893 }
894 }
895 }
896
897 /* Called from handleKeyEvent.
898 * The purpose of this function is to make some adjustments to keysyms
899 * that have been found to be necessary when the NumLock mask is set.
900 * They come from various bug fixes and rearchitectures.
901 * This function is meant to be called when
902 * (event->xkey.state & awt_NumLockMask) is TRUE.
903 */
904 static void
905 handleKeyEventWithNumLockMask(XEvent *event, KeySym *keysym)
906 {
907 KeySym originalKeysym = *keysym;
908
909 #if !defined(__linux__) && !defined(MACOSX)
910 /* The following code on Linux will cause the keypad keys
911 * not to echo on JTextField when the NumLock is on. The
912 * keysyms will be 0, because the last parameter 2 is not defined.
913 * See Xlib Programming Manual, O'Reilly & Associates, Section
914 * 9.1.5 "Other Keyboard-handling Routines", "The meaning of
915 * the keysym list beyond the first two (unmodified, Shift or
916 * Shift Lock) is not defined."
917 */
918
919 /* Translate again with NumLock as modifier. */
920 /* ECH - I wonder why we think that NumLock corresponds to 2?
921 On Linux, we've seen xmodmap -pm yield mod2 as NumLock,
922 but I don't know that it will be for every configuration.
923 Perhaps using the index (modn in awt_MToolkit.c:setup_modifier_map)
924 would be more correct.
925 */
926 *keysym = keycodeToKeysym(event->xkey.display,
927 event->xkey.keycode, 2);
928 if (originalKeysym != *keysym) {
929 DTRACE_PRINTLN3("%s originalKeysym=0x%x, keysym=0x%x",
|
1 /*
2 * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
69 /*
70 * Two osf keys are not defined in standard keysym.h,
71 * /Xm/VirtKeys.h, or HPkeysym.h, so I added them below.
72 * I found them in /usr/openwin/lib/X11/XKeysymDB
73 */
74 #ifndef osfXK_Prior
75 #define osfXK_Prior 0x1004FF55
76 #endif
77 #ifndef osfXK_Next
78 #define osfXK_Next 0x1004FF56
79 #endif
80
81 jfieldID windowID;
82 jfieldID drawStateID;
83 jfieldID targetID;
84 jfieldID graphicsConfigID;
85
86 extern jobject currentX11InputMethodInstance;
87 extern Boolean awt_x11inputmethod_lookupString(XKeyPressedEvent *, KeySym *);
88 Boolean awt_UseType4Patch = False;
89 Boolean awt_ServerDetected = False;
90 Boolean awt_XKBDetected = False;
91 Boolean awt_IsXsun = False;
92 Boolean awt_UseXKB = False;
93
94 typedef struct KEYMAP_ENTRY {
95 jint awtKey;
96 KeySym x11Key;
97 Boolean mapsToUnicodeChar;
98 jint keyLocation;
99 } KeymapEntry;
100
101 /* NB: XK_R? keysyms are for Type 4 keyboards.
102 * The corresponding XK_F? keysyms are for Type 5
103 *
104 * Note: this table must be kept in sorted order, since it is traversed
105 * according to both Java keycode and X keysym. There are a number of
106 * keycodes that map to more than one corresponding keysym, and we need
107 * to choose the right one. Unfortunately, there are some keysyms that
108 * can map to more than one keycode, depending on what kind of keyboard
888 event->xkey.keycode, 0);
889 }else{
890 *keysym = keycodeToKeysym(event->xkey.display,
891 event->xkey.keycode, 1);
892 }
893 }
894 }
895
896 /* Called from handleKeyEvent.
897 * The purpose of this function is to make some adjustments to keysyms
898 * that have been found to be necessary when the NumLock mask is set.
899 * They come from various bug fixes and rearchitectures.
900 * This function is meant to be called when
901 * (event->xkey.state & awt_NumLockMask) is TRUE.
902 */
903 static void
904 handleKeyEventWithNumLockMask(XEvent *event, KeySym *keysym)
905 {
906 KeySym originalKeysym = *keysym;
907
908 #if !defined(__linux__)
909 /* The following code on Linux will cause the keypad keys
910 * not to echo on JTextField when the NumLock is on. The
911 * keysyms will be 0, because the last parameter 2 is not defined.
912 * See Xlib Programming Manual, O'Reilly & Associates, Section
913 * 9.1.5 "Other Keyboard-handling Routines", "The meaning of
914 * the keysym list beyond the first two (unmodified, Shift or
915 * Shift Lock) is not defined."
916 */
917
918 /* Translate again with NumLock as modifier. */
919 /* ECH - I wonder why we think that NumLock corresponds to 2?
920 On Linux, we've seen xmodmap -pm yield mod2 as NumLock,
921 but I don't know that it will be for every configuration.
922 Perhaps using the index (modn in awt_MToolkit.c:setup_modifier_map)
923 would be more correct.
924 */
925 *keysym = keycodeToKeysym(event->xkey.display,
926 event->xkey.keycode, 2);
927 if (originalKeysym != *keysym) {
928 DTRACE_PRINTLN3("%s originalKeysym=0x%x, keysym=0x%x",
|