aboutsummaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/nativewindow/classes/com')
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/impl/ProxySurface.java (renamed from src/nativewindow/classes/com/jogamp/nativewindow/impl/NullWindow.java)56
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTWindow.java96
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java3
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/util/Rectangle.java61
4 files changed, 101 insertions, 115 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/NullWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/ProxySurface.java
index fc6242968..5e6487ae8 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/NullWindow.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/ProxySurface.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -36,16 +37,19 @@
package com.jogamp.nativewindow.impl;
-import javax.media.nativewindow.*;
-import com.jogamp.nativewindow.impl.RecursiveToolkitLock;
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.NativeSurface;
+import javax.media.nativewindow.NativeWindow;
+import javax.media.nativewindow.NativeWindowException;
+import javax.media.nativewindow.SurfaceChangeable;
-public class NullWindow implements NativeWindow, SurfaceChangeable {
+public class ProxySurface implements NativeSurface, SurfaceChangeable {
private RecursiveToolkitLock recurLock = new RecursiveToolkitLock();
protected int width, height, scrnIndex;
protected long surfaceHandle, displayHandle;
protected AbstractGraphicsConfiguration config;
- public NullWindow(AbstractGraphicsConfiguration cfg) {
+ public ProxySurface(AbstractGraphicsConfiguration cfg) {
invalidate();
config = cfg;
displayHandle=cfg.getScreen().getDevice().getHandle();
@@ -58,6 +62,10 @@ public class NullWindow implements NativeWindow, SurfaceChangeable {
protected void initNative() throws NativeWindowException {
}
+ public NativeWindow getParent() {
+ return null;
+ }
+
public void destroy() {
invalidate();
}
@@ -97,7 +105,23 @@ public class NullWindow implements NativeWindow, SurfaceChangeable {
return false;
}
- public void surfaceUpdated(Object updater, NativeWindow window, long when) { }
+ public long getSurfaceHandle() {
+ return surfaceHandle;
+ }
+
+ public int getWidth() {
+ return width;
+ }
+
+ public int getHeight() {
+ return height;
+ }
+
+ public AbstractGraphicsConfiguration getGraphicsConfiguration() {
+ return config;
+ }
+
+ public void surfaceUpdated(Object updater, NativeSurface ns, long when) { }
public long getDisplayHandle() {
return displayHandle;
@@ -105,36 +129,16 @@ public class NullWindow implements NativeWindow, SurfaceChangeable {
public int getScreenIndex() {
return scrnIndex;
}
- public long getWindowHandle() {
- return 0;
- }
- public long getSurfaceHandle() {
- return surfaceHandle;
- }
+
public void setSurfaceHandle(long surfaceHandle) {
this.surfaceHandle=surfaceHandle;
}
- public AbstractGraphicsConfiguration getGraphicsConfiguration() {
- return config;
- }
-
- public final boolean isTerminalObject() {
- return true;
- }
public void setSize(int width, int height) {
this.width=width;
this.height=height;
}
- public int getWidth() {
- return width;
- }
-
- public int getHeight() {
- return height;
- }
-
public String toString() {
return "NullWindow[config "+config+
", displayHandle 0x"+Long.toHexString(getDisplayHandle())+
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 1cd63235d..0cb861453 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTWindow.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTWindow.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -36,14 +37,14 @@
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;
import java.awt.GraphicsEnvironment;
import javax.media.nativewindow.*;
import com.jogamp.nativewindow.impl.*;
+import javax.media.nativewindow.util.Point;
+import javax.media.nativewindow.util.Rectangle;
public abstract class JAWTWindow implements NativeWindow {
protected static final boolean DEBUG = Debug.debug("JAWT");
@@ -79,21 +80,12 @@ public abstract class JAWTWindow implements NativeWindow {
protected abstract void initNative() throws NativeWindowException;
- public synchronized void invalidate() {
+ protected synchronized void invalidate() {
component = null;
drawable= 0;
bounds = new Rectangle();
}
- public synchronized void destroy() {
- if(null!=component) {
- if(component instanceof Window) {
- ((Window)component).dispose();
- }
- }
- invalidate();
- }
-
protected void updateBounds(JAWT_Rectangle jawtBounds) {
bounds.setX(jawtBounds.getX());
bounds.setY(jawtBounds.getY());
@@ -101,6 +93,25 @@ public abstract class JAWTWindow implements NativeWindow {
bounds.setHeight(jawtBounds.getHeight());
}
+ /** @return the JAWT_DrawingSurfaceInfo's (JAWT_Rectangle) bounds, updated with lock */
+ public Rectangle getBounds() { return bounds; }
+
+ public Component getAWTComponent() {
+ return component;
+ }
+
+ //
+ // SurfaceUpdateListener
+ //
+
+ public void surfaceUpdated(Object updater, NativeSurface ns, long when) {
+ // nop
+ }
+
+ //
+ // NativeSurface
+ //
+
private RecursiveToolkitLock recurLock = new RecursiveToolkitLock();
protected abstract int lockSurfaceImpl() throws NativeWindowException;
@@ -148,15 +159,6 @@ public abstract class JAWTWindow implements NativeWindow {
public void surfaceUpdated(Object updater, NativeWindow window, long when) { }
- public long getDisplayHandle() {
- return config.getScreen().getDevice().getHandle();
- }
- public int getScreenIndex() {
- return config.getScreen().getIndex();
- }
- public long getWindowHandle() {
- return drawable;
- }
public long getSurfaceHandle() {
return drawable;
}
@@ -164,8 +166,12 @@ public abstract class JAWTWindow implements NativeWindow {
return config;
}
- public Object getWrappedWindow() {
- return component;
+ public long getDisplayHandle() {
+ return config.getScreen().getDevice().getHandle();
+ }
+
+ public int getScreenIndex() {
+ return config.getScreen().getIndex();
}
public void setSize(int width, int height) {
@@ -180,8 +186,44 @@ 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; }
+ //
+ // NativeWindow
+ //
+
+ public synchronized void destroy() {
+ if(null!=component) {
+ if(component instanceof Window) {
+ ((Window)component).dispose();
+ }
+ }
+ invalidate();
+ }
+
+ public NativeWindow getParent() {
+ return null;
+ }
+
+ public long getWindowHandle() {
+ return drawable;
+ }
+
+ public int getX() {
+ return component.getX();
+ }
+
+ public int getY() {
+ return component.getY();
+ }
+
+ public Point getLocationOnScreen(Point point) {
+ java.awt.Point awtLOS = component.getLocationOnScreen();
+ int dx = (int) ( awtLOS.getX() + .5 ) ;
+ int dy = (int) ( awtLOS.getY() + .5 ) ;
+ if(null!=point) {
+ return point.translate(dx, dy);
+ }
+ return new Point(dx, dy);
+ }
public String toString() {
StringBuffer sb = new StringBuffer();
@@ -191,14 +233,14 @@ public abstract class JAWTWindow implements NativeWindow {
", surfaceHandle 0x"+Long.toHexString(getSurfaceHandle())+
", bounds "+bounds);
if(null!=component) {
- sb.append(", pos "+component.getX()+"/"+component.getY()+", size "+getWidth()+"x"+getHeight()+
+ sb.append(", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+
", visible "+component.isVisible());
} else {
sb.append(", component NULL");
}
sb.append(", lockedExt "+isSurfaceLockedByOtherThread()+
",\n\tconfig "+config+
- ",\n\twrappedWindow "+getWrappedWindow()+"]");
+ ",\n\tawtComponent "+getAWTComponent()+"]");
return sb.toString();
}
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 c3b3682fd..b6da7166d 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
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -56,7 +57,7 @@ public class WindowsJAWTWindow extends JAWTWindow {
protected void initNative() throws NativeWindowException {
}
- public synchronized void invalidate() {
+ protected synchronized void invalidate() {
super.invalidate();
windowHandle = 0;
}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/util/Rectangle.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/Rectangle.java
deleted file mode 100644
index 9f7711443..000000000
--- a/src/nativewindow/classes/com/jogamp/nativewindow/util/Rectangle.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``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 JogAmp Community OR
- * CONTRIBUTORS 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.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-
-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+"]");
- }
-}
-