8143295: Validating issue in AWT
authorssadetsky
Tue, 15 Mar 2016 09:11:43 +0300
changeset 36881 3a22af76f434
parent 36880 3a05117c7611
child 36882 9347af61016c
8143295: Validating issue in AWT Reviewed-by: serb, alexsch
jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindow.java
jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindowPeer.java
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindow.java	Mon Mar 14 13:10:50 2016 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindow.java	Tue Mar 15 09:11:43 2016 +0300
@@ -1008,13 +1008,10 @@
 //  if ( Check if it's a resize, a move, or a stacking order change )
 //  {
         Rectangle bounds = getBounds();
-        final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
         if (!bounds.getSize().equals(oldBounds.getSize())) {
-            acc.setSize(target, bounds.width, bounds.height);
             postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_RESIZED));
         }
         if (!bounds.getLocation().equals(oldBounds.getLocation())) {
-            acc.setLocation(target, bounds.x, bounds.y);
             postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_MOVED));
         }
 //  }
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindowPeer.java	Mon Mar 14 13:10:50 2016 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindowPeer.java	Tue Mar 15 09:11:43 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -803,23 +803,31 @@
      */
     @Override
     public void handleConfigureNotifyEvent(XEvent xev) {
+        assert (SunToolkit.isAWTLockHeldByCurrentThread());
         XConfigureEvent xe = xev.get_xconfigure();
-        /*
-         * Correct window location which could be wrong in some cases.
-         * See getNewLocation() for the details.
-         */
-        Point newLocation = getNewLocation(xe, 0, 0);
-        xe.set_x(scaleUp(newLocation.x));
-        xe.set_y(scaleUp(newLocation.y));
-        checkIfOnNewScreen(new Rectangle(newLocation.x,
-                                         newLocation.y,
-                                         scaleDown(xe.get_width()),
-                                         scaleDown(xe.get_height())));
+        if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
+            insLog.fine(xe.toString());
+        }
+        checkIfOnNewScreen(toGlobal(new Rectangle(scaleDown(xe.get_x()),
+                scaleDown(xe.get_y()),
+                scaleDown(xe.get_width()),
+                scaleDown(xe.get_height()))));
+
+        Rectangle oldBounds = getBounds();
 
-        // Don't call super until we've handled a screen change.  Otherwise
-        // there could be a race condition in which a ComponentListener could
-        // see the old screen.
-        super.handleConfigureNotifyEvent(xev);
+        x = scaleDown(xe.get_x());
+        y = scaleDown(xe.get_y());
+        width = scaleDown(xe.get_width());
+        height = scaleDown(xe.get_height());
+
+        if (!getBounds().getSize().equals(oldBounds.getSize())) {
+            AWTAccessor.getComponentAccessor().setSize(target, width, height);
+            postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_RESIZED));
+        }
+        if (!getBounds().getLocation().equals(oldBounds.getLocation())) {
+            AWTAccessor.getComponentAccessor().setLocation(target, x, y);
+            postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_MOVED));
+        }
         repositionSecurityWarning();
     }