aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/classes/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-09-16 10:57:08 +0200
committerSven Gothel <[email protected]>2011-09-16 10:57:08 +0200
commit85f60adb5ae675af4bf81c0a7e69ec836aa50a4b (patch)
tree91c061440c427c321f6b530e4c559ae352c8133e /src/newt/classes/jogamp
parent01f0384825688335d1d639553f58fbb2d6f0f592 (diff)
waitForPosSize/createWindow: exclude 0/0, at creation wait for size as well
- 0/0 may result in -1/-1, which is impl. specific (X11), might get deleted if causes more harm than ham - waiting for size after creation is actually a good thing todo
Diffstat (limited to 'src/newt/classes/jogamp')
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java46
1 files changed, 9 insertions, 37 deletions
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 8bc6d01ac..dd8752613 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -258,14 +258,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
private boolean createNative() {
if(DEBUG_IMPLEMENTATION) {
System.err.println("Window.createNative() START ("+getThreadName()+", "+this+")");
- }
- final boolean userPos = 0<=x && 0<=y; // user has specified a position
-
+ }
if( null != parentWindow &&
NativeSurface.LOCK_SURFACE_NOT_READY >= parentWindow.lockSurface() ) {
throw new NativeWindowException("Parent surface lock: not ready: "+parentWindow);
}
- if( !userPos && ( isUndecorated() || null != parentWindow ) ) {
+ if( ( 0>x || 0>y ) && ( isUndecorated() || null != parentWindow ) ) {
// default child/undecorated window position is 0/0, if not set by user
x = 0; y = 0;
}
@@ -282,15 +280,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
screen.addScreenModeListener(screenModeListenerImpl);
setTitleImpl(title);
if(waitForVisible(true, false)) {
- if(userPos) {
- // fix req position about window decoration
- _x = Math.max(_x, insets.getLeftWidth());
- _y = Math.max(_y, insets.getTopHeight());
- // wait for user req position
- waitForPosSize(_x, _y, -1, -1, false, TIMEOUT_NATIVEWINDOW);
- } else {
- waitForAnyPos(false, TIMEOUT_NATIVEWINDOW);
- }
+ // fix req position about window decoration
+ _x = Math.max(_x, insets.getLeftWidth());
+ _y = Math.max(_y, insets.getTopHeight());
+ // wait for user req position
+ waitForPosSize(_x, _y, width, height, false, TIMEOUT_NATIVEWINDOW);
if(isFullscreen()) {
fullscreen = false;
FullScreenActionImpl fsa = new FullScreenActionImpl(true);
@@ -2213,8 +2207,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
private boolean waitForPosSize(int x, int y, int w, int h, boolean failFast, long timeOut) {
DisplayImpl display = (DisplayImpl) screen.getDisplay();
- final boolean wpos = x>=0 && y>=0;
- final boolean wsiz = w>0 && h>0;
+ final boolean wpos = 0<x && 0<y ; // 0/0 maybe be -1/-1 (at least X11)
+ final boolean wsiz = 0<w && 0<h;
boolean reached = false;
for(long sleep = timeOut; !reached && 0<sleep; sleep-=10 ) {
if( ( wpos && x==getX() && y==getY() || !wpos ) &&
@@ -2237,28 +2231,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
return reached;
}
- private boolean waitForAnyPos(boolean failFast, long timeOut) {
- DisplayImpl display = (DisplayImpl) screen.getDisplay();
- boolean reached = false;
- for(long sleep = timeOut; !reached && 0<sleep; sleep-=10 ) {
- if( 0<=getX() && 0<=getY() ) {
- reached = true;
- } else {
- display.dispatchMessagesNative(); // status up2date
- try { Thread.sleep(10); } catch (InterruptedException ie) {}
- }
- }
- if(!reached) {
- final String msg = "Any Pos not reached as requested within "+timeOut+"ms : is "+getX()+"/"+getY();
- if(failFast) {
- throw new NativeWindowException(msg);
- } else if (DEBUG_IMPLEMENTATION) {
- System.err.println(msg);
- }
- }
- return reached;
- }
-
/** Triggered by implementation's WM events to update the position. */
protected void positionChanged(int newX, int newY) {
if ( x != newX || y != newY ) {