7034291: Regression : Preedit String on active client is committed into unexpected component
Reviewed-by: art, naoto
--- a/jdk/src/windows/native/sun/windows/awt_Component.cpp Thu Apr 28 19:39:47 2011 +0400
+++ b/jdk/src/windows/native/sun/windows/awt_Component.cpp Fri Apr 29 16:02:05 2011 +0400
@@ -1203,7 +1203,7 @@
WIN_MSG(WM_IME_COMPOSITIONFULL)
WIN_MSG(WM_IME_SELECT)
WIN_MSG(WM_IME_CHAR)
- FMT_MSG(0x0288, "WM_IME_REQUEST")
+ FMT_MSG(WM_IME_REQUEST)
WIN_MSG(WM_IME_KEYDOWN)
WIN_MSG(WM_IME_KEYUP)
FMT_MSG(0x02A1, "WM_MOUSEHOVER")
@@ -1733,7 +1733,7 @@
case WM_IME_SELECT:
case WM_IME_KEYUP:
case WM_IME_KEYDOWN:
- case 0x0288: // WM_IME_REQUEST
+ case WM_IME_REQUEST:
CallProxyDefWindowProc(message, wParam, lParam, retValue, mr);
break;
case WM_CHAR:
@@ -4657,10 +4657,6 @@
ret:
if (c && ::IsWindow(c->GetHWnd())) {
sm_focusOwner = c->GetHWnd();
- AwtFrame *owner = (AwtFrame*)GetComponent(c->GetProxyToplevelContainer());
- if (owner) {
- owner->SetLastProxiedFocusOwner(sm_focusOwner);
- }
} else {
sm_focusOwner = NULL;
}
--- a/jdk/src/windows/native/sun/windows/awt_Frame.cpp Thu Apr 28 19:39:47 2011 +0400
+++ b/jdk/src/windows/native/sun/windows/awt_Frame.cpp Fri Apr 29 16:02:05 2011 +0400
@@ -109,7 +109,7 @@
m_isMenuDropped = FALSE;
m_isInputMethodWindow = FALSE;
m_isUndecorated = FALSE;
- m_lastProxiedFocusOwner = NULL;
+ m_imeTargetComponent = NULL;
m_actualFocusedWindow = NULL;
m_iconic = FALSE;
m_zoomed = FALSE;
@@ -311,6 +311,8 @@
LRESULT retValue = 0L;
AwtComponent *focusOwner = NULL;
+ AwtComponent *imeTargetComponent = NULL;
+
// IME and input language related messages need to be sent to a window
// which has the Java input focus
switch (message) {
@@ -323,15 +325,29 @@
case WM_IME_COMPOSITIONFULL:
case WM_IME_SELECT:
case WM_IME_CHAR:
- case 0x0288: // WM_IME_REQUEST
+ case WM_IME_REQUEST:
case WM_IME_KEYDOWN:
case WM_IME_KEYUP:
case WM_INPUTLANGCHANGEREQUEST:
case WM_INPUTLANGCHANGE:
+ if (message == WM_IME_STARTCOMPOSITION) {
+ SetImeTargetComponent(sm_focusOwner);
+ }
+ imeTargetComponent = AwtComponent::GetComponent(GetImeTargetComponent());
+ if (imeTargetComponent != NULL &&
+ imeTargetComponent != this) // avoid recursive calls
+ {
+ retValue = imeTargetComponent->WindowProc(message, wParam, lParam);
+ mr = mrConsume;
+ }
+ if (message == WM_IME_ENDCOMPOSITION) {
+ SetImeTargetComponent(NULL);
+ }
+ break;
// TODO: when a Choice's list is dropped down and we're scrolling in
// the list WM_MOUSEWHEEL messages come to the poxy, not to the list. Why?
case WM_MOUSEWHEEL:
- focusOwner = AwtComponent::GetComponent(GetLastProxiedFocusOwner());
+ focusOwner = AwtComponent::GetComponent(sm_focusOwner);
if (focusOwner != NULL &&
focusOwner != this) // avoid recursive calls
{
--- a/jdk/src/windows/native/sun/windows/awt_Frame.h Thu Apr 28 19:39:47 2011 +0400
+++ b/jdk/src/windows/native/sun/windows/awt_Frame.h Fri Apr 29 16:02:05 2011 +0400
@@ -150,8 +150,8 @@
void CheckRetainActualFocusedWindow(HWND activatedOpositeHWnd);
BOOL CheckActivateActualFocusedWindow(HWND deactivatedOpositeHWnd);
- INLINE HWND GetLastProxiedFocusOwner() { return m_lastProxiedFocusOwner; }
- INLINE void SetLastProxiedFocusOwner(HWND hwnd) { m_lastProxiedFocusOwner = hwnd; }
+ INLINE HWND GetImeTargetComponent() { return m_imeTargetComponent; }
+ INLINE void SetImeTargetComponent(HWND hwnd) { m_imeTargetComponent = hwnd; }
protected:
/* The frame is undecorated. */
@@ -179,9 +179,8 @@
/* The frame is an InputMethodWindow */
BOOL m_isInputMethodWindow;
- /* Retains the last/current sm_focusOwner proxied. Actually, it should be
- * a component of an owned window last/currently active. */
- HWND m_lastProxiedFocusOwner;
+ // retains the target component for the IME messages
+ HWND m_imeTargetComponent;
/*
* Fix for 4823903.