JDK-5090325 : A window having another window as it's parent does not gain focus on XToolkit
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: linux_sun
  • CPU: x86
  • Submitted: 2004-08-21
  • Updated: 2005-12-01
  • Resolved: 2004-10-25
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
6 b10Fixed
Related Reports
Relates :  
Description
I have written an application where I am creating 3 levels of windows. A parent frame, a child window using the frame as it's parent and another child window using the previous window as it's parent. I am showing all the 3 windows on the screen and each of them is having a textarea in it. When the frame and the windows popup, the child window (third level window having another window as it's parent) is not gaining focus when running this on XToolkit. This is not reproducible on Motif Toolkit. Since XToolkit is the default toolkit on linux, this does not work on linux by default. 

This is reproducible in tiger-beta-b32d. I tested this with Solaris9 and Cinnabar.

I have attached a sample test. Execute the sample test with XToolkit. You would see a frame and 2 child windows. Click on the second window that is shown below the frame and the first window. If the text area available in this window is not gaining focus, then the bug is reproduced.

Comments
SUGGESTED FIX ------- XDecoratedPeer.java ------- *** /tmp/sccs.RoaWfd Fri Oct 8 18:25:45 2004 --- XDecoratedPeer.java Fri Oct 8 18:24:52 2004 *************** *** 798,808 **** if (actualFocusedWindow != null && actualFocusedWindow != target) { Window owner = actualFocusedWindow.getOwner(); // Check that actual focused window is one of owned windows while (owner != null && !(owner instanceof Frame || owner instanceof Dialog)) { ! owner = actualFocusedWindow.getOwner(); } if (owner != null && owner == target) { this.actualFocusedWindow = (XWindowPeer)actualFocusedWindow.getPeer(); } } --- 798,808 ---- if (actualFocusedWindow != null && actualFocusedWindow != target) { Window owner = actualFocusedWindow.getOwner(); // Check that actual focused window is one of owned windows while (owner != null && !(owner instanceof Frame || owner instanceof Dialog)) { ! owner = owner.getOwner(); } if (owner != null && owner == target) { this.actualFocusedWindow = (XWindowPeer)actualFocusedWindow.getPeer(); } } ------- XWindowPeer.java ------- *** /tmp/sccs.BzaOod Fri Oct 8 18:25:46 2004 --- XWindowPeer.java Fri Oct 8 18:21:58 2004 *************** *** 796,805 **** --- 796,810 ---- focusLog.fine("Request for window focus"); // If this is Frame or Dialog we can't assure focus request success - but we still can try // If this is Window and its owner Frame is active we can be sure request succedded. Window win = (Window)target; Window owner = win.getOwner(); + + // Get decorated owner + while (owner != null && !(owner instanceof Frame || owner instanceof Dialog)) { + owner = owner.getOwner(); + } if (owner.isActive()) { focusLog.fine("Parent window is active - generating focus for this window"); handleWindowFocusInSync(-1); return true; } else { ###@###.### 10/12/04 15:13 GMT
12-10-2004

EVALUATION Name: at153223 Date: 08/23/2004 The problem is in XWindowPeer.requestWindowFocus method. When the second window (the last child) is requested to get focus its owner is taken. Then the owner is checked to be active or not. Since the owner turns to be a Window (not a Frame) the focus request gets failed. The solution is just to go further up the hierachy to gain a Frame. The bug is not so critical to be fixed in tiger. Probably it will fit for the update release. ###@###.### 08/23/2004 ====================================================================== ###@###.### 10/8/04 13:40 GMT
23-08-2004