--- a/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java Fri Nov 02 16:14:14 2012 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java Fri Nov 02 19:20:03 2012 +0400
@@ -675,8 +675,9 @@
getLWToolkit().getCursorManager().updateCursorLater(this);
}
- public void notifyActivation(boolean activation) {
- changeFocusedWindow(activation);
+ public void notifyActivation(boolean activation, LWWindowPeer opposite) {
+ Window oppositeWindow = (opposite == null)? null : opposite.getTarget();
+ changeFocusedWindow(activation, oppositeWindow);
}
// MouseDown in non-client area
@@ -1151,6 +1152,9 @@
Window currentActive = KeyboardFocusManager.
getCurrentKeyboardFocusManager().getActiveWindow();
+ Window opposite = LWKeyboardFocusManagerPeer.getInstance().
+ getCurrentFocusedWindow();
+
// Make the owner active window.
if (isSimpleWindow()) {
LWWindowPeer owner = getOwnerFrameDialog(this);
@@ -1177,16 +1181,17 @@
}
// DKFM will synthesize all the focus/activation events correctly.
- changeFocusedWindow(true);
+ changeFocusedWindow(true, opposite);
return true;
// In case the toplevel is active but not focused, change focus directly,
// as requesting native focus on it will not have effect.
} else if (getTarget() == currentActive && !getTarget().hasFocus()) {
- changeFocusedWindow(true);
+ changeFocusedWindow(true, opposite);
return true;
}
+
return platformWindow.requestWindowFocus();
}
@@ -1216,7 +1221,7 @@
/*
* Changes focused window on java level.
*/
- private void changeFocusedWindow(boolean becomesFocused) {
+ private void changeFocusedWindow(boolean becomesFocused, Window opposite) {
if (focusLog.isLoggable(PlatformLogger.FINE)) {
focusLog.fine((becomesFocused?"gaining":"loosing") + " focus window: " + this);
}
@@ -1240,9 +1245,6 @@
}
}
- KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
- Window oppositeWindow = becomesFocused ? kfmPeer.getCurrentFocusedWindow() : null;
-
// Note, the method is not called:
// - when the opposite (gaining focus) window is an owned/owner window.
// - for a simple window in any case.
@@ -1254,10 +1256,11 @@
grabbingWindow.ungrab();
}
+ KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
kfmPeer.setCurrentFocusedWindow(becomesFocused ? getTarget() : null);
int eventID = becomesFocused ? WindowEvent.WINDOW_GAINED_FOCUS : WindowEvent.WINDOW_LOST_FOCUS;
- WindowEvent windowEvent = new TimedWindowEvent(getTarget(), eventID, oppositeWindow, System.currentTimeMillis());
+ WindowEvent windowEvent = new TimedWindowEvent(getTarget(), eventID, opposite, System.currentTimeMillis());
// TODO: wrap in SequencedEvent
postEvent(windowEvent);