diff options
Diffstat (limited to 'src/newt/classes/com')
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(); |