changeset 92:63f02cc8ff3d

6645885: small refactoring for XContentWindow Summary: move createContent() method from XDecoratedPeer to XContentWindow, so only XContentWindow keep information about the way we position it. Reviewed-by: anthony
author son
date Thu, 13 Mar 2008 17:04:54 +0300
parents 026144f0d26a
children d9fb87af8b07
files src/solaris/classes/sun/awt/X11/XContentWindow.java src/solaris/classes/sun/awt/X11/XDecoratedPeer.java
diffstat 2 files changed, 31 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/classes/sun/awt/X11/XContentWindow.java	Thu Mar 13 16:56:54 2008 +0300
+++ b/src/solaris/classes/sun/awt/X11/XContentWindow.java	Thu Mar 13 17:04:54 2008 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2003-2008 Sun Microsystems, Inc.  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
@@ -39,16 +39,37 @@
  * This class implements window which serves as content window for decorated frames.
  * Its purpose to provide correct events dispatching for the complex
  * constructs such as decorated frames.
+ *
+ * It should always be located at (- left inset, - top inset) in the associated
+ * decorated window.  So coordinates in it would be the same as java coordinates.
  */
-public class XContentWindow extends XWindow implements XConstants {
+public final class XContentWindow extends XWindow implements XConstants {
     private static Logger insLog = Logger.getLogger("sun.awt.X11.insets.XContentWindow");
 
-    XDecoratedPeer parentFrame;
+    static XContentWindow createContent(XDecoratedPeer parentFrame) {
+        final WindowDimensions dims = parentFrame.getDimensions();
+        Rectangle rec = dims.getBounds();
+        // Fix for  - set the location of the content window to the (-left inset, -top inset)
+        Insets ins = dims.getInsets();
+        if (ins != null) {
+            rec.x = -ins.left;
+            rec.y = -ins.top;
+        } else {
+            rec.x = 0;
+            rec.y = 0;
+        }
+        final XContentWindow cw = new XContentWindow(parentFrame, rec);
+        cw.xSetVisible(true);
+        return cw;
+    }
+
+    private final XDecoratedPeer parentFrame;
 
     // A list of expose events that come when the parentFrame is iconified
-    private java.util.List<SavedExposeEvent> iconifiedExposeEvents = new java.util.ArrayList<SavedExposeEvent>();
+    private final java.util.List<SavedExposeEvent> iconifiedExposeEvents =
+            new java.util.ArrayList<SavedExposeEvent>();
 
-    XContentWindow(XDecoratedPeer parentFrame, Rectangle bounds) {
+    private XContentWindow(XDecoratedPeer parentFrame, Rectangle bounds) {
         super((Component)parentFrame.getTarget(), parentFrame.getShell(), bounds);
         this.parentFrame = parentFrame;
     }
@@ -63,9 +84,6 @@
         }
     }
 
-    void initialize() {
-        xSetVisible(true);
-    }
     protected String getWMName() {
         return "Content window";
     }
--- a/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java	Thu Mar 13 16:56:54 2008 +0300
+++ b/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java	Thu Mar 13 17:04:54 2008 +0300
@@ -98,8 +98,7 @@
         // happen after the X window is created.
         initResizability();
         updateSizeHints(dimensions);
-        content = createContent(dimensions);
-        content.initialize();
+        content = XContentWindow.createContent(this);
         if (warningWindow != null) {
             warningWindow.toFront();
         }
@@ -160,20 +159,6 @@
         }
     }
 
-    XContentWindow createContent(WindowDimensions dims) {
-        Rectangle rec = dims.getBounds();
-        // Fix for  - set the location of the content window to the (-left inset, -top inset)
-        Insets ins = dims.getInsets();
-        if (ins != null) {
-            rec.x = -ins.left;
-            rec.y = -ins.top;
-        } else {
-            rec.x = 0;
-            rec.y = 0;
-        }
-        return new XContentWindow(this, rec);
-    }
-
     XFocusProxyWindow createFocusProxy() {
         return new XFocusProxyWindow(this);
     }
@@ -286,7 +271,7 @@
                 return;
             }
             Component t = (Component)target;
-            if (getDecorations() == winAttr.AWT_DECOR_NONE) {
+            if (getDecorations() == XWindowAttributesData.AWT_DECOR_NONE) {
                 setReparented(true);
                 insets_corrected = true;
                 reshape(dimensions, SET_SIZE, false);
@@ -651,12 +636,12 @@
         }
         if (!isReparented() && isVisible() && runningWM != XWM.NO_WM
                 &&  !XWM.isNonReparentingWM()
-                && getDecorations() != winAttr.AWT_DECOR_NONE) {
+                && getDecorations() != XWindowAttributesData.AWT_DECOR_NONE) {
             insLog.fine("- visible but not reparented, skipping");
             return;
         }
         //Last chance to correct insets
-        if (!insets_corrected && getDecorations() != winAttr.AWT_DECOR_NONE) {
+        if (!insets_corrected && getDecorations() != XWindowAttributesData.AWT_DECOR_NONE) {
             long parent = XlibUtil.getParentWindow(window);
             Insets correctWM = (parent != -1) ? XWM.getWM().getInsets(this, window, parent) : null;
             if (insLog.isLoggable(Level.FINER)) {
@@ -870,7 +855,7 @@
         return getSize().height;
     }
 
-    public WindowDimensions getDimensions() {
+    final public WindowDimensions getDimensions() {
         return dimensions;
     }