1 /*
2 * Copyright (c) 2002, 2014, 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
820 }
821 static Boolean
822 isKPevent(XEvent *event)
823 {
824 /*
825 * Xlib manual, ch 12.7 says, as a first rule for choice of keysym:
826 * The numlock modifier is on and the second KeySym is a keypad KeySym. In this case,
827 * if the Shift modifier is on, or if the Lock modifier is on and is interpreted as ShiftLock,
828 * then the first KeySym is used, otherwise the second KeySym is used.
829 *
830 * However, Xsun server does ignore ShiftLock and always takes 3-rd element from an array.
831 *
832 * So, is it a keypad keysym?
833 */
834 Boolean bsun = isXsunServer( event );
835 Boolean bxkb = isXKBenabled( event->xkey.display );
836 return IsKeypadKey( XKeycodeToKeysym(event->xkey.display, event->xkey.keycode,(bsun && !bxkb ? 2 : 1) ) );
837 }
838 static void
839 dumpKeysymArray(XEvent *event) {
840 printf(" 0x%X\n",XKeycodeToKeysym(event->xkey.display, event->xkey.keycode, 0));
841 printf(" 0x%X\n",XKeycodeToKeysym(event->xkey.display, event->xkey.keycode, 1));
842 printf(" 0x%X\n",XKeycodeToKeysym(event->xkey.display, event->xkey.keycode, 2));
843 printf(" 0x%X\n",XKeycodeToKeysym(event->xkey.display, event->xkey.keycode, 3));
844 }
845 /*
846 * In a next redesign, get rid of this code altogether.
847 *
848 */
849 static void
850 handleKeyEventWithNumLockMask_New(XEvent *event, KeySym *keysym)
851 {
852 KeySym originalKeysym = *keysym;
853 if( !isKPevent( event ) ) {
854 return;
855 }
856 if( isXsunServer( event ) && !awt_UseXKB) {
857 if( (event->xkey.state & ShiftMask) ) { // shift modifier is on
858 *keysym = XKeycodeToKeysym(event->xkey.display,
859 event->xkey.keycode, 3);
860 }else {
861 *keysym = XKeycodeToKeysym(event->xkey.display,
862 event->xkey.keycode, 2);
863 }
|
1 /*
2 * Copyright (c) 2002, 2016, 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
820 }
821 static Boolean
822 isKPevent(XEvent *event)
823 {
824 /*
825 * Xlib manual, ch 12.7 says, as a first rule for choice of keysym:
826 * The numlock modifier is on and the second KeySym is a keypad KeySym. In this case,
827 * if the Shift modifier is on, or if the Lock modifier is on and is interpreted as ShiftLock,
828 * then the first KeySym is used, otherwise the second KeySym is used.
829 *
830 * However, Xsun server does ignore ShiftLock and always takes 3-rd element from an array.
831 *
832 * So, is it a keypad keysym?
833 */
834 Boolean bsun = isXsunServer( event );
835 Boolean bxkb = isXKBenabled( event->xkey.display );
836 return IsKeypadKey( XKeycodeToKeysym(event->xkey.display, event->xkey.keycode,(bsun && !bxkb ? 2 : 1) ) );
837 }
838 static void
839 dumpKeysymArray(XEvent *event) {
840 printf(" 0x%X\n", (unsigned int) XKeycodeToKeysym(event->xkey.display, event->xkey.keycode, 0));
841 printf(" 0x%X\n", (unsigned int) XKeycodeToKeysym(event->xkey.display, event->xkey.keycode, 1));
842 printf(" 0x%X\n", (unsigned int) XKeycodeToKeysym(event->xkey.display, event->xkey.keycode, 2));
843 printf(" 0x%X\n", (unsigned int) XKeycodeToKeysym(event->xkey.display, event->xkey.keycode, 3));
844 }
845 /*
846 * In a next redesign, get rid of this code altogether.
847 *
848 */
849 static void
850 handleKeyEventWithNumLockMask_New(XEvent *event, KeySym *keysym)
851 {
852 KeySym originalKeysym = *keysym;
853 if( !isKPevent( event ) ) {
854 return;
855 }
856 if( isXsunServer( event ) && !awt_UseXKB) {
857 if( (event->xkey.state & ShiftMask) ) { // shift modifier is on
858 *keysym = XKeycodeToKeysym(event->xkey.display,
859 event->xkey.keycode, 3);
860 }else {
861 *keysym = XKeycodeToKeysym(event->xkey.display,
862 event->xkey.keycode, 2);
863 }
|