You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ap...@apache.org on 2008/01/23 12:31:19 UTC
svn commit: r614497 - in
/harmony/enhanced/classlib/trunk/modules/awt/src/main:
java/unix/org/apache/harmony/awt/wtk/linux/ native/gl/unix/
native/gl/unix/include/
Author: apetrenko
Date: Wed Jan 23 03:31:06 2008
New Revision: 614497
URL: http://svn.apache.org/viewvc?rev=614497&view=rev
Log:
Patch for HARMONY-4636 "[classlib][awt] Toolkit.getLockingKeyState() is not implemented on Linux"
Added:
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/unix/LockingKeys.cpp
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/unix/include/org_apache_harmony_awt_wtk_linux_LinuxWTK.h (with props)
Modified:
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/wtk/linux/LinuxWTK.java
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/unix/exports.txt
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/unix/makefile
Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/wtk/linux/LinuxWTK.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/wtk/linux/LinuxWTK.java?rev=614497&r1=614496&r2=614497&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/wtk/linux/LinuxWTK.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/wtk/linux/LinuxWTK.java Wed Jan 23 03:31:06 2008
@@ -29,6 +29,10 @@
public final class LinuxWTK extends WTK {
+ static {
+ System.loadLibrary("gl");
+ }
+
/**
* @see org.apache.harmony.awt.wtk.WTK#getGraphicsFactory()
*/
@@ -89,14 +93,9 @@
return null;
}
- public boolean getLockingState(int keyCode) {
- // TODO implement
- return false;
- }
+ public native boolean getLockingState(int keyCode);
- public void setLockingState(int keyCode, boolean on) {
- // TODO implement
- }
+ public native void setLockingState(int keyCode, boolean on);
private final LinuxWindowFactory windowFactory = new LinuxWindowFactory();
private final LinuxEventQueue eventQueue = new LinuxEventQueue(windowFactory);
Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/unix/LockingKeys.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/unix/LockingKeys.cpp?rev=614497&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/unix/LockingKeys.cpp (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/unix/LockingKeys.cpp Wed Jan 23 03:31:06 2008
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <X11/Xlib.h>
+#include <X11/XKBlib.h>
+#include <X11/keysym.h>
+#include <X11/extensions/XTest.h>
+#include "exceptions.h"
+#include "org_apache_harmony_awt_wtk_linux_LinuxWTK.h"
+
+#define CAPS_LOCK_MASK 0x00000001
+#define NUM_LOCK_MASK 0x00000002
+#define SCROLL_LOCK_MASK 0x00000004
+
+/*
+ * Class: org_apache_harmony_awt_wtk_linux_LinuxWTK
+ * Method: getLockingState
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_apache_harmony_awt_wtk_linux_LinuxWTK_getLockingState
+ (JNIEnv *env, jobject cls, jint keyCode){
+ Display *dpy = NULL;
+ unsigned int states = 0;
+
+ if ((dpy = XOpenDisplay (NULL)) == NULL) {
+ throwNewExceptionByName(env, "java/lang/UnsupportedOperationException",
+ "Cannot open display");
+ return 0;
+ }
+
+ if (XkbGetIndicatorState(dpy, XkbUseCoreKbd, &states) != Success) {
+ XCloseDisplay(dpy);
+ throwNewExceptionByName(env, "java/lang/UnsupportedOperationException",
+ "Error in reading keyboard indicator states");
+ return 0;
+ }
+
+ XCloseDisplay(dpy);
+
+ switch (keyCode)
+ {
+ case 20:
+ return (states & CAPS_LOCK_MASK);
+ case 144:
+ return (states & NUM_LOCK_MASK);
+ case 145:
+ return (states & SCROLL_LOCK_MASK);
+ default:
+ throwNewExceptionByName(env, "java/lang/IllegalArgumentException",
+ "Illegal argument");
+ }
+
+ return 0;
+}
+
+/*
+ * Class: org_apache_harmony_awt_wtk_linux_LinuxWTK
+ * Method: setLockingState
+ * Signature: (IZ)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_wtk_linux_LinuxWTK_setLockingState
+ (JNIEnv *env, jobject cls, jint keyCode, jboolean on)
+{
+ Display *dpy = NULL;
+ unsigned int states = 0;
+
+ if ((dpy = XOpenDisplay (NULL)) == NULL) {
+ throwNewExceptionByName(env, "java/lang/UnsupportedOperationException",
+ "Cannot open display");
+ return;
+ }
+
+ if (XkbGetIndicatorState(dpy, XkbUseCoreKbd, &states) != Success) {
+ XCloseDisplay(dpy);
+ throwNewExceptionByName(env, "java/lang/UnsupportedOperationException",
+ "Error in reading keyboard indicator states");
+ return;
+ }
+
+ KeyCode lock_key;
+ bool pressed;
+
+ switch (keyCode)
+ {
+ case 20:
+ lock_key = XKeysymToKeycode(dpy,XK_Caps_Lock);
+ pressed = states & CAPS_LOCK_MASK;
+ break;
+ case 144:
+ lock_key = XKeysymToKeycode(dpy,XK_Num_Lock);
+ pressed = states & NUM_LOCK_MASK;
+ break;
+ case 145:
+ lock_key = XKeysymToKeycode(dpy,XK_Scroll_Lock);
+ pressed = states & SCROLL_LOCK_MASK;
+ break;
+ default:
+ XCloseDisplay(dpy);
+ throwNewExceptionByName(env, "java/lang/IllegalArgumentException",
+ "Illegal argument");
+ return;
+ }
+
+ if ((!pressed && on) || (pressed && !on))
+ {
+ XTestFakeKeyEvent(dpy, lock_key, true, CurrentTime);
+ XTestFakeKeyEvent(dpy, lock_key, false, CurrentTime);
+ }
+
+ XCloseDisplay(dpy);
+}
+
Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/unix/exports.txt
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/unix/exports.txt?rev=614497&r1=614496&r2=614497&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/unix/exports.txt (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/unix/exports.txt Wed Jan 23 03:31:06 2008
@@ -41,3 +41,5 @@
Java_org_apache_harmony_awt_gl_linux_XBlitter_xorImage
Java_org_apache_harmony_awt_gl_linux_XBlitter_xorPixmap
Java_org_apache_harmony_awt_wtk_linux_XServerConnection_init
+Java_org_apache_harmony_awt_wtk_linux_LinuxWTK_getLockingState
+Java_org_apache_harmony_awt_wtk_linux_LinuxWTK_setLockingState
Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/unix/include/org_apache_harmony_awt_wtk_linux_LinuxWTK.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/unix/include/org_apache_harmony_awt_wtk_linux_LinuxWTK.h?rev=614497&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/unix/include/org_apache_harmony_awt_wtk_linux_LinuxWTK.h (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/unix/include/org_apache_harmony_awt_wtk_linux_LinuxWTK.h Wed Jan 23 03:31:06 2008
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class org_apache_harmony_awt_wtk_linux_LinuxWTK */
+
+#ifndef _Included_org_apache_harmony_awt_wtk_linux_LinuxWTK
+#define _Included_org_apache_harmony_awt_wtk_linux_LinuxWTK
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: org_apache_harmony_awt_wtk_linux_LinuxWTK
+ * Method: getLockingState
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_apache_harmony_awt_wtk_linux_LinuxWTK_getLockingState
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: org_apache_harmony_awt_wtk_linux_LinuxWTK
+ * Method: setLockingState
+ * Signature: (IZ)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_wtk_linux_LinuxWTK_setLockingState
+ (JNIEnv *, jobject, jint, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/unix/include/org_apache_harmony_awt_wtk_linux_LinuxWTK.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/unix/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/unix/makefile?rev=614497&r1=614496&r2=614497&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/unix/makefile (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/unix/makefile Wed Jan 23 03:31:06 2008
@@ -28,6 +28,7 @@
gl.o \
XBlitter.o \
XGraphics2D.o \
+ LockingKeys.o \
libpng.a
ifneq ($(HY_ZIP_API),true)