summaryrefslogtreecommitdiffstats
path: root/src/newt/classes
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-10-16 07:30:09 +0200
committerSven Gothel <[email protected]>2011-10-16 07:30:09 +0200
commitcac4e2e3f2d6c69a207077fd5e0ebec803afb6b0 (patch)
treef9e47f3ba7ac704f8c14bfe83f64122b883af49c /src/newt/classes
parentaf332515f76a4017e7a52ebec920e794a5398db4 (diff)
NEWT/OSX: Proper impl. of NEWT's focus management (fixes NEWT/AWT focus behavior/tests)
- Old code was just requesting the focus and made the window upfront and notifying a gained focus to WindowImpl. (hack) - Using proper requestFocus impl. issuing focusAction() and utilizing native focus gained/lost messages. This distinguish between 'makeKey' and 'orderFront'. Also requesting and accepting (view) first responder role, which is a precursor to proper gained/lost focus handling on OSX. - NEWTCanvasAWT: Adding 'steal AWT focus': +++ void requestFocus() { super.requestFocus(); // AWT < steal AWT focus > NEWTChild.requestFocus() } +++ Helps make the focus traversal between NEWT/AWT more reliable. Happend on OSX that AWT (NewtCanvasAWT instance) didn't release the focus after NEWT child gained the same. We are not able to use the 'focusAction()' here (disabled in this code path) due to AWT-EDT blocking and recursive focus changes. The latter is also intendend to request the AWT focus first .. - AWT/NEWT focus test 01 passes on OSX
Diffstat (limited to 'src/newt/classes')
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java4
-rw-r--r--src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java16
2 files changed, 10 insertions, 10 deletions
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
index b2d97c7d5..47977610f 100644
--- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
+++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
@@ -307,6 +307,10 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
final void requestFocusNEWTChild() {
if(null!=newtChild) {
newtChild.setFocusAction(null);
+ // FIXME: Experimental 'steal AWT focus',
+ // since we have to disable the focus action due to recursion and AWT EDT blocking.
+ KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
+ kfm.clearGlobalFocusOwner();
newtChild.requestFocus();
newtChild.setFocusAction(focusAction);
}
diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java
index 0bb0b6b13..8886cf630 100644
--- a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java
+++ b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java
@@ -181,8 +181,8 @@ public class MacWindow extends WindowImpl {
setTitle0(getWindowHandle(), title);
}
- protected void requestFocusImpl(boolean reparented) {
- makeKeyAndOrderFront0(getWindowHandle());
+ protected void requestFocusImpl(boolean force) {
+ requestFocus0(getWindowHandle(), force);
}
protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) {
@@ -196,17 +196,14 @@ public class MacWindow extends WindowImpl {
if( getWindowHandle() == 0 ) {
if( 0 != ( FLAG_IS_VISIBLE & flags) ) {
createWindow(false, pS, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags));
- makeKeyAndOrderFront0(getWindowHandle());
// no native event ..
visibleChanged(true, true);
- focusChanged(true, true);
} /* else { ?? } */
} else {
if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 == ( FLAG_IS_VISIBLE & flags) ) {
orderOut0(getWindowHandle());
// no native event ..
visibleChanged(true, false);
- focusChanged(true, false);
}
if( 0 != ( FLAG_CHANGE_DECORATION & flags) ||
0 != ( FLAG_CHANGE_PARENTING & flags) ||
@@ -225,10 +222,9 @@ public class MacWindow extends WindowImpl {
sizeChanged(true, width, height, false); // incl. validation (incl. repositioning)
}
if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 != ( FLAG_IS_VISIBLE & flags) ) {
- makeKeyAndOrderFront0(getWindowHandle());
+ orderFront0(getWindowHandle());
// no native event ..
- visibleChanged(true, true);
- focusChanged(true, true);
+ visibleChanged(true, true);
}
setAlwaysOnTop0(getWindowHandle(), 0 != ( FLAG_IS_ALWAYSONTOP & flags));
}
@@ -447,10 +443,10 @@ public class MacWindow extends WindowImpl {
boolean opaque, boolean fullscreen, int windowStyle,
int backingStoreType,
int screen_idx, long view);
- private native void makeKeyAndOrderFront0(long window);
- private native void makeKey0(long window);
+ private native void requestFocus0(long window, boolean force);
/** in case of a child window, it actually only issues orderBack(..) */
private native void orderOut0(long window);
+ private native void orderFront0(long window);
private native void close0(long window);
private native void setTitle0(long window, String title);
private native long contentView0(long window);