提交 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -39,16 +39,37 @@ import sun.awt.ComponentAccessor; ...@@ -39,16 +39,37 @@ import sun.awt.ComponentAccessor;
* This class implements window which serves as content window for decorated frames. * This class implements window which serves as content window for decorated frames.
* Its purpose to provide correct events dispatching for the complex * Its purpose to provide correct events dispatching for the complex
* constructs such as decorated frames. * 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"); 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 // 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); super((Component)parentFrame.getTarget(), parentFrame.getShell(), bounds);
this.parentFrame = parentFrame; this.parentFrame = parentFrame;
} }
...@@ -63,9 +84,6 @@ public class XContentWindow extends XWindow implements XConstants { ...@@ -63,9 +84,6 @@ public class XContentWindow extends XWindow implements XConstants {
} }
} }
void initialize() {
xSetVisible(true);
}
protected String getWMName() { protected String getWMName() {
return "Content window"; return "Content window";
} }
......
...@@ -98,8 +98,7 @@ class XDecoratedPeer extends XWindowPeer { ...@@ -98,8 +98,7 @@ class XDecoratedPeer extends XWindowPeer {
// happen after the X window is created. // happen after the X window is created.
initResizability(); initResizability();
updateSizeHints(dimensions); updateSizeHints(dimensions);
content = createContent(dimensions); content = XContentWindow.createContent(this);
content.initialize();
if (warningWindow != null) { if (warningWindow != null) {
warningWindow.toFront(); warningWindow.toFront();
} }
...@@ -160,20 +159,6 @@ class XDecoratedPeer extends XWindowPeer { ...@@ -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() { XFocusProxyWindow createFocusProxy() {
return new XFocusProxyWindow(this); return new XFocusProxyWindow(this);
} }
...@@ -286,7 +271,7 @@ class XDecoratedPeer extends XWindowPeer { ...@@ -286,7 +271,7 @@ class XDecoratedPeer extends XWindowPeer {
return; return;
} }
Component t = (Component)target; Component t = (Component)target;
if (getDecorations() == winAttr.AWT_DECOR_NONE) { if (getDecorations() == XWindowAttributesData.AWT_DECOR_NONE) {
setReparented(true); setReparented(true);
insets_corrected = true; insets_corrected = true;
reshape(dimensions, SET_SIZE, false); reshape(dimensions, SET_SIZE, false);
...@@ -651,12 +636,12 @@ class XDecoratedPeer extends XWindowPeer { ...@@ -651,12 +636,12 @@ class XDecoratedPeer extends XWindowPeer {
} }
if (!isReparented() && isVisible() && runningWM != XWM.NO_WM if (!isReparented() && isVisible() && runningWM != XWM.NO_WM
&& !XWM.isNonReparentingWM() && !XWM.isNonReparentingWM()
&& getDecorations() != winAttr.AWT_DECOR_NONE) { && getDecorations() != XWindowAttributesData.AWT_DECOR_NONE) {
insLog.fine("- visible but not reparented, skipping"); insLog.fine("- visible but not reparented, skipping");
return; return;
} }
//Last chance to correct insets //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); long parent = XlibUtil.getParentWindow(window);
Insets correctWM = (parent != -1) ? XWM.getWM().getInsets(this, window, parent) : null; Insets correctWM = (parent != -1) ? XWM.getWM().getInsets(this, window, parent) : null;
if (insLog.isLoggable(Level.FINER)) { if (insLog.isLoggable(Level.FINER)) {
...@@ -870,7 +855,7 @@ class XDecoratedPeer extends XWindowPeer { ...@@ -870,7 +855,7 @@ class XDecoratedPeer extends XWindowPeer {
return getSize().height; return getSize().height;
} }
public WindowDimensions getDimensions() { final public WindowDimensions getDimensions() {
return dimensions; return dimensions;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册