Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Kovatch2010-11-17 17:51:18 +0000
committerScott Kovatch2010-11-17 17:51:18 +0000
commit2291cc53864300688c3a58c6df5ee259c93044d9 (patch)
treeaf68be79337ce3155e3db6cbc1cc9159f28fec60
parent0596cb1449efda4b7041de386646bd25379c1f2a (diff)
downloadeclipse.platform.swt-2291cc53864300688c3a58c6df5ee259c93044d9.tar.gz
eclipse.platform.swt-2291cc53864300688c3a58c6df5ee259c93044d9.tar.xz
eclipse.platform.swt-2291cc53864300688c3a58c6df5ee259c93044d9.zip
329511 - make keyboard post call conditionally for 10.5.
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/CoreGraphicsFull.bridgesupport.extras6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java26
6 files changed, 44 insertions, 12 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c
index 058da5bf4f..69e427ef82 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c
@@ -1941,6 +1941,18 @@ JNIEXPORT jint JNICALL OS_NATIVE(CGPoint_1sizeof)
}
#endif
+#ifndef NO_CGPostKeyboardEvent
+JNIEXPORT jint JNICALL OS_NATIVE(CGPostKeyboardEvent)
+ (JNIEnv *env, jclass that, jshort arg0, jshort arg1, jboolean arg2)
+{
+ jint rc = 0;
+ OS_NATIVE_ENTER(env, that, CGPostKeyboardEvent_FUNC);
+ rc = (jint)CGPostKeyboardEvent((CGCharCode)arg0, (CGKeyCode)arg1, (boolean_t)arg2);
+ OS_NATIVE_EXIT(env, that, CGPostKeyboardEvent_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO_CGRect_1sizeof
JNIEXPORT jint JNICALL OS_NATIVE(CGRect_1sizeof)
(JNIEnv *env, jclass that)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c
index d8258f8987..9cbb60e852 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c
@@ -14,8 +14,8 @@
#ifdef NATIVE_STATS
-int OS_nativeFunctionCount = 618;
-int OS_nativeFunctionCallCount[618];
+int OS_nativeFunctionCount = 619;
+int OS_nativeFunctionCallCount[619];
char * OS_nativeFunctionNames[] = {
"ATSFontActivateFromFileReference",
"AcquireRootMenu",
@@ -141,6 +141,7 @@ char * OS_nativeFunctionNames[] = {
"CGPathMoveToPoint",
"CGPathRelease",
"CGPoint_1sizeof",
+ "CGPostKeyboardEvent",
"CGRect_1sizeof",
"CGSetLocalEventsFilterDuringSuppressionState",
"CGSetLocalEventsSuppressionInterval",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h
index 291c150334..3bf2e82b36 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h
@@ -149,6 +149,7 @@ typedef enum {
CGPathMoveToPoint_FUNC,
CGPathRelease_FUNC,
CGPoint_1sizeof_FUNC,
+ CGPostKeyboardEvent_FUNC,
CGRect_1sizeof_FUNC,
CGSetLocalEventsFilterDuringSuppressionState_FUNC,
CGSetLocalEventsSuppressionInterval_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/CoreGraphicsFull.bridgesupport.extras b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/CoreGraphicsFull.bridgesupport.extras
index c61b131c2d..fe64997263 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/CoreGraphicsFull.bridgesupport.extras
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/CoreGraphicsFull.bridgesupport.extras
@@ -321,6 +321,12 @@
<function name="CGPathRelease" swt_gen="true">
<arg swt_gen="true"></arg>
</function>
+ <function name="CGPostKeyboardEvent" swt_gen="true">
+ <arg swt_gen="true"></arg>
+ <arg swt_gen="true"></arg>
+ <arg swt_gen="true" swt_java_type="boolean"></arg>
+ <retval swt_gen="true"></retval>
+ </function>
<function name="CGPostMouseEvent" swt_variadic_count="4" swt_variadic_java_types="boolean,*">
<arg></arg>
<arg swt_java_type="boolean"></arg>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
index 8a143e0708..5cdeb3412b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
@@ -3418,6 +3418,12 @@ public static final native void CGPathMoveToPoint(int /*long*/ path, int /*long*
*/
public static final native void CGPathRelease(int /*long*/ path);
/**
+ * @param keyChar cast=(CGCharCode)
+ * @param virtualKey cast=(CGKeyCode)
+ * @param keyDown cast=(boolean_t)
+ */
+public static final native int CGPostKeyboardEvent(short keyChar, short virtualKey, boolean keyDown);
+/**
* @param filter cast=(CGEventFilterMask)
* @param state cast=(CGEventSuppressionState)
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
index 14209a6984..d9c6dfbe66 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
@@ -2962,6 +2962,7 @@ public boolean post(Event event) {
int /*long*/ eventRef = 0;
int /*long*/ eventSource = OS.CGEventSourceCreate(OS.kCGEventSourceStateHIDSystemState);
if (eventSource == 0) return false;
+ boolean returnValue = false;
int type = event.type;
switch (type) {
@@ -3009,7 +3010,11 @@ public boolean post(Event event) {
}
if (vKey != -1) {
- eventRef = OS.CGEventCreateKeyboardEvent(eventSource, vKey, type == SWT.KeyDown);
+ if (OS.VERSION < 0x1060) {
+ returnValue = OS.CGPostKeyboardEvent((short)0, vKey, type == SWT.KeyDown) == OS.noErr;
+ } else {
+ eventRef = OS.CGEventCreateKeyboardEvent(eventSource, vKey, type == SWT.KeyDown);
+ }
}
break;
}
@@ -3056,16 +3061,17 @@ public boolean post(Event event) {
}
}
- boolean returnValue = false;
-
- if (eventRef != 0) {
- try {
- Thread.sleep(1);
- } catch (Exception e) {
+ // returnValue is true if we called CGPostKeyboardEvent (10.5 only).
+ if (returnValue == false) {
+ if (eventRef != 0) {
+ try {
+ Thread.sleep(1);
+ } catch (Exception e) {
+ }
+ OS.CGEventPost(OS.kCGSessionEventTap, eventRef);
+ OS.CFRelease(eventRef);
+ returnValue = true;
}
- OS.CGEventPost(OS.kCGSessionEventTap, eventRef);
- OS.CFRelease(eventRef);
- returnValue = true;
}
if (eventSource != 0) OS.CFRelease(eventSource);

Back to the top