aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/classes/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-10-15 07:34:06 +0200
committerSven Gothel <[email protected]>2011-10-15 07:34:06 +0200
commit50dca7ef60f28711397d40d8daeb8a24dff41dc2 (patch)
treef9830fb69f82ffd6e162c462255f858a52914d0f /src/newt/classes/jogamp
parentd7e47e58b5b33f3ead939d3c630ea13568dfe74c (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/classes/jogamp')
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java15
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;
}
}
}