6595651: Focus transfers broken for applications embedding AWT across processes
Now we allow cross-process focus requests if focus is in embedder's process. Reviewed-by: ant
This commit is contained in:
parent
1fd0bb2370
commit
2a20e69f1a
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user