--- old/modules/graphics/src/main/java/com/sun/glass/ui/monocle/MonocleApplication.java 2014-04-09 13:31:43.795522809 -0400 +++ new/modules/graphics/src/main/java/com/sun/glass/ui/monocle/MonocleApplication.java 2014-04-09 13:31:43.683578805 -0400 @@ -68,6 +68,8 @@ /** A running count of the numbers of devices with each device capability */ private int[] deviceFlags = new int[DEVICE_MAX + 1]; + private Thread shutdownHookThread; + private Runnable renderEndNotifier = new Runnable() { public void run() { platform.getScreen().swapBuffers(); @@ -104,6 +106,11 @@ } if (device.isRelative()) { deviceFlags[DEVICE_POINTER] += modifier; + if (deviceFlags[DEVICE_POINTER] >= 1 && added) { + staticCursor_setVisible(true); + } else if (deviceFlags[DEVICE_POINTER] < 1 && !added) { + staticCursor_setVisible(false); + } } if (device.isFullKeyboard()) { deviceFlags[DEVICE_PC_KEYBOARD] += modifier; @@ -119,6 +126,12 @@ Thread t = new Thread(runnableProcessor); setEventThread(t); t.start(); + shutdownHookThread = new Thread("Monocle shutdown hook") { + @Override public void run() { + platform.shutdown(); + } + }; + Runtime.getRuntime().addShutdownHook(shutdownHookThread); } @Override @@ -168,8 +181,11 @@ @Override protected void staticCursor_setVisible(boolean visible) { - NativeCursor cursor = NativePlatformFactory.getNativePlatform().getCursor(); - cursor.setVisibility(visible); + if ((visible && deviceFlags[DEVICE_POINTER] >= 1) || + (!visible && deviceFlags[DEVICE_POINTER] < 1)) { + NativeCursor cursor = NativePlatformFactory.getNativePlatform().getCursor(); + cursor.setVisibility(visible); + } } @Override @@ -350,6 +366,8 @@ @Override protected void finishTerminating() { + //if this method is getting called, we don't need the shutdown hook + Runtime.getRuntime().removeShutdownHook(shutdownHookThread); setEventThread(null); platform.shutdown(); super.finishTerminating();