Bug 582 - NewtCanvasAWT.setCursor doesn't retain the set cursor
Summary: NewtCanvasAWT.setCursor doesn't retain the set cursor
Status: RESOLVED INVALID
Alias: None
Product: Newt
Classification: JogAmp
Component: awt (show other bugs)
Version: 1
Hardware: pc_x86_64 windows
: --- normal
Assignee: Sven Gothel
URL:
Depends on:
Blocks:
 
Reported: 2012-05-07 22:24 CEST by William Bittle
Modified: 2012-05-14 14:53 CEST (History)
0 users

See Also:
Type: ---
SCM Refs:
Workaround: ---


Attachments
Not a junit test but illustrates the problem (4.49 KB, application/octet-stream)
2012-05-07 22:24 CEST, William Bittle
Details

Note You need to log in before you can comment on or make changes to this bug.
Description William Bittle 2012-05-07 22:24:46 CEST
Created attachment 347 [details]
Not a junit test but illustrates the problem

You can set the cursor on a NewtCanvasAWT class by the setCursor method.  This works great as long as the mouse is not moved.  If the mouse is moved, the cursor reverts to Cursor.getDefaultCursor().

The original problem was that the cursor flickered; from the set cursor to the default cursor.  This can be illustrated by un-commenting the time.start() on line 95.

So to review there are two problems (which I think are related):
1. The cursor reverts to the default cursor when the mouse moves when using NewtCanvasAWT
2. The cursor flickers if a swing timer is used to update anything else on the JFrame.

Platform(s):
Windows Vista (amd) or Windows 7 (intel) (both x86_64)
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b05)
Java HotSpot(TM) Client VM (build 20.6-b01, mixed mode, sharing)

Version Information:
Package: javax.media.opengl
Extension Name: javax.media.opengl
Specification Title: Java Bindings for OpenGL API Specification
Specification Vendor: JogAmp Community
Specification Version: 2.0
Implementation Title: Java Bindings for OpenGL Runtime Environment
Implementation Vendor: JogAmp Community
Implementation Vendor ID: com.jogamp
Implementation URL: http://jogamp.org/
Implementation Version: 2.0-b57-20120502
Implementation Branch: rc
Implementation Commit: 9ff0b0dafea2a03a915c97eb1513c39c27b6a7ae

Package: com.jogamp.newt
Extension Name: null
Specification Title: null
Specification Vendor: null
Specification Version: null
Implementation Title: null
Implementation Vendor: null
Implementation Vendor ID: null
Implementation URL: null
Implementation Version: null
Implementation Branch: null
Implementation Commit: null

Package: com.jogamp.common
Extension Name: com.jogamp.common
Specification Title: GlueGen Java Bindings Generator
Specification Vendor: JogAmp Community
Specification Version: 2.0
Implementation Title: GlueGen Run-Time
Implementation Vendor: JogAmp Community
Implementation Vendor ID: com.jogamp
Implementation URL: http://jogamp.org/
Implementation Version: 2.0-b43-20120502
Implementation Branch: rc
Implementation Commit: 4ce601b38ca8418eddbe8cca4d531e6161fae26b
Comment 1 Sven Gothel 2012-05-13 22:30:56 CEST
setCursor(..) is an AWT method / functionality and only works while the mouse cursor
is within it's native peer bounds.

Even thought NewtCanvasAWT is derived from AWT Canvas and hence an
AWT component allowing you to call AWT's setCursor(..),
it adds a native NEWT child to the AWT native peer.
The NEWT child is ontop of the AWT native peer and visible,
hiding the AWT one.

This implies that the AWT native peer cursor setting is inactive
so to speak while NEWT is ontop.

Pls use NEWT's setPointerVisible(..) pointer methods to make the cursor disappear.
Comment 2 William Bittle 2012-05-14 14:24:59 CEST
(In reply to comment #1)
> setCursor(..) is an AWT method / functionality and only works while the mouse
> cursor
> is within it's native peer bounds.
> 
> Even thought NewtCanvasAWT is derived from AWT Canvas and hence an
> AWT component allowing you to call AWT's setCursor(..),
> it adds a native NEWT child to the AWT native peer.
> The NEWT child is ontop of the AWT native peer and visible,
> hiding the AWT one.
> 
> This implies that the AWT native peer cursor setting is inactive
> so to speak while NEWT is ontop.
> 
> Pls use NEWT's setPointerVisible(..) pointer methods to make the cursor
> disappear.

To make sure it's clear, the problem here isn't that the cursor shouldn't be visible, but that it should be changed to another cursor (then changed back at some later point in time).

Are you suggesting something like this?:
1. setPointerVisible(false) to hide the cursor
2. render the cursor manually using a quad + texture that follows the cursor
3. then use setPointerVisible(true) when it should change back

William
Comment 3 Sven Gothel 2012-05-14 14:53:56 CEST
(In reply to comment #2)
> To make sure it's clear, the problem here isn't that the cursor shouldn't be
> visible, but that it should be changed to another cursor (then changed back at
> some later point in time).

Both are related to the native windowing toolkit's restriction 
of having a native child window (NEWT) opaque on top of the parent (NewtCanvasAWT).

Your use case goes a bit further, i.e. changing the mouse cursor 
instead of simply turning it off.
Since this feature is not [yet] implemented in NEWT
your 'workaround' as you describe below seems to be a good idea
where you render the cursor as a HUD above your geometry using OpenGL.

> 
> Are you suggesting something like this?:
> 1. setPointerVisible(false) to hide the cursor
> 2. render the cursor manually using a quad + texture that follows the cursor
> 3. then use setPointerVisible(true) when it should change back
> 

Due to NEWT's lack of changing the cursor .. this would be a workaround.

The missing NEWT feature is due to lack of time to properly 
impl. this feature for X11, Windows and OSX.
However, if you or somebody else is willing to do so - we are for sure
integrating it into NEWT.

> William

~Sven