--- a/jdk/src/solaris/classes/sun/awt/X11/XCanvasPeer.java Thu Feb 19 14:10:19 2009 +0300
+++ b/jdk/src/solaris/classes/sun/awt/X11/XCanvasPeer.java Fri Feb 20 17:34:16 2009 +0300
@@ -27,7 +27,6 @@
import java.awt.*;
import java.awt.peer.*;
-import sun.awt.ComponentAccessor;
import sun.awt.SunToolkit;
import sun.awt.X11GraphicsConfig;
@@ -54,60 +53,45 @@
}
}
- void resetTargetGC(Component target) {
- ComponentAccessor.resetGC(target);
- }
+ /* Get a GraphicsConfig with the same visual on the new
+ * screen, which should be easy in Xinerama mode.
+ */
+ 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
+
+ int screenNum = ((X11GraphicsDevice)gc.getDevice()).getScreen();
+
+ X11GraphicsConfig parentgc;
+ // save vis id of current gc
+ int visual = graphicsConfig.getVisual();
- /*
- * 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);
+ X11GraphicsDevice newDev = (X11GraphicsDevice) GraphicsEnvironment.
+ getLocalGraphicsEnvironment().
+ getScreenDevices()[screenNum];
+
+ for (int i = 0; i < newDev.getNumConfigs(screenNum); i++) {
+ if (visual == newDev.getConfigVisualId(i, screenNum)) {
+ // use that
+ graphicsConfig = (X11GraphicsConfig)newDev.getConfigurations()[i];
+ break;
+ }
+ }
+ // just in case...
+ if (graphicsConfig == null) {
+ graphicsConfig = (X11GraphicsConfig) GraphicsEnvironment.
+ getLocalGraphicsEnvironment().
+ getScreenDevices()[screenNum].
+ getDefaultConfiguration();
+ }
+
+ return graphicsConfig;
}
- /* Set graphicsConfig to a GraphicsConfig with the same visual on the new
- * 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) {
- // Opt: Only need to do if we're not using the default GC
- if (graphicsConfig != null) {
- X11GraphicsConfig parentgc;
- // save vis id of current gc
- int visual = graphicsConfig.getVisual();
-
- X11GraphicsDevice newDev = (X11GraphicsDevice) GraphicsEnvironment.
- getLocalGraphicsEnvironment().
- getScreenDevices()[screenNum];
-
- for (int i = 0; i < newDev.getNumConfigs(screenNum); i++) {
- if (visual == newDev.getConfigVisualId(i, screenNum)) {
- // use that
- graphicsConfig = (X11GraphicsConfig)newDev.getConfigurations()[i];
- break;
- }
- }
- // just in case...
- if (graphicsConfig == null) {
- graphicsConfig = (X11GraphicsConfig) GraphicsEnvironment.
- getLocalGraphicsEnvironment().
- getScreenDevices()[screenNum].
- getDefaultConfiguration();
- }
- }
- }
protected boolean shouldFocusOnClick() {
// Canvas should always be able to be focused by mouse clicks.
return true;