diff options
author | Sven Gothel <[email protected]> | 2014-01-04 17:15:04 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-01-04 17:15:04 +0100 |
commit | fcc0e7397bb6f3ceb1fe143667f8c59b5bf63874 (patch) | |
tree | fbb8225c6408cfe6bf17cccdfeafbc293d126e39 /src/test | |
parent | e3cf96249f4c722f8b2a7d0e052e19165cef171e (diff) |
Bug 935: NEWT PointerIcon: Refine Spec and Implementation / Fix OSX Crash and Issues
- Refine Display.PointerIcon: Complete type allowing re-creation
- Add associated Display reference
- Add used IOUtil.ClassResources reference
- Add isValid()/validate() methods for recreation
- Refine API doc
- Move Display.destroyPointerIcon(PointerIcon) -> PointerIcon.destroy()
- Move DisplayImpl.PointerIconImpl -> PointerIconImpl (own source file)
- Creation/Destruction and setting of PointerIcon happens on EDT
- DisplayImpl.shutdownAll() and Display.destroy() calls destroyAllPointerIconFromList
- WindowDriver.setPointerIconImpl: Validates PointerIconImpl (i.e. re-creates if required)
- Fix 'initial' window.setPointerIcon(..) before createNative(..),
tested w/ TestGearsES2NEWT
- OSX Native Code:
- Move mouse and pointer-state handling from NewtMacWindow -> NewtView class
to retain states (pointer handle, pointer visibility, etc) when reparenting.
Reparenting will move an exisiting NewtView into a new NewtMacWindow.
- Enable all mouse move events:
- NewtView::mouseEnter [nsWin makeFirstResponder: nsView];
- NewtView::mouseExited if( !mouseConfined ) { [nsView resignFirstResponder]; }
- NewtView::mouseMoved issued [myCurser set] if required, fixing
OSX issue not updating NSCursor properly.
- MacWindow:
- Test NewtMacWindow, NewtView and NSCursor handles before usage
- Fix DBG_PRINT(..) warnings
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java | 28 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java | 53 |
2 files changed, 68 insertions, 13 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index efec961de..8cc676291 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -85,6 +85,7 @@ public class TestGearsES2NEWT extends UITestCase { static boolean waitForKey = false; static boolean mouseVisible = true; static boolean mouseConfined = false; + static boolean setPointerIcon = false; static boolean showFPS = false; static int loops = 1; static boolean loop_shutdown = false; @@ -183,6 +184,10 @@ public class TestGearsES2NEWT extends UITestCase { } pointerIconOne = _pointerIconOne; } + if( setPointerIcon ) { + glWindow.setPointerIcon(pointerIconOne); + System.err.println("Set PointerIcon: "+glWindow.getPointerIcon()); + } glWindow.addKeyListener(new KeyAdapter() { @Override @@ -216,16 +221,6 @@ public class TestGearsES2NEWT extends UITestCase { System.err.println("[set alwaysontop post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); glWindow.setExclusiveContextThread(t); } }.start(); - } else if(e.getKeyChar()=='c') { - new Thread() { - public void run() { - final Thread t = glWindow.setExclusiveContextThread(null); - System.err.println("[set pointer-icon pre]"); - final PointerIcon currentPI = glWindow.getPointerIcon(); - glWindow.setPointerIcon( currentPI == pointerIconOne ? null : pointerIconOne); - System.err.println("[set pointer-icon post] "+currentPI+" -> "+glWindow.getPointerIcon()); - glWindow.setExclusiveContextThread(t); - } }.start(); } else if(e.getKeyChar()=='d') { new Thread() { public void run() { @@ -245,6 +240,16 @@ public class TestGearsES2NEWT extends UITestCase { System.err.println("[set position post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); glWindow.setExclusiveContextThread(t); } }.start(); + } else if(e.getKeyChar()=='c') { + new Thread() { + public void run() { + final Thread t = glWindow.setExclusiveContextThread(null); + System.err.println("[set pointer-icon pre]"); + final PointerIcon currentPI = glWindow.getPointerIcon(); + glWindow.setPointerIcon( currentPI == pointerIconOne ? null : pointerIconOne); + System.err.println("[set pointer-icon post] "+currentPI+" -> "+glWindow.getPointerIcon()); + glWindow.setExclusiveContextThread(t); + } }.start(); } else if(e.getKeyChar()=='i') { new Thread() { public void run() { @@ -482,6 +487,8 @@ public class TestGearsES2NEWT extends UITestCase { mouseVisible = false; } else if(args[i].equals("-mouseConfine")) { mouseConfined = true; + } else if(args[i].equals("-pointerIcon")) { + setPointerIcon = true; } else if(args[i].equals("-showFPS")) { showFPS = true; } else if(args[i].equals("-width")) { @@ -537,6 +544,7 @@ public class TestGearsES2NEWT extends UITestCase { System.err.println("pmvDirect "+(!pmvUseBackingArray)); System.err.println("mouseVisible "+mouseVisible); System.err.println("mouseConfined "+mouseConfined); + System.err.println("pointerIcon "+setPointerIcon); System.err.println("loops "+loops); System.err.println("loop shutdown "+loop_shutdown); System.err.println("forceES2 "+forceES2); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java index 189645d3d..69874df6b 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java @@ -31,6 +31,10 @@ import java.awt.Frame; import javax.media.nativewindow.util.InsetsImmutable; +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.awt.NewtCanvasAWT; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; @@ -42,6 +46,7 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { final NewtCanvasAWT newtCanvasAWT; final GLWindow glWindow; final QuitAdapter quitAdapter; + PointerIcon pointerIconTest = null; public NewtAWTReparentingKeyAdapter(Frame frame, NewtCanvasAWT newtCanvasAWT, GLWindow glWindow, QuitAdapter quitAdapter) { this.frame = frame; @@ -54,9 +59,7 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { if( !e.isPrintableKey() || e.isAutoRepeat() ) { return; } - if( e.getKeySymbol() == KeyEvent.VK_I ) { - System.err.println(glWindow); - } else if( e.getKeySymbol() == KeyEvent.VK_L ) { + if( e.getKeySymbol() == KeyEvent.VK_L ) { javax.media.nativewindow.util.Point p0 = newtCanvasAWT.getNativeWindow().getLocationOnScreen(null); javax.media.nativewindow.util.Point p1 = glWindow.getLocationOnScreen(null); System.err.println("NewtCanvasAWT position: "+p0+", "+p1); @@ -140,6 +143,50 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { quitAdapter.enable(true); } } }.start(); + } else if(e.getKeySymbol() == KeyEvent.VK_C ) { + 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 err) { + err.printStackTrace(); + } + } + new Thread() { + public void run() { + final Thread t = glWindow.setExclusiveContextThread(null); + 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()); + glWindow.setExclusiveContextThread(t); + } }.start(); + } else if( e.getKeySymbol() == KeyEvent.VK_I ) { + new Thread() { + public void run() { + final Thread t = glWindow.setExclusiveContextThread(null); + System.err.println("[set mouse visible pre]: "+glWindow.isPointerVisible()); + glWindow.setPointerVisible(!glWindow.isPointerVisible()); + System.err.println("[set mouse visible post]: "+glWindow.isPointerVisible()); + glWindow.setExclusiveContextThread(t); + } }.start(); + } else if(e.getKeySymbol() == KeyEvent.VK_J ) { + new Thread() { + public void run() { + final Thread t = glWindow.setExclusiveContextThread(null); + System.err.println("[set mouse confined pre]: "+glWindow.isPointerConfined()); + glWindow.confinePointer(!glWindow.isPointerConfined()); + System.err.println("[set mouse confined post]: "+glWindow.isPointerConfined()); + glWindow.setExclusiveContextThread(t); + } }.start(); + } else if(e.getKeySymbol() == KeyEvent.VK_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(); } } }
\ No newline at end of file |