Mercurial > hg > openjdk > icedtea > jdk7 > jdk
changeset 5194:2e90db16f9af
7154480: [macosx] Not all popup menu items are visible
Reviewed-by: swingler, anthony
author | leonidr |
---|---|
date | Wed, 28 Mar 2012 19:08:32 +0400 |
parents | 1dff65eca846 |
children | ad6710b8b7c1 |
files | src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java src/share/classes/javax/swing/JPopupMenu.java src/share/classes/sun/awt/SunToolkit.java |
diffstat | 3 files changed, 39 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Wed Mar 28 19:04:15 2012 +0400 +++ b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Wed Mar 28 19:08:32 2012 +0400 @@ -656,6 +656,14 @@ return ((mods & (InputEvent.META_MASK | InputEvent.CTRL_MASK)) == 0); } + /** + * Returns whether popup is allowed to be shown above the task bar. + */ + @Override + public boolean canPopupOverlapTaskBar() { + return false; + } + // Extends PeerEvent because we want to pass long an ObjC mediator object and because we want these events to be posted early // Typically, rather than relying on the notifier to call notifyAll(), we use the mediator to stop the runloop public static class CPeerEvent extends PeerEvent {
--- a/src/share/classes/javax/swing/JPopupMenu.java Wed Mar 28 19:04:15 2012 +0400 +++ b/src/share/classes/javax/swing/JPopupMenu.java Wed Mar 28 19:08:32 2012 +0400 @@ -41,6 +41,8 @@ import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicComboPopup; import javax.swing.event.*; + +import sun.awt.SunToolkit; import sun.security.util.SecurityConstants; import java.applet.Applet; @@ -346,6 +348,7 @@ long popupBottomY = (long)popupLocation.y + (long)popupSize.height; int scrWidth = scrBounds.width; int scrHeight = scrBounds.height; + if (!canPopupOverlapTaskBar()) { // Insets include the task bar. Take them into account. Insets scrInsets = toolkit.getScreenInsets(gc); @@ -403,25 +406,19 @@ } /** - * Checks that there are enough security permissions - * to make popup "always on top", which allows to show it above the task bar. + * Returns whether popup is allowed to be shown above the task bar. */ static boolean canPopupOverlapTaskBar() { boolean result = true; - try { - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPermission( - SecurityConstants.AWT.SET_WINDOW_ALWAYS_ON_TOP_PERMISSION); - } - } catch (SecurityException se) { - // There is no permission to show popups over the task bar - result = false; + + Toolkit tk = Toolkit.getDefaultToolkit(); + if (tk instanceof SunToolkit) { + result = ((SunToolkit)tk).canPopupOverlapTaskBar(); } + return result; } - /** * Factory method which creates the <code>JMenuItem</code> for * <code>Actions</code> added to the <code>JPopupMenu</code>.
--- a/src/share/classes/sun/awt/SunToolkit.java Wed Mar 28 19:04:15 2012 +0400 +++ b/src/share/classes/sun/awt/SunToolkit.java Wed Mar 28 19:08:32 2012 +0400 @@ -42,6 +42,8 @@ import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; + +import sun.security.util.SecurityConstants; import sun.util.logging.PlatformLogger; import sun.misc.SoftCache; import sun.font.FontDesignMetrics; @@ -1094,6 +1096,26 @@ } /** + * Returns whether popup is allowed to be shown above the task bar. + * This is a default implementation of this method, which checks + * corresponding security permission. + */ + public boolean canPopupOverlapTaskBar() { + boolean result = true; + try { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission( + SecurityConstants.AWT.SET_WINDOW_ALWAYS_ON_TOP_PERMISSION); + } + } catch (SecurityException se) { + // There is no permission to show popups over the task bar + result = false; + } + return result; + } + + /** * Returns a new input method window, with behavior as specified in * {@link java.awt.im.spi.InputMethodContext#createInputMethodWindow}. * If the inputContext is not null, the window should return it from its