< prev index next >
src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
Print this page
@@ -23,35 +23,52 @@
* questions.
*/
package sun.lwawt.macosx;
-import com.apple.eawt.FullScreenAdapter;
-import com.apple.eawt.FullScreenUtilities;
-import com.apple.eawt.event.FullScreenEvent;
-import java.awt.*;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.DefaultKeyboardFocusManager;
+import java.awt.Dialog;
import java.awt.Dialog.ModalityType;
-import java.awt.event.*;
-import java.beans.*;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Frame;
+import java.awt.GraphicsDevice;
+import java.awt.Insets;
+import java.awt.MenuBar;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Toolkit;
+import java.awt.Window;
+import java.awt.event.FocusEvent;
+import java.awt.event.WindowEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Comparator;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
-import javax.swing.*;
+import javax.swing.JRootPane;
+import javax.swing.RootPaneContainer;
+import javax.swing.SwingUtilities;
-import sun.awt.*;
+import com.apple.laf.ClientPropertyApplicator;
+import sun.awt.AWTAccessor;
import sun.awt.AWTAccessor.ComponentAccessor;
import sun.awt.AWTAccessor.WindowAccessor;
import sun.java2d.SurfaceData;
import sun.java2d.opengl.CGLSurfaceData;
-import sun.lwawt.*;
+import sun.lwawt.LWToolkit;
+import sun.lwawt.LWWindowPeer;
+import sun.lwawt.PlatformWindow;
import sun.util.logging.PlatformLogger;
-import com.apple.laf.*;
import com.apple.laf.ClientPropertyApplicator.Property;
import com.sun.awt.AWTUtilities;
import sun.lwawt.LWWindowPeer.PeerType;
public class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
@@ -222,10 +239,24 @@
final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
if (root == null || acc.getPeer(root) == null) return null;
return (CPlatformWindow)((LWWindowPeer)acc.getPeer(root)).getPlatformWindow();
}
};
+ private final Comparator<Window> siblingsComparator = (w1, w2) -> {
+ if (w1 == w2) {
+ return 0;
+ }
+ ComponentAccessor componentAccessor = AWTAccessor.getComponentAccessor();
+ Object p1 = componentAccessor.getPeer(w1);
+ Object p2 = componentAccessor.getPeer(w2);
+ if (p1 instanceof LWWindowPeer && p2 instanceof LWWindowPeer) {
+ return Long.compare(
+ ((CPlatformWindow) (((LWWindowPeer) p1).getPlatformWindow())).lastBecomeMainTime,
+ ((CPlatformWindow) (((LWWindowPeer) p2).getPlatformWindow())).lastBecomeMainTime);
+ }
+ return 0;
+ };
// Bounds of the native widget but in the Java coordinate system.
// In order to keep it up-to-date we will update them on
// 1) setting native bounds via nativeSetBounds() call
// 2) getting notification from the native level via deliverMoveResizeEvent()
@@ -243,10 +274,11 @@
protected CPlatformWindow owner;
protected boolean visible = false; // visibility status from native perspective
private boolean undecorated; // initialized in getInitialStyleBits()
private Rectangle normalBounds = null; // not-null only for undecorated maximized windows
private CPlatformResponder responder;
+ private long lastBecomeMainTime; // this is necessary to preserve right siblings order
public CPlatformWindow() {
super(0, true);
}
@@ -1170,12 +1202,13 @@
private void orderAboveSiblingsImpl(Window[] windows) {
ArrayList<Window> childWindows = new ArrayList<Window>();
final ComponentAccessor componentAccessor = AWTAccessor.getComponentAccessor();
final WindowAccessor windowAccessor = AWTAccessor.getWindowAccessor();
-
+ Arrays.sort(windows, siblingsComparator);
// Go through the list of windows and perform ordering.
+ CPlatformWindow pwUnder = null;
for (Window w : windows) {
boolean iconified = false;
final Object p = componentAccessor.getPeer(w);
if (p instanceof LWWindowPeer) {
CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow();
@@ -1185,15 +1218,19 @@
// the window should be ordered above its siblings; otherwise the window is just ordered
// above its nearest parent.
if (pw.isOneOfOwnersOrSelf(this)) {
pw.execute(CWrapper.NSWindow::orderFront);
} else {
- pw.owner.execute(ownerPtr -> {
+ if (pwUnder == null) {
+ pwUnder = pw.owner;
+ }
+ pwUnder.execute(underPtr -> {
pw.execute(ptr -> {
- CWrapper.NSWindow.orderWindow(ptr, CWrapper.NSWindow.NSWindowAbove, ownerPtr);
+ CWrapper.NSWindow.orderWindow(ptr, CWrapper.NSWindow.NSWindowAbove, underPtr);
});
});
+ pwUnder = pw;
}
pw.applyWindowLevel(w);
}
}
// Retrieve the child windows for each window from the list except iconified ones
@@ -1226,10 +1263,11 @@
private void windowWillMiniaturize() {
isIconifyAnimationActive = true;
}
private void windowDidBecomeMain() {
+ lastBecomeMainTime = System.currentTimeMillis();
if (checkBlockingAndOrder()) return;
// If it's not blocked, make sure it's above its siblings
orderAboveSiblings();
}
< prev index next >