From d8b3e369cf5365d09853db20b817cda7553b9a48 Mon Sep 17 00:00:00 2001
From: Sven Gothel
Date: Tue, 31 Dec 2013 08:40:48 +0100
Subject: Bug 935: NEWT: Expose Pointer Icons Feature in JOGLNewtAppletBase
Tests
---
...nner-newt-ElektronenMultiplizierer-napplet.html | 3 +
...pplet-runner-newt-ElektronenMultiplizierer.html | 3 +
...let-runner-newt-GraphUISceneDemo01-napplet.html | 3 +
...jogl-applet-runner-newt-GraphUISceneDemo01.html | 3 +
.../jogl-applet-runner-newt-MovieCube-napplet.html | 3 +
jnlp-files/jogl-applet-runner-newt-MovieCube.html | 3 +
.../jogl-applet-runner-newt-gears-gl3-napplet.html | 3 +
...plet-runner-newt-gears-normal-launcheronly.html | 3 +
...gl-applet-runner-newt-gears-normal-napplet.html | 3 +
...l-applet-runner-newt-gears-normal-napplet2.html | 3 +
.../jogl-applet-runner-newt-gears-normal.html | 3 +
...l-applet-runner-newt-gears-special-napplet.html | 3 +
.../jogl-applet-runner-newt-gears-special.html | 3 +
.../jogamp/newt/awt/applet/JOGLNewtAppletBase.java | 85 +++++++++++++++++-----
14 files changed, 105 insertions(+), 19 deletions(-)
diff --git a/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer-napplet.html b/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer-napplet.html
index 19a3b2965..a989f7f09 100644
--- a/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer-napplet.html
+++ b/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer-napplet.html
@@ -58,6 +58,9 @@ JOGL NEWT JNLP Applet Runner Special Keys:
f - toggle fullscreen
r - in/out browser window
a - on/off always-on-top
+ c - change mouse pointer
+ i - invisible mouse pointer
+ w - warp mouse pointer to center
diff --git a/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer.html b/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer.html
index 71c9baff8..83131585a 100644
--- a/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer.html
+++ b/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer.html
@@ -75,6 +75,9 @@ JOGL NEWT JNLP Applet Runner Special Keys:
f - toggle fullscreen
r - in/out browser window
a - on/off always-on-top
+ c - change mouse pointer
+ i - invisible mouse pointer
+ w - warp mouse pointer to center
diff --git a/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01-napplet.html b/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01-napplet.html
index 8f9783f03..a22d8f26c 100644
--- a/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01-napplet.html
+++ b/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01-napplet.html
@@ -60,6 +60,9 @@ JOGL NEWT JNLP Applet Runner Special Keys:
f - toggle fullscreen
r - in/out browser window
a - on/off always-on-top
+ c - change mouse pointer
+ i - invisible mouse pointer
+ w - warp mouse pointer to center
diff --git a/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01.html b/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01.html
index 429e80311..0f050a98d 100644
--- a/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01.html
+++ b/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01.html
@@ -78,6 +78,9 @@ JOGL NEWT JNLP Applet Runner Special Keys:
f - toggle fullscreen
r - in/out browser window
a - on/off always-on-top
+ c - change mouse pointer
+ i - invisible mouse pointer
+ w - warp mouse pointer to center
diff --git a/jnlp-files/jogl-applet-runner-newt-MovieCube-napplet.html b/jnlp-files/jogl-applet-runner-newt-MovieCube-napplet.html
index 5dc77f024..242efa6fd 100644
--- a/jnlp-files/jogl-applet-runner-newt-MovieCube-napplet.html
+++ b/jnlp-files/jogl-applet-runner-newt-MovieCube-napplet.html
@@ -72,6 +72,9 @@ JOGL NEWT JNLP Applet Runner Special Keys:
f - toggle fullscreen
r - in/out browser window
a - on/off always-on-top
+ c - change mouse pointer
+ i - invisible mouse pointer
+ w - warp mouse pointer to center
diff --git a/jnlp-files/jogl-applet-runner-newt-MovieCube.html b/jnlp-files/jogl-applet-runner-newt-MovieCube.html
index a154eb825..bb61fc143 100644
--- a/jnlp-files/jogl-applet-runner-newt-MovieCube.html
+++ b/jnlp-files/jogl-applet-runner-newt-MovieCube.html
@@ -89,6 +89,9 @@ JOGL NEWT JNLP Applet Runner Special Keys:
f - toggle fullscreen
r - in/out browser window
a - on/off always-on-top
+ c - change mouse pointer
+ i - invisible mouse pointer
+ w - warp mouse pointer to center
diff --git a/jnlp-files/jogl-applet-runner-newt-gears-gl3-napplet.html b/jnlp-files/jogl-applet-runner-newt-gears-gl3-napplet.html
index cb2375e4c..9dd3806f1 100644
--- a/jnlp-files/jogl-applet-runner-newt-gears-gl3-napplet.html
+++ b/jnlp-files/jogl-applet-runner-newt-gears-gl3-napplet.html
@@ -12,6 +12,9 @@ JOGL NEWT Applet Runner Special Keys:
f - toggle fullscreen
r - in/out browser window
a - on/off always-on-top
+ c - change mouse pointer
+ i - invisible mouse pointer
+ w - warp mouse pointer to center
diff --git a/jnlp-files/jogl-applet-runner-newt-gears-normal-launcheronly.html b/jnlp-files/jogl-applet-runner-newt-gears-normal-launcheronly.html
index a9e42d342..328228146 100644
--- a/jnlp-files/jogl-applet-runner-newt-gears-normal-launcheronly.html
+++ b/jnlp-files/jogl-applet-runner-newt-gears-normal-launcheronly.html
@@ -12,6 +12,9 @@ JOGL NEWT JNLP Applet Runner Special Keys:
f - toggle fullscreen
r - in/out browser window
a - on/off always-on-top
+ c - change mouse pointer
+ i - invisible mouse pointer
+ w - warp mouse pointer to center
diff --git a/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet.html b/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet.html
index 9b448394d..e1e9593de 100644
--- a/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet.html
+++ b/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet.html
@@ -12,6 +12,9 @@ JOGL NEWT Applet Runner Special Keys:
f - toggle fullscreen
r - in/out browser window
a - on/off always-on-top
+ c - change mouse pointer
+ i - invisible mouse pointer
+ w - warp mouse pointer to center
diff --git a/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet2.html b/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet2.html
index 8970aea53..09c5f4b47 100644
--- a/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet2.html
+++ b/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet2.html
@@ -12,6 +12,9 @@ JOGL NEWT Applet Runner Special Keys:
f - toggle fullscreen
r - in/out browser window
a - on/off always-on-top
+ c - change mouse pointer
+ i - invisible mouse pointer
+ w - warp mouse pointer to center
If Applet is out of browser window, it is closeable.
diff --git a/jnlp-files/jogl-applet-runner-newt-gears-normal.html b/jnlp-files/jogl-applet-runner-newt-gears-normal.html
index a6dd16a0c..310e659ba 100644
--- a/jnlp-files/jogl-applet-runner-newt-gears-normal.html
+++ b/jnlp-files/jogl-applet-runner-newt-gears-normal.html
@@ -26,6 +26,9 @@ JOGL NEWT JNLP Applet Runner Special Keys:
f - toggle fullscreen
r - in/out browser window
a - on/off always-on-top
+ c - change mouse pointer
+ i - invisible mouse pointer
+ w - warp mouse pointer to center
diff --git a/jnlp-files/jogl-applet-runner-newt-gears-special-napplet.html b/jnlp-files/jogl-applet-runner-newt-gears-special-napplet.html
index 7df167844..bb27fde68 100644
--- a/jnlp-files/jogl-applet-runner-newt-gears-special-napplet.html
+++ b/jnlp-files/jogl-applet-runner-newt-gears-special-napplet.html
@@ -57,6 +57,9 @@ JOGL NEWT JNLP Applet Runner Special Keys:
f - toggle fullscreen
r - in/out browser window
a - on/off always-on-top
+ c - change mouse pointer
+ i - invisible mouse pointer
+ w - warp mouse pointer to center
Normal webpage text - Normal webpage text - Normal webpage text - Normal webpage text
Normal webpage text - Normal webpage text - Normal webpage text - Normal webpage text
diff --git a/jnlp-files/jogl-applet-runner-newt-gears-special.html b/jnlp-files/jogl-applet-runner-newt-gears-special.html
index 0f5911414..01f37d6c7 100644
--- a/jnlp-files/jogl-applet-runner-newt-gears-special.html
+++ b/jnlp-files/jogl-applet-runner-newt-gears-special.html
@@ -75,6 +75,9 @@ JOGL NEWT JNLP Applet Runner Special Keys:
f - toggle fullscreen
r - in/out browser window
a - on/off always-on-top
+ c - change mouse pointer
+ i - invisible mouse pointer
+ w - warp mouse pointer to center
Normal webpage text - Normal webpage text - Normal webpage text - Normal webpage text
Normal webpage text - Normal webpage text - Normal webpage text - Normal webpage text
diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java
index e6571d21a..eac328cdd 100644
--- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java
+++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java
@@ -42,7 +42,10 @@ import javax.media.opengl.GLPipelineFactory;
import jogamp.newt.Debug;
+import com.jogamp.common.util.IOUtil;
+import com.jogamp.newt.Display;
import com.jogamp.newt.Window;
+import com.jogamp.newt.Display.PointerIcon;
import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.event.KeyListener;
import com.jogamp.newt.event.MouseListener;
@@ -65,6 +68,7 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener {
boolean glClosable;
boolean glDebug;
boolean glTrace;
+ PointerIcon pointerIconTest = null;
GLEventListener glEventListener = null;
GLWindow glWindow = null;
@@ -230,6 +234,15 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener {
if(isValid) {
glWindow.setVisible(true);
glWindow.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
+ if( null == pointerIconTest ) {
+ final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/jogamp-32x32.png" } );
+ final Display disp = glWindow.getScreen().getDisplay();
+ try {
+ pointerIconTest = disp.createPointerIcon(res, 16, 0);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
glAnimator.start();
awtParent = glWindow.getParent();
glWindow.addWindowListener(reparentHomeListener);
@@ -302,28 +315,62 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener {
return;
}
if(e.getKeyChar()=='d') {
- glWindow.setUndecorated(!glWindow.isUndecorated());
+ new Thread() {
+ public void run() {
+ glWindow.setUndecorated(!glWindow.isUndecorated());
+ } }.start();
} if(e.getKeyChar()=='f') {
- glWindow.setFullscreen(!glWindow.isFullscreen());
+ new Thread() {
+ public void run() {
+ glWindow.setFullscreen(!glWindow.isFullscreen());
+ } }.start();
} else if(e.getKeyChar()=='a') {
- glWindow.setAlwaysOnTop(!glWindow.isAlwaysOnTop());
+ new Thread() {
+ public void run() {
+ glWindow.setAlwaysOnTop(!glWindow.isAlwaysOnTop());
+ } }.start();
} else if(e.getKeyChar()=='r' && null!=awtParent) {
- if(null == glWindow.getParent()) {
- glWindow.reparentWindow(awtParent, -1, -1, 0 /* hints */);
- } else {
- final InsetsImmutable insets = glWindow.getInsets();
- final int x, y;
- if ( 0 >= insets.getTopHeight() ) {
- // fail safe ..
- x = 32;
- y = 32;
- } else {
- x = insets.getLeftWidth();
- y = insets.getTopHeight();
- }
- glWindow.reparentWindow(null, x, y, 0 /* hints */);
- glWindow.setDefaultCloseOperation( glClosable ? WindowClosingMode.DISPOSE_ON_CLOSE : WindowClosingMode.DO_NOTHING_ON_CLOSE );
- }
+ new Thread() {
+ public void run() {
+ if(null == glWindow.getParent()) {
+ glWindow.reparentWindow(awtParent, -1, -1, 0 /* hints */);
+ } else {
+ final InsetsImmutable insets = glWindow.getInsets();
+ final int x, y;
+ if ( 0 >= insets.getTopHeight() ) {
+ // fail safe ..
+ x = 32;
+ y = 32;
+ } else {
+ x = insets.getLeftWidth();
+ y = insets.getTopHeight();
+ }
+ glWindow.reparentWindow(null, x, y, 0 /* hints */);
+ glWindow.setDefaultCloseOperation( glClosable ? WindowClosingMode.DISPOSE_ON_CLOSE : WindowClosingMode.DO_NOTHING_ON_CLOSE );
+ }
+ } }.start();
+ } else if(e.getKeyChar()=='c') {
+ new Thread() {
+ public void run() {
+ System.err.println("[set pointer-icon pre]");
+ final PointerIcon currentPI = glWindow.getPointerIcon();
+ glWindow.setPointerIcon( currentPI == pointerIconTest ? null : pointerIconTest);
+ System.err.println("[set pointer-icon post] "+currentPI+" -> "+glWindow.getPointerIcon());
+ } }.start();
+ } else if(e.getKeyChar()=='i') {
+ new Thread() {
+ public void run() {
+ System.err.println("[set mouse visible pre]: "+glWindow.isPointerVisible());
+ glWindow.setPointerVisible(!glWindow.isPointerVisible());
+ System.err.println("[set mouse visible post]: "+glWindow.isPointerVisible());
+ } }.start();
+ } else if(e.getKeyChar()=='w') {
+ new Thread() {
+ public void run() {
+ System.err.println("[set mouse pos pre]");
+ glWindow.warpPointer(glWindow.getWidth()/2, glWindow.getHeight()/2);
+ System.err.println("[set mouse pos post]");
+ } }.start();
}
}
--
cgit v1.2.3