diff --git a/src/windows/native/sun/windows/awt_Frame.cpp b/src/windows/native/sun/windows/awt_Frame.cpp index 4748eac71b4f81c37d68d008732e941bb628c86c..ca874cac84171353e19d5d6cb50a11eab795fadc 100644 --- a/src/windows/native/sun/windows/awt_Frame.cpp +++ b/src/windows/native/sun/windows/awt_Frame.cpp @@ -109,7 +109,6 @@ AwtFrame::AwtFrame() { m_isMenuDropped = FALSE; m_isInputMethodWindow = FALSE; m_isUndecorated = FALSE; - m_proxyFocusOwner = NULL; m_lastProxiedFocusOwner = NULL; m_actualFocusedWindow = NULL; m_iconic = FALSE; @@ -127,7 +126,6 @@ AwtFrame::~AwtFrame() void AwtFrame::Dispose() { - DestroyProxyFocusOwner(); AwtWindow::Dispose(); } @@ -308,22 +306,9 @@ done: return frame; } -LRESULT CALLBACK AwtFrame::ProxyWindowProc(HWND hwnd, UINT message, - WPARAM wParam, LPARAM lParam) +LRESULT AwtFrame::ProxyWindowProc(UINT message, WPARAM wParam, LPARAM lParam, MsgRouting &mr) { - TRY; - - DASSERT(::IsWindow(hwnd)); - - AwtFrame *parent = (AwtFrame *) - AwtComponent::GetComponentImpl(::GetParent(hwnd)); - - if (!parent || parent->GetProxyFocusOwner() != hwnd || - message == AwtComponent::WmAwtIsComponent || - message == WM_GETOBJECT) - { - return ComCtl32Util::GetInstance().DefWindowProc(NULL, hwnd, message, wParam, lParam); - } + LRESULT retValue = 0L; AwtComponent *focusOwner = NULL; // IME and input language related messages need to be sent to a window @@ -346,19 +331,23 @@ LRESULT CALLBACK AwtFrame::ProxyWindowProc(HWND hwnd, UINT message, // 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(parent->GetLastProxiedFocusOwner()); - if (focusOwner != NULL) { - return focusOwner->WindowProc(message, wParam, lParam); + focusOwner = AwtComponent::GetComponent(GetLastProxiedFocusOwner()); + if (focusOwner != NULL && + focusOwner != this) // avoid recursive calls + { + retValue = focusOwner->WindowProc(message, wParam, lParam); + mr = mrConsume; } break; case WM_SETFOCUS: - if (!sm_suppressFocusAndActivation && parent->IsEmbeddedFrame()) { - parent->AwtSetActiveWindow(); + if (!sm_suppressFocusAndActivation && IsEmbeddedFrame()) { + AwtSetActiveWindow(); } - return 0; + mr = mrConsume; + break; case WM_KILLFOCUS: - if (!sm_suppressFocusAndActivation && parent->IsEmbeddedFrame()) { - AwtWindow::SynthesizeWmActivate(FALSE, parent->GetHWnd(), NULL); + if (!sm_suppressFocusAndActivation && IsEmbeddedFrame()) { + AwtWindow::SynthesizeWmActivate(FALSE, GetHWnd(), NULL); } else if (sm_restoreFocusAndActivation) { if (AwtComponent::GetFocusedWindow() != NULL) { @@ -369,64 +358,28 @@ LRESULT CALLBACK AwtFrame::ProxyWindowProc(HWND hwnd, UINT message, } } } - return 0; + mr = mrConsume; + break; case 0x0127: // WM_CHANGEUISTATE case 0x0128: // WM_UPDATEUISTATE - return 0; + mr = mrConsume; + break; } - return parent->WindowProc(message, wParam, lParam); - CATCH_BAD_ALLOC_RET(0); + return retValue; } -void AwtFrame::CreateProxyFocusOwner() +LRESULT AwtFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { - if (AwtToolkit::IsMainThread()) { - AwtFrame::_CreateProxyFocusOwner((void *)this); - } else { - AwtToolkit::GetInstance().InvokeFunction(AwtFrame::_CreateProxyFocusOwner, (void *)this); - } -} - -void AwtFrame::_CreateProxyFocusOwner(void *param) -{ - DASSERT(AwtToolkit::IsMainThread()); - - AwtFrame *f = (AwtFrame *)param; - DASSERT(f->m_proxyFocusOwner == NULL); - - f->m_proxyFocusOwner = ::CreateWindow(TEXT("STATIC"), - TEXT("ProxyFocusOwner"), - WS_CHILD, - 0, 0, 0, 0, f->GetHWnd(), NULL, - AwtToolkit::GetInstance(). - GetModuleHandle(), - NULL); - - f->m_proxyDefWindowProc = ComCtl32Util::GetInstance().SubclassHWND(f->m_proxyFocusOwner, ProxyWindowProc); -} + MsgRouting mr = mrDoDefault; + LRESULT retValue = 0L; -void AwtFrame::DestroyProxyFocusOwner() -{ - // proxy focus owner must be destroyed on toolkit thread only - if (AwtToolkit::IsMainThread()) { - AwtFrame::_DestroyProxyFocusOwner((void *)this); - } else { - AwtToolkit::GetInstance().InvokeFunction(AwtFrame::_DestroyProxyFocusOwner, (void *)this); - } -} + retValue = ProxyWindowProc(message, wParam, lParam, mr); -void AwtFrame::_DestroyProxyFocusOwner(void *param) -{ - DASSERT(AwtToolkit::IsMainThread()); - - AwtFrame *f = (AwtFrame *)param; - if (f->m_proxyFocusOwner != NULL) { - HWND toDestroy = f->m_proxyFocusOwner; - f->m_proxyFocusOwner = NULL; - ComCtl32Util::GetInstance().UnsubclassHWND(toDestroy, ProxyWindowProc, f->m_proxyDefWindowProc); - ::DestroyWindow(toDestroy); + if (mr != mrConsume) { + retValue = AwtWindow::WindowProc(message, wParam, lParam); } + return retValue; } MsgRouting AwtFrame::WmShowWindow(BOOL show, UINT status) diff --git a/src/windows/native/sun/windows/awt_Frame.h b/src/windows/native/sun/windows/awt_Frame.h index 705dd731db1c3e3cd0988fdc084ea9279fbd3bc5..2949ac9292494f0312f70856c0053c57be94afa9 100644 --- a/src/windows/native/sun/windows/awt_Frame.h +++ b/src/windows/native/sun/windows/awt_Frame.h @@ -96,6 +96,8 @@ public: AwtMenuBar* GetMenuBar(); void SetMenuBar(AwtMenuBar*); + virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); + MsgRouting WmGetMinMaxInfo(LPMINMAXINFO lpmmi); MsgRouting WmSize(UINT type, int w, int h); MsgRouting WmActivate(UINT nState, BOOL fMinimized, HWND opposite); @@ -117,10 +119,7 @@ public: INLINE BOOL IsUndecorated() { return m_isUndecorated; } INLINE HWND GetProxyFocusOwner() { - if (m_proxyFocusOwner == NULL) { - CreateProxyFocusOwner(); - } - return m_proxyFocusOwner; + return GetHWnd(); } void SetMaximizedBounds(int x, int y, int w, int h); @@ -159,15 +158,7 @@ protected: BOOL m_isUndecorated; private: - static LRESULT CALLBACK ProxyWindowProc(HWND hwnd, UINT message, - WPARAM wParam, LPARAM lParam); - void CreateProxyFocusOwner(); - void DestroyProxyFocusOwner(); - - /* creates proxy focus owner, called on Toolkit thread */ - static void _CreateProxyFocusOwner(void *param); - /* destroys proxy focus owner, called on Toolkit thread */ - static void _DestroyProxyFocusOwner(void *param); + LRESULT ProxyWindowProc(UINT message, WPARAM wParam, LPARAM lParam, MsgRouting &mr); /* The frame's embedding parent (if any) */ HWND m_parentWnd; @@ -188,10 +179,6 @@ private: /* The frame is an InputMethodWindow */ BOOL m_isInputMethodWindow; - /* Receives all keyboard input when an AwtWindow which is not an AwtFrame - or an AwtDialog (or one of its children) has the logical input focus. */ - HWND m_proxyFocusOwner; - /* Retains the last/current sm_focusOwner proxied. Actually, it should be * a component of an owned window last/currently active. */ HWND m_lastProxiedFocusOwner;