/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* Note that the contents of this file were taken from canvas.c
* in the old motif-based AWT.
*/
#ifdef HEADLESS
#endif
#include <ctype.h>
#include <jvm.h>
#include <jni.h>
#include <jlong.h>
#include <jni_util.h>
#include "sun_awt_X11_XWindow.h"
#include "awt_p.h"
#include "awt_GraphicsEnv.h"
#include "awt_AWTEvent.h"
#define XK_KATAKANA
/*
* #include <X11/HPkeysym.h> HP vendor-specific
* I checked HPkeysym.h into the workspace because although
* I think it will ship with X11R6.4.2 (and later) on Linux,
* it doesn't seem to be in Solaris 9 Update 2.
*
* This is done not only for the hp keysyms, but also to
* give us the osf keysyms that are also defined in HPkeysym.h.
* However, HPkeysym.h is missing a couple of osf keysyms,
* so I have #defined them below.
*/
#include "HPkeysym.h" /* HP vendor-specific */
#include "java_awt_event_KeyEvent.h"
#include "java_awt_event_InputEvent.h"
#include "java_awt_event_MouseEvent.h"
#include "java_awt_event_MouseWheelEvent.h"
#include "java_awt_AWTEvent.h"
/*
* Two osf keys are not defined in standard keysym.h,
* /Xm/VirtKeys.h, or HPkeysym.h, so I added them below.
*/
#ifndef osfXK_Prior
#endif
#ifndef osfXK_Next
#endif
extern jobject currentX11InputMethodInstance;
/* how about HEADLESS */
typedef struct KEYMAP_ENTRY {
} KeymapEntry;
/* NB: XK_R? keysyms are for Type 4 keyboards.
* The corresponding XK_F? keysyms are for Type 5
*
* Note: this table must be kept in sorted order, since it is traversed
* according to both Java keycode and X keysym. There are a number of
* keycodes that map to more than one corresponding keysym, and we need
* to choose the right one. Unfortunately, there are some keysyms that
* can map to more than one keycode, depending on what kind of keyboard
* is in use (e.g. F11 and F12).
*/
{
/* TTY Function keys */
{java_awt_event_KeyEvent_VK_BACK_SPACE, XK_BackSpace, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_TAB, XK_ISO_Left_Tab, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_ENTER, XK_Linefeed, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_SCROLL_LOCK, XK_Scroll_Lock, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_SCROLL_LOCK, XK_F23, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_SCROLL_LOCK, XK_R3, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_ESCAPE, XK_Escape, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
/* Other vendor-specific versions of TTY Function keys */
{java_awt_event_KeyEvent_VK_BACK_SPACE, osfXK_BackSpace, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_CLEAR, osfXK_Clear, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_ESCAPE, osfXK_Escape, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
/* Modifier keys */
{java_awt_event_KeyEvent_VK_CONTROL, XK_Control_L, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_LEFT},
{java_awt_event_KeyEvent_VK_CONTROL, XK_Control_R, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_RIGHT},
{java_awt_event_KeyEvent_VK_CAPS_LOCK, XK_Caps_Lock, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
/* Misc Functions */
{java_awt_event_KeyEvent_VK_PRINTSCREEN, XK_Print, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_PRINTSCREEN, XK_F22, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_PRINTSCREEN, XK_R2, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_CANCEL, XK_Cancel, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_NUM_LOCK, XK_Num_Lock, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
/* Other vendor-specific versions of Misc Functions */
{java_awt_event_KeyEvent_VK_CANCEL, osfXK_Cancel, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_HELP, osfXK_Help, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
/* Rectangular Navigation Block */
{java_awt_event_KeyEvent_VK_PAGE_UP, XK_Page_Up, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_PAGE_UP, XK_Prior, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_PAGE_DOWN, XK_Page_Down, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_PAGE_DOWN, XK_Next, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_PAGE_DOWN, XK_R15, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_INSERT, XK_Insert, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DELETE, XK_Delete, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
/* Keypad equivalents of Rectangular Navigation Block */
{java_awt_event_KeyEvent_VK_PAGE_UP, XK_KP_Page_Up, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
{java_awt_event_KeyEvent_VK_PAGE_UP, XK_KP_Prior, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
{java_awt_event_KeyEvent_VK_PAGE_DOWN, XK_KP_Page_Down, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
{java_awt_event_KeyEvent_VK_PAGE_DOWN, XK_KP_Next, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
{java_awt_event_KeyEvent_VK_INSERT, XK_KP_Insert, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
{java_awt_event_KeyEvent_VK_DELETE, XK_KP_Delete, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
/* Other vendor-specific Rectangular Navigation Block */
{java_awt_event_KeyEvent_VK_PAGE_UP, osfXK_PageUp, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_PAGE_UP, osfXK_Prior, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_PAGE_DOWN, osfXK_PageDown, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_PAGE_DOWN, osfXK_Next, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_END, osfXK_EndLine, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_INSERT, osfXK_Insert, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DELETE, osfXK_Delete, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
/* Triangular Navigation Block */
/* Keypad equivalents of Triangular Navigation Block */
{java_awt_event_KeyEvent_VK_KP_LEFT, XK_KP_Left, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
{java_awt_event_KeyEvent_VK_KP_RIGHT, XK_KP_Right, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
{java_awt_event_KeyEvent_VK_KP_DOWN, XK_KP_Down, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
/* Other vendor-specific Triangular Navigation Block */
{java_awt_event_KeyEvent_VK_LEFT, osfXK_Left, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_RIGHT, osfXK_Right, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DOWN, osfXK_Down, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
/* Remaining Cursor control & motion */
{java_awt_event_KeyEvent_VK_BEGIN, XK_KP_Begin, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
{java_awt_event_KeyEvent_VK_EXCLAMATION_MARK, XK_exclam, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_QUOTEDBL, XK_quotedbl, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_NUMBER_SIGN, XK_numbersign, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DOLLAR, XK_dollar, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_AMPERSAND, XK_ampersand, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_QUOTE, XK_apostrophe, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_LEFT_PARENTHESIS, XK_parenleft, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_RIGHT_PARENTHESIS, XK_parenright, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_ASTERISK, XK_asterisk, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_PERIOD, XK_period, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_SEMICOLON, XK_semicolon, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_GREATER, XK_greater, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_OPEN_BRACKET, XK_bracketleft, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_BACK_SLASH, XK_backslash, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_CLOSE_BRACKET, XK_bracketright, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_CIRCUMFLEX, XK_asciicircum, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_UNDERSCORE, XK_underscore, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_BACK_QUOTE, XK_grave, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_BRACELEFT, XK_braceleft, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_BRACERIGHT, XK_braceright, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_INVERTED_EXCLAMATION_MARK, XK_exclamdown, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
/* Remaining Numeric Keypad Keys */
{java_awt_event_KeyEvent_VK_EQUALS, XK_KP_Equal, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
{java_awt_event_KeyEvent_VK_MULTIPLY, XK_KP_Multiply, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
{java_awt_event_KeyEvent_VK_SEPARATOR, XK_KP_Separator, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
{java_awt_event_KeyEvent_VK_SUBTRACT, XK_KP_Subtract, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
{java_awt_event_KeyEvent_VK_DECIMAL, XK_KP_Decimal, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
{java_awt_event_KeyEvent_VK_DIVIDE, XK_KP_Divide, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
/* Function Keys */
/* Sun vendor-specific version of F11 and F12 */
/* X11 keysym names for input method related keys don't always
* match keytop engravings or Java virtual key names, so here we
* only map constants that we've found on real keyboards.
*/
/* Type 5c Japanese keyboard: kakutei */
{java_awt_event_KeyEvent_VK_ACCEPT, XK_Execute, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
/* Type 5c Japanese keyboard: henkan */
{java_awt_event_KeyEvent_VK_CONVERT, XK_Kanji, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
/* Type 5c Japanese keyboard: nihongo */
{java_awt_event_KeyEvent_VK_INPUT_METHOD_ON_OFF, XK_Henkan_Mode, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
/* VK_KANA_LOCK is handled separately because it generates the
* same keysym as ALT_GRAPH in spite of its different behavior.
*/
{java_awt_event_KeyEvent_VK_COMPOSE, XK_Multi_key, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_ALT_GRAPH, XK_Mode_switch, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
/* Editing block */
/* Sun vendor-specific versions for editing block */
{java_awt_event_KeyEvent_VK_AGAIN, SunXK_Again, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_UNDO, SunXK_Undo, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_COPY, SunXK_Copy, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_PASTE, SunXK_Paste, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_FIND, SunXK_Find, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_PROPS, SunXK_Props, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_STOP, SunXK_Stop, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
/* Apollo (HP) vendor-specific versions for editing block */
{java_awt_event_KeyEvent_VK_PASTE, apXK_Paste, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
/* Other vendor-specific versions for editing block */
{java_awt_event_KeyEvent_VK_COPY, osfXK_Copy, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_PASTE, osfXK_Paste, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_UNDO, osfXK_Undo, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
/* Dead key mappings (for European keyboards) */
{java_awt_event_KeyEvent_VK_DEAD_GRAVE, XK_dead_grave, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_ACUTE, XK_dead_acute, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_CIRCUMFLEX, XK_dead_circumflex, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_TILDE, XK_dead_tilde, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_MACRON, XK_dead_macron, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_BREVE, XK_dead_breve, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_ABOVEDOT, XK_dead_abovedot, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_DIAERESIS, XK_dead_diaeresis, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_ABOVERING, XK_dead_abovering, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_DOUBLEACUTE, XK_dead_doubleacute, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_CARON, XK_dead_caron, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_CEDILLA, XK_dead_cedilla, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_OGONEK, XK_dead_ogonek, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_IOTA, XK_dead_iota, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_VOICED_SOUND, XK_dead_voiced_sound, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_SEMIVOICED_SOUND, XK_dead_semivoiced_sound, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
/* Sun vendor-specific dead key mappings (for European keyboards) */
{java_awt_event_KeyEvent_VK_DEAD_GRAVE, SunXK_FA_Grave, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_CIRCUMFLEX, SunXK_FA_Circum, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_TILDE, SunXK_FA_Tilde, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_ACUTE, SunXK_FA_Acute, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_DIAERESIS, SunXK_FA_Diaeresis, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_CEDILLA, SunXK_FA_Cedilla, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
/* DEC vendor-specific dead key mappings (for European keyboards) */
{java_awt_event_KeyEvent_VK_DEAD_ABOVERING, DXK_ring_accent, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_CIRCUMFLEX, DXK_circumflex_accent, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_CEDILLA, DXK_cedilla_accent, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_ACUTE, DXK_acute_accent, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_GRAVE, DXK_grave_accent, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_TILDE, DXK_tilde, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_DIAERESIS, DXK_diaeresis, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
/* Other vendor-specific dead key mappings (for European keyboards) */
{java_awt_event_KeyEvent_VK_DEAD_ACUTE, hpXK_mute_acute, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_GRAVE, hpXK_mute_grave, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_CIRCUMFLEX, hpXK_mute_asciicircum, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_DIAERESIS, hpXK_mute_diaeresis, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_DEAD_TILDE, hpXK_mute_asciitilde, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
{java_awt_event_KeyEvent_VK_UNDEFINED, NoSymbol, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN}
};
static Boolean
{
int32_t i;
// Solaris doesn't let you swap keyboards without rebooting,
// so there's no need to check for the kana lock key more than once.
if (haveResult) {
return result;
}
// There's no direct way to determine whether the keyboard has
// a kana lock key. From available keyboard mapping tables, it looks
// like only keyboards with the kana lock key can produce keysyms
// for kana characters. So, as an indirect test, we check for those.
keySyms = XGetKeyboardMapping(awt_display, minKeyCode, maxKeyCode - minKeyCode + 1, &keySymsPerKeyCode);
kanaCount++;
}
}
// use a (somewhat arbitrary) minimum so we don't get confused by a stray function key
haveResult = TRUE;
return result;
}
static void
{
int32_t i;
// Solaris uses XK_Mode_switch for both the non-locking AltGraph
// and the locking Kana key, but we want to keep them separate for
// KeyEvent.
return;
}
for (i = 0;
i++)
{
return;
}
}
}
{
int32_t i;
return XK_Mode_switch;
}
for (i = 0; keymapTable[i].awtKey != 0; i++) {
return keymapTable[i].x11Key;
}
}
return NoSymbol;
}
/* Called from handleKeyEvent. The purpose of this function is
* to check for a list of vendor-specific keysyms, most of which
* have values greater than 0xFFFF. Most of these keys don't map
* to unicode characters, but some do.
*
* For keys that don't map to unicode characters, the keysym
* is irrelevant at this point. We set the keysym to zero
* to ensure that the switch statement immediately below
* this function call (in adjustKeySym) won't incorrectly act
* on them after the high bits are stripped off.
*
* For keys that do map to unicode characters, we change the keysym
* to the equivalent that is < 0xFFFF
*/
static void
{
switch (*keysym) {
/* Apollo (HP) vendor-specific from <X11/ap_keysym.h> */
case apXK_Copy:
case apXK_Cut:
case apXK_Paste:
/* DEC vendor-specific from <X11/DECkeysym.h> */
case DXK_ring_accent: /* syn usldead_ring */
case DXK_circumflex_accent:
case DXK_cedilla_accent: /* syn usldead_cedilla */
case DXK_acute_accent:
case DXK_grave_accent:
case DXK_tilde:
case DXK_diaeresis:
/* Sun vendor-specific from <X11/Sunkeysym.h> */
case SunXK_FA_Grave:
case SunXK_FA_Circum:
case SunXK_FA_Tilde:
case SunXK_FA_Acute:
case SunXK_FA_Diaeresis:
case SunXK_FA_Cedilla:
case SunXK_F36: /* Labeled F11 */
case SunXK_F37: /* Labeled F12 */
case SunXK_Props:
case SunXK_Copy:
case SunXK_Open:
case SunXK_Paste:
case SunXK_Cut:
/* Other vendor-specific from HPkeysym.h */
case hpXK_mute_acute: /* syn usldead_acute */
case hpXK_mute_grave: /* syn usldead_grave */
case hpXK_mute_asciicircum: /* syn usldead_asciicircum */
case hpXK_mute_diaeresis: /* syn usldead_diaeresis */
case hpXK_mute_asciitilde: /* syn usldead_asciitilde */
case osfXK_Copy:
case osfXK_Cut:
case osfXK_Paste:
case osfXK_PageUp:
case osfXK_PageDown:
case osfXK_EndLine:
case osfXK_Clear:
case osfXK_Left:
case osfXK_Up:
case osfXK_Right:
case osfXK_Down:
case osfXK_Prior:
case osfXK_Next:
case osfXK_Insert:
case osfXK_Undo:
case osfXK_Help:
*keysym = 0;
break;
/*
* The rest DO map to unicode characters, so translate them
*/
case osfXK_BackSpace:
*keysym = XK_BackSpace;
break;
case osfXK_Escape:
break;
case osfXK_Cancel:
break;
case osfXK_Delete:
break;
default:
break;
}
if (originalKeysym != *keysym) {
DTRACE_PRINTLN3("%s originalKeysym=0x%x, keysym=0x%x",
}
}
/* Called from handleKeyEvent.
* The purpose of this function is to adjust the keysym and XEvent
* keycode for a key event. This is basically a conglomeration of
* bugfixes that require these adjustments.
* Note that none of the keysyms in this function are less than 256.
*/
static void
{
/* We have seen bits set in the high two bytes on Linux,
* which prevents this switch statement from executing
* correctly. Strip off the high order bits.
*/
*keysym &= 0x0000FFFF;
switch (*keysym) {
case XK_ISO_Left_Tab: /* shift-tab on Linux */
break;
case XK_KP_Decimal:
*keysym = '.';
break;
case XK_KP_Add:
*keysym = '+';
break;
case XK_F24: /* NumLock off */
case XK_KP_Subtract: /* NumLock on */
*keysym = '-';
break;
case XK_F25: /* NumLock off */
case XK_KP_Divide: /* NumLock on */
*keysym = '/';
break;
case XK_F26: /* NumLock off */
case XK_KP_Multiply: /* NumLock on */
*keysym = '*';
break;
case XK_KP_Equal:
*keysym = '=';
break;
case XK_KP_0:
*keysym = '0';
break;
case XK_KP_1:
*keysym = '1';
break;
case XK_KP_2:
*keysym = '2';
break;
case XK_KP_3:
*keysym = '3';
break;
case XK_KP_4:
*keysym = '4';
break;
case XK_KP_5:
*keysym = '5';
break;
case XK_KP_6:
*keysym = '6';
break;
case XK_KP_7:
*keysym = '7';
break;
case XK_KP_8:
*keysym = '8';
break;
case XK_KP_9:
*keysym = '9';
break;
case XK_KP_Left: /* Bug 4350175 */
break;
case XK_KP_Up:
break;
case XK_KP_Right:
break;
case XK_KP_Down:
break;
case XK_KP_Home:
break;
case XK_KP_End:
break;
case XK_KP_Page_Up:
*keysym = XK_Page_Up;
break;
case XK_KP_Page_Down:
*keysym = XK_Page_Down;
break;
case XK_KP_Begin:
break;
case XK_KP_Insert:
break;
case XK_KP_Delete:
break;
case XK_KP_Enter:
*keysym = XK_Linefeed;
break;
default:
break;
}
if (originalKeysym != *keysym) {
DTRACE_PRINTLN2("In adjustKeySym: originalKeysym=0x%x, keysym=0x%x",
originalKeysym, *keysym);
}
DTRACE_PRINTLN2("In adjustKeySym: originalKeycode=0x%x, keycode=0x%x",
}
}
/*
* What a sniffer sez?
* Xsun and Xorg if NumLock is on do two thing different:
* keep Keypad key in different places of keysyms array and
* People say, it's right to use behavior and not Vendor tags to decide.
* Maybe. But why these tags were invented, then?
* TODO: use behavior, not tags. Maybe.
*/
static Boolean
if( awt_ServerDetected ) return awt_IsXsun;
{
awt_IsXsun = False;
return False;
}
// Now, it's Sun. It still may be Xorg though, eg on Solaris 10, x86.
// Today (2005), VendorRelease of Xorg is a Big Number unlike Xsun.
awt_IsXsun = False;
return False;
}
awt_IsXsun = True;
return True;
}
/*
* +kb or -kb ?
*/
static Boolean
if( !awt_XKBDetected ) {
/*
* NB: TODO: hope it will return False if XkbIgnoreExtension was called!
*/
}
return awt_UseXKB;
}
static Boolean
{
/*
* Xlib manual, ch 12.7 says, as a first rule for choice of keysym:
* The numlock modifier is on and the second KeySym is a keypad KeySym. In this case,
* if the Shift modifier is on, or if the Lock modifier is on and is interpreted as ShiftLock,
* then the first KeySym is used, otherwise the second KeySym is used.
*
* However, Xsun server does ignore ShiftLock and always takes 3-rd element from an array.
*
* So, is it a keypad keysym?
*/
return IsKeypadKey( XKeycodeToKeysym(event->xkey.display, event->xkey.keycode,(bsun && !bxkb ? 2 : 1) ) );
}
static void
}
/*
* In a next redesign, get rid of this code altogether.
*
*/
static void
{
return;
}
}else {
}
} else {
(awt_ModLockIsShiftLock)) ) { // it is interpreted as ShiftLock
}else{
}
}
}
/* Called from handleKeyEvent.
* The purpose of this function is to make some adjustments to keysyms
* that have been found to be necessary when the NumLock mask is set.
* They come from various bug fixes and rearchitectures.
* This function is meant to be called when
* (event->xkey.state & awt_NumLockMask) is TRUE.
*/
static void
{
/* The following code on Linux will cause the keypad keys
* not to echo on JTextField when the NumLock is on. The
* keysyms will be 0, because the last parameter 2 is not defined.
* See Xlib Programming Manual, O'Reilly & Associates, Section
* 9.1.5 "Other Keyboard-handling Routines", "The meaning of
* the keysym list beyond the first two (unmodified, Shift or
* Shift Lock) is not defined."
*/
/* Translate again with NumLock as modifier. */
/* ECH - I wonder why we think that NumLock corresponds to 2?
On Linux, we've seen xmodmap -pm yield mod2 as NumLock,
but I don't know that it will be for every configuration.
Perhaps using the index (modn in awt_MToolkit.c:setup_modifier_map)
would be more correct.
*/
if (originalKeysym != *keysym) {
DTRACE_PRINTLN3("%s originalKeysym=0x%x, keysym=0x%x",
"In handleKeyEventWithNumLockMask ifndef linux:",
originalKeysym, *keysym);
}
#endif
/* Note: the XK_R? key assignments are for Type 4 kbds */
switch (*keysym) {
case XK_R13:
break;
case XK_R14:
break;
case XK_R15:
break;
case XK_R10:
break;
case XK_R11:
break;
case XK_R12:
break;
case XK_R7:
break;
case XK_R8:
break;
case XK_R9:
break;
case XK_KP_Insert:
break;
case XK_KP_Delete:
*keysym = XK_KP_Decimal;
break;
case XK_R4:
break;
case XK_R5:
*keysym = XK_KP_Divide;
break;
case XK_R6:
*keysym = XK_KP_Multiply;
break;
/*
* Need the following keysym changes for Linux key releases.
* Sometimes the modifier state gets messed up, so we get a
* KP_Left when we should get a KP_4, for example.
* XK_KP_Insert and XK_KP_Delete were already handled above.
*/
case XK_KP_Left:
break;
case XK_KP_Up:
break;
case XK_KP_Right:
break;
case XK_KP_Down:
break;
case XK_KP_Home:
break;
case XK_KP_End:
break;
case XK_KP_Page_Up:
break;
case XK_KP_Page_Down:
break;
case XK_KP_Begin:
break;
default:
break;
}
if (originalKeysym != *keysym) {
DTRACE_PRINTLN3("%s originalKeysym=0x%x, keysym=0x%x",
}
}
/* This function is called as the keyChar parameter of a call to
* awt_post_java_key_event. It depends on being called after adjustKeySym.
*
* This function just handles a few values where we know that the
* keysym is not the same as the unicode value. For values that
* we don't handle explicitly, we just cast the keysym to a jchar.
* Most of the real mapping work that gets the correct keysym is handled
* in the mapping table, adjustKeySym, etc.
*
* XXX
* Maybe we should enumerate the keysyms for which we have a mapping
* in the keyMap, but that don't map to unicode chars, and return
* CHAR_UNDEFINED? Then use the buffer value from XLookupString
* instead of the keysym as the keychar when posting. Then we don't
* need to test using mapsToUnicodeChar. That way, we would post keyTyped
* for all the chars that generate unicode chars, including LATIN2-4, etc.
* Note: what does the buffer from XLookupString contain when
* the character is a non-printable unicode character like Cancel or Delete?
*/
switch (keysym) {
case XK_BackSpace:
case XK_Tab:
case XK_Linefeed:
case XK_Escape:
case XK_Delete:
/* Strip off highorder bits defined in xkeysymdef.h
* I think doing this converts them to values that
* we can cast to jchars and use as java keychars.
*/
break;
case XK_Return:
break;
case XK_Cancel:
break;
default:
break;
}
DTRACE_PRINTLN3("%s originalKeysym=0x%x, keysym=0x%x",
}
return unicodeValue;
}
void
{
} /* awt_post_java_key_event() */
return keycode;
}
/*printf("Java_sun_awt_X11_XWindow_haveCurrentX11InputMethodInstance: %s\n", (currentX11InputMethodInstance==NULL? "NULL":" notnull"));
*/
}
/* keysymArray (and testbuf[]) have dimension 2 because we put there two
* perhaps different values of keysyms.
* XXX: not anymore at the moment, but I'll still keep them as arrays
* for a while. If in the course of testing we will be satisfied with
* a current single result from awt_x11inputmethod_lookupString, we'll
* change this.
*/
testbuf[1]=0;
}
extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
/*
* Class: Java_sun_awt_X11_XWindow_getNativeColor
* Method: getNativeColor
*/
/* fire warning because JNU_GetLongFieldAsPtr casts jlong to (void *) */
adata = (AwtGraphicsConfigDataPtr) JNU_GetLongFieldAsPtr(env, gc_object, x11GraphicsConfigIDs.aData);
}
/* syncTopLevelPos() is necessary to insure that the window manager has in
* fact moved us to our final position relative to the reParented WM window.
* We have noted a timing window which our shell has not been moved so we
* screw up the insets thinking they are 0,0. Wait (for a limited period of
* time to let the WM hava a chance to move us
*/
int32_t i = 0;
do {
XGetWindowAttributes( d, w, winAttr );
/* Sometimes we get here before the WM has updated the
** window data struct with the correct position. Loop
** until we get a non-zero position.
*/
break;
}
else {
/* What we really want here is to sync with the WM,
** but there's no explicit way to do this, so we
** call XSync for a delay.
*/
}
} while (i++ < 50);
}
{
unsigned int ignore_uint=0;
do {
&root,
&parent,
&ignore_uint);
return prev_window;
}
}
static void
// window is event->xreparent.window
// (screenX, screenY) is (0,0) of the reparented window
// converted to screen coordinates.
}
(JNIEnv *env, jclass clazz, jlong window, jlong left, jlong top, jlong right, jlong bottom, jlong border) {
(int*) jlong_to_ptr(left),
(int*) jlong_to_ptr(top),
(int*) jlong_to_ptr(right),
(int*) jlong_to_ptr(bottom),
(int*) jlong_to_ptr(border));
}
static void
*x = winAttr.x;
*y = winAttr.y;
}
}
size_hints->x = (int)x;
size_hints->y = (int)y;
XFree((char*)size_hints);
}
{
}
}
}
return awt_getX11KeySym(keycode);
}