JDK-6867293 : switching TAB in a browser doesn't deactivate EmbeddedFrame
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6u18
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: windows
  • CPU: x86
  • Submitted: 2009-07-31
  • Updated: 2011-01-19
  • Resolved: 2010-01-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u18 b02Fixed 7Fixed
Description
When an applet is launched and focused in a browser and then another TAB is selected in the browser
the EmbeddedFrame doesn't receive WM_ACTIVATE(WA_INACTIVE) native message. On returning back to
the applet and clicking, say, some textfield in the applet the textfield will not be able to
receive key events. The latter is reproducible with JavaFX applets (see Comments), but is not
reproducible with Java applets.

Comments
EVALUATION When another TAB is selected the focused HW component in the applet receives WM_KILLFOCUS. Then the EmbeddedFrame should be synthetically deactivated. Here's the code that should do that: void AwtFrame::SynthesizeWmActivate(BOOL doActivate, HWND opposite) { if (!::IsWindowVisible(GetHWnd()) || (doActivate && ::IsIconic(::GetAncestor(GetHWnd(), GA_ROOT)))) { // The activation is rejected if either: // - EmbeddedFrame is not visible or // - its topmost ancestor window is in minimized state. return; } m_isEmbeddedFrameActivationRequest = TRUE; ::SendMessage(GetHWnd(), WM_ACTIVATE, MAKEWPARAM(doActivate ? WA_ACTIVE : WA_INACTIVE, FALSE), (LPARAM) opposite); } However it returns before ::SendMessage gets executed because EmbeddedFrame is not already visible (on switching to another TAB), that is !::IsWindowVisible(GetHWnd()) condition is true. So, the EmbeddedFrame remains active. Then, after returning to the applet it is not re-activated. However, Java applet receives WM_SETFOCUS triggered by WM_LBUTTONDOWN that restores focus to correct state. But in case of JavaFX applet, WM_SETFOCUS is not generated by the native system (the reason is unknown for me). On re-activating EmbeddedFrame, WM_SETFOCUS is generated in both the cases. The fix is to check for invisibility only for ACTIVATING message (WA_ACTIVE), deactivation should happen anyway.
31-07-2009

SUGGESTED FIX ------- awt_Frame.cpp ------- *** /tmp/sccs.7Mdxmm 2009-07-31 13:42:02.000000000 +0400 --- awt_Frame.cpp 2009-07-31 13:40:05.494253000 +0400 *************** *** 1100,1111 **** /* * Execute on Toolkit only. */ void AwtFrame::SynthesizeWmActivate(BOOL doActivate, HWND opposite) { ! if (!::IsWindowVisible(GetHWnd()) || ! (doActivate && ::IsIconic(::GetAncestor(GetHWnd(), GA_ROOT)))) { // The activation is rejected if either: // - EmbeddedFrame is not visible or // - its topmost ancestor window is in minimized state. return; --- 1100,1111 ---- /* * Execute on Toolkit only. */ void AwtFrame::SynthesizeWmActivate(BOOL doActivate, HWND opposite) { ! if (doActivate && ! (!::IsWindowVisible(GetHWnd()) || ::IsIconic(::GetAncestor(GetHWnd(), GA_ROOT)))) { // The activation is rejected if either: // - EmbeddedFrame is not visible or // - its topmost ancestor window is in minimized state. return;
31-07-2009