aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-09-28 08:37:33 +0300
committerSven Gothel <[email protected]>2010-09-28 08:37:33 +0300
commitb32c65e2322bf046250b090a4c10c47a55f45c29 (patch)
treea19028edada8b853bc9ca8fc8dc1a070c576afcf /src/newt
parent6eb90f6e63c2449bad1215caf7163f7d2497d46e (diff)
NEWT Focus fixes / out.println -> err.println
NEWT Focus fixes: WindowImpl.setFocusAction(): fix (was never set) NewtCanvasAWT.FocusActionImpl: KeyboardFocusManager.clearGlobalFocusOwner() after requestFocusAWTParent()
Diffstat (limited to 'src/newt')
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java8
-rw-r--r--src/newt/classes/com/jogamp/newt/event/NEWTEvent.java4
-rw-r--r--src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java6
-rw-r--r--src/newt/classes/com/jogamp/newt/event/TraceMouseAdapter.java16
-rw-r--r--src/newt/classes/com/jogamp/newt/event/TraceWindowAdapter.java12
-rw-r--r--src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java26
-rw-r--r--src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java4
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/WindowImpl.java2
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/macosx/MacDisplay.java4
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java6
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Window.java4
11 files changed, 57 insertions, 35 deletions
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
index de4ea2a30..d378e8ed0 100644
--- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
+++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
@@ -36,6 +36,7 @@ import java.security.*;
import java.awt.Canvas;
import java.awt.EventQueue;
import java.awt.Graphics;
+import java.awt.KeyboardFocusManager;
import javax.media.nativewindow.*;
@@ -50,7 +51,7 @@ public class NewtCanvasAWT extends java.awt.Canvas {
NativeWindow parent = null;
Window newtChild = null;
- AWTAdapter awtAdapter = null;
+ AWTParentWindowAdapter awtAdapter = null;
/**
* Instantiates a NewtCanvas without a NEWT child.<br>
@@ -88,6 +89,9 @@ public class NewtCanvasAWT extends java.awt.Canvas {
System.err.println("FocusActionImpl.run() "+Display.getThreadName());
}
NewtCanvasAWT.this.requestFocusAWTParent();
+ // awtAdapter.setForcePermanentFocusLossOneShot();
+ KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
+ kfm.clearGlobalFocusOwner();
}
}
FocusActionImpl focusActionImpl = new FocusActionImpl();
@@ -123,7 +127,7 @@ public class NewtCanvasAWT extends java.awt.Canvas {
awtAdapter=null;
}
if(attach && null!=newtChild) {
- awtAdapter = new AWTParentWindowAdapter(newtChild).addTo(this);
+ awtAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter(newtChild).addTo(this);
}
}
diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java
index c85fc5f64..bbe648c42 100644
--- a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java
+++ b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java
@@ -80,7 +80,7 @@ public class NEWTEvent extends java.util.EventObject {
}
if(DEBUG) {
for (int i = 0; i < stack.length && i<5; i++) {
- System.out.println(i+": " + stack[i].getClassName()+ "." + stack[i].getMethodName());
+ System.err.println(i+": " + stack[i].getClassName()+ "." + stack[i].getMethodName());
}
}
@@ -101,7 +101,7 @@ public class NEWTEvent extends java.util.EventObject {
clazzName.equals(WindowClazzName) ||
clazzName.equals(AWTNewtEventFactoryClazzName) ) ;
if(DEBUG) {
- System.out.println("system: "+res);
+ System.err.println("system: "+res);
}
return res;
}
diff --git a/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java
index 999c9bed4..98ba5a24d 100644
--- a/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java
@@ -41,15 +41,15 @@ public class TraceKeyAdapter implements KeyListener {
}
public void keyPressed(KeyEvent e) {
- System.out.println(e);
+ System.err.println(e);
if(null!=downstream) { downstream.keyPressed(e); }
}
public void keyReleased(KeyEvent e) {
- System.out.println(e);
+ System.err.println(e);
if(null!=downstream) { downstream.keyReleased(e); }
}
public void keyTyped(KeyEvent e) {
- System.out.println(e);
+ System.err.println(e);
if(null!=downstream) { downstream.keyTyped(e); }
}
}
diff --git a/src/newt/classes/com/jogamp/newt/event/TraceMouseAdapter.java b/src/newt/classes/com/jogamp/newt/event/TraceMouseAdapter.java
index 0ec0e6fe4..17d8df80b 100644
--- a/src/newt/classes/com/jogamp/newt/event/TraceMouseAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/TraceMouseAdapter.java
@@ -43,35 +43,35 @@ public class TraceMouseAdapter implements MouseListener {
}
public void mouseClicked(MouseEvent e) {
- System.out.println(e);
+ System.err.println(e);
if(null!=downstream) { downstream.mouseClicked(e); }
}
public void mouseEntered(MouseEvent e) {
- System.out.println(e);
+ System.err.println(e);
if(null!=downstream) { downstream.mouseEntered(e); }
}
public void mouseExited(MouseEvent e) {
- System.out.println(e);
+ System.err.println(e);
if(null!=downstream) { downstream.mouseExited(e); }
}
public void mousePressed(MouseEvent e) {
- System.out.println(e);
+ System.err.println(e);
if(null!=downstream) { downstream.mousePressed(e); }
}
public void mouseReleased(MouseEvent e) {
- System.out.println(e);
+ System.err.println(e);
if(null!=downstream) { downstream.mouseReleased(e); }
}
public void mouseMoved(MouseEvent e) {
- System.out.println(e);
+ System.err.println(e);
if(null!=downstream) { downstream.mouseMoved(e); }
}
public void mouseDragged(MouseEvent e) {
- System.out.println(e);
+ System.err.println(e);
if(null!=downstream) { downstream.mouseDragged(e); }
}
public void mouseWheelMoved(MouseEvent e) {
- System.out.println(e);
+ System.err.println(e);
if(null!=downstream) { downstream.mouseWheelMoved(e); }
}
}
diff --git a/src/newt/classes/com/jogamp/newt/event/TraceWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/TraceWindowAdapter.java
index 7a7207e4e..3545a42d4 100644
--- a/src/newt/classes/com/jogamp/newt/event/TraceWindowAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/TraceWindowAdapter.java
@@ -43,27 +43,27 @@ public class TraceWindowAdapter implements WindowListener {
}
public void windowResized(WindowEvent e) {
- System.out.println(e);
+ System.err.println(e);
if(null!=downstream) { downstream.windowResized(e); }
}
public void windowMoved(WindowEvent e) {
- System.out.println(e);
+ System.err.println(e);
if(null!=downstream) { downstream.windowMoved(e); }
}
public void windowDestroyNotify(WindowEvent e) {
- System.out.println(e);
+ System.err.println(e);
if(null!=downstream) { downstream.windowDestroyNotify(e); }
}
public void windowGainedFocus(WindowEvent e) {
- System.out.println(e);
+ System.err.println(e);
if(null!=downstream) { downstream.windowGainedFocus(e); }
}
public void windowLostFocus(WindowEvent e) {
- System.out.println(e);
+ System.err.println(e);
if(null!=downstream) { downstream.windowLostFocus(e); }
}
public void windowRepaint(WindowUpdateEvent e) {
- System.out.println(e);
+ System.err.println(e);
if(null!=downstream) { downstream.windowRepaint(e); }
}
}
diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java
index 32452d6ee..e86d365bc 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java
@@ -28,6 +28,8 @@
package com.jogamp.newt.event.awt;
+import java.awt.KeyboardFocusManager;
+
/**
* Specialized parent/client adapter,
* where the NEWT child window really gets resized,
@@ -50,15 +52,29 @@ public class AWTParentWindowAdapter
return super.removeFrom(awtComponent);
}
+ boolean forcePermanentFocusLossOneShot = false;
+
+ public void setForcePermanentFocusLossOneShot() {
+ forcePermanentFocusLossOneShot = true;
+ }
+
public void focusGained(java.awt.event.FocusEvent e) {
if(DEBUG_IMPLEMENTATION) {
- System.out.println("AWT: focusGained: START "+ e.getComponent());
+ System.err.println("AWT: focusGained: "+ e);
}
}
public void focusLost(java.awt.event.FocusEvent e) {
if(DEBUG_IMPLEMENTATION) {
- System.out.println("AWT: focusLost: "+ e.getComponent());
+ System.err.println("AWT: focusLost: "+ e);
+ }
+ if(forcePermanentFocusLossOneShot) {
+ forcePermanentFocusLossOneShot = false;
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("AWT: focusLost: - clearGlobalFocusOwner -");
+ }
+ KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
+ kfm.clearGlobalFocusOwner();
}
}
@@ -67,7 +83,7 @@ public class AWTParentWindowAdapter
// the resized event will be send via the native window feedback.
final java.awt.Component comp = e.getComponent();
if(DEBUG_IMPLEMENTATION) {
- System.out.println("AWT: componentResized: "+comp);
+ System.err.println("AWT: componentResized: "+comp);
}
newtWindow.runOnEDTIfAvail(false, new Runnable() {
public void run() {
@@ -99,7 +115,7 @@ public class AWTParentWindowAdapter
if( 0 != ( java.awt.event.HierarchyEvent.SHOWING_CHANGED & bits ) ) {
final boolean showing = changed.isShowing();
if(DEBUG_IMPLEMENTATION) {
- System.out.println("AWT: hierarchyChanged SHOWING_CHANGED: showing "+showing+", "+changed);
+ System.err.println("AWT: hierarchyChanged SHOWING_CHANGED: showing "+showing+", "+changed);
}
if(newtWindow.isValid()) {
newtWindow.runOnEDTIfAvail(false, new Runnable() {
@@ -112,7 +128,7 @@ public class AWTParentWindowAdapter
if( 0 != ( java.awt.event.HierarchyEvent.DISPLAYABILITY_CHANGED & bits ) ) {
final boolean displayability = changed.isDisplayable();
if(DEBUG_IMPLEMENTATION) {
- System.out.println("AWT: hierarchyChanged DISPLAYABILITY_CHANGED: displayability "+displayability+", "+changed);
+ System.err.println("AWT: hierarchyChanged DISPLAYABILITY_CHANGED: displayability "+displayability+", "+changed);
}
}
}
diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java
index dd58ad1c8..85fe5407b 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java
@@ -124,7 +124,7 @@ public class AWTWindowAdapter
public void componentShown(java.awt.event.ComponentEvent e) {
final java.awt.Component comp = e.getComponent();
if(DEBUG_IMPLEMENTATION) {
- System.out.println("AWT: componentShown: "+comp);
+ System.err.println("AWT: componentShown: "+comp);
}
/**
if(null==newtListener) {
@@ -141,7 +141,7 @@ public class AWTWindowAdapter
public void componentHidden(java.awt.event.ComponentEvent e) {
final java.awt.Component comp = e.getComponent();
if(DEBUG_IMPLEMENTATION) {
- System.out.println("AWT: componentHidden: "+comp);
+ System.err.println("AWT: componentHidden: "+comp);
}
/**
if(null==newtListener) {
diff --git a/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java b/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java
index e26947a36..02541aa73 100644
--- a/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java
+++ b/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java
@@ -1064,7 +1064,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
* hence focus traversal can be made transparent.
*/
public void setFocusAction(FocusRunnable focusAction) {
- focusAction = focusAction;
+ this.focusAction = focusAction;
}
protected boolean focusAction() {
if(DEBUG_IMPLEMENTATION) {
diff --git a/src/newt/classes/com/jogamp/newt/impl/macosx/MacDisplay.java b/src/newt/classes/com/jogamp/newt/impl/macosx/MacDisplay.java
index 42cdb9ca3..dc45f7479 100644
--- a/src/newt/classes/com/jogamp/newt/impl/macosx/MacDisplay.java
+++ b/src/newt/classes/com/jogamp/newt/impl/macosx/MacDisplay.java
@@ -51,7 +51,9 @@ public class MacDisplay extends DisplayImpl {
if(!MacWindow.initIDs0()) {
throw new NativeWindowException("Failed to initialize jmethodIDs");
}
- if(DEBUG) System.out.println("MacDisplay.init App and IDs OK "+Thread.currentThread().getName());
+ if(DEBUG) {
+ System.err.println("MacDisplay.init App and IDs OK "+Thread.currentThread().getName());
+ }
}
public static void initSingleton() {
diff --git a/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java b/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java
index 6432f363e..5043be918 100644
--- a/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java
+++ b/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java
@@ -152,7 +152,7 @@ public class MacWindow extends WindowImpl {
protected void closeNativeImpl() {
nsViewLock.lock();
try {
- if(DEBUG_IMPLEMENTATION) { System.out.println("MacWindow.CloseAction "+Thread.currentThread().getName()); }
+ if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow.CloseAction "+Thread.currentThread().getName()); }
if (getWindowHandle() != 0) {
close0(getWindowHandle());
}
@@ -270,7 +270,7 @@ public class MacWindow extends WindowImpl {
private void insetsChanged(int left, int top, int right, int bottom) {
if (DEBUG_IMPLEMENTATION) {
- System.out.println(Thread.currentThread().getName()+
+ System.err.println(Thread.currentThread().getName()+
" Insets changed to " + left + ", " + top + ", " + right + ", " + bottom);
}
if (left != -1 && top != -1 && right != -1 && bottom != -1) {
@@ -366,7 +366,7 @@ public class MacWindow extends WindowImpl {
public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) {
int key = convertKeyChar(keyChar);
- if(DEBUG_IMPLEMENTATION) System.out.println("MacWindow.enqueueKeyEvent "+Thread.currentThread().getName());
+ if(DEBUG_IMPLEMENTATION) System.err.println("MacWindow.enqueueKeyEvent "+Thread.currentThread().getName());
// Note that we send the key char for the key code on this
// platform -- we do not get any useful key codes out of the system
super.enqueueKeyEvent(wait, eventType, modifiers, key, keyChar);
diff --git a/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Window.java b/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Window.java
index 947e28c27..9f5e7b7c1 100644
--- a/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Window.java
+++ b/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Window.java
@@ -111,7 +111,7 @@ public class Window extends com.jogamp.newt.impl.WindowImpl {
private long realizeWindow(boolean chromaKey, int width, int height) {
if(DEBUG_IMPLEMENTATION) {
- System.out.println("BCEGL Window.realizeWindow() with: chroma "+chromaKey+", "+width+"x"+height+", "+config);
+ System.err.println("BCEGL Window.realizeWindow() with: chroma "+chromaKey+", "+width+"x"+height+", "+config);
}
long handle = CreateWindow(getDisplayHandle(), chromaKey, width, height);
if (0 == handle) {
@@ -130,7 +130,7 @@ public class Window extends com.jogamp.newt.impl.WindowImpl {
throw new NativeWindowException("Error creating EGLGraphicsConfiguration from id: "+cfgID+", "+this);
}
if(DEBUG_IMPLEMENTATION) {
- System.out.println("BCEGL Window.windowCreated(): "+toHexString(cfgID)+", "+width+"x"+height+", "+config);
+ System.err.println("BCEGL Window.windowCreated(): "+toHexString(cfgID)+", "+width+"x"+height+", "+config);
}
}