提交 4296a9f2 编写于 作者: S son

6595651: Focus transfers broken for applications embedding AWT across processes

Summary: Now we allow cross-process focus requests if focus is in embedder's process.
Reviewed-by: ant
上级 7a0daf2b
/*
* Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1996-2008 Sun Microsystems, Inc. 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
......@@ -2190,8 +2190,11 @@ AwtComponent::AwtSetFocus()
DWORD fgProcessID;
::GetWindowThreadProcessId(fgWindow, &fgProcessID);
if (fgProcessID != ::GetCurrentProcessId()) {
// fix for 6458497. we shouldn't request focus if it is out of our application.
if (fgProcessID != ::GetCurrentProcessId()
&& !AwtToolkit::GetInstance().IsEmbedderProcessId(fgProcessID))
{
// fix for 6458497. we shouldn't request focus if it is out of both
// our and embedder process.
return FALSE;
}
}
......
/*
* Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1996-2008 Sun Microsystems, Inc. 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
......@@ -221,8 +221,7 @@ AwtFrame* AwtFrame::Create(jobject self, jobject parent)
// Update target's dimensions to reflect this embedded window.
::GetClientRect(frame->m_hwnd, &rect);
::MapWindowPoints(frame->m_hwnd, hwndParent, (LPPOINT)&rect,
2);
::MapWindowPoints(frame->m_hwnd, hwndParent, (LPPOINT)&rect, 2);
env->SetIntField(target, AwtComponent::xID, rect.left);
env->SetIntField(target, AwtComponent::yID, rect.top);
......@@ -231,6 +230,7 @@ AwtFrame* AwtFrame::Create(jobject self, jobject parent)
env->SetIntField(target, AwtComponent::heightID,
rect.bottom-rect.top);
frame->InitPeerGraphicsConfig(env, self);
AwtToolkit::GetInstance().RegisterEmbedderProcessId(hwndParent);
} else {
jint state = env->GetIntField(target, AwtFrame::stateID);
DWORD exStyle;
......
/*
* Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1996-2008 Sun Microsystems, Inc. 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
......@@ -354,6 +354,7 @@ AwtToolkit::AwtToolkit() {
m_dllHandle = NULL;
m_displayChanged = FALSE;
m_embedderProcessID = 0;
// XXX: keyboard mapping should really be moved out of AwtComponent
AwtComponent::InitDynamicKeyMapTable();
......@@ -1442,49 +1443,17 @@ void hang_if_shutdown(void)
}
}
/*
* Returns a reference to the class java.awt.Component.
*/
jclass
getComponentClass(JNIEnv *env)
// for now we support only one embedder, but should be ready for future
void AwtToolkit::RegisterEmbedderProcessId(HWND embedder)
{
static jclass componentCls = NULL;
// get global reference of java/awt/Component class (run only once)
if (componentCls == NULL) {
jclass componentClsLocal = env->FindClass("java/awt/Component");
DASSERT(componentClsLocal != NULL);
if (componentClsLocal == NULL) {
/* exception already thrown */
return NULL;
}
componentCls = (jclass)env->NewGlobalRef(componentClsLocal);
env->DeleteLocalRef(componentClsLocal);
if (m_embedderProcessID) {
// we already set embedder process and do not expect
// two different processes to embed the same AwtToolkit
return;
}
return componentCls;
}
/*
* Returns a reference to the class java.awt.MenuComponent.
*/
jclass
getMenuComponentClass(JNIEnv *env)
{
static jclass menuComponentCls = NULL;
// get global reference of java/awt/MenuComponent class (run only once)
if (menuComponentCls == NULL) {
jclass menuComponentClsLocal = env->FindClass("java/awt/MenuComponent");
DASSERT(menuComponentClsLocal != NULL);
if (menuComponentClsLocal == NULL) {
/* exception already thrown */
return NULL;
}
menuComponentCls = (jclass)env->NewGlobalRef(menuComponentClsLocal);
env->DeleteLocalRef(menuComponentClsLocal);
}
return menuComponentCls;
embedder = ::GetAncestor(embedder, GA_ROOT);
::GetWindowThreadProcessId(embedder, &m_embedderProcessID);
}
JNIEnv* AwtToolkit::m_env;
......
/*
* Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1996-2008 Sun Microsystems, Inc. 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
......@@ -426,10 +426,17 @@ private:
*/
private:
BOOL m_displayChanged; /* Tracks displayChanged events */
// 0 means we are not embedded.
DWORD m_embedderProcessID;
public:
BOOL HasDisplayChanged() { return m_displayChanged; }
void ResetDisplayChanged() { m_displayChanged = FALSE; }
void RegisterEmbedderProcessId(HWND);
BOOL IsEmbedderProcessId(const DWORD processID) const
{
return m_embedderProcessID && (processID == m_embedderProcessID);
}
private:
static JNIEnv *m_env;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册