6804747: Ensure consistent graphicsConfig member across components hierarchy
Reviewed-by: art, dcherepanov
This commit is contained in:
parent
a1117d31b6
commit
f9a987bf43
@ -25,6 +25,7 @@
|
|||||||
package java.awt;
|
package java.awt;
|
||||||
|
|
||||||
import java.awt.image.BufferStrategy;
|
import java.awt.image.BufferStrategy;
|
||||||
|
import java.awt.peer.CanvasPeer;
|
||||||
import javax.accessibility.*;
|
import javax.accessibility.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,7 +66,17 @@ public class Canvas extends Component implements Accessible {
|
|||||||
*/
|
*/
|
||||||
public Canvas(GraphicsConfiguration config) {
|
public Canvas(GraphicsConfiguration config) {
|
||||||
this();
|
this();
|
||||||
graphicsConfig = config;
|
setGraphicsConfiguration(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void setGraphicsConfiguration(GraphicsConfiguration gc) {
|
||||||
|
CanvasPeer peer = (CanvasPeer)getPeer();
|
||||||
|
if (peer != null) {
|
||||||
|
gc = peer.getAppropriateGraphicsConfiguration(gc);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.setGraphicsConfiguration(gc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -300,7 +300,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
|||||||
* @see GraphicsConfiguration
|
* @see GraphicsConfiguration
|
||||||
* @see #getGraphicsConfiguration
|
* @see #getGraphicsConfiguration
|
||||||
*/
|
*/
|
||||||
transient GraphicsConfiguration graphicsConfig = null;
|
private transient GraphicsConfiguration graphicsConfig = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A reference to a <code>BufferStrategy</code> object
|
* A reference to a <code>BufferStrategy</code> object
|
||||||
@ -845,6 +845,12 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setGraphicsConfiguration(Component comp,
|
||||||
|
GraphicsConfiguration gc)
|
||||||
|
{
|
||||||
|
comp.setGraphicsConfiguration(gc);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1012,50 +1018,21 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
|||||||
*/
|
*/
|
||||||
public GraphicsConfiguration getGraphicsConfiguration() {
|
public GraphicsConfiguration getGraphicsConfiguration() {
|
||||||
synchronized(getTreeLock()) {
|
synchronized(getTreeLock()) {
|
||||||
if (graphicsConfig != null) {
|
return getGraphicsConfiguration_NoClientCode();
|
||||||
return graphicsConfig;
|
|
||||||
} else if (getParent() != null) {
|
|
||||||
return getParent().getGraphicsConfiguration();
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final GraphicsConfiguration getGraphicsConfiguration_NoClientCode() {
|
final GraphicsConfiguration getGraphicsConfiguration_NoClientCode() {
|
||||||
GraphicsConfiguration graphicsConfig = this.graphicsConfig;
|
|
||||||
Container parent = this.parent;
|
|
||||||
if (graphicsConfig != null) {
|
|
||||||
return graphicsConfig;
|
return graphicsConfig;
|
||||||
} else if (parent != null) {
|
|
||||||
return parent.getGraphicsConfiguration_NoClientCode();
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
void setGraphicsConfiguration(GraphicsConfiguration gc) {
|
||||||
* Resets this <code>Component</code>'s
|
|
||||||
* <code>GraphicsConfiguration</code> back to a default
|
|
||||||
* value. For most componenets, this is <code>null</code>.
|
|
||||||
* Called from the Toolkit thread, so NO CLIENT CODE.
|
|
||||||
*/
|
|
||||||
void resetGC() {
|
|
||||||
synchronized(getTreeLock()) {
|
synchronized(getTreeLock()) {
|
||||||
graphicsConfig = null;
|
graphicsConfig = gc;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
ComponentPeer peer = getPeer();
|
||||||
* Not called on Component, but needed for Canvas and Window
|
if (peer != null) {
|
||||||
*/
|
peer.updateGraphicsData(gc);
|
||||||
void setGCFromPeer() {
|
|
||||||
synchronized(getTreeLock()) {
|
|
||||||
if (peer != null) { // can't imagine how this will be false,
|
|
||||||
// but just in case
|
|
||||||
graphicsConfig = peer.getGraphicsConfiguration();
|
|
||||||
} else {
|
|
||||||
graphicsConfig = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -506,6 +506,7 @@ public class Container extends Component {
|
|||||||
adjustDescendants(-(comp.countHierarchyMembers()));
|
adjustDescendants(-(comp.countHierarchyMembers()));
|
||||||
|
|
||||||
comp.parent = null;
|
comp.parent = null;
|
||||||
|
comp.setGraphicsConfiguration(null);
|
||||||
component.remove(index);
|
component.remove(index);
|
||||||
|
|
||||||
invalidateIfValid();
|
invalidateIfValid();
|
||||||
@ -789,6 +790,7 @@ public class Container extends Component {
|
|||||||
component.add(index, comp);
|
component.add(index, comp);
|
||||||
}
|
}
|
||||||
comp.parent = this;
|
comp.parent = this;
|
||||||
|
comp.setGraphicsConfiguration(getGraphicsConfiguration());
|
||||||
|
|
||||||
adjustListeningChildren(AWTEvent.HIERARCHY_EVENT_MASK,
|
adjustListeningChildren(AWTEvent.HIERARCHY_EVENT_MASK,
|
||||||
comp.numListening(AWTEvent.HIERARCHY_EVENT_MASK));
|
comp.numListening(AWTEvent.HIERARCHY_EVENT_MASK));
|
||||||
@ -1056,6 +1058,7 @@ public class Container extends Component {
|
|||||||
component.add(index, comp);
|
component.add(index, comp);
|
||||||
}
|
}
|
||||||
comp.parent = this;
|
comp.parent = this;
|
||||||
|
comp.setGraphicsConfiguration(thisGC);
|
||||||
|
|
||||||
adjustListeningChildren(AWTEvent.HIERARCHY_EVENT_MASK,
|
adjustListeningChildren(AWTEvent.HIERARCHY_EVENT_MASK,
|
||||||
comp.numListening(AWTEvent.HIERARCHY_EVENT_MASK));
|
comp.numListening(AWTEvent.HIERARCHY_EVENT_MASK));
|
||||||
@ -1094,6 +1097,19 @@ public class Container extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void setGraphicsConfiguration(GraphicsConfiguration gc) {
|
||||||
|
synchronized (getTreeLock()) {
|
||||||
|
super.setGraphicsConfiguration(gc);
|
||||||
|
|
||||||
|
for (Component comp : component) {
|
||||||
|
if (comp != null) {
|
||||||
|
comp.setGraphicsConfiguration(gc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks that all Components that this Container contains are on
|
* Checks that all Components that this Container contains are on
|
||||||
* the same GraphicsDevice as this Container. If not, throws an
|
* the same GraphicsDevice as this Container. If not, throws an
|
||||||
@ -1151,6 +1167,7 @@ public class Container extends Component {
|
|||||||
|
|
||||||
comp.parent = null;
|
comp.parent = null;
|
||||||
component.remove(index);
|
component.remove(index);
|
||||||
|
comp.setGraphicsConfiguration(null);
|
||||||
|
|
||||||
invalidateIfValid();
|
invalidateIfValid();
|
||||||
if (containerListener != null ||
|
if (containerListener != null ||
|
||||||
@ -1227,6 +1244,7 @@ public class Container extends Component {
|
|||||||
layoutMgr.removeLayoutComponent(comp);
|
layoutMgr.removeLayoutComponent(comp);
|
||||||
}
|
}
|
||||||
comp.parent = null;
|
comp.parent = null;
|
||||||
|
comp.setGraphicsConfiguration(null);
|
||||||
if (containerListener != null ||
|
if (containerListener != null ||
|
||||||
(eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 ||
|
(eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 ||
|
||||||
Toolkit.enabledOnToolkit(AWTEvent.CONTAINER_EVENT_MASK)) {
|
Toolkit.enabledOnToolkit(AWTEvent.CONTAINER_EVENT_MASK)) {
|
||||||
|
@ -394,6 +394,18 @@ public class Window extends Container implements Accessible {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private GraphicsConfiguration initGC(GraphicsConfiguration gc) {
|
||||||
|
GraphicsEnvironment.checkHeadless();
|
||||||
|
|
||||||
|
if (gc == null) {
|
||||||
|
gc = GraphicsEnvironment.getLocalGraphicsEnvironment().
|
||||||
|
getDefaultScreenDevice().getDefaultConfiguration();
|
||||||
|
}
|
||||||
|
setGraphicsConfiguration(gc);
|
||||||
|
|
||||||
|
return gc;
|
||||||
|
}
|
||||||
|
|
||||||
private void init(GraphicsConfiguration gc) {
|
private void init(GraphicsConfiguration gc) {
|
||||||
GraphicsEnvironment.checkHeadless();
|
GraphicsEnvironment.checkHeadless();
|
||||||
|
|
||||||
@ -405,14 +417,10 @@ public class Window extends Container implements Accessible {
|
|||||||
setWarningString();
|
setWarningString();
|
||||||
this.cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
|
this.cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
if (gc == null) {
|
|
||||||
this.graphicsConfig =
|
gc = initGC(gc);
|
||||||
GraphicsEnvironment.getLocalGraphicsEnvironment().
|
|
||||||
getDefaultScreenDevice().getDefaultConfiguration();
|
if (gc.getDevice().getType() !=
|
||||||
} else {
|
|
||||||
this.graphicsConfig = gc;
|
|
||||||
}
|
|
||||||
if (graphicsConfig.getDevice().getType() !=
|
|
||||||
GraphicsDevice.TYPE_RASTER_SCREEN) {
|
GraphicsDevice.TYPE_RASTER_SCREEN) {
|
||||||
throw new IllegalArgumentException("not a screen device");
|
throw new IllegalArgumentException("not a screen device");
|
||||||
}
|
}
|
||||||
@ -420,8 +428,8 @@ public class Window extends Container implements Accessible {
|
|||||||
|
|
||||||
/* offset the initial location with the original of the screen */
|
/* offset the initial location with the original of the screen */
|
||||||
/* and any insets */
|
/* and any insets */
|
||||||
Rectangle screenBounds = graphicsConfig.getBounds();
|
Rectangle screenBounds = gc.getBounds();
|
||||||
Insets screenInsets = getToolkit().getScreenInsets(graphicsConfig);
|
Insets screenInsets = getToolkit().getScreenInsets(gc);
|
||||||
int x = getX() + screenBounds.x + screenInsets.left;
|
int x = getX() + screenBounds.x + screenInsets.left;
|
||||||
int y = getY() + screenBounds.y + screenInsets.top;
|
int y = getY() + screenBounds.y + screenInsets.top;
|
||||||
if (x != this.x || y != this.y) {
|
if (x != this.x || y != this.y) {
|
||||||
@ -2765,7 +2773,7 @@ public class Window extends Container implements Accessible {
|
|||||||
sun.java2d.Disposer.addRecord(anchor, new WindowDisposerRecord(appContext, this));
|
sun.java2d.Disposer.addRecord(anchor, new WindowDisposerRecord(appContext, this));
|
||||||
|
|
||||||
addToWindowList();
|
addToWindowList();
|
||||||
|
initGC(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deserializeResources(ObjectInputStream s)
|
private void deserializeResources(ObjectInputStream s)
|
||||||
@ -2939,41 +2947,18 @@ public class Window extends Container implements Accessible {
|
|||||||
|
|
||||||
} // inner class AccessibleAWTWindow
|
} // inner class AccessibleAWTWindow
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* This method returns the GraphicsConfiguration used by this Window.
|
void setGraphicsConfiguration(GraphicsConfiguration gc) {
|
||||||
* @since 1.3
|
if (gc == null) {
|
||||||
*/
|
gc = GraphicsEnvironment.
|
||||||
public GraphicsConfiguration getGraphicsConfiguration() {
|
|
||||||
//NOTE: for multiscreen, this will need to take into account
|
|
||||||
//which screen the window is on/mostly on instead of returning the
|
|
||||||
//default or constructor argument config.
|
|
||||||
synchronized(getTreeLock()) {
|
|
||||||
if (graphicsConfig == null && !GraphicsEnvironment.isHeadless()) {
|
|
||||||
graphicsConfig =
|
|
||||||
GraphicsEnvironment. getLocalGraphicsEnvironment().
|
|
||||||
getDefaultScreenDevice().
|
|
||||||
getDefaultConfiguration();
|
|
||||||
}
|
|
||||||
return graphicsConfig;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reset this Window's GraphicsConfiguration to match its peer.
|
|
||||||
*/
|
|
||||||
void resetGC() {
|
|
||||||
if (!GraphicsEnvironment.isHeadless()) {
|
|
||||||
// use the peer's GC
|
|
||||||
setGCFromPeer();
|
|
||||||
// if it's still null, use the default
|
|
||||||
if (graphicsConfig == null) {
|
|
||||||
graphicsConfig = GraphicsEnvironment.
|
|
||||||
getLocalGraphicsEnvironment().
|
getLocalGraphicsEnvironment().
|
||||||
getDefaultScreenDevice().
|
getDefaultScreenDevice().
|
||||||
getDefaultConfiguration();
|
getDefaultConfiguration();
|
||||||
}
|
}
|
||||||
|
synchronized (getTreeLock()) {
|
||||||
|
super.setGraphicsConfiguration(gc);
|
||||||
if (log.isLoggable(Level.FINER)) {
|
if (log.isLoggable(Level.FINER)) {
|
||||||
log.finer("+ Window.resetGC(): new GC is \n+ " + graphicsConfig + "\n+ this is " + this);
|
log.finer("+ Window.setGraphicsConfiguration(): new GC is \n+ " + getGraphicsConfiguration_NoClientCode() + "\n+ this is " + this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3033,7 +3018,7 @@ public class Window extends Container implements Accessible {
|
|||||||
// target location
|
// target location
|
||||||
int dx = 0, dy = 0;
|
int dx = 0, dy = 0;
|
||||||
// target GC
|
// target GC
|
||||||
GraphicsConfiguration gc = this.graphicsConfig;
|
GraphicsConfiguration gc = getGraphicsConfiguration_NoClientCode();
|
||||||
Rectangle gcBounds = gc.getBounds();
|
Rectangle gcBounds = gc.getBounds();
|
||||||
|
|
||||||
Dimension windowSize = getSize();
|
Dimension windowSize = getSize();
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
package java.awt.peer;
|
package java.awt.peer;
|
||||||
|
|
||||||
import java.awt.Canvas;
|
import java.awt.Canvas;
|
||||||
|
import java.awt.GraphicsConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The peer interface for {@link Canvas}.
|
* The peer interface for {@link Canvas}.
|
||||||
@ -36,4 +37,13 @@ import java.awt.Canvas;
|
|||||||
* instances.
|
* instances.
|
||||||
*/
|
*/
|
||||||
public interface CanvasPeer extends ComponentPeer {
|
public interface CanvasPeer extends ComponentPeer {
|
||||||
|
/**
|
||||||
|
* Requests a GC that best suits this Canvas. The returned GC may differ
|
||||||
|
* from the requested GC passed as the argument to this method. This method
|
||||||
|
* must return a non-null value (given the argument is non-null as well).
|
||||||
|
*
|
||||||
|
* @since 1.7
|
||||||
|
*/
|
||||||
|
GraphicsConfiguration getAppropriateGraphicsConfiguration(
|
||||||
|
GraphicsConfiguration gc);
|
||||||
}
|
}
|
||||||
|
@ -539,4 +539,10 @@ public interface ComponentPeer {
|
|||||||
*/
|
*/
|
||||||
void applyShape(Region shape);
|
void applyShape(Region shape);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates internal data structures related to the component's GC.
|
||||||
|
*
|
||||||
|
* @since 1.7
|
||||||
|
*/
|
||||||
|
void updateGraphicsData(GraphicsConfiguration gc);
|
||||||
}
|
}
|
||||||
|
@ -78,6 +78,11 @@ public final class AWTAccessor {
|
|||||||
* See 6797587, 6776743, 6768307, and 6768332 for details
|
* See 6797587, 6776743, 6768307, and 6768332 for details
|
||||||
*/
|
*/
|
||||||
void setMixingCutoutShape(Component comp, Shape shape);
|
void setMixingCutoutShape(Component comp, Shape shape);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets GraphicsConfiguration value for the component.
|
||||||
|
*/
|
||||||
|
void setGraphicsConfiguration(Component comp, GraphicsConfiguration gc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -73,7 +73,6 @@ public class ComponentAccessor
|
|||||||
private static Field fieldPacked;
|
private static Field fieldPacked;
|
||||||
private static Field fieldIgnoreRepaint;
|
private static Field fieldIgnoreRepaint;
|
||||||
private static Field fieldPeer;
|
private static Field fieldPeer;
|
||||||
private static Method methodResetGC;
|
|
||||||
private static Field fieldVisible;
|
private static Field fieldVisible;
|
||||||
private static Method methodIsEnabledImpl;
|
private static Method methodIsEnabledImpl;
|
||||||
private static Method methodGetCursorNoClientCode;
|
private static Method methodGetCursorNoClientCode;
|
||||||
@ -124,9 +123,6 @@ public class ComponentAccessor
|
|||||||
fieldPeer = componentClass.getDeclaredField("peer");
|
fieldPeer = componentClass.getDeclaredField("peer");
|
||||||
fieldPeer.setAccessible(true);
|
fieldPeer.setAccessible(true);
|
||||||
|
|
||||||
methodResetGC = componentClass.getDeclaredMethod("resetGC", (Class[]) null);
|
|
||||||
methodResetGC.setAccessible(true);
|
|
||||||
|
|
||||||
fieldVisible = componentClass.getDeclaredField("visible");
|
fieldVisible = componentClass.getDeclaredField("visible");
|
||||||
fieldVisible.setAccessible(true);
|
fieldVisible.setAccessible(true);
|
||||||
|
|
||||||
@ -425,18 +421,6 @@ public class ComponentAccessor
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void resetGC(Component c) {
|
|
||||||
try {
|
|
||||||
methodResetGC.invoke(c, (Object[]) null);
|
|
||||||
}
|
|
||||||
catch (IllegalAccessException e) {
|
|
||||||
log.log(Level.FINE, "Unable to access the Component object", e);
|
|
||||||
}
|
|
||||||
catch (InvocationTargetException e) {
|
|
||||||
log.log(Level.FINE, "Unable to invoke on the Component object", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean getVisible(Component c) {
|
public static boolean getVisible(Component c) {
|
||||||
try {
|
try {
|
||||||
return fieldVisible.getBoolean(c);
|
return fieldVisible.getBoolean(c);
|
||||||
|
@ -305,4 +305,12 @@ public class NullComponentPeer implements LightweightPeer,
|
|||||||
*/
|
*/
|
||||||
public void applyShape(Region shape) {
|
public void applyShape(Region shape) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateGraphicsData(GraphicsConfiguration gc) {}
|
||||||
|
|
||||||
|
public GraphicsConfiguration getAppropriateGraphicsConfiguration(
|
||||||
|
GraphicsConfiguration gc)
|
||||||
|
{
|
||||||
|
return gc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ package sun.awt.X11;
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.peer.*;
|
import java.awt.peer.*;
|
||||||
|
|
||||||
import sun.awt.ComponentAccessor;
|
|
||||||
import sun.awt.SunToolkit;
|
import sun.awt.SunToolkit;
|
||||||
|
|
||||||
import sun.awt.X11GraphicsConfig;
|
import sun.awt.X11GraphicsConfig;
|
||||||
@ -54,36 +53,19 @@ class XCanvasPeer extends XComponentPeer implements CanvasPeer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetTargetGC(Component target) {
|
/* Get a GraphicsConfig with the same visual on the new
|
||||||
ComponentAccessor.resetGC(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Called when the Window this
|
|
||||||
* Canvas is on is moved onto another Xinerama screen.
|
|
||||||
*
|
|
||||||
* Canvases can be created with a non-defulat GraphicsConfiguration. The
|
|
||||||
* GraphicsConfiguration needs to be changed to one on the new screen,
|
|
||||||
* preferably with the same visual ID.
|
|
||||||
*
|
|
||||||
* Up-called for other windows peer instances (XPanelPeer, XWindowPeer).
|
|
||||||
*
|
|
||||||
* Should only be called from the event thread.
|
|
||||||
*/
|
|
||||||
public void displayChanged(int screenNum) {
|
|
||||||
resetLocalGC(screenNum);
|
|
||||||
resetTargetGC(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set graphicsConfig to a GraphicsConfig with the same visual on the new
|
|
||||||
* screen, which should be easy in Xinerama mode.
|
* screen, which should be easy in Xinerama mode.
|
||||||
*
|
|
||||||
* Should only be called from displayChanged(), and therefore only from
|
|
||||||
* the event thread.
|
|
||||||
*/
|
*/
|
||||||
void resetLocalGC(int screenNum) {
|
public GraphicsConfiguration getAppropriateGraphicsConfiguration(
|
||||||
|
GraphicsConfiguration gc)
|
||||||
|
{
|
||||||
|
if (graphicsConfig == null || gc == null) {
|
||||||
|
return gc;
|
||||||
|
}
|
||||||
// Opt: Only need to do if we're not using the default GC
|
// Opt: Only need to do if we're not using the default GC
|
||||||
if (graphicsConfig != null) {
|
|
||||||
|
int screenNum = ((X11GraphicsDevice)gc.getDevice()).getScreen();
|
||||||
|
|
||||||
X11GraphicsConfig parentgc;
|
X11GraphicsConfig parentgc;
|
||||||
// save vis id of current gc
|
// save vis id of current gc
|
||||||
int visual = graphicsConfig.getVisual();
|
int visual = graphicsConfig.getVisual();
|
||||||
@ -106,8 +88,10 @@ class XCanvasPeer extends XComponentPeer implements CanvasPeer {
|
|||||||
getScreenDevices()[screenNum].
|
getScreenDevices()[screenNum].
|
||||||
getDefaultConfiguration();
|
getDefaultConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return graphicsConfig;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
protected boolean shouldFocusOnClick() {
|
protected boolean shouldFocusOnClick() {
|
||||||
// Canvas should always be able to be focused by mouse clicks.
|
// Canvas should always be able to be focused by mouse clicks.
|
||||||
return true;
|
return true;
|
||||||
|
@ -35,6 +35,7 @@ import java.awt.Dimension;
|
|||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.FontMetrics;
|
import java.awt.FontMetrics;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
|
import java.awt.GraphicsConfiguration;
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
import java.awt.KeyboardFocusManager;
|
import java.awt.KeyboardFocusManager;
|
||||||
@ -1556,4 +1557,8 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateGraphicsData(GraphicsConfiguration gc) {
|
||||||
|
initGraphicsConfiguration();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -379,4 +379,6 @@ public class XEmbedChildProxyPeer implements ComponentPeer, XEventDispatcher{
|
|||||||
|
|
||||||
public void applyShape(Region shape) {
|
public void applyShape(Region shape) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateGraphicsData(GraphicsConfiguration gc) {}
|
||||||
}
|
}
|
||||||
|
@ -130,39 +130,6 @@ public class XPanelPeer extends XCanvasPeer implements PanelPeer {
|
|||||||
return getInsets();
|
return getInsets();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* This method is called from XWindowPeer.displayChanged, when
|
|
||||||
* the window this Panel is on is moved to the new screen, or
|
|
||||||
* display mode is changed.
|
|
||||||
*
|
|
||||||
* The notification is propagated to the child Canvas components.
|
|
||||||
* Top-level windows and other Panels are notified too as their
|
|
||||||
* peers are subclasses of XCanvasPeer.
|
|
||||||
*/
|
|
||||||
public void displayChanged(int screenNum) {
|
|
||||||
super.displayChanged(screenNum);
|
|
||||||
displayChanged((Container)target, screenNum);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Recursively iterates through all the HW and LW children
|
|
||||||
* of the container and calls displayChanged() for HW peers.
|
|
||||||
* Iteration through children peers only is not enough as the
|
|
||||||
* displayChanged notification may not be propagated to HW
|
|
||||||
* components inside LW containers, see 4452373 for details.
|
|
||||||
*/
|
|
||||||
private static void displayChanged(Container target, int screenNum) {
|
|
||||||
Component children[] = ((Container)target).getComponents();
|
|
||||||
for (Component child : children) {
|
|
||||||
ComponentPeer cpeer = child.getPeer();
|
|
||||||
if (cpeer instanceof XCanvasPeer) {
|
|
||||||
((XCanvasPeer)cpeer).displayChanged(screenNum);
|
|
||||||
} else if (child instanceof Container) {
|
|
||||||
displayChanged((Container)child, screenNum);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
if (embedder != null) {
|
if (embedder != null) {
|
||||||
embedder.deinstall();
|
embedder.deinstall();
|
||||||
|
@ -47,6 +47,7 @@ import java.util.logging.Logger;
|
|||||||
import sun.awt.AWTAccessor;
|
import sun.awt.AWTAccessor;
|
||||||
import sun.awt.ComponentAccessor;
|
import sun.awt.ComponentAccessor;
|
||||||
import sun.awt.WindowAccessor;
|
import sun.awt.WindowAccessor;
|
||||||
|
import sun.awt.AWTAccessor;
|
||||||
import sun.awt.DisplayChangedListener;
|
import sun.awt.DisplayChangedListener;
|
||||||
import sun.awt.SunToolkit;
|
import sun.awt.SunToolkit;
|
||||||
import sun.awt.X11GraphicsDevice;
|
import sun.awt.X11GraphicsDevice;
|
||||||
@ -711,6 +712,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
|||||||
int curScreenNum = ((X11GraphicsDevice)getGraphicsConfiguration().getDevice()).getScreen();
|
int curScreenNum = ((X11GraphicsDevice)getGraphicsConfiguration().getDevice()).getScreen();
|
||||||
int newScreenNum = 0;
|
int newScreenNum = 0;
|
||||||
GraphicsDevice gds[] = XToolkit.localEnv.getScreenDevices();
|
GraphicsDevice gds[] = XToolkit.localEnv.getScreenDevices();
|
||||||
|
GraphicsConfiguration newGC = null;
|
||||||
Rectangle screenBounds;
|
Rectangle screenBounds;
|
||||||
|
|
||||||
for (int i = 0; i < gds.length; i++) {
|
for (int i = 0; i < gds.length; i++) {
|
||||||
@ -726,11 +728,13 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
|||||||
if (intAmt == area) {
|
if (intAmt == area) {
|
||||||
// Completely on this screen - done!
|
// Completely on this screen - done!
|
||||||
newScreenNum = i;
|
newScreenNum = i;
|
||||||
|
newGC = gds[i].getDefaultConfiguration();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (intAmt > largestAmt) {
|
if (intAmt > largestAmt) {
|
||||||
largestAmt = intAmt;
|
largestAmt = intAmt;
|
||||||
newScreenNum = i;
|
newScreenNum = i;
|
||||||
|
newGC = gds[i].getDefaultConfiguration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -738,28 +742,20 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
|||||||
if (log.isLoggable(Level.FINEST)) {
|
if (log.isLoggable(Level.FINEST)) {
|
||||||
log.finest("XWindowPeer: Moved to a new screen");
|
log.finest("XWindowPeer: Moved to a new screen");
|
||||||
}
|
}
|
||||||
draggedToNewScreen(newScreenNum);
|
executeDisplayChangedOnEDT(newGC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Xinerama
|
|
||||||
* called to update our GC when dragged onto another screen
|
|
||||||
*/
|
|
||||||
public void draggedToNewScreen(int screenNum) {
|
|
||||||
executeDisplayChangedOnEDT(screenNum);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method that executes the displayChanged(screen) method on
|
* Helper method that executes the displayChanged(screen) method on
|
||||||
* the event dispatch thread. This method is used in the Xinerama case
|
* the event dispatch thread. This method is used in the Xinerama case
|
||||||
* and after display mode change events.
|
* and after display mode change events.
|
||||||
*/
|
*/
|
||||||
private void executeDisplayChangedOnEDT(final int screenNum) {
|
private void executeDisplayChangedOnEDT(final GraphicsConfiguration gc) {
|
||||||
Runnable dc = new Runnable() {
|
Runnable dc = new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
// Updates this window's GC and notifies all the children.
|
AWTAccessor.getComponentAccessor().
|
||||||
// See XPanelPeer/XCanvasPeer.displayChanged(int) for details.
|
setGraphicsConfiguration((Component)target, gc);
|
||||||
displayChanged(screenNum);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
SunToolkit.executeOnEventHandlerThread((Component)target, dc);
|
SunToolkit.executeOnEventHandlerThread((Component)target, dc);
|
||||||
@ -770,9 +766,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
|||||||
* X11GraphicsDevice when the display mode has been changed.
|
* X11GraphicsDevice when the display mode has been changed.
|
||||||
*/
|
*/
|
||||||
public void displayChanged() {
|
public void displayChanged() {
|
||||||
GraphicsConfiguration gc = getGraphicsConfiguration();
|
executeDisplayChangedOnEDT(getGraphicsConfiguration());
|
||||||
int curScreenNum = ((X11GraphicsDevice)gc.getDevice()).getScreen();
|
|
||||||
executeDisplayChangedOnEDT(curScreenNum);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,7 +41,6 @@ struct ComponentIDs {
|
|||||||
jfieldID appContext;
|
jfieldID appContext;
|
||||||
jmethodID getParent;
|
jmethodID getParent;
|
||||||
jmethodID getLocationOnScreen;
|
jmethodID getLocationOnScreen;
|
||||||
jmethodID resetGCMID;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* field and method IDs for Container */
|
/* field and method IDs for Container */
|
||||||
@ -65,7 +64,3 @@ struct MComponentPeerIDs {
|
|||||||
extern void processTree(Widget from, Widget to, Boolean action);
|
extern void processTree(Widget from, Widget to, Boolean action);
|
||||||
#endif // HEADLESS
|
#endif // HEADLESS
|
||||||
|
|
||||||
/* fieldIDs for Canvas fields that may be accessed from C */
|
|
||||||
struct CanvasIDs {
|
|
||||||
jmethodID setGCFromPeerMID;
|
|
||||||
};
|
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
/* fieldIDs for Window fields that may be accessed from C */
|
/* fieldIDs for Window fields that may be accessed from C */
|
||||||
struct WindowIDs {
|
struct WindowIDs {
|
||||||
jfieldID warningString;
|
jfieldID warningString;
|
||||||
jmethodID resetGCMID;
|
|
||||||
jfieldID locationByPlatform;
|
jfieldID locationByPlatform;
|
||||||
jfieldID isAutoRequestFocus;
|
jfieldID isAutoRequestFocus;
|
||||||
};
|
};
|
||||||
|
@ -182,9 +182,6 @@ Java_java_awt_Component_initIDs
|
|||||||
(*env)->GetMethodID(env, cls, "getLocationOnScreen_NoTreeLock",
|
(*env)->GetMethodID(env, cls, "getLocationOnScreen_NoTreeLock",
|
||||||
"()Ljava/awt/Point;");
|
"()Ljava/awt/Point;");
|
||||||
|
|
||||||
componentIDs.resetGCMID =
|
|
||||||
(*env)->GetMethodID(env, cls, "resetGC", "()V");
|
|
||||||
|
|
||||||
keyclass = (*env)->FindClass(env, "java/awt/event/KeyEvent");
|
keyclass = (*env)->FindClass(env, "java/awt/event/KeyEvent");
|
||||||
DASSERT (keyclass != NULL);
|
DASSERT (keyclass != NULL);
|
||||||
|
|
||||||
@ -197,9 +194,6 @@ Java_java_awt_Component_initIDs
|
|||||||
"Lsun/awt/AppContext;");
|
"Lsun/awt/AppContext;");
|
||||||
|
|
||||||
(*env)->DeleteLocalRef(env, keyclass);
|
(*env)->DeleteLocalRef(env, keyclass);
|
||||||
|
|
||||||
DASSERT(componentIDs.resetGCMID);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -380,7 +380,6 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
|
|||||||
|
|
||||||
// fix for 4868278
|
// fix for 4868278
|
||||||
peer.updateGC();
|
peer.updateGC();
|
||||||
peer.resetTargetGC();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,44 +38,12 @@ class WCanvasPeer extends WComponentPeer implements CanvasPeer {
|
|||||||
|
|
||||||
private boolean eraseBackground;
|
private boolean eraseBackground;
|
||||||
|
|
||||||
Method resetGCMethod;
|
|
||||||
|
|
||||||
// Toolkit & peer internals
|
// Toolkit & peer internals
|
||||||
|
|
||||||
WCanvasPeer(Component target) {
|
WCanvasPeer(Component target) {
|
||||||
super(target);
|
super(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* From the DisplayChangedListener interface.
|
|
||||||
*
|
|
||||||
* Overrides WComponentPeer version because Canvases can be created with
|
|
||||||
* a non-defulat GraphicsConfiguration, which is no longer valid.
|
|
||||||
* Up-called for other windows peer instances (WPanelPeer, WWindowPeer).
|
|
||||||
*/
|
|
||||||
public void displayChanged() {
|
|
||||||
clearLocalGC();
|
|
||||||
resetTargetGC();
|
|
||||||
super.displayChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Reset the graphicsConfiguration member of our target Component.
|
|
||||||
* Component.resetGC() is a package-private method, so we have to call it
|
|
||||||
* through reflection.
|
|
||||||
*/
|
|
||||||
public void resetTargetGC() {
|
|
||||||
ComponentAccessor.resetGC((Component)target);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Clears the peer's winGraphicsConfig member.
|
|
||||||
* Overridden by WWindowPeer, which shouldn't have a null winGraphicsConfig.
|
|
||||||
*/
|
|
||||||
void clearLocalGC() {
|
|
||||||
winGraphicsConfig = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
native void create(WComponentPeer parent);
|
native void create(WComponentPeer parent);
|
||||||
|
|
||||||
void initialize() {
|
void initialize() {
|
||||||
@ -152,4 +120,10 @@ class WCanvasPeer extends WComponentPeer implements CanvasPeer {
|
|||||||
*/
|
*/
|
||||||
private native void setNativeBackgroundErase(boolean doErase,
|
private native void setNativeBackgroundErase(boolean doErase,
|
||||||
boolean doEraseOnResize);
|
boolean doEraseOnResize);
|
||||||
|
|
||||||
|
public GraphicsConfiguration getAppropriateGraphicsConfiguration(
|
||||||
|
GraphicsConfiguration gc)
|
||||||
|
{
|
||||||
|
return gc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ import java.util.logging.*;
|
|||||||
|
|
||||||
|
|
||||||
public abstract class WComponentPeer extends WObjectPeer
|
public abstract class WComponentPeer extends WObjectPeer
|
||||||
implements ComponentPeer, DropTargetPeer, DisplayChangedListener
|
implements ComponentPeer, DropTargetPeer
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Handle to native window
|
* Handle to native window
|
||||||
@ -452,15 +452,8 @@ public abstract class WComponentPeer extends WObjectPeer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void updateGraphicsData(GraphicsConfiguration gc) {
|
||||||
* From the DisplayChangedListener interface.
|
winGraphicsConfig = (Win32GraphicsConfig)gc;
|
||||||
*
|
|
||||||
* Called after a change in the display mode. This event
|
|
||||||
* triggers replacing the surfaceData object (since that object
|
|
||||||
* reflects the current display depth information, which has
|
|
||||||
* just changed).
|
|
||||||
*/
|
|
||||||
public void displayChanged() {
|
|
||||||
try {
|
try {
|
||||||
replaceSurfaceData();
|
replaceSurfaceData();
|
||||||
} catch (InvalidPipeException e) {
|
} catch (InvalidPipeException e) {
|
||||||
@ -468,13 +461,6 @@ public abstract class WComponentPeer extends WObjectPeer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Part of the DisplayChangedListener interface: components
|
|
||||||
* do not need to react to this event
|
|
||||||
*/
|
|
||||||
public void paletteChanged() {
|
|
||||||
}
|
|
||||||
|
|
||||||
//This will return null for Components not yet added to a Container
|
//This will return null for Components not yet added to a Container
|
||||||
public ColorModel getColorModel() {
|
public ColorModel getColorModel() {
|
||||||
GraphicsConfiguration gc = getGraphicsConfiguration();
|
GraphicsConfiguration gc = getGraphicsConfiguration();
|
||||||
|
@ -100,34 +100,6 @@ class WPanelPeer extends WCanvasPeer implements PanelPeer {
|
|||||||
return getInsets();
|
return getInsets();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* From the DisplayChangedListener interface. Often is
|
|
||||||
* up-called from a WWindowPeer instance.
|
|
||||||
*/
|
|
||||||
public void displayChanged() {
|
|
||||||
super.displayChanged();
|
|
||||||
displayChanged((Container)target);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Recursively iterates through all the HW and LW children
|
|
||||||
* of the container and calls displayChanged() for HW peers.
|
|
||||||
* Iteration through children peers only is not enough as the
|
|
||||||
* displayChanged notification may not be propagated to HW
|
|
||||||
* components inside LW containers, see 4452373 for details.
|
|
||||||
*/
|
|
||||||
private static void displayChanged(Container target) {
|
|
||||||
Component children[] = ((Container)target).getComponents();
|
|
||||||
for (Component child : children) {
|
|
||||||
ComponentPeer cpeer = child.getPeer();
|
|
||||||
if (cpeer instanceof WComponentPeer) {
|
|
||||||
((WComponentPeer)cpeer).displayChanged();
|
|
||||||
} else if (child instanceof Container) {
|
|
||||||
displayChanged((Container)child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private native void pRestack(Object[] peers);
|
private native void pRestack(Object[] peers);
|
||||||
private void restack(Container cont, Vector peers) {
|
private void restack(Container cont, Vector peers) {
|
||||||
for (int i = 0; i < cont.getComponentCount(); i++) {
|
for (int i = 0; i < cont.getComponentCount(); i++) {
|
||||||
|
@ -41,7 +41,9 @@ import sun.awt.*;
|
|||||||
|
|
||||||
import sun.java2d.pipe.Region;
|
import sun.java2d.pipe.Region;
|
||||||
|
|
||||||
public class WWindowPeer extends WPanelPeer implements WindowPeer {
|
public class WWindowPeer extends WPanelPeer implements WindowPeer,
|
||||||
|
DisplayChangedListener
|
||||||
|
{
|
||||||
|
|
||||||
private static final Logger log = Logger.getLogger("sun.awt.windows.WWindowPeer");
|
private static final Logger log = Logger.getLogger("sun.awt.windows.WWindowPeer");
|
||||||
private static final Logger screenLog = Logger.getLogger("sun.awt.windows.screen.WWindowPeer");
|
private static final Logger screenLog = Logger.getLogger("sun.awt.windows.screen.WWindowPeer");
|
||||||
@ -198,7 +200,6 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer {
|
|||||||
// super.displayChanged() in WWindowPeer.displayChanged() regardless of whether
|
// super.displayChanged() in WWindowPeer.displayChanged() regardless of whether
|
||||||
// GraphicsDevice was really changed, or not. So we need to track it here.
|
// GraphicsDevice was really changed, or not. So we need to track it here.
|
||||||
updateGC();
|
updateGC();
|
||||||
resetTargetGC();
|
|
||||||
|
|
||||||
realShow();
|
realShow();
|
||||||
updateMinimumSize();
|
updateMinimumSize();
|
||||||
@ -400,14 +401,6 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Called from WCanvasPeer.displayChanged().
|
|
||||||
* Override to do nothing - Window and WWindowPeer GC must never be set to
|
|
||||||
* null!
|
|
||||||
*/
|
|
||||||
void clearLocalGC() {}
|
|
||||||
|
|
||||||
public void updateGC() {
|
public void updateGC() {
|
||||||
int scrn = getScreenImOn();
|
int scrn = getScreenImOn();
|
||||||
if (screenLog.isLoggable(Level.FINER)) {
|
if (screenLog.isLoggable(Level.FINER)) {
|
||||||
@ -446,18 +439,36 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer {
|
|||||||
oldDev.removeDisplayChangedListener(this);
|
oldDev.removeDisplayChangedListener(this);
|
||||||
newDev.addDisplayChangedListener(this);
|
newDev.addDisplayChangedListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SunToolkit.executeOnEventHandlerThread((Component)target,
|
||||||
|
new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
AWTAccessor.getComponentAccessor().
|
||||||
|
setGraphicsConfiguration((Component)target, winGraphicsConfig);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* From the DisplayChangedListener interface
|
* From the DisplayChangedListener interface.
|
||||||
*
|
*
|
||||||
* This method handles a display change - either when the display settings
|
* This method handles a display change - either when the display settings
|
||||||
* are changed, or when the window has been dragged onto a different
|
* are changed, or when the window has been dragged onto a different
|
||||||
* display.
|
* display.
|
||||||
|
* Called after a change in the display mode. This event
|
||||||
|
* triggers replacing the surfaceData object (since that object
|
||||||
|
* reflects the current display depth information, which has
|
||||||
|
* just changed).
|
||||||
*/
|
*/
|
||||||
public void displayChanged() {
|
public void displayChanged() {
|
||||||
updateGC();
|
updateGC();
|
||||||
super.displayChanged();
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Part of the DisplayChangedListener interface: components
|
||||||
|
* do not need to react to this event
|
||||||
|
*/
|
||||||
|
public void paletteChanged() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private native int getScreenImOn();
|
private native int getScreenImOn();
|
||||||
|
Loading…
Reference in New Issue
Block a user