8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
Reviewed-by: alanb, prr
This commit is contained in:
parent
966cbcfce3
commit
a5e760b81c
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -238,6 +238,10 @@ SUNWprivate_1.1 {
|
||||
awt_GetDrawingSurface;
|
||||
awt_FreeDrawingSurface;
|
||||
awt_GetComponent;
|
||||
awt_CreateEmbeddedFrame;
|
||||
awt_SetBounds;
|
||||
awt_SynthesizeWindowActivation;
|
||||
|
||||
|
||||
X11SurfaceData_GetOps;
|
||||
getDefaultConfig;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -264,6 +264,10 @@ SUNWprivate_1.1 {
|
||||
awt_GetDrawingSurface;
|
||||
awt_FreeDrawingSurface;
|
||||
awt_GetComponent;
|
||||
awt_CreateEmbeddedFrame;
|
||||
awt_SetBounds;
|
||||
awt_SynthesizeWindowActivation;
|
||||
|
||||
|
||||
X11SurfaceData_GetOps;
|
||||
getDefaultConfig;
|
||||
|
@ -458,6 +458,9 @@ SUNWprivate_1.1 {
|
||||
awt_Unlock;
|
||||
awt_Lock;
|
||||
awt_GetComponent;
|
||||
awt_CreateEmbeddedFrame;
|
||||
awt_SetBounds;
|
||||
awt_SynthesizeWindowActivation;
|
||||
|
||||
#XAWT entry point for CDE
|
||||
Java_sun_awt_motif_XsessionWMcommand;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,6 +27,8 @@
|
||||
|
||||
#import "AWTSurfaceLayers.h"
|
||||
|
||||
#import "jni_util.h"
|
||||
|
||||
JNIEXPORT JAWT_DrawingSurfaceInfo* JNICALL awt_DrawingSurface_GetDrawingSurfaceInfo
|
||||
(JAWT_DrawingSurface* ds)
|
||||
{
|
||||
@ -130,3 +132,47 @@ JNIEXPORT jobject JNICALL awt_GetComponent
|
||||
// TODO: implement
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// EmbeddedFrame support
|
||||
|
||||
static char *const embeddedClassName = "sun/lwawt/macosx/CViewEmbeddedFrame";
|
||||
|
||||
JNIEXPORT jobject JNICALL awt_CreateEmbeddedFrame
|
||||
(JNIEnv* env, void* platformInfo)
|
||||
{
|
||||
static jmethodID mid = NULL;
|
||||
static jclass cls;
|
||||
if (mid == NULL) {
|
||||
cls = (*env)->FindClass(env, embeddedClassName);
|
||||
CHECK_NULL_RETURN(cls, NULL);
|
||||
mid = (*env)->GetMethodID(env, cls, "<init>", "(J)V");
|
||||
CHECK_NULL_RETURN(mid, NULL);
|
||||
}
|
||||
return (*env)->NewObject(env, cls, mid, platformInfo);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL awt_SetBounds
|
||||
(JNIEnv *env, jobject embeddedFrame, jint x, jint y, jint w, jint h)
|
||||
{
|
||||
static jmethodID mid = NULL;
|
||||
if (mid == NULL) {
|
||||
jclass cls = (*env)->FindClass(env, embeddedClassName);
|
||||
CHECK_NULL(cls);
|
||||
mid = (*env)->GetMethodID(env, cls, "setBoundsPrivate", "(IIII)V");
|
||||
CHECK_NULL(mid);
|
||||
}
|
||||
(*env)->CallVoidMethod(env, embeddedFrame, mid, x, y, w, h);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL awt_SynthesizeWindowActivation
|
||||
(JNIEnv *env, jobject embeddedFrame, jboolean doActivate)
|
||||
{
|
||||
static jmethodID mid = NULL;
|
||||
if (mid == NULL) {
|
||||
jclass cls = (*env)->FindClass(env, embeddedClassName);
|
||||
CHECK_NULL(cls);
|
||||
mid = (*env)->GetMethodID(env, cls, "synthesizeWindowActivation", "(Z)V");
|
||||
CHECK_NULL(mid);
|
||||
}
|
||||
(*env)->CallVoidMethod(env, embeddedFrame, mid, doActivate);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -46,8 +46,9 @@ JNIEXPORT jboolean JNICALL JAWT_GetAWT
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
if (awt->version != (JAWT_VERSION_1_4 | JAWT_MACOSX_USE_CALAYER) &&
|
||||
awt->version != JAWT_VERSION_1_7)
|
||||
if (awt->version != (JAWT_VERSION_1_4 | JAWT_MACOSX_USE_CALAYER)
|
||||
&& awt->version != JAWT_VERSION_1_7
|
||||
&& awt->version != JAWT_VERSION_9)
|
||||
{
|
||||
return JNI_FALSE;
|
||||
}
|
||||
@ -58,6 +59,11 @@ JNIEXPORT jboolean JNICALL JAWT_GetAWT
|
||||
awt->Lock = awt_Lock;
|
||||
awt->Unlock = awt_Unlock;
|
||||
awt->GetComponent = awt_GetComponent;
|
||||
if (awt->version >= JAWT_VERSION_9) {
|
||||
awt->CreateEmbeddedFrame = awt_CreateEmbeddedFrame;
|
||||
awt->SetBounds = awt_SetBounds;
|
||||
awt->SynthesizeWindowActivation = awt_SynthesizeWindowActivation;
|
||||
}
|
||||
}
|
||||
|
||||
return JNI_TRUE;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -33,7 +33,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* AWT native interface (new in JDK 1.3)
|
||||
* AWT native interface.
|
||||
*
|
||||
* The AWT native interface allows a native C or C++ application a means
|
||||
* by which to access native structures in AWT. This is to facilitate moving
|
||||
@ -279,6 +279,50 @@ typedef struct jawt {
|
||||
*/
|
||||
jobject (JNICALL *GetComponent)(JNIEnv* env, void* platformInfo);
|
||||
|
||||
/**
|
||||
* Since 9
|
||||
* Creates a java.awt.Frame placed in a native container. Container is
|
||||
* referenced by the native platform handle. For example on Windows this
|
||||
* corresponds to an HWND. For other platforms, see the appropriate
|
||||
* machine-dependent header file for a description. The reference returned
|
||||
* by this function is a local reference that is only valid in this
|
||||
* environment. This function returns a NULL reference if no frame could be
|
||||
* created with matching platform information.
|
||||
*/
|
||||
jobject (JNICALL *CreateEmbeddedFrame) (JNIEnv *env, void* platformInfo);
|
||||
|
||||
/**
|
||||
* Since 9
|
||||
* Moves and resizes the embedded frame. The new location of the top-left
|
||||
* corner is specified by x and y parameters relative to the native parent
|
||||
* component. The new size is specified by width and height.
|
||||
*
|
||||
* The embedded frame should be created by CreateEmbeddedFrame() method, or
|
||||
* this function will not have any effect.
|
||||
*
|
||||
* java.awt.Component.setLocation() and java.awt.Component.setBounds() for
|
||||
* EmbeddedFrame really don't move it within the native parent. These
|
||||
* methods always locate the embedded frame at (0, 0) for backward
|
||||
* compatibility. To allow moving embedded frames this method was
|
||||
* introduced, and it works just the same way as setLocation() and
|
||||
* setBounds() for usual, non-embedded components.
|
||||
*
|
||||
* Using usual get/setLocation() and get/setBounds() together with this new
|
||||
* method is not recommended.
|
||||
*/
|
||||
void (JNICALL *SetBounds) (JNIEnv *env, jobject embeddedFrame,
|
||||
jint x, jint y, jint w, jint h);
|
||||
/**
|
||||
* Since 9
|
||||
* Synthesize a native message to activate or deactivate an EmbeddedFrame
|
||||
* window depending on the value of parameter doActivate, if "true"
|
||||
* activates the window; otherwise, deactivates the window.
|
||||
*
|
||||
* The embedded frame should be created by CreateEmbeddedFrame() method, or
|
||||
* this function will not have any effect.
|
||||
*/
|
||||
void (JNICALL *SynthesizeWindowActivation) (JNIEnv *env,
|
||||
jobject embeddedFrame, jboolean doActivate);
|
||||
} JAWT;
|
||||
|
||||
/*
|
||||
@ -291,6 +335,7 @@ jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt);
|
||||
#define JAWT_VERSION_1_3 0x00010003
|
||||
#define JAWT_VERSION_1_4 0x00010004
|
||||
#define JAWT_VERSION_1_7 0x00010007
|
||||
#define JAWT_VERSION_9 0x00090000
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,7 +28,6 @@
|
||||
|
||||
#include <jawt.h>
|
||||
#include <jni.h>
|
||||
#include <jni_util.h>
|
||||
|
||||
_JNI_IMPORT_OR_EXPORT_ JAWT_DrawingSurface* JNICALL
|
||||
awt_GetDrawingSurface(JNIEnv* env, jobject target);
|
||||
@ -45,4 +44,14 @@ _JNI_IMPORT_OR_EXPORT_ void JNICALL
|
||||
_JNI_IMPORT_OR_EXPORT_ jobject JNICALL
|
||||
awt_GetComponent(JNIEnv* env, void* platformInfo);
|
||||
|
||||
_JNI_IMPORT_OR_EXPORT_ jobject JNICALL
|
||||
awt_CreateEmbeddedFrame(JNIEnv* env, void* platformInfo);
|
||||
|
||||
_JNI_IMPORT_OR_EXPORT_ void JNICALL
|
||||
awt_SetBounds(JNIEnv *env, jobject embeddedFrame, jint x, jint y,
|
||||
jint w, jint h);
|
||||
|
||||
_JNI_IMPORT_OR_EXPORT_ void JNICALL
|
||||
awt_SynthesizeWindowActivation(JNIEnv *env, jobject embeddedFrame,
|
||||
jboolean doActivate);
|
||||
#endif /* !_AWT_DRAWING_SURFACE_H_ */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -383,3 +383,48 @@ JNIEXPORT jobject JNICALL
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
// EmbeddedFrame support
|
||||
|
||||
static char *const embeddedClassName = "sun/awt/X11/XEmbeddedFrame";
|
||||
|
||||
JNIEXPORT jobject JNICALL awt_CreateEmbeddedFrame
|
||||
(JNIEnv* env, void* platformInfo)
|
||||
{
|
||||
static jmethodID mid = NULL;
|
||||
static jclass cls;
|
||||
if (mid == NULL) {
|
||||
cls = (*env)->FindClass(env, embeddedClassName);
|
||||
CHECK_NULL_RETURN(cls, NULL);
|
||||
mid = (*env)->GetMethodID(env, cls, "<init>", "(JZ)V");
|
||||
CHECK_NULL_RETURN(mid, NULL);
|
||||
}
|
||||
return (*env)->NewObject(env, cls, mid, platformInfo, JNI_TRUE);
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL awt_SetBounds
|
||||
(JNIEnv *env, jobject embeddedFrame, jint x, jint y, jint w, jint h)
|
||||
{
|
||||
static jmethodID mid = NULL;
|
||||
if (mid == NULL) {
|
||||
jclass cls = (*env)->FindClass(env, embeddedClassName);
|
||||
CHECK_NULL(cls);
|
||||
mid = (*env)->GetMethodID(env, cls, "setBoundsPrivate", "(IIII)V");
|
||||
CHECK_NULL(mid);
|
||||
}
|
||||
(*env)->CallVoidMethod(env, embeddedFrame, mid, x, y, w, h);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL awt_SynthesizeWindowActivation
|
||||
(JNIEnv *env, jobject embeddedFrame, jboolean doActivate)
|
||||
{
|
||||
static jmethodID mid = NULL;
|
||||
if (mid == NULL) {
|
||||
jclass cls = (*env)->FindClass(env, embeddedClassName);
|
||||
CHECK_NULL(cls);
|
||||
mid = (*env)->GetMethodID(env, cls, "synthesizeWindowActivation", "(Z)V");
|
||||
CHECK_NULL(mid);
|
||||
}
|
||||
(*env)->CallVoidMethod(env, embeddedFrame, mid, doActivate);
|
||||
}
|
||||
|
@ -45,7 +45,8 @@ JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt)
|
||||
|
||||
if (awt->version != JAWT_VERSION_1_3
|
||||
&& awt->version != JAWT_VERSION_1_4
|
||||
&& awt->version != JAWT_VERSION_1_7) {
|
||||
&& awt->version != JAWT_VERSION_1_7
|
||||
&& awt->version != JAWT_VERSION_9) {
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
@ -55,6 +56,11 @@ JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt)
|
||||
awt->Lock = awt_Lock;
|
||||
awt->Unlock = awt_Unlock;
|
||||
awt->GetComponent = awt_GetComponent;
|
||||
if (awt->version >= JAWT_VERSION_9) {
|
||||
awt->CreateEmbeddedFrame = awt_CreateEmbeddedFrame;
|
||||
awt->SetBounds = awt_SetBounds;
|
||||
awt->SynthesizeWindowActivation = awt_SynthesizeWindowActivation;
|
||||
}
|
||||
}
|
||||
|
||||
return JNI_TRUE;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -272,3 +272,47 @@ extern "C" JNIEXPORT void JNICALL DSUnlockAWT(JNIEnv* env)
|
||||
{
|
||||
// Do nothing on Windows
|
||||
}
|
||||
|
||||
// EmbeddedFrame support
|
||||
|
||||
static char *const embeddedClassName = "sun/awt/windows/WEmbeddedFrame";
|
||||
|
||||
JNIEXPORT jobject JNICALL awt_CreateEmbeddedFrame
|
||||
(JNIEnv* env, void* platformInfo)
|
||||
{
|
||||
static jmethodID mid = NULL;
|
||||
static jclass cls;
|
||||
if (mid == NULL) {
|
||||
cls = env->FindClass(embeddedClassName);
|
||||
CHECK_NULL_RETURN(cls, NULL);
|
||||
mid = env->GetMethodID(cls, "<init>", "(J)V");
|
||||
CHECK_NULL_RETURN(mid, NULL);
|
||||
}
|
||||
return env->NewObject(cls, mid, platformInfo);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL awt_SetBounds
|
||||
(JNIEnv *env, jobject embeddedFrame, jint x, jint y, jint w, jint h)
|
||||
{
|
||||
static jmethodID mid = NULL;
|
||||
if (mid == NULL) {
|
||||
jclass cls = env->FindClass(embeddedClassName);
|
||||
CHECK_NULL(cls);
|
||||
mid = env->GetMethodID(cls, "setBoundsPrivate", "(IIII)V");
|
||||
CHECK_NULL(mid);
|
||||
}
|
||||
env->CallVoidMethod(embeddedFrame, mid, x, y, w, h);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL awt_SynthesizeWindowActivation
|
||||
(JNIEnv *env, jobject embeddedFrame, jboolean doActivate)
|
||||
{
|
||||
static jmethodID mid = NULL;
|
||||
if (mid == NULL) {
|
||||
jclass cls = env->FindClass(embeddedClassName);
|
||||
CHECK_NULL(cls);
|
||||
mid = env->GetMethodID(cls, "synthesizeWindowActivation", "(Z)V");
|
||||
CHECK_NULL(mid);
|
||||
}
|
||||
env->CallVoidMethod(embeddedFrame, mid, doActivate);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -162,6 +162,16 @@ extern "C" {
|
||||
jobject JNICALL DSGetComponent(
|
||||
JNIEnv* env, void* platformInfo);
|
||||
|
||||
_JNI_IMPORT_OR_EXPORT_ jobject JNICALL
|
||||
awt_CreateEmbeddedFrame(JNIEnv* env, void* platformInfo);
|
||||
|
||||
_JNI_IMPORT_OR_EXPORT_ void JNICALL
|
||||
awt_SetBounds(JNIEnv *env, jobject embeddedFrame, jint x,
|
||||
jint y, jint w, jint h);
|
||||
|
||||
_JNI_IMPORT_OR_EXPORT_ void JNICALL
|
||||
awt_SynthesizeWindowActivation(JNIEnv *env, jobject embeddedFrame,
|
||||
jboolean doActivate);
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -46,7 +46,9 @@ extern "C" JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt)
|
||||
}
|
||||
|
||||
if (awt->version != JAWT_VERSION_1_3
|
||||
&& awt->version != JAWT_VERSION_1_4) {
|
||||
&& awt->version != JAWT_VERSION_1_4
|
||||
&& awt->version != JAWT_VERSION_1_7
|
||||
&& awt->version != JAWT_VERSION_9) {
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
@ -56,6 +58,11 @@ extern "C" JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt)
|
||||
awt->Lock = DSLockAWT;
|
||||
awt->Unlock = DSUnlockAWT;
|
||||
awt->GetComponent = DSGetComponent;
|
||||
if (awt->version >= JAWT_VERSION_9) {
|
||||
awt->CreateEmbeddedFrame = awt_CreateEmbeddedFrame;
|
||||
awt->SetBounds = awt_SetBounds;
|
||||
awt->SynthesizeWindowActivation = awt_SynthesizeWindowActivation;
|
||||
}
|
||||
}
|
||||
|
||||
return JNI_TRUE;
|
||||
|
Loading…
Reference in New Issue
Block a user