diff options
author | Mark Wielaard <mark@klomp.org> | 2007-01-03 22:51:07 +0000 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2007-01-03 22:51:07 +0000 |
commit | d4abda4fbba696e2845884445b9cd20e82627c18 (patch) | |
tree | 33432fcc879596902a4e8bd1d02a589d60cb9625 /native/jni | |
parent | 956a1df4a565bc70f1acbfedb89ad8b40a5c7eee (diff) | |
download | classpath-d4abda4fbba696e2845884445b9cd20e82627c18.tar.gz |
2007-01-03 Cameron McCormack <cam@mcc.id.au>
Fixes bug #29246
* java/awt/Toolkit.java (getLockingKeyState): Use AWTUtilities
isValidKey method. Throw UnsupportedOperationException on a valid
key (for which no locking state can be given).
* gnu/java/awt/AWTUtilities.java (isValidKey): New method.
* gnu/java/awt/peer/gtk/GtkToolkit.java (getLockingKeyState): New
method.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
(Java_gnu_java_awt_peer_gtk_GtkToolkit_getLockState): New method.
* include/gnu_java_awt_peer_gtk_GtkToolkit.h: Regenerated.
Diffstat (limited to 'native/jni')
-rw-r--r-- | native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c index 0f868eaed..dc36bdc2d 100644 --- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c +++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c @@ -1,5 +1,5 @@ /* gtktoolkit.c -- Native portion of GtkToolkit - Copyright (C) 1998, 1999, 2005 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2005, 2007 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -73,6 +73,12 @@ exception statement from your version. */ #define AWT_INFO_TEXT 25 #define AWT_NUM_COLORS 26 +#define VK_SHIFT 16 +#define VK_CONTROL 17 +#define VK_ALT 18 +#define VK_CAPS_LOCK 20 +#define VK_META 157 + struct state_table *cp_gtk_native_state_table; struct state_table *cp_gtk_native_global_ref_table; @@ -514,6 +520,53 @@ gdk_color_to_java_color (GdkColor gdk_color) return (jint) (0xff000000 | (red << 16) | (green << 8) | blue); } +JNIEXPORT jint JNICALL +Java_gnu_java_awt_peer_gtk_GtkToolkit_getLockState + (JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)), + jint key) +{ + gint coord; + GdkModifierType state, mask; + GdkWindow *root_window; + + gdk_threads_enter (); + + root_window = gdk_get_default_root_window (); + gdk_window_get_pointer (root_window, &coord, &coord, &state); + + switch (key) + { + case VK_SHIFT: + mask = GDK_SHIFT_MASK; + break; + case VK_CONTROL: + mask = GDK_CONTROL_MASK; + break; + case VK_ALT: + /* This is dubious, since MOD1 could have been mapped to something + other than ALT. */ + mask = GDK_MOD1_MASK; + break; +#if GTK_CHECK_VERSION(2, 10, 0) + case VK_META: + mask = GDK_META_MASK; + break; +#endif + case VK_CAPS_LOCK: + mask = GDK_LOCK_MASK; + break; + default: + mask = 0; + } + + gdk_threads_leave (); + + if (mask == 0) + return -1; + + return state & mask ? 1 : 0; +} + static gboolean post_set_running_flag (gpointer data __attribute__((unused))) { |