提交 e7590d65 编写于 作者: S son

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
上级 74e978ac
/*
* 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<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 @@ public class XContentWindow extends XWindow implements XConstants {
}
}
void initialize() {
xSetVisible(true);
}
protected String getWMName() {
return "Content window";
}
......
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册