JDK-4907493 : input focus not working with multiple applets
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.2_01
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_2.6
  • CPU: generic
  • Submitted: 2003-08-15
  • Updated: 2003-12-19
  • Resolved: 2003-10-28
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.
Other
1.4.2_04 04Fixed
Description
If there are multiple applets with text input on the same webpage, one of the text input field steals the focus and it is not possible to enter text into textfield of another applet. This is happening on Netscape/Solaris with plugin enabled, but working correctly on Windows. Tested with JDK 1.4.2 FCS and 1.4.2_01 EA

to reproduce:

modify 

/java/re/jdk/1.4.2/latest/binaries/solaris-sparc/demo/applets/ArcTest/example1.html

to have two instances of the same  applet as follows

     <applet code=ArcTest.class width=400 height=400>
     </applet>
     <hr>
     <applet code=ArcTest.class width=400 height=400>
     <applet>

or load the already modified applet at /home/sko/tmp/ArcTest/example1.html

Load the modified html page into Netscape on Solaris to test with
Java Plugin. Try to type into the text fields in both the
applets and observe that one of the applets can not receive
input focus  correctly and it is impossible to type text into 
textfileds of that applet.

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.4.2_04 tiger-beta FIXED IN: 1.4.2_04 tiger-beta INTEGRATED IN: 1.4.2_04 tiger-beta VERIFIED IN: 1.4.2_04
24-08-2004

SUGGESTED FIX src/solaris/native/sun/awt/awt_TopLevel.h 7c7 < * @(#)awt_TopLevel.h 1.6 03/01/23 --- > * %W% %E% 16a17 > extern void callSynthesize(JNIEnv *env,jobject peer); src/solaris/native/sun/awt/awt_TopLevel.c 2c2 < * @(#)awt_TopLevel.c 1.102 03/08/25 --- > * %W% %E% 2076a2077,2100 > extern void callSynthesize(JNIEnv *env,jobject peer) > { > EmbeddedFrame *ef; > Boolean dummy; > AWT_LOCK(); > ef = theEmbeddedFrameList; > while (ef != NULL) { > if ((*env)->IsSameObject(env, ef->javaRef, peer)) { > XFocusChangeEvent xev; > xev.display = awt_display; > xev.serial = 0; > xev.type = FocusIn; > xev.send_event = False; > xev.window = XtWindow(ef->embeddedFrame); > xev.mode = NotifyNormal; > xev.detail = NotifyNonlinear; > shellEH(ef->embeddedFrame, peer, (XEvent*)&xev, &dummy); > break; > } > ef = ef->next; > } > AWT_UNLOCK(); > } > 4132,4152c4156 < EmbeddedFrame *ef; < Boolean dummy; < < AWT_LOCK(); < ef = theEmbeddedFrameList; < while (ef != NULL) { < if ((*env)->IsSameObject(env, ef->javaRef, this)) { < XFocusChangeEvent xev; < xev.display = awt_display; < xev.serial = 0; < xev.type = FocusIn; < xev.send_event = False; < xev.window = XtWindow(ef->embeddedFrame); < xev.mode = NotifyNormal; < xev.detail = NotifyNonlinear; < shellEH(ef->embeddedFrame, this, (XEvent*)&xev, &dummy); < break; < } < ef = ef->next; < } < AWT_UNLOCK(); --- > callSynthesize(env,this); src/solaris/native/sun/awt/awt_MToolkit.c 2c2 < * @(#)awt_MToolkit.c 1.206 03/01/23 --- > * %W% %E% 1505a1506,1522 > void *peer; > jobject target; > jobject targetPeer; > jobject l_peer; > JNIEnv *env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2); > peer = findPeer(&widget); > if (peer == NULL) return; > target = findTopLevel(peer, env); > if (target == NULL) return; > AWT_LOCK(); > l_peer = awt_canvas_getFocusedWindowPeer(); > AWT_UNLOCK(); > if (l_peer == NULL) return; > targetPeer = (*env)->GetObjectField(env,target, componentIDs.peer); > if (!(*env)->IsSameObject(env,targetPeer,l_peer)) > callSynthesize(env,targetPeer); ###@###.### 2003-09-14
14-09-2003

EVALUATION Since this is an escalation, I will assume that a sustaining engineer will be working on it. I will assign it to an AWT engineer for tracking purposes. ###@###.### 2003-08-15 Usually a focus gain on setVisible of EmbeddedFrame is simulated but these applets both become visible at once and therefore only one of them actually gets the required focus events. When we click on the second "unlucky" applet the focus gain is not happening. Solution is to catch all mouse events in awt_MToolkit.c:processOneEvent, then, find to which toplevel they go. Then, we should check if it is focused. If it is not focused - and it is ButtonPress we need to call synthesizeFocusIn to generate necessary focus events. ###@###.### 2003-09-14 We believe this problem has been resolved by the XEmbed work done in 1.5. ###@###.### 2003-10-28
14-09-2003