diff options
author | Sven Gothel <[email protected]> | 2011-10-15 07:34:06 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-10-15 07:34:06 +0200 |
commit | 50dca7ef60f28711397d40d8daeb8a24dff41dc2 (patch) | |
tree | f9830fb69f82ffd6e162c462255f858a52914d0f /src/newt | |
parent | d7e47e58b5b33f3ead939d3c630ea13568dfe74c (diff) |
NEWT/Pointer Confined: Dispatch mouse move events before enabled; Only request-focus/warp-ptr if enabled
Dispatch mouse move events before enabled
- Allows user app listener to track to the new centered mouse position
before using the confined position. This is important for position change usage.
See simplified demo GearsES2
Only request-focus/warp-ptr if enabled
- No need to request focus and center mouse if leaving confinement
Demo GearsES2:
- No need to assume some position changes are erroneous (jumps)
due to confinement.
- Track unconfined mouse position, allowing confined navigation
to have the proper position change value
Diffstat (limited to 'src/newt')
-rw-r--r-- | src/newt/classes/jogamp/newt/WindowImpl.java | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index caa91fd7c..f0c351048 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -1358,12 +1358,21 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(this.pointerConfined != confine) { boolean setVal = 0 == getWindowHandle(); if(!setVal) { - requestFocus(); - warpPointer(width/2, height/2); + if(confine) { + requestFocus(); + warpPointer(width/2, height/2); + } setVal = confinePointerImpl(confine); + if(confine) { + // give time to deliver mouse movements w/o confinement, + // this allows user listener to sync previous position value to the new centered position + try { + Thread.sleep(3 * screen.getDisplay().getEDTUtil().getPollPeriod()); + } catch (InterruptedException e) { } + } } if(setVal) { - this.pointerConfined = confine; + this.pointerConfined = confine; } } } |