diff options
author | Lakshmi Shanmugam | 2018-03-26 10:27:23 +0000 |
---|---|---|
committer | Lakshmi Shanmugam | 2018-03-27 08:49:17 +0000 |
commit | e45931420d84a5bf7c66e3556d72afddbabefbdd (patch) | |
tree | f796e7d4bcc5fc858959c230ed23d10a448ebdb6 | |
parent | 497da643ab2f9b45aa9ed219ef46a552c9350b46 (diff) | |
download | eclipse.platform.swt-lshanmugam/MultiMonitor.tar.gz eclipse.platform.swt-lshanmugam/MultiMonitor.tar.xz eclipse.platform.swt-lshanmugam/MultiMonitor.zip |
NsImage callback changeslshanmugam/MultiMonitor
Change-Id: Iaba21020cdfaf5e91a71e4e5544735f1dbb09057
10 files changed, 132 insertions, 5 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 58e3a92bae..97273d9321 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 @@ -1265,7 +1265,7 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(CFURLCreateFromFSRef) jintLong rc = 0; OS_NATIVE_ENTER(env, that, CFURLCreateFromFSRef_FUNC); if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail; - rc = (jintLong)CFURLCreateFromFSRef((CFAllocatorRef)arg0, (struct FSRef*)lparg1); + rc = (jintLong)CFURLCreateFromFSRef((CFAllocatorRef)arg0, (structFSRef*)lparg1); fail: if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0); OS_NATIVE_EXIT(env, that, CFURLCreateFromFSRef_FUNC); @@ -9906,6 +9906,33 @@ fail: } #endif +#if (!defined(NO_objc_1msgSend_1bool__IIILorg_eclipse_swt_internal_cocoa_NSRect_2) && !defined(JNI64)) || (!defined(NO_objc_1msgSend_1bool__JJJLorg_eclipse_swt_internal_cocoa_NSRect_2) && defined(JNI64)) +#ifndef JNI64 +JNIEXPORT jboolean JNICALL OS_NATIVE(objc_1msgSend_1bool__IIILorg_eclipse_swt_internal_cocoa_NSRect_2)(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jintLong arg2, jobject arg3) +#else +JNIEXPORT jboolean JNICALL OS_NATIVE(objc_1msgSend_1bool__JJJLorg_eclipse_swt_internal_cocoa_NSRect_2)(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jintLong arg2, jobject arg3) +#endif +{ + NSRect _arg3, *lparg3=NULL; + jboolean rc = 0; +#ifndef JNI64 + OS_NATIVE_ENTER(env, that, objc_1msgSend_1bool__IIILorg_eclipse_swt_internal_cocoa_NSRect_2_FUNC); +#else + OS_NATIVE_ENTER(env, that, objc_1msgSend_1bool__JJJLorg_eclipse_swt_internal_cocoa_NSRect_2_FUNC); +#endif + if (arg3) if ((lparg3 = getNSRectFields(env, arg3, &_arg3)) == NULL) goto fail; + rc = (jboolean)((BOOL (*)(jintLong, jintLong, jintLong, NSRect))objc_msgSend_bool)(arg0, arg1, arg2, *lparg3); +fail: + if (arg3 && lparg3) setNSRectFields(env, arg3, lparg3); +#ifndef JNI64 + OS_NATIVE_EXIT(env, that, objc_1msgSend_1bool__IIILorg_eclipse_swt_internal_cocoa_NSRect_2_FUNC); +#else + OS_NATIVE_EXIT(env, that, objc_1msgSend_1bool__JJJLorg_eclipse_swt_internal_cocoa_NSRect_2_FUNC); +#endif + return rc; +} +#endif + #if (!defined(NO_objc_1msgSend_1bool__IIILorg_eclipse_swt_internal_cocoa_NSSize_2Z) && !defined(JNI64)) || (!defined(NO_objc_1msgSend_1bool__JJJLorg_eclipse_swt_internal_cocoa_NSSize_2Z) && defined(JNI64)) #ifndef JNI64 JNIEXPORT jboolean JNICALL OS_NATIVE(objc_1msgSend_1bool__IIILorg_eclipse_swt_internal_cocoa_NSSize_2Z)(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jintLong arg2, jobject arg3, jboolean arg4) 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 05d934f65f..8ebc81e4a6 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 @@ -1119,6 +1119,11 @@ char * OS_nativeFunctionNames[] = { "objc_1msgSend_1bool__JJJLorg_eclipse_swt_internal_cocoa_NSPoint_2", #endif #ifndef JNI64 + "objc_1msgSend_1bool__IIILorg_eclipse_swt_internal_cocoa_NSRect_2", +#else + "objc_1msgSend_1bool__JJJLorg_eclipse_swt_internal_cocoa_NSRect_2", +#endif +#ifndef JNI64 "objc_1msgSend_1bool__IIILorg_eclipse_swt_internal_cocoa_NSSize_2Z", #else "objc_1msgSend_1bool__JJJLorg_eclipse_swt_internal_cocoa_NSSize_2Z", 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 6d43bdd89c..4b4c412da7 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 @@ -1129,6 +1129,11 @@ typedef enum { objc_1msgSend_1bool__JJJLorg_eclipse_swt_internal_cocoa_NSPoint_2_FUNC, #endif #ifndef JNI64 + objc_1msgSend_1bool__IIILorg_eclipse_swt_internal_cocoa_NSRect_2_FUNC, +#else + objc_1msgSend_1bool__JJJLorg_eclipse_swt_internal_cocoa_NSRect_2_FUNC, +#endif +#ifndef JNI64 objc_1msgSend_1bool__IIILorg_eclipse_swt_internal_cocoa_NSSize_2Z_FUNC, #else objc_1msgSend_1bool__JJJLorg_eclipse_swt_internal_cocoa_NSSize_2Z_FUNC, 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 41934477dc..05c77fa31e 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 @@ -1553,6 +1553,10 @@ <arg swt_gen="true"></arg> <retval swt_gen="true"></retval> </method> + <method selector="drawInRect:" swt_gen="true"> + <arg swt_gen="true"></arg> + <retval swt_gen="true"></retval> + </method> <method selector="drawInRect:fromRect:operation:fraction:" swt_gen="true"> <arg swt_gen="true"></arg> <arg swt_gen="true"></arg> @@ -1560,6 +1564,11 @@ <arg swt_gen="true"></arg> <retval swt_gen="true"></retval> </method> + <method selector="drawRepresentation:inRect:" swt_gen="true"> + <arg swt_gen="true"></arg> + <arg swt_gen="true"></arg> + <retval swt_gen="true"></retval> + </method> <method class_method="true" selector="imageNamed:" swt_gen="true"> <arg swt_gen="true"></arg> <retval swt_gen="true" swt_java_type="NSImage"></retval> diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSImage.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSImage.java index b93d6ad92f..ee097b4455 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSImage.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSImage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -42,10 +42,18 @@ public void drawAtPoint(NSPoint point, NSRect fromRect, long /*int*/ op, double OS.objc_msgSend(this.id, OS.sel_drawAtPoint_fromRect_operation_fraction_, point, fromRect, op, delta); } +public void drawInRect(NSRect rect) { + OS.objc_msgSend(this.id, OS.sel_drawInRect_, rect); +} + public void drawInRect(NSRect rect, NSRect fromRect, long /*int*/ op, double /*float*/ delta) { OS.objc_msgSend(this.id, OS.sel_drawInRect_fromRect_operation_fraction_, rect, fromRect, op, delta); } +public boolean drawRepresentation(NSImageRep imageRep, NSRect rect) { + return OS.objc_msgSend_bool(this.id, OS.sel_drawRepresentation_inRect_, imageRep != null ? imageRep.id : 0, rect); +} + public static NSImage imageNamed(NSString name) { long /*int*/ result = OS.objc_msgSend(OS.class_NSImage, OS.sel_imageNamed_, name != null ? name.id : 0); return result != 0 ? new NSImage(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 3ab61a3d9d..8b604e5b9e 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 @@ -1334,6 +1334,7 @@ public static final long /*int*/ sel_drawInRect_fromRect_operation_fraction_ = S public static final long /*int*/ sel_drawInteriorWithFrame_inView_ = Selector.sel_drawInteriorWithFrame_inView_.value; public static final long /*int*/ sel_drawLabel_inRect_ = Selector.sel_drawLabel_inRect_.value; public static final long /*int*/ sel_drawRect_ = Selector.sel_drawRect_.value; +public static final long /*int*/ sel_drawRepresentation_inRect_ = Selector.sel_drawRepresentation_inRect_.value; public static final long /*int*/ sel_drawSortIndicatorWithFrame_inView_ascending_priority_ = Selector.sel_drawSortIndicatorWithFrame_inView_ascending_priority_.value; public static final long /*int*/ sel_drawStatusBarBackgroundInRect_withHighlight_ = Selector.sel_drawStatusBarBackgroundInRect_withHighlight_.value; public static final long /*int*/ sel_drawTitle_withFrame_inView_ = Selector.sel_drawTitle_withFrame_inView_.value; @@ -3387,7 +3388,7 @@ public static final native void CFRunLoopStop(long /*int*/ rl); public static final native long /*int*/ CFStringCreateWithCharacters(long /*int*/ alloc, char[] chars, long /*int*/ numChars); /** * @param allocator cast=(CFAllocatorRef) - * @param fsRef cast=(struct FSRef*) + * @param fsRef cast=(structFSRef*) */ public static final native long /*int*/ CFURLCreateFromFSRef(long /*int*/ allocator, byte[] fsRef); /** @@ -3911,6 +3912,11 @@ public static final native boolean objc_msgSend_bool(long /*int*/ id, long /*int * @method flags=cast * @param arg1 flags=struct */ +public static final native boolean objc_msgSend_bool(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0, NSRect arg1); +/** + * @method flags=cast + * @param arg1 flags=struct + */ public static final native boolean objc_msgSend_bool(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0, NSSize arg1, boolean arg2); /** @method flags=cast */ public static final native boolean objc_msgSend_bool(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0, long /*int*/ arg1); 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 fa99603993..9da4cf4ab5 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 @@ -455,6 +455,7 @@ public enum Selector { , sel_drawInteriorWithFrame_inView_("drawInteriorWithFrame:inView:") , sel_drawLabel_inRect_("drawLabel:inRect:") , sel_drawRect_("drawRect:") + , sel_drawRepresentation_inRect_("drawRepresentation:inRect:") , sel_drawSortIndicatorWithFrame_inView_ascending_priority_("drawSortIndicatorWithFrame:inView:ascending:priority:") , sel_drawStatusBarBackgroundInRect_withHighlight_("drawStatusBarBackgroundInRect:withHighlight:") , sel_drawTitle_withFrame_inView_("drawTitle:withFrame:inView:") diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/Library.java b/bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/Library.java index 923012fbd0..c798e05c34 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/Library.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/Library.java @@ -28,7 +28,7 @@ public class Library { /** * SWT Minor version number (must be in the range 0..999) */ - static int MINOR_VERSION = 858; + static int MINOR_VERSION = 863; /** * SWT revision number (must be >= 0) @@ -55,7 +55,7 @@ public class Library { static { DELIMITER = System.getProperty("line.separator"); //$NON-NLS-1$ - SEPARATOR = System.getProperty("file.separator"); //$NON-NLS-1$ + SEPARATOR = File.separator; USER_HOME = System.getProperty ("user.home"); SWT_LIB_DIR = ".swt" + SEPARATOR + "lib" + SEPARATOR + os() + SEPARATOR + arch(); //$NON-NLS-1$ $NON-NLS-2$ JAVA_VERSION = parseVersion(System.getProperty("java.version")); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java index fe7317c754..b9ec82aff5 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java @@ -136,6 +136,18 @@ public final class Image extends Resource implements Drawable { */ private AlphaInfo alphaInfo_100, alphaInfo_200; + private Callback callback_draw_representation; + + private long method; + + private long methodImpl; + + private Callback callback_drawInRect; + + private long method1; + + private long methodImpl1; + static class AlphaInfo { /** * The alpha data of the image. @@ -803,10 +815,13 @@ public Image(Device device, ImageFileNameProvider imageFileNameProvider) { */ public Image(Device device, ImageDataProvider imageDataProvider) { super(device); + if (imageDataProvider == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); this.imageDataProvider = imageDataProvider; ImageData data = imageDataProvider.getImageData (100); if (data == null) SWT.error(SWT.ERROR_INVALID_ARGUMENT); + + NSAutoreleasePool pool = null; if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); try { @@ -819,11 +834,43 @@ public Image(Device device, ImageDataProvider imageDataProvider) { handle.addRepresentation(rep); rep.release(); } + addCallBacks (); } finally { if (pool != null) pool.release(); } } +void addCallBacks () { + System.out.println("add call backs"); + callback_draw_representation = new Callback(this, "_drawRepresentationInRect", 4); + long /*int*/ proc = callback_draw_representation.getAddress(); + if (proc == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS); + method = OS.class_getInstanceMethod(OS.class_NSImage, OS.sel_drawRepresentation_inRect_); + if (method != 0) methodImpl = OS.method_setImplementation(method, proc); + + callback_drawInRect = new Callback(this, "_drawAtPoint", 5); + proc = 0; + proc = callback_draw_representation.getAddress(); + if (proc == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS); + method1 = OS.class_getInstanceMethod(OS.class_NSImage, OS.sel_drawAtPoint_fromRect_operation_fraction_); + if (method1 != 0) methodImpl1 = OS.method_setImplementation(method1, proc); +} + +long /*int*/ _drawRepresentationInRect (long id, long sel, long imageRep, long NSRect) { + System.out.println("draw representation"); + return 1; +} + +long /*int*/ _drawInRect (long id, long sel, long NSRect) { + System.out.println("draw in rect"); + return 1; +} + +long /*int*/ _drawAtPoint (long id, long sel, long NSRect, long op, long fraction) { + System.out.println("draw at point"); + return 1; +} + private AlphaInfo _getAlphaInfoAtCurrentZoom (NSBitmapImageRep rep) { int deviceZoom = DPIUtil.getDeviceZoom(); if (deviceZoom != 100 && (imageFileNameProvider != null || imageDataProvider != null)) { @@ -1079,6 +1126,14 @@ private NSBitmapImageRep createRepresentation(ImageData imageData, AlphaInfo alp @Override void destroy() { + if (method != 0) OS.method_setImplementation(method, methodImpl); + if (callback_draw_representation != null) callback_draw_representation.dispose(); + callback_draw_representation = null; + + if (method1 != 0) OS.method_setImplementation(method1, methodImpl1); + if (callback_drawInRect != null) callback_drawInRect.dispose(); + callback_drawInRect = null; + if (memGC != null) memGC.dispose(); handle.release(); handle = null; 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 1407a04ac9..aeba87f9ea 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 @@ -2601,6 +2601,12 @@ void initClasses () { OS.class_addMethod(cls, OS.sel_shouldChangeTextInRange_replacementString_, shouldChangeTextInRange_replacementString_Proc, "@:{NSRange}@"); OS.objc_registerClassPair(cls); +// className = "SWTImage"; +// cls = OS.objc_allocateClassPair(OS.class_NSImage, className, 0); +// OS.class_addMethod(cls, OS.sel_drawRect_, drawRectProc, "@:{NSRect}"); +// OS.class_addMethod(cls, OS.sel_drawRepresentation_inRect_, proc4, "@:@{NSRect}"); +// OS.objc_registerClassPair(cls); + className = "SWTImageView"; cls = OS.objc_allocateClassPair(OS.class_NSImageView, className, 0); OS.class_addIvar(cls, SWT_OBJECT, size, (byte)align, types); @@ -6339,6 +6345,11 @@ static long /*int*/ windowProc(long /*int*/ id, long /*int*/ sel, long /*int*/ a } static long /*int*/ windowProc(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0, long /*int*/ arg1) { +// if (sel == OS.sel_drawRepresentation_inRect_){ +// System.out.println("draw representation"); +// return 0; +// } + Widget widget = LookupWidget(id, sel); if (widget == null) return 0; |