]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.eclipse.swt.win32.win32.x86_64/library/swt_awt.c
Work around SWT 4.13 - 4.18 Win32 DnD bug 567422
[simantics/platform.git] / bundles / org.eclipse.swt.win32.win32.x86_64 / library / swt_awt.c
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
18 #define SWT_AWT_NATIVE(func) Java_org_eclipse_swt_awt_SWT_1AWT_##func
19
20 #ifndef NO_getAWTHandle
21 JNIEXPORT jintLong JNICALL SWT_AWT_NATIVE(getAWTHandle)
22         (JNIEnv *env, jclass that, jobject canvas)
23 {
24         JAWT awt;
25         JAWT_DrawingSurface* ds;
26         JAWT_DrawingSurfaceInfo* dsi;
27         JAWT_Win32DrawingSurfaceInfo* dsi_win;
28         jintLong result = 0;
29         jint lock;
30
31         awt.version = JAWT_VERSION_1_3;
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 = (jintLong)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_initFrame
51 JNIEXPORT jobject JNICALL SWT_AWT_NATIVE(initFrame)
52         (JNIEnv *env, jclass that, jintLong handle, jstring className)
53 {
54         jobject object;
55         jmethodID constructor;
56         
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);
61         return object;
62 }
63 #endif
64
65 #ifndef NO_synthesizeWindowActivation
66 JNIEXPORT void JNICALL SWT_AWT_NATIVE(synthesizeWindowActivation)
67 (JNIEnv *env, jclass that, jobject frame, jboolean doActivate)
68 {
69         jmethodID midInit;
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);
74 }
75 #endif