Skip to content

Commit

Permalink
JBR-5265 Workaround incorrect position of content window in queryXLoc…
Browse files Browse the repository at this point in the history
…ation.
  • Loading branch information
YaaZ authored and JB-Dmitry committed Dec 8, 2023
1 parent 9b813e2 commit 26684fd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
12 changes: 12 additions & 0 deletions src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ abstract class XDecoratedPeer extends XWindowPeer {
// reparented - indicates that WM has adopted the top-level.
boolean configure_seen;
boolean insets_corrected;
// Set to true after reconfigureContentWindow is called for the first time.
// Before this, content window may not be in sync with insets.
private boolean content_reconfigured;

XIconWindow iconWindow;
volatile WindowDimensions dimensions;
Expand Down Expand Up @@ -760,6 +763,7 @@ void reconfigureContentWindow(WindowDimensions dims) {
return;
}
content.setContentBounds(dims);
content_reconfigured = true;
}

private XEvent pendingConfigureEvent;
Expand Down Expand Up @@ -899,6 +903,14 @@ private void processConfigureEvent(XConfigureEvent xe) {
});
}

@Override
WindowLocation queryXLocation() {
XContentWindow c = content;
boolean client = c == null || !content_reconfigured;
return new WindowLocation(XlibUtil.translateCoordinates(client ? window : c.getWindow(),
XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber()), 0, 0), client);
}

private void checkShellRectSize(Rectangle shellRect) {
shellRect.width = Math.max(MIN_SIZE, shellRect.width);
shellRect.height = Math.max(MIN_SIZE, shellRect.height);
Expand Down
15 changes: 9 additions & 6 deletions src/java.desktop/unix/classes/sun/awt/X11/XWindowPeer.java
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ void xSetSize(int width, int height) {
class WindowLocation {
private final Point location; // Device space
private final boolean client;
private WindowLocation(Point location, boolean client) {
WindowLocation(Point location, boolean client) {
this.location = location;
this.client = client;
}
Expand Down Expand Up @@ -804,6 +804,11 @@ Point getUserLocation() {
}
}

WindowLocation queryXLocation() {
return new WindowLocation(XlibUtil.translateCoordinates(getContentWindow(),
XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber()), 0, 0), false);
}

WindowLocation getNewLocation(XConfigureEvent xe) {
int runningWM = XWM.getWMID();
if (xe.get_send_event() ||
Expand All @@ -826,13 +831,11 @@ WindowLocation getNewLocation(XConfigureEvent xe) {
case XWM.UNITY_COMPIZ_WM:
case XWM.AWESOME_WM:
{
Point xlocation = XlibUtil.translateCoordinates(getContentWindow(), XlibWrapper
.RootWindow(XToolkit.getDisplay(),
getScreenNumber()), 0, 0);
WindowLocation xlocation = queryXLocation();
if (log.isLoggable(PlatformLogger.Level.FINE)) {
log.fine("New X location: {0}", xlocation);
log.fine("New X location: {0} ({1})", xlocation.location, xlocation.client ? "client" : "bounds");
}
return new WindowLocation(xlocation, false);
return xlocation;
}
}
}
Expand Down

0 comments on commit 26684fd

Please sign in to comment.