Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/windows/native/sun/bridge/JAWTAccessBridge.cpp
32287 views
1
/*
2
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
/*
27
* A DLL which is loaded by Java applications and used to map
28
* between Java applications and native Win32 window handles.
29
*/
30
31
#include "com_sun_java_accessibility_AccessBridge.h" // programatically generated by JNI
32
33
#include <windows.h>
34
#include <stdio.h>
35
36
#include <jawt.h>
37
#include <win32/jawt_md.h>
38
39
// ---------------------------------------------------------------------------
40
41
extern "C" {
42
/**
43
* DllMain - where Windows executables will load/unload us
44
*
45
*/
46
BOOL WINAPI DllMain(HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved) {
47
48
return TRUE;
49
}
50
51
52
/*
53
* Map a HWND to a Java component
54
*
55
* Class: com_sun_java_accessibility_AccessBridge
56
* Method: jawtGetComponentFromNativeWindowHandle
57
* Signature: (I)Ljava/awt/Component;
58
*/
59
JNIEXPORT jobject JNICALL
60
Java_com_sun_java_accessibility_AccessBridge_jawtGetComponentFromNativeWindowHandle
61
(JNIEnv *env, jobject callingObj, jint windowHandle) {
62
63
JAWT awt;
64
jboolean result;
65
jobject component = (jobject)0;
66
67
// Get the AWT
68
awt.version = JAWT_VERSION_1_4;
69
result = JAWT_GetAWT(env, &awt);
70
if (result == JNI_FALSE) {
71
return (jobject)0;
72
}
73
74
// Get the component
75
return awt.GetComponent(env, (void *)windowHandle);
76
}
77
78
79
/*
80
* Map a Java component to a HWND
81
*
82
* Class: com_sun_java_accessibility_AccessBridge
83
* Method: jawtGetNativeWindowHandleFromComponent
84
* Signature: (Ljava/awt/Component;)I
85
*/
86
JNIEXPORT jint JNICALL
87
Java_com_sun_java_accessibility_AccessBridge_jawtGetNativeWindowHandleFromComponent
88
(JNIEnv *env, jobject callingObj, jobject component)
89
{
90
91
JAWT awt;
92
JAWT_DrawingSurface* ds;
93
JAWT_DrawingSurfaceInfo* dsi;
94
JAWT_Win32DrawingSurfaceInfo* dsi_win;
95
jboolean result;
96
// jint lock;
97
jint windowHandle = -1;
98
99
// Get the AWT
100
awt.version = JAWT_VERSION_1_4;
101
result = JAWT_GetAWT(env, &awt);
102
if (result == JNI_FALSE) {
103
return -1;
104
}
105
106
// Get the drawing surface
107
ds = awt.GetDrawingSurface(env, component);
108
if (ds == NULL) {
109
return -1;
110
}
111
112
/*
113
* Should not be necessary.
114
*
115
// Lock the drawing surface
116
lock = ds->Lock(ds);
117
if ((lock & JAWT_LOCK_ERROR) != 0) {
118
return -1;
119
}
120
*/
121
122
// Get the drawing surface info
123
dsi = ds->GetDrawingSurfaceInfo(ds);
124
125
// Get the platform-specific drawing info
126
dsi_win = (JAWT_Win32DrawingSurfaceInfo *)dsi->platformInfo;
127
128
// Get the window handle
129
windowHandle = (jint)dsi_win->hwnd;
130
131
// Free the drawing surface info
132
ds->FreeDrawingSurfaceInfo(dsi);
133
134
/*
135
// Unlock the drawing surface
136
ds->Unlock(ds);
137
*/
138
139
// Free the drawing surface
140
awt.FreeDrawingSurface(ds);
141
142
return windowHandle;
143
}
144
}
145
146