8167652: Making a frame/dialog resizeble/unresizeble shifts its position on Unity
Reviewed-by: azvegint, serb
This commit is contained in:
parent
2044170e89
commit
63d3e42189
@ -51,9 +51,9 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
|||||||
boolean insets_corrected;
|
boolean insets_corrected;
|
||||||
|
|
||||||
XIconWindow iconWindow;
|
XIconWindow iconWindow;
|
||||||
WindowDimensions dimensions;
|
volatile WindowDimensions dimensions;
|
||||||
XContentWindow content;
|
XContentWindow content;
|
||||||
Insets currentInsets;
|
volatile Insets currentInsets;
|
||||||
XFocusProxyWindow focusProxy;
|
XFocusProxyWindow focusProxy;
|
||||||
static final Map<Class<?>,Insets> lastKnownInsets =
|
static final Map<Class<?>,Insets> lastKnownInsets =
|
||||||
Collections.synchronizedMap(new HashMap<>());
|
Collections.synchronizedMap(new HashMap<>());
|
||||||
@ -106,7 +106,7 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
|||||||
|
|
||||||
// The lines that follow need to be in a postInit, so they
|
// The lines that follow need to be in a postInit, so they
|
||||||
// happen after the X window is created.
|
// happen after the X window is created.
|
||||||
initResizability();
|
setResizable(winAttr.initialResizability);
|
||||||
XWM.requestWMExtents(getWindow());
|
XWM.requestWMExtents(getWindow());
|
||||||
|
|
||||||
content = XContentWindow.createContent(this);
|
content = XContentWindow.createContent(this);
|
||||||
@ -130,7 +130,12 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
|||||||
|
|
||||||
public void updateMinimumSize() {
|
public void updateMinimumSize() {
|
||||||
super.updateMinimumSize();
|
super.updateMinimumSize();
|
||||||
updateMinSizeHints();
|
XToolkit.awtLock();
|
||||||
|
try {
|
||||||
|
updateMinSizeHints();
|
||||||
|
} finally {
|
||||||
|
XToolkit.awtUnlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateMinSizeHints() {
|
private void updateMinSizeHints() {
|
||||||
@ -193,8 +198,13 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
|||||||
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
||||||
log.fine("Title is " + title);
|
log.fine("Title is " + title);
|
||||||
}
|
}
|
||||||
winAttr.title = title;
|
XToolkit.awtLock();
|
||||||
updateWMName();
|
try {
|
||||||
|
winAttr.title = title;
|
||||||
|
updateWMName();
|
||||||
|
} finally {
|
||||||
|
XToolkit.awtUnlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getWMName() {
|
protected String getWMName() {
|
||||||
@ -206,10 +216,10 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateWMName() {
|
void updateWMName() {
|
||||||
super.updateWMName();
|
|
||||||
String name = getWMName();
|
|
||||||
XToolkit.awtLock();
|
XToolkit.awtLock();
|
||||||
try {
|
try {
|
||||||
|
super.updateWMName();
|
||||||
|
String name = getWMName();
|
||||||
if (name == null || name.trim().equals("")) {
|
if (name == null || name.trim().equals("")) {
|
||||||
name = "Java";
|
name = "Java";
|
||||||
}
|
}
|
||||||
@ -304,6 +314,8 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
|||||||
if (XWM.getWMID() != XWM.UNITY_COMPIZ_WM) {
|
if (XWM.getWMID() != XWM.UNITY_COMPIZ_WM) {
|
||||||
currentInsets = new Insets(0, 0, 0, 0);
|
currentInsets = new Insets(0, 0, 0, 0);
|
||||||
wm_set_insets = null;
|
wm_set_insets = null;
|
||||||
|
} else {
|
||||||
|
insets_corrected = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,7 +342,7 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
|||||||
if (XWM.getWMID() != XWM.UNITY_COMPIZ_WM) {
|
if (XWM.getWMID() != XWM.UNITY_COMPIZ_WM) {
|
||||||
getWMSetInsets(XAtom.get(ev.get_atom()));
|
getWMSetInsets(XAtom.get(ev.get_atom()));
|
||||||
} else {
|
} else {
|
||||||
if(!isReparented()) {
|
if (!isReparented()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wm_set_insets = null;
|
wm_set_insets = null;
|
||||||
@ -377,137 +389,127 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
|||||||
insLog.fine(xe.toString());
|
insLog.fine(xe.toString());
|
||||||
}
|
}
|
||||||
reparent_serial = xe.get_serial();
|
reparent_serial = xe.get_serial();
|
||||||
XToolkit.awtLock();
|
long root = XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber());
|
||||||
try {
|
|
||||||
long root = XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber());
|
|
||||||
|
|
||||||
if (isEmbedded()) {
|
if (isEmbedded()) {
|
||||||
setReparented(true);
|
setReparented(true);
|
||||||
insets_corrected = true;
|
insets_corrected = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (getDecorations() == XWindowAttributesData.AWT_DECOR_NONE) {
|
||||||
|
setReparented(true);
|
||||||
|
insets_corrected = true;
|
||||||
|
reshape(dimensions, SET_SIZE, false);
|
||||||
|
} else if (xe.get_parent() == root) {
|
||||||
|
configure_seen = false;
|
||||||
|
insets_corrected = false;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We can be repareted to root for two reasons:
|
||||||
|
* . setVisible(false)
|
||||||
|
* . WM exited
|
||||||
|
*/
|
||||||
|
if (isVisible()) { /* WM exited */
|
||||||
|
/* Work around 4775545 */
|
||||||
|
XWM.getWM().unshadeKludge(this);
|
||||||
|
insLog.fine("- WM exited");
|
||||||
|
} else {
|
||||||
|
insLog.fine(" - reparent due to hide");
|
||||||
|
}
|
||||||
|
} else { /* reparented to WM frame, figure out our insets */
|
||||||
|
setReparented(true);
|
||||||
|
insets_corrected = false;
|
||||||
|
if (XWM.getWMID() == XWM.UNITY_COMPIZ_WM) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Component t = target;
|
|
||||||
if (getDecorations() == XWindowAttributesData.AWT_DECOR_NONE) {
|
|
||||||
setReparented(true);
|
|
||||||
insets_corrected = true;
|
|
||||||
reshape(dimensions, SET_SIZE, false);
|
|
||||||
} else if (xe.get_parent() == root) {
|
|
||||||
configure_seen = false;
|
|
||||||
insets_corrected = false;
|
|
||||||
|
|
||||||
/*
|
// Check if we have insets provided by the WM
|
||||||
* We can be repareted to root for two reasons:
|
Insets correctWM = getWMSetInsets(null);
|
||||||
* . setVisible(false)
|
if (correctWM != null) {
|
||||||
* . WM exited
|
if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
|
||||||
*/
|
insLog.finer("wm-provided insets {0}", correctWM);
|
||||||
if (isVisible()) { /* WM exited */
|
|
||||||
/* Work around 4775545 */
|
|
||||||
XWM.getWM().unshadeKludge(this);
|
|
||||||
insLog.fine("- WM exited");
|
|
||||||
} else {
|
|
||||||
insLog.fine(" - reparent due to hide");
|
|
||||||
}
|
}
|
||||||
} else { /* reparented to WM frame, figure out our insets */
|
// If these insets are equal to our current insets - no actions are necessary
|
||||||
setReparented(true);
|
Insets dimInsets = dimensions.getInsets();
|
||||||
insets_corrected = false;
|
if (correctWM.equals(dimInsets)) {
|
||||||
if (XWM.getWMID() == XWM.UNITY_COMPIZ_WM) {
|
insLog.finer("Insets are the same as estimated - no additional reshapes necessary");
|
||||||
|
no_reparent_artifacts = true;
|
||||||
|
insets_corrected = true;
|
||||||
|
applyGuessedInsets();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we have insets provided by the WM
|
|
||||||
Insets correctWM = getWMSetInsets(null);
|
|
||||||
if (correctWM != null) {
|
|
||||||
if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
|
|
||||||
insLog.finer("wm-provided insets {0}", correctWM);
|
|
||||||
}
|
|
||||||
// If these insets are equal to our current insets - no actions are necessary
|
|
||||||
Insets dimInsets = dimensions.getInsets();
|
|
||||||
if (correctWM.equals(dimInsets)) {
|
|
||||||
insLog.finer("Insets are the same as estimated - no additional reshapes necessary");
|
|
||||||
no_reparent_artifacts = true;
|
|
||||||
insets_corrected = true;
|
|
||||||
applyGuessedInsets();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
correctWM = XWM.getWM().getInsets(this, xe.get_window(), xe.get_parent());
|
|
||||||
if (correctWM != null) {
|
|
||||||
correctWM = copyAndScaleDown(correctWM);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
|
|
||||||
if (correctWM != null) {
|
|
||||||
insLog.finer("correctWM {0}", correctWM);
|
|
||||||
} else {
|
|
||||||
insLog.finer("correctWM insets are not available, waiting for configureNotify");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (correctWM != null) {
|
|
||||||
handleCorrectInsets(correctWM);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
XToolkit.awtUnlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void handleCorrectInsets(Insets correctWM) {
|
|
||||||
XToolkit.awtLock();
|
|
||||||
try {
|
|
||||||
/*
|
|
||||||
* Ok, now see if we need adjust window size because
|
|
||||||
* initial insets were wrong (most likely they were).
|
|
||||||
*/
|
|
||||||
Insets correction = difference(correctWM, currentInsets);
|
|
||||||
if (insLog.isLoggable(PlatformLogger.Level.FINEST)) {
|
|
||||||
insLog.finest("Corrention {0}", correction);
|
|
||||||
}
|
|
||||||
if (!isNull(correction)) {
|
|
||||||
currentInsets = copy(correctWM);
|
|
||||||
applyGuessedInsets();
|
|
||||||
|
|
||||||
//Fix for 6318109: PIT: Min Size is not honored properly when a
|
|
||||||
//smaller size is specified in setSize(), XToolkit
|
|
||||||
//update minimum size hints
|
|
||||||
updateMinSizeHints();
|
|
||||||
}
|
|
||||||
if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
|
|
||||||
insLog.finer("Dimensions before reparent: " + dimensions);
|
|
||||||
}
|
|
||||||
|
|
||||||
dimensions.setInsets(getRealInsets());
|
|
||||||
insets_corrected = true;
|
|
||||||
|
|
||||||
if (isMaximized()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If this window has been sized by a pack() we need
|
|
||||||
* to keep the interior geometry intact. Since pack()
|
|
||||||
* computed width and height with wrong insets, we
|
|
||||||
* must adjust the target dimensions appropriately.
|
|
||||||
*/
|
|
||||||
if ((getHints().get_flags() & (XUtilConstants.USPosition | XUtilConstants.PPosition)) != 0) {
|
|
||||||
reshape(dimensions, SET_BOUNDS, false);
|
|
||||||
} else {
|
} else {
|
||||||
reshape(dimensions, SET_SIZE, false);
|
correctWM = XWM.getWM().getInsets(this, xe.get_window(), xe.get_parent());
|
||||||
|
if (correctWM != null) {
|
||||||
|
correctWM = copyAndScaleDown(correctWM);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
|
||||||
|
if (correctWM != null) {
|
||||||
|
insLog.finer("correctWM {0}", correctWM);
|
||||||
|
} else {
|
||||||
|
insLog.finer("correctWM insets are not available, waiting for configureNotify");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (correctWM != null) {
|
||||||
|
handleCorrectInsets(correctWM);
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
XToolkit.awtUnlock();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleMoved(WindowDimensions dims) {
|
private void handleCorrectInsets(Insets correctWM) {
|
||||||
|
/*
|
||||||
|
* Ok, now see if we need adjust window size because
|
||||||
|
* initial insets were wrong (most likely they were).
|
||||||
|
*/
|
||||||
|
Insets correction = difference(correctWM, currentInsets);
|
||||||
|
if (insLog.isLoggable(PlatformLogger.Level.FINEST)) {
|
||||||
|
insLog.finest("Corrention {0}", correction);
|
||||||
|
}
|
||||||
|
if (!isNull(correction)) {
|
||||||
|
currentInsets = copy(correctWM);
|
||||||
|
applyGuessedInsets();
|
||||||
|
|
||||||
|
//Fix for 6318109: PIT: Min Size is not honored properly when a
|
||||||
|
//smaller size is specified in setSize(), XToolkit
|
||||||
|
//update minimum size hints
|
||||||
|
updateMinSizeHints();
|
||||||
|
}
|
||||||
|
if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
|
||||||
|
insLog.finer("Dimensions before reparent: " + dimensions);
|
||||||
|
}
|
||||||
|
WindowDimensions newDimensions = new WindowDimensions(dimensions);
|
||||||
|
newDimensions.setInsets(getRealInsets());
|
||||||
|
dimensions = newDimensions;
|
||||||
|
insets_corrected = true;
|
||||||
|
|
||||||
|
if (isMaximized()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If this window has been sized by a pack() we need
|
||||||
|
* to keep the interior geometry intact. Since pack()
|
||||||
|
* computed width and height with wrong insets, we
|
||||||
|
* must adjust the target dimensions appropriately.
|
||||||
|
*/
|
||||||
|
if ((getHints().get_flags() & (XUtilConstants.USPosition | XUtilConstants.PPosition)) != 0) {
|
||||||
|
reshape(dimensions, SET_BOUNDS, false);
|
||||||
|
} else {
|
||||||
|
reshape(dimensions, SET_SIZE, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleMoved(WindowDimensions dims) {
|
||||||
Point loc = dims.getLocation();
|
Point loc = dims.getLocation();
|
||||||
AWTAccessor.getComponentAccessor().setLocation(target, loc.x, loc.y);
|
AWTAccessor.getComponentAccessor().setLocation(target, loc.x, loc.y);
|
||||||
postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_MOVED));
|
postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_MOVED));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected Insets guessInsets() {
|
private Insets guessInsets() {
|
||||||
if (isEmbedded() || isTargetUndecorated()) {
|
if (isEmbedded() || isTargetUndecorated()) {
|
||||||
return new Insets(0, 0, 0, 0);
|
return new Insets(0, 0, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
@ -532,16 +534,7 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
|||||||
currentInsets = copy(guessed);
|
currentInsets = copy(guessed);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void revalidate() {
|
private Insets getRealInsets() {
|
||||||
XToolkit.executeOnEventHandlerThread(target, new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
target.invalidate();
|
|
||||||
target.validate();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Insets getRealInsets() {
|
|
||||||
if (isNull(currentInsets)) {
|
if (isNull(currentInsets)) {
|
||||||
applyGuessedInsets();
|
applyGuessedInsets();
|
||||||
}
|
}
|
||||||
@ -578,7 +571,7 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
|||||||
|
|
||||||
// Coordinates are that of the target
|
// Coordinates are that of the target
|
||||||
// Called only on Toolkit thread
|
// Called only on Toolkit thread
|
||||||
public void reshape(WindowDimensions newDimensions, int op,
|
private void reshape(WindowDimensions newDimensions, int op,
|
||||||
boolean userReshape)
|
boolean userReshape)
|
||||||
{
|
{
|
||||||
if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
|
if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
|
||||||
@ -599,81 +592,75 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
|||||||
}
|
}
|
||||||
newDimensions = new WindowDimensions(newBounds, insets, newDimensions.isClientSizeSet());
|
newDimensions = new WindowDimensions(newBounds, insets, newDimensions.isClientSizeSet());
|
||||||
}
|
}
|
||||||
XToolkit.awtLock();
|
if (!isReparented() || !isVisible()) {
|
||||||
try {
|
if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
|
||||||
if (!isReparented() || !isVisible()) {
|
insLog.fine("- not reparented({0}) or not visible({1}), default reshape",
|
||||||
if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
|
Boolean.valueOf(isReparented()), Boolean.valueOf(visible));
|
||||||
insLog.fine("- not reparented({0}) or not visible({1}), default reshape",
|
|
||||||
Boolean.valueOf(isReparented()), Boolean.valueOf(visible));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fix for 6323293.
|
|
||||||
// This actually is needed to preserve compatibility with previous releases -
|
|
||||||
// some of licensees are expecting componentMoved event on invisible one while
|
|
||||||
// its location changes.
|
|
||||||
Point oldLocation = getLocation();
|
|
||||||
|
|
||||||
Point newLocation = new Point(AWTAccessor.getComponentAccessor().getX(target),
|
|
||||||
AWTAccessor.getComponentAccessor().getY(target));
|
|
||||||
|
|
||||||
if (!newLocation.equals(oldLocation)) {
|
|
||||||
handleMoved(newDimensions);
|
|
||||||
}
|
|
||||||
|
|
||||||
dimensions = new WindowDimensions(newDimensions);
|
|
||||||
updateSizeHints(dimensions);
|
|
||||||
Rectangle client = dimensions.getClientRect();
|
|
||||||
checkShellRect(client);
|
|
||||||
setShellBounds(client);
|
|
||||||
if (content != null &&
|
|
||||||
!content.getSize().equals(newDimensions.getSize()))
|
|
||||||
{
|
|
||||||
reconfigureContentWindow(newDimensions);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int wm = XWM.getWMID();
|
// Fix for 6323293.
|
||||||
updateChildrenSizes();
|
// This actually is needed to preserve compatibility with previous releases -
|
||||||
applyGuessedInsets();
|
// some of licensees are expecting componentMoved event on invisible one while
|
||||||
|
// its location changes.
|
||||||
|
Point oldLocation = getLocation();
|
||||||
|
|
||||||
Rectangle shellRect = newDimensions.getClientRect();
|
Point newLocation = new Point(AWTAccessor.getComponentAccessor().getX(target),
|
||||||
|
AWTAccessor.getComponentAccessor().getY(target));
|
||||||
|
|
||||||
if (gravityBug()) {
|
if (!newLocation.equals(oldLocation)) {
|
||||||
Insets in = newDimensions.getInsets();
|
handleMoved(newDimensions);
|
||||||
shellRect.translate(in.left, in.top);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((op & NO_EMBEDDED_CHECK) == 0 && isEmbedded()) {
|
dimensions = new WindowDimensions(newDimensions);
|
||||||
shellRect.setLocation(0, 0);
|
updateSizeHints(dimensions);
|
||||||
|
Rectangle client = dimensions.getClientRect();
|
||||||
|
checkShellRect(client);
|
||||||
|
setShellBounds(client);
|
||||||
|
if (content != null &&
|
||||||
|
!content.getSize().equals(newDimensions.getSize()))
|
||||||
|
{
|
||||||
|
reconfigureContentWindow(newDimensions);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
checkShellRectSize(shellRect);
|
|
||||||
if (!isEmbedded()) {
|
|
||||||
checkShellRectPos(shellRect);
|
|
||||||
}
|
|
||||||
|
|
||||||
op = op & ~NO_EMBEDDED_CHECK;
|
|
||||||
|
|
||||||
if (op == SET_LOCATION) {
|
|
||||||
setShellPosition(shellRect);
|
|
||||||
} else if (isResizable()) {
|
|
||||||
if (op == SET_BOUNDS) {
|
|
||||||
setShellBounds(shellRect);
|
|
||||||
} else {
|
|
||||||
setShellSize(shellRect);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
XWM.setShellNotResizable(this, newDimensions, shellRect, true);
|
|
||||||
if (op == SET_BOUNDS) {
|
|
||||||
setShellPosition(shellRect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
reconfigureContentWindow(newDimensions);
|
|
||||||
} finally {
|
|
||||||
XToolkit.awtUnlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateChildrenSizes();
|
||||||
|
applyGuessedInsets();
|
||||||
|
|
||||||
|
Rectangle shellRect = newDimensions.getClientRect();
|
||||||
|
|
||||||
|
if (gravityBug()) {
|
||||||
|
Insets in = newDimensions.getInsets();
|
||||||
|
shellRect.translate(in.left, in.top);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((op & NO_EMBEDDED_CHECK) == 0 && isEmbedded()) {
|
||||||
|
shellRect.setLocation(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
checkShellRectSize(shellRect);
|
||||||
|
if (!isEmbedded()) {
|
||||||
|
checkShellRectPos(shellRect);
|
||||||
|
}
|
||||||
|
|
||||||
|
op = op & ~NO_EMBEDDED_CHECK;
|
||||||
|
|
||||||
|
if (op == SET_LOCATION) {
|
||||||
|
setShellPosition(shellRect);
|
||||||
|
} else if (isResizable()) {
|
||||||
|
if (op == SET_BOUNDS) {
|
||||||
|
setShellBounds(shellRect);
|
||||||
|
} else {
|
||||||
|
setShellSize(shellRect);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
XWM.setShellNotResizable(this, newDimensions, shellRect, true);
|
||||||
|
if (op == SET_BOUNDS) {
|
||||||
|
setShellPosition(shellRect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
reconfigureContentWindow(newDimensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -682,8 +669,6 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
|||||||
private void reshape(int x, int y, int width, int height, int operation,
|
private void reshape(int x, int y, int width, int height, int operation,
|
||||||
boolean userReshape)
|
boolean userReshape)
|
||||||
{
|
{
|
||||||
Rectangle newRec;
|
|
||||||
boolean setClient = false;
|
|
||||||
WindowDimensions dims = new WindowDimensions(dimensions);
|
WindowDimensions dims = new WindowDimensions(dimensions);
|
||||||
switch (operation & (~NO_EMBEDDED_CHECK)) {
|
switch (operation & (~NO_EMBEDDED_CHECK)) {
|
||||||
case SET_LOCATION:
|
case SET_LOCATION:
|
||||||
@ -726,7 +711,12 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
|||||||
*/
|
*/
|
||||||
public void setBounds(int x, int y, int width, int height, int op) {
|
public void setBounds(int x, int y, int width, int height, int op) {
|
||||||
// TODO: Rewrite with WindowDimensions
|
// TODO: Rewrite with WindowDimensions
|
||||||
reshape(x, y, width, height, op, true);
|
XToolkit.awtLock();
|
||||||
|
try {
|
||||||
|
reshape(x, y, width, height, op, true);
|
||||||
|
} finally {
|
||||||
|
XToolkit.awtUnlock();
|
||||||
|
}
|
||||||
validateSurface();
|
validateSurface();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -861,81 +851,74 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
|||||||
checkShellRectPos(shellRect);
|
checkShellRectPos(shellRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShellBounds(Rectangle rec) {
|
private void setShellBounds(Rectangle rec) {
|
||||||
if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
|
if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
|
||||||
insLog.fine("Setting shell bounds on " + this + " to " + rec);
|
insLog.fine("Setting shell bounds on " + this + " to " + rec);
|
||||||
}
|
}
|
||||||
XToolkit.awtLock();
|
updateSizeHints(rec.x, rec.y, rec.width, rec.height);
|
||||||
try {
|
XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(), getShell(),
|
||||||
updateSizeHints(rec.x, rec.y, rec.width, rec.height);
|
scaleUp(rec.x), scaleUp(rec.y),
|
||||||
XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(), getShell(),
|
scaleUp(rec.width), scaleUp(rec.height));
|
||||||
scaleUp(rec.x), scaleUp(rec.y),
|
|
||||||
scaleUp(rec.width), scaleUp(rec.height));
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
XToolkit.awtUnlock();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public void setShellSize(Rectangle rec) {
|
|
||||||
|
private void setShellSize(Rectangle rec) {
|
||||||
if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
|
if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
|
||||||
insLog.fine("Setting shell size on " + this + " to " + rec);
|
insLog.fine("Setting shell size on " + this + " to " + rec);
|
||||||
}
|
}
|
||||||
XToolkit.awtLock();
|
updateSizeHints(rec.x, rec.y, rec.width, rec.height);
|
||||||
try {
|
XlibWrapper.XResizeWindow(XToolkit.getDisplay(), getShell(),
|
||||||
updateSizeHints(rec.x, rec.y, rec.width, rec.height);
|
scaleUp(rec.width), scaleUp(rec.height));
|
||||||
XlibWrapper.XResizeWindow(XToolkit.getDisplay(), getShell(),
|
|
||||||
scaleUp(rec.width), scaleUp(rec.height));
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
XToolkit.awtUnlock();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public void setShellPosition(Rectangle rec) {
|
|
||||||
|
private void setShellPosition(Rectangle rec) {
|
||||||
if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
|
if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
|
||||||
insLog.fine("Setting shell position on " + this + " to " + rec);
|
insLog.fine("Setting shell position on " + this + " to " + rec);
|
||||||
}
|
}
|
||||||
XToolkit.awtLock();
|
updateSizeHints(rec.x, rec.y, rec.width, rec.height);
|
||||||
try {
|
XlibWrapper.XMoveWindow(XToolkit.getDisplay(), getShell(),
|
||||||
updateSizeHints(rec.x, rec.y, rec.width, rec.height);
|
scaleUp(rec.x), scaleUp(rec.y));
|
||||||
XlibWrapper.XMoveWindow(XToolkit.getDisplay(), getShell(),
|
|
||||||
scaleUp(rec.x), scaleUp(rec.y));
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
XToolkit.awtUnlock();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void initResizability() {
|
|
||||||
setResizable(winAttr.initialResizability);
|
|
||||||
}
|
|
||||||
public void setResizable(boolean resizable) {
|
public void setResizable(boolean resizable) {
|
||||||
int fs = winAttr.functions;
|
XToolkit.awtLock();
|
||||||
if (!isResizable() && resizable) {
|
try {
|
||||||
resetWMSetInsets();
|
int fs = winAttr.functions;
|
||||||
if (!isEmbedded()) {
|
if (!isResizable() && resizable) {
|
||||||
setReparented(false);
|
resetWMSetInsets();
|
||||||
|
if (!isEmbedded()) {
|
||||||
|
setReparented(false);
|
||||||
|
}
|
||||||
|
winAttr.isResizable = resizable;
|
||||||
|
if ((fs & MWMConstants.MWM_FUNC_ALL) != 0) {
|
||||||
|
fs &= ~(MWMConstants.MWM_FUNC_RESIZE
|
||||||
|
| MWMConstants.MWM_FUNC_MAXIMIZE);
|
||||||
|
} else {
|
||||||
|
fs |= (MWMConstants.MWM_FUNC_RESIZE
|
||||||
|
| MWMConstants.MWM_FUNC_MAXIMIZE);
|
||||||
|
}
|
||||||
|
winAttr.functions = fs;
|
||||||
|
XWM.setShellResizable(this);
|
||||||
|
} else if (isResizable() && !resizable) {
|
||||||
|
resetWMSetInsets();
|
||||||
|
if (!isEmbedded()) {
|
||||||
|
setReparented(false);
|
||||||
|
}
|
||||||
|
winAttr.isResizable = resizable;
|
||||||
|
if ((fs & MWMConstants.MWM_FUNC_ALL) != 0) {
|
||||||
|
fs |= (MWMConstants.MWM_FUNC_RESIZE
|
||||||
|
| MWMConstants.MWM_FUNC_MAXIMIZE);
|
||||||
|
} else {
|
||||||
|
fs &= ~(MWMConstants.MWM_FUNC_RESIZE
|
||||||
|
| MWMConstants.MWM_FUNC_MAXIMIZE);
|
||||||
|
}
|
||||||
|
winAttr.functions = fs;
|
||||||
|
XWM.setShellNotResizable(this, dimensions,
|
||||||
|
XWM.getWMID() == XWM.UNITY_COMPIZ_WM && configure_seen ?
|
||||||
|
dimensions.getScreenBounds() :
|
||||||
|
dimensions.getBounds(), false);
|
||||||
}
|
}
|
||||||
winAttr.isResizable = resizable;
|
} finally {
|
||||||
if ((fs & MWMConstants.MWM_FUNC_ALL) != 0) {
|
XToolkit.awtUnlock();
|
||||||
fs &= ~(MWMConstants.MWM_FUNC_RESIZE | MWMConstants.MWM_FUNC_MAXIMIZE);
|
|
||||||
} else {
|
|
||||||
fs |= (MWMConstants.MWM_FUNC_RESIZE | MWMConstants.MWM_FUNC_MAXIMIZE);
|
|
||||||
}
|
|
||||||
winAttr.functions = fs;
|
|
||||||
XWM.setShellResizable(this);
|
|
||||||
} else if (isResizable() && !resizable) {
|
|
||||||
resetWMSetInsets();
|
|
||||||
if (!isEmbedded()) {
|
|
||||||
setReparented(false);
|
|
||||||
}
|
|
||||||
winAttr.isResizable = resizable;
|
|
||||||
if ((fs & MWMConstants.MWM_FUNC_ALL) != 0) {
|
|
||||||
fs |= (MWMConstants.MWM_FUNC_RESIZE | MWMConstants.MWM_FUNC_MAXIMIZE);
|
|
||||||
} else {
|
|
||||||
fs &= ~(MWMConstants.MWM_FUNC_RESIZE | MWMConstants.MWM_FUNC_MAXIMIZE);
|
|
||||||
}
|
|
||||||
winAttr.functions = fs;
|
|
||||||
XWM.setShellNotResizable(this, dimensions, dimensions.getBounds(), false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -990,17 +973,16 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
|||||||
try {
|
try {
|
||||||
if (configure_seen) {
|
if (configure_seen) {
|
||||||
return toGlobal(0,0);
|
return toGlobal(0,0);
|
||||||
} else {
|
|
||||||
Point location = target.getLocation();
|
|
||||||
if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
|
|
||||||
insLog.fine("getLocationOnScreen {0} not reparented: {1} ",
|
|
||||||
this, location);
|
|
||||||
}
|
|
||||||
return location;
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
XToolkit.awtUnlock();
|
XToolkit.awtUnlock();
|
||||||
}
|
}
|
||||||
|
Point location = target.getLocation();
|
||||||
|
if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
|
||||||
|
insLog.fine("getLocationOnScreen {0} not reparented: {1} ",
|
||||||
|
this, location);
|
||||||
|
}
|
||||||
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1134,7 +1116,7 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
|||||||
return focusProxy;
|
return focusProxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleQuit() {
|
private void handleQuit() {
|
||||||
postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_CLOSING));
|
postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_CLOSING));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1029,8 +1029,14 @@ final class XWM
|
|||||||
}
|
}
|
||||||
XToolkit.awtLock();
|
XToolkit.awtLock();
|
||||||
try {
|
try {
|
||||||
Rectangle shellBounds = window.getShellBounds();
|
Rectangle shellBounds;
|
||||||
shellBounds.translate(-window.currentInsets.left, -window.currentInsets.top);
|
if (getWMID() != UNITY_COMPIZ_WM) {
|
||||||
|
shellBounds = window.getShellBounds();
|
||||||
|
shellBounds.translate(-window.currentInsets.left,
|
||||||
|
-window.currentInsets.top);
|
||||||
|
} else {
|
||||||
|
shellBounds = window.getDimensions().getScreenBounds();
|
||||||
|
}
|
||||||
window.updateSizeHints(window.getDimensions());
|
window.updateSizeHints(window.getDimensions());
|
||||||
requestWMExtents(window.getWindow());
|
requestWMExtents(window.getWindow());
|
||||||
XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(),
|
XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(),
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
/* @test
|
/* @test
|
||||||
@key headful
|
@key headful
|
||||||
@bug 8166897
|
@bug 8166897 8167652
|
||||||
@summary Some font overlap in the Optionpane dialog.
|
@summary Some font overlap in the Optionpane dialog.
|
||||||
@run main ChangeWindowResizabiltyTest
|
@run main ChangeWindowResizabiltyTest
|
||||||
*/
|
*/
|
||||||
@ -34,41 +34,75 @@ import java.awt.Dimension;
|
|||||||
import java.awt.Frame;
|
import java.awt.Frame;
|
||||||
import java.awt.Panel;
|
import java.awt.Panel;
|
||||||
import java.awt.Robot;
|
import java.awt.Robot;
|
||||||
|
import java.awt.Point;
|
||||||
|
|
||||||
public class ChangeWindowResizabiltyTest {
|
public class ChangeWindowResizabiltyTest {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
Robot robot = new Robot();
|
Robot robot = new Robot();
|
||||||
for(int i = 0; i < 10; i++) {
|
for(int i = 0; i < 10; i++) {
|
||||||
Dialog dialog = new Dialog((Frame) null);
|
Dialog dialog = new Dialog((Frame) null);
|
||||||
|
dialog.setLocation(100, 100);
|
||||||
Component panel = new Panel();
|
Component panel = new Panel();
|
||||||
panel.setPreferredSize(new Dimension(200, 100));
|
panel.setPreferredSize(new Dimension(200, 100));
|
||||||
dialog.add(panel);
|
dialog.add(panel);
|
||||||
dialog.pack();
|
dialog.pack();
|
||||||
dialog.setVisible(true);
|
dialog.setVisible(true);
|
||||||
|
robot.waitForIdle();
|
||||||
|
robot.delay(200);
|
||||||
|
|
||||||
|
Point frameLoc = dialog.getLocationOnScreen();
|
||||||
|
Point contentLoc = panel.getLocationOnScreen();
|
||||||
|
|
||||||
|
System.out.println("Decor location " + frameLoc);
|
||||||
|
System.out.println("Content location " + contentLoc);
|
||||||
|
|
||||||
dialog.setResizable(false);
|
dialog.setResizable(false);
|
||||||
robot.waitForIdle();
|
robot.waitForIdle();
|
||||||
robot.delay(200);
|
robot.delay(200);
|
||||||
|
|
||||||
System.out.println(panel.getLocationOnScreen());
|
Point l = dialog.getLocationOnScreen();
|
||||||
System.out.println(dialog.getLocationOnScreen());
|
if (!l.equals(frameLoc)) {
|
||||||
|
dialog.dispose();
|
||||||
|
throw new RuntimeException("Decorated frame location moved " +
|
||||||
|
"after setResizable(false)" + l);
|
||||||
|
}
|
||||||
|
|
||||||
|
l = panel.getLocationOnScreen();
|
||||||
|
if (!l.equals(contentLoc)) {
|
||||||
|
dialog.dispose();
|
||||||
|
throw new RuntimeException("Content location moved after " +
|
||||||
|
"setResizable(false)" + l);
|
||||||
|
}
|
||||||
|
|
||||||
if (panel.getLocationOnScreen().y <
|
if (panel.getLocationOnScreen().y <
|
||||||
dialog.getLocationOnScreen().y + dialog.getInsets().top) {
|
dialog.getLocationOnScreen().y + dialog.getInsets().top) {
|
||||||
dialog.dispose();
|
dialog.dispose();
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
"Wrong content position after setResizable(false)");
|
"Wrong content position after setResizable(false)");
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog.setResizable(true);
|
dialog.setResizable(true);
|
||||||
robot.waitForIdle();
|
robot.waitForIdle();
|
||||||
robot.delay(200);
|
robot.delay(200);
|
||||||
System.out.println(panel.getLocationOnScreen());
|
|
||||||
System.out.println(dialog.getLocationOnScreen());
|
l = dialog.getLocationOnScreen();
|
||||||
|
if (!l.equals(frameLoc)) {
|
||||||
|
dialog.dispose();
|
||||||
|
throw new RuntimeException("Decorated frame location moved " +
|
||||||
|
"after setResizable(true)" + l);
|
||||||
|
}
|
||||||
|
|
||||||
|
l = panel.getLocationOnScreen();
|
||||||
|
if (!l.equals(contentLoc)) {
|
||||||
|
dialog.dispose();
|
||||||
|
throw new RuntimeException("Content location moved after " +
|
||||||
|
"setResizable(true)" + l);
|
||||||
|
}
|
||||||
if (panel.getLocationOnScreen().y <
|
if (panel.getLocationOnScreen().y <
|
||||||
dialog.getLocationOnScreen().y + dialog.getInsets().top) {
|
dialog.getLocationOnScreen().y + dialog.getInsets().top) {
|
||||||
dialog.dispose();
|
dialog.dispose();
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
"Wrong content position after setResizable(true)");
|
"Wrong content position after setResizable(true)");
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog.dispose();
|
dialog.dispose();
|
||||||
|
Loading…
Reference in New Issue
Block a user