JDK-6472274 : toFront() sometimes fails on Gnome (Metacity) 2.10
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 5.0,7
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: linux,solaris
  • CPU: generic,x86
  • Submitted: 2006-09-19
  • Updated: 2011-06-22
  • Resolved: 2011-01-14
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
Evaluating the bug 6464656 it was discovered that the root cause of the failing test java/awt/Window/AlwaysOnTop/AutoTestOnTop.java is the toFront() method that doesn't always bring a window to front as expected. 

In fact, the spec of the method DOES NOT guarantee that the window will become the top-most window. But the test is failing on an officially supported platform (Gnome/Metacity 2.10) and we feel the problem must be investigated more deeply on this platform. See the CR 6464656 for more details.
This problem can be often reproduced using the test from description of 6472860 which is closed as duplicate of this CR.

Comments
EVALUATION It appears that a fix for 6942047 might ease the issue with the toFront() behavior on X11 systems.
22-06-2011

EVALUATION The XAWT implementations of toFront()/toBack() method perform actions according to the ICCCM. toFront() calls XMapWindow(), and toBack() calls XLowerWindow(). According to ICCCM (and a newer flavor of it - the EWMH), the window manager is responsible for handling these requests properly. However, Metacity is known to not always handle these requests as other window managers do. This particular bug with the toFront() incorrect behavior is described here: https://bugzilla.gnome.org/show_bug.cgi?id=567528 Also see https://bugs.launchpad.net/metacity/+bug/416058 for some details. Unless Metacity developers fix that, Java can't do anything to make the toFront() work when the Metacity window manager is running. A workaround is to temporarily call setAlwaysOnTop(true) on the window, and then immediately call setAlwaysOnTop(false). Note that the final behavior still depends on the window manager, and the result is not 100% guaranteed. Also, this won't work for unsinged applications. Another workaround is to try other window manager (e.g. Compiz, KWin, etc.)
14-01-2011