|
| 1 | +/******************************************************************************* |
| 2 | + * Copyright (c) 2000, 2016 IBM Corporation and others. |
| 3 | + * |
| 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/ |
| 8 | + * |
| 9 | + * SPDX-License-Identifier: EPL-2.0 |
| 10 | + * |
| 11 | + * Contributors: |
| 12 | + * IBM Corporation - initial API and implementation |
| 13 | + *******************************************************************************/ |
| 14 | + |
| 15 | +#include "swt.h" |
| 16 | +#include "jawt_md.h" |
| 17 | +#include <windows.h> |
| 18 | + |
| 19 | +#define SWT_AWT_NATIVE(func) Java_org_eclipse_swt_awt_SWT_1AWT_##func |
| 20 | + |
| 21 | +#ifndef NO_getAWTHandle |
| 22 | +JNIEXPORT jlong JNICALL SWT_AWT_NATIVE(getAWTHandle) |
| 23 | +(JNIEnv *env, jclass that, jobject canvas) { |
| 24 | + JAWT awt; |
| 25 | + JAWT_DrawingSurface* ds; |
| 26 | + JAWT_DrawingSurfaceInfo* dsi; |
| 27 | + JAWT_Win32DrawingSurfaceInfo* dsi_win; |
| 28 | + jlong result = 0; |
| 29 | + jint lock; |
| 30 | + |
| 31 | + awt.version = JAWT_VERSION_1_4; |
| 32 | + if (JAWT_GetAWT(env, &awt) != 0) { |
| 33 | + ds = awt.GetDrawingSurface(env, canvas); |
| 34 | + if (ds != NULL) { |
| 35 | + lock = ds->Lock(ds); |
| 36 | + if ((lock & JAWT_LOCK_ERROR) == 0) { |
| 37 | + dsi = ds->GetDrawingSurfaceInfo(ds); |
| 38 | + dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo; |
| 39 | + result = (jlong)dsi_win->hwnd; |
| 40 | + ds->FreeDrawingSurfaceInfo(dsi); |
| 41 | + ds->Unlock(ds); |
| 42 | + } |
| 43 | + } |
| 44 | + awt.FreeDrawingSurface(ds); |
| 45 | + } |
| 46 | + return result; |
| 47 | +} |
| 48 | +#endif |
| 49 | + |
| 50 | +#ifndef NO_setDebug |
| 51 | +JNIEXPORT void JNICALL SWT_AWT_NATIVE(setDebug) |
| 52 | +(JNIEnv *env, jclass that, jobject frame, jboolean debug) { |
| 53 | + // Debug function not applicable on Windows, can be left empty or implement logging |
| 54 | +} |
| 55 | +#endif |
| 56 | + |
| 57 | +#ifndef NO_initFrame |
| 58 | +JNIEXPORT jobject JNICALL Java_org_eclipse_swt_awt_SWT_1AWT_initFrame |
| 59 | +(JNIEnv *env, jclass that, jlong handle) { |
| 60 | + jobject object; |
| 61 | + jmethodID constructor; |
| 62 | + |
| 63 | + jclass cls = (*env)->FindClass(env, "sun/awt/windows/WEmbeddedFrame"); |
| 64 | + if (NULL == cls) return NULL; |
| 65 | + constructor = (*env)->GetMethodID(env, cls, "<init>", "(J)V"); |
| 66 | + object = (*env)->NewObject(env, cls, constructor, handle, JNI_TRUE); |
| 67 | + return object; |
| 68 | +} |
| 69 | +#endif |
| 70 | + |
| 71 | +#ifndef NO_validateWithBounds |
| 72 | +JNIEXPORT void JNICALL Java_org_eclipse_swt_awt_SWT_1AWT_validateWithBounds |
| 73 | +(JNIEnv *env, jclass that, jobject frame, jint x, jint y, jint w, jint h) { |
| 74 | + jclass cls = (*env)->FindClass(env, "sun/awt/windows/WEmbeddedFrame"); |
| 75 | + if (NULL == cls) return; |
| 76 | + jmethodID midInit = (*env)->GetMethodID(env, cls, "validateWithBounds", "(IIII)V"); |
| 77 | + (*env)->CallVoidMethod(env, frame, midInit, x, y, w, h); |
| 78 | +} |
| 79 | +#endif |
| 80 | + |
| 81 | +#ifndef NO_synthesizeWindowActivation |
| 82 | +JNIEXPORT void JNICALL Java_org_eclipse_swt_awt_SWT_1AWT_synthesizeWindowActivation |
| 83 | +(JNIEnv *env, jclass that, jobject frame, jboolean doActivate) { |
| 84 | + jclass cls = (*env)->FindClass(env, "sun/awt/windows/WEmbeddedFrame"); |
| 85 | + if (NULL == cls) return; |
| 86 | + jmethodID midInit = (*env)->GetMethodID(env, cls, "synthesizeWindowActivation", "(Z)V"); |
| 87 | + (*env)->CallVoidMethod(env, frame, midInit, doActivate); |
| 88 | +} |
| 89 | +#endif |
| 90 | + |
| 91 | +#ifndef NO_registerListeners |
| 92 | +JNIEXPORT void JNICALL Java_org_eclipse_swt_awt_SWT_1AWT_registerListeners |
| 93 | +(JNIEnv *env, jclass that, jobject frame) { |
| 94 | + jclass cls = (*env)->FindClass(env, "sun/awt/windows/WEmbeddedFrame"); |
| 95 | + if (NULL == cls) return; |
| 96 | + jmethodID midInit = (*env)->GetMethodID(env, cls, "registerListeners", "()V"); |
| 97 | + (*env)->CallVoidMethod(env, frame, midInit); |
| 98 | +} |
| 99 | +#endif |
0 commit comments