提交 e27fb691 编写于 作者: L leonidr

7154480: [macosx] Not all popup menu items are visible

Reviewed-by: art
上级 b3608893
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -656,6 +656,14 @@ public class LWCToolkit extends LWToolkit { ...@@ -656,6 +656,14 @@ public class LWCToolkit extends LWToolkit {
return ((mods & (InputEvent.META_MASK | InputEvent.CTRL_MASK)) == 0); 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 // 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 // Typically, rather than relying on the notifier to call notifyAll(), we use the mediator to stop the runloop
public static class CPeerEvent extends PeerEvent { public static class CPeerEvent extends PeerEvent {
......
/* /*
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -41,6 +41,8 @@ import javax.swing.plaf.PopupMenuUI; ...@@ -41,6 +41,8 @@ import javax.swing.plaf.PopupMenuUI;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicComboPopup; import javax.swing.plaf.basic.BasicComboPopup;
import javax.swing.event.*; import javax.swing.event.*;
import sun.awt.SunToolkit;
import sun.security.util.SecurityConstants; import sun.security.util.SecurityConstants;
import java.applet.Applet; import java.applet.Applet;
...@@ -347,6 +349,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement { ...@@ -347,6 +349,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement {
long popupBottomY = (long)popupLocation.y + (long)popupSize.height; long popupBottomY = (long)popupLocation.y + (long)popupSize.height;
int scrWidth = scrBounds.width; int scrWidth = scrBounds.width;
int scrHeight = scrBounds.height; int scrHeight = scrBounds.height;
if (!canPopupOverlapTaskBar()) { if (!canPopupOverlapTaskBar()) {
// Insets include the task bar. Take them into account. // Insets include the task bar. Take them into account.
Insets scrInsets = toolkit.getScreenInsets(gc); Insets scrInsets = toolkit.getScreenInsets(gc);
...@@ -407,25 +410,19 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement { ...@@ -407,25 +410,19 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement {
} }
/** /**
* Checks that there are enough security permissions * Returns whether popup is allowed to be shown above the task bar.
* to make popup "always on top", which allows to show it above the task bar.
*/ */
static boolean canPopupOverlapTaskBar() { static boolean canPopupOverlapTaskBar() {
boolean result = true; boolean result = true;
try {
SecurityManager sm = System.getSecurityManager(); Toolkit tk = Toolkit.getDefaultToolkit();
if (sm != null) { if (tk instanceof SunToolkit) {
sm.checkPermission( result = ((SunToolkit)tk).canPopupOverlapTaskBar();
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; return result;
} }
/** /**
* Factory method which creates the <code>JMenuItem</code> for * Factory method which creates the <code>JMenuItem</code> for
* <code>Actions</code> added to the <code>JPopupMenu</code>. * <code>Actions</code> added to the <code>JPopupMenu</code>.
......
/* /*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -42,6 +42,8 @@ import java.util.concurrent.TimeUnit; ...@@ -42,6 +42,8 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import sun.security.util.SecurityConstants;
import sun.util.logging.PlatformLogger; import sun.util.logging.PlatformLogger;
import sun.misc.SoftCache; import sun.misc.SoftCache;
import sun.font.FontDesignMetrics; import sun.font.FontDesignMetrics;
...@@ -1135,6 +1137,26 @@ public abstract class SunToolkit extends Toolkit ...@@ -1135,6 +1137,26 @@ public abstract class SunToolkit extends Toolkit
return ((mods & InputEvent.ALT_MASK) == (mods & InputEvent.CTRL_MASK)); return ((mods & InputEvent.ALT_MASK) == (mods & InputEvent.CTRL_MASK));
} }
/**
* 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 * Returns a new input method window, with behavior as specified in
* {@link java.awt.im.spi.InputMethodContext#createInputMethodWindow}. * {@link java.awt.im.spi.InputMethodContext#createInputMethodWindow}.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册