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
846
847 static Boolean
848 isKPevent(XEvent *event)
849 {
850 /*
851 * Xlib manual, ch 12.7 says, as a first rule for choice of keysym:
852 * The numlock modifier is on and the second KeySym is a keypad KeySym. In this case,
853 * if the Shift modifier is on, or if the Lock modifier is on and is interpreted as ShiftLock,
854 * then the first KeySym is used, otherwise the second KeySym is used.
855 *
856 * However, Xsun server does ignore ShiftLock and always takes 3-rd element from an array.
857 *
858 * So, is it a keypad keysym?
859 */
860 Boolean bsun = isXsunServer( event );
861 Boolean bxkb = isXKBenabled( event->xkey.display );
862 return IsKeypadKey( keycodeToKeysym(event->xkey.display, event->xkey.keycode,(bsun && !bxkb ? 2 : 1) ) );
863 }
864 static void
865 dumpKeysymArray(XEvent *event) {
866 printf(" 0x%X\n",keycodeToKeysym(event->xkey.display, event->xkey.keycode, 0));
867 printf(" 0x%X\n",keycodeToKeysym(event->xkey.display, event->xkey.keycode, 1));
868 printf(" 0x%X\n",keycodeToKeysym(event->xkey.display, event->xkey.keycode, 2));
869 printf(" 0x%X\n",keycodeToKeysym(event->xkey.display, event->xkey.keycode, 3));
870 }
871 /*
872 * In a next redesign, get rid of this code altogether.
873 *
874 */
875 static void
876 handleKeyEventWithNumLockMask_New(XEvent *event, KeySym *keysym)
877 {
878 KeySym originalKeysym = *keysym;
879 if( !isKPevent( event ) ) {
880 return;
881 }
882 if( isXsunServer( event ) && !awt_UseXKB) {
883 if( (event->xkey.state & ShiftMask) ) { // shift modifier is on
884 *keysym = keycodeToKeysym(event->xkey.display,
885 event->xkey.keycode, 3);
886 }else {
887 *keysym = keycodeToKeysym(event->xkey.display,
888 event->xkey.keycode, 2);
889 }
|
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
846
847 static Boolean
848 isKPevent(XEvent *event)
849 {
850 /*
851 * Xlib manual, ch 12.7 says, as a first rule for choice of keysym:
852 * The numlock modifier is on and the second KeySym is a keypad KeySym. In this case,
853 * if the Shift modifier is on, or if the Lock modifier is on and is interpreted as ShiftLock,
854 * then the first KeySym is used, otherwise the second KeySym is used.
855 *
856 * However, Xsun server does ignore ShiftLock and always takes 3-rd element from an array.
857 *
858 * So, is it a keypad keysym?
859 */
860 Boolean bsun = isXsunServer( event );
861 Boolean bxkb = isXKBenabled( event->xkey.display );
862 return IsKeypadKey( keycodeToKeysym(event->xkey.display, event->xkey.keycode,(bsun && !bxkb ? 2 : 1) ) );
863 }
864 static void
865 dumpKeysymArray(XEvent *event) {
866 printf(" 0x%lX\n", (unsigned long)keycodeToKeysym(event->xkey.display, event->xkey.keycode, 0));
867 printf(" 0x%lX\n", (unsigned long)keycodeToKeysym(event->xkey.display, event->xkey.keycode, 1));
868 printf(" 0x%lX\n", (unsigned long)keycodeToKeysym(event->xkey.display, event->xkey.keycode, 2));
869 printf(" 0x%lX\n", (unsigned long)keycodeToKeysym(event->xkey.display, event->xkey.keycode, 3));
870 }
871 /*
872 * In a next redesign, get rid of this code altogether.
873 *
874 */
875 static void
876 handleKeyEventWithNumLockMask_New(XEvent *event, KeySym *keysym)
877 {
878 KeySym originalKeysym = *keysym;
879 if( !isKPevent( event ) ) {
880 return;
881 }
882 if( isXsunServer( event ) && !awt_UseXKB) {
883 if( (event->xkey.state & ShiftMask) ) { // shift modifier is on
884 *keysym = keycodeToKeysym(event->xkey.display,
885 event->xkey.keycode, 3);
886 }else {
887 *keysym = keycodeToKeysym(event->xkey.display,
888 event->xkey.keycode, 2);
889 }
|