src/windows/native/sun/windows/awt_Frame.cpp
Print this page
@@ -103,10 +103,11 @@
AwtFrame::AwtFrame() {
m_parentWnd = NULL;
menuBar = NULL;
m_isEmbedded = FALSE;
+ m_isLightweight = FALSE;
m_ignoreWmSize = FALSE;
m_isMenuDropped = FALSE;
m_isInputMethodWindow = FALSE;
m_isUndecorated = FALSE;
m_imeTargetComponent = NULL;
@@ -168,26 +169,32 @@
/*
* A variation on Netscape's hack for embedded frames: the client
* area of the browser is a Java Frame for parenting purposes, but
* really a Windows child window
*/
+ BOOL isEmbeddedInstance = FALSE;
+ BOOL isEmbedded = FALSE;
cls = env->FindClass("sun/awt/EmbeddedFrame");
- if (cls == NULL) {
- return NULL;
+ if (cls) {
+ isEmbeddedInstance = env->IsInstanceOf(target, cls);
}
INT_PTR handle;
- jboolean isEmbeddedInstance = env->IsInstanceOf(target, cls);
- jboolean isEmbedded = FALSE;
-
if (isEmbeddedInstance) {
handle = static_cast<INT_PTR>(env->GetLongField(target, AwtFrame::handleID));
if (handle != 0) {
isEmbedded = TRUE;
}
}
frame->m_isEmbedded = isEmbedded;
+ BOOL isLightweight = FALSE;
+ cls = env->FindClass("sun/awt/LightweightFrame");
+ if (cls) {
+ isLightweight = env->IsInstanceOf(target, cls);
+ }
+ frame->m_isLightweight = isLightweight;
+
if (isEmbedded) {
hwndParent = (HWND)handle;
RECT rect;
::GetClientRect(hwndParent, &rect);
//Fix for 6328675: SWT_AWT.new_Frame doesn't occupy client area under JDK6
@@ -228,10 +235,27 @@
rect.right-rect.left);
env->SetIntField(target, AwtComponent::heightID,
rect.bottom-rect.top);
frame->InitPeerGraphicsConfig(env, self);
AwtToolkit::GetInstance().RegisterEmbedderProcessId(hwndParent);
+ } else if (isLightweight) {
+ frame->m_isUndecorated = true;
+ frame->m_peerObject = env->NewGlobalRef(self);
+ frame->RegisterClass();
+
+ DWORD exStyle = 0;
+ DWORD style = WS_POPUP;
+
+ frame->CreateHWnd(env, L"",
+ style,
+ exStyle,
+ 0, 0, 0, 0,
+ 0,
+ NULL,
+ ::GetSysColor(COLOR_WINDOWTEXT),
+ ::GetSysColor(COLOR_WINDOWFRAME),
+ self);
} else {
jint state = env->CallIntMethod(self, AwtFrame::getExtendedStateMID);
DWORD exStyle;
DWORD style;
@@ -343,20 +367,24 @@
}
break;
case WM_SETFOCUS:
if (sm_inSynthesizeFocus) break; // pass it up the WindowProc chain
- if (!sm_suppressFocusAndActivation && IsEmbeddedFrame()) {
+ if (!sm_suppressFocusAndActivation) {
+ if (IsLightweightFrame() || IsEmbeddedFrame()) {
AwtSetActiveWindow();
}
+ }
mr = mrConsume;
break;
case WM_KILLFOCUS:
if (sm_inSynthesizeFocus) break; // pass it up the WindowProc chain
- if (!sm_suppressFocusAndActivation && IsEmbeddedFrame()) {
+ if (!sm_suppressFocusAndActivation) {
+ if (IsLightweightFrame() || IsEmbeddedFrame()) {
AwtWindow::SynthesizeWmActivate(FALSE, GetHWnd(), NULL);
+ }
} else if (sm_restoreFocusAndActivation) {
if (AwtComponent::GetFocusedWindow() != NULL) {
AwtWindow *focusedWindow = (AwtWindow*)GetComponent(AwtComponent::GetFocusedWindow());
if (focusedWindow != NULL) {
@@ -638,10 +666,14 @@
{
m_visible = true;
HWND hwnd = GetHWnd();
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+ if (IsLightweightFrame()) {
+ return;
+ }
+
DTRACE_PRINTLN3("AwtFrame::Show:%s%s%s",
m_iconic ? " iconic" : "",
m_zoomed ? " zoomed" : "",
m_iconic || m_zoomed ? "" : " normal");
@@ -990,10 +1022,13 @@
// Don't let the actualFocusedWindow to steal focus if:
// a) the frame is clicked in its client area;
// b) focus is requested to some of the frame's child.
m_actualFocusedWindow = NULL;
}
+ if (IsLightweightFrame()) {
+ return TRUE;
+ }
return AwtWindow::AwtSetActiveWindow(isMouseEventCause);
}
MsgRouting AwtFrame::WmEnterMenuLoop(BOOL isTrackPopupMenu)
{
@@ -1871,11 +1906,11 @@
CATCH_BAD_ALLOC_RET(NULL);
}
JNIEXPORT void JNICALL
-Java_sun_awt_windows_WEmbeddedFramePeer_synthesizeWmActivate(JNIEnv *env, jobject self, jboolean doActivate)
+Java_sun_awt_windows_WFramePeer_synthesizeWmActivate(JNIEnv *env, jobject self, jboolean doActivate)
{
TRY;
SynthesizeWmActivateStruct *sas = new SynthesizeWmActivateStruct;
sas->frame = env->NewGlobalRef(self);