aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-01-18 23:08:30 +0100
committerSven Gothel <[email protected]>2012-01-18 23:08:30 +0100
commit319fdccb670743daa6c27e247591baf1f254e5ac (patch)
tree73a8e9773f1be547cb341925e36665c7276e8afd /src/newt
parentbc933c6e18a68d9cd94b0349fb516852ac0c7457 (diff)
NEWT: Use accessors to read/write postion and size, allowing better trace and controlling autoPosition; Restrict more fields to private where possible.
WindowImpl's position and size is made private and accessed by it's getter and setter (definePosition/defineSize). This allows better tracing of value changes and ensures autoPosition is set to false.
Diffstat (limited to 'src/newt')
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java173
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java19
-rw-r--r--src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java23
-rw-r--r--src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java12
-rw-r--r--src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java8
-rw-r--r--src/newt/classes/jogamp/newt/driver/kd/KDWindow.java9
-rw-r--r--src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java6
-rw-r--r--src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java4
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/X11Window.java2
9 files changed, 124 insertions, 132 deletions
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 3d7b8ec1c..29056ee04 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -93,17 +93,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
private AbstractGraphicsConfiguration config = null; // control access due to delegation
protected CapabilitiesImmutable capsRequested = null;
protected CapabilitiesChooser capabilitiesChooser = null; // default null -> default
- protected boolean fullscreen = false, hasFocus = false;
- protected int width = 128, height = 128; // client-area size w/o insets, default: may be overwritten by user
- protected int x = 64, y = 64; // client-area pos w/o insets
- protected boolean autoPosition = true; // default: true (allow WM to choose top-level position, if not set by user)
- protected Insets insets = new Insets(); // insets of decoration (if top-level && decorated)
+ private boolean fullscreen = false, hasFocus = false;
+ private int width = 128, height = 128; // client-area size w/o insets, default: may be overwritten by user
+ private int x = 64, y = 64; // client-area pos w/o insets
+ private boolean autoPosition = true; // default: true (allow WM to choose top-level position, if not set by user)
+ private Insets insets = new Insets(); // insets of decoration (if top-level && decorated)
- protected int nfs_width, nfs_height, nfs_x, nfs_y; // non fullscreen client-area size/pos w/o insets
- protected NativeWindow nfs_parent = null; // non fullscreen parent, in case explicit reparenting is performed (offscreen)
- protected String title = "Newt Window";
- protected boolean undecorated = false;
- protected boolean alwaysOnTop = false;
+ private int nfs_width, nfs_height, nfs_x, nfs_y; // non fullscreen client-area size/pos w/o insets
+ private NativeWindow nfs_parent = null; // non fullscreen parent, in case explicit reparenting is performed (offscreen)
+ private String title = "Newt Window";
+ private boolean undecorated = false;
+ private boolean alwaysOnTop = false;
private boolean pointerVisible = true;
private boolean pointerConfined = false;
private LifecycleHook lifecycleHook = null;
@@ -125,8 +125,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
private int mouseButtonPressed = 0; // current pressed mouse button number
private long lastMousePressed = 0; // last time when a mouse button was pressed
private int lastMouseClickCount = 0; // last mouse button click count
- protected boolean mouseInWindow = false;// mouse entered window - is inside the window (may be synthetic)
- protected Point lastMousePosition = new Point();
+ private boolean mouseInWindow = false;// mouse entered window - is inside the window (may be synthetic)
+ private Point lastMousePosition = new Point();
private ArrayList<KeyListener> keyListeners = new ArrayList<KeyListener>();
@@ -279,16 +279,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
if( null != parentWindow &&
NativeSurface.LOCK_SURFACE_NOT_READY >= parentWindow.lockSurface() ) {
throw new NativeWindowException("Parent surface lock: not ready: "+parentWindow);
- }
- if(null != parentWindow ) {
- if( autoPosition ) {
- // child position default to 0/0, no auto position
- x = 0; y = 0;
- autoPosition = false;
- } else if( 0>x || 0>y ) {
- // min. child window position is 0/0
- x = 0; y = 0;
- }
+ }
+
+ // child window: position defaults to 0/0, no auto position, no negative position
+ if( null != parentWindow && ( autoPosition || 0>getX() || 0>getY() ) ) {
+ definePosition(0, 0);
}
try {
if(validateParentWindowHandle()) {
@@ -727,7 +722,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
}
if(!isNativeValid() && visible) {
- if( 0<width*height ) {
+ if( 0<getWidth()*getHeight() ) {
nativeWindowCreated = createNative();
madeVisible = nativeWindowCreated;
}
@@ -735,7 +730,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
WindowImpl.this.visible = true;
} else if(WindowImpl.this.visible != visible) {
if(isNativeValid()) {
- setVisibleImpl(visible, x, y, width, height);
+ setVisibleImpl(visible, getX(), getY(), getWidth(), getHeight());
WindowImpl.this.waitForVisible(visible, true);
madeVisible = visible;
}
@@ -756,7 +751,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
}
if(DEBUG_IMPLEMENTATION) {
- System.err.println("Window setVisible: END ("+getThreadName()+") "+x+"/"+y+" "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+WindowImpl.this.visible+", nativeWindowCreated: "+nativeWindowCreated+", madeVisible: "+madeVisible);
+ System.err.println("Window setVisible: END ("+getThreadName()+") "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+WindowImpl.this.visible+", nativeWindowCreated: "+nativeWindowCreated+", madeVisible: "+madeVisible);
}
} finally {
windowLock.unlock();
@@ -778,7 +773,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
public void setVisible(boolean visible) {
if(DEBUG_IMPLEMENTATION) {
- System.err.println("Window setVisible: START ("+getThreadName()+") "+x+"/"+y+" "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+this.visible+" -> "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+(null!=parentWindow));
+ System.err.println("Window setVisible: START ("+getThreadName()+") "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+this.visible+" -> "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+(null!=parentWindow));
Thread.dumpStack();
}
runOnEDTIfAvail(true, new VisibleAction(visible));
@@ -789,10 +784,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
windowLock.lock();
try {
int visibleAction = 0; // 1 invisible, 2 visible (create)
- if ( !fullscreen && ( width != WindowImpl.this.width || WindowImpl.this.height != height ) ) {
+ if ( !fullscreen && ( getWidth() != width || getHeight() != height ) ) {
recreate = isNativeValid() && !getGraphicsConfiguration().getChosenCapabilities().isOnscreen();
if(DEBUG_IMPLEMENTATION) {
- System.err.println("Window setSize: START "+WindowImpl.this.width+"x"+WindowImpl.this.height+" -> "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible "+visible+", recreate "+recreate);
+ System.err.println("Window setSize: START "+getWidth()+"x"+getHeight()+" -> "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible "+visible+", recreate "+recreate);
}
if(recreate) {
// will trigger visibleAction:=2 -> create if wasVisible
@@ -803,21 +798,18 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
if ( isNativeValid() && 0>=width*height && visible ) {
visibleAction=1; // invisible
- WindowImpl.this.width = 0;
- WindowImpl.this.height = 0;
+ defineSize(0, 0);
} else if ( !isNativeValid() && 0<width*height && visible ) {
visibleAction = 2; // visible (create)
- WindowImpl.this.width = width;
- WindowImpl.this.height = height;
+ defineSize(width, height);
} else if ( isNativeValid() ) {
// this width/height will be set by windowChanged, called by the native implementation
- reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(0, isVisible()));
+ reconfigureWindowImpl(getX(), getY(), width, height, getReconfigureFlags(0, isVisible()));
} else {
- WindowImpl.this.width = width;
- WindowImpl.this.height = height;
+ defineSize(width, height);
}
if(DEBUG_IMPLEMENTATION) {
- System.err.println("Window setSize: END "+WindowImpl.this.width+"x"+WindowImpl.this.height+", visibleAction "+visibleAction);
+ System.err.println("Window setSize: END "+getWidth()+"x"+getHeight()+", visibleAction "+visibleAction);
}
switch(visibleAction) {
case 1: setVisibleActionImpl(false); break;
@@ -990,10 +982,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
private void reparent() {
// mirror pos/size so native change notification can get overwritten
- int x = WindowImpl.this.x;
- int y = WindowImpl.this.y;
- int width = WindowImpl.this.width;
- int height = WindowImpl.this.height;
+ int x = getX();
+ int y = getY();
+ int width = getWidth();
+ int height = getHeight();
boolean wasVisible;
windowLock.lock();
@@ -1136,10 +1128,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
if( ACTION_NATIVE_CREATION_PENDING == reparentAction ) {
// make size and position persistent for proper recreation
- WindowImpl.this.x = x;
- WindowImpl.this.y = y;
- WindowImpl.this.width = width;
- WindowImpl.this.height = height;
+ definePosition(x, y);
+ defineSize(width, height);
return;
}
@@ -1197,10 +1187,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
if(!ok || !wasVisible) {
// make size and position persistent manual,
// since we don't have a WM feedback (invisible or recreation)
- WindowImpl.this.x = x;
- WindowImpl.this.y = y;
- WindowImpl.this.width = width;
- WindowImpl.this.height = height;
+ definePosition(x, y);
+ defineSize(width, height);
}
if(!ok) {
@@ -1298,10 +1286,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
// Change decoration on active window
// Mirror pos/size so native change notification can get overwritten
- final int x = WindowImpl.this.x;
- final int y = WindowImpl.this.y;
- final int width = WindowImpl.this.width;
- final int height = WindowImpl.this.height;
+ final int x = getX();
+ final int y = getY();
+ final int width = getWidth();
+ final int height = getHeight();
if( isNativeValid() ) {
DisplayImpl display = (DisplayImpl) screen.getDisplay();
@@ -1347,10 +1335,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
// Change decoration on active window
// Mirror pos/size so native change notification can get overwritten
- final int x = WindowImpl.this.x;
- final int y = WindowImpl.this.y;
- final int width = WindowImpl.this.width;
- final int height = WindowImpl.this.height;
+ final int x = getX();
+ final int y = getY();
+ final int width = getWidth();
+ final int height = getHeight();
if( isNativeValid() ) {
DisplayImpl display = (DisplayImpl) screen.getDisplay();
@@ -1412,7 +1400,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
if(!setVal) {
if(confine) {
requestFocus();
- warpPointer(width/2, height/2);
+ warpPointer(getWidth()/2, getHeight()/2);
}
setVal = confinePointerImpl(confine);
if(confine) {
@@ -1459,6 +1447,27 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
return y;
}
+ protected final boolean autoPosition() { return autoPosition; }
+
+ /** Sets the position fields {@link #x} and {@link #y} to the given values and {@link #autoPosition} to false. */
+ protected final void definePosition(int x, int y) {
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("definePosition: "+this.x+"/"+this.y+" -> "+x+"/"+y);
+ // Thread.dumpStack();
+ }
+ autoPosition = false;
+ this.x = x; this.y = y;
+ }
+
+ /** Sets the size fields {@link #width} and {@link #height} to the given values. */
+ protected final void defineSize(int width, int height) {
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("defineSize: "+this.width+"x"+this.height+" -> "+width+"x"+height);
+ // Thread.dumpStack();
+ }
+ this.width = width; this.height = height;
+ }
+
public final boolean isVisible() {
return visible;
}
@@ -1533,8 +1542,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
"\n, ParentWindowHandle "+toHexString(parentWindowHandle)+" ("+(0!=getParentWindowHandle())+")"+
"\n, WindowHandle "+toHexString(getWindowHandle())+
"\n, SurfaceHandle "+toHexString(getSurfaceHandle())+ " (lockedExt window "+isWindowLockedByOtherThread()+", surface "+isSurfaceLockedByOtherThread()+")"+
- "\n, Pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+
- "\n, Visible "+isVisible()+
+ "\n, Pos "+getX()+"/"+getY()+" (auto "+autoPosition()+"), size "+getWidth()+"x"+getHeight()+
+ "\n, Visible "+isVisible()+", focus "+hasFocus()+
"\n, Undecorated "+undecorated+" ("+isUndecorated()+")"+
"\n, AlwaysOnTop "+alwaysOnTop+", Fullscreen "+fullscreen+
"\n, WrappedWindow "+getWrappedWindow()+
@@ -1656,16 +1665,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
windowLock.lock();
try {
if(DEBUG_IMPLEMENTATION) {
- System.err.println("Window setPosition: "+WindowImpl.this.x+"/"+WindowImpl.this.y+" -> "+x+"/"+y+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle));
+ System.err.println("Window setPosition: "+getX()+"/"+getY()+" -> "+x+"/"+y+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle));
}
- if ( WindowImpl.this.x != x || WindowImpl.this.y != y ) {
+ if ( getX() != x || getY() != y ) {
if(!fullscreen) {
if(0!=windowHandle) {
// this.x/this.y will be set by sizeChanged, triggered by windowing event system
- reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(0, isVisible()));
+ reconfigureWindowImpl(x, y, getWidth(), getHeight(), getReconfigureFlags(0, isVisible()));
} else {
- WindowImpl.this.x = x;
- WindowImpl.this.y = y;
+ definePosition(x, y);
}
}
}
@@ -1683,7 +1691,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
public void setTopLevelPosition(int x, int y) {
setPosition(x + getInsets().getLeftWidth(), y + getInsets().getTopHeight());
}
-
+
private class FullScreenActionImpl implements Runnable {
boolean fullscreen;
boolean nativeFullscreenChange;
@@ -1707,10 +1715,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
int x,y,w,h;
if(fullscreen) {
- nfs_x = WindowImpl.this.x;
- nfs_y = WindowImpl.this.y;
- nfs_width = WindowImpl.this.width;
- nfs_height = WindowImpl.this.height;
+ nfs_x = getX();
+ nfs_y = getY();
+ nfs_width = getWidth();
+ nfs_height = getHeight();
x = screen.getX();
y = screen.getY();
w = screen.getWidth();
@@ -1976,11 +1984,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
y = lastMousePosition.getY();
}
// clip coordinates to window dimension
- x = Math.min(Math.max(x, 0), width-1);
- y = Math.min(Math.max(y, 0), height-1);
+ x = Math.min(Math.max(x, 0), getWidth()-1);
+ y = Math.min(Math.max(y, 0), getHeight()-1);
mouseInWindow = eventType == MouseEvent.EVENT_MOUSE_ENTERED;
}
- if(x<0||y<0||x>=width||y>=height) {
+ if(x<0||y<0||x>=getWidth()||y>=getHeight()) {
return; // .. invalid ..
}
if(DEBUG_MOUSE_EVENT) {
@@ -2366,15 +2374,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
/** Triggered by implementation's WM events to update the client-area size w/o insets/decorations. */
protected void sizeChanged(boolean defer, int newWidth, int newHeight, boolean force) {
- if(force || width != newWidth || height != newHeight) {
+ if(force || getWidth() != newWidth || getHeight() != newHeight) {
if(DEBUG_IMPLEMENTATION) {
- System.err.println("Window.sizeChanged: ("+getThreadName()+"): (defer: "+defer+") force "+force+", "+width+"x"+height+" -> "+newWidth+"x"+newHeight+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle));
+ System.err.println("Window.sizeChanged: ("+getThreadName()+"): (defer: "+defer+") force "+force+", "+getWidth()+"x"+getHeight()+" -> "+newWidth+"x"+newHeight+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle));
}
if(0>newWidth || 0>newHeight) {
throw new NativeWindowException("Illegal width or height "+newWidth+"x"+newHeight+" (must be >= 0)");
}
- width = newWidth;
- height = newHeight;
+ defineSize(newWidth, newHeight);
if(isNativeValid()) {
if(!defer) {
sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
@@ -2411,18 +2418,18 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
/** Triggered by implementation's WM events to update the position. */
protected void positionChanged(boolean defer, int newX, int newY) {
- autoPosition = false;
- if ( x != newX || y != newY ) {
+ if ( getX() != newX || getY() != newY ) {
if(DEBUG_IMPLEMENTATION) {
- System.err.println("Window.positionChanged: ("+getThreadName()+"): (defer: "+defer+") "+x+"/"+y+" -> "+newX+"/"+newY+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle));
+ System.err.println("Window.positionChanged: ("+getThreadName()+"): (defer: "+defer+") "+getX()+"/"+getY()+" -> "+newX+"/"+newY+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle));
}
- x = newX;
- y = newY;
+ definePosition(newX, newY);
if(!defer) {
sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED);
} else {
enqueueWindowEvent(false, WindowEvent.EVENT_WINDOW_MOVED);
}
+ } else {
+ autoPosition = false; // ensure it's off even w/ same position
}
}
@@ -2477,8 +2484,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
* Triggered by implementation's WM events to update the content
*/
protected void windowRepaint(boolean defer, int x, int y, int width, int height) {
- width = ( 0 >= width ) ? this.width : width;
- height = ( 0 >= height ) ? this.height : height;
+ width = ( 0 >= width ) ? getWidth() : width;
+ height = ( 0 >= height ) ? getHeight() : height;
if(DEBUG_IMPLEMENTATION) {
System.err.println("Window.windowRepaint "+getThreadName()+" (defer: "+defer+") "+x+"/"+y+" "+width+"x"+height);
}
diff --git a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java
index 6348cf19e..52c789a4d 100644
--- a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java
+++ b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java
@@ -177,19 +177,18 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
// sh.setType(SurfaceHolder.SURFACE_TYPE_NORMAL);
// default size -> TBD !
- this.width = 0;
- this.height = 0;
+ defineSize(0, 0);
}
public SurfaceView getAndroidView() { return androidView; }
public void setAndroidWindow(android.view.Window window) {
- System.err.println("setandroidWindow: "+window+", "+width+"x"+height);
+ System.err.println("setandroidWindow: "+window+", "+getWidth()+"x"+getHeight());
androidWindow = window;
androidWindowConfigurationPreCreate();
- if(width>0 && height>0 && !isFullscreen()) {
+ if(getWidth()>0 && getHeight()>0 && !isFullscreen()) {
if(null != androidWindow) {
- androidWindow.setLayout(width, height);
+ androidWindow.setLayout(getWidth(), getHeight());
}
}
}
@@ -205,7 +204,7 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
@Override
protected void createNativeImpl() {
Log.d(MD.TAG, "createNativeImpl 0 - surfaceHandle 0x"+Long.toHexString(surfaceHandle)+
- ", format "+format+", "+x+"/"+y+" "+width+"x"+height+" - "+Thread.currentThread().getName());
+ ", format "+format+", "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+" - "+Thread.currentThread().getName());
Thread.dumpStack();
if(0!=getParentWindowHandle()) {
throw new NativeWindowException("Window parenting not supported (yet)");
@@ -328,7 +327,7 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
//
public void surfaceCreated(SurfaceHolder holder) {
- Log.d(MD.TAG, "surfaceCreated: "+x+"/"+y+" "+width+"x"+height);
+ Log.d(MD.TAG, "surfaceCreated: "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight());
}
public void surfaceChanged(SurfaceHolder aHolder, int aFormat, int aWidth, int aHeight) {
@@ -347,9 +346,7 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
getScreen().getCurrentScreenMode(); // if ScreenMode changed .. trigger ScreenMode event
}
- if(0>x || 0>y) {
- x = 0;
- y = 0;
+ if(0>getX() || 0>getY()) {
positionChanged(false, 0, 0);
}
@@ -365,7 +362,7 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
Log.d(MD.TAG, "surfaceRealized: isValid: "+surface.isValid()+
", new surfaceHandle 0x"+Long.toHexString(surfaceHandle)+", format: "+format+
- ", "+x+"/"+y+" "+nWidth+"x"+nHeight+", visible: "+isVisible());
+ ", "+getX()+"/"+getY()+" "+nWidth+"x"+nHeight+", visible: "+isVisible());
if(isVisible()) {
setVisible(true);
diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java b/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java
index e9e3ec0ba..2c921e7b2 100644
--- a/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java
+++ b/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java
@@ -59,13 +59,12 @@ public class AWTWindow extends WindowImpl {
this(null);
}
- public static Class[] getCustomConstructorArgumentTypes() {
- return new Class[] { Container.class } ;
+ public static Class<?>[] getCustomConstructorArgumentTypes() {
+ return new Class<?>[] { Container.class } ;
}
public AWTWindow(Container container) {
super();
- title = "AWT NewtWindow";
this.container = container;
if(container instanceof Frame) {
frame = (Frame) container;
@@ -99,10 +98,8 @@ public class AWTWindow extends WindowImpl {
owningFrame=true;
} else {
owningFrame=false;
- width = container.getWidth();
- height = container.getHeight();
- x = container.getX();
- y = container.getY();
+ defineSize(container.getWidth(), container.getHeight());
+ definePosition(container.getX(), container.getY());
}
if(null!=frame) {
frame.setTitle(getTitle());
@@ -117,11 +114,11 @@ public class AWTWindow extends WindowImpl {
// canvas.addComponentListener(listener);
container.add(canvas, BorderLayout.CENTER);
- container.setSize(width, height);
- container.setLocation(x, y);
+ container.setSize(getWidth(), getHeight());
+ container.setLocation(getX(), getY());
new AWTWindowAdapter(this).addTo(container); // fwd all AWT Window events to here
- reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(FLAG_CHANGE_VISIBILITY | FLAG_CHANGE_DECORATION, true));
+ reconfigureWindowImpl(getX(), getY(), getWidth(), getHeight(), getReconfigureFlags(FLAG_CHANGE_VISIBILITY | FLAG_CHANGE_DECORATION, true));
// throws exception if failed ..
setWindowHandle(1); // just a marker ..
@@ -221,15 +218,13 @@ public class AWTWindow extends WindowImpl {
@Override
public void windowMoved(com.jogamp.newt.event.WindowEvent e) {
if(null!=container) {
- x = container.getX();
- y = container.getY();
+ definePosition(container.getX(), container.getY());
}
}
@Override
public void windowResized(com.jogamp.newt.event.WindowEvent e) {
if(null!=canvas) {
- width = canvas.getWidth();
- height = canvas.getHeight();
+ defineSize(canvas.getWidth(), canvas.getHeight());
}
}
}
diff --git a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java b/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java
index 6f66eedd3..bd63f83ab 100644
--- a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java
+++ b/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java
@@ -35,7 +35,6 @@ package jogamp.newt.driver.broadcom.egl;
import jogamp.opengl.egl.*;
import javax.media.nativewindow.*;
-import javax.media.nativewindow.awt.AWTGraphicsConfiguration;
import javax.media.nativewindow.util.Insets;
import javax.media.nativewindow.util.Point;
import javax.media.opengl.GLCapabilitiesImmutable;
@@ -62,7 +61,7 @@ public class Window extends jogamp.newt.WindowImpl {
setGraphicsConfiguration(cfg);
setSizeImpl(getScreen().getWidth(), getScreen().getHeight());
- setWindowHandle(realizeWindow(true, width, height));
+ setWindowHandle(realizeWindow(true, getWidth(), getHeight()));
if (0 == getWindowHandle()) {
throw new NativeWindowException("Error native Window Handle is null");
}
@@ -81,8 +80,7 @@ public class Window extends jogamp.newt.WindowImpl {
// n/a in BroadcomEGL
System.err.println("BCEGL Window.setSizeImpl n/a in BroadcomEGL with realized window");
} else {
- this.width = width;
- this.height = height;
+ defineSize(width, height);
}
}
@@ -101,8 +99,7 @@ public class Window extends jogamp.newt.WindowImpl {
// n/a in BroadcomEGL
System.err.println("BCEGL Window.setSizeImpl n/a in BroadcomEGL with realized window");
} else {
- this.width=(width>0)?width:this.width;
- this.height=(height>0)?height:this.height;
+ defineSize((width>0)?width:getWidth(), (height>0)?height:getHeight());
}
}
if(x>=0 || y>=0) {
@@ -152,8 +149,7 @@ public class Window extends jogamp.newt.WindowImpl {
}
private void windowCreated(int cfgID, int width, int height) {
- this.width = width;
- this.height = height;
+ defineSize(width, height);
GLCapabilitiesImmutable capsReq = (GLCapabilitiesImmutable) getGraphicsConfiguration().getRequestedCapabilities();
final AbstractGraphicsConfiguration cfg = EGLGraphicsConfiguration.create(capsReq, getScreen().getGraphicsScreen(), cfgID);
if (null == cfg) {
diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java
index 873d0a0c1..09e0e3016 100644
--- a/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java
+++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java
@@ -64,7 +64,7 @@ public class Window extends jogamp.newt.WindowImpl {
synchronized(Window.class) {
setWindowHandle(nextWindowHandle++); // just a marker
- surfaceHandle = CreateSurface(aDevice.getHandle(), getScreen().getWidth(), getScreen().getHeight(), x, y, width, height);
+ surfaceHandle = CreateSurface(aDevice.getHandle(), getScreen().getWidth(), getScreen().getHeight(), getX(), getY(), getWidth(), getHeight());
if (surfaceHandle == 0) {
throw new NativeWindowException("Error creating window");
}
@@ -138,10 +138,8 @@ public class Window extends jogamp.newt.WindowImpl {
private native void SetBounds0(long surfaceHandle, int scrn_width, int scrn_height, int x, int y, int width, int height);
private void updateBounds(int x, int y, int width, int height) {
- this.x = x;
- this.y = y;
- this.width = width;
- this.height = height;
+ definePosition(x, y);
+ defineSize(width, height);
}
private long surfaceHandle;
diff --git a/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java b/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java
index 92f8251bc..8ae0b6587 100644
--- a/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java
+++ b/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java
@@ -34,7 +34,6 @@
package jogamp.newt.driver.kd;
import jogamp.newt.*;
-import jogamp.newt.driver.intel.gdl.Display;
import jogamp.opengl.egl.*;
import javax.media.nativewindow.*;
import javax.media.nativewindow.util.Insets;
@@ -102,8 +101,8 @@ public class KDWindow extends WindowImpl {
}
// int _x=(x>=0)?x:this.x;
// int _y=(x>=0)?y:this.y;
- width=(width>0)?width:this.width;
- height=(height>0)?height:this.height;
+ width=(width>0)?width:getWidth();
+ height=(height>0)?height:getHeight();
if(width>0 || height>0) {
setSize0(eglWindowHandle, width, height);
}
@@ -145,8 +144,8 @@ public class KDWindow extends WindowImpl {
@Override
protected void sizeChanged(boolean defer, int newWidth, int newHeight, boolean force) {
- if(fullscreen) {
- ((KDScreen)getScreen()).sizeChanged(width, height);
+ if(isFullscreen()) {
+ ((KDScreen)getScreen()).sizeChanged(getWidth(), getHeight());
}
super.sizeChanged(defer, newWidth, newHeight, force);
}
diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java
index 32e76ec00..c926d44ee 100644
--- a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java
+++ b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java
@@ -67,7 +67,7 @@ public class MacWindow extends WindowImpl implements SurfaceChangeable, DriverCl
throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
}
setGraphicsConfiguration(cfg);
- reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(FLAG_CHANGE_VISIBILITY, true));
+ reconfigureWindowImpl(getX(), getY(), getWidth(), getHeight(), getReconfigureFlags(FLAG_CHANGE_VISIBILITY, true));
if (0 == getWindowHandle()) {
throw new NativeWindowException("Error creating window");
}
@@ -247,8 +247,8 @@ public class MacWindow extends WindowImpl implements SurfaceChangeable, DriverCl
@Override
protected void sizeChanged(boolean defer, int newWidth, int newHeight, boolean force) {
- if(width != newWidth || height != newHeight) {
- final Point p0S = getTopLevelLocationOnScreen(x, y);
+ if(getWidth() != newWidth || getHeight() != newHeight) {
+ final Point p0S = getTopLevelLocationOnScreen(getX(), getY());
setFrameTopLeftPoint0(getParentWindowHandle(), getWindowHandle(), p0S.getX(), p0S.getY());
}
super.sizeChanged(defer, newWidth, newHeight, force);
diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java b/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java
index ff3bd5ef6..d14c47f5a 100644
--- a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java
+++ b/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java
@@ -115,7 +115,7 @@ public class WindowsWindow extends WindowImpl {
final int flags = getReconfigureFlags(0, true) &
( FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED ) ;
setWindowHandle(CreateWindow0(display.getHInstance(), display.getWindowClassName(), display.getWindowClassName(),
- getParentWindowHandle(), x, y, width, height, autoPosition, flags));
+ getParentWindowHandle(), getX(), getY(), getWidth(), getHeight(), autoPosition(), flags));
if (getWindowHandle() == 0) {
throw new NativeWindowException("Error creating window");
}
@@ -220,7 +220,7 @@ public class WindowsWindow extends WindowImpl {
public void run() {
final Point p0 = getLocationOnScreenImpl(0, 0);
res[0] = Boolean.valueOf(confinePointer0(getWindowHandle(), confine,
- p0.getX(), p0.getY(), p0.getX()+width, p0.getY()+height));
+ p0.getX(), p0.getY(), p0.getX()+getWidth(), p0.getY()+getHeight()));
}
});
return res[0].booleanValue();
diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java b/src/newt/classes/jogamp/newt/driver/x11/X11Window.java
index 33b541c34..c975306b4 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/X11Window.java
@@ -79,7 +79,7 @@ public class X11Window extends WindowImpl {
setWindowHandle(CreateWindow0(getParentWindowHandle(),
display.getEDTHandle(), screen.getIndex(), visualID,
display.getJavaObjectAtom(), display.getWindowDeleteAtom(),
- x, y, width, height, autoPosition, flags));
+ getX(), getY(), getWidth(), getHeight(), autoPosition(), flags));
windowHandleClose = getWindowHandle();
if (0 == windowHandleClose) {
throw new NativeWindowException("Error creating window");