提交 00ac0d0c 编写于 作者: A anthony

6812298: Dynamic GraphicsConfig changes don't work on X11 platforms

Summary: The peer gets recreated if the visual of the new GC differs from the previous one
Reviewed-by: art, dcherepanov
上级 0e2b7c8f
......@@ -1038,15 +1038,25 @@ public abstract class Component implements ImageObserver, MenuContainer,
void setGraphicsConfiguration(GraphicsConfiguration gc) {
synchronized(getTreeLock()) {
graphicsConfig = gc;
ComponentPeer peer = getPeer();
if (peer != null) {
peer.updateGraphicsData(gc);
if (updateGraphicsData(gc)) {
removeNotify();
addNotify();
}
}
}
boolean updateGraphicsData(GraphicsConfiguration gc) {
checkTreeLock();
graphicsConfig = gc;
ComponentPeer peer = getPeer();
if (peer != null) {
return peer.updateGraphicsData(gc);
}
return false;
}
/**
* Checks that this component's <code>GraphicsDevice</code>
* <code>idString</code> matches the string argument.
......
......@@ -1113,16 +1113,17 @@ public class Container extends Component {
}
@Override
void setGraphicsConfiguration(GraphicsConfiguration gc) {
synchronized (getTreeLock()) {
super.setGraphicsConfiguration(gc);
boolean updateGraphicsData(GraphicsConfiguration gc) {
checkTreeLock();
for (Component comp : component) {
if (comp != null) {
comp.setGraphicsConfiguration(gc);
}
boolean ret = super.updateGraphicsData(gc);
for (Component comp : component) {
if (comp != null) {
ret |= comp.updateGraphicsData(gc);
}
}
return ret;
}
/**
......
......@@ -548,7 +548,8 @@ public interface ComponentPeer {
/**
* Updates internal data structures related to the component's GC.
*
* @return if the peer needs to be recreated for the changes to take effect
* @since 1.7
*/
void updateGraphicsData(GraphicsConfiguration gc);
boolean updateGraphicsData(GraphicsConfiguration gc);
}
......@@ -300,7 +300,9 @@ public class NullComponentPeer implements LightweightPeer,
public void setZOrder(ComponentPeer above) {
}
public void updateGraphicsData(GraphicsConfiguration gc) {}
public boolean updateGraphicsData(GraphicsConfiguration gc) {
return false;
}
public GraphicsConfiguration getAppropriateGraphicsConfiguration(
GraphicsConfiguration gc)
......
......@@ -1429,7 +1429,26 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
}
}
public void updateGraphicsData(GraphicsConfiguration gc) {
public boolean updateGraphicsData(GraphicsConfiguration gc) {
int oldVisual = -1, newVisual = -1;
if (graphicsConfig != null) {
oldVisual = graphicsConfig.getVisual();
}
if (gc != null && gc instanceof X11GraphicsConfig) {
newVisual = ((X11GraphicsConfig)gc).getVisual();
}
// If the new visual differs from the old one, the peer must be
// recreated because X11 does not allow changing the visual on the fly.
// So we even skip the initGraphicsConfiguration() call.
// The initial assignment should happen though, hence the != -1 thing.
if (oldVisual != -1 && oldVisual != newVisual) {
return true;
}
initGraphicsConfiguration();
doValidateSurface();
return false;
}
}
......@@ -386,5 +386,7 @@ public class XEmbedChildProxyPeer implements ComponentPeer, XEventDispatcher{
public void setZOrder(ComponentPeer above) {
}
public void updateGraphicsData(GraphicsConfiguration gc) {}
public boolean updateGraphicsData(GraphicsConfiguration gc) {
return false;
}
}
......@@ -1343,18 +1343,23 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
setSizeHints(flags, x, y, width, height);
}
void validateSurface() {
void validateSurface() {
if ((width != oldWidth) || (height != oldHeight)) {
SurfaceData oldData = surfaceData;
if (oldData != null) {
surfaceData = graphicsConfig.createSurfaceData(this);
oldData.invalidate();
}
doValidateSurface();
oldWidth = width;
oldHeight = height;
}
}
final void doValidateSurface() {
SurfaceData oldData = surfaceData;
if (oldData != null) {
surfaceData = graphicsConfig.createSurfaceData(this);
oldData.invalidate();
}
}
public SurfaceData getSurfaceData() {
return surfaceData;
}
......
......@@ -488,13 +488,14 @@ public abstract class WComponentPeer extends WObjectPeer
}
}
public void updateGraphicsData(GraphicsConfiguration gc) {
public boolean updateGraphicsData(GraphicsConfiguration gc) {
winGraphicsConfig = (Win32GraphicsConfig)gc;
try {
replaceSurfaceData();
} catch (InvalidPipeException e) {
// REMIND : what do we do if our surface creation failed?
}
return false;
}
//This will return null for Components not yet added to a Container
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册