aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbagiras <none@none>2013-11-18 23:24:27 +0400
committerbagiras <none@none>2013-11-18 23:24:27 +0400
commitf965e9c38a3614216a775726851ef23e205b40ce (patch)
tree7ee5223f502254674fcafd7ad72aff988f5296b9 /src
parent60a2d4c759e06194218ba2ee99293c40be1472f5 (diff)
8027628: JWindow jumps to (0, 0) after mouse clicked
Reviewed-by: anthony, serb
Diffstat (limited to 'src')
-rw-r--r--src/solaris/classes/sun/awt/X11/XDecoratedPeer.java40
-rw-r--r--src/solaris/classes/sun/awt/X11/XWindowPeer.java56
2 files changed, 55 insertions, 41 deletions
diff --git a/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java b/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java
index 912a951f3..fa5c88402 100644
--- a/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java
+++ b/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java
@@ -740,37 +740,7 @@ abstract class XDecoratedPeer extends XWindowPeer {
// Bounds of the window
Rectangle targetBounds = AWTAccessor.getComponentAccessor().getBounds((Component)target);
- Point newLocation = targetBounds.getLocation();
- if (xe.get_send_event() || runningWM == XWM.NO_WM || XWM.isNonReparentingWM()) {
- // Location, Client size + insets
- newLocation = new Point(xe.get_x() - currentInsets.left, xe.get_y() - currentInsets.top);
- } else {
- // ICCCM 4.1.5 states that a real ConfigureNotify will be sent when
- // a window is resized but the client can not tell if the window was
- // moved or not. The client should consider the position as unkown
- // and use TranslateCoordinates to find the actual position.
- //
- // TODO this should be the default for every case.
- switch (XWM.getWMID()) {
- case XWM.CDE_WM:
- case XWM.MOTIF_WM:
- case XWM.METACITY_WM:
- case XWM.MUTTER_WM:
- case XWM.SAWFISH_WM:
- {
- Point xlocation = queryXLocation();
- if (log.isLoggable(PlatformLogger.Level.FINE)) {
- log.fine("New X location: {0}", xlocation);
- }
- if (xlocation != null) {
- newLocation = xlocation;
- }
- break;
- }
- default:
- break;
- }
- }
+ Point newLocation = getNewLocation(xe, currentInsets.left, currentInsets.top);
WindowDimensions newDimensions =
new WindowDimensions(newLocation,
@@ -1261,12 +1231,4 @@ abstract class XDecoratedPeer extends XWindowPeer {
}
super.handleWindowFocusOut(oppositeWindow, serial);
}
-
- private Point queryXLocation()
- {
- return XlibUtil.translateCoordinates(
- getContentWindow(),
- XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber()),
- new Point(0, 0));
- }
}
diff --git a/src/solaris/classes/sun/awt/X11/XWindowPeer.java b/src/solaris/classes/sun/awt/X11/XWindowPeer.java
index e0b1cc478..8dcd15bc9 100644
--- a/src/solaris/classes/sun/awt/X11/XWindowPeer.java
+++ b/src/solaris/classes/sun/awt/X11/XWindowPeer.java
@@ -740,15 +740,67 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
public void paletteChanged() {
}
+ private Point queryXLocation()
+ {
+ return XlibUtil.translateCoordinates(
+ getContentWindow(),
+ XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber()),
+ new Point(0, 0));
+ }
+
+ protected Point getNewLocation(XConfigureEvent xe, int leftInset, int topInset) {
+ // Bounds of the window
+ Rectangle targetBounds = AWTAccessor.getComponentAccessor().getBounds((Component)target);
+
+ int runningWM = XWM.getWMID();
+ Point newLocation = targetBounds.getLocation();
+ if (xe.get_send_event() || runningWM == XWM.NO_WM || XWM.isNonReparentingWM()) {
+ // Location, Client size + insets
+ newLocation = new Point(xe.get_x() - leftInset, xe.get_y() - topInset);
+ } else {
+ // ICCCM 4.1.5 states that a real ConfigureNotify will be sent when
+ // a window is resized but the client can not tell if the window was
+ // moved or not. The client should consider the position as unkown
+ // and use TranslateCoordinates to find the actual position.
+ //
+ // TODO this should be the default for every case.
+ switch (runningWM) {
+ case XWM.CDE_WM:
+ case XWM.MOTIF_WM:
+ case XWM.METACITY_WM:
+ case XWM.MUTTER_WM:
+ case XWM.SAWFISH_WM:
+ {
+ Point xlocation = queryXLocation();
+ if (log.isLoggable(PlatformLogger.Level.FINE)) {
+ log.fine("New X location: {0}", xlocation);
+ }
+ if (xlocation != null) {
+ newLocation = xlocation;
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ return newLocation;
+ }
+
/*
* Overridden to check if we need to update our GraphicsDevice/Config
* Added for 4934052.
*/
@Override
public void handleConfigureNotifyEvent(XEvent xev) {
- // TODO: We create an XConfigureEvent every time we override
- // handleConfigureNotify() - too many!
XConfigureEvent xe = xev.get_xconfigure();
+ /*
+ * Correct window location which could be wrong in some cases.
+ * See getNewLocation() for the details.
+ */
+ Point newLocation = getNewLocation(xe, 0, 0);
+ xe.set_x(newLocation.x);
+ xe.set_y(newLocation.y);
checkIfOnNewScreen(new Rectangle(xe.get_x(),
xe.get_y(),
xe.get_width(),