From 9e9ac093ae4d2447a5f487341f219521d01d731b Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Tue, 26 Jun 2012 13:46:09 +0400 Subject: [PATCH 1/4] 7142091: [macosx] RFE: Refactoring of peer initialization/disposing Reviewed-by: anthony, art --- .../classes/sun/lwawt/LWButtonPeer.java | 4 +- .../classes/sun/lwawt/LWCheckboxPeer.java | 4 +- .../classes/sun/lwawt/LWChoicePeer.java | 4 +- .../classes/sun/lwawt/LWComponentPeer.java | 80 +++++++++--------- .../macosx/classes/sun/lwawt/LWLabelPeer.java | 4 +- .../macosx/classes/sun/lwawt/LWListPeer.java | 4 +- .../classes/sun/lwawt/LWScrollBarPeer.java | 4 +- .../classes/sun/lwawt/LWScrollPanePeer.java | 4 +- .../classes/sun/lwawt/LWTextAreaPeer.java | 4 +- .../sun/lwawt/LWTextComponentPeer.java | 4 +- .../classes/sun/lwawt/LWTextFieldPeer.java | 4 +- .../classes/sun/lwawt/LWWindowPeer.java | 84 ++++++++----------- .../sun/lwawt/macosx/CPlatformWindow.java | 24 +----- jdk/src/macosx/native/sun/awt/AWTWindow.m | 21 ----- 14 files changed, 100 insertions(+), 149 deletions(-) diff --git a/jdk/src/macosx/classes/sun/lwawt/LWButtonPeer.java b/jdk/src/macosx/classes/sun/lwawt/LWButtonPeer.java index f0cd54d93b3..e5f8838c8cd 100644 --- a/jdk/src/macosx/classes/sun/lwawt/LWButtonPeer.java +++ b/jdk/src/macosx/classes/sun/lwawt/LWButtonPeer.java @@ -47,8 +47,8 @@ final class LWButtonPeer extends LWComponentPeer } @Override - public void initialize() { - super.initialize(); + void initializeImpl() { + super.initializeImpl(); setLabel(getTarget().getLabel()); synchronized (getDelegateLock()) { getDelegate().addActionListener(this); diff --git a/jdk/src/macosx/classes/sun/lwawt/LWCheckboxPeer.java b/jdk/src/macosx/classes/sun/lwawt/LWCheckboxPeer.java index b639e6c2903..69bce89adae 100644 --- a/jdk/src/macosx/classes/sun/lwawt/LWCheckboxPeer.java +++ b/jdk/src/macosx/classes/sun/lwawt/LWCheckboxPeer.java @@ -61,8 +61,8 @@ final class LWCheckboxPeer } @Override - public void initialize() { - super.initialize(); + void initializeImpl() { + super.initializeImpl(); setLabel(getTarget().getLabel()); setState(getTarget().getState()); setCheckboxGroup(getTarget().getCheckboxGroup()); diff --git a/jdk/src/macosx/classes/sun/lwawt/LWChoicePeer.java b/jdk/src/macosx/classes/sun/lwawt/LWChoicePeer.java index b0ab9d0e3f0..dc781d3d682 100644 --- a/jdk/src/macosx/classes/sun/lwawt/LWChoicePeer.java +++ b/jdk/src/macosx/classes/sun/lwawt/LWChoicePeer.java @@ -55,8 +55,8 @@ final class LWChoicePeer extends LWComponentPeer> } @Override - public void initialize() { - super.initialize(); + void initializeImpl() { + super.initializeImpl(); final Choice choice = getTarget(); final JComboBox combo = getDelegate(); synchronized (getDelegateLock()) { diff --git a/jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java b/jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java index 035cfe1596b..61d0dd060c4 100644 --- a/jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java +++ b/jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java @@ -81,19 +81,10 @@ public abstract class LWComponentPeer // lock is not used as there are many peers related ops // to be done on the toolkit thread, and we don't want to // depend on a public lock on this thread - private final static Object peerTreeLock = + private static final Object peerTreeLock = new StringBuilder("LWComponentPeer.peerTreeLock"); - /** - * A custom tree-lock used for the hierarchy of the delegate Swing - * components. - * The lock synchronizes access to the delegate - * internal state. Think of it as a 'virtual EDT'. - */ -// private final Object delegateTreeLock = -// new StringBuilder("LWComponentPeer.delegateTreeLock"); - - private T target; + private final T target; // Container peer. It may not be the peer of the target's direct // parent, for example, in the case of hw/lw mixing. However, @@ -108,10 +99,10 @@ public abstract class LWComponentPeer // be updated when the component is reparented to another container private LWWindowPeer windowPeer; - private AtomicBoolean disposed = new AtomicBoolean(false); + private final AtomicBoolean disposed = new AtomicBoolean(false); // Bounds are relative to parent peer - private Rectangle bounds = new Rectangle(); + private final Rectangle bounds = new Rectangle(); private Region region; // Component state. Should be accessed under the state lock @@ -122,9 +113,11 @@ public abstract class LWComponentPeer private Color foreground; private Font font; - // Paint area to coalesce all the paint events and store - // the target dirty area - private RepaintArea targetPaintArea; + /** + * Paint area to coalesce all the paint events and store the target dirty + * area. + */ + private final RepaintArea targetPaintArea; // private volatile boolean paintPending; private volatile boolean isLayouting; @@ -137,7 +130,7 @@ public abstract class LWComponentPeer private int fNumDropTargets = 0; private CDropTarget fDropTarget = null; - private PlatformComponent platformComponent; + private final PlatformComponent platformComponent; private final class DelegateContainer extends Container { { @@ -175,6 +168,7 @@ public abstract class LWComponentPeer } public LWComponentPeer(T target, PlatformComponent platformComponent) { + targetPaintArea = new LWRepaintArea(); this.target = target; this.platformComponent = platformComponent; @@ -201,10 +195,13 @@ public abstract class LWComponentPeer synchronized (getDelegateLock()) { delegate = createDelegate(); if (delegate != null) { + delegate.setVisible(false); delegateContainer = new DelegateContainer(); delegateContainer.add(delegate); delegateContainer.addNotify(); delegate.addNotify(); + resetColorsAndFont(delegate); + delegate.setOpaque(true); } else { return; } @@ -278,27 +275,28 @@ public abstract class LWComponentPeer return getDelegate(); } - /* - * Initializes this peer by fetching all the properties from the target. - * The call to initialize() is not placed to LWComponentPeer ctor to - * let the subclass ctor to finish completely first. Instead, it's the - * LWToolkit object who is responsible for initialization. + /** + * Initializes this peer. The call to initialize() is not placed to + * LWComponentPeer ctor to let the subclass ctor to finish completely first. + * Instead, it's the LWToolkit object who is responsible for initialization. + * Note that we call setVisible() at the end of initialization. */ - public void initialize() { + public final void initialize() { platformComponent.initialize(target, this, getPlatformWindow()); - targetPaintArea = new LWRepaintArea(); - if (getDelegate() != null) { - synchronized (getDelegateLock()) { - resetColorsAndFont(delegate); - getDelegate().setOpaque(true); - } - } + initializeImpl(); + setVisible(target.isVisible()); + } + + /** + * Fetching general properties from the target. Should be overridden in + * subclasses to initialize specific peers properties. + */ + void initializeImpl() { setBackground(target.getBackground()); setForeground(target.getForeground()); setFont(target.getFont()); setBounds(target.getBounds()); setEnabled(target.isEnabled()); - setVisible(target.isVisible()); } private static void resetColorsAndFont(final Container c) { @@ -314,15 +312,18 @@ public abstract class LWComponentPeer return stateLock; } - // Synchronize all operations with the Swing delegates under - // AWT tree lock, using a new separate lock to synchronize - // access to delegates may lead deadlocks + /** + * Synchronize all operations with the Swing delegates under AWT tree lock, + * using a new separate lock to synchronize access to delegates may lead + * deadlocks. Think of it as a 'virtual EDT'. + * + * @return DelegateLock + */ final Object getDelegateLock() { - //return delegateTreeLock; return getTarget().getTreeLock(); } - protected final static Object getPeerTreeLock() { + protected static final Object getPeerTreeLock() { return peerTreeLock; } @@ -758,14 +759,17 @@ public abstract class LWComponentPeer } @Override - public void setVisible(boolean v) { + public void setVisible(final boolean v) { synchronized (getStateLock()) { if (visible == v) { return; } visible = v; } + setVisibleImpl(v); + } + protected void setVisibleImpl(final boolean v) { final D delegate = getDelegate(); if (delegate != null) { @@ -1355,7 +1359,7 @@ public abstract class LWComponentPeer * * @see #isVisible() */ - protected boolean isShowing() { + protected final boolean isShowing() { synchronized (getPeerTreeLock()) { if (isVisible()) { final LWContainerPeer container = getContainerPeer(); diff --git a/jdk/src/macosx/classes/sun/lwawt/LWLabelPeer.java b/jdk/src/macosx/classes/sun/lwawt/LWLabelPeer.java index 7577007fa7f..f8c764364cc 100644 --- a/jdk/src/macosx/classes/sun/lwawt/LWLabelPeer.java +++ b/jdk/src/macosx/classes/sun/lwawt/LWLabelPeer.java @@ -60,8 +60,8 @@ final class LWLabelPeer extends LWComponentPeer } @Override - public void initialize() { - super.initialize(); + void initializeImpl() { + super.initializeImpl(); setText(getTarget().getText()); setAlignment(getTarget().getAlignment()); } diff --git a/jdk/src/macosx/classes/sun/lwawt/LWListPeer.java b/jdk/src/macosx/classes/sun/lwawt/LWListPeer.java index df705fd5068..1e6154fd64f 100644 --- a/jdk/src/macosx/classes/sun/lwawt/LWListPeer.java +++ b/jdk/src/macosx/classes/sun/lwawt/LWListPeer.java @@ -49,8 +49,8 @@ final class LWListPeer } @Override - public void initialize() { - super.initialize(); + void initializeImpl() { + super.initializeImpl(); setMultipleMode(getTarget().isMultipleMode()); final int[] selectedIndices = getTarget().getSelectedIndexes(); synchronized (getDelegateLock()) { diff --git a/jdk/src/macosx/classes/sun/lwawt/LWScrollBarPeer.java b/jdk/src/macosx/classes/sun/lwawt/LWScrollBarPeer.java index d376a6b1d82..688f9e96f16 100644 --- a/jdk/src/macosx/classes/sun/lwawt/LWScrollBarPeer.java +++ b/jdk/src/macosx/classes/sun/lwawt/LWScrollBarPeer.java @@ -54,8 +54,8 @@ final class LWScrollBarPeer extends LWComponentPeer } @Override - public void initialize() { - super.initialize(); + void initializeImpl() { + super.initializeImpl(); final Scrollbar target = getTarget(); setValues(target.getValue(), target.getVisibleAmount(), target.getMinimum(), target.getMaximum()); diff --git a/jdk/src/macosx/classes/sun/lwawt/LWScrollPanePeer.java b/jdk/src/macosx/classes/sun/lwawt/LWScrollPanePeer.java index 1b1bdf5369e..1e386f25725 100644 --- a/jdk/src/macosx/classes/sun/lwawt/LWScrollPanePeer.java +++ b/jdk/src/macosx/classes/sun/lwawt/LWScrollPanePeer.java @@ -70,8 +70,8 @@ final class LWScrollPanePeer extends LWContainerPeer } @Override - public void initialize() { - super.initialize(); + void initializeImpl() { + super.initializeImpl(); final int policy = getTarget().getScrollbarDisplayPolicy(); synchronized (getDelegateLock()) { getDelegate().getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); diff --git a/jdk/src/macosx/classes/sun/lwawt/LWTextAreaPeer.java b/jdk/src/macosx/classes/sun/lwawt/LWTextAreaPeer.java index ebe97745d49..8517313b741 100644 --- a/jdk/src/macosx/classes/sun/lwawt/LWTextAreaPeer.java +++ b/jdk/src/macosx/classes/sun/lwawt/LWTextAreaPeer.java @@ -59,8 +59,8 @@ final class LWTextAreaPeer } @Override - public void initialize() { - super.initialize(); + void initializeImpl() { + super.initializeImpl(); final int visibility = getTarget().getScrollbarVisibility(); synchronized (getDelegateLock()) { setScrollBarVisibility(visibility); diff --git a/jdk/src/macosx/classes/sun/lwawt/LWTextComponentPeer.java b/jdk/src/macosx/classes/sun/lwawt/LWTextComponentPeer.java index 01de62b6c96..f0215d40f75 100644 --- a/jdk/src/macosx/classes/sun/lwawt/LWTextComponentPeer.java +++ b/jdk/src/macosx/classes/sun/lwawt/LWTextComponentPeer.java @@ -63,8 +63,8 @@ abstract class LWTextComponentPeer Date: Tue, 26 Jun 2012 16:46:00 +0400 Subject: [PATCH 2/4] 7024749: JDK7 b131---a crash in: Java_sun_awt_windows_ThemeReader_isGetThemeTransitionDurationDefined+0x75 Reviewed-by: art, ant --- .../native/sun/windows/awt_Component.cpp | 37 +++++++----- .../native/sun/windows/awt_Component.h | 2 +- .../native/sun/windows/awt_FileDialog.cpp | 1 + .../windows/native/sun/windows/awt_Frame.cpp | 2 - .../native/sun/windows/awt_TextComponent.cpp | 4 +- .../java/awt/Frame/7024749/bug7024749.java | 59 +++++++++++++++++++ 6 files changed, 85 insertions(+), 20 deletions(-) create mode 100644 jdk/test/java/awt/Frame/7024749/bug7024749.java diff --git a/jdk/src/windows/native/sun/windows/awt_Component.cpp b/jdk/src/windows/native/sun/windows/awt_Component.cpp index 9cc2f76e90b..d7b265c44e3 100644 --- a/jdk/src/windows/native/sun/windows/awt_Component.cpp +++ b/jdk/src/windows/native/sun/windows/awt_Component.cpp @@ -1474,9 +1474,7 @@ LRESULT AwtComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) ::GetClientRect( GetHWnd(), &r ); mr = WmSize(static_cast(wParam), r.right - r.left, r.bottom - r.top); //mr = WmSize(wParam, LOWORD(lParam), HIWORD(lParam)); - if (ImmGetContext() != NULL) { - SetCompositionWindow(r); - } + SetCompositionWindow(r); break; } case WM_SIZING: @@ -1535,7 +1533,10 @@ LRESULT AwtComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) // When the window is deactivated, send WM_IME_ENDCOMPOSITION // message to deactivate the composition window so that // it won't receive keyboard input focus. - if (ImmGetContext() != NULL) { + HIMC hIMC; + HWND hwnd = ImmGetHWnd(); + if ((hIMC = ImmGetContext(hwnd)) != NULL) { + ImmReleaseContext(hwnd, hIMC); DefWindowProc(WM_IME_ENDCOMPOSITION, 0, 0); } } @@ -1718,11 +1719,9 @@ LRESULT AwtComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) case WM_IME_SETCONTEXT: // lParam is passed as pointer and it can be modified. mr = WmImeSetContext(static_cast(wParam), &lParam); - CallProxyDefWindowProc(message, wParam, lParam, retValue, mr); break; case WM_IME_NOTIFY: mr = WmImeNotify(wParam, lParam); - CallProxyDefWindowProc(message, wParam, lParam, retValue, mr); break; case WM_IME_STARTCOMPOSITION: mr = WmImeStartComposition(); @@ -3723,12 +3722,14 @@ MsgRouting AwtComponent::WmPaste() // support IME Composition messages void AwtComponent::SetCompositionWindow(RECT& r) { - HIMC hIMC = ImmGetContext(); + HWND hwnd = ImmGetHWnd(); + HIMC hIMC = ImmGetContext(hwnd); if (hIMC == NULL) { return; } COMPOSITIONFORM cf = {CFS_DEFAULT, {0, 0}, {0, 0, 0, 0}}; ImmSetCompositionWindow(hIMC, &cf); + ImmReleaseContext(hwnd, hIMC); } void AwtComponent::OpenCandidateWindow(int x, int y) @@ -3742,16 +3743,16 @@ void AwtComponent::OpenCandidateWindow(int x, int y) SetCandidateWindow(iCandType, x-rc.left, y-rc.top); } if (m_bitsCandType != 0) { - HWND proxy = GetProxyFocusOwner(); // REMIND: is there any chance GetProxyFocusOwner() returns NULL here? - ::DefWindowProc((proxy != NULL) ? proxy : GetHWnd(), + ::DefWindowProc(ImmGetHWnd(), WM_IME_NOTIFY, IMN_OPENCANDIDATE, m_bitsCandType); } } void AwtComponent::SetCandidateWindow(int iCandType, int x, int y) { - HIMC hIMC = ImmGetContext(); + HWND hwnd = ImmGetHWnd(); + HIMC hIMC = ImmGetContext(hwnd); CANDIDATEFORM cf; cf.dwIndex = iCandType; cf.dwStyle = CFS_CANDIDATEPOS; @@ -3759,17 +3760,20 @@ void AwtComponent::SetCandidateWindow(int iCandType, int x, int y) cf.ptCurrentPos.y = y; ImmSetCandidateWindow(hIMC, &cf); + ImmReleaseContext(hwnd, hIMC); } MsgRouting AwtComponent::WmImeSetContext(BOOL fSet, LPARAM *lplParam) { // If the Windows input context is disabled, do not let Windows // display any UIs. - HIMC hIMC = ImmGetContext(); + HWND hwnd = ImmGetHWnd(); + HIMC hIMC = ImmGetContext(hwnd); if (hIMC == NULL) { *lplParam = 0; return mrDoDefault; } + ImmReleaseContext(hwnd, hIMC); if (fSet) { LPARAM lParam = *lplParam; @@ -3824,11 +3828,13 @@ MsgRouting AwtComponent::WmImeComposition(WORD wChar, LPARAM flags) AwtInputTextInfor* textInfor = NULL; try { - HIMC hIMC = ImmGetContext(); + HWND hwnd = ImmGetHWnd(); + HIMC hIMC = ImmGetContext(hwnd); DASSERT(hIMC!=0); textInfor = new AwtInputTextInfor; textInfor->GetContextData(hIMC, flags); + ImmReleaseContext(hwnd, hIMC); jstring jtextString = textInfor->GetText(); /* The conditions to send the input method event to AWT EDT are: @@ -4012,16 +4018,15 @@ void AwtComponent::InquireCandidatePosition() DASSERT(!safe_ExceptionOccurred(env)); } -HIMC AwtComponent::ImmGetContext() +HWND AwtComponent::ImmGetHWnd() { HWND proxy = GetProxyFocusOwner(); - return ::ImmGetContext((proxy != NULL) ? proxy : GetHWnd()); + return (proxy != NULL) ? proxy : GetHWnd(); } HIMC AwtComponent::ImmAssociateContext(HIMC himc) { - HWND proxy = GetProxyFocusOwner(); - return ::ImmAssociateContext((proxy != NULL) ? proxy : GetHWnd(), himc); + return ::ImmAssociateContext(ImmGetHWnd(), himc); } HWND AwtComponent::GetProxyFocusOwner() diff --git a/jdk/src/windows/native/sun/windows/awt_Component.h b/jdk/src/windows/native/sun/windows/awt_Component.h index 3257c517516..75c1b3c9384 100644 --- a/jdk/src/windows/native/sun/windows/awt_Component.h +++ b/jdk/src/windows/native/sun/windows/awt_Component.h @@ -464,7 +464,7 @@ public: int caretPos, int visiblePos); void InquireCandidatePosition(); INLINE LPARAM GetCandidateType() { return m_bitsCandType; } - HIMC ImmGetContext(); + HWND ImmGetHWnd(); HIMC ImmAssociateContext(HIMC himc); HWND GetProxyFocusOwner(); diff --git a/jdk/src/windows/native/sun/windows/awt_FileDialog.cpp b/jdk/src/windows/native/sun/windows/awt_FileDialog.cpp index abd6e120451..d60fbd329b1 100644 --- a/jdk/src/windows/native/sun/windows/awt_FileDialog.cpp +++ b/jdk/src/windows/native/sun/windows/awt_FileDialog.cpp @@ -156,6 +156,7 @@ FileDialogHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) HIMC hIMC = ::ImmGetContext(hdlg); if (hIMC != NULL) { ::ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_CANCEL, 0); + ::ImmReleaseContext(hdlg, hIMC); } WNDPROC lpfnWndProc = (WNDPROC)(::GetProp(parent, NativeDialogWndProcProp)); diff --git a/jdk/src/windows/native/sun/windows/awt_Frame.cpp b/jdk/src/windows/native/sun/windows/awt_Frame.cpp index 76811dfec03..da1df839535 100644 --- a/jdk/src/windows/native/sun/windows/awt_Frame.cpp +++ b/jdk/src/windows/native/sun/windows/awt_Frame.cpp @@ -319,8 +319,6 @@ LRESULT AwtFrame::ProxyWindowProc(UINT message, WPARAM wParam, LPARAM lParam, Ms case WM_IME_STARTCOMPOSITION: case WM_IME_ENDCOMPOSITION: case WM_IME_COMPOSITION: - case WM_IME_SETCONTEXT: - case WM_IME_NOTIFY: case WM_IME_CONTROL: case WM_IME_COMPOSITIONFULL: case WM_IME_SELECT: diff --git a/jdk/src/windows/native/sun/windows/awt_TextComponent.cpp b/jdk/src/windows/native/sun/windows/awt_TextComponent.cpp index 17d7c68088c..5ba2efca861 100644 --- a/jdk/src/windows/native/sun/windows/awt_TextComponent.cpp +++ b/jdk/src/windows/native/sun/windows/awt_TextComponent.cpp @@ -336,7 +336,8 @@ AwtTextComponent::WmPaste() //im --- override to over the spot composition void AwtTextComponent::SetCompositionWindow(RECT& rc) { - HIMC hIMC = ImmGetContext(); + HWND hwnd = ImmGetHWnd(); + HIMC hIMC = ImmGetContext(hwnd); // rc is not used for text component. COMPOSITIONFORM cf = { CFS_FORCE_POSITION, {0,0}, {0,0,0,0} }; GetCaretPos(&(cf.ptCurrentPos)); @@ -348,6 +349,7 @@ void AwtTextComponent::SetCompositionWindow(RECT& rc) LOGFONT lf; GetObject(m_hFont, sizeof(LOGFONT), &lf); ImmSetCompositionFont(hIMC, &lf); + ImmReleaseContext(hwnd, hIMC); } //im --- end diff --git a/jdk/test/java/awt/Frame/7024749/bug7024749.java b/jdk/test/java/awt/Frame/7024749/bug7024749.java new file mode 100644 index 00000000000..5eb28b6723d --- /dev/null +++ b/jdk/test/java/awt/Frame/7024749/bug7024749.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2012, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7024749 + * @summary JDK7 b131---a crash in: Java_sun_awt_windows_ThemeReader_isGetThemeTransitionDurationDefined+0x75 + * @library ../../../regtesthelpers + * @build Util + * @author Oleg Pekhovskiy: area=awt.toplevel + @run main bug7024749 + */ + +import java.awt.*; +import test.java.awt.regtesthelpers.Util; + +public class bug7024749 { + public static void main(String[] args) { + final Frame f = new Frame("F"); + f.setBounds(0,0,200,200); + f.setEnabled(false); // <- disable the top-level + f.setVisible(true); + + Window w = new Window(f); + w.setBounds(300,300,300,300); + w.add(new TextField(20)); + w.setVisible(true); + + Robot robot = Util.createRobot(); + robot.setAutoDelay(1000); + Util.waitForIdle(robot); + robot.delay(1000); + Util.clickOnTitle(f, robot); + Util.waitForIdle(robot); + + f.dispose(); + System.out.println("Test passed!"); + } +} From 98dba02e885b9a1393a1b6c848a685e8c9a0fe8b Mon Sep 17 00:00:00 2001 From: Anthony Petrov Date: Tue, 26 Jun 2012 17:29:10 +0400 Subject: [PATCH 3/4] 7124326: [macosx] An issue similar to autoshutdown one in two AppContexts situation Don't add SystemTrayPeer to the peers map Reviewed-by: art, leonidr --- jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java | 1 - 1 file changed, 1 deletion(-) diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java b/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java index d3565b845ad..524abddcf4f 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java @@ -216,7 +216,6 @@ public class LWCToolkit extends LWToolkit { @Override public SystemTrayPeer createSystemTray(SystemTray target) { SystemTrayPeer peer = new CSystemTray(); - targetCreatedPeer(target, peer); return peer; } From 86e45f8339f82447c55bf30f174dac186a93789c Mon Sep 17 00:00:00 2001 From: Pavel Porvatov Date: Thu, 28 Jun 2012 14:05:06 +0400 Subject: [PATCH 4/4] 7169111: Unreadable menu bar with Ambiance theme in GTK L&F Reviewed-by: kizune --- .../classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java | 3 ++- .../com/sun/java/swing/plaf/gtk/GTKStyleFactory.java | 6 ++++++ .../share/classes/javax/swing/plaf/synth/SynthMenuUI.java | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java index fcfb1783605..6fb52a4cd4a 100644 --- a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java +++ b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java @@ -796,9 +796,10 @@ public class GTKLookAndFeel extends SynthLookAndFeel { "Menu.margin", zeroInsets, "Menu.cancelMode", "hideMenuTree", "Menu.alignAcceleratorText", Boolean.FALSE, + "Menu.useMenuBarForTopLevelMenus", Boolean.TRUE, - "MenuBar.windowBindings", new Object[] { + "MenuBar.windowBindings", new Object[] { "F10", "takeFocus" }, "MenuBar.font", new FontLazyValue(Region.MENU_BAR), diff --git a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKStyleFactory.java b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKStyleFactory.java index 5c28db4e23d..cfc2fc3ccb3 100644 --- a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKStyleFactory.java +++ b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKStyleFactory.java @@ -92,7 +92,13 @@ class GTKStyleFactory extends SynthStyleFactory { boolean defaultCapable = btn.isDefaultCapable(); key = new ComplexKey(wt, toolButton, defaultCapable); } + } else if (id == Region.MENU) { + if (c instanceof JMenu && ((JMenu) c).isTopLevelMenu() && + UIManager.getBoolean("Menu.useMenuBarForTopLevelMenus")) { + wt = WidgetType.MENU_BAR; + } } + if (key == null) { // Otherwise, just use the WidgetType as the key. key = wt; diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java index 6f309861ba5..a55aa715fe3 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java @@ -299,7 +299,8 @@ public class SynthMenuUI extends BasicMenuUI */ @Override public void propertyChange(PropertyChangeEvent e) { - if (SynthLookAndFeel.shouldUpdateStyle(e)) { + if (SynthLookAndFeel.shouldUpdateStyle(e) || + (e.getPropertyName().equals("ancestor") && UIManager.getBoolean("Menu.useMenuBarForTopLevelMenus"))) { updateStyle((JMenu)e.getSource()); } }