6613426: two WM_TAKE_FOCUS messages on one mouse click in GNOME Metacity 2.16.0
authorant
Tue, 25 Mar 2008 18:08:57 +0300
changeset 420 870b749c14f5
parent 419 2d7b6a4f8002
child 421 85ea363337e6
6613426: two WM_TAKE_FOCUS messages on one mouse click in GNOME Metacity 2.16.0 Summary: A workaround to the metacity issue 485016. Reviewed-by: son
jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java
--- a/jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java	Mon Mar 24 15:51:26 2008 +0300
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java	Tue Mar 25 18:08:57 2008 +0300
@@ -1013,6 +1013,16 @@
 
     private void handleWmTakeFocus(XClientMessageEvent cl) {
         focusLog.log(Level.FINE, "WM_TAKE_FOCUS on {0}", new Object[]{this});
+        // A workaround to Metacity issue (see 6613426).
+        // The first check is to skip redundant WM_TAKE_FOCUS on click
+        // in a focused frame. The second check is to allow requesting focus
+        // on click in a frame when its owned window is currently focused.
+        if (this == getNativeFocusedWindowPeer() &&
+            target == XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow())
+        {
+            focusLog.fine("The window is already focused, skipping.");
+            return;
+        }
         requestWindowFocus(cl.get_data(1), true);
     }