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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -2190,8 +2190,11 @@ AwtComponent::AwtSetFocus()
|
|||||||
DWORD fgProcessID;
|
DWORD fgProcessID;
|
||||||
::GetWindowThreadProcessId(fgWindow, &fgProcessID);
|
::GetWindowThreadProcessId(fgWindow, &fgProcessID);
|
||||||
|
|
||||||
if (fgProcessID != ::GetCurrentProcessId()) {
|
if (fgProcessID != ::GetCurrentProcessId()
|
||||||
// fix for 6458497. we shouldn't request focus if it is out of our application.
|
&& !AwtToolkit::GetInstance().IsEmbedderProcessId(fgProcessID))
|
||||||
|
{
|
||||||
|
// fix for 6458497. we shouldn't request focus if it is out of both
|
||||||
|
// our and embedder process.
|
||||||
return FALSE;
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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.
|
// Update target's dimensions to reflect this embedded window.
|
||||||
::GetClientRect(frame->m_hwnd, &rect);
|
::GetClientRect(frame->m_hwnd, &rect);
|
||||||
::MapWindowPoints(frame->m_hwnd, hwndParent, (LPPOINT)&rect,
|
::MapWindowPoints(frame->m_hwnd, hwndParent, (LPPOINT)&rect, 2);
|
||||||
2);
|
|
||||||
|
|
||||||
env->SetIntField(target, AwtComponent::xID, rect.left);
|
env->SetIntField(target, AwtComponent::xID, rect.left);
|
||||||
env->SetIntField(target, AwtComponent::yID, rect.top);
|
env->SetIntField(target, AwtComponent::yID, rect.top);
|
||||||
@ -231,6 +230,7 @@ AwtFrame* AwtFrame::Create(jobject self, jobject parent)
|
|||||||
env->SetIntField(target, AwtComponent::heightID,
|
env->SetIntField(target, AwtComponent::heightID,
|
||||||
rect.bottom-rect.top);
|
rect.bottom-rect.top);
|
||||||
frame->InitPeerGraphicsConfig(env, self);
|
frame->InitPeerGraphicsConfig(env, self);
|
||||||
|
AwtToolkit::GetInstance().RegisterEmbedderProcessId(hwndParent);
|
||||||
} else {
|
} else {
|
||||||
jint state = env->GetIntField(target, AwtFrame::stateID);
|
jint state = env->GetIntField(target, AwtFrame::stateID);
|
||||||
DWORD exStyle;
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -354,6 +354,7 @@ AwtToolkit::AwtToolkit() {
|
|||||||
m_dllHandle = NULL;
|
m_dllHandle = NULL;
|
||||||
|
|
||||||
m_displayChanged = FALSE;
|
m_displayChanged = FALSE;
|
||||||
|
m_embedderProcessID = 0;
|
||||||
|
|
||||||
// XXX: keyboard mapping should really be moved out of AwtComponent
|
// XXX: keyboard mapping should really be moved out of AwtComponent
|
||||||
AwtComponent::InitDynamicKeyMapTable();
|
AwtComponent::InitDynamicKeyMapTable();
|
||||||
@ -1442,49 +1443,17 @@ void hang_if_shutdown(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// for now we support only one embedder, but should be ready for future
|
||||||
* Returns a reference to the class java.awt.Component.
|
void AwtToolkit::RegisterEmbedderProcessId(HWND embedder)
|
||||||
*/
|
|
||||||
jclass
|
|
||||||
getComponentClass(JNIEnv *env)
|
|
||||||
{
|
{
|
||||||
static jclass componentCls = NULL;
|
if (m_embedderProcessID) {
|
||||||
|
// we already set embedder process and do not expect
|
||||||
// get global reference of java/awt/Component class (run only once)
|
// two different processes to embed the same AwtToolkit
|
||||||
if (componentCls == NULL) {
|
return;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
return componentCls;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
embedder = ::GetAncestor(embedder, GA_ROOT);
|
||||||
/*
|
::GetWindowThreadProcessId(embedder, &m_embedderProcessID);
|
||||||
* 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEnv* AwtToolkit::m_env;
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -426,10 +426,17 @@ private:
|
|||||||
*/
|
*/
|
||||||
private:
|
private:
|
||||||
BOOL m_displayChanged; /* Tracks displayChanged events */
|
BOOL m_displayChanged; /* Tracks displayChanged events */
|
||||||
|
// 0 means we are not embedded.
|
||||||
|
DWORD m_embedderProcessID;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BOOL HasDisplayChanged() { return m_displayChanged; }
|
BOOL HasDisplayChanged() { return m_displayChanged; }
|
||||||
void ResetDisplayChanged() { m_displayChanged = FALSE; }
|
void ResetDisplayChanged() { m_displayChanged = FALSE; }
|
||||||
|
void RegisterEmbedderProcessId(HWND);
|
||||||
|
BOOL IsEmbedderProcessId(const DWORD processID) const
|
||||||
|
{
|
||||||
|
return m_embedderProcessID && (processID == m_embedderProcessID);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static JNIEnv *m_env;
|
static JNIEnv *m_env;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user