JDK-6500814 : XEmbed focus traversal problems, inside GTK socket
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: linux
  • CPU: generic
  • Submitted: 2006-12-05
  • Updated: 2011-03-07
  • Resolved: 2011-03-07
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
6u2Fixed 7 b09Fixed
Description
Run the attached test:

make
./helloworld2 | java JavaClient

The test creates a GTK-based application and then embeds a Java embedded frame into it. However, there are some problems with focus traversal in the test, when you press TAB or Shift+TAB on the GTK buttons and Java components. Behaviour differs for different versions of JDK 6.0:

1. With JDK 6.0b38 focus can be transferred from GTK container to Java eframe and back.
2. With JDK 6.0b51 focus can be transferred from GTK container to Java eframe and then can be traversed inside the Java eframe only. When focus reaches the last component in Java eframe, it then comes to the first Java component.
3. With JDK 6.0b58 and later builds, and with 6.0b01 focus can be transferred from GTK container to Java frame and then stays inside it. When focus reaches the last cojmponent in Java eframe, it stays on it and can only be traversed back with Shift+TAB to the first Java component.

Comments
EVALUATION I have also tried to perform an opposite embedding, when GTK widget is embedded into Java XEmbed server. Here another problem was found with focus: at the moment of embedding Java XEmbedCanvasPeer (XEmbed server) may be the focus owner. If later user clicks with mouse on the GTK component, it sends XEMBED_REQUEST_FOCUS to Java, which is translated into the call to requestFocusInWindow(). Then we wait for the focusGainded event, but it is never sent as XEmbedCanvasPeer is already focused. That's why XEmbed client can't get focus. To solve this problem I add an additional check when starting XEmbed. If XEmbedCanvasPeer is the focus owner, it sends XEMBED_FOCUS_IN to the client after XEMBED_ACTIVATE_WINDOW.
24-01-2007

EVALUATION I suspect the problem is just a timings shift between all these JDK versions. The source of the bug is that sometimes our embedded frame doesn't receive XEMBED_EMBEDDED_NOTIFY client message, so XEmbed is not started properly. After some investigation I have found that this notification is always sent to us by GTK socket, but sometimes it comes too early, before embedded frame X events dispatcher is installed. The fix may be to install it earlier, or create an embedded frame without any parent, install dispatcher and then reparent it into the XEmbed server control.
05-12-2006