1.1 --- a/src/share/classes/java/awt/Component.java Tue May 19 12:15:18 2009 +0400
1.2 +++ b/src/share/classes/java/awt/Component.java Tue May 19 14:14:31 2009 +0400
1.3 @@ -1038,13 +1038,23 @@
1.4
1.5 void setGraphicsConfiguration(GraphicsConfiguration gc) {
1.6 synchronized(getTreeLock()) {
1.7 - graphicsConfig = gc;
1.8 -
1.9 - ComponentPeer peer = getPeer();
1.10 - if (peer != null) {
1.11 - peer.updateGraphicsData(gc);
1.12 - }
1.13 - }
1.14 + if (updateGraphicsData(gc)) {
1.15 + removeNotify();
1.16 + addNotify();
1.17 + }
1.18 + }
1.19 + }
1.20 +
1.21 + boolean updateGraphicsData(GraphicsConfiguration gc) {
1.22 + checkTreeLock();
1.23 +
1.24 + graphicsConfig = gc;
1.25 +
1.26 + ComponentPeer peer = getPeer();
1.27 + if (peer != null) {
1.28 + return peer.updateGraphicsData(gc);
1.29 + }
1.30 + return false;
1.31 }
1.32
1.33 /**
2.1 --- a/src/share/classes/java/awt/Container.java Tue May 19 12:15:18 2009 +0400
2.2 +++ b/src/share/classes/java/awt/Container.java Tue May 19 14:14:31 2009 +0400
2.3 @@ -1113,16 +1113,17 @@
2.4 }
2.5
2.6 @Override
2.7 - void setGraphicsConfiguration(GraphicsConfiguration gc) {
2.8 - synchronized (getTreeLock()) {
2.9 - super.setGraphicsConfiguration(gc);
2.10 -
2.11 - for (Component comp : component) {
2.12 - if (comp != null) {
2.13 - comp.setGraphicsConfiguration(gc);
2.14 - }
2.15 + boolean updateGraphicsData(GraphicsConfiguration gc) {
2.16 + checkTreeLock();
2.17 +
2.18 + boolean ret = super.updateGraphicsData(gc);
2.19 +
2.20 + for (Component comp : component) {
2.21 + if (comp != null) {
2.22 + ret |= comp.updateGraphicsData(gc);
2.23 }
2.24 }
2.25 + return ret;
2.26 }
2.27
2.28 /**
3.1 --- a/src/share/classes/java/awt/peer/ComponentPeer.java Tue May 19 12:15:18 2009 +0400
3.2 +++ b/src/share/classes/java/awt/peer/ComponentPeer.java Tue May 19 14:14:31 2009 +0400
3.3 @@ -548,7 +548,8 @@
3.4 /**
3.5 * Updates internal data structures related to the component's GC.
3.6 *
3.7 + * @return if the peer needs to be recreated for the changes to take effect
3.8 * @since 1.7
3.9 */
3.10 - void updateGraphicsData(GraphicsConfiguration gc);
3.11 + boolean updateGraphicsData(GraphicsConfiguration gc);
3.12 }
4.1 --- a/src/share/classes/sun/awt/NullComponentPeer.java Tue May 19 12:15:18 2009 +0400
4.2 +++ b/src/share/classes/sun/awt/NullComponentPeer.java Tue May 19 14:14:31 2009 +0400
4.3 @@ -300,7 +300,9 @@
4.4 public void setZOrder(ComponentPeer above) {
4.5 }
4.6
4.7 - public void updateGraphicsData(GraphicsConfiguration gc) {}
4.8 + public boolean updateGraphicsData(GraphicsConfiguration gc) {
4.9 + return false;
4.10 + }
4.11
4.12 public GraphicsConfiguration getAppropriateGraphicsConfiguration(
4.13 GraphicsConfiguration gc)
5.1 --- a/src/solaris/classes/sun/awt/X11/XComponentPeer.java Tue May 19 12:15:18 2009 +0400
5.2 +++ b/src/solaris/classes/sun/awt/X11/XComponentPeer.java Tue May 19 14:14:31 2009 +0400
5.3 @@ -1429,7 +1429,26 @@
5.4 }
5.5 }
5.6
5.7 - public void updateGraphicsData(GraphicsConfiguration gc) {
5.8 + public boolean updateGraphicsData(GraphicsConfiguration gc) {
5.9 + int oldVisual = -1, newVisual = -1;
5.10 +
5.11 + if (graphicsConfig != null) {
5.12 + oldVisual = graphicsConfig.getVisual();
5.13 + }
5.14 + if (gc != null && gc instanceof X11GraphicsConfig) {
5.15 + newVisual = ((X11GraphicsConfig)gc).getVisual();
5.16 + }
5.17 +
5.18 + // If the new visual differs from the old one, the peer must be
5.19 + // recreated because X11 does not allow changing the visual on the fly.
5.20 + // So we even skip the initGraphicsConfiguration() call.
5.21 + // The initial assignment should happen though, hence the != -1 thing.
5.22 + if (oldVisual != -1 && oldVisual != newVisual) {
5.23 + return true;
5.24 + }
5.25 +
5.26 initGraphicsConfiguration();
5.27 + doValidateSurface();
5.28 + return false;
5.29 }
5.30 }
6.1 --- a/src/solaris/classes/sun/awt/X11/XEmbedChildProxyPeer.java Tue May 19 12:15:18 2009 +0400
6.2 +++ b/src/solaris/classes/sun/awt/X11/XEmbedChildProxyPeer.java Tue May 19 14:14:31 2009 +0400
6.3 @@ -386,5 +386,7 @@
6.4 public void setZOrder(ComponentPeer above) {
6.5 }
6.6
6.7 - public void updateGraphicsData(GraphicsConfiguration gc) {}
6.8 + public boolean updateGraphicsData(GraphicsConfiguration gc) {
6.9 + return false;
6.10 + }
6.11 }
7.1 --- a/src/solaris/classes/sun/awt/X11/XWindow.java Tue May 19 12:15:18 2009 +0400
7.2 +++ b/src/solaris/classes/sun/awt/X11/XWindow.java Tue May 19 14:14:31 2009 +0400
7.3 @@ -1343,18 +1343,23 @@
7.4 setSizeHints(flags, x, y, width, height);
7.5 }
7.6
7.7 - void validateSurface() {
7.8 + void validateSurface() {
7.9 if ((width != oldWidth) || (height != oldHeight)) {
7.10 - SurfaceData oldData = surfaceData;
7.11 - if (oldData != null) {
7.12 - surfaceData = graphicsConfig.createSurfaceData(this);
7.13 - oldData.invalidate();
7.14 - }
7.15 + doValidateSurface();
7.16 +
7.17 oldWidth = width;
7.18 oldHeight = height;
7.19 }
7.20 }
7.21
7.22 + final void doValidateSurface() {
7.23 + SurfaceData oldData = surfaceData;
7.24 + if (oldData != null) {
7.25 + surfaceData = graphicsConfig.createSurfaceData(this);
7.26 + oldData.invalidate();
7.27 + }
7.28 + }
7.29 +
7.30 public SurfaceData getSurfaceData() {
7.31 return surfaceData;
7.32 }
8.1 --- a/src/windows/classes/sun/awt/windows/WComponentPeer.java Tue May 19 12:15:18 2009 +0400
8.2 +++ b/src/windows/classes/sun/awt/windows/WComponentPeer.java Tue May 19 14:14:31 2009 +0400
8.3 @@ -488,13 +488,14 @@
8.4 }
8.5 }
8.6
8.7 - public void updateGraphicsData(GraphicsConfiguration gc) {
8.8 + public boolean updateGraphicsData(GraphicsConfiguration gc) {
8.9 winGraphicsConfig = (Win32GraphicsConfig)gc;
8.10 try {
8.11 replaceSurfaceData();
8.12 } catch (InvalidPipeException e) {
8.13 // REMIND : what do we do if our surface creation failed?
8.14 }
8.15 + return false;
8.16 }
8.17
8.18 //This will return null for Components not yet added to a Container