diff options
Diffstat (limited to 'src/nativewindow')
9 files changed, 204 insertions, 153 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/NullWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/NullWindow.java index 4458d7b3d..a1c2b594c 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/NullWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/NullWindow.java @@ -117,10 +117,6 @@ public class NullWindow implements NativeWindow, SurfaceChangeable { return config; } - public Object getWrappedWindow() { - return null; - } - public final boolean isTerminalObject() { return true; } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/RecursiveToolkitLock.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/RecursiveToolkitLock.java index 06ce54368..52c211615 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/RecursiveToolkitLock.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/RecursiveToolkitLock.java @@ -6,8 +6,8 @@ import javax.media.nativewindow.*; // Reentrance locking toolkit // public class RecursiveToolkitLock implements ToolkitLock { - private Thread owner; - private int recursionCount; + private Thread owner = null; + private int recursionCount = 0; private Exception lockedStack = null; private static final long timeout = 3000; // maximum wait 3s @@ -31,6 +31,10 @@ public class RecursiveToolkitLock implements ToolkitLock { return null != owner; } + public synchronized int getRecursionCount() { + return recursionCount; + } + /** Recursive and blocking lockSurface() implementation */ public synchronized void lock() { Thread cur = Thread.currentThread(); @@ -49,10 +53,10 @@ public class RecursiveToolkitLock implements ToolkitLock { } if(owner != null) { lockedStack.printStackTrace(); - throw new RuntimeException("Waited "+timeout+"ms for: "+owner+" - "+cur); + throw new RuntimeException("Waited "+timeout+"ms for: "+owner+" - "+cur+", with recursionCount "+recursionCount+", lock: "+this); } owner = cur; - lockedStack = new Exception("Previously locked by "+owner); + lockedStack = new Exception("Previously locked by "+owner+", lock: "+this); } @@ -62,7 +66,7 @@ public class RecursiveToolkitLock implements ToolkitLock { } /** Recursive and unblocking unlockSurface() implementation */ - public synchronized void unlock(Runnable releaseAfterUnlockBeforeNotify) { + public synchronized void unlock(Runnable taskAfterUnlockBeforeNotify) { Thread cur = Thread.currentThread(); if (owner != cur) { lockedStack.printStackTrace(); @@ -74,8 +78,8 @@ public class RecursiveToolkitLock implements ToolkitLock { } owner = null; lockedStack = null; - if(null!=releaseAfterUnlockBeforeNotify) { - releaseAfterUnlockBeforeNotify.run(); + if(null!=taskAfterUnlockBeforeNotify) { + taskAfterUnlockBeforeNotify.run(); } notifyAll(); } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTWindow.java index d0529878f..68e61cd85 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTWindow.java @@ -37,6 +37,7 @@ package com.jogamp.nativewindow.impl.jawt; import com.jogamp.nativewindow.impl.*; +import com.jogamp.nativewindow.util.Rectangle; import java.awt.Component; import java.awt.Window; @@ -60,6 +61,7 @@ public abstract class JAWTWindow implements NativeWindow { // lifetime: valid after lock, forever until invalidate protected long drawable; + protected Rectangle bounds; public JAWTWindow(Object comp, AbstractGraphicsConfiguration config) { if (config == null) { @@ -80,6 +82,7 @@ public abstract class JAWTWindow implements NativeWindow { public synchronized void invalidate() { component = null; drawable= 0; + bounds = new Rectangle(); } public synchronized void destroy() { @@ -91,9 +94,18 @@ public abstract class JAWTWindow implements NativeWindow { invalidate(); } + protected void updateBounds(JAWT_Rectangle jawtBounds) { + bounds.setX(jawtBounds.getX()); + bounds.setY(jawtBounds.getY()); + bounds.setWidth(jawtBounds.getWidth()); + bounds.setHeight(jawtBounds.getHeight()); + } + private volatile Exception lockedStack = null; - public synchronized int lockSurface() throws NativeWindowException { + protected abstract int lockSurfaceImpl() throws NativeWindowException; + + public final synchronized int lockSurface() throws NativeWindowException { // We have to be the owner of the JAWT ToolkitLock 'lock' to benefit from it's // recursive and blocking lock capabitlites. // Otherwise a followup ToolkitLock would deadlock, @@ -107,15 +119,18 @@ public abstract class JAWTWindow implements NativeWindow { } lockedStack = new Exception("JAWT Surface previously locked by "+Thread.currentThread().getName()); - return LOCK_SUCCESS; + return lockSurfaceImpl(); } + protected abstract void unlockSurfaceImpl() throws NativeWindowException; + public synchronized void unlockSurface() { if (null!=lockedStack) { lockedStack = null; } else { throw new NativeWindowException("JAWT Surface not locked"); } + unlockSurfaceImpl(); NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock(); } @@ -165,12 +180,16 @@ public abstract class JAWTWindow implements NativeWindow { return component.getHeight(); } + /** @return the JAWT_DrawingSurfaceInfo's (JAWT_Rectangle) bounds, updated with lock */ + public Rectangle getBounds() { return bounds; } + public String toString() { StringBuffer sb = new StringBuffer(); sb.append("JAWT-Window["+ "windowHandle 0x"+Long.toHexString(getWindowHandle())+ - ", surfaceHandle 0x"+Long.toHexString(getSurfaceHandle())); + ", surfaceHandle 0x"+Long.toHexString(getSurfaceHandle())+ + ", bounds "+bounds); if(null!=component) { sb.append(", pos "+component.getX()+"/"+component.getY()+", size "+getWidth()+"x"+getHeight()+ ", visible "+component.isVisible()); @@ -183,4 +202,5 @@ public abstract class JAWTWindow implements NativeWindow { return sb.toString(); } + } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java index 967d43d60..ed932ff91 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java @@ -57,20 +57,18 @@ public class MacOSXJAWTWindow extends JAWTWindow { protected void initNative() throws NativeWindowException { } - public int lockSurface() throws NativeWindowException { - int ret = super.lockSurface(); - if(NativeWindow.LOCK_SUCCESS != ret) { - return ret; - } + protected int lockSurfaceImpl() throws NativeWindowException { + int ret = NativeWindow.LOCK_SUCCESS; ds = JAWT.getJAWT().GetDrawingSurface(component); if (ds == null) { // Widget not yet realized - super.unlockSurface(); + unlockSurface(); return NativeWindow.LOCK_SURFACE_NOT_READY; } int res = ds.Lock(); - if ((res & JAWTFactory.JAWT_LOCK_ERROR) != 0) { - super.unlockSurface(); + dsLocked = ( 0 == ( res & JAWTFactory.JAWT_LOCK_ERROR ) ) ; + if (!dsLocked) { + unlockSurface(); throw new NativeWindowException("Unable to lock surface"); } // See whether the surface changed and if so destroy the old @@ -92,56 +90,44 @@ public class MacOSXJAWTWindow extends JAWTWindow { dsi = ds.GetDrawingSurfaceInfo(); } if (dsi == null) { - // Widget not yet realized - ds.Unlock(); - JAWT.getJAWT().FreeDrawingSurface(ds); - ds = null; - super.unlockSurface(); + unlockSurface(); return NativeWindow.LOCK_SURFACE_NOT_READY; } firstLock = false; macosxdsi = (JAWT_MacOSXDrawingSurfaceInfo) dsi.platformInfo(); if (macosxdsi == null) { - // Widget not yet realized - ds.FreeDrawingSurfaceInfo(dsi); - ds.Unlock(); - JAWT.getJAWT().FreeDrawingSurface(ds); - ds = null; - dsi = null; - super.unlockSurface(); + unlockSurface(); return NativeWindow.LOCK_SURFACE_NOT_READY; } drawable = macosxdsi.getCocoaViewRef(); if (drawable == 0) { - // Widget not yet realized - ds.FreeDrawingSurfaceInfo(dsi); - ds.Unlock(); - JAWT.getJAWT().FreeDrawingSurface(ds); - ds = null; - dsi = null; - macosxdsi = null; - super.unlockSurface(); + unlockSurface(); return NativeWindow.LOCK_SURFACE_NOT_READY; + } else { + updateBounds(dsi.getBounds()); } return ret; } - public void unlockSurface() throws NativeWindowException { - if(!isSurfaceLocked()) { - throw new RuntimeException("JAWTWindow not locked"); + protected void unlockSurfaceImpl() throws NativeWindowException { + if(null!=ds) { + if (null!=dsi) { + ds.FreeDrawingSurfaceInfo(dsi); + } + if (dsLocked) { + ds.Unlock(); + } + JAWT.getJAWT().FreeDrawingSurface(ds); } - ds.FreeDrawingSurfaceInfo(dsi); - ds.Unlock(); - JAWT.getJAWT().FreeDrawingSurface(ds); ds = null; dsi = null; macosxdsi = null; - super.unlockSurface(); } // Variables for lockSurface/unlockSurface private JAWT_DrawingSurface ds; + private boolean dsLocked; private JAWT_DrawingSurfaceInfo dsi; private JAWT_MacOSXDrawingSurfaceInfo macosxdsi; diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java index 7d680dfa0..c3b3682fd 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java @@ -61,12 +61,8 @@ public class WindowsJAWTWindow extends JAWTWindow { windowHandle = 0; } - public int lockSurface() throws NativeWindowException { - int ret = super.lockSurface(); - if(LOCK_SUCCESS != ret) { - return ret; - } - + protected int lockSurfaceImpl() throws NativeWindowException { + int ret = NativeWindow.LOCK_SUCCESS; long startTime; if (PROFILING) { startTime = System.currentTimeMillis(); @@ -74,12 +70,13 @@ public class WindowsJAWTWindow extends JAWTWindow { ds = JAWT.getJAWT().GetDrawingSurface(component); if (ds == null) { // Widget not yet realized - super.unlockSurface(); + unlockSurface(); return LOCK_SURFACE_NOT_READY; } int res = ds.Lock(); - if ((res & JAWTFactory.JAWT_LOCK_ERROR) != 0) { - super.unlockSurface(); + dsLocked = ( 0 == ( res & JAWTFactory.JAWT_LOCK_ERROR ) ) ; + if (!dsLocked) { + unlockSurface(); throw new NativeWindowException("Unable to lock surface"); } // See whether the surface changed and if so destroy the old @@ -92,36 +89,21 @@ public class WindowsJAWTWindow extends JAWTWindow { } dsi = ds.GetDrawingSurfaceInfo(); if (dsi == null) { - // Widget not yet realized - ds.Unlock(); - JAWT.getJAWT().FreeDrawingSurface(ds); - ds = null; - super.unlockSurface(); + unlockSurface(); return LOCK_SURFACE_NOT_READY; } win32dsi = (JAWT_Win32DrawingSurfaceInfo) dsi.platformInfo(); if (win32dsi == null) { - // Widget not yet realized - ds.FreeDrawingSurfaceInfo(dsi); - ds.Unlock(); - JAWT.getJAWT().FreeDrawingSurface(ds); - ds = null; - dsi = null; - super.unlockSurface(); + unlockSurface(); return LOCK_SURFACE_NOT_READY; } windowHandle = win32dsi.getHandle(); drawable = win32dsi.getHdc(); if (windowHandle == 0 || drawable == 0) { - // Widget not yet realized - ds.FreeDrawingSurfaceInfo(dsi); - ds.Unlock(); - JAWT.getJAWT().FreeDrawingSurface(ds); - ds = null; - dsi = null; - win32dsi = null; - super.unlockSurface(); + unlockSurface(); return LOCK_SURFACE_NOT_READY; + } else { + updateBounds(dsi.getBounds()); } if (PROFILING) { long endTime = System.currentTimeMillis(); @@ -136,21 +118,23 @@ public class WindowsJAWTWindow extends JAWTWindow { return ret; } - public void unlockSurface() { - if(!isSurfaceLocked()) { - throw new RuntimeException("JAWTWindow not locked"); - } + protected void unlockSurfaceImpl() throws NativeWindowException { long startTime = 0; if (PROFILING) { startTime = System.currentTimeMillis(); } - ds.FreeDrawingSurfaceInfo(dsi); - ds.Unlock(); - JAWT.getJAWT().FreeDrawingSurface(ds); + if(null!=ds) { + if (null!=dsi) { + ds.FreeDrawingSurfaceInfo(dsi); + } + if (dsLocked) { + ds.Unlock(); + } + JAWT.getJAWT().FreeDrawingSurface(ds); + } ds = null; dsi = null; win32dsi = null; - super.unlockSurface(); if (PROFILING) { long endTime = System.currentTimeMillis(); profilingUnlockSurfaceTime += (endTime - startTime); @@ -169,6 +153,7 @@ public class WindowsJAWTWindow extends JAWTWindow { // Variables for lockSurface/unlockSurface private JAWT_DrawingSurface ds; + private boolean dsLocked; private JAWT_DrawingSurfaceInfo dsi; private JAWT_Win32DrawingSurfaceInfo win32dsi; private long profilingLockSurfaceTime = 0; diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/x11/X11JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/x11/X11JAWTWindow.java index 77bf93204..f7151d9f1 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/x11/X11JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/x11/X11JAWTWindow.java @@ -69,20 +69,18 @@ public class X11JAWTWindow extends JAWTWindow { } } - public synchronized int lockSurface() throws NativeWindowException { - int ret = super.lockSurface(); - if(LOCK_SUCCESS != ret) { - return ret; - } + protected int lockSurfaceImpl() throws NativeWindowException { + int ret = NativeWindow.LOCK_SUCCESS; ds = JAWT.getJAWT().GetDrawingSurface(component); if (ds == null) { // Widget not yet realized - super.unlockSurface(); + unlockSurface(); return LOCK_SURFACE_NOT_READY; } int res = ds.Lock(); - if ((res & JAWTFactory.JAWT_LOCK_ERROR) != 0) { - super.unlockSurface(); + dsLocked = ( 0 == ( res & JAWTFactory.JAWT_LOCK_ERROR ) ) ; + if (!dsLocked) { + unlockSurface(); throw new NativeWindowException("Unable to lock surface"); } // See whether the surface changed and if so destroy the old @@ -95,55 +93,42 @@ public class X11JAWTWindow extends JAWTWindow { } dsi = ds.GetDrawingSurfaceInfo(); if (dsi == null) { - // Widget not yet realized - ds.Unlock(); - JAWT.getJAWT().FreeDrawingSurface(ds); - ds = null; - super.unlockSurface(); + unlockSurface(); return LOCK_SURFACE_NOT_READY; } x11dsi = (JAWT_X11DrawingSurfaceInfo) dsi.platformInfo(); if (x11dsi == null) { - // Widget not yet realized - ds.FreeDrawingSurfaceInfo(dsi); - ds.Unlock(); - JAWT.getJAWT().FreeDrawingSurface(ds); - ds = null; - dsi = null; - super.unlockSurface(); + unlockSurface(); return LOCK_SURFACE_NOT_READY; } drawable = x11dsi.getDrawable(); if (drawable == 0) { - // Widget not yet realized - ds.FreeDrawingSurfaceInfo(dsi); - ds.Unlock(); - JAWT.getJAWT().FreeDrawingSurface(ds); - ds = null; - dsi = null; - x11dsi = null; - drawable = 0; - super.unlockSurface(); + unlockSurface(); return LOCK_SURFACE_NOT_READY; + } else { + updateBounds(dsi.getBounds()); } return ret; } - public synchronized void unlockSurface() { - if(!isSurfaceLocked()) { - throw new RuntimeException("JAWTWindow not locked"); + protected void unlockSurfaceImpl() throws NativeWindowException { + if(null!=ds) { + if (null!=dsi) { + ds.FreeDrawingSurfaceInfo(dsi); + } + if (dsLocked) { + ds.Unlock(); + } + JAWT.getJAWT().FreeDrawingSurface(ds); } - ds.FreeDrawingSurfaceInfo(dsi); - ds.Unlock(); - JAWT.getJAWT().FreeDrawingSurface(ds); ds = null; dsi = null; x11dsi = null; - super.unlockSurface(); } // Variables for lockSurface/unlockSurface private JAWT_DrawingSurface ds; + private boolean dsLocked; private JAWT_DrawingSurfaceInfo dsi; private JAWT_X11DrawingSurfaceInfo x11dsi; diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java index 196e8f4e2..6e3c62d3b 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java @@ -54,19 +54,24 @@ public class X11Util { private static final boolean DEBUG = Debug.debug("X11Util"); private static final boolean DEBUG_XDISPLAY_LOCK = false; + public static final String nullDisplayName; + static { NWJNILibLoader.loadNativeWindow("x11"); - // No concurrent threading support in case AWT could be used, - // Mixing AWT and X11/NEWT results in a segmentation fault: - // C pthread_mutex_lock+0x4 - // J sun.awt.X11.XlibWrapper.XGetDefault - // J sun.awt.X11.XToolkit.initializeMultiClickTime - // J sun.awt.X11.XToolkit.getMultiClickTime - // - // It seems like (Oracle's) AWT's Display locking is buggy. - // - initialize( ! NativeWindowFactory.isAWTAvailable() ) ; + initialize( true ); + + long dpy = X11Lib.XOpenDisplay(null); + XLockDisplay(dpy); + try { + nullDisplayName = X11Lib.XDisplayString(dpy); + } finally { + XUnlockDisplay(dpy); + } + X11Lib.XCloseDisplay(dpy); + if(DEBUG) { + System.out.println("X11 Display(NULL) <"+nullDisplayName+">"); + } } public static void initSingleton() { @@ -82,8 +87,6 @@ public class X11Util { private static ThreadLocal currentDisplayMap = new ThreadLocal(); - public static final String nullDeviceName = "nil" ; - public static class NamedDisplay extends RecursiveToolkitLock implements Cloneable { String name; long handle; @@ -98,7 +101,6 @@ public class X11Util { } public final String getName() { return name; } - public final String getNameSafe() { return null == name ? nullDeviceName : name; } public final long getHandle() { return handle; } public final int getRefCount() { return refCount; } public final boolean isUncloseable() { return unCloseable; } @@ -134,6 +136,20 @@ public class X11Util { return num; } + /** + * @return If name is null, it returns the previous queried NULL display name, + * otherwise the name. */ + public static String validateDisplayName(String name) { + return ( null == name ) ? nullDisplayName : name ; + } + + public static String validateDisplayName(String name, long handle) { + if(null==name && 0!=handle) { + name = getNameOfDisplay(handle); + } + return ( null == name ) ? nullDisplayName : name ; + } + /** Returns a clone of the thread local display map, you may {@link Object#wait()} on it */ public static Map getCurrentDisplayMap() { return (Map) ((HashMap)getCurrentDisplayMapImpl()).clone(); @@ -146,6 +162,7 @@ public class X11Util { /** Returns this thread named display. If it doesn not exist, it is being created, otherwise the reference count is increased */ public static long createThreadLocalDisplay(String name) { + name = validateDisplayName(name); NamedDisplay namedDpy = getCurrentDisplay(name); if(null==namedDpy) { long dpy = X11Lib.XOpenDisplay(name); @@ -179,6 +196,7 @@ public class X11Util { or the reference count goes below 0. */ public static long closeThreadLocalDisplay(String name) { + name = validateDisplayName(name); NamedDisplay namedDpy = getCurrentDisplay(name); if(null==namedDpy) { throw new RuntimeException("X11Util.Display: Display("+name+") with given name is not mapped to TLS in thread "+Thread.currentThread().getName()); @@ -220,18 +238,24 @@ public class X11Util { } public static boolean setSynchronizeDisplay(long handle, boolean onoff) { - String name; + boolean res=false; XLockDisplay(handle); - boolean res = X11Lib.XSynchronize(handle, onoff); - XUnlockDisplay(handle); + try { + res = X11Lib.XSynchronize(handle, onoff); + } finally { + XUnlockDisplay(handle); + } return res; } public static String getNameOfDisplay(long handle) { String name; XLockDisplay(handle); - name = X11Lib.XDisplayString(handle); - XUnlockDisplay(handle); + try { + name = X11Lib.XDisplayString(handle); + } finally { + XUnlockDisplay(handle); + } return name; } @@ -299,7 +323,7 @@ public class X11Util { Map displayMap = getCurrentDisplayMapImpl(); NamedDisplay oldDisplay = null; synchronized(displayMap) { - oldDisplay = (NamedDisplay) displayMap.put(newDisplay.getNameSafe(), newDisplay); + oldDisplay = (NamedDisplay) displayMap.put(newDisplay.getName(), newDisplay); displayMap.notifyAll(); } return oldDisplay; @@ -310,7 +334,7 @@ public class X11Util { private static NamedDisplay removeCurrentDisplay(NamedDisplay ndpy) { Map displayMap = getCurrentDisplayMapImpl(); synchronized(displayMap) { - NamedDisplay ndpyDel = (NamedDisplay) displayMap.remove(ndpy.getNameSafe()); + NamedDisplay ndpyDel = (NamedDisplay) displayMap.remove(ndpy.getName()); if(ndpyDel!=ndpy) { throw new RuntimeException("Wrong mapping req: "+ndpy+", got "+ndpyDel); } @@ -321,7 +345,6 @@ public class X11Util { /** Returns the thread local display mapped to the given name */ private static NamedDisplay getCurrentDisplay(String name) { - if(null==name) name=nullDeviceName; Map displayMap = getCurrentDisplayMapImpl(); return (NamedDisplay) displayMap.get(name); } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/util/Rectangle.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/Rectangle.java new file mode 100644 index 000000000..9f487f847 --- /dev/null +++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/Rectangle.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2010, Sven Gothel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Sven Gothel nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL Sven Gothel BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.jogamp.nativewindow.util; + +public class Rectangle { + int x; + int y; + int width; + int height; + + public Rectangle() { + this(0, 0, 0, 0); + } + + public Rectangle(int x, int y, int width, int height) { + this.x=x; + this.y=y; + this.width=width; + this.height=height; + } + public int getX() { return x; } + public int getY() { return y; } + public int getWidth() { return width; } + public int getHeight() { return height; } + public void setX(int x) { this.x = x; } + public void setY(int y) { this.y = y; } + public void setWidth(int width) { this.width = width; } + public void setHeight(int height) { this.height = height; } + + public String toString() { + return new String("Rect["+x+"/"+y+" "+width+"x"+height+"]"); + } +} + diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java index 37606e8d8..09c605e1c 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java @@ -65,9 +65,8 @@ public interface NativeWindow extends SurfaceUpdatedListener { /** * Lock the surface of this native window<P> * - * The window handle, see {@link #getWindowHandle()}, - * and the surface handle, see {@link #lockSurface()}, <br> - * shall be set and be valid after a successfull call, + * The surface handle, see {@link #lockSurface()}, <br> + * shall be set and valid after a successfull call, * ie a return value other than {@link #LOCK_SURFACE_NOT_READY}.<P> * * The semantics of the underlying native locked resource @@ -88,8 +87,7 @@ public interface NativeWindow extends SurfaceUpdatedListener { /** * Unlock the surface of this native window * - * Shall not modify the window handle, see {@link #getWindowHandle()}, - * or the surface handle, see {@link #lockSurface()} <P> + * Shall not modify the surface handle, see {@link #lockSurface()} <P> * * @throws NativeWindowException if surface is not locked * @@ -140,11 +138,6 @@ public interface NativeWindow extends SurfaceUpdatedListener { /** * Returns the window handle for this NativeWindow. <P> * - * The window handle should be set/update by {@link #lockSurface()}, - * where {@link #unlockSurface()} is not allowed to modify it.<br> - * After {@link #unlockSurface()} it is no more guaranteed - * that the window handle is still valid.<p> - * * The window handle shall reflect the platform one * for all window related operations, e.g. open, close, resize. <P> * |