Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikita Nemkin2019-04-22 09:47:03 -0400
committerLakshmi Shanmugam2019-06-14 02:41:35 -0400
commit143a750b606afcb9465d03b28724ea61c02d1f04 (patch)
treecf5348221c2ddcd88d62f4c5d2ce6cbf63ed7f05
parenteee77d9544f575efd95665a23adbfed79e841cc9 (diff)
downloadeclipse.platform.swt-143a750b606afcb9465d03b28724ea61c02d1f04.tar.gz
eclipse.platform.swt-143a750b606afcb9465d03b28724ea61c02d1f04.tar.xz
eclipse.platform.swt-143a750b606afcb9465d03b28724ea61c02d1f04.zip
Bug 547192 - [Cocoa] Replace deprecated Carbon functions (Part 1)
Deprecated function | Modern equivalent ------------------------------------------------------------------- Gestalt | NSProcessInfo.operatingSystemVersion GetDblTime | NSEvent.doubleClickInterval GetCurrentEventButtonState | NSEvent.pressedMouseButtons ATSFontActivateFromFileReference | CTFontManagerRegisterFontsForURL Change-Id: I7ba3e3da6c73117bc7800d022b8eba9fb3cc907a Signed-off-by: Nikita Nemkin <nikita@nemkin.ru>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c44
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_structs.c37
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_structs.h12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/CoreTextFull.bridgesupport.extras7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSEvent.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSOperatingSystemVersion.java24
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSProcessInfo.java41
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java27
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Device.java15
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java2
16 files changed, 227 insertions, 21 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 d76726a58e..f869bd729d 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
@@ -2225,6 +2225,18 @@ JNIEXPORT jdouble JNICALL OS_NATIVE(CTFontGetLeading)
}
#endif
+#ifndef NO_CTFontManagerRegisterFontsForURL
+JNIEXPORT jboolean JNICALL OS_NATIVE(CTFontManagerRegisterFontsForURL)
+ (JNIEnv *env, jclass that, jlong arg0, jint arg1, jlong arg2)
+{
+ jboolean rc = 0;
+ OS_NATIVE_ENTER(env, that, CTFontManagerRegisterFontsForURL_FUNC);
+ rc = (jboolean)CTFontManagerRegisterFontsForURL((CFURLRef)arg0, (CTFontManagerScope)arg1, (CFErrorRef*)arg2);
+ OS_NATIVE_EXIT(env, that, CTFontManagerRegisterFontsForURL_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO_CTLineCreateWithAttributedString
JNIEXPORT jlong JNICALL OS_NATIVE(CTLineCreateWithAttributedString)
(JNIEnv *env, jclass that, jlong arg0)
@@ -4881,6 +4893,18 @@ JNIEXPORT jlong JNICALL OS_NATIVE(NSObliquenessAttributeName)
}
#endif
+#ifndef NO_NSOperatingSystemVersion_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(NSOperatingSystemVersion_1sizeof)
+ (JNIEnv *env, jclass that)
+{
+ jint rc = 0;
+ OS_NATIVE_ENTER(env, that, NSOperatingSystemVersion_1sizeof_FUNC);
+ rc = (jint)NSOperatingSystemVersion_sizeof();
+ OS_NATIVE_EXIT(env, that, NSOperatingSystemVersion_1sizeof_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO_NSOutlineViewColumnDidMoveNotification
JNIEXPORT jlong JNICALL OS_NATIVE(NSOutlineViewColumnDidMoveNotification)
(JNIEnv *env, jclass that)
@@ -8467,6 +8491,26 @@ fail:
}
#endif
+#ifndef NO_objc_1msgSend_1stret__Lorg_eclipse_swt_internal_cocoa_NSOperatingSystemVersion_2JJ
+JNIEXPORT void JNICALL OS_NATIVE(objc_1msgSend_1stret__Lorg_eclipse_swt_internal_cocoa_NSOperatingSystemVersion_2JJ)
+ (JNIEnv *env, jclass that, jobject arg0, jlong arg1, jlong arg2)
+{
+ NSOperatingSystemVersion _arg0, *lparg0=NULL;
+ OS_NATIVE_ENTER(env, that, objc_1msgSend_1stret__Lorg_eclipse_swt_internal_cocoa_NSOperatingSystemVersion_2JJ_FUNC);
+ if (arg0) if ((lparg0 = getNSOperatingSystemVersionFields(env, arg0, &_arg0)) == NULL) goto fail;
+ if (STRUCT_SIZE_LIMIT == 0) {
+ ((void (*)(NSOperatingSystemVersion *, jlong, jlong))objc_msgSend_stret)(lparg0, arg1, arg2);
+ } else if (sizeof(_arg0) > STRUCT_SIZE_LIMIT) {
+ *lparg0 = (*(NSOperatingSystemVersion (*)(jlong, jlong))objc_msgSend_stret)(arg1, arg2);
+ } else {
+ *lparg0 = (*(NSOperatingSystemVersion (*)(jlong, jlong))objc_msgSend)(arg1, arg2);
+ }
+fail:
+ if (arg0 && lparg0) setNSOperatingSystemVersionFields(env, arg0, lparg0);
+ OS_NATIVE_EXIT(env, that, objc_1msgSend_1stret__Lorg_eclipse_swt_internal_cocoa_NSOperatingSystemVersion_2JJ_FUNC);
+}
+#endif
+
#ifndef NO_objc_1msgSend_1stret__Lorg_eclipse_swt_internal_cocoa_NSPoint_2JJ
JNIEXPORT void JNICALL OS_NATIVE(objc_1msgSend_1stret__Lorg_eclipse_swt_internal_cocoa_NSPoint_2JJ)
(JNIEnv *env, jclass that, jobject arg0, jlong arg1, jlong arg2)
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 b712b271da..10882deb69 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
@@ -160,6 +160,7 @@ char * OS_nativeFunctionNames[] = {
"CTFontGetAscent",
"CTFontGetDescent",
"CTFontGetLeading",
+ "CTFontManagerRegisterFontsForURL",
"CTLineCreateWithAttributedString",
"CTLineDraw",
"CTLineGetTypographicBounds",
@@ -370,6 +371,7 @@ char * OS_nativeFunctionNames[] = {
"NSNotFound",
"NSNumberOfColorComponents",
"NSObliquenessAttributeName",
+ "NSOperatingSystemVersion_1sizeof",
"NSOutlineViewColumnDidMoveNotification",
"NSParagraphStyleAttributeName",
"NSPasteboardTypeHTML",
@@ -610,6 +612,7 @@ char * OS_nativeFunctionNames[] = {
"objc_1msgSend_1fpret__JJJ",
"objc_1msgSend_1fpret__JJJJ",
"objc_1msgSend_1stret__Lorg_eclipse_swt_internal_cocoa_NSAffineTransformStruct_2JJ",
+ "objc_1msgSend_1stret__Lorg_eclipse_swt_internal_cocoa_NSOperatingSystemVersion_2JJ",
"objc_1msgSend_1stret__Lorg_eclipse_swt_internal_cocoa_NSPoint_2JJ",
"objc_1msgSend_1stret__Lorg_eclipse_swt_internal_cocoa_NSPoint_2JJJ",
"objc_1msgSend_1stret__Lorg_eclipse_swt_internal_cocoa_NSPoint_2JJLorg_eclipse_swt_internal_cocoa_NSPoint_2",
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 96258bb768..3488f71691 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
@@ -170,6 +170,7 @@ typedef enum {
CTFontGetAscent_FUNC,
CTFontGetDescent_FUNC,
CTFontGetLeading_FUNC,
+ CTFontManagerRegisterFontsForURL_FUNC,
CTLineCreateWithAttributedString_FUNC,
CTLineDraw_FUNC,
CTLineGetTypographicBounds_FUNC,
@@ -380,6 +381,7 @@ typedef enum {
NSNotFound_FUNC,
NSNumberOfColorComponents_FUNC,
NSObliquenessAttributeName_FUNC,
+ NSOperatingSystemVersion_1sizeof_FUNC,
NSOutlineViewColumnDidMoveNotification_FUNC,
NSParagraphStyleAttributeName_FUNC,
NSPasteboardTypeHTML_FUNC,
@@ -620,6 +622,7 @@ typedef enum {
objc_1msgSend_1fpret__JJJ_FUNC,
objc_1msgSend_1fpret__JJJJ_FUNC,
objc_1msgSend_1stret__Lorg_eclipse_swt_internal_cocoa_NSAffineTransformStruct_2JJ_FUNC,
+ objc_1msgSend_1stret__Lorg_eclipse_swt_internal_cocoa_NSOperatingSystemVersion_2JJ_FUNC,
objc_1msgSend_1stret__Lorg_eclipse_swt_internal_cocoa_NSPoint_2JJ_FUNC,
objc_1msgSend_1stret__Lorg_eclipse_swt_internal_cocoa_NSPoint_2JJJ_FUNC,
objc_1msgSend_1stret__Lorg_eclipse_swt_internal_cocoa_NSPoint_2JJLorg_eclipse_swt_internal_cocoa_NSPoint_2_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_structs.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_structs.c
index 7f3619598b..045af4793d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_structs.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_structs.c
@@ -329,6 +329,43 @@ void setNSAffineTransformStructFields(JNIEnv *env, jobject lpObject, NSAffineTra
}
#endif
+#ifndef NO_NSOperatingSystemVersion
+typedef struct NSOperatingSystemVersion_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID majorVersion, minorVersion, patchVersion;
+} NSOperatingSystemVersion_FID_CACHE;
+
+NSOperatingSystemVersion_FID_CACHE NSOperatingSystemVersionFc;
+
+void cacheNSOperatingSystemVersionFields(JNIEnv *env, jobject lpObject)
+{
+ if (NSOperatingSystemVersionFc.cached) return;
+ NSOperatingSystemVersionFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ NSOperatingSystemVersionFc.majorVersion = (*env)->GetFieldID(env, NSOperatingSystemVersionFc.clazz, "majorVersion", "J");
+ NSOperatingSystemVersionFc.minorVersion = (*env)->GetFieldID(env, NSOperatingSystemVersionFc.clazz, "minorVersion", "J");
+ NSOperatingSystemVersionFc.patchVersion = (*env)->GetFieldID(env, NSOperatingSystemVersionFc.clazz, "patchVersion", "J");
+ NSOperatingSystemVersionFc.cached = 1;
+}
+
+NSOperatingSystemVersion *getNSOperatingSystemVersionFields(JNIEnv *env, jobject lpObject, NSOperatingSystemVersion *lpStruct)
+{
+ if (!NSOperatingSystemVersionFc.cached) cacheNSOperatingSystemVersionFields(env, lpObject);
+ lpStruct->majorVersion = (NSInteger)(*env)->GetLongField(env, lpObject, NSOperatingSystemVersionFc.majorVersion);
+ lpStruct->minorVersion = (NSInteger)(*env)->GetLongField(env, lpObject, NSOperatingSystemVersionFc.minorVersion);
+ lpStruct->patchVersion = (NSInteger)(*env)->GetLongField(env, lpObject, NSOperatingSystemVersionFc.patchVersion);
+ return lpStruct;
+}
+
+void setNSOperatingSystemVersionFields(JNIEnv *env, jobject lpObject, NSOperatingSystemVersion *lpStruct)
+{
+ if (!NSOperatingSystemVersionFc.cached) cacheNSOperatingSystemVersionFields(env, lpObject);
+ (*env)->SetLongField(env, lpObject, NSOperatingSystemVersionFc.majorVersion, (jlong)lpStruct->majorVersion);
+ (*env)->SetLongField(env, lpObject, NSOperatingSystemVersionFc.minorVersion, (jlong)lpStruct->minorVersion);
+ (*env)->SetLongField(env, lpObject, NSOperatingSystemVersionFc.patchVersion, (jlong)lpStruct->patchVersion);
+}
+#endif
+
#ifndef NO_NSPoint
typedef struct NSPoint_FID_CACHE {
int cached;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_structs.h b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_structs.h
index 67fb462ef9..178ea2d68d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_structs.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_structs.h
@@ -113,6 +113,18 @@ void setNSAffineTransformStructFields(JNIEnv *env, jobject lpObject, NSAffineTra
#define NSAffineTransformStruct_sizeof() 0
#endif
+#ifndef NO_NSOperatingSystemVersion
+void cacheNSOperatingSystemVersionFields(JNIEnv *env, jobject lpObject);
+NSOperatingSystemVersion *getNSOperatingSystemVersionFields(JNIEnv *env, jobject lpObject, NSOperatingSystemVersion *lpStruct);
+void setNSOperatingSystemVersionFields(JNIEnv *env, jobject lpObject, NSOperatingSystemVersion *lpStruct);
+#define NSOperatingSystemVersion_sizeof() sizeof(NSOperatingSystemVersion)
+#else
+#define cacheNSOperatingSystemVersionFields(a,b)
+#define getNSOperatingSystemVersionFields(a,b,c) NULL
+#define setNSOperatingSystemVersionFields(a,b,c)
+#define NSOperatingSystemVersion_sizeof() 0
+#endif
+
#ifndef NO_NSPoint
void cacheNSPointFields(JNIEnv *env, jobject lpObject);
NSPoint *getNSPointFields(JNIEnv *env, jobject lpObject, NSPoint *lpStruct);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
index 90fa40ec2d..f970f78fe4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
@@ -1277,6 +1277,9 @@
<method selector="deltaY" swt_gen="true">
<retval swt_gen="true"></retval>
</method>
+ <method class_method="true" selector="doubleClickInterval" swt_gen="true">
+ <retval swt_gen="true"></retval>
+ </method>
<method class_method="true" selector="enterExitEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:trackingNumber:userData:" swt_gen="true">
<arg swt_gen="true"></arg>
<arg swt_gen="true"></arg>
@@ -1316,6 +1319,9 @@
<arg swt_gen="true"></arg>
<retval swt_gen="true"></retval>
</method>
+ <method class_method="true" selector="pressedMouseButtons" swt_gen="true">
+ <retval swt_gen="true"></retval>
+ </method>
<method selector="rotation" swt_gen="true">
<retval swt_gen="true"></retval>
</method>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/CoreTextFull.bridgesupport.extras b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/CoreTextFull.bridgesupport.extras
index bd180d9230..6d614bbddf 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/CoreTextFull.bridgesupport.extras
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/CoreTextFull.bridgesupport.extras
@@ -3,6 +3,7 @@
<constant name="kCTFontAttributeName" swt_gen="true"></constant>
<constant name="kCTForegroundColorAttributeName" swt_gen="true"></constant>
<constant name="kCTParagraphStyleAttributeName" swt_gen="true"></constant>
+ <enum name="kCTFontManagerScopeProcess" swt_gen="true"></enum>
<enum name="kCTParagraphStyleSpecifierBaseWritingDirection" swt_gen="true"></enum>
<enum name="kCTWritingDirectionLeftToRight" swt_gen="true"></enum>
<enum name="kCTWritingDirectionNatural" swt_gen="true"></enum>
@@ -19,6 +20,12 @@
<arg swt_gen="true"></arg>
<retval swt_gen="true"></retval>
</function>
+ <function name="CTFontManagerRegisterFontsForURL" swt_gen="true">
+ <arg swt_gen="true"></arg>
+ <arg swt_gen="true"></arg>
+ <arg swt_gen="true"></arg>
+ <retval swt_gen="true"></retval>
+ </function>
<function name="CTLineCreateWithAttributedString" swt_gen="true">
<arg swt_gen="true"></arg>
<retval swt_gen="true"></retval>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras
index 8617aa1c03..940e398314 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras
@@ -826,6 +826,14 @@
</class>
<class name="NSPortCoder" swt_superclass="NSCoder">
</class>
+ <class name="NSProcessInfo" swt_gen="mixed">
+ <method selector="operatingSystemVersion" swt_gen="true">
+ <retval swt_gen="true"></retval>
+ </method>
+ <method class_method="true" selector="processInfo" swt_gen="true">
+ <retval swt_gen="true"></retval>
+ </method>
+ </class>
<class name="NSProtocolChecker" swt_superclass="NSProxy">
</class>
<class name="NSQuitCommand" swt_superclass="NSScriptCommand">
@@ -1227,6 +1235,11 @@
<field name="tX" swt_gen="true"></field>
<field name="tY" swt_gen="true"></field>
</struct>
+ <struct name="NSOperatingSystemVersion" swt_gen="true">
+ <field name="majorVersion" swt_gen="true"></field>
+ <field name="minorVersion" swt_gen="true"></field>
+ <field name="patchVersion" swt_gen="true"></field>
+ </struct>
<struct name="NSPoint" swt_gen="true" swt_gen_memmove="true" swt_gen_tostring="true">
<field name="x" swt_gen="true"></field>
<field name="y" swt_gen="true"></field>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSEvent.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSEvent.java
index 789b1ac266..f761e7f8db 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSEvent.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSEvent.java
@@ -57,6 +57,10 @@ public double deltaY() {
return OS.objc_msgSend_fpret(this.id, OS.sel_deltaY);
}
+public static double doubleClickInterval() {
+ return OS.objc_msgSend_fpret(OS.class_NSEvent, OS.sel_doubleClickInterval);
+}
+
public static NSEvent enterExitEventWithType(long type, NSPoint location, long flags, double time, long wNum, NSGraphicsContext context, long eNum, long tNum, long data) {
long result = OS.objc_msgSend(OS.class_NSEvent, OS.sel_enterExitEventWithType_location_modifierFlags_timestamp_windowNumber_context_eventNumber_trackingNumber_userData_, type, location, flags, time, wNum, context != null ? context.id : 0, eNum, tNum, data);
return result != 0 ? new NSEvent(result) : null;
@@ -91,6 +95,10 @@ public static NSEvent otherEventWithType(long type, NSPoint location, long flags
return result != 0 ? new NSEvent(result) : null;
}
+public static long pressedMouseButtons() {
+ return OS.objc_msgSend(OS.class_NSEvent, OS.sel_pressedMouseButtons);
+}
+
public float rotation() {
return OS.objc_msgSend_floatret(this.id, OS.sel_rotation);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSOperatingSystemVersion.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSOperatingSystemVersion.java
new file mode 100644
index 0000000000..6e30236790
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSOperatingSystemVersion.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.cocoa;
+
+public class NSOperatingSystemVersion {
+ /** @field cast=(NSInteger) */
+ public long majorVersion;
+ /** @field cast=(NSInteger) */
+ public long minorVersion;
+ /** @field cast=(NSInteger) */
+ public long patchVersion;
+ public static final int sizeof = OS.NSOperatingSystemVersion_sizeof();
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSProcessInfo.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSProcessInfo.java
new file mode 100644
index 0000000000..70c58d8f0d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSProcessInfo.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.cocoa;
+
+public class NSProcessInfo extends NSObject {
+
+public NSProcessInfo() {
+ super();
+}
+
+public NSProcessInfo(long id) {
+ super(id);
+}
+
+public NSProcessInfo(id id) {
+ super(id);
+}
+
+public NSOperatingSystemVersion operatingSystemVersion() {
+ NSOperatingSystemVersion result = new NSOperatingSystemVersion();
+ OS.objc_msgSend_stret(result, this.id, OS.sel_operatingSystemVersion);
+ return result;
+}
+
+public static NSProcessInfo processInfo() {
+ long result = OS.objc_msgSend(OS.class_NSProcessInfo, OS.sel_processInfo);
+ return result != 0 ? new NSProcessInfo(result) : null;
+}
+
+}
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 cd774929e0..e053462734 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
@@ -22,13 +22,6 @@ public class OS extends C {
}
public static final int VERSION;
- static {
- int [] major = new int [1], minor = new int [1], bugfix = new int [1];
- OS.Gestalt (OS.gestaltSystemVersionMajor, major);
- OS.Gestalt (OS.gestaltSystemVersionMinor, minor);
- OS.Gestalt (OS.gestaltSystemVersionBugFix, bugfix);
- VERSION = VERSION (major [0], minor [0], bugfix [0]);
- }
public static int VERSION (int major, int minor, int bugfix) {
return (major << 16) + (minor << 8) + bugfix;
@@ -872,6 +865,7 @@ public static final long class_NSPrintInfo = objc_getClass("NSPrintInfo");
public static final long class_NSPrintOperation = objc_getClass("NSPrintOperation");
public static final long class_NSPrintPanel = objc_getClass("NSPrintPanel");
public static final long class_NSPrinter = objc_getClass("NSPrinter");
+public static final long class_NSProcessInfo = objc_getClass("NSProcessInfo");
public static final long class_NSProgressIndicator = objc_getClass("NSProgressIndicator");
public static final long class_NSResponder = objc_getClass("NSResponder");
public static final long class_NSRunLoop = objc_getClass("NSRunLoop");
@@ -1322,6 +1316,7 @@ public static final long sel_documentView = Selector.sel_documentView.value;
public static final long sel_documentViewShouldHandlePrint = Selector.sel_documentViewShouldHandlePrint.value;
public static final long sel_documentVisibleRect = Selector.sel_documentVisibleRect.value;
public static final long sel_doubleClickAtIndex_ = Selector.sel_doubleClickAtIndex_.value;
+public static final long sel_doubleClickInterval = Selector.sel_doubleClickInterval.value;
public static final long sel_doubleValue = Selector.sel_doubleValue.value;
public static final long sel_download = Selector.sel_download.value;
public static final long sel_download_decideDestinationWithSuggestedFilename_ = Selector.sel_download_decideDestinationWithSuggestedFilename_.value;
@@ -1678,6 +1673,7 @@ public static final long sel_openFile_withApplication_ = Selector.sel_openFile_w
public static final long sel_openPanel = Selector.sel_openPanel.value;
public static final long sel_openURL_ = Selector.sel_openURL_.value;
public static final long sel_openURLs_withAppBundleIdentifier_options_additionalEventParamDescriptor_launchIdentifiers_ = Selector.sel_openURLs_withAppBundleIdentifier_options_additionalEventParamDescriptor_launchIdentifiers_.value;
+public static final long sel_operatingSystemVersion = Selector.sel_operatingSystemVersion.value;
public static final long sel_operationNotAllowedCursor = Selector.sel_operationNotAllowedCursor.value;
public static final long sel_options = Selector.sel_options.value;
public static final long sel_orderBack_ = Selector.sel_orderBack_.value;
@@ -1747,6 +1743,7 @@ public static final long sel_port = Selector.sel_port.value;
public static final long sel_postEvent_atStart_ = Selector.sel_postEvent_atStart_.value;
public static final long sel_preparedCellAtColumn_row_ = Selector.sel_preparedCellAtColumn_row_.value;
public static final long sel_prependTransform_ = Selector.sel_prependTransform_.value;
+public static final long sel_pressedMouseButtons = Selector.sel_pressedMouseButtons.value;
public static final long sel_preventDefault = Selector.sel_preventDefault.value;
public static final long sel_previousFailureCount = Selector.sel_previousFailureCount.value;
public static final long sel_printDocumentView = Selector.sel_printDocumentView.value;
@@ -1757,6 +1754,7 @@ public static final long sel_printSettings = Selector.sel_printSettings.value;
public static final long sel_printer = Selector.sel_printer.value;
public static final long sel_printerNames = Selector.sel_printerNames.value;
public static final long sel_printerWithName_ = Selector.sel_printerWithName_.value;
+public static final long sel_processInfo = Selector.sel_processInfo.value;
public static final long sel_propertyListForType_ = Selector.sel_propertyListForType_.value;
public static final long sel_proposedCredential = Selector.sel_proposedCredential.value;
public static final long sel_protectionSpace = Selector.sel_protectionSpace.value;
@@ -2664,6 +2662,7 @@ public static final int kCGPathStroke = 2;
public static final int kCGScrollEventUnitLine = 1;
public static final int kCGScrollEventUnitPixel = 0;
public static final int kCGTextFillStroke = 2;
+public static final int kCTFontManagerScopeProcess = 1;
public static final int kCTParagraphStyleSpecifierBaseWritingDirection = 13;
public static final int kCTWritingDirectionLeftToRight = 0;
public static final int kCTWritingDirectionNatural = -1;
@@ -3739,6 +3738,12 @@ public static final native double CTFontGetDescent(long font);
*/
public static final native double CTFontGetLeading(long font);
/**
+ * @param fontURL cast=(CFURLRef)
+ * @param scope cast=(CTFontManagerScope)
+ * @param error cast=(CFErrorRef*)
+ */
+public static final native boolean CTFontManagerRegisterFontsForURL(long fontURL, int scope, long error);
+/**
* @param attrString cast=(CFAttributedStringRef)
*/
public static final native long CTLineCreateWithAttributedString(long attrString);
@@ -4235,6 +4240,8 @@ public static final native long objc_msgSend(long id, long sel, long[] arg0, lon
/** @method flags=cast */
public static final native void objc_msgSend_stret(NSAffineTransformStruct result, long id, long sel);
/** @method flags=cast */
+public static final native void objc_msgSend_stret(NSOperatingSystemVersion result, long id, long sel);
+/** @method flags=cast */
public static final native void objc_msgSend_stret(NSPoint result, long id, long sel);
/**
* @method flags=cast
@@ -4329,6 +4336,7 @@ public static final native int CGRect_sizeof();
public static final native int CGSize_sizeof();
public static final native int CTParagraphStyleSetting_sizeof();
public static final native int NSAffineTransformStruct_sizeof();
+public static final native int NSOperatingSystemVersion_sizeof();
public static final native int NSPoint_sizeof();
public static final native int NSRange_sizeof();
public static final native int NSRect_sizeof();
@@ -4389,4 +4397,9 @@ public static final native void memmove(NSSize dest, long src, long size);
/** This section is auto generated */
+static {
+ NSOperatingSystemVersion version = NSProcessInfo.processInfo().operatingSystemVersion();
+ VERSION = VERSION ((int)version.majorVersion, (int)version.minorVersion, (int)version.patchVersion);
+}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java
index ef483afb8e..6045f563fc 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java
@@ -427,6 +427,7 @@ public enum Selector {
, sel_documentViewShouldHandlePrint("documentViewShouldHandlePrint")
, sel_documentVisibleRect("documentVisibleRect")
, sel_doubleClickAtIndex_("doubleClickAtIndex:")
+ , sel_doubleClickInterval("doubleClickInterval")
, sel_doubleValue("doubleValue")
, sel_download("download")
, sel_download_decideDestinationWithSuggestedFilename_("download:decideDestinationWithSuggestedFilename:")
@@ -783,6 +784,7 @@ public enum Selector {
, sel_openPanel("openPanel")
, sel_openURL_("openURL:")
, sel_openURLs_withAppBundleIdentifier_options_additionalEventParamDescriptor_launchIdentifiers_("openURLs:withAppBundleIdentifier:options:additionalEventParamDescriptor:launchIdentifiers:")
+ , sel_operatingSystemVersion("operatingSystemVersion")
, sel_operationNotAllowedCursor("operationNotAllowedCursor")
, sel_options("options")
, sel_orderBack_("orderBack:")
@@ -852,6 +854,7 @@ public enum Selector {
, sel_postEvent_atStart_("postEvent:atStart:")
, sel_preparedCellAtColumn_row_("preparedCellAtColumn:row:")
, sel_prependTransform_("prependTransform:")
+ , sel_pressedMouseButtons("pressedMouseButtons")
, sel_preventDefault("preventDefault")
, sel_previousFailureCount("previousFailureCount")
, sel_printDocumentView("printDocumentView")
@@ -862,6 +865,7 @@ public enum Selector {
, sel_printer("printer")
, sel_printerNames("printerNames")
, sel_printerWithName_("printerWithName:")
+ , sel_processInfo("processInfo")
, sel_propertyListForType_("propertyListForType:")
, sel_proposedCredential("proposedCredential")
, sel_protectionSpace("protectionSpace")
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Device.java
index e634fe2366..c2846e19b0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Device.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Device.java
@@ -634,19 +634,10 @@ public boolean isDisposed () {
public boolean loadFont (String path) {
checkDevice();
if (path == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- boolean result = false;
NSString nsPath = NSString.stringWith(path);
- long fsRepresentation = nsPath.fileSystemRepresentation();
-
- if (fsRepresentation != 0) {
- byte [] fsRef = new byte [80];
- boolean [] isDirectory = new boolean[1];
- if (OS.FSPathMakeRef (fsRepresentation, fsRef, isDirectory) == OS.noErr) {
- result = OS.ATSFontActivateFromFileReference (fsRef, OS.kATSFontContextLocal, OS.kATSFontFormatUnspecified, 0, OS.kATSOptionFlagsDefault, null) == OS.noErr;
- }
- }
-
- return result;
+ NSURL nsUrl = NSURL.fileURLWithPath(nsPath);
+ if (nsUrl == null) return false;
+ return OS.CTFontManagerRegisterFontsForURL(nsUrl.id, OS.kCTFontManagerScopeProcess, 0);
}
void new_Object (Object object) {
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 0008ed9407..5dbf3cf255 100644
--- 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
@@ -1547,7 +1547,7 @@ public int getDismissalAlignment () {
*/
public int getDoubleClickTime () {
checkDevice ();
- return OS.GetDblTime () * 1000 / 60;
+ return (int)(NSEvent.doubleClickInterval() * 1000);
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java
index 96c6cb4f5b..854e799bd4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java
@@ -1738,7 +1738,7 @@ boolean setInputState (Event event, NSEvent nsEvent, int type) {
if ((modifierFlags & OS.NSControlKeyMask) != 0) event.stateMask |= SWT.CONTROL;
if ((modifierFlags & OS.NSCommandKeyMask) != 0) event.stateMask |= SWT.COMMAND;
- int state = OS.GetCurrentEventButtonState ();
+ long state = NSEvent.pressedMouseButtons();
if ((state & 0x1) != 0) event.stateMask |= SWT.BUTTON1;
if ((state & 0x2) != 0) event.stateMask |= SWT.BUTTON3;
if ((state & 0x4) != 0) event.stateMask |= SWT.BUTTON2;

Back to the top