From 3c81ec385171c2b969b3d2e8b9d06624879ecea5 Mon Sep 17 00:00:00 2001 From: Oleg Sukhodolsky Date: Thu, 13 Mar 2008 17:04:54 +0300 Subject: [PATCH] 6645885: small refactoring for XContentWindow Move createContent() method from XDecoratedPeer to XContentWindow, so only XContentWindow keep information about the way we position it. Reviewed-by: anthony --- .../classes/sun/awt/X11/XContentWindow.java | 34 ++++++++++++++----- .../classes/sun/awt/X11/XDecoratedPeer.java | 25 +++----------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/jdk/src/solaris/classes/sun/awt/X11/XContentWindow.java b/jdk/src/solaris/classes/sun/awt/X11/XContentWindow.java index 72737df0691..268f7f5d151 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XContentWindow.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XContentWindow.java @@ -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 @@ import sun.awt.ComponentAccessor; * 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 iconifiedExposeEvents = new java.util.ArrayList(); + private final java.util.List iconifiedExposeEvents = + new java.util.ArrayList(); - 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 @@ public class XContentWindow extends XWindow implements XConstants { } } - void initialize() { - xSetVisible(true); - } protected String getWMName() { return "Content window"; } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java index a6b8c36f8f6..07b7e1cde0f 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java @@ -98,8 +98,7 @@ class XDecoratedPeer extends XWindowPeer { // 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 @@ class XDecoratedPeer extends XWindowPeer { } } - 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 @@ class XDecoratedPeer extends XWindowPeer { 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 @@ class XDecoratedPeer extends XWindowPeer { } 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 @@ class XDecoratedPeer extends XWindowPeer { return getSize().height; } - public WindowDimensions getDimensions() { + final public WindowDimensions getDimensions() { return dimensions; }