From ac95e3f1ed0b9069ca2c193ba6489c99996c5a08 Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Tue, 5 Feb 2013 20:07:54 +0400 Subject: [PATCH] 8006790: Improve checking for windows Reviewed-by: art, mschoene --- jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java | 6 +++--- .../classes/sun/lwawt/macosx/CFileDialog.java | 4 ++-- .../sun/lwawt/macosx/CPrinterDialogPeer.java | 4 ++-- jdk/src/share/classes/java/awt/Window.java | 4 ++-- jdk/src/share/classes/java/awt/peer/WindowPeer.java | 13 ++++++------- jdk/src/share/classes/sun/awt/EmbeddedFrame.java | 4 ++-- .../solaris/classes/sun/awt/X11/XWindowPeer.java | 6 +++--- .../classes/sun/awt/windows/WFileDialogPeer.java | 4 ++-- .../classes/sun/awt/windows/WPrintDialogPeer.java | 4 ++-- .../classes/sun/awt/windows/WWindowPeer.java | 6 +++++- 10 files changed, 29 insertions(+), 26 deletions(-) diff --git a/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java b/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java index d50335f7cd5..0a789c415b3 100644 --- a/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java +++ b/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java @@ -170,7 +170,7 @@ public class LWWindowPeer setTitle(((Dialog) getTarget()).getTitle()); } - setAlwaysOnTop(getTarget().isAlwaysOnTop()); + updateAlwaysOnTopState(); updateMinimumSize(); final Shape shape = getTarget().getShape(); @@ -357,8 +357,8 @@ public class LWWindowPeer } @Override - public void setAlwaysOnTop(boolean value) { - platformWindow.setAlwaysOnTop(value); + public void updateAlwaysOnTopState() { + platformWindow.setAlwaysOnTop(getTarget().isAlwaysOnTop()); } @Override diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/CFileDialog.java b/jdk/src/macosx/classes/sun/lwawt/macosx/CFileDialog.java index 359f6066364..29129394a37 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CFileDialog.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CFileDialog.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -180,7 +180,7 @@ class CFileDialog implements FileDialogPeer { } @Override - public void setAlwaysOnTop(boolean alwaysOnTop) { + public void updateAlwaysOnTopState() { } @Override diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/CPrinterDialogPeer.java b/jdk/src/macosx/classes/sun/lwawt/macosx/CPrinterDialogPeer.java index 1ca65e7faae..8dfe7e1e51e 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPrinterDialogPeer.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPrinterDialogPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -87,7 +87,7 @@ public class CPrinterDialogPeer extends LWWindowPeer { } // 1.6 peer method - public void setAlwaysOnTop(boolean value) { + public void updateAlwaysOnTopState() { // no-op, since we just show the native print dialog } diff --git a/jdk/src/share/classes/java/awt/Window.java b/jdk/src/share/classes/java/awt/Window.java index 68b9af95a96..89270e27df1 100644 --- a/jdk/src/share/classes/java/awt/Window.java +++ b/jdk/src/share/classes/java/awt/Window.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -2234,7 +2234,7 @@ public class Window extends Container implements Accessible { WindowPeer peer = (WindowPeer)this.peer; synchronized(getTreeLock()) { if (peer != null) { - peer.setAlwaysOnTop(alwaysOnTop); + peer.updateAlwaysOnTopState(); } } } diff --git a/jdk/src/share/classes/java/awt/peer/WindowPeer.java b/jdk/src/share/classes/java/awt/peer/WindowPeer.java index fca78b7eed4..b44bfa00da9 100644 --- a/jdk/src/share/classes/java/awt/peer/WindowPeer.java +++ b/jdk/src/share/classes/java/awt/peer/WindowPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,15 +53,14 @@ public interface WindowPeer extends ContainerPeer { void toBack(); /** - * Sets if the window should always stay on top of all other windows or - * not. - * - * @param alwaysOnTop if the window should always stay on top of all other - * windows or not + * Updates the window's always-on-top state. + * Sets if the window should always stay + * on top of all other windows or not. * + * @see Window#getAlwaysOnTop() * @see Window#setAlwaysOnTop(boolean) */ - void setAlwaysOnTop(boolean alwaysOnTop); + void updateAlwaysOnTopState(); /** * Updates the window's focusable state. diff --git a/jdk/src/share/classes/sun/awt/EmbeddedFrame.java b/jdk/src/share/classes/sun/awt/EmbeddedFrame.java index 0ae1ec762df..fe8ad9a9a0f 100644 --- a/jdk/src/share/classes/sun/awt/EmbeddedFrame.java +++ b/jdk/src/share/classes/sun/awt/EmbeddedFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -542,7 +542,7 @@ public abstract class EmbeddedFrame extends Frame public void toBack() {} public void updateFocusableWindowState() {} public void updateAlwaysOnTop() {} - public void setAlwaysOnTop(boolean alwaysOnTop) {} + public void updateAlwaysOnTopState() {} public Component getGlobalHeavyweightFocusOwner() { return null; } public void setBoundsPrivate(int x, int y, int width, int height) { setBounds(x, y, width, height, SET_BOUNDS); diff --git a/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java index 4d867175597..0c230d6aa99 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -993,8 +993,8 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, XLayerProtocol.LAYER_NORMAL); } - public void setAlwaysOnTop(boolean alwaysOnTop) { - this.alwaysOnTop = alwaysOnTop; + public void updateAlwaysOnTopState() { + this.alwaysOnTop = ((Window) this.target).isAlwaysOnTop(); updateAlwaysOnTop(); } diff --git a/jdk/src/windows/classes/sun/awt/windows/WFileDialogPeer.java b/jdk/src/windows/classes/sun/awt/windows/WFileDialogPeer.java index 11fe02f83d0..92ec5f337ee 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WFileDialogPeer.java +++ b/jdk/src/windows/classes/sun/awt/windows/WFileDialogPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -237,7 +237,7 @@ public class WFileDialogPeer extends WWindowPeer implements FileDialogPeer { // unused methods. Overridden to disable this functionality as // it requires HWND which is not available for FileDialog - public void setAlwaysOnTop(boolean value) {} + public void updateAlwaysOnTopState() {} public void setDirectory(String dir) {} public void setFile(String file) {} public void setTitle(String title) {} diff --git a/jdk/src/windows/classes/sun/awt/windows/WPrintDialogPeer.java b/jdk/src/windows/classes/sun/awt/windows/WPrintDialogPeer.java index 988098eb648..ee116d46879 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WPrintDialogPeer.java +++ b/jdk/src/windows/classes/sun/awt/windows/WPrintDialogPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -117,7 +117,7 @@ public class WPrintDialogPeer extends WWindowPeer implements DialogPeer { // unused methods. Overridden to disable this functionality as // it requires HWND which is not available for FileDialog void initialize() {} - public void setAlwaysOnTop(boolean b) {} + public void updateAlwaysOnTopState() {} public void setResizable(boolean resizable) {} public void hide() {} public void enable() {} diff --git a/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java b/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java index 07f0c1c08f9..8b941c6f3c5 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java +++ b/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -132,6 +132,10 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer, } } + public void updateAlwaysOnTopState() { + setAlwaysOnTop(((Window)target).isAlwaysOnTop()); + } + public void updateFocusableWindowState() { setFocusableWindow(((Window)target).isFocusableWindow()); }