提交 9119e3ec 编写于 作者: A anthony

6818787: It is possible to reposition the security icon too far from the...

6818787: It is possible to reposition the security icon too far from the border of the window on X11
Summary: The constraints for the position of the icon are moved to the shared code
Reviewed-by: art, dcherepanov
上级 1f65791c
......@@ -3593,16 +3593,56 @@ public class Window extends Container implements Accessible {
// ****************** END OF MIXING CODE ********************************
// This method gets the window location/size as reported by the native
// system since the locally cached values may represent outdated data.
// NOTE: this method is invoked on the toolkit thread, and therefore
// is not supposed to become public/user-overridable.
/**
* Limit the given double value with the given range.
*/
private static double limit(double value, double min, double max) {
value = Math.max(value, min);
value = Math.min(value, max);
return value;
}
/**
* Calculate the position of the security warning.
*
* This method gets the window location/size as reported by the native
* system since the locally cached values may represent outdated data.
*
* The method is used from the native code, or via AWTAccessor.
*
* NOTE: this method is invoked on the toolkit thread, and therefore is not
* supposed to become public/user-overridable.
*/
private Point2D calculateSecurityWarningPosition(double x, double y,
double w, double h)
{
return new Point2D.Double(
x + w * securityWarningAlignmentX + securityWarningPointX,
y + h * securityWarningAlignmentY + securityWarningPointY);
// The position according to the spec of SecurityWarning.setPosition()
double wx = x + w * securityWarningAlignmentX + securityWarningPointX;
double wy = y + h * securityWarningAlignmentY + securityWarningPointY;
// First, make sure the warning is not too far from the window bounds
wx = Window.limit(wx,
x - securityWarningWidth - 2,
x + w + 2);
wy = Window.limit(wy,
y - securityWarningHeight - 2,
y + h + 2);
// Now make sure the warning window is visible on the screen
Rectangle screenBounds = graphicsConfig.getBounds();
Insets screenInsets =
Toolkit.getDefaultToolkit().getScreenInsets(graphicsConfig);
wx = Window.limit(wx,
screenBounds.x + screenInsets.left,
screenBounds.x + screenBounds.width - screenInsets.right
- securityWarningWidth);
wy = Window.limit(wy,
screenBounds.y + screenInsets.top,
screenBounds.y + screenBounds.height - screenInsets.bottom
- securityWarningHeight);
return new Point2D.Double(wx, wy);
}
static {
......
......@@ -707,31 +707,6 @@ void AwtWindow::CalculateWarningWindowBounds(JNIEnv *env, LPRECT rect)
env->DeleteLocalRef(point2D);
//Make sure the warning is not far from the window bounds
x = max(x, windowBounds.left - (int)warningWindowWidth - 2);
x = min(x, windowBounds.right + (int)warningWindowWidth + 2);
y = max(y, windowBounds.top - (int)warningWindowHeight - 2);
y = min(y, windowBounds.bottom + (int)warningWindowHeight + 2);
// Now make sure the warning window is visible on the screen
HMONITOR hmon = MonitorFromWindow(GetHWnd(), MONITOR_DEFAULTTOPRIMARY);
DASSERT(hmon != NULL);
RECT monitorBounds;
RECT monitorInsets;
MonitorBounds(hmon, &monitorBounds);
if (!AwtToolkit::GetScreenInsets(m_screenNum, &monitorInsets)) {
::ZeroMemory(&monitorInsets, sizeof(monitorInsets));
}
x = max(x, monitorBounds.left + monitorInsets.left);
x = min(x, monitorBounds.right - monitorInsets.right - (int)warningWindowWidth);
y = max(y, monitorBounds.top + monitorInsets.top);
y = min(y, monitorBounds.bottom - monitorInsets.bottom - (int)warningWindowHeight);
rect->left = x;
rect->top = y;
rect->right = rect->left + warningWindowWidth;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册