1 /*******************************************************************************
2 * Copyright (c) 2000, 2016 IBM Corporation and others.
4 * This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
9 * SPDX-License-Identifier: EPL-2.0
12 * IBM Corporation - initial API and implementation
13 *******************************************************************************/
18 #define SWT_AWT_NATIVE(func) Java_org_eclipse_swt_awt_SWT_1AWT_##func
20 #ifndef NO_getAWTHandle
21 JNIEXPORT jintLong JNICALL SWT_AWT_NATIVE(getAWTHandle)
22 (JNIEnv *env, jclass that, jobject canvas)
25 JAWT_DrawingSurface* ds;
26 JAWT_DrawingSurfaceInfo* dsi;
27 JAWT_Win32DrawingSurfaceInfo* dsi_win;
31 awt.version = JAWT_VERSION_1_3;
32 if (JAWT_GetAWT(env, &awt) != 0) {
33 ds = awt.GetDrawingSurface(env, canvas);
36 if ((lock & JAWT_LOCK_ERROR) == 0) {
37 dsi = ds->GetDrawingSurfaceInfo(ds);
38 dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
39 result = (jintLong)dsi_win->hwnd;
40 ds->FreeDrawingSurfaceInfo(dsi);
44 awt.FreeDrawingSurface(ds);
51 JNIEXPORT jobject JNICALL SWT_AWT_NATIVE(initFrame)
52 (JNIEnv *env, jclass that, jintLong handle, jstring className)
55 jmethodID constructor;
57 jclass cls = (*env)->FindClass(env, "sun/awt/windows/WEmbeddedFrame");
58 if (NULL == cls) return NULL;
59 constructor = (*env)->GetMethodID(env, cls, "<init>", "(J)V");
60 object = (*env)->NewObject(env, cls, constructor, handle);
65 #ifndef NO_synthesizeWindowActivation
66 JNIEXPORT void JNICALL SWT_AWT_NATIVE(synthesizeWindowActivation)
67 (JNIEnv *env, jclass that, jobject frame, jboolean doActivate)
70 jclass cls = (*env)->FindClass(env, "sun/awt/windows/WEmbeddedFrame");
71 if (NULL == cls) return;
72 midInit = (*env)->GetMethodID(env, cls, "synthesizeWindowActivation", "(Z)V");
73 (*env)->CallVoidMethod(env, frame, midInit, doActivate);