summaryrefslogtreecommitdiffstats
path: root/src/newt
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-04-24 05:11:29 +0200
committerSven Gothel <[email protected]>2010-04-24 05:11:29 +0200
commit1ad8c39df6b097c80ba7a85badf555e7f669cc3f (patch)
tree740606f85dafdef5d5958498b080873c7bf188dd /src/newt
parent778225504c00c7ca03386b6eabfbda929542130f (diff)
NEWT/AWT Interoperability
- Moved all event classes to com.jogamp.newt.event and the new AWT event helper to com.jogamp.newt.awt.event - Added Newt<Type>Adapter for convenience - Added AWT<Type>Adapter for - Using AWT agnostic NEWT event listener see com.jogamp.test.junit.jogl.demos.gl2.gears.TestGearsNEWT even for AWT see com.jogamp.test.junit.jogl.demos.gl2.gears.TestGearsAWT (Nice idea by mbien) - Forwarding AWT events to NEWT (refactoring) Misc - GLDrawableFactory.shutdown() is now protected and called by the JVM shutdown hook. Hence removing the validate().
Diffstat (limited to 'src/newt')
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/Display.java35
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/Window.java77
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/AWTDisplay.java113
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/AWTWindow.java142
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/event/AWTAdapter.java155
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/event/AWTKeyAdapter.java80
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/event/AWTMouseAdapter.java117
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/event/AWTNewtEventFactory.java140
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/event/AWTWindowAdapter.java126
-rw-r--r--src/newt/classes/com/jogamp/newt/event/Event.java73
-rw-r--r--src/newt/classes/com/jogamp/newt/event/KeyAdapter.java45
-rw-r--r--src/newt/classes/com/jogamp/newt/event/MouseAdapter.java55
-rw-r--r--src/newt/classes/com/jogamp/newt/event/WindowAdapter.java48
-rw-r--r--src/newt/classes/com/jogamp/newt/intel/gdl/Display.java2
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/macosx/MacDisplay.java2
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/macosx/MacWindow.java1
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java12
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Display.java2
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/opengl/kd/KDDisplay.java2
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/opengl/kd/KDWindow.java1
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/windows/WindowsDisplay.java2
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/windows/WindowsWindow.java1
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/x11/X11Display.java2
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/x11/X11Window.java1
24 files changed, 948 insertions, 286 deletions
diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java
index 2bc99475c..931c16cd9 100755
--- a/src/newt/classes/com/jogamp/newt/Display.java
+++ b/src/newt/classes/com/jogamp/newt/Display.java
@@ -33,6 +33,7 @@
package com.jogamp.newt;
+import com.jogamp.newt.event.*;
import javax.media.nativewindow.*;
import com.jogamp.newt.impl.Debug;
import com.jogamp.newt.util.EDTUtil;
@@ -264,7 +265,39 @@ public abstract class Display {
return "NEWT-Display["+name+", refCount "+refCount+", "+aDevice+"]";
}
- protected abstract void dispatchMessages();
+ protected abstract void dispatchMessagesNative();
+
+ private LinkedList/*<Event>*/ events = new LinkedList();
+
+ protected void dispatchMessages() {
+ Event e;
+ do {
+ synchronized(events) {
+ if (!events.isEmpty()) {
+ e = (Event) events.removeFirst();
+ } else {
+ e = null;
+ }
+ }
+ if (e != null) {
+ Object source = e.getSource();
+ if(source instanceof Window) {
+ ((Window)source).sendEvent(e);
+ } else {
+ throw new RuntimeException("Event source not a NEWT Window: "+source.getClass().getName()+", "+source);
+ }
+ }
+ } while (e != null);
+
+ dispatchMessagesNative();
+ }
+
+ public void enqueueEvent(com.jogamp.newt.event.Event e) {
+ synchronized(events) {
+ events.add(e);
+ }
+ }
+
/** Default impl. nop - Currently only X11 needs a Display lock */
protected void lockDisplay() { }
diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java
index b1f8b3977..33b971578 100755
--- a/src/newt/classes/com/jogamp/newt/Window.java
+++ b/src/newt/classes/com/jogamp/newt/Window.java
@@ -33,6 +33,7 @@
package com.jogamp.newt;
+import com.jogamp.newt.event.*;
import com.jogamp.newt.impl.Debug;
import com.jogamp.newt.util.EDTUtil;
@@ -571,8 +572,24 @@ public abstract class Window implements NativeWindow
}
}
+ //
+ // Generic Event Support
+ //
+
+ protected void sendEvent(Event e) {
+ if(e instanceof WindowEvent) {
+ sendWindowEvent((WindowEvent)e);
+ } else if(e instanceof KeyEvent) {
+ sendKeyEvent((KeyEvent)e);
+ } else if(e instanceof MouseEvent) {
+ sendMouseEvent((MouseEvent)e);
+ } else if(e instanceof PaintEvent) {
+ sendPaintEvent((PaintEvent)e);
+ }
+ }
+
//
- // MouseListener Support
+ // MouseListener/Event Support
//
public void addMouseListener(MouseListener l) {
@@ -609,6 +626,7 @@ public abstract class Window implements NativeWindow
private int lastMouseClickCount = 0; // last mouse button click count
public static final int ClickTimeout = 300;
+ /** Be aware that this method synthesizes the events: MouseClicked and MouseDragged */
protected void sendMouseEvent(int eventType, int modifiers,
int x, int y, int button, int rotation) {
if(x<0||y<0||x>=width||y>=height) {
@@ -633,13 +651,13 @@ public abstract class Window implements NativeWindow
}
lastMousePressed=when;
mouseButtonPressed=button;
- e = new MouseEvent(true, eventType, this, when,
+ e = new MouseEvent(eventType, this, when,
modifiers, x, y, lastMouseClickCount, button, 0);
} else if(MouseEvent.EVENT_MOUSE_RELEASED==eventType) {
- e = new MouseEvent(true, eventType, this, when,
+ e = new MouseEvent(eventType, this, when,
modifiers, x, y, lastMouseClickCount, button, 0);
if(when-lastMousePressed<ClickTimeout) {
- eClicked = new MouseEvent(true, MouseEvent.EVENT_MOUSE_CLICKED, this, when,
+ eClicked = new MouseEvent(MouseEvent.EVENT_MOUSE_CLICKED, this, when,
modifiers, x, y, lastMouseClickCount, button, 0);
} else {
lastMouseClickCount=0;
@@ -648,23 +666,29 @@ public abstract class Window implements NativeWindow
mouseButtonPressed=0;
} else if(MouseEvent.EVENT_MOUSE_MOVED==eventType) {
if (mouseButtonPressed>0) {
- e = new MouseEvent(true, MouseEvent.EVENT_MOUSE_DRAGGED, this, when,
+ e = new MouseEvent(MouseEvent.EVENT_MOUSE_DRAGGED, this, when,
modifiers, x, y, 1, mouseButtonPressed, 0);
} else {
- e = new MouseEvent(true, eventType, this, when,
+ e = new MouseEvent(eventType, this, when,
modifiers, x, y, 0, button, 0);
}
} else if(MouseEvent.EVENT_MOUSE_WHEEL_MOVED==eventType) {
- e = new MouseEvent(true, eventType, this, when, modifiers, x, y, 0, button, rotation);
+ e = new MouseEvent(eventType, this, when, modifiers, x, y, 0, button, rotation);
} else {
- e = new MouseEvent(true, eventType, this, when, modifiers, x, y, 0, button, 0);
+ e = new MouseEvent(eventType, this, when, modifiers, x, y, 0, button, 0);
+ }
+ sendMouseEvent(e);
+ if(null!=eClicked) {
+ if(DEBUG_MOUSE_EVENT) {
+ System.out.println("sendMouseEvent: synthesized MOUSE_CLICKED event");
+ }
+ sendMouseEvent(eClicked);
}
+ }
+ protected void sendMouseEvent(MouseEvent e) {
if(DEBUG_MOUSE_EVENT) {
System.out.println("sendMouseEvent: event: "+e);
- if(null!=eClicked) {
- System.out.println("sendMouseEvent: event Clicked: "+eClicked);
- }
}
ArrayList listeners = null;
@@ -688,9 +712,6 @@ public abstract class Window implements NativeWindow
break;
case MouseEvent.EVENT_MOUSE_RELEASED:
l.mouseReleased(e);
- if(null!=eClicked) {
- l.mouseClicked(eClicked);
- }
break;
case MouseEvent.EVENT_MOUSE_MOVED:
l.mouseMoved(e);
@@ -708,7 +729,7 @@ public abstract class Window implements NativeWindow
}
//
- // KeyListener Support
+ // KeyListener/Event Support
//
public void addKeyListener(KeyListener l) {
@@ -742,8 +763,11 @@ public abstract class Window implements NativeWindow
private ArrayList keyListeners = new ArrayList();
protected void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) {
- KeyEvent e = new KeyEvent(true, eventType, this, System.currentTimeMillis(),
- modifiers, keyCode, keyChar);
+ sendKeyEvent(new KeyEvent(eventType, this, System.currentTimeMillis(),
+ modifiers, keyCode, keyChar) );
+ }
+
+ protected void sendKeyEvent(KeyEvent e) {
if(DEBUG_KEY_EVENT) {
System.out.println("sendKeyEvent: "+e);
}
@@ -753,7 +777,7 @@ public abstract class Window implements NativeWindow
}
for(Iterator i = listeners.iterator(); i.hasNext(); ) {
KeyListener l = (KeyListener) i.next();
- switch(eventType) {
+ switch(e.getEventType()) {
case KeyEvent.EVENT_KEY_PRESSED:
l.keyPressed(e);
break;
@@ -770,7 +794,7 @@ public abstract class Window implements NativeWindow
}
//
- // WindowListener Support
+ // WindowListener/Event Support
//
private ArrayList windowListeners = new ArrayList();
@@ -804,7 +828,10 @@ public abstract class Window implements NativeWindow
}
protected void sendWindowEvent(int eventType) {
- WindowEvent e = new WindowEvent(true, eventType, this, System.currentTimeMillis());
+ sendWindowEvent( new WindowEvent(eventType, this, System.currentTimeMillis()) );
+ }
+
+ protected void sendWindowEvent(WindowEvent e) {
if(DEBUG_WINDOW_EVENT) {
System.out.println("sendWindowEvent: "+e);
}
@@ -814,7 +841,7 @@ public abstract class Window implements NativeWindow
}
for(Iterator i = listeners.iterator(); i.hasNext(); ) {
WindowListener l = (WindowListener) i.next();
- switch(eventType) {
+ switch(e.getEventType()) {
case WindowEvent.EVENT_WINDOW_RESIZED:
l.windowResized(e);
break;
@@ -840,7 +867,7 @@ public abstract class Window implements NativeWindow
//
- // WindowListener Support
+ // PaintListener/Event Support
//
private ArrayList paintListeners = new ArrayList();
@@ -868,8 +895,10 @@ public abstract class Window implements NativeWindow
}
protected void sendPaintEvent(int eventType, int x, int y, int w, int h) {
- PaintEvent e =
- new PaintEvent(eventType, this, System.currentTimeMillis(), x, y, w, h);
+ sendPaintEvent( new PaintEvent(eventType, this, System.currentTimeMillis(), x, y, w, h) );
+ }
+
+ protected void sendPaintEvent(PaintEvent e) {
ArrayList listeners = null;
synchronized(paintListeners) {
listeners = paintListeners;
diff --git a/src/newt/classes/com/jogamp/newt/awt/AWTDisplay.java b/src/newt/classes/com/jogamp/newt/awt/AWTDisplay.java
index 09ce10017..d1fc1bc85 100644
--- a/src/newt/classes/com/jogamp/newt/awt/AWTDisplay.java
+++ b/src/newt/classes/com/jogamp/newt/awt/AWTDisplay.java
@@ -54,115 +54,6 @@ public class AWTDisplay extends Display {
protected void closeNative() { }
- public void dispatchMessages() {
- AWTEventWrapper w;
- do {
- synchronized(this) {
- if (!events.isEmpty()) {
- w = (AWTEventWrapper) events.removeFirst();
- } else {
- w = null;
- }
- }
- if (w != null) {
- switch (w.getType()) {
- case com.jogamp.newt.WindowEvent.EVENT_WINDOW_RESIZED:
- case com.jogamp.newt.WindowEvent.EVENT_WINDOW_MOVED:
- case com.jogamp.newt.WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY:
- w.getWindow().sendWindowEvent(w.getType());
- break;
-
- case com.jogamp.newt.MouseEvent.EVENT_MOUSE_CLICKED:
- case com.jogamp.newt.MouseEvent.EVENT_MOUSE_ENTERED:
- case com.jogamp.newt.MouseEvent.EVENT_MOUSE_EXITED:
- case com.jogamp.newt.MouseEvent.EVENT_MOUSE_PRESSED:
- case com.jogamp.newt.MouseEvent.EVENT_MOUSE_RELEASED:
- case com.jogamp.newt.MouseEvent.EVENT_MOUSE_MOVED:
- case com.jogamp.newt.MouseEvent.EVENT_MOUSE_DRAGGED:
- case com.jogamp.newt.MouseEvent.EVENT_MOUSE_WHEEL_MOVED:
- {
- MouseEvent e = (MouseEvent) w.getEvent();
- int rotation = 0;
- if (e instanceof MouseWheelEvent) {
- rotation = ((MouseWheelEvent)e).getWheelRotation();
- }
- w.getWindow().sendMouseEvent(w.getType(), convertModifiers(e),
- e.getX(), e.getY(), convertButton(e),
- rotation);
- }
- break;
-
- case com.jogamp.newt.KeyEvent.EVENT_KEY_PRESSED:
- case com.jogamp.newt.KeyEvent.EVENT_KEY_RELEASED:
- case com.jogamp.newt.KeyEvent.EVENT_KEY_TYPED:
- {
- KeyEvent e = (KeyEvent) w.getEvent();
- w.getWindow().sendKeyEvent(w.getType(), convertModifiers(e),
- e.getKeyCode(), e.getKeyChar());
- }
- break;
-
- default:
- throw new NativeWindowException("Unknown event type " + w.getType());
- }
- if(Window.DEBUG_MOUSE_EVENT) {
- System.out.println("dispatchMessages: "+w.getWindow()+" in event:"+w.getEvent());
- }
- }
- } while (w != null);
- }
-
- protected void enqueueEvent(AWTWindow w, int type, InputEvent e) {
- AWTEventWrapper wrapper = new AWTEventWrapper(w, type, e);
- synchronized(this) {
- events.add(wrapper);
- }
- }
-
- private LinkedList/*<AWTEventWrapper>*/ events = new LinkedList();
-
- static class AWTEventWrapper {
- AWTWindow window;
- int type;
- InputEvent e;
-
- AWTEventWrapper(AWTWindow w, int type, InputEvent e) {
- this.window = w;
- this.type = type;
- this.e = e;
- }
-
- public AWTWindow getWindow() {
- return window;
- }
-
- public int getType() {
- return type;
- }
-
- public InputEvent getEvent() {
- return e;
- }
- }
-
- private static int convertModifiers(InputEvent e) {
- int newtMods = 0;
- int mods = e.getModifiers();
- if ((mods & InputEvent.SHIFT_MASK) != 0) newtMods |= com.jogamp.newt.InputEvent.SHIFT_MASK;
- if ((mods & InputEvent.CTRL_MASK) != 0) newtMods |= com.jogamp.newt.InputEvent.CTRL_MASK;
- if ((mods & InputEvent.META_MASK) != 0) newtMods |= com.jogamp.newt.InputEvent.META_MASK;
- if ((mods & InputEvent.ALT_MASK) != 0) newtMods |= com.jogamp.newt.InputEvent.ALT_MASK;
- if ((mods & InputEvent.ALT_GRAPH_MASK) != 0) newtMods |= com.jogamp.newt.InputEvent.ALT_GRAPH_MASK;
- return newtMods;
- }
-
- private static int convertButton(MouseEvent e) {
- switch (e.getButton()) {
- case MouseEvent.BUTTON1: return com.jogamp.newt.MouseEvent.BUTTON1;
- case MouseEvent.BUTTON2: return com.jogamp.newt.MouseEvent.BUTTON2;
- case MouseEvent.BUTTON3: return com.jogamp.newt.MouseEvent.BUTTON3;
- }
- return 0;
- }
-
+ protected void dispatchMessagesNative() { /* nop */ }
}
+
diff --git a/src/newt/classes/com/jogamp/newt/awt/AWTWindow.java b/src/newt/classes/com/jogamp/newt/awt/AWTWindow.java
index 7beeed44b..daeaa3e4e 100644
--- a/src/newt/classes/com/jogamp/newt/awt/AWTWindow.java
+++ b/src/newt/classes/com/jogamp/newt/awt/AWTWindow.java
@@ -33,6 +33,8 @@
package com.jogamp.newt.awt;
+import com.jogamp.newt.awt.event.*;
+
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Container;
@@ -43,7 +45,6 @@ import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
-import java.awt.event.*;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.*;
@@ -119,18 +120,20 @@ public class AWTWindow extends Window {
}
container.setLayout(new BorderLayout());
canvas = new AWTCanvas(caps);
- Listener listener = new Listener(awtWindow);
- canvas.addMouseListener(listener);
- canvas.addMouseMotionListener(listener);
- canvas.addKeyListener(listener);
- canvas.addComponentListener(listener);
+
+ addWindowListener(new LocalWindowListener());
+
+ new AWTMouseAdapter(awtWindow).addTo(canvas); // fwd all AWT Mouse events to here
+ new AWTKeyAdapter(awtWindow).addTo(canvas); // fwd all AWT Key events to here
+
+ // canvas.addComponentListener(listener);
container.add(canvas, BorderLayout.CENTER);
container.setSize(width, height);
container.setLocation(x, y);
- container.addComponentListener(new MoveListener(awtWindow));
+ new AWTWindowAdapter(awtWindow).addTo(container); // fwd all AWT Window events to here
+
if(null!=frame) {
frame.setUndecorated(undecorated||fullscreen);
- frame.addWindowListener(new WindowEventListener(awtWindow));
}
}
});
@@ -315,127 +318,18 @@ public class AWTWindow extends Window {
}
}
- private static final int WINDOW_EVENT = 1;
- private static final int KEY_EVENT = 2;
- private static final int MOUSE_EVENT = 3;
-
- class MoveListener implements ComponentListener {
- private AWTWindow window;
- private AWTDisplay display;
-
- public MoveListener(AWTWindow w) {
- window = w;
- display = (AWTDisplay)window.getScreen().getDisplay();
- }
-
- public void componentResized(ComponentEvent e) {
- }
-
- public void componentMoved(ComponentEvent e) {
+ class LocalWindowListener extends com.jogamp.newt.event.WindowAdapter {
+ public void windowMoved(com.jogamp.newt.event.WindowEvent e) {
if(null!=container) {
x = container.getX();
y = container.getY();
}
- display.enqueueEvent(window, com.jogamp.newt.WindowEvent.EVENT_WINDOW_MOVED, null);
- }
-
- public void componentShown(ComponentEvent e) {
- }
-
- public void componentHidden(ComponentEvent e) {
- }
-
- }
-
- class Listener implements ComponentListener, MouseListener, MouseMotionListener, KeyListener {
- private AWTWindow window;
- private AWTDisplay display;
-
- public Listener(AWTWindow w) {
- window = w;
- display = (AWTDisplay)window.getScreen().getDisplay();
- }
-
- public void componentResized(ComponentEvent e) {
- width = canvas.getWidth();
- height = canvas.getHeight();
- display.enqueueEvent(window, com.jogamp.newt.WindowEvent.EVENT_WINDOW_RESIZED, null);
- }
-
- public void componentMoved(ComponentEvent e) {
- }
-
- public void componentShown(ComponentEvent e) {
- }
-
- public void componentHidden(ComponentEvent e) {
- }
-
- public void mouseClicked(MouseEvent e) {
- // We ignore these as we synthesize them ourselves out of
- // mouse pressed and released events
}
-
- public void mouseEntered(MouseEvent e) {
- display.enqueueEvent(window, com.jogamp.newt.MouseEvent.EVENT_MOUSE_ENTERED, e);
- }
-
- public void mouseExited(MouseEvent e) {
- display.enqueueEvent(window, com.jogamp.newt.MouseEvent.EVENT_MOUSE_EXITED, e);
- }
-
- public void mousePressed(MouseEvent e) {
- display.enqueueEvent(window, com.jogamp.newt.MouseEvent.EVENT_MOUSE_PRESSED, e);
- }
-
- public void mouseReleased(MouseEvent e) {
- display.enqueueEvent(window, com.jogamp.newt.MouseEvent.EVENT_MOUSE_RELEASED, e);
- }
-
- public void mouseMoved(MouseEvent e) {
- display.enqueueEvent(window, com.jogamp.newt.MouseEvent.EVENT_MOUSE_MOVED, e);
- }
-
- public void mouseDragged(MouseEvent e) {
- display.enqueueEvent(window, com.jogamp.newt.MouseEvent.EVENT_MOUSE_DRAGGED, e);
- }
-
- public void keyPressed(KeyEvent e) {
- display.enqueueEvent(window, com.jogamp.newt.KeyEvent.EVENT_KEY_PRESSED, e);
- }
-
- public void keyReleased(KeyEvent e) {
- display.enqueueEvent(window, com.jogamp.newt.KeyEvent.EVENT_KEY_RELEASED, e);
- }
-
- public void keyTyped(KeyEvent e) {
- display.enqueueEvent(window, com.jogamp.newt.KeyEvent.EVENT_KEY_TYPED, e);
- }
- }
-
- class WindowEventListener implements WindowListener {
- private AWTWindow window;
- private AWTDisplay display;
-
- public WindowEventListener(AWTWindow w) {
- window = w;
- display = (AWTDisplay)window.getScreen().getDisplay();
- }
-
- public void windowActivated(WindowEvent e) {
- }
- public void windowClosed(WindowEvent e) {
- }
- public void windowClosing(WindowEvent e) {
- display.enqueueEvent(window, com.jogamp.newt.WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY, null);
- }
- public void windowDeactivated(WindowEvent e) {
- }
- public void windowDeiconified(WindowEvent e) {
- }
- public void windowIconified(WindowEvent e) {
- }
- public void windowOpened(WindowEvent e) {
+ public void windowResized(com.jogamp.newt.event.WindowEvent e) {
+ if(null!=canvas) {
+ width = canvas.getWidth();
+ height = canvas.getHeight();
+ }
}
}
}
diff --git a/src/newt/classes/com/jogamp/newt/awt/event/AWTAdapter.java b/src/newt/classes/com/jogamp/newt/awt/event/AWTAdapter.java
new file mode 100644
index 000000000..345eb02b9
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/awt/event/AWTAdapter.java
@@ -0,0 +1,155 @@
+/*
+ * 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:
+ *
+ * - 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 Sven Gothel 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
+ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+package com.jogamp.newt.awt.event;
+
+/**
+ * Convenient adapter forwarding AWT events to NEWT via the event listener model.<br>
+ *
+ * You may attach an instance of this adapter to an AWT Component. When an event happen,
+ * it is converted to a NEWT event and the given NEWT listener is being called.<br>
+ *
+ * This adapter fullfills three use cases. First as a plain utility to write code AWT agnostic,
+ * ie write an {@link javax.media.opengl.GLEvenListener} and some appropriate NEWT {@link com.jogamp.newt.event.EventListener}.<br>
+ *
+ * Attach the {@link javax.media.opengl.GLEvenListener} to a NEWT {@link javax.media.opengl.GLAutoDrawable}, e.g. {@link com.jogamp.newt.opengl.GLWindow},
+ * or to an AWT {@link javax.media.opengl.GLAutoDrawable}, e.g. {@link javax.media.opengl.awt.GLCanvas}.<br>
+ * Attach the NEWT {@link com.jogamp.newt.event.EventListener} to a NEWT component, e.g. {@link com.jogamp.newt.Window},
+ * or to an AWT component, e.g. {@link java.awt.Component}.<br><br>
+ * <code>
+ javax.media.opengl.GLEvenListener demo1 = new javax.media.opengl.GLEvenListener() { ... } ;
+ com.jogamp.newt.event.MouseListener mouseListener = new com.jogamp.newt.event.MouseAdapter() { ... } ;
+
+ // NEWT Usage
+ GLWindow glWindow = GLWindow.create();
+ glWindow.addGLEventListener(demo1);
+ glWindow.addMouseListener(mouseListener);
+ ..
+
+ // AWT Usage
+ GLCanvas glCanvas = new GLCanvas();
+ glCanvas.addGLEventListener(demo1);
+ new AWTMouseAdapter(mouseListener).addTo(glCanvas);
+
+ // This last line is nothing else but a simplified form of:
+ AWTMouseAdapter mouseAdapter = new AWTMouseAdapter(mouseListener);
+ glCanvas.addMouseListener(mouseAdapter);
+ glCanvas.addMouseMotionListener(mouseAdapter);
+ * </code>
+ *
+ * Second is just a litte variation, where we pass a NEWT Window
+ * to impersonate as the source of the event.<br>
+ *
+ * <code>
+ com.jogamp.newt.event.MouseListener mouseListener = new com.jogamp.newt.event.MouseAdapter() { ... } ;
+ Component comp = ... ; // the AWT component
+ GLWindow glWindow = GLWindow.create(); // the NEWT component
+
+ new AWTMouseAdapter(mouseListener, glWindow).addTo(comp);
+ * </code>
+ *
+ * Last but not least, the AWTAdapter maybe used as a general AWT event forwarder to NEWT.<br>
+ *
+ * <code>
+ com.jogamp.newt.event.MouseListener mouseListener = new com.jogamp.newt.event.MouseAdapter() { ... } ;
+ Component comp = ... ; // the AWT component
+ GLWindow glWindow = GLWindow.create(); // the NEWT component
+ glWindow.addMouseListener(mouseListener); // add the custom EventListener to the NEWT component
+
+ new AWTMouseAdapter(glWindow).addTo(comp); // forward all AWT events to glWindow, as NEWT events
+ * </code>
+ *
+ * </code>
+ *
+ * @see #attachTo
+ */
+public abstract class AWTAdapter implements java.util.EventListener
+{
+ com.jogamp.newt.event.EventListener newtListener;
+ com.jogamp.newt.Window newtWindow;
+
+ /**
+ * Simply wrap aroung a NEWT EventListener, exposed as an AWT EventListener.<br>
+ * The NEWT EventListener will be called when an event happens.<br>
+ */
+ public AWTAdapter(com.jogamp.newt.event.EventListener newtListener) {
+ if(null==newtListener) {
+ throw new RuntimeException("Argument newtListener is null");
+ }
+ this.newtListener = newtListener;
+ this.newtWindow = null;
+ }
+
+ /**
+ * Wrap aroung a NEWT EventListener, exposed as an AWT EventListener,<br>
+ * where the given NEWT Window impersonates as the event's source.
+ * The NEWT EventListener will be called when an event happens.<br>
+ */
+ public AWTAdapter(com.jogamp.newt.event.EventListener newtListener, com.jogamp.newt.Window newtProxy) {
+ if(null==newtListener) {
+ throw new RuntimeException("Argument newtListener is null");
+ }
+ if(null==newtProxy) {
+ throw new RuntimeException("Argument newtProxy is null");
+ }
+ this.newtListener = newtListener;
+ this.newtWindow = newtProxy;
+ }
+
+ /**
+ * Create a pipeline adapter, AWT EventListener.<br>
+ * Once attached to an AWT component, it sends the converted AWT events to the NEWT downstream window.<br>
+ */
+ public AWTAdapter(com.jogamp.newt.Window downstream) {
+ if(null==downstream) {
+ throw new RuntimeException("Argument downstream is null");
+ }
+ this.newtListener = null;
+ this.newtWindow = downstream;
+ }
+
+ /**
+ * Due to the fact that some NEWT {@link com.jogamp.newt.event.EventListener}
+ * are mapped to more than one {@link java.util.EventListener},
+ * this method is for your convenience to use this Adapter as a listener for all types.<br>
+ * E.g. {@link com.jogamp.newt.event.MouseListener} is mapped to {@link java.awt.event.MouseListener} and {@link java.awt.event.MouseMotionListener}.
+ */
+ public abstract AWTAdapter addTo(java.awt.Component awtComponent);
+
+ void enqueueEvent(com.jogamp.newt.event.Event event) {
+ try {
+ newtWindow.getScreen().getDisplay().enqueueEvent(event);
+ } catch (NullPointerException npe) {
+ /* that's ok .. window might be down already */
+ }
+ }
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/awt/event/AWTKeyAdapter.java b/src/newt/classes/com/jogamp/newt/awt/event/AWTKeyAdapter.java
new file mode 100644
index 000000000..866ec5476
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/awt/event/AWTKeyAdapter.java
@@ -0,0 +1,80 @@
+/*
+ * 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:
+ *
+ * - 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 Sven Gothel 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
+ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+package com.jogamp.newt.awt.event;
+
+public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListener
+{
+ public AWTKeyAdapter(com.jogamp.newt.event.KeyListener newtListener) {
+ super(newtListener);
+ }
+
+ public AWTKeyAdapter(com.jogamp.newt.event.KeyListener newtListener, com.jogamp.newt.Window newtProxy) {
+ super(newtListener, newtProxy);
+ }
+
+ public AWTKeyAdapter(com.jogamp.newt.Window downstream) {
+ super(downstream);
+ }
+
+ public AWTAdapter addTo(java.awt.Component awtComponent) {
+ awtComponent.addKeyListener(this);
+ return this;
+ }
+
+ public void keyPressed(java.awt.event.KeyEvent e) {
+ com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.KeyListener)newtListener).keyPressed(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+
+ public void keyReleased(java.awt.event.KeyEvent e) {
+ com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.KeyListener)newtListener).keyReleased(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+
+ public void keyTyped(java.awt.event.KeyEvent e) {
+ com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.KeyListener)newtListener).keyTyped(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/awt/event/AWTMouseAdapter.java b/src/newt/classes/com/jogamp/newt/awt/event/AWTMouseAdapter.java
new file mode 100644
index 000000000..db28616b9
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/awt/event/AWTMouseAdapter.java
@@ -0,0 +1,117 @@
+/*
+ * 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:
+ *
+ * - 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 Sven Gothel 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
+ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+package com.jogamp.newt.awt.event;
+
+public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener
+{
+ public AWTMouseAdapter(com.jogamp.newt.event.MouseListener newtListener) {
+ super(newtListener);
+ }
+
+ public AWTMouseAdapter(com.jogamp.newt.event.MouseListener newtListener, com.jogamp.newt.Window newtProxy) {
+ super(newtListener, newtProxy);
+ }
+
+ public AWTMouseAdapter(com.jogamp.newt.Window downstream) {
+ super(downstream);
+ }
+
+ public AWTAdapter addTo(java.awt.Component awtComponent) {
+ awtComponent.addMouseListener(this);
+ awtComponent.addMouseMotionListener(this);
+ return this;
+ }
+
+ public void mouseClicked(java.awt.event.MouseEvent e) {
+ com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.MouseListener)newtListener).mouseClicked(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+
+ public void mouseEntered(java.awt.event.MouseEvent e) {
+ com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.MouseListener)newtListener).mouseEntered(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+
+ public void mouseExited(java.awt.event.MouseEvent e) {
+ com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.MouseListener)newtListener).mouseExited(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+
+ public void mousePressed(java.awt.event.MouseEvent e) {
+ com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.MouseListener)newtListener).mousePressed(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+
+ public void mouseReleased(java.awt.event.MouseEvent e) {
+ com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.MouseListener)newtListener).mouseReleased(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+
+ public void mouseDragged(java.awt.event.MouseEvent e) {
+ com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.MouseListener)newtListener).mouseDragged(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+
+ public void mouseMoved(java.awt.event.MouseEvent e) {
+ com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.MouseListener)newtListener).mouseMoved(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/com/jogamp/newt/awt/event/AWTNewtEventFactory.java
new file mode 100644
index 000000000..ea10c9de5
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/awt/event/AWTNewtEventFactory.java
@@ -0,0 +1,140 @@
+
+/*
+ * 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:
+ *
+ * - 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 Sven Gothel 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
+ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+package com.jogamp.newt.awt.event;
+
+import com.jogamp.common.util.IntIntHashMap;
+
+class AWTNewtEventFactory {
+
+ protected static final IntIntHashMap eventTypeAWT2NEWT;
+
+ static {
+ IntIntHashMap map = new IntIntHashMap();
+ map.setKeyNotFoundValue(-1);
+ // n/a map.put(java.awt.event.WindowEvent.WINDOW_OPENED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_OPENED);
+ map.put(java.awt.event.WindowEvent.WINDOW_CLOSING, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY);
+ // n/a map.put(java.awt.event.WindowEvent.WINDOW_CLOSED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_CLOSED);
+ // n/a map.put(java.awt.event.WindowEvent.WINDOW_ICONIFIED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_ICONIFIED);
+ // n/a map.put(java.awt.event.WindowEvent.WINDOW_DEICONIFIED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_DEICONIFIED);
+ map.put(java.awt.event.WindowEvent.WINDOW_ACTIVATED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS);
+ map.put(java.awt.event.WindowEvent.WINDOW_GAINED_FOCUS, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS);
+ map.put(java.awt.event.WindowEvent.WINDOW_DEACTIVATED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_LOST_FOCUS);
+ map.put(java.awt.event.WindowEvent.WINDOW_LOST_FOCUS, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_LOST_FOCUS);
+ // n/a map.put(java.awt.event.WindowEvent.WINDOW_STATE_CHANGED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_STATE_CHANGED);
+
+ map.put(java.awt.event.ComponentEvent.COMPONENT_MOVED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_MOVED);
+ map.put(java.awt.event.ComponentEvent.COMPONENT_RESIZED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_RESIZED);
+ // n/a map.put(java.awt.event.ComponentEvent.COMPONENT_SHOWN, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_SHOWN);
+ // n/a map.put(java.awt.event.ComponentEvent.COMPONENT_HIDDEN, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_HIDDEN);
+
+ map.put(java.awt.event.MouseEvent.MOUSE_CLICKED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED);
+ map.put(java.awt.event.MouseEvent.MOUSE_PRESSED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED);
+ map.put(java.awt.event.MouseEvent.MOUSE_RELEASED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED);
+ map.put(java.awt.event.MouseEvent.MOUSE_MOVED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED);
+ map.put(java.awt.event.MouseEvent.MOUSE_ENTERED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_ENTERED);
+ map.put(java.awt.event.MouseEvent.MOUSE_EXITED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_EXITED);
+ map.put(java.awt.event.MouseEvent.MOUSE_DRAGGED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED);
+ map.put(java.awt.event.MouseEvent.MOUSE_WHEEL, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED);
+
+ map.put(java.awt.event.KeyEvent.KEY_PRESSED, com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED);
+ map.put(java.awt.event.KeyEvent.KEY_RELEASED, com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED);
+ map.put(java.awt.event.KeyEvent.KEY_TYPED, com.jogamp.newt.event.KeyEvent.EVENT_KEY_TYPED);
+
+ eventTypeAWT2NEWT = map;
+ }
+
+ public static final int awtModifiers2Newt(int awtMods, boolean mouseHint) {
+ int newtMods = 0;
+ if ((awtMods & java.awt.event.InputEvent.SHIFT_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.SHIFT_MASK;
+ if ((awtMods & java.awt.event.InputEvent.CTRL_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.CTRL_MASK;
+ if ((awtMods & java.awt.event.InputEvent.META_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.META_MASK;
+ if ((awtMods & java.awt.event.InputEvent.ALT_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.ALT_MASK;
+ if ((awtMods & java.awt.event.InputEvent.ALT_GRAPH_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK;
+ return newtMods;
+ }
+
+ public static final int awtButton2Newt(int awtButton) {
+ switch (awtButton) {
+ case java.awt.event.MouseEvent.BUTTON1: return com.jogamp.newt.event.MouseEvent.BUTTON1;
+ case java.awt.event.MouseEvent.BUTTON2: return com.jogamp.newt.event.MouseEvent.BUTTON2;
+ case java.awt.event.MouseEvent.BUTTON3: return com.jogamp.newt.event.MouseEvent.BUTTON3;
+ }
+ return 0;
+ }
+
+ static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.WindowEvent event, com.jogamp.newt.Window newtSource) {
+ int type = eventTypeAWT2NEWT.get(event.getID());
+ if(-1 < type) {
+ return new com.jogamp.newt.event.WindowEvent(type, ((null==newtSource)?(Object)event.getComponent():(Object)newtSource), System.currentTimeMillis());
+ }
+ return null; // no mapping ..
+ }
+
+ static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.ComponentEvent event, com.jogamp.newt.Window newtSource) {
+ int type = eventTypeAWT2NEWT.get(event.getID());
+ if(-1 < type) {
+ return new com.jogamp.newt.event.WindowEvent(type, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, System.currentTimeMillis());
+ }
+ return null; // no mapping ..
+ }
+
+ static final com.jogamp.newt.event.MouseEvent createMouseEvent(java.awt.event.MouseEvent event, com.jogamp.newt.Window newtSource) {
+ int type = eventTypeAWT2NEWT.get(event.getID());
+ if(-1 < type) {
+ int rotation = 0;
+ if (event instanceof java.awt.event.MouseWheelEvent) {
+ rotation = ((java.awt.event.MouseWheelEvent)event).getWheelRotation();
+ }
+
+ return new com.jogamp.newt.event.MouseEvent(
+ type, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(),
+ awtModifiers2Newt(event.getModifiers(), true),
+ event.getX(), event.getY(), event.getClickCount(),
+ awtButton2Newt(event.getButton()), rotation);
+ }
+ return null; // no mapping ..
+ }
+
+ static final com.jogamp.newt.event.KeyEvent createKeyEvent(java.awt.event.KeyEvent event, com.jogamp.newt.Window newtSource) {
+ int type = eventTypeAWT2NEWT.get(event.getID());
+ if(-1 < type) {
+ return new com.jogamp.newt.event.KeyEvent(
+ type, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(),
+ awtModifiers2Newt(event.getModifiers(), false),
+ event.getKeyCode(), event.getKeyChar());
+ }
+ return null; // no mapping ..
+ }
+
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/awt/event/AWTWindowAdapter.java b/src/newt/classes/com/jogamp/newt/awt/event/AWTWindowAdapter.java
new file mode 100644
index 000000000..d17bac242
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/awt/event/AWTWindowAdapter.java
@@ -0,0 +1,126 @@
+/*
+ * 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:
+ *
+ * - 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 Sven Gothel 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
+ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+package com.jogamp.newt.awt.event;
+
+public class AWTWindowAdapter extends AWTAdapter implements java.awt.event.ComponentListener, java.awt.event.WindowListener
+{
+ public AWTWindowAdapter(com.jogamp.newt.event.WindowListener newtListener) {
+ super(newtListener);
+ }
+
+ public AWTWindowAdapter(com.jogamp.newt.event.WindowListener newtListener, com.jogamp.newt.Window newtProxy) {
+ super(newtListener, newtProxy);
+ }
+
+ public AWTWindowAdapter(com.jogamp.newt.Window downstream) {
+ super(downstream);
+ }
+
+ public AWTAdapter addTo(java.awt.Component awtComponent) {
+ awtComponent.addComponentListener(this);
+ if(awtComponent instanceof java.awt.Window) {
+ ((java.awt.Window)awtComponent).addWindowListener(this);
+ }
+ return this;
+ }
+
+ public void componentResized(java.awt.event.ComponentEvent e) {
+ com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.WindowListener)newtListener).windowResized(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+
+ public void componentMoved(java.awt.event.ComponentEvent e) {
+ com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.WindowListener)newtListener).windowMoved(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+
+ public void componentShown(java.awt.event.ComponentEvent e) {
+ // n/a
+ }
+
+ public void componentHidden(java.awt.event.ComponentEvent e) {
+ // n/a
+ }
+
+ public void windowActivated(java.awt.event.WindowEvent e) {
+ com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.WindowListener)newtListener).windowGainedFocus(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+
+ public void windowClosed(java.awt.event.WindowEvent e) {
+ // n/a
+ }
+
+ public void windowClosing(java.awt.event.WindowEvent e) {
+ com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.WindowListener)newtListener).windowDestroyNotify(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+
+ public void windowDeactivated(java.awt.event.WindowEvent e) {
+ com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.WindowListener)newtListener).windowLostFocus(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
+
+ public void windowDeiconified(java.awt.event.WindowEvent e) {
+ // n/a
+ }
+
+ public void windowIconified(java.awt.event.WindowEvent e) {
+ // n/a
+ }
+
+ public void windowOpened(java.awt.event.WindowEvent e) {
+ // n/a
+ }
+
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/event/Event.java b/src/newt/classes/com/jogamp/newt/event/Event.java
index d42a95735..d93995ead 100644
--- a/src/newt/classes/com/jogamp/newt/event/Event.java
+++ b/src/newt/classes/com/jogamp/newt/event/Event.java
@@ -31,25 +31,78 @@
*
*/
-package com.jogamp.newt;
+package com.jogamp.newt.event;
+
+import com.jogamp.newt.*;
+import java.util.*;
public class Event {
private boolean isSystemEvent;
private int eventType;
- private Window source;
+ private Object source;
private long when;
- Event(boolean isSystemEvent, int eventType, Window source, long when) {
- this.isSystemEvent = isSystemEvent;
+ static final boolean DEBUG = false;
+
+ // 0: Event.java
+ // 1: InputEvent.java
+ // 2: KeyEvent.java
+ // 3: com.jogamp.newt.Window
+ // 3: com.jogamp.newt.awt.event.AWTNewtEventFactory
+ // 2: MouseEvent.java
+ // 3: com.jogamp.newt.Window
+ // 3: com.jogamp.newt.awt.event.AWTNewtEventFactory
+ // 1: PaintEvent.java
+ // 2: com.jogamp.newt.Window
+ // 2: com.jogamp.newt.awt.event.AWTNewtEventFactory
+ // 1: WindowEvent.java
+ // 2: com.jogamp.newt.Window
+ // 2: com.jogamp.newt.awt.event.AWTNewtEventFactory
+ //
+ static final String WindowClazzName = "com.jogamp.newt.Window" ;
+ static final String AWTNewtEventFactoryClazzName = "com.jogamp.newt.awt.event.AWTNewtEventFactory" ;
+
+ static final boolean evaluateIsSystemEvent(Event event, Throwable t) {
+ StackTraceElement[] stack = t.getStackTrace();
+ if(stack.length==0 || null==stack[0]) {
+ return false;
+ }
+ if(DEBUG) {
+ for (int i = 0; i < stack.length && i<5; i++) {
+ System.out.println(i+": " + stack[i].getClassName()+ "." + stack[i].getMethodName());
+ }
+ }
+
+ String clazzName = null;
+
+ if( (event instanceof com.jogamp.newt.event.WindowEvent) ||
+ (event instanceof com.jogamp.newt.event.PaintEvent) ) {
+ if ( stack.length > 2 ) {
+ clazzName = stack[2].getClassName();
+ }
+ } else if( (event instanceof com.jogamp.newt.event.MouseEvent) ||
+ (event instanceof com.jogamp.newt.event.KeyEvent) ) {
+ if ( stack.length > 3 ) {
+ clazzName = stack[3].getClassName();
+ }
+ }
+
+ boolean res = null!=clazzName && (
+ clazzName.equals(WindowClazzName) ||
+ clazzName.equals(AWTNewtEventFactoryClazzName) ) ;
+ if(DEBUG) {
+ System.out.println("system: "+res);
+ }
+ return res;
+ }
+
+ protected Event(int eventType, Object source, long when) {
+ this.isSystemEvent = evaluateIsSystemEvent(this, new Throwable());
this.eventType = eventType;
this.source = source;
this.when = when;
}
- protected Event(int eventType, Window source, long when) {
- this(false, eventType, source, when);
- }
-
/** Indicates whether this event was produced by the system or
generated by user code. */
public final boolean isSystemEvent() {
@@ -61,8 +114,8 @@ public class Event {
return eventType;
}
- /** Returns the source Window which produced this Event. */
- public final Window getSource() {
+ /** Returns the source Object which produced this Event. */
+ public final Object getSource() {
return source;
}
diff --git a/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java
new file mode 100644
index 000000000..22b4cf1f7
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java
@@ -0,0 +1,45 @@
+/*
+ * 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:
+ *
+ * - 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 Sven Gothel 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
+ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+package com.jogamp.newt.event;
+
+import com.jogamp.newt.*;
+
+public abstract class KeyAdapter implements KeyListener
+{
+ public void keyPressed(KeyEvent e) {
+ }
+ public void keyReleased(KeyEvent e) {
+ }
+ public void keyTyped(KeyEvent e) {
+ }
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/event/MouseAdapter.java b/src/newt/classes/com/jogamp/newt/event/MouseAdapter.java
new file mode 100644
index 000000000..b7428e313
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/event/MouseAdapter.java
@@ -0,0 +1,55 @@
+/*
+ * 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:
+ *
+ * - 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 Sven Gothel 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
+ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+package com.jogamp.newt.event;
+
+import com.jogamp.newt.*;
+
+public abstract class MouseAdapter implements MouseListener
+{
+ public void mouseClicked(MouseEvent e) {
+ }
+ public void mouseEntered(MouseEvent e) {
+ }
+ public void mouseExited(MouseEvent e) {
+ }
+ public void mousePressed(MouseEvent e) {
+ }
+ public void mouseReleased(MouseEvent e) {
+ }
+ public void mouseMoved(MouseEvent e) {
+ }
+ public void mouseDragged(MouseEvent e) {
+ }
+ public void mouseWheelMoved(MouseEvent e) {
+ }
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/event/WindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/WindowAdapter.java
new file mode 100644
index 000000000..51732789e
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/event/WindowAdapter.java
@@ -0,0 +1,48 @@
+/*
+ * 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:
+ *
+ * - 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 Sven Gothel 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
+ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+package com.jogamp.newt.event;
+
+import com.jogamp.newt.*;
+
+public abstract class WindowAdapter implements WindowListener
+{
+ public void windowResized(WindowEvent e) {
+ }
+ public void windowMoved(WindowEvent e) {
+ }
+ public void windowDestroyNotify(WindowEvent e) {
+ }
+ public void windowGainedFocus(WindowEvent e) {
+ }
+ public void windowLostFocus(WindowEvent e) {
+ }
+}
diff --git a/src/newt/classes/com/jogamp/newt/intel/gdl/Display.java b/src/newt/classes/com/jogamp/newt/intel/gdl/Display.java
index a3e5501c4..f79573644 100644
--- a/src/newt/classes/com/jogamp/newt/intel/gdl/Display.java
+++ b/src/newt/classes/com/jogamp/newt/intel/gdl/Display.java
@@ -85,7 +85,7 @@ public class Display extends com.jogamp.newt.Display {
}
}
- protected void dispatchMessages() {
+ protected void dispatchMessagesNative() {
if(0!=displayHandle) {
DispatchMessages(displayHandle, focusedWindow);
}
diff --git a/src/newt/classes/com/jogamp/newt/macosx/MacDisplay.java b/src/newt/classes/com/jogamp/newt/macosx/MacDisplay.java
index 0b5297685..cf67537ae 100755
--- a/src/newt/classes/com/jogamp/newt/macosx/MacDisplay.java
+++ b/src/newt/classes/com/jogamp/newt/macosx/MacDisplay.java
@@ -66,7 +66,7 @@ public class MacDisplay extends Display {
}
private DispatchAction dispatchAction = new DispatchAction();
- public void dispatchMessages() {
+ protected void dispatchMessagesNative() {
MainThread.invoke(false, dispatchAction);
}
diff --git a/src/newt/classes/com/jogamp/newt/macosx/MacWindow.java b/src/newt/classes/com/jogamp/newt/macosx/MacWindow.java
index 52d6fb0c7..8762d106c 100755
--- a/src/newt/classes/com/jogamp/newt/macosx/MacWindow.java
+++ b/src/newt/classes/com/jogamp/newt/macosx/MacWindow.java
@@ -37,6 +37,7 @@ import javax.media.nativewindow.*;
import com.jogamp.newt.util.MainThread;
import com.jogamp.newt.*;
+import com.jogamp.newt.event.*;
import com.jogamp.newt.impl.*;
public class MacWindow extends Window {
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index fec70c99c..0bbd38a4e 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -34,6 +34,7 @@
package com.jogamp.newt.opengl;
import com.jogamp.newt.*;
+import com.jogamp.newt.event.*;
import javax.media.nativewindow.*;
import javax.media.opengl.*;
import com.jogamp.opengl.impl.GLDrawableHelper;
@@ -66,20 +67,11 @@ public class GLWindow extends Window implements GLAutoDrawable {
this.window = window;
this.window.setAutoDrawableClient(true);
this.runPumpMessages = ( null == getScreen().getDisplay().getEDTUtil() ) ;
- window.addWindowListener(new WindowListener() {
+ window.addWindowListener(new WindowAdapter() {
public void windowResized(WindowEvent e) {
sendReshape = true;
}
- public void windowMoved(WindowEvent e) {
- }
-
- public void windowGainedFocus(WindowEvent e) {
- }
-
- public void windowLostFocus(WindowEvent e) {
- }
-
public void windowDestroyNotify(WindowEvent e) {
sendDestroy = true;
}
diff --git a/src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Display.java b/src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Display.java
index 999a407ec..7db5b18dd 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Display.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Display.java
@@ -70,7 +70,7 @@ public class Display extends com.jogamp.newt.Display {
}
}
- protected void dispatchMessages() {
+ protected void dispatchMessagesNative() {
// n/a .. DispatchMessages();
}
diff --git a/src/newt/classes/com/jogamp/newt/opengl/kd/KDDisplay.java b/src/newt/classes/com/jogamp/newt/opengl/kd/KDDisplay.java
index 6a28f992b..8a8e2a7c3 100755
--- a/src/newt/classes/com/jogamp/newt/opengl/kd/KDDisplay.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/kd/KDDisplay.java
@@ -75,7 +75,7 @@ public class KDDisplay extends Display {
}
}
- protected void dispatchMessages() {
+ protected void dispatchMessagesNative() {
DispatchMessages();
}
diff --git a/src/newt/classes/com/jogamp/newt/opengl/kd/KDWindow.java b/src/newt/classes/com/jogamp/newt/opengl/kd/KDWindow.java
index 555f54599..c8bed8a68 100755
--- a/src/newt/classes/com/jogamp/newt/opengl/kd/KDWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/kd/KDWindow.java
@@ -34,6 +34,7 @@
package com.jogamp.newt.opengl.kd;
import com.jogamp.newt.*;
+import com.jogamp.newt.event.*;
import com.jogamp.newt.impl.*;
import com.jogamp.opengl.impl.egl.*;
import javax.media.nativewindow.*;
diff --git a/src/newt/classes/com/jogamp/newt/windows/WindowsDisplay.java b/src/newt/classes/com/jogamp/newt/windows/WindowsDisplay.java
index 281022901..678777e81 100755
--- a/src/newt/classes/com/jogamp/newt/windows/WindowsDisplay.java
+++ b/src/newt/classes/com/jogamp/newt/windows/WindowsDisplay.java
@@ -69,7 +69,7 @@ public class WindowsDisplay extends Display {
// UnregisterWindowClass(getWindowClassAtom(), getHInstance());
}
- protected void dispatchMessages() {
+ protected void dispatchMessagesNative() {
DispatchMessages();
}
diff --git a/src/newt/classes/com/jogamp/newt/windows/WindowsWindow.java b/src/newt/classes/com/jogamp/newt/windows/WindowsWindow.java
index 4a468ae86..db1ae4718 100755
--- a/src/newt/classes/com/jogamp/newt/windows/WindowsWindow.java
+++ b/src/newt/classes/com/jogamp/newt/windows/WindowsWindow.java
@@ -35,6 +35,7 @@ package com.jogamp.newt.windows;
import javax.media.nativewindow.*;
import com.jogamp.newt.*;
+import com.jogamp.newt.event.*;
public class WindowsWindow extends Window {
diff --git a/src/newt/classes/com/jogamp/newt/x11/X11Display.java b/src/newt/classes/com/jogamp/newt/x11/X11Display.java
index c8faefbf1..70e002e9e 100755
--- a/src/newt/classes/com/jogamp/newt/x11/X11Display.java
+++ b/src/newt/classes/com/jogamp/newt/x11/X11Display.java
@@ -78,7 +78,7 @@ public class X11Display extends Display {
X11Util.closeThreadLocalDisplay(name);
}
- protected void dispatchMessages() {
+ protected void dispatchMessagesNative() {
DispatchMessages(getHandle(), javaObjectAtom, windowDeleteAtom);
}
diff --git a/src/newt/classes/com/jogamp/newt/x11/X11Window.java b/src/newt/classes/com/jogamp/newt/x11/X11Window.java
index cc3aa58a2..59ecc3bab 100755
--- a/src/newt/classes/com/jogamp/newt/x11/X11Window.java
+++ b/src/newt/classes/com/jogamp/newt/x11/X11Window.java
@@ -34,6 +34,7 @@
package com.jogamp.newt.x11;
import com.jogamp.newt.*;
+import com.jogamp.newt.event.*;
import javax.media.nativewindow.*;
import javax.media.nativewindow.x11.*;