< prev index next >
src/windows/native/sun/windows/awt_Component.cpp
Print this page
rev 12527 : 8165543: Better window framing
Reviewed-by: serb
*** 148,157 ****
--- 148,162 ----
// Struct for _SetFocus function
struct SetFocusStruct {
jobject component;
jboolean doSetFocus;
};
+ // Struct for _SetParent function
+ struct SetParentStruct {
+ jobject component;
+ jobject parentComp;
+ };
/************************************************************************/
//////////////////////////////////////////////////////////////////////////
/*************************************************************************
*** 259,271 ****
AwtComponent::~AwtComponent()
{
DASSERT(AwtToolkit::IsMainThread());
- /* Disconnect all links. */
- UnlinkObjects();
-
/*
* All the messages for this component are processed, native
* resources are freed, and Java object is not connected to
* the native one anymore. So we can safely destroy component's
* handle.
--- 264,273 ----
*** 273,282 ****
--- 275,286 ----
DestroyHWnd();
}
void AwtComponent::Dispose()
{
+ DASSERT(AwtToolkit::IsMainThread());
+
// NOTE: in case the component/toplevel was focused, Java should
// have already taken care of proper transferring it or clearing.
if (m_hdwp != NULL) {
// end any deferred window positioning, regardless
*** 291,302 ****
UnsubclassHWND();
/* Release global ref to input method */
SetInputMethod(NULL, TRUE);
! if (m_childList != NULL)
delete m_childList;
DestroyDropTarget();
ReleaseDragCapture(0);
if (m_myControlID != 0) {
--- 295,308 ----
UnsubclassHWND();
/* Release global ref to input method */
SetInputMethod(NULL, TRUE);
! if (m_childList != NULL) {
delete m_childList;
+ m_childList = NULL;
+ }
DestroyDropTarget();
ReleaseDragCapture(0);
if (m_myControlID != 0) {
*** 315,324 ****
--- 321,333 ----
if (m_brushBackground != NULL) {
m_brushBackground->Release();
m_brushBackground = NULL;
}
+ /* Disconnect all links. */
+ UnlinkObjects();
+
if (m_bPauseDestroy) {
// AwtComponent::WmNcDestroy could be released now
m_bPauseDestroy = FALSE;
m_hwnd = NULL;
}
*** 6121,6145 ****
env->DeleteGlobalRef(self);
return result;
}
! void AwtComponent::SetParent(void * param) {
if (AwtToolkit::IsMainThread()) {
! AwtComponent** comps = (AwtComponent**)param;
! if ((comps[0] != NULL) && (comps[1] != NULL)) {
! HWND selfWnd = comps[0]->GetHWnd();
! HWND parentWnd = comps[1]->GetHWnd();
if (::IsWindow(selfWnd) && ::IsWindow(parentWnd)) {
// Shouldn't trigger native focus change
// (only the proxy may be the native focus owner).
::SetParent(selfWnd, parentWnd);
}
! }
! delete[] comps;
} else {
! AwtToolkit::GetInstance().InvokeFunction(AwtComponent::SetParent, param);
}
}
void AwtComponent::_SetRectangularShape(void *param)
{
--- 6130,6169 ----
env->DeleteGlobalRef(self);
return result;
}
! void AwtComponent::_SetParent(void * param)
! {
if (AwtToolkit::IsMainThread()) {
! JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
! SetParentStruct *data = (SetParentStruct*) param;
! jobject self = data->component;
! jobject parent = data->parentComp;
!
! AwtComponent *awtComponent = NULL;
! AwtComponent *awtParent = NULL;
!
! PDATA pData;
! JNI_CHECK_PEER_GOTO(self, ret);
! awtComponent = (AwtComponent *)pData;
! JNI_CHECK_PEER_GOTO(parent, ret);
! awtParent = (AwtComponent *)pData;
!
! HWND selfWnd = awtComponent->GetHWnd();
! HWND parentWnd = awtParent->GetHWnd();
if (::IsWindow(selfWnd) && ::IsWindow(parentWnd)) {
// Shouldn't trigger native focus change
// (only the proxy may be the native focus owner).
::SetParent(selfWnd, parentWnd);
}
! ret:
! env->DeleteGlobalRef(self);
! env->DeleteGlobalRef(parent);
! delete data;
} else {
! AwtToolkit::GetInstance().InvokeFunction(AwtComponent::_SetParent, param);
}
}
void AwtComponent::_SetRectangularShape(void *param)
{
*** 6962,6980 ****
JNIEXPORT void JNICALL
Java_sun_awt_windows_WComponentPeer_pSetParent(JNIEnv* env, jobject self, jobject parent) {
TRY;
! typedef AwtComponent* PComponent;
! AwtComponent** comps = new PComponent[2];
! AwtComponent* comp = (AwtComponent*)JNI_GET_PDATA(self);
! AwtComponent* parentComp = (AwtComponent*)JNI_GET_PDATA(parent);
! comps[0] = comp;
! comps[1] = parentComp;
! AwtToolkit::GetInstance().SyncCall(AwtComponent::SetParent, comps);
! // comps is deleted in SetParent
CATCH_BAD_ALLOC;
}
JNIEXPORT void JNICALL
--- 6986,7001 ----
JNIEXPORT void JNICALL
Java_sun_awt_windows_WComponentPeer_pSetParent(JNIEnv* env, jobject self, jobject parent) {
TRY;
! SetParentStruct * data = new SetParentStruct;
! data->component = env->NewGlobalRef(self);
! data->parentComp = env->NewGlobalRef(parent);
! AwtToolkit::GetInstance().SyncCall(AwtComponent::_SetParent, data);
! // global refs and data are deleted in SetParent
CATCH_BAD_ALLOC;
}
JNIEXPORT void JNICALL
< prev index next >