summaryrefslogtreecommitdiffstats
path: root/src/newt/classes/com/sun/javafx
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-10-03 20:36:23 -0700
committerSven Gothel <[email protected]>2009-10-03 20:36:23 -0700
commit4d4b7c52d032d0c9302e4e16560f2e874e31b8bc (patch)
tree6e74ed48af864dcd3ca37b5d8ad45f07c30be2a7 /src/newt/classes/com/sun/javafx
parent907c249a5a6f80d10912440aa073ba42b94ae6de (diff)
surfaceupdated:: NativeWindow: passing 'updater'; NEWT: adding event listener
Diffstat (limited to 'src/newt/classes/com/sun/javafx')
-rw-r--r--src/newt/classes/com/sun/javafx/newt/EventListener.java7
-rw-r--r--src/newt/classes/com/sun/javafx/newt/SurfaceUpdatedListener.java48
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/Window.java56
-rw-r--r--src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java8
4 files changed, 105 insertions, 14 deletions
diff --git a/src/newt/classes/com/sun/javafx/newt/EventListener.java b/src/newt/classes/com/sun/javafx/newt/EventListener.java
index 2af63bd7c..a312752fe 100644
--- a/src/newt/classes/com/sun/javafx/newt/EventListener.java
+++ b/src/newt/classes/com/sun/javafx/newt/EventListener.java
@@ -35,9 +35,10 @@ package com.sun.javafx.newt;
public interface EventListener
{
- public static final int WINDOW = 1 << 0;
- public static final int MOUSE = 1 << 1;
- public static final int KEY = 1 << 2;
+ public static final int WINDOW = 1 << 0;
+ public static final int MOUSE = 1 << 1;
+ public static final int KEY = 1 << 2;
+ public static final int SURFACE = 1 << 3;
}
diff --git a/src/newt/classes/com/sun/javafx/newt/SurfaceUpdatedListener.java b/src/newt/classes/com/sun/javafx/newt/SurfaceUpdatedListener.java
new file mode 100644
index 000000000..a1b0918e6
--- /dev/null
+++ b/src/newt/classes/com/sun/javafx/newt/SurfaceUpdatedListener.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution 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 Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+
+package com.sun.javafx.newt;
+
+import javax.media.nativewindow.NativeWindow;
+
+public interface SurfaceUpdatedListener extends EventListener {
+ /** Notification of a surface update event.
+ *
+ * @param updater is the caller object who updated the surface,
+ * e.g. a JOGL GLDrawable.
+ * @param window the NativeWindow, which surface is updated
+ * @param when the time in ms, when the surface was updated
+ */
+ public void surfaceUpdated(Object updater, NativeWindow window, long when) ;
+}
+
diff --git a/src/newt/classes/com/sun/javafx/newt/Window.java b/src/newt/classes/com/sun/javafx/newt/Window.java
index da31b084c..1f55eee26 100755
--- a/src/newt/classes/com/sun/javafx/newt/Window.java
+++ b/src/newt/classes/com/sun/javafx/newt/Window.java
@@ -182,6 +182,10 @@ public abstract class Window implements NativeWindow
", "+screen+
", wrappedWindow "+getWrappedWindow());
+ sb.append(", SurfaceUpdatedListeners num "+surfaceUpdatedListeners.size()+" [");
+ for (Iterator iter = surfaceUpdatedListeners.iterator(); iter.hasNext(); ) {
+ sb.append(iter.next()+", ");
+ }
sb.append(", WindowListeners num "+windowListeners.size()+" [");
for (Iterator iter = windowListeners.iterator(); iter.hasNext(); ) {
sb.append(iter.next()+", ");
@@ -267,6 +271,9 @@ public abstract class Window implements NativeWindow
if(DEBUG_WINDOW_EVENT) {
System.out.println("Window.destroy() start "+Thread.currentThread().getName());
}
+ synchronized(surfaceUpdatedListeners) {
+ surfaceUpdatedListeners = new ArrayList();
+ }
synchronized(windowListeners) {
windowListeners = new ArrayList();
}
@@ -305,8 +312,6 @@ public abstract class Window implements NativeWindow
return false;
}
- public void surfaceUpdated() {}
-
protected void clearEventMask() {
eventMask=0;
}
@@ -451,6 +456,52 @@ public abstract class Window implements NativeWindow
public abstract boolean setFullscreen(boolean fullscreen);
//
+ // SurfaceUpdatedListener Support
+ //
+ private ArrayList surfaceUpdatedListeners = new ArrayList();
+
+ public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) {
+ if(l == null) {
+ return;
+ }
+ synchronized(surfaceUpdatedListeners) {
+ ArrayList newSurfaceUpdatedListeners = (ArrayList) surfaceUpdatedListeners.clone();
+ newSurfaceUpdatedListeners.add(l);
+ surfaceUpdatedListeners = newSurfaceUpdatedListeners;
+ }
+ }
+
+ public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) {
+ if (l == null) {
+ return;
+ }
+ synchronized(surfaceUpdatedListeners) {
+ ArrayList newSurfaceUpdatedListeners = (ArrayList) surfaceUpdatedListeners.clone();
+ newSurfaceUpdatedListeners.remove(l);
+ surfaceUpdatedListeners = newSurfaceUpdatedListeners;
+ }
+ }
+
+ public SurfaceUpdatedListener[] getSurfaceUpdatedListener() {
+ synchronized(surfaceUpdatedListeners) {
+ return (SurfaceUpdatedListener[]) surfaceUpdatedListeners.toArray();
+ }
+ }
+
+ public void surfaceUpdated(Object updater) {
+ long when = System.currentTimeMillis();
+
+ ArrayList listeners = null;
+ synchronized(surfaceUpdatedListeners) {
+ listeners = surfaceUpdatedListeners;
+ }
+ for(Iterator i = listeners.iterator(); i.hasNext(); ) {
+ SurfaceUpdatedListener l = (SurfaceUpdatedListener) i.next();
+ l.surfaceUpdated(updater, this, when);
+ }
+ }
+
+ //
// MouseListener Support
//
@@ -805,5 +856,4 @@ public abstract class Window implements NativeWindow
}
return sb.toString();
}
-
}
diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java b/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java
index 90a3d18ba..6e9d4aaf6 100644
--- a/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java
@@ -667,14 +667,6 @@ public class GLWindow extends Window implements GLAutoDrawable {
return super.surfaceSwap();
}
- public void surfaceUpdated() {
- if(null!=drawable) {
- drawable.getNativeWindow().surfaceUpdated();
- } else {
- super.surfaceUpdated();
- }
- }
-
public long getWindowHandle() {
if(null!=drawable) return drawable.getNativeWindow().getWindowHandle();
return super.getWindowHandle();