aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2019-11-30 08:20:29 +0100
committerSven Gothel <[email protected]>2019-11-30 08:20:29 +0100
commit94dbf9b151bfa8590ea223f58dfe43d45dc0783d (patch)
treeddd03bdab0567768307ab3d740c60e0819604eec /src/newt
parent453f80e38bcb0945e7eac27a5917dce9bdc6446b (diff)
Bug 1156: LinuxKeyEventTracker, LinuxMouseTracker: Robostness (+NEWT fix)
commit 453f80e38bcb0945e7eac27a5917dce9bdc6446b added disabling the tracker, however the NEWT usage didn't cover all mouse tracker null pointer. Further, let's initialize and spawn off the threads only at first getSingleton() call not at class initialization earlier.
Diffstat (limited to 'src/newt')
-rw-r--r--src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java6
-rw-r--r--src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java30
-rw-r--r--src/newt/classes/jogamp/newt/driver/egl/gbm/ScreenDriver.java6
-rw-r--r--src/newt/classes/jogamp/newt/driver/egl/gbm/WindowDriver.java12
-rw-r--r--src/newt/classes/jogamp/newt/driver/linux/LinuxKeyEventTracker.java28
-rw-r--r--src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java24
6 files changed, 65 insertions, 41 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java
index d4af1b972..5e1e61407 100644
--- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java
@@ -108,7 +108,11 @@ public class DisplayDriver extends DisplayImpl {
}
if( null != defaultPointerIcon ) {
final LinuxMouseTracker lmt = LinuxMouseTracker.getSingleton();
- setPointerIconActive(defaultPointerIcon.getHandle(), lmt.getLastX(), lmt.getLastY());
+ if( null != lmt ) {
+ setPointerIconActive(defaultPointerIcon.getHandle(), lmt.getLastX(), lmt.getLastY());
+ } else {
+ setPointerIconActive(defaultPointerIcon.getHandle(), 0, 0);
+ }
}
}
private PointerIconImpl defaultPointerIcon = null;
diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java
index 31b1d7087..e12b033cc 100644
--- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java
@@ -210,9 +210,12 @@ public class WindowDriver extends WindowImpl {
}
windowHandleClose = nativeWindowHandle;
- addWindowListener(keyTracker);
- addWindowListener(mouseTracker);
-
+ if( null != keyTracker ) {
+ addWindowListener(keyTracker);
+ }
+ if( null != mouseTracker ) {
+ addWindowListener(mouseTracker);
+ }
focusChanged(false, true);
}
@@ -222,9 +225,12 @@ public class WindowDriver extends WindowImpl {
final DisplayDriver display = (DisplayDriver) getScreen().getDisplay();
final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) getGraphicsConfiguration().getScreen().getDevice();
- removeWindowListener(mouseTracker);
- removeWindowListener(keyTracker);
-
+ if( null != mouseTracker ) {
+ removeWindowListener(mouseTracker);
+ }
+ if( null != keyTracker ) {
+ removeWindowListener(keyTracker);
+ }
if(0!=windowHandleClose) {
CloseWindow0(display.getBCMHandle(), windowHandleClose);
}
@@ -285,13 +291,21 @@ public class WindowDriver extends WindowImpl {
@Override
protected void setPointerIconImpl(final PointerIconImpl pi) {
final DisplayDriver display = (DisplayDriver) getScreen().getDisplay();
- display.setPointerIconActive(null != pi ? pi.validatedHandle() : 0, mouseTracker.getLastX(), mouseTracker.getLastY());
+ if( null != mouseTracker ) {
+ display.setPointerIconActive(null != pi ? pi.validatedHandle() : 0, mouseTracker.getLastX(), mouseTracker.getLastY());
+ } else {
+ display.setPointerIconActive(null != pi ? pi.validatedHandle() : 0, 0, 0);
+ }
}
@Override
protected boolean setPointerVisibleImpl(final boolean pointerVisible) {
final DisplayDriver display = (DisplayDriver) getScreen().getDisplay();
- display.setActivePointerIconVisible(pointerVisible, mouseTracker.getLastX(), mouseTracker.getLastY());
+ if( null != mouseTracker ) {
+ display.setActivePointerIconVisible(pointerVisible, mouseTracker.getLastX(), mouseTracker.getLastY());
+ } else {
+ display.setActivePointerIconVisible(pointerVisible, 0, 0);
+ }
return true;
}
diff --git a/src/newt/classes/jogamp/newt/driver/egl/gbm/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/egl/gbm/ScreenDriver.java
index 77ec3ce1a..82f13f6d6 100644
--- a/src/newt/classes/jogamp/newt/driver/egl/gbm/ScreenDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/egl/gbm/ScreenDriver.java
@@ -120,7 +120,11 @@ public class ScreenDriver extends ScreenImpl {
crtc_ids = new int[] { encoder[scridx].getCrtc_id() };
if( null != defaultPointerIcon ) {
final LinuxMouseTracker lmt = LinuxMouseTracker.getSingleton();
- setPointerIconActive(defaultPointerIcon.getHandle(), lmt.getLastX(), lmt.getLastY());
+ if( null != lmt ) {
+ setPointerIconActive(defaultPointerIcon.getHandle(), lmt.getLastX(), lmt.getLastY());
+ } else {
+ setPointerIconActive(defaultPointerIcon.getHandle(), 0, 0);
+ }
}
}
diff --git a/src/newt/classes/jogamp/newt/driver/egl/gbm/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/egl/gbm/WindowDriver.java
index de09ba6e3..b5985c66c 100644
--- a/src/newt/classes/jogamp/newt/driver/egl/gbm/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/egl/gbm/WindowDriver.java
@@ -347,13 +347,21 @@ public class WindowDriver extends WindowImpl {
@Override
protected void setPointerIconImpl(final PointerIconImpl pi) {
final ScreenDriver screen = (ScreenDriver) getScreen();
- screen.setPointerIconActive(null != pi ? pi.validatedHandle() : 0, mouseTracker.getLastX(), mouseTracker.getLastY());
+ if( null != mouseTracker ) {
+ screen.setPointerIconActive(null != pi ? pi.validatedHandle() : 0, mouseTracker.getLastX(), mouseTracker.getLastY());
+ } else {
+ screen.setPointerIconActive(null != pi ? pi.validatedHandle() : 0, 0, 0);
+ }
}
@Override
protected boolean setPointerVisibleImpl(final boolean pointerVisible) {
final ScreenDriver screen = (ScreenDriver) getScreen();
- screen.setActivePointerIconVisible(pointerVisible, mouseTracker.getLastX(), mouseTracker.getLastY());
+ if( null != mouseTracker ) {
+ screen.setActivePointerIconVisible(pointerVisible, mouseTracker.getLastX(), mouseTracker.getLastY());
+ } else {
+ screen.setActivePointerIconVisible(pointerVisible, 0, 0);
+ }
return true;
}
diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxKeyEventTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxKeyEventTracker.java
index b6503c1ed..8265ec7f8 100644
--- a/src/newt/classes/jogamp/newt/driver/linux/LinuxKeyEventTracker.java
+++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxKeyEventTracker.java
@@ -82,30 +82,24 @@ import com.jogamp.newt.event.KeyEvent;
*/
public class LinuxKeyEventTracker implements WindowListener, KeyTracker {
- private static final boolean DISABLE;
- private static final boolean ENABLE_PLAIN_EVENTX;
+ private static final boolean DISABLE = PropertyAccess.isPropertyDefined("newt.disable.LinuxKeyEventTracker", true);
+ private static final boolean ENABLE_PLAIN_EVENTX = PropertyAccess.isPropertyDefined("newt.enable.LinuxKeyEventTracker.eventx", true);
private static final String linuxDevInputByEventXRoot = "/dev/input/";
private static final String linuxDevInputByIDRoot = "/dev/input/by-id/";
private static final String linuxDevInputByPathRoot = "/dev/input/by-path/";
- private static final LinuxKeyEventTracker ledt;
-
- static {
- DISABLE = PropertyAccess.isPropertyDefined("newt.disable.LinuxKeyEventTracker", true);
- ENABLE_PLAIN_EVENTX = PropertyAccess.isPropertyDefined("newt.enable.LinuxKeyEventTracker.eventx", true);
+ private static LinuxKeyEventTracker ledt = null;
+ public static synchronized LinuxKeyEventTracker getSingleton() {
if( !DISABLE ) {
- ledt = new LinuxKeyEventTracker();
- final Thread t = new InterruptSource.Thread(null, ledt.eventDeviceManager, "NEWT-LinuxEventDeviceManager");
- t.setDaemon(true);
- t.start();
- } else {
- ledt = null;
+ if( null == ledt ) {
+ ledt = new LinuxKeyEventTracker();
+ final Thread t = new InterruptSource.Thread(null, ledt.eventDeviceManager, "NEWT-LinuxEventDeviceManager");
+ t.setDaemon(true);
+ t.start();
+ }
}
- }
-
- public static LinuxKeyEventTracker getSingleton() {
return ledt;
}
@@ -124,6 +118,8 @@ public class LinuxKeyEventTracker implements WindowListener, KeyTracker {
*/
private final Map<String, EventDevicePoller> edpMap = new HashMap<String, EventDevicePoller>();
+ private LinuxKeyEventTracker() {}
+
@Override
public void windowResized(final WindowEvent e) { }
diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java
index c49defe11..4f9bce88e 100644
--- a/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java
+++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java
@@ -57,22 +57,18 @@ import com.jogamp.newt.event.WindowUpdateEvent;
*/
public class LinuxMouseTracker implements WindowListener, MouseTracker {
- private static final boolean DISABLE;
- private static final LinuxMouseTracker lmt;
+ private static final boolean DISABLE = PropertyAccess.isPropertyDefined("newt.disable.LinuxMouseTracker", true);
+ private static LinuxMouseTracker lmt = null;
- static {
- DISABLE = PropertyAccess.isPropertyDefined("newt.disable.LinuxMouseTracker", true);
+ public static synchronized LinuxMouseTracker getSingleton() {
if(!DISABLE) {
- lmt = new LinuxMouseTracker();
- final Thread t = new InterruptSource.Thread(null, lmt.mouseDevicePoller, "NEWT-MouseTracker");
- t.setDaemon(true);
- t.start();
- } else {
- lmt = null;
+ if( null == lmt ) {
+ lmt = new LinuxMouseTracker();
+ final Thread t = new InterruptSource.Thread(null, lmt.mouseDevicePoller, "NEWT-MouseTracker");
+ t.setDaemon(true);
+ t.start();
+ }
}
- }
-
- public static LinuxMouseTracker getSingleton() {
return lmt;
}
@@ -88,6 +84,8 @@ public class LinuxMouseTracker implements WindowListener, MouseTracker {
private WindowImpl focusedWindow = null;
private final MouseDevicePoller mouseDevicePoller = new MouseDevicePoller();
+ private LinuxMouseTracker() {}
+
public final int getLastX() { return lastFocusedX; }
public final int getLastY() { return lastFocusedY; }