summaryrefslogtreecommitdiffstats
path: root/src/newt/classes/jogamp
diff options
context:
space:
mode:
authorgohai <[email protected]>2017-03-05 17:27:23 +0100
committergohai <[email protected]>2017-03-05 17:27:23 +0100
commit51d301875a65f511b6a9846fc3bf661e50a48a68 (patch)
treeba4eb3903d8960c6c3480cc08f4fb4a7231f2382 /src/newt/classes/jogamp
parent45cc13c4d68fb3137b741cbc39ea653c15db2f66 (diff)
Fix overlay/underlay position mismatch in X11UnderlayTracker with overscan enabled
With the overscan enabled by the Raspberry Pi firmware, which seems to be the default for some attached displays, the underlayWindow size will be e.g. 1888x1048 (retrieved from X11), whereas the overlayWindow size remains at 1920x1080 (retrieved from the Broadcom VC IV implementation). This causes the overlay window to be visually offset by a few pixels. Correct this by applying an offset when the two don't match. (Both displays are assumed to have the same center.)
Diffstat (limited to 'src/newt/classes/jogamp')
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/X11UnderlayTracker.java7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11UnderlayTracker.java b/src/newt/classes/jogamp/newt/driver/x11/X11UnderlayTracker.java
index 1be6dcea8..6bb5b9144 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/X11UnderlayTracker.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/X11UnderlayTracker.java
@@ -140,6 +140,13 @@ public class X11UnderlayTracker implements WindowListener, KeyListener, MouseLis
Point underlayOnScreen = new Point();
overlayWindow.getLocationOnScreen(overlayOnScreen);
underlayWindow.getLocationOnScreen(underlayOnScreen);
+ /*
+ * Apply an offset when the dimensions of over- and
+ * underlay don't match
+ */
+ int dx = (overlayWindow.getScreen().getWidth() - underlayWindow.getScreen().getWidth()) / 2;
+ int dy = (overlayWindow.getScreen().getHeight() - underlayWindow.getScreen().getHeight()) / 2;
+ underlayOnScreen.translate(dx, dy);
if(overlayOnScreen.getX()!=underlayOnScreen.getX() ||
overlayOnScreen.getY()!=underlayOnScreen.getY()) {
overlayWindow.setPosition(underlayOnScreen.getX(), underlayOnScreen.getY());