From 60fadc1e723eaae471d68e9b0b939dfe2ba6abfe Mon Sep 17 00:00:00 2001 From: gohai Date: Thu, 16 Feb 2017 11:54:19 +0100 Subject: Fix mouse button reporting in X11UnderlayTracker --- .../jogamp/newt/driver/x11/X11UnderlayTracker.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/newt/classes/jogamp') diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11UnderlayTracker.java b/src/newt/classes/jogamp/newt/driver/x11/X11UnderlayTracker.java index 1be6dcea8..f9987860d 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/X11UnderlayTracker.java +++ b/src/newt/classes/jogamp/newt/driver/x11/X11UnderlayTracker.java @@ -316,7 +316,7 @@ public class X11UnderlayTracker implements WindowListener, KeyListener, MouseLis if (underlayWindowMap.containsKey(s)) { WindowImpl overlayWindow = underlayWindowMap.get(s); overlayWindow.sendMouseEvent(MouseEvent.EVENT_MOUSE_CLICKED, 0, - e.getX(), e.getY(), (short) 0, 0); + e.getX(), e.getY(), e.getButton(), 0); } } @@ -327,7 +327,7 @@ public class X11UnderlayTracker implements WindowListener, KeyListener, MouseLis if (underlayWindowMap.containsKey(s)) { WindowImpl overlayWindow = underlayWindowMap.get(s); overlayWindow.sendMouseEvent(MouseEvent.EVENT_MOUSE_ENTERED, 0, - e.getX(), e.getY(), (short) 0, 0); + e.getX(), e.getY(), e.getButton(), 0); } } @@ -338,7 +338,7 @@ public class X11UnderlayTracker implements WindowListener, KeyListener, MouseLis if (underlayWindowMap.containsKey(s)) { WindowImpl overlayWindow = underlayWindowMap.get(s); overlayWindow.sendMouseEvent(MouseEvent.EVENT_MOUSE_EXITED, 0, - e.getX(), e.getY(), (short) 0, 0); + e.getX(), e.getY(), e.getButton(), 0); } } @@ -349,7 +349,7 @@ public class X11UnderlayTracker implements WindowListener, KeyListener, MouseLis if (underlayWindowMap.containsKey(s)) { WindowImpl overlayWindow = underlayWindowMap.get(s); overlayWindow.sendMouseEvent(MouseEvent.EVENT_MOUSE_PRESSED, 0, - e.getX(), e.getY(), (short) 0, 0); + e.getX(), e.getY(), e.getButton(), 0); } } @@ -360,7 +360,7 @@ public class X11UnderlayTracker implements WindowListener, KeyListener, MouseLis if (underlayWindowMap.containsKey(s)) { WindowImpl overlayWindow = underlayWindowMap.get(s); overlayWindow.sendMouseEvent(MouseEvent.EVENT_MOUSE_RELEASED, 0, - e.getX(), e.getY(), (short) 0, 0); + e.getX(), e.getY(), e.getButton(), 0); } } @@ -371,7 +371,7 @@ public class X11UnderlayTracker implements WindowListener, KeyListener, MouseLis if (underlayWindowMap.containsKey(s)) { WindowImpl overlayWindow = underlayWindowMap.get(s); overlayWindow.sendMouseEvent(MouseEvent.EVENT_MOUSE_MOVED, 0, - e.getX(), e.getY(), (short) 0, 0); + e.getX(), e.getY(), e.getButton(), 0); } } @@ -382,7 +382,7 @@ public class X11UnderlayTracker implements WindowListener, KeyListener, MouseLis if (underlayWindowMap.containsKey(s)) { WindowImpl overlayWindow = underlayWindowMap.get(s); overlayWindow.sendMouseEvent(MouseEvent.EVENT_MOUSE_DRAGGED, 0, - e.getX(), e.getY(), (short) 0, 0); + e.getX(), e.getY(), e.getButton(), 0); } } @@ -393,7 +393,7 @@ public class X11UnderlayTracker implements WindowListener, KeyListener, MouseLis if (underlayWindowMap.containsKey(s)) { WindowImpl overlayWindow = underlayWindowMap.get(s); overlayWindow.sendMouseEvent(MouseEvent.EVENT_MOUSE_WHEEL_MOVED, 0, - e.getX(), e.getY(), (short) 0, 0); + e.getX(), e.getY(), e.getButton(), 0); } } -- cgit v1.2.3 From 51d301875a65f511b6a9846fc3bf661e50a48a68 Mon Sep 17 00:00:00 2001 From: gohai Date: Sun, 5 Mar 2017 17:27:23 +0100 Subject: 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.) --- src/newt/classes/jogamp/newt/driver/x11/X11UnderlayTracker.java | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/newt/classes/jogamp') 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()); -- cgit v1.2.3