Bug 29246 - Toolkit.getLockingKeyState(int) not implemented
Summary: Toolkit.getLockingKeyState(int) not implemented
Status: RESOLVED FIXED
Alias: None
Product: classpath
Classification: Unclassified
Component: awt (show other bugs)
Version: unspecified
: P3 normal
Target Milestone: 0.94
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-27 01:10 UTC by Cameron McCormack
Modified: 2007-01-03 23:19 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Patch to implement Toolkit.getLockingKeyState(int) for GTK+ peers. (2.10 KB, patch)
2006-09-27 01:16 UTC, Cameron McCormack
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Cameron McCormack 2006-09-27 01:10:16 UTC
The java.awt.Toolkit.getLockingKeyState(int) method is not implemented.  The stub method also throws IllegalArgumentException when it should be throwing UnsupportedOperationException, for key codes that are valid KeyEvent.VK_* values but cannot have their locking state inspected.

This method is required for Batik's DOM UIEvents to function properly.
Comment 1 Cameron McCormack 2006-09-27 01:16:16 UTC
Created attachment 12334 [details]
Patch to implement Toolkit.getLockingKeyState(int) for GTK+ peers.

This patch fixes the exception throwing behaviour of Toolkit.getLockingKeyState and implements actual locking key state inspection for GTK+ peers in GtkToolkit.

One slightly dodgy thing is that the GDK_MOD1_MASK bit is checked for when the state of the Alt key is requested.  Most of the time, this will be right, but under X this could be remapped.  I guess some X specific code should be used to look up the modifier key mappings.  (This would also have the benefit of exposing other locking keys, like Num, Kana, etc.)

It would be good if the VK_* #defines in gnu_java_awt_peer_gtk_GtkToolkit.c were separated out into a .h file so that they need not be duplicated in GtkToolkit.c.

Also, the patch is completely untested, since I've screwed up my installed VMs.  It does compile, though. :)
Comment 2 Cameron McCormack 2006-10-15 07:13:21 UTC
Ok, I've tested this patch now and it works for me.  My papers are in, so feel free to test/commit. :)  (And bug 29014, too...)
Comment 3 cvs-commit@developer.classpath.org 2007-01-03 22:51:26 UTC
Subject: Bug 29246

CVSROOT:	/cvsroot/classpath
Module name:	classpath
Changes by:	Mark Wielaard <mark>	07/01/03 22:51:07

Modified files:
	.              : ChangeLog 
	java/awt       : Toolkit.java 
	gnu/java/awt   : AWTUtilities.java 
	gnu/java/awt/peer/gtk: GtkToolkit.java 
	native/jni/gtk-peer: gnu_java_awt_peer_gtk_GtkToolkit.c 
	include        : gnu_java_awt_peer_gtk_GtkToolkit.h 

Log message:
	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.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpath&r1=1.9039&r2=1.9040
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/Toolkit.java?cvsroot=classpath&r1=1.48&r2=1.49
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/AWTUtilities.java?cvsroot=classpath&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/GtkToolkit.java?cvsroot=classpath&r1=1.98&r2=1.99
http://cvs.savannah.gnu.org/viewcvs/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c?cvsroot=classpath&r1=1.30&r2=1.31
http://cvs.savannah.gnu.org/viewcvs/classpath/include/gnu_java_awt_peer_gtk_GtkToolkit.h?cvsroot=classpath&r1=1.14&r2=1.15



Comment 4 Mark Wielaard 2007-01-03 23:19:35 UTC
Patch checked in