public abstract class JAWTWindow extends Object implements NativeWindow, OffscreenLayerSurface, OffscreenLayerOption
LOCK_SUCCESS, LOCK_SURFACE_CHANGED, LOCK_SURFACE_NOT_READY, LOCK_SURFACE_UNLOCKED| Modifier and Type | Method and Description |
|---|---|
void |
addSurfaceUpdatedListener(int index,
SurfaceUpdatedListener l)
Inserts the given
SurfaceUpdatedListener at the
specified position in the list. |
void |
addSurfaceUpdatedListener(SurfaceUpdatedListener l)
Appends the given
SurfaceUpdatedListener to the end of the list. |
void |
attachSurfaceLayer(long layerHandle)
Attach the offscreen layer to this offscreen layer surface.
|
int[] |
convertToPixelUnits(int[] windowUnitsAndResult)
Converts the given window units into pixel units in place.
|
int[] |
convertToWindowUnits(int[] pixelUnitsAndResult)
Converts the given pixel units into window units in place.
|
void |
destroy()
Destroys this window incl.
|
void |
detachSurfaceLayer()
Detaches a previously attached offscreen layer from this offscreen layer surface.
|
long |
getAttachedSurfaceLayer()
Returns the attached surface layer or null if none is attached.
|
Component |
getAWTComponent() |
RectangleImmutable |
getBounds() |
long |
getDisplayHandle()
Convenience: Get display handle from
AbstractGraphicsConfiguration .
|
AbstractGraphicsConfiguration |
getGraphicsConfiguration()
Returns the graphics configuration corresponding to this window.
|
int |
getHeight()
Returns the height of the client area excluding insets (window decorations) in window units.
|
InsetsImmutable |
getInsets()
Returns the insets defined as the width and height of the window decoration
on the left, right, top and bottom in window units.
|
jogamp.nativewindow.jawt.JAWT |
getJAWT()
Returns the underlying JAWT instance created @
lockSurface(). |
Point |
getLocationOnScreen(Point storage)
Returns the window's top-left client-area position in the screen.
|
RecursiveLock |
getLock()
Returns the recursive lock object of this surface, which synchronizes multithreaded access.
|
NativeWindow |
getParent() |
int |
getPixelScale() |
int |
getScreenIndex()
Convenience: Get display handle from
AbstractGraphicsConfiguration .
|
boolean |
getShallUseOffscreenLayer()
Returns the property set by
OffscreenLayerOption.setShallUseOffscreenLayer(boolean). |
long |
getSurfaceHandle()
Returns the handle to the surface for this NativeSurface.
|
int |
getSurfaceHeight()
Returns the height of the client area excluding insets (window decorations) in pixel units.
|
Thread |
getSurfaceLockOwner()
Return the locking owner's Thread, or null if not locked.
|
int |
getSurfaceWidth()
Returns the width of the client area excluding insets (window decorations) in pixel units.
|
int |
getWidth()
Returns the width of the client area excluding insets (window decorations) in window units.
|
long |
getWindowHandle()
Returns the window handle for this NativeWindow.
|
int |
getX()
Returns the x position of the top-left corner
of the client area relative to it's parent in window units.
|
int |
getY()
Returns the current y position of the top-left corner
of the client area relative to it's parent in window units.
|
boolean |
hasFocus()
Returns true if this native window owns the focus, otherwise false.
|
boolean |
hideCursor()
Optional method hiding the cursor in the corresponding on-screen surface/window, if exists.
|
boolean |
isApplet()
Returns true if the AWT component is parented to an
Applet,
otherwise false. |
boolean |
isOffscreenLayerSurfaceEnabled()
Returns true if this instance uses an offscreen layer, otherwise false.
|
boolean |
isSurfaceLayerAttached()
Returns true if a surface layer is attached, otherwise false.
|
boolean |
isSurfaceLockedByOtherThread()
Query if surface is locked by another thread, i.e.
|
int |
lockSurface()
Lock the surface of this native window.
|
void |
removeSurfaceUpdatedListener(SurfaceUpdatedListener l)
Remove the specified
SurfaceUpdatedListener from the list. |
void |
setChosenCapabilities(CapabilitiesImmutable caps)
Sets the capabilities of this instance, allowing upstream API's to refine it, i.e.
|
boolean |
setCursor(PixelRectangle pixelrect,
PointImmutable hotSpot)
Optional method setting cursor in the corresponding on-screen surface/window, if exists.
|
void |
setShallUseOffscreenLayer(boolean v)
Request an offscreen layer, if supported.
|
boolean |
surfaceSwap()
Provide a mechanism to utilize custom (pre-) swap surface
code.
|
void |
surfaceUpdated(Object updater,
NativeSurface ns,
long when)
Notification of a surface update event, eg.
|
String |
toString() |
void |
unlockSurface()
Unlock the surface of this native window
Shall not modify the surface handle, see
NativeSurface.lockSurface() |
public final RectangleImmutable getBounds()
public final int getPixelScale()
public final InsetsImmutable getInsets()
NativeWindowInsets are zero if the window is undecorated, including child windows.
Insets are available only after the native window has been created,
ie. the native window has been made visible.
The top-level window area's top-left corner is located at
The top-level window size isNativeWindow.getX()- getInsets().getLeftWidth()NativeWindow.getY()- getInsets().getTopHeight()
NativeWindow.getWidth()+ getInsets().getTotalWidth()NativeWindow.getHeight()+ getInsets().getTotalHeight()
getInsets in interface NativeWindowpublic final Component getAWTComponent()
public final boolean isApplet()
Applet,
otherwise false. This information is valid only after lockSurface().public final jogamp.nativewindow.jawt.JAWT getJAWT()
lockSurface().public void setShallUseOffscreenLayer(boolean v)
OffscreenLayerOption
Shall be called before the first NativeSurface.lockSurface(),
and hence before realization.
setShallUseOffscreenLayer in interface OffscreenLayerOptionOffscreenLayerOption.getShallUseOffscreenLayer(),
OffscreenLayerOption.isOffscreenLayerSurfaceEnabled()public final boolean getShallUseOffscreenLayer()
OffscreenLayerOptionOffscreenLayerOption.setShallUseOffscreenLayer(boolean).getShallUseOffscreenLayer in interface OffscreenLayerOptionpublic final boolean isOffscreenLayerSurfaceEnabled()
OffscreenLayerOption
This instance is an offscreen layer, if setShallUseOffscreenLayer(true)
has been called before it's realization and first lock and the underlying implementation supports it.
NativeSurface.lockSurface().isOffscreenLayerSurfaceEnabled in interface OffscreenLayerOptionOffscreenLayerOption.setShallUseOffscreenLayer(boolean)public final void attachSurfaceLayer(long layerHandle)
throws NativeWindowException
OffscreenLayerSurfaceImplementation may realize all required resources at this point.
attachSurfaceLayer in interface OffscreenLayerSurfaceNativeWindowException - if #isOffscreenLayerSurfaceEnabled() == false#isOffscreenLayerSurfaceEnabled()public final void detachSurfaceLayer()
throws NativeWindowException
OffscreenLayerSurfacedetachSurfaceLayer in interface OffscreenLayerSurfaceNativeWindowException - if #isOffscreenLayerSurfaceEnabled() == false
or no surface layer is attached.OffscreenLayerSurface.attachSurfaceLayer(long),
#isOffscreenLayerSurfaceEnabled()public final long getAttachedSurfaceLayer()
OffscreenLayerSurfacegetAttachedSurfaceLayer in interface OffscreenLayerSurfacepublic final boolean isSurfaceLayerAttached()
OffscreenLayerSurfaceisSurfaceLayerAttached in interface OffscreenLayerSurfacepublic final void setChosenCapabilities(CapabilitiesImmutable caps)
OffscreenLayerSurfacesetChosenCapabilities in interface OffscreenLayerSurfacepublic final RecursiveLock getLock()
OffscreenLayerSurfacegetLock in interface OffscreenLayerSurfacepublic final boolean setCursor(PixelRectangle pixelrect, PointImmutable hotSpot)
OffscreenLayerSurfacesetCursor in interface OffscreenLayerSurfacepixelrect - cursor pixels, maybe null for default cursorhotSpot - maybe null for default cursorpublic final boolean hideCursor()
OffscreenLayerSurfacehideCursor in interface OffscreenLayerSurfacepublic final int lockSurface()
throws NativeWindowException,
RuntimeException
NativeSurface
The surface handle shall be valid after a successfull call,
ie return a value other than NativeSurface.LOCK_SURFACE_UNLOCKED and NativeSurface.LOCK_SURFACE_NOT_READY,
which is
boolean ok = LOCK_SURFACE_NOT_READY < lockSurface();
The caller may need to take care of the result NativeSurface.LOCK_SURFACE_CHANGED,
where the surface handle is valid but has changed.
This call is blocking until the surface has been locked or a timeout is reached. The latter will throw a runtime exception.
This call allows recursion from the same thread.
The implementation may want to aquire the
application level RecursiveLock
first before proceeding with a native surface lock.
The implementation shall also invoke AbstractGraphicsDevice.lock()
for the initial lock (recursive count zero).
lockSurface in interface NativeSurfaceNativeSurface.LOCK_SUCCESS, NativeSurface.LOCK_SURFACE_CHANGED or NativeSurface.LOCK_SURFACE_NOT_READY.NativeWindowException - if native locking failed, maybe platform relatedRuntimeException - after timeout when waiting for the surface lockRecursiveLockpublic final void unlockSurface()
NativeSurfaceNativeSurface.lockSurface()
The implementation shall also invoke AbstractGraphicsDevice.unlock()
for the final unlock (recursive count zero).
The implementation shall be fail safe, i.e. tolerant in case the native resources are already released / unlocked. In this case the implementation shall simply ignore the call.
unlockSurface in interface NativeSurfaceNativeSurface.lockSurface(),
RecursiveLockpublic final boolean isSurfaceLockedByOtherThread()
NativeSurface
final Thread o = getSurfaceLockOwner();
if( null != o && Thread.currentThread() != o ) { .. }
isSurfaceLockedByOtherThread in interface NativeSurfacepublic final Thread getSurfaceLockOwner()
NativeSurfacegetSurfaceLockOwner in interface NativeSurfacepublic boolean surfaceSwap()
NativeSurfaceThe implementation may itself apply the swapping, in which case true shall be returned.
surfaceSwap in interface NativeSurfacepublic void addSurfaceUpdatedListener(SurfaceUpdatedListener l)
NativeSurfaceSurfaceUpdatedListener to the end of the list.addSurfaceUpdatedListener in interface NativeSurfacepublic void addSurfaceUpdatedListener(int index,
SurfaceUpdatedListener l)
throws IndexOutOfBoundsException
NativeSurfaceSurfaceUpdatedListener at the
specified position in the list.addSurfaceUpdatedListener in interface NativeSurfaceindex - Position where the listener will be inserted.
Should be within (0 <= index && index <= size()).
An index value of -1 is interpreted as the end of the list, size().l - The listener object to be insertedIndexOutOfBoundsException - If the index is not within (0 <= index && index <= size()), or -1public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l)
NativeSurfaceSurfaceUpdatedListener from the list.removeSurfaceUpdatedListener in interface NativeSurfacepublic void surfaceUpdated(Object updater, NativeSurface ns, long when)
SurfaceUpdatedListenersurfaceUpdated in interface SurfaceUpdatedListenerupdater - is the caller object who updated the surface,
e.g. a JOGL GLDrawable.ns - the updated NativeSurfacewhen - the time in ms, when the surface was updatedpublic long getSurfaceHandle()
NativeSurface
The surface handle should be set/update by NativeSurface.lockSurface(),
where NativeSurface.unlockSurface() is not allowed to modify it.
After NativeSurface.unlockSurface() it is no more guaranteed
that the surface handle is still valid.
The surface handle shall reflect the platform one
for all drawable surface operations, e.g. opengl, swap-buffer.
On X11 this returns an entity of type Window,
since there is no differentiation of surface and window there.
On Microsoft Windows this returns an entity of type HDC.
getSurfaceHandle in interface NativeSurfacepublic final AbstractGraphicsConfiguration getGraphicsConfiguration()
NativeSurface
In case the implementation utilizes a delegation pattern to wrap abstract toolkits,
this method shall return the native AbstractGraphicsConfiguration via AbstractGraphicsConfiguration.getNativeGraphicsConfiguration().
getGraphicsConfiguration in interface NativeSurfaceAbstractGraphicsConfiguration.getNativeGraphicsConfiguration(),
javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)public final long getDisplayHandle()
NativeSurfacegetDisplayHandle in interface NativeSurfacepublic final int getScreenIndex()
NativeSurfacegetScreenIndex in interface NativeSurfacepublic final int getSurfaceWidth()
NativeSurfacegetSurfaceWidth in interface NativeSurfaceNativeWindow.getWidth(),
NativeSurface.convertToWindowUnits(int[])public final int getSurfaceHeight()
NativeSurfacegetSurfaceHeight in interface NativeSurfaceNativeWindow.getHeight(),
NativeSurface.convertToWindowUnits(int[])public final int getWidth()
NativeWindowgetWidth in interface NativeWindowNativeSurface.getSurfaceWidth()public final int getHeight()
NativeWindowgetHeight in interface NativeWindowNativeSurface.getSurfaceHeight()public final int[] convertToWindowUnits(int[] pixelUnitsAndResult)
NativeSurfaceconvertToWindowUnits in interface NativeSurfacepixelUnitsAndResult - int[2] storage holding the pixel units for the x- and y-coord to convert
and the resulting values.public final int[] convertToPixelUnits(int[] windowUnitsAndResult)
NativeSurfaceconvertToPixelUnits in interface NativeSurfacewindowUnitsAndResult - int[2] storage holding the window units for the x- and y-coord to convert
and the resulting values.public void destroy()
NativeWindowdestroy in interface NativeWindowpublic final NativeWindow getParent()
getParent in interface NativeWindowpublic long getWindowHandle()
NativeWindowThe window handle shall reflect the platform one for all window related operations, e.g. open, close, resize.
On X11 this returns an entity of type Window.
On Microsoft Windows this returns an entity of type HWND.
getWindowHandle in interface NativeWindowpublic final int getX()
NativeWindowIf no parent exist (top-level window), this coordinate equals the screen coordinate.
Since the position reflects the client area, it does not include the insets.
See Coordinate System.
getX in interface NativeWindowNativeWindow.getInsets(),
NativeWindow.getLocationOnScreen(Point)public final int getY()
NativeWindowIf no parent exist (top-level window), this coordinate equals the screen coordinate.
Since the position reflects the client area, it does not include the insets.
See Coordinate System.
getY in interface NativeWindowNativeWindow.getInsets(),
NativeWindow.getLocationOnScreen(Point)public Point getLocationOnScreen(Point storage)
If Point is not null, it is translated about the resulting screen position
and returned.
See Coordinate System.
Since the position reflects the client area, it does not include the insets.
This JAWT default implementation is currently still using
a blocking implementation. It first attempts to retrieve the location
via a native implementation. If this fails, it tries the blocking AWT implementation.
If the latter fails due to an external AWT tree-lock, the non block
implementation getLocationOnScreenNonBlocking(Point, Component) is being used.
The latter simply traverse up to the AWT component tree and sums the rel. position.
We have to determine whether the latter is good enough for all cases,
currently only OS X utilizes the non blocking method per default.
getLocationOnScreen in interface NativeWindowstorage - Optional Point storage.
If not null, null, it is translated about the resulting screen position
and returned.NativeWindow.getX(),
NativeWindow.getY(),
NativeWindow.getInsets()public boolean hasFocus()
NativeWindowhasFocus in interface NativeWindowCopyright 2010 JogAmp Community.