Skip to content

Commit 580a2a9

Browse files
dellgreenJohan Vos
authored and
Johan Vos
committed
8087980: Add property to disable Monocle cursor
Reviewed-by: jvos
1 parent 3bbcbfb commit 580a2a9

File tree

8 files changed

+47
-9
lines changed

8 files changed

+47
-9
lines changed

modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/AndroidPlatform.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ protected InputDeviceRegistry createInputDeviceRegistry() {
3939

4040
@Override
4141
protected NativeCursor createCursor() {
42-
return new NullCursor();
42+
return logSelectedCursor(new NullCursor());
4343
}
4444

4545
@Override

modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/DispmanPlatform.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ class DispmanPlatform extends LinuxPlatform {
2929

3030
@Override
3131
protected NativeCursor createCursor() {
32-
return new DispmanCursor();
32+
final NativeCursor c = useCursor ? new DispmanCursor() : new NullCursor();
33+
return logSelectedCursor(c);
3334
}
3435

3536
@Override

modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/HeadlessPlatform.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected InputDeviceRegistry createInputDeviceRegistry() {
3636

3737
@Override
3838
protected NativeCursor createCursor() {
39-
return new NullCursor();
39+
return logSelectedCursor(new NullCursor());
4040
}
4141

4242
@Override

modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/LinuxPlatform.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ protected InputDeviceRegistry createInputDeviceRegistry() {
3939

4040
@Override
4141
protected NativeCursor createCursor() {
42-
return new SoftwareCursor();
42+
final NativeCursor c = useCursor ? new SoftwareCursor() : new NullCursor();
43+
return logSelectedCursor(c);
4344
}
4445

4546
@Override

modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/MX6Platform.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ class MX6Platform extends LinuxPlatform {
2929

3030
@Override
3131
protected NativeCursor createCursor() {
32-
return new MX6Cursor();
32+
final NativeCursor c = useCursor ? new MX6Cursor() : new NullCursor();
33+
return logSelectedCursor(c);
3334
}
3435

3536
@Override

modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/NativePlatform.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,33 @@
2525

2626
package com.sun.glass.ui.monocle;
2727

28+
import java.security.AccessController;
29+
import java.security.PrivilegedAction;
30+
import com.sun.javafx.logging.PlatformLogger;
31+
import com.sun.javafx.logging.PlatformLogger.Level;
32+
import com.sun.javafx.util.Logging;
33+
2834
/** Abstract of a platform on which JavaFX can run. */
2935
public abstract class NativePlatform {
3036

3137
private static InputDeviceRegistry inputDeviceRegistry;
3238
private final RunnableProcessor runnableProcessor;
39+
private final PlatformLogger logger = Logging.getJavaFXLogger();
40+
3341
private NativeCursor cursor;
3442
private NativeScreen screen;
3543
protected AcceleratedScreen accScreen;
3644

45+
46+
protected static final boolean useCursor =
47+
AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> {
48+
final String str =
49+
System.getProperty("monocle.cursor.enabled", "true");
50+
return "true".equalsIgnoreCase(str);
51+
});
52+
53+
54+
3755
protected NativePlatform() {
3856
runnableProcessor = new RunnableProcessor();
3957
}
@@ -129,4 +147,19 @@ public synchronized AcceleratedScreen getAcceleratedScreen(int[] attributes)
129147
return accScreen;
130148
}
131149

150+
151+
/**
152+
* Log the name of the supplied native cursor class if required.
153+
*
154+
* @param cursor the native cursor in use, null is permitted
155+
* @return the passed in cursor
156+
*/
157+
protected NativeCursor logSelectedCursor(final NativeCursor cursor) {
158+
if (logger.isLoggable(Level.FINE)) {
159+
final String name = cursor == null ? null : cursor.getClass().getSimpleName();
160+
logger.fine("Using native cursor: {0}", name);
161+
}
162+
return cursor;
163+
}
164+
132165
}

modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/OMAPPlatform.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ class OMAPPlatform extends LinuxPlatform {
2929

3030
@Override
3131
protected NativeCursor createCursor() {
32-
return new OMAPCursor();
32+
final NativeCursor c = useCursor ? new OMAPCursor() : new NullCursor();
33+
return logSelectedCursor(c);
3334
}
3435

3536
@Override

modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/X11Platform.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ protected InputDeviceRegistry createInputDeviceRegistry() {
6161
*/
6262
@Override
6363
protected NativeCursor createCursor() {
64-
if (x11Input) {
65-
return new X11Cursor();
64+
if (useCursor) {
65+
final NativeCursor c = x11Input ? new X11Cursor() : new X11WarpingCursor();
66+
return logSelectedCursor(c);
6667
} else {
67-
return new X11WarpingCursor();
68+
return logSelectedCursor(new NullCursor());
6869
}
6970
}
7071

0 commit comments

Comments
 (0)