From dfd8fdc32c3c83c96479c8d23ef42f1a3b2a2db2 Mon Sep 17 00:00:00 2001 From: Semyon Sadetsky Date: Tue, 15 Mar 2016 09:11:43 +0300 Subject: [PATCH] 8143295: Validating issue in AWT Reviewed-by: serb, alexsch --- .../unix/classes/sun/awt/X11/XWindow.java | 3 -- .../unix/classes/sun/awt/X11/XWindowPeer.java | 40 +++++++++++-------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindow.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindow.java index b431c14d9d1..907446ad81c 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindow.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindow.java @@ -1008,13 +1008,10 @@ class XWindow extends XBaseWindow implements X11ComponentPeer { // 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)); } // } diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindowPeer.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindowPeer.java index 862508ccfcf..a5dfc6afb62 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindowPeer.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindowPeer.java @@ -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 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, */ @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())))); - // 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); + Rectangle oldBounds = getBounds(); + + 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(); }