diff options
author | Nikita Nemkin | 2020-01-10 10:13:03 +0000 |
---|---|---|
committer | Nikita Nemkin | 2020-01-25 13:59:30 +0000 |
commit | 30ad38d69b91bac02f587cec89b564c73a903bdb (patch) | |
tree | bb570e3c1ce5cfe976041c39c04a841b98f146f3 | |
parent | 552c841cdec57d1445d04f981fead6cc3fbd21c8 (diff) | |
download | eclipse.platform.swt-30ad38d69b91bac02f587cec89b564c73a903bdb.tar.gz eclipse.platform.swt-30ad38d69b91bac02f587cec89b564c73a903bdb.tar.xz eclipse.platform.swt-30ad38d69b91bac02f587cec89b564c73a903bdb.zip |
Bug 418245 - [SWT_AWT] Embedded SWT in AWT broken on Mac with Java 7
In Java 7 and later, AWT widgets are backed by CALayer and not NSView.
This makes it impossible to embed NSView-backed SWT widgets into AWT
widgets. Make the limitation clear by throwing ERROR_NOT_IMPLEMENTED.
Since JAWT is no longer used, don't link to JavaVM framework.
Change-Id: Ic9932cd726ed98887bd12501729e9dc4994ff291
Signed-off-by: Nikita Nemkin <nikita@nemkin.ru>
3 files changed, 4 insertions, 82 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/cocoa/library/swt_awt.c b/bundles/org.eclipse.swt/Eclipse SWT AWT/cocoa/library/swt_awt.c index ddb2e96141..7a02052021 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT AWT/cocoa/library/swt_awt.c +++ b/bundles/org.eclipse.swt/Eclipse SWT AWT/cocoa/library/swt_awt.c @@ -16,54 +16,8 @@ #include "swt.h" #include "jawt_md.h" -#ifdef __OBJC__ -#import <AppKit/NSView.h> -#endif - #define SWT_AWT_NATIVE(func) Java_org_eclipse_swt_awt_SWT_1AWT_##func -/* - * JAWT version 1.7 does not define the type JAWT_MacOSXDrawingSurfaceInfo. - */ -#ifdef JAWT_VERSION_1_7 -// Legacy NSView-based rendering -typedef struct JAWT_MacOSXDrawingSurfaceInfo { - NSView *cocoaViewRef; // the view is guaranteed to be valid only for the duration of Component.paint method -} -JAWT_MacOSXDrawingSurfaceInfo; -#endif /* #ifdef JAWT_VERSION_1_7 */ - - -#ifndef NO_getAWTHandle -JNIEXPORT jlong JNICALL SWT_AWT_NATIVE(getAWTHandle) - (JNIEnv *env, jclass that, jobject canvas) -{ - jlong result = 0; - JAWT awt; - JAWT_DrawingSurface* ds; - JAWT_DrawingSurfaceInfo* dsi; - JAWT_MacOSXDrawingSurfaceInfo* dsi_cocoa; - jint lock; - - awt.version = JAWT_VERSION_1_4 | JAWT_MACOSX_USE_CALAYER; - if (JAWT_GetAWT(env, &awt) != 0) { - ds = awt.GetDrawingSurface(env, canvas); - if (ds != NULL) { - lock = ds->Lock(ds); - if ((lock & JAWT_LOCK_ERROR) == 0) { - dsi = ds->GetDrawingSurfaceInfo(ds); - dsi_cocoa = (JAWT_MacOSXDrawingSurfaceInfo*)dsi->platformInfo; - result = (jlong)dsi_cocoa->cocoaViewRef; - ds->FreeDrawingSurfaceInfo(dsi); - ds->Unlock(ds); - } - } - awt.FreeDrawingSurface(ds); - } - return result; -} -#endif - #ifndef NO_initFrame JNIEXPORT jobject JNICALL Java_org_eclipse_swt_awt_SWT_1AWT_initFrame (JNIEnv *env, jclass that, jlong handle, const char *className) diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/cocoa/org/eclipse/swt/awt/SWT_AWT.java b/bundles/org.eclipse.swt/Eclipse SWT AWT/cocoa/org/eclipse/swt/awt/SWT_AWT.java index 4a5cb861dc..6c474f7e4b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT AWT/cocoa/org/eclipse/swt/awt/SWT_AWT.java +++ b/bundles/org.eclipse.swt/Eclipse SWT AWT/cocoa/org/eclipse/swt/awt/SWT_AWT.java @@ -58,7 +58,6 @@ public class SWT_AWT { static boolean loaded, swingInitialized; - static native final long getAWTHandle (Canvas canvas); static native final Object initFrame (long handle, String className); static native final void validateWithBounds (Frame frame, int x, int y, int w, int h); static native final void synthesizeWindowActivation (Frame frame, boolean doActivate); @@ -67,15 +66,6 @@ public class SWT_AWT { if (loaded) return; loaded = true; Toolkit.getDefaultToolkit(); - /* - * Note that the jawt library is loaded explicitly - * because it cannot be found by the library loader. - * All exceptions are caught because the library may - * have been loaded already. - */ - try { - System.loadLibrary("jawt"); - } catch (Throwable e) {} Library.loadLibrary("swt-awt"); } @@ -311,30 +301,8 @@ public static Frame new_Frame(final Composite parent) { public static Shell new_Shell(final Display display, final Canvas parent) { if (display == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); if (parent == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); - long handle = 0; - - try { - loadLibrary (); - handle = getAWTHandle (parent); - } catch (Throwable e) { - SWT.error (SWT.ERROR_NOT_IMPLEMENTED, e); - } - if (handle == 0) SWT.error (SWT.ERROR_INVALID_ARGUMENT, null, " [peer not created]"); - - final Shell shell = Shell.cocoa_new (display, handle); - final ComponentListener listener = new ComponentAdapter () { - @Override - public void componentResized (ComponentEvent e) { - display.asyncExec (() -> { - if (shell.isDisposed()) return; - Dimension dim = parent.getSize (); - shell.setSize (dim.width, dim.height); - }); - } - }; - parent.addComponentListener(listener); - shell.addListener(SWT.Dispose, event -> parent.removeComponentListener(listener)); - shell.setVisible (true); - return shell; + // Since Java 7, AWT widgets don't have a backing NSView, making embedding impossible + SWT.error(SWT.ERROR_NOT_IMPLEMENTED, null, "[Embedding SWT in AWT isn't supported on macOS]"); + return null; } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/make_macosx.mak b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/make_macosx.mak index 3a74d90331..080c642081 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/make_macosx.mak +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/make_macosx.mak @@ -35,7 +35,7 @@ CFLAGS = -c -xobjective-c -Wall $(ARCHS) -DSWT_VERSION=$(SWT_VERSION) $(NATIVE_S $(CFLAGS_JAVA_VM) \ -I /System/Library/Frameworks/Cocoa.framework/Headers \ -I /System/Library/Frameworks/JavaScriptCore.framework/Headers -LFLAGS = -bundle $(ARCHS) -framework JavaVM -framework Cocoa -framework WebKit -framework CoreServices -framework JavaScriptCore -framework Security -framework SecurityInterface +LFLAGS = -bundle $(ARCHS) -framework Cocoa -framework WebKit -framework CoreServices -framework JavaScriptCore -framework Security -framework SecurityInterface SWT_OBJECTS = swt.o c.o c_stats.o callback.o SWTPI_OBJECTS = swt.o os.o os_structs.o os_stats.o os_custom.o |