8342903: Deprecate for removal java.awt.Window.getWarningString()
Reviewed-by: kizune, erikj, azvegint
@ -46,18 +46,6 @@ EXCLUDE_FILES += \
|
|||||||
javax/swing/plaf/nimbus/SpinnerPainter.java \
|
javax/swing/plaf/nimbus/SpinnerPainter.java \
|
||||||
javax/swing/plaf/nimbus/SplitPanePainter.java \
|
javax/swing/plaf/nimbus/SplitPanePainter.java \
|
||||||
javax/swing/plaf/nimbus/TabbedPanePainter.java \
|
javax/swing/plaf/nimbus/TabbedPanePainter.java \
|
||||||
sun/awt/resources/security-icon-bw16.png \
|
|
||||||
sun/awt/resources/security-icon-bw24.png \
|
|
||||||
sun/awt/resources/security-icon-bw32.png \
|
|
||||||
sun/awt/resources/security-icon-bw48.png \
|
|
||||||
sun/awt/resources/security-icon-interim16.png \
|
|
||||||
sun/awt/resources/security-icon-interim24.png \
|
|
||||||
sun/awt/resources/security-icon-interim32.png \
|
|
||||||
sun/awt/resources/security-icon-interim48.png \
|
|
||||||
sun/awt/resources/security-icon-yellow16.png \
|
|
||||||
sun/awt/resources/security-icon-yellow24.png \
|
|
||||||
sun/awt/resources/security-icon-yellow32.png \
|
|
||||||
sun/awt/resources/security-icon-yellow48.png \
|
|
||||||
sun/awt/X11/java-icon16.png \
|
sun/awt/X11/java-icon16.png \
|
||||||
sun/awt/X11/java-icon24.png \
|
sun/awt/X11/java-icon24.png \
|
||||||
sun/awt/X11/java-icon32.png \
|
sun/awt/X11/java-icon32.png \
|
||||||
|
@ -37,23 +37,6 @@ GENSRC_AWT_ICONS_SRC += \
|
|||||||
$(X11_ICONS_PATH_PREFIX)/classes/sun/awt/X11/java-icon32.png \
|
$(X11_ICONS_PATH_PREFIX)/classes/sun/awt/X11/java-icon32.png \
|
||||||
$(X11_ICONS_PATH_PREFIX)/classes/sun/awt/X11/java-icon48.png
|
$(X11_ICONS_PATH_PREFIX)/classes/sun/awt/X11/java-icon48.png
|
||||||
|
|
||||||
|
|
||||||
AWT_ICONPATH := $(MODULE_SRC)/share/classes/sun/awt/resources
|
|
||||||
|
|
||||||
GENSRC_AWT_ICONS_SRC += \
|
|
||||||
$(AWT_ICONPATH)/security-icon-bw16.png \
|
|
||||||
$(AWT_ICONPATH)/security-icon-interim16.png \
|
|
||||||
$(AWT_ICONPATH)/security-icon-yellow16.png \
|
|
||||||
$(AWT_ICONPATH)/security-icon-bw24.png \
|
|
||||||
$(AWT_ICONPATH)/security-icon-interim24.png \
|
|
||||||
$(AWT_ICONPATH)/security-icon-yellow24.png \
|
|
||||||
$(AWT_ICONPATH)/security-icon-bw32.png \
|
|
||||||
$(AWT_ICONPATH)/security-icon-interim32.png \
|
|
||||||
$(AWT_ICONPATH)/security-icon-yellow32.png \
|
|
||||||
$(AWT_ICONPATH)/security-icon-bw48.png \
|
|
||||||
$(AWT_ICONPATH)/security-icon-interim48.png \
|
|
||||||
$(AWT_ICONPATH)/security-icon-yellow48.png
|
|
||||||
|
|
||||||
GENSRC_AWT_ICONS_FILES := $(notdir $(GENSRC_AWT_ICONS_SRC))
|
GENSRC_AWT_ICONS_FILES := $(notdir $(GENSRC_AWT_ICONS_SRC))
|
||||||
|
|
||||||
GENSRC_AWT_ICONS_SHORT_NAME = $(subst .,_,$(subst -,_,$(1)))
|
GENSRC_AWT_ICONS_SHORT_NAME = $(subst .,_,$(subst -,_,$(1)))
|
||||||
|
@ -1114,13 +1114,7 @@ public final class FontPanel extends JPanel implements AdjustmentListener {
|
|||||||
/// Position and set size of zoom window as needed
|
/// Position and set size of zoom window as needed
|
||||||
zoomWindow.setLocation( canvasLoc.x + zoomAreaX, canvasLoc.y + zoomAreaY );
|
zoomWindow.setLocation( canvasLoc.x + zoomAreaX, canvasLoc.y + zoomAreaY );
|
||||||
if ( !nowZooming ) {
|
if ( !nowZooming ) {
|
||||||
if ( zoomWindow.getWarningString() != null )
|
zoomWindow.setSize( zoomAreaWidth + 1, zoomAreaHeight + 1 );
|
||||||
/// If this is not opened as a "secure" window,
|
|
||||||
/// it has a banner below the zoom dialog which makes it look really BAD
|
|
||||||
/// So enlarge it by a bit
|
|
||||||
zoomWindow.setSize( zoomAreaWidth + 1, zoomAreaHeight + 20 );
|
|
||||||
else
|
|
||||||
zoomWindow.setSize( zoomAreaWidth + 1, zoomAreaHeight + 1 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Prepare zoomed image
|
/// Prepare zoomed image
|
||||||
|
@ -57,13 +57,6 @@ public class LWKeyboardFocusManagerPeer extends KeyboardFocusManagerPeerImpl {
|
|||||||
focusedWindow = win;
|
focusedWindow = win;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (from != null) {
|
|
||||||
from.updateSecurityWarningVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (to != null) {
|
|
||||||
to.updateSecurityWarningVisibility();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -421,9 +421,6 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
|
|||||||
return clipboard;
|
return clipboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract SecurityWarningWindow createSecurityWarning(
|
|
||||||
Window ownerWindow, LWWindowPeer ownerPeer);
|
|
||||||
|
|
||||||
// ---- DELEGATES ---- //
|
// ---- DELEGATES ---- //
|
||||||
|
|
||||||
public abstract Clipboard createPlatformClipboard();
|
public abstract Clipboard createPlatformClipboard();
|
||||||
|
@ -146,8 +146,6 @@ public class LWWindowPeer
|
|||||||
|
|
||||||
private final PeerType peerType;
|
private final PeerType peerType;
|
||||||
|
|
||||||
private final SecurityWarningWindow warningWindow;
|
|
||||||
|
|
||||||
private volatile boolean targetFocusable;
|
private volatile boolean targetFocusable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -197,18 +195,6 @@ public class LWWindowPeer
|
|||||||
}
|
}
|
||||||
|
|
||||||
platformWindow.initialize(target, this, ownerDelegate);
|
platformWindow.initialize(target, this, ownerDelegate);
|
||||||
// Init warning window(for applets)
|
|
||||||
SecurityWarningWindow warn = null;
|
|
||||||
if (target.getWarningString() != null) {
|
|
||||||
// accessSystemTray permission allows to display TrayIcon, TrayIcon tooltip
|
|
||||||
// and TrayIcon balloon windows without a warning window.
|
|
||||||
if (!AWTAccessor.getWindowAccessor().isTrayIconWindow(target)) {
|
|
||||||
LWToolkit toolkit = (LWToolkit)Toolkit.getDefaultToolkit();
|
|
||||||
warn = toolkit.createSecurityWarning(target, this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
warningWindow = warn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -274,9 +260,6 @@ public class LWWindowPeer
|
|||||||
if (isGrabbing()) {
|
if (isGrabbing()) {
|
||||||
ungrab();
|
ungrab();
|
||||||
}
|
}
|
||||||
if (warningWindow != null) {
|
|
||||||
warningWindow.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
platformWindow.dispose();
|
platformWindow.dispose();
|
||||||
super.disposeImpl();
|
super.disposeImpl();
|
||||||
@ -294,9 +277,6 @@ public class LWWindowPeer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setVisibleImpl(final boolean visible) {
|
protected void setVisibleImpl(final boolean visible) {
|
||||||
if (!visible && warningWindow != null) {
|
|
||||||
warningWindow.setVisible(false, false);
|
|
||||||
}
|
|
||||||
updateFocusableWindowState();
|
updateFocusableWindowState();
|
||||||
super.setVisibleImpl(visible);
|
super.setVisibleImpl(visible);
|
||||||
// TODO: update graphicsConfig, see 4868278
|
// TODO: update graphicsConfig, see 4868278
|
||||||
@ -555,19 +535,6 @@ public class LWWindowPeer
|
|||||||
updateOpaque();
|
updateOpaque();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void repositionSecurityWarning() {
|
|
||||||
if (warningWindow != null) {
|
|
||||||
ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
|
|
||||||
Window target = getTarget();
|
|
||||||
int x = compAccessor.getX(target);
|
|
||||||
int y = compAccessor.getY(target);
|
|
||||||
int width = compAccessor.getWidth(target);
|
|
||||||
int height = compAccessor.getHeight(target);
|
|
||||||
warningWindow.reposition(x, y, width, height);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---- FRAME PEER METHODS ---- //
|
// ---- FRAME PEER METHODS ---- //
|
||||||
|
|
||||||
@Override // FramePeer and DialogPeer
|
@Override // FramePeer and DialogPeer
|
||||||
@ -753,7 +720,6 @@ public class LWWindowPeer
|
|||||||
repaintPeer();
|
repaintPeer();
|
||||||
}
|
}
|
||||||
|
|
||||||
repositionSecurityWarning();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearBackground(final int w, final int h) {
|
private void clearBackground(final int w, final int h) {
|
||||||
@ -991,8 +957,6 @@ public class LWWindowPeer
|
|||||||
Point loc, int xAbs, int yAbs,
|
Point loc, int xAbs, int yAbs,
|
||||||
int clickCount, boolean popupTrigger, int button) {
|
int clickCount, boolean popupTrigger, int button) {
|
||||||
|
|
||||||
updateSecurityWarningVisibility();
|
|
||||||
|
|
||||||
postEvent(new MouseEvent(target,
|
postEvent(new MouseEvent(target,
|
||||||
MouseEvent.MOUSE_ENTERED,
|
MouseEvent.MOUSE_ENTERED,
|
||||||
when, modifiers,
|
when, modifiers,
|
||||||
@ -1004,8 +968,6 @@ public class LWWindowPeer
|
|||||||
Point loc, int xAbs, int yAbs,
|
Point loc, int xAbs, int yAbs,
|
||||||
int clickCount, boolean popupTrigger, int button) {
|
int clickCount, boolean popupTrigger, int button) {
|
||||||
|
|
||||||
updateSecurityWarningVisibility();
|
|
||||||
|
|
||||||
postEvent(new MouseEvent(target,
|
postEvent(new MouseEvent(target,
|
||||||
MouseEvent.MOUSE_EXITED,
|
MouseEvent.MOUSE_EXITED,
|
||||||
when, modifiers,
|
when, modifiers,
|
||||||
@ -1094,7 +1056,6 @@ public class LWWindowPeer
|
|||||||
postEvent(stateChangedEvent);
|
postEvent(stateChangedEvent);
|
||||||
windowState = newWindowState;
|
windowState = newWindowState;
|
||||||
|
|
||||||
updateSecurityWarningVisibility();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getGraphicsConfigScreen(GraphicsConfiguration gc) {
|
private static int getGraphicsConfigScreen(GraphicsConfiguration gc) {
|
||||||
@ -1454,13 +1415,11 @@ public class LWWindowPeer
|
|||||||
@Override
|
@Override
|
||||||
public void enterFullScreenMode() {
|
public void enterFullScreenMode() {
|
||||||
platformWindow.enterFullScreenMode();
|
platformWindow.enterFullScreenMode();
|
||||||
updateSecurityWarningVisibility();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exitFullScreenMode() {
|
public void exitFullScreenMode() {
|
||||||
platformWindow.exitFullScreenMode();
|
platformWindow.exitFullScreenMode();
|
||||||
updateSecurityWarningVisibility();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getLayerPtr() {
|
public long getLayerPtr() {
|
||||||
@ -1495,33 +1454,6 @@ public class LWWindowPeer
|
|||||||
return peerType;
|
return peerType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateSecurityWarningVisibility() {
|
|
||||||
if (warningWindow == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isVisible()) {
|
|
||||||
return; // The warning window should already be hidden.
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean show = false;
|
|
||||||
|
|
||||||
if (!platformWindow.isFullScreenMode()) {
|
|
||||||
if (isVisible()) {
|
|
||||||
if (LWKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow() ==
|
|
||||||
getTarget()) {
|
|
||||||
show = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (platformWindow.isUnderMouse() || warningWindow.isUnderMouse()) {
|
|
||||||
show = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
warningWindow.setVisible(show, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return super.toString() + " [target is " + getTarget() + "]";
|
return super.toString() + " [target is " + getTarget() + "]";
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 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
|
|
||||||
* under the terms of the GNU General Public License version 2 only, as
|
|
||||||
* published by the Free Software Foundation. Oracle designates this
|
|
||||||
* particular file as subject to the "Classpath" exception as provided
|
|
||||||
* by Oracle in the LICENSE file that accompanied this code.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package sun.lwawt;
|
|
||||||
|
|
||||||
public interface SecurityWarningWindow extends PlatformWindow {
|
|
||||||
/**
|
|
||||||
* @param x,y,w,h coordinates of the untrusted window
|
|
||||||
*/
|
|
||||||
public void reposition(int x, int y, int w, int h);
|
|
||||||
|
|
||||||
public void setVisible(boolean visible, boolean doSchedule);
|
|
||||||
}
|
|
@ -189,10 +189,6 @@ class CFileDialog implements FileDialogPeer {
|
|||||||
public void setTitle(String title) {
|
public void setTitle(String title) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void repositionSecurityWarning() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GraphicsConfiguration getAppropriateGraphicsConfiguration(
|
public GraphicsConfiguration getAppropriateGraphicsConfiguration(
|
||||||
GraphicsConfiguration gc) {
|
GraphicsConfiguration gc) {
|
||||||
|
@ -360,7 +360,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
setPtr(ref.get());
|
setPtr(ref.get());
|
||||||
if (peer != null) { // Not applicable to CWarningWindow
|
if (peer != null) {
|
||||||
peer.setTextured(IS(TEXTURED, styleBits));
|
peer.setTextured(IS(TEXTURED, styleBits));
|
||||||
}
|
}
|
||||||
if (target instanceof javax.swing.RootPaneContainer) {
|
if (target instanceof javax.swing.RootPaneContainer) {
|
||||||
|
@ -1,475 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2013, 2021, 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. Oracle designates this
|
|
||||||
* particular file as subject to the "Classpath" exception as provided
|
|
||||||
* by Oracle in the LICENSE file that accompanied this code.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package sun.lwawt.macosx;
|
|
||||||
|
|
||||||
import sun.awt.AWTAccessor;
|
|
||||||
import sun.awt.IconInfo;
|
|
||||||
import sun.java2d.SunGraphics2D;
|
|
||||||
import sun.java2d.SurfaceData;
|
|
||||||
import sun.java2d.metal.MTLLayer;
|
|
||||||
import sun.java2d.opengl.CGLLayer;
|
|
||||||
import sun.lwawt.LWWindowPeer;
|
|
||||||
import sun.lwawt.PlatformEventNotifier;
|
|
||||||
import sun.lwawt.SecurityWarningWindow;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.awt.geom.Point2D;
|
|
||||||
import java.lang.ref.WeakReference;
|
|
||||||
|
|
||||||
public final class CWarningWindow extends CPlatformWindow
|
|
||||||
implements SecurityWarningWindow, PlatformEventNotifier {
|
|
||||||
|
|
||||||
private static class Lock {}
|
|
||||||
private final Lock lock = new Lock();
|
|
||||||
|
|
||||||
private static final int SHOWING_DELAY = 300;
|
|
||||||
private static final int HIDING_DELAY = 2000;
|
|
||||||
|
|
||||||
private Rectangle bounds = new Rectangle();
|
|
||||||
private final WeakReference<LWWindowPeer> ownerPeer;
|
|
||||||
private final Window ownerWindow;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Animation stage.
|
|
||||||
*/
|
|
||||||
private volatile int currentIcon;
|
|
||||||
|
|
||||||
/* -1 - uninitialized.
|
|
||||||
* 0 - 16x16
|
|
||||||
* 1 - 24x24
|
|
||||||
* 2 - 32x32
|
|
||||||
* 3 - 48x48
|
|
||||||
*/
|
|
||||||
private int currentSize = -1;
|
|
||||||
private static IconInfo[][] icons;
|
|
||||||
private static IconInfo getSecurityIconInfo(int size, int num) {
|
|
||||||
synchronized (CWarningWindow.class) {
|
|
||||||
if (icons == null) {
|
|
||||||
icons = new IconInfo[4][3];
|
|
||||||
icons[0][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw16_png.security_icon_bw16_png);
|
|
||||||
icons[0][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim16_png.security_icon_interim16_png);
|
|
||||||
icons[0][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow16_png.security_icon_yellow16_png);
|
|
||||||
icons[1][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw24_png.security_icon_bw24_png);
|
|
||||||
icons[1][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim24_png.security_icon_interim24_png);
|
|
||||||
icons[1][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow24_png.security_icon_yellow24_png);
|
|
||||||
icons[2][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw32_png.security_icon_bw32_png);
|
|
||||||
icons[2][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim32_png.security_icon_interim32_png);
|
|
||||||
icons[2][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow32_png.security_icon_yellow32_png);
|
|
||||||
icons[3][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw48_png.security_icon_bw48_png);
|
|
||||||
icons[3][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim48_png.security_icon_interim48_png);
|
|
||||||
icons[3][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow48_png.security_icon_yellow48_png);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final int sizeIndex = size % icons.length;
|
|
||||||
return icons[sizeIndex][num % icons[sizeIndex].length];
|
|
||||||
}
|
|
||||||
|
|
||||||
public CWarningWindow(final Window _ownerWindow, final LWWindowPeer _ownerPeer) {
|
|
||||||
super();
|
|
||||||
|
|
||||||
this.ownerPeer = new WeakReference<>(_ownerPeer);
|
|
||||||
this.ownerWindow = _ownerWindow;
|
|
||||||
|
|
||||||
initialize(null, null, _ownerPeer.getPlatformWindow());
|
|
||||||
|
|
||||||
setOpaque(false);
|
|
||||||
|
|
||||||
String warningString = ownerWindow.getWarningString();
|
|
||||||
if (warningString != null) {
|
|
||||||
contentView.setToolTip(ownerWindow.getWarningString());
|
|
||||||
}
|
|
||||||
|
|
||||||
updateIconSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param x,y,w,h coordinates of the untrusted window
|
|
||||||
*/
|
|
||||||
public void reposition(int x, int y, int w, int h) {
|
|
||||||
final Point2D point = AWTAccessor.getWindowAccessor().
|
|
||||||
calculateSecurityWarningPosition(ownerWindow, x, y, w, h);
|
|
||||||
setBounds((int)point.getX(), (int)point.getY(), getWidth(), getHeight());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVisible(boolean visible, boolean doSchedule) {
|
|
||||||
synchronized (taskLock) {
|
|
||||||
cancelTasks();
|
|
||||||
|
|
||||||
if (visible) {
|
|
||||||
if (isVisible()) {
|
|
||||||
currentIcon = 0;
|
|
||||||
} else {
|
|
||||||
currentIcon = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
showHideTask = new ShowingTask();
|
|
||||||
LWCToolkit.performOnMainThreadAfterDelay(showHideTask, 50);
|
|
||||||
} else {
|
|
||||||
if (!isVisible()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
showHideTask = new HidingTask();
|
|
||||||
if (doSchedule) {
|
|
||||||
LWCToolkit.performOnMainThreadAfterDelay(showHideTask, HIDING_DELAY);
|
|
||||||
} else {
|
|
||||||
LWCToolkit.performOnMainThreadAfterDelay(showHideTask, 50);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void notifyIconify(boolean iconify) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void notifyZoom(boolean isZoomed) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void notifyExpose(final Rectangle r) {
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void notifyReshape(int x, int y, int w, int h) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void notifyUpdateCursor() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void notifyActivation(boolean activation, LWWindowPeer opposite) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void notifyNCMouseDown() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void notifyMouseEvent(int id, long when, int button, int x, int y,
|
|
||||||
int absX, int absY, int modifiers,
|
|
||||||
int clickCount, boolean popupTrigger,
|
|
||||||
byte[] bdata) {
|
|
||||||
LWWindowPeer peer = ownerPeer.get();
|
|
||||||
if (id == MouseEvent.MOUSE_EXITED) {
|
|
||||||
if (peer != null) {
|
|
||||||
peer.updateSecurityWarningVisibility();
|
|
||||||
}
|
|
||||||
} else if(id == MouseEvent.MOUSE_ENTERED) {
|
|
||||||
if (peer != null) {
|
|
||||||
peer.updateSecurityWarningVisibility();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Rectangle getBounds() {
|
|
||||||
synchronized (lock) {
|
|
||||||
return bounds.getBounds();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isVisible() {
|
|
||||||
synchronized (lock) {
|
|
||||||
return visible;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setVisible(boolean visible) {
|
|
||||||
synchronized (lock) {
|
|
||||||
execute(ptr -> {
|
|
||||||
// Actually show or hide the window
|
|
||||||
if (visible) {
|
|
||||||
CWrapper.NSWindow.orderFront(ptr);
|
|
||||||
} else {
|
|
||||||
CWrapper.NSWindow.orderOut(ptr);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this.visible = visible;
|
|
||||||
|
|
||||||
// Manage parent-child relationship when showing
|
|
||||||
if (visible) {
|
|
||||||
// Order myself above my parent
|
|
||||||
if (owner != null && owner.isVisible()) {
|
|
||||||
owner.execute(ownerPtr -> {
|
|
||||||
execute(ptr -> {
|
|
||||||
CWrapper.NSWindow.orderWindow(ptr,
|
|
||||||
CWrapper.NSWindow.NSWindowAbove,
|
|
||||||
ownerPtr);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// do not allow security warning to be obscured by other windows
|
|
||||||
applyWindowLevel(ownerWindow);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void notifyMouseWheelEvent(long when, int x, int y, int absX,
|
|
||||||
int absY, int modifiers, int scrollType,
|
|
||||||
int scrollAmount, int wheelRotation,
|
|
||||||
double preciseWheelRotation,
|
|
||||||
byte[] bdata) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void notifyKeyEvent(int id, long when, int modifiers, int keyCode,
|
|
||||||
char keyChar, int keyLocation, int jextendedkeyCode) {
|
|
||||||
}
|
|
||||||
|
|
||||||
protected int getInitialStyleBits() {
|
|
||||||
int styleBits = 0;
|
|
||||||
CPlatformWindow.SET(styleBits, CPlatformWindow.UTILITY, true);
|
|
||||||
return styleBits;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void deliverMoveResizeEvent(int x, int y, int width, int height,
|
|
||||||
boolean byUser) {
|
|
||||||
|
|
||||||
boolean isResize;
|
|
||||||
synchronized (lock) {
|
|
||||||
isResize = (bounds.width != width || bounds.height != height);
|
|
||||||
bounds = new Rectangle(x, y, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isResize) {
|
|
||||||
replaceSurface();
|
|
||||||
}
|
|
||||||
|
|
||||||
super.deliverMoveResizeEvent(x, y, width, height, byUser);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected CPlatformResponder createPlatformResponder() {
|
|
||||||
return new CPlatformResponder(this, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
CPlatformView createContentView() {
|
|
||||||
return new CPlatformView() {
|
|
||||||
public GraphicsConfiguration getGraphicsConfiguration() {
|
|
||||||
LWWindowPeer peer = ownerPeer.get();
|
|
||||||
return peer.getGraphicsConfiguration();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Rectangle getBounds() {
|
|
||||||
return CWarningWindow.this.getBounds();
|
|
||||||
}
|
|
||||||
|
|
||||||
public CGLLayer createCGLayer() {
|
|
||||||
return new CGLLayer(null) {
|
|
||||||
public Rectangle getBounds() {
|
|
||||||
return CWarningWindow.this.getBounds();
|
|
||||||
}
|
|
||||||
|
|
||||||
public GraphicsConfiguration getGraphicsConfiguration() {
|
|
||||||
LWWindowPeer peer = ownerPeer.get();
|
|
||||||
return peer.getGraphicsConfiguration();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOpaque() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public MTLLayer createMTLLayer() {
|
|
||||||
return new MTLLayer(null) {
|
|
||||||
public Rectangle getBounds() {
|
|
||||||
return CWarningWindow.this.getBounds();
|
|
||||||
}
|
|
||||||
|
|
||||||
public GraphicsConfiguration getGraphicsConfiguration() {
|
|
||||||
LWWindowPeer peer = ownerPeer.get();
|
|
||||||
return peer.getGraphicsConfiguration();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOpaque() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
cancelTasks();
|
|
||||||
SurfaceData surfaceData = contentView.getSurfaceData();
|
|
||||||
if (surfaceData != null) {
|
|
||||||
surfaceData.invalidate();
|
|
||||||
}
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void cancelTasks() {
|
|
||||||
synchronized (taskLock) {
|
|
||||||
if (showHideTask != null) {
|
|
||||||
showHideTask.cancel();
|
|
||||||
showHideTask = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateIconSize() {
|
|
||||||
int newSize = -1;
|
|
||||||
|
|
||||||
if (ownerWindow != null) {
|
|
||||||
Insets insets = ownerWindow.getInsets();
|
|
||||||
int max = Math.max(insets.top, Math.max(insets.bottom,
|
|
||||||
Math.max(insets.left, insets.right)));
|
|
||||||
if (max < 24) {
|
|
||||||
newSize = 0;
|
|
||||||
} else if (max < 32) {
|
|
||||||
newSize = 1;
|
|
||||||
} else if (max < 48) {
|
|
||||||
newSize = 2;
|
|
||||||
} else {
|
|
||||||
newSize = 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Make sure we have a valid size
|
|
||||||
if (newSize == -1) {
|
|
||||||
newSize = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronized (lock) {
|
|
||||||
if (newSize != currentSize) {
|
|
||||||
currentSize = newSize;
|
|
||||||
IconInfo ico = getSecurityIconInfo(currentSize, 0);
|
|
||||||
AWTAccessor.getWindowAccessor().setSecurityWarningSize(
|
|
||||||
ownerWindow, ico.getWidth(), ico.getHeight());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Graphics getGraphics() {
|
|
||||||
SurfaceData sd = contentView.getSurfaceData();
|
|
||||||
if (ownerWindow == null || sd == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new SunGraphics2D(sd, SystemColor.windowText, SystemColor.window,
|
|
||||||
ownerWindow.getFont());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void repaint() {
|
|
||||||
final Graphics g = getGraphics();
|
|
||||||
if (g != null) {
|
|
||||||
try {
|
|
||||||
((Graphics2D) g).setComposite(AlphaComposite.Src);
|
|
||||||
g.drawImage(getSecurityIconInfo().getImage(), 0, 0, null);
|
|
||||||
} finally {
|
|
||||||
g.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void replaceSurface() {
|
|
||||||
SurfaceData oldData = contentView.getSurfaceData();
|
|
||||||
|
|
||||||
replaceSurfaceData();
|
|
||||||
|
|
||||||
if (oldData != null && oldData != contentView.getSurfaceData()) {
|
|
||||||
oldData.flush();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getWidth() {
|
|
||||||
return getSecurityIconInfo().getWidth();
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getHeight() {
|
|
||||||
return getSecurityIconInfo().getHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
private IconInfo getSecurityIconInfo() {
|
|
||||||
return getSecurityIconInfo(currentSize, currentIcon);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Lock taskLock = new Lock();
|
|
||||||
private CancelableRunnable showHideTask;
|
|
||||||
|
|
||||||
private abstract static class CancelableRunnable implements Runnable {
|
|
||||||
private volatile boolean perform = true;
|
|
||||||
|
|
||||||
public final void cancel() {
|
|
||||||
perform = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final void run() {
|
|
||||||
if (perform) {
|
|
||||||
perform();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void perform();
|
|
||||||
}
|
|
||||||
|
|
||||||
private class HidingTask extends CancelableRunnable {
|
|
||||||
@Override
|
|
||||||
public void perform() {
|
|
||||||
synchronized (lock) {
|
|
||||||
setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronized (taskLock) {
|
|
||||||
showHideTask = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ShowingTask extends CancelableRunnable {
|
|
||||||
@Override
|
|
||||||
public void perform() {
|
|
||||||
synchronized (lock) {
|
|
||||||
if (!isVisible()) {
|
|
||||||
setVisible(true);
|
|
||||||
}
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronized (taskLock) {
|
|
||||||
if (currentIcon > 0) {
|
|
||||||
currentIcon--;
|
|
||||||
showHideTask = new ShowingTask();
|
|
||||||
LWCToolkit.performOnMainThreadAfterDelay(showHideTask, SHOWING_DELAY);
|
|
||||||
} else {
|
|
||||||
showHideTask = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -117,7 +117,6 @@ import sun.lwawt.LWWindowPeer.PeerType;
|
|||||||
import sun.lwawt.PlatformComponent;
|
import sun.lwawt.PlatformComponent;
|
||||||
import sun.lwawt.PlatformDropTarget;
|
import sun.lwawt.PlatformDropTarget;
|
||||||
import sun.lwawt.PlatformWindow;
|
import sun.lwawt.PlatformWindow;
|
||||||
import sun.lwawt.SecurityWarningWindow;
|
|
||||||
|
|
||||||
@SuppressWarnings("serial") // JDK implementation class
|
@SuppressWarnings("serial") // JDK implementation class
|
||||||
final class NamedCursor extends Cursor {
|
final class NamedCursor extends Cursor {
|
||||||
@ -292,12 +291,6 @@ public final class LWCToolkit extends LWToolkit {
|
|||||||
return super.createDialog(target);
|
return super.createDialog(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected SecurityWarningWindow createSecurityWarning(Window ownerWindow,
|
|
||||||
LWWindowPeer ownerPeer) {
|
|
||||||
return new CWarningWindow(ownerWindow, ownerPeer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PlatformComponent createPlatformComponent() {
|
protected PlatformComponent createPlatformComponent() {
|
||||||
return new CPlatformComponent();
|
return new CPlatformComponent();
|
||||||
|
@ -378,22 +378,6 @@ public class Desktop {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calls to the security manager's {@code checkPermission} method with an
|
|
||||||
* {@code AWTPermission("showWindowWithoutWarningBanner")} permission. This
|
|
||||||
* permission is needed, because we cannot add a security warning icon to
|
|
||||||
* the windows of the external native application.
|
|
||||||
*/
|
|
||||||
private void checkAWTPermission() {
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
SecurityManager sm = System.getSecurityManager();
|
|
||||||
if (sm != null) {
|
|
||||||
sm.checkPermission(new AWTPermission(
|
|
||||||
"showWindowWithoutWarningBanner"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launches the associated application to open the file.
|
* Launches the associated application to open the file.
|
||||||
*
|
*
|
||||||
@ -411,7 +395,6 @@ public class Desktop {
|
|||||||
*/
|
*/
|
||||||
public void open(File file) throws IOException {
|
public void open(File file) throws IOException {
|
||||||
file = new File(file.getPath());
|
file = new File(file.getPath());
|
||||||
checkAWTPermission();
|
|
||||||
checkExec();
|
checkExec();
|
||||||
checkActionSupport(Action.OPEN);
|
checkActionSupport(Action.OPEN);
|
||||||
checkFileValidation(file);
|
checkFileValidation(file);
|
||||||
@ -434,7 +417,6 @@ public class Desktop {
|
|||||||
*/
|
*/
|
||||||
public void edit(File file) throws IOException {
|
public void edit(File file) throws IOException {
|
||||||
file = new File(file.getPath());
|
file = new File(file.getPath());
|
||||||
checkAWTPermission();
|
|
||||||
checkExec();
|
checkExec();
|
||||||
checkActionSupport(Action.EDIT);
|
checkActionSupport(Action.EDIT);
|
||||||
file.canWrite();
|
file.canWrite();
|
||||||
@ -493,7 +475,6 @@ public class Desktop {
|
|||||||
* @see java.net.URI
|
* @see java.net.URI
|
||||||
*/
|
*/
|
||||||
public void browse(URI uri) throws IOException {
|
public void browse(URI uri) throws IOException {
|
||||||
checkAWTPermission();
|
|
||||||
checkExec();
|
checkExec();
|
||||||
checkActionSupport(Action.BROWSE);
|
checkActionSupport(Action.BROWSE);
|
||||||
Objects.requireNonNull(uri);
|
Objects.requireNonNull(uri);
|
||||||
@ -510,7 +491,6 @@ public class Desktop {
|
|||||||
* found, or it fails to be launched
|
* found, or it fails to be launched
|
||||||
*/
|
*/
|
||||||
public void mail() throws IOException {
|
public void mail() throws IOException {
|
||||||
checkAWTPermission();
|
|
||||||
checkExec();
|
checkExec();
|
||||||
checkActionSupport(Action.MAIL);
|
checkActionSupport(Action.MAIL);
|
||||||
URI mailtoURI = null;
|
URI mailtoURI = null;
|
||||||
@ -548,7 +528,6 @@ public class Desktop {
|
|||||||
* @see java.net.URI
|
* @see java.net.URI
|
||||||
*/
|
*/
|
||||||
public void mail(URI mailtoURI) throws IOException {
|
public void mail(URI mailtoURI) throws IOException {
|
||||||
checkAWTPermission();
|
|
||||||
checkExec();
|
checkExec();
|
||||||
checkActionSupport(Action.MAIL);
|
checkActionSupport(Action.MAIL);
|
||||||
if (mailtoURI == null) throw new NullPointerException();
|
if (mailtoURI == null) throw new NullPointerException();
|
||||||
@ -860,7 +839,6 @@ public class Desktop {
|
|||||||
* @since 9
|
* @since 9
|
||||||
*/
|
*/
|
||||||
public void openHelpViewer() {
|
public void openHelpViewer() {
|
||||||
checkAWTPermission();
|
|
||||||
checkExec();
|
checkExec();
|
||||||
checkEventsProcessingPermission();
|
checkEventsProcessingPermission();
|
||||||
checkActionSupport(Action.APP_HELP_VIEWER);
|
checkActionSupport(Action.APP_HELP_VIEWER);
|
||||||
@ -903,7 +881,6 @@ public class Desktop {
|
|||||||
*/
|
*/
|
||||||
public void browseFileDirectory(File file) {
|
public void browseFileDirectory(File file) {
|
||||||
file = new File(file.getPath());
|
file = new File(file.getPath());
|
||||||
checkAWTPermission();
|
|
||||||
checkExec();
|
checkExec();
|
||||||
checkActionSupport(Action.BROWSE_FILE_DIR);
|
checkActionSupport(Action.BROWSE_FILE_DIR);
|
||||||
checkFileValidation(file);
|
checkFileValidation(file);
|
||||||
|
@ -209,18 +209,6 @@ public class Window extends Container implements Accessible {
|
|||||||
POPUP
|
POPUP
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This represents the warning message that is
|
|
||||||
* to be displayed in a non secure window. ie :
|
|
||||||
* a window that has a security manager installed that denies
|
|
||||||
* {@code AWTPermission("showWindowWithoutWarningBanner")}.
|
|
||||||
* This message can be displayed anywhere in the window.
|
|
||||||
*
|
|
||||||
* @serial
|
|
||||||
* @see #getWarningString
|
|
||||||
*/
|
|
||||||
String warningString;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code icons} is the graphical way we can
|
* {@code icons} is the graphical way we can
|
||||||
* represent the frames and dialogs.
|
* represent the frames and dialogs.
|
||||||
@ -398,13 +386,6 @@ public class Window extends Container implements Accessible {
|
|||||||
|
|
||||||
transient boolean isTrayIconWindow = false;
|
transient boolean isTrayIconWindow = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* These fields are initialized in the native peer code
|
|
||||||
* or via AWTAccessor's WindowAccessor.
|
|
||||||
*/
|
|
||||||
private transient volatile int securityWarningWidth;
|
|
||||||
private transient volatile int securityWarningHeight;
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
/* ensure that the necessary native libraries are loaded */
|
/* ensure that the necessary native libraries are loaded */
|
||||||
Toolkit.loadLibraries();
|
Toolkit.loadLibraries();
|
||||||
@ -428,10 +409,6 @@ public class Window extends Container implements Accessible {
|
|||||||
* Constructs a new, initially invisible window in default size with the
|
* Constructs a new, initially invisible window in default size with the
|
||||||
* specified {@code GraphicsConfiguration}.
|
* specified {@code GraphicsConfiguration}.
|
||||||
* <p>
|
* <p>
|
||||||
* If there is a security manager, then it is invoked to check
|
|
||||||
* {@code AWTPermission("showWindowWithoutWarningBanner")}
|
|
||||||
* to determine whether or not the window must be displayed with
|
|
||||||
* a warning banner.
|
|
||||||
*
|
*
|
||||||
* @param gc the {@code GraphicsConfiguration} of the target screen
|
* @param gc the {@code GraphicsConfiguration} of the target screen
|
||||||
* device. If {@code gc} is {@code null}, the system default
|
* device. If {@code gc} is {@code null}, the system default
|
||||||
@ -532,10 +509,6 @@ public class Window extends Container implements Accessible {
|
|||||||
/**
|
/**
|
||||||
* Constructs a new, initially invisible window in the default size.
|
* Constructs a new, initially invisible window in the default size.
|
||||||
* <p>
|
* <p>
|
||||||
* If there is a security manager set, it is invoked to check
|
|
||||||
* {@code AWTPermission("showWindowWithoutWarningBanner")}.
|
|
||||||
* If that check fails with a {@code SecurityException} then a warning
|
|
||||||
* banner is created.
|
|
||||||
*
|
*
|
||||||
* @throws HeadlessException when
|
* @throws HeadlessException when
|
||||||
* {@code GraphicsEnvironment.isHeadless()} returns {@code true}
|
* {@code GraphicsEnvironment.isHeadless()} returns {@code true}
|
||||||
@ -1361,11 +1334,14 @@ public class Window extends Container implements Accessible {
|
|||||||
* Gets the warning string that is displayed with this window.
|
* Gets the warning string that is displayed with this window.
|
||||||
* <p>
|
* <p>
|
||||||
* Warning strings are no longer applicable,
|
* Warning strings are no longer applicable,
|
||||||
* so this method always returns {@code null}.
|
* so this method always returns {@code null} and may be
|
||||||
|
* removed in a future release.
|
||||||
* @return null
|
* @return null
|
||||||
|
* @deprecated since JDK 24
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(since="24", forRemoval=true)
|
||||||
public final String getWarningString() {
|
public final String getWarningString() {
|
||||||
return warningString;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -3075,9 +3051,6 @@ public class Window extends Container implements Accessible {
|
|||||||
shape = (Shape)f.get("shape", null);
|
shape = (Shape)f.get("shape", null);
|
||||||
opacity = (Float)f.get("opacity", 1.0f);
|
opacity = (Float)f.get("opacity", 1.0f);
|
||||||
|
|
||||||
this.securityWarningWidth = 0;
|
|
||||||
this.securityWarningHeight = 0;
|
|
||||||
|
|
||||||
deserializeResources(s);
|
deserializeResources(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3977,69 +3950,12 @@ public class Window extends Container implements Accessible {
|
|||||||
return value;
|
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)
|
|
||||||
{
|
|
||||||
// The desired location for the security warning
|
|
||||||
double wx = x + w * RIGHT_ALIGNMENT + 2.0;
|
|
||||||
double wy = y + h * TOP_ALIGNMENT + 0.0;
|
|
||||||
|
|
||||||
// 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
|
|
||||||
GraphicsConfiguration graphicsConfig =
|
|
||||||
getGraphicsConfiguration_NoClientCode();
|
|
||||||
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 {
|
static {
|
||||||
AWTAccessor.setWindowAccessor(new AWTAccessor.WindowAccessor() {
|
AWTAccessor.setWindowAccessor(new AWTAccessor.WindowAccessor() {
|
||||||
public void updateWindow(Window window) {
|
public void updateWindow(Window window) {
|
||||||
window.updateWindow();
|
window.updateWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSecurityWarningSize(Window window, int width, int height)
|
|
||||||
{
|
|
||||||
window.securityWarningWidth = width;
|
|
||||||
window.securityWarningHeight = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Point2D calculateSecurityWarningPosition(Window window,
|
|
||||||
double x, double y, double w, double h)
|
|
||||||
{
|
|
||||||
return window.calculateSecurityWarningPosition(x, y, w, h);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLWRequestStatus(Window changed, boolean status) {
|
public void setLWRequestStatus(Window changed, boolean status) {
|
||||||
changed.syncLWRequests = status;
|
changed.syncLWRequests = status;
|
||||||
}
|
}
|
||||||
|
@ -114,11 +114,6 @@ public interface WindowPeer extends ContainerPeer {
|
|||||||
*/
|
*/
|
||||||
void updateWindow();
|
void updateWindow();
|
||||||
|
|
||||||
/**
|
|
||||||
* Instructs the peer to update the position of the security warning.
|
|
||||||
*/
|
|
||||||
void repositionSecurityWarning();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests a GC that best suits this Window. The returned GC may differ
|
* Requests a GC that best suits this Window. The returned GC may differ
|
||||||
* from the requested GC passed as the argument to this method. This method
|
* from the requested GC passed as the argument to this method. This method
|
||||||
|
@ -1862,12 +1862,14 @@ public class JInternalFrame extends JComponent implements
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the warning string that is displayed with this internal frame.
|
* Gets the warning string that is displayed with this internal frame.
|
||||||
* Since an internal frame is always secure (since it's fully
|
* This method always returns <code>null</code>.
|
||||||
* contained within a window that might need a warning string)
|
* Warning strings are no longer applicable, even to top-level
|
||||||
* this method always returns <code>null</code>.
|
* windows, so this method may be removed in a future release
|
||||||
* @return <code>null</code>
|
* @return <code>null</code>
|
||||||
* @see java.awt.Window#getWarningString
|
* @see java.awt.Window#getWarningString
|
||||||
|
* @deprecated since JDK 24
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(since="24", forRemoval=true)
|
||||||
@BeanProperty(bound = false)
|
@BeanProperty(bound = false)
|
||||||
public final String getWarningString() {
|
public final String getWarningString() {
|
||||||
return null;
|
return null;
|
||||||
|
@ -305,17 +305,6 @@ public final class AWTAccessor {
|
|||||||
*/
|
*/
|
||||||
void updateWindow(Window window);
|
void updateWindow(Window window);
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the size of the security warning.
|
|
||||||
*/
|
|
||||||
void setSecurityWarningSize(Window w, int width, int height);
|
|
||||||
|
|
||||||
/** Request to recalculate the new position of the security warning for
|
|
||||||
* the given window size/location as reported by the native system.
|
|
||||||
*/
|
|
||||||
Point2D calculateSecurityWarningPosition(Window window,
|
|
||||||
double x, double y, double w, double h);
|
|
||||||
|
|
||||||
/** Sets the synchronous status of focus requests on lightweight
|
/** Sets the synchronous status of focus requests on lightweight
|
||||||
* components in the specified window to the specified value.
|
* components in the specified window to the specified value.
|
||||||
*/
|
*/
|
||||||
|
@ -33,9 +33,6 @@ import java.awt.AWTPermission;
|
|||||||
public final class AWTPermissions {
|
public final class AWTPermissions {
|
||||||
private AWTPermissions() { }
|
private AWTPermissions() { }
|
||||||
|
|
||||||
public static final AWTPermission TOPLEVEL_WINDOW_PERMISSION =
|
|
||||||
new AWTPermission("showWindowWithoutWarningBanner");
|
|
||||||
|
|
||||||
public static final AWTPermission ACCESS_CLIPBOARD_PERMISSION =
|
public static final AWTPermission ACCESS_CLIPBOARD_PERMISSION =
|
||||||
new AWTPermission("accessClipboard");
|
new AWTPermission("accessClipboard");
|
||||||
|
|
||||||
|
@ -590,9 +590,6 @@ public abstract class EmbeddedFrame extends Frame
|
|||||||
public void updateWindow() {
|
public void updateWindow() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void repositionSecurityWarning() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void emulateActivation(boolean activate) {
|
public void emulateActivation(boolean activate) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Before Width: | Height: | Size: 463 B |
Before Width: | Height: | Size: 682 B |
Before Width: | Height: | Size: 795 B |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 489 B |
Before Width: | Height: | Size: 741 B |
Before Width: | Height: | Size: 871 B |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 477 B |
Before Width: | Height: | Size: 749 B |
Before Width: | Height: | Size: 866 B |
Before Width: | Height: | Size: 1.3 KiB |
@ -943,13 +943,6 @@ public class XBaseWindow {
|
|||||||
void ungrabInputImpl() {
|
void ungrabInputImpl() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void checkSecurity() {
|
|
||||||
if (XToolkit.isSecurityWarningEnabled() && XToolkit.isToolkitThread()) {
|
|
||||||
StackTraceElement[] stack = (new Throwable()).getStackTrace();
|
|
||||||
log.warning(stack[1] + ": Security violation: calling user code on toolkit thread");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<Long> getChildren() {
|
public Set<Long> getChildren() {
|
||||||
synchronized (getStateLock()) {
|
synchronized (getStateLock()) {
|
||||||
return new HashSet<Long>(children);
|
return new HashSet<Long>(children);
|
||||||
|
@ -112,9 +112,6 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
|||||||
|
|
||||||
content = XContentWindow.createContent(this);
|
content = XContentWindow.createContent(this);
|
||||||
|
|
||||||
if (warningWindow != null) {
|
|
||||||
warningWindow.toFront();
|
|
||||||
}
|
|
||||||
focusProxy = createFocusProxy();
|
focusProxy = createFocusProxy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -843,7 +840,6 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
|||||||
reconfigureContentWindow(newDimensions);
|
reconfigureContentWindow(newDimensions);
|
||||||
updateChildrenSizes();
|
updateChildrenSizes();
|
||||||
|
|
||||||
repositionSecurityWarning();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkShellRectSize(Rectangle shellRect) {
|
private void checkShellRectSize(Rectangle shellRect) {
|
||||||
|
@ -216,7 +216,6 @@ public class XEmbedHelper {
|
|||||||
|
|
||||||
// Shouldn't be called on Toolkit thread.
|
// Shouldn't be called on Toolkit thread.
|
||||||
AWTKeyStroke getKeyStrokeForKeySym(long keysym, long state) {
|
AWTKeyStroke getKeyStrokeForKeySym(long keysym, long state) {
|
||||||
XBaseWindow.checkSecurity();
|
|
||||||
|
|
||||||
int keycode;
|
int keycode;
|
||||||
|
|
||||||
|
@ -79,13 +79,6 @@ public class XKeyboardFocusManagerPeer extends KeyboardFocusManagerPeerImpl {
|
|||||||
to = AWTAccessor.getComponentAccessor().getPeer(currentFocusedWindow);
|
to = AWTAccessor.getComponentAccessor().getPeer(currentFocusedWindow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (from != null) {
|
|
||||||
from.updateSecurityWarningVisibility();
|
|
||||||
}
|
|
||||||
if (to != null) {
|
|
||||||
to.updateSecurityWarningVisibility();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -272,7 +272,6 @@ class XScrollPanePeer extends XComponentPeer implements ScrollPanePeer, XScrollb
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
void scroll(int x, int y, int flag, int type) {
|
void scroll(int x, int y, int flag, int type) {
|
||||||
checkSecurity();
|
|
||||||
ScrollPane sp = (ScrollPane)target;
|
ScrollPane sp = (ScrollPane)target;
|
||||||
Component c = getScrollChild();
|
Component c = getScrollChild();
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
|
@ -199,7 +199,6 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
|
|||||||
private static final X11GraphicsDevice device;
|
private static final X11GraphicsDevice device;
|
||||||
private static final long display;
|
private static final long display;
|
||||||
static int awt_multiclick_time;
|
static int awt_multiclick_time;
|
||||||
static boolean securityWarningEnabled;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dimensions of default virtual screen in pixels. These values are used to
|
* Dimensions of default virtual screen in pixels. These values are used to
|
||||||
@ -211,7 +210,6 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
|
|||||||
private static XMouseInfoPeer xPeer;
|
private static XMouseInfoPeer xPeer;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
initSecurityWarning();
|
|
||||||
if (GraphicsEnvironment.isHeadless()) {
|
if (GraphicsEnvironment.isHeadless()) {
|
||||||
localEnv = null;
|
localEnv = null;
|
||||||
device = null;
|
device = null;
|
||||||
@ -240,16 +238,6 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
|
|||||||
return Thread.currentThread() == toolkitThread;
|
return Thread.currentThread() == toolkitThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initSecurityWarning() {
|
|
||||||
// Enable warning only for internal builds
|
|
||||||
String runtime = System.getProperty("java.runtime.version");
|
|
||||||
securityWarningEnabled = (runtime != null && runtime.contains("internal"));
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean isSecurityWarningEnabled() {
|
|
||||||
return securityWarningEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
static native void awt_output_flush();
|
static native void awt_output_flush();
|
||||||
|
|
||||||
static void awtFUnlock() {
|
static void awtFUnlock() {
|
||||||
|
@ -1,416 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2003, 2021, 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. Oracle designates this
|
|
||||||
* particular file as subject to the "Classpath" exception as provided
|
|
||||||
* by Oracle in the LICENSE file that accompanied this code.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package sun.awt.X11;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.geom.Point2D;
|
|
||||||
import java.lang.ref.WeakReference;
|
|
||||||
|
|
||||||
import sun.awt.IconInfo;
|
|
||||||
import sun.awt.AWTAccessor;
|
|
||||||
import sun.awt.SunToolkit;
|
|
||||||
|
|
||||||
class XWarningWindow extends XWindow {
|
|
||||||
private static final int SHOWING_DELAY = 330;
|
|
||||||
private static final int HIDING_DELAY = 2000;
|
|
||||||
|
|
||||||
private final Window ownerWindow;
|
|
||||||
private WeakReference<XWindowPeer> ownerPeer;
|
|
||||||
private long parentWindow;
|
|
||||||
|
|
||||||
private static final String OWNER = "OWNER";
|
|
||||||
private InfoWindow.Tooltip tooltip;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Animation stage.
|
|
||||||
*/
|
|
||||||
private volatile int currentIcon;
|
|
||||||
|
|
||||||
/* -1 - uninitialized.
|
|
||||||
* 0 - 16x16
|
|
||||||
* 1 - 24x24
|
|
||||||
* 2 - 32x32
|
|
||||||
* 3 - 48x48
|
|
||||||
*/
|
|
||||||
private int currentSize = -1;
|
|
||||||
private static IconInfo[][] icons;
|
|
||||||
private static IconInfo getSecurityIconInfo(int size, int num) {
|
|
||||||
synchronized (XWarningWindow.class) {
|
|
||||||
if (icons == null) {
|
|
||||||
icons = new IconInfo[4][3];
|
|
||||||
if (XlibWrapper.dataModel == 32) {
|
|
||||||
icons[0][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw16_png.security_icon_bw16_png);
|
|
||||||
icons[0][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim16_png.security_icon_interim16_png);
|
|
||||||
icons[0][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow16_png.security_icon_yellow16_png);
|
|
||||||
icons[1][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw24_png.security_icon_bw24_png);
|
|
||||||
icons[1][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim24_png.security_icon_interim24_png);
|
|
||||||
icons[1][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow24_png.security_icon_yellow24_png);
|
|
||||||
icons[2][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw32_png.security_icon_bw32_png);
|
|
||||||
icons[2][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim32_png.security_icon_interim32_png);
|
|
||||||
icons[2][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow32_png.security_icon_yellow32_png);
|
|
||||||
icons[3][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw48_png.security_icon_bw48_png);
|
|
||||||
icons[3][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim48_png.security_icon_interim48_png);
|
|
||||||
icons[3][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow48_png.security_icon_yellow48_png);
|
|
||||||
} else {
|
|
||||||
icons[0][0] = new IconInfo(sun.awt.AWTIcon64_security_icon_bw16_png.security_icon_bw16_png);
|
|
||||||
icons[0][1] = new IconInfo(sun.awt.AWTIcon64_security_icon_interim16_png.security_icon_interim16_png);
|
|
||||||
icons[0][2] = new IconInfo(sun.awt.AWTIcon64_security_icon_yellow16_png.security_icon_yellow16_png);
|
|
||||||
icons[1][0] = new IconInfo(sun.awt.AWTIcon64_security_icon_bw24_png.security_icon_bw24_png);
|
|
||||||
icons[1][1] = new IconInfo(sun.awt.AWTIcon64_security_icon_interim24_png.security_icon_interim24_png);
|
|
||||||
icons[1][2] = new IconInfo(sun.awt.AWTIcon64_security_icon_yellow24_png.security_icon_yellow24_png);
|
|
||||||
icons[2][0] = new IconInfo(sun.awt.AWTIcon64_security_icon_bw32_png.security_icon_bw32_png);
|
|
||||||
icons[2][1] = new IconInfo(sun.awt.AWTIcon64_security_icon_interim32_png.security_icon_interim32_png);
|
|
||||||
icons[2][2] = new IconInfo(sun.awt.AWTIcon64_security_icon_yellow32_png.security_icon_yellow32_png);
|
|
||||||
icons[3][0] = new IconInfo(sun.awt.AWTIcon64_security_icon_bw48_png.security_icon_bw48_png);
|
|
||||||
icons[3][1] = new IconInfo(sun.awt.AWTIcon64_security_icon_interim48_png.security_icon_interim48_png);
|
|
||||||
icons[3][2] = new IconInfo(sun.awt.AWTIcon64_security_icon_yellow48_png.security_icon_yellow48_png);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final int sizeIndex = size % icons.length;
|
|
||||||
return icons[sizeIndex][num % icons[sizeIndex].length];
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateIconSize() {
|
|
||||||
int newSize = -1;
|
|
||||||
|
|
||||||
if (ownerWindow != null) {
|
|
||||||
Insets insets = ownerWindow.getInsets();
|
|
||||||
int max = Math.max(insets.top, Math.max(insets.bottom,
|
|
||||||
Math.max(insets.left, insets.right)));
|
|
||||||
if (max < 24) {
|
|
||||||
newSize = 0;
|
|
||||||
} else if (max < 32) {
|
|
||||||
newSize = 1;
|
|
||||||
} else if (max < 48) {
|
|
||||||
newSize = 2;
|
|
||||||
} else {
|
|
||||||
newSize = 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Make sure we have a valid size
|
|
||||||
if (newSize == -1) {
|
|
||||||
newSize = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: this is not the most wise solution to use awtLock here,
|
|
||||||
// this should have been sync'ed with the stateLock. However,
|
|
||||||
// the awtLock must be taken first (see XBaseWindow.getStateLock()),
|
|
||||||
// and we need the awtLock anyway to update the shape of the icon.
|
|
||||||
// So it's easier to use just one lock instead.
|
|
||||||
XToolkit.awtLock();
|
|
||||||
try {
|
|
||||||
if (newSize != currentSize) {
|
|
||||||
currentSize = newSize;
|
|
||||||
IconInfo ico = getSecurityIconInfo(currentSize, 0);
|
|
||||||
XlibWrapper.SetBitmapShape(XToolkit.getDisplay(), getWindow(),
|
|
||||||
ico.getWidth(), ico.getHeight(), ico.getIntData());
|
|
||||||
AWTAccessor.getWindowAccessor().setSecurityWarningSize(
|
|
||||||
ownerWindow, ico.getWidth(), ico.getHeight());
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
XToolkit.awtUnlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private IconInfo getSecurityIconInfo() {
|
|
||||||
updateIconSize();
|
|
||||||
return getSecurityIconInfo(currentSize, currentIcon);
|
|
||||||
}
|
|
||||||
|
|
||||||
XWarningWindow(final Window ownerWindow, long parentWindow, XWindowPeer ownerPeer) {
|
|
||||||
super(new XCreateWindowParams(new Object[] {
|
|
||||||
TARGET, ownerWindow,
|
|
||||||
OWNER, Long.valueOf(parentWindow)
|
|
||||||
}));
|
|
||||||
this.ownerWindow = ownerWindow;
|
|
||||||
this.parentWindow = parentWindow;
|
|
||||||
this.tooltip = new InfoWindow.Tooltip(null, getTarget(),
|
|
||||||
new InfoWindow.Tooltip.LiveArguments() {
|
|
||||||
public boolean isDisposed() {
|
|
||||||
return XWarningWindow.this.isDisposed();
|
|
||||||
}
|
|
||||||
public Rectangle getBounds() {
|
|
||||||
return XWarningWindow.this.getBounds();
|
|
||||||
}
|
|
||||||
public String getTooltipString() {
|
|
||||||
return XWarningWindow.this.ownerWindow.getWarningString();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.ownerPeer = new WeakReference<XWindowPeer>(ownerPeer);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void requestNoTaskbar() {
|
|
||||||
XNETProtocol netProtocol = XWM.getWM().getNETProtocol();
|
|
||||||
if (netProtocol != null) {
|
|
||||||
netProtocol.requestState(this, netProtocol.XA_NET_WM_STATE_SKIP_TASKBAR, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
void postInit(XCreateWindowParams params) {
|
|
||||||
super.postInit(params);
|
|
||||||
XToolkit.awtLock();
|
|
||||||
try {
|
|
||||||
XWM.setMotifDecor(this, false, 0, 0);
|
|
||||||
XWM.setOLDecor(this, false, 0);
|
|
||||||
|
|
||||||
long parentWindow = ((Long)params.get(OWNER)).longValue();
|
|
||||||
XlibWrapper.XSetTransientFor(XToolkit.getDisplay(),
|
|
||||||
getWindow(), parentWindow);
|
|
||||||
|
|
||||||
XWMHints hints = getWMHints();
|
|
||||||
hints.set_flags(hints.get_flags() | (int)XUtilConstants.InputHint | (int)XUtilConstants.StateHint);
|
|
||||||
hints.set_input(false);
|
|
||||||
hints.set_initial_state(XUtilConstants.NormalState);
|
|
||||||
XlibWrapper.XSetWMHints(XToolkit.getDisplay(), getWindow(), hints.pData);
|
|
||||||
|
|
||||||
initWMProtocols();
|
|
||||||
requestNoTaskbar();
|
|
||||||
} finally {
|
|
||||||
XToolkit.awtUnlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param x,y,w,h coordinates of the untrusted window
|
|
||||||
*/
|
|
||||||
public void reposition(int x, int y, int w, int h) {
|
|
||||||
Point2D point = AWTAccessor.getWindowAccessor().
|
|
||||||
calculateSecurityWarningPosition(ownerWindow,
|
|
||||||
x, y, w, h);
|
|
||||||
reshape((int)point.getX(), (int)point.getY(), getWidth(), getHeight());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String getWMName() {
|
|
||||||
return "Warning window";
|
|
||||||
}
|
|
||||||
|
|
||||||
public Graphics getGraphics() {
|
|
||||||
if ((surfaceData == null) || (ownerWindow == null)) return null;
|
|
||||||
return getGraphics(surfaceData,
|
|
||||||
getColor(),
|
|
||||||
getBackground(),
|
|
||||||
getFont());
|
|
||||||
}
|
|
||||||
void paint(Graphics g, int x, int y, int width, int height) {
|
|
||||||
g.drawImage(getSecurityIconInfo().getImage(), 0, 0, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
String getWarningString() {
|
|
||||||
return ownerWindow.getWarningString();
|
|
||||||
}
|
|
||||||
|
|
||||||
int getWidth() {
|
|
||||||
return getSecurityIconInfo().getWidth();
|
|
||||||
}
|
|
||||||
|
|
||||||
int getHeight() {
|
|
||||||
return getSecurityIconInfo().getHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
Color getBackground() {
|
|
||||||
return SystemColor.window;
|
|
||||||
}
|
|
||||||
Color getColor() {
|
|
||||||
return Color.black;
|
|
||||||
}
|
|
||||||
Font getFont () {
|
|
||||||
return ownerWindow.getFont();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void repaint() {
|
|
||||||
final Rectangle bounds = getBounds();
|
|
||||||
final Graphics g = getGraphics();
|
|
||||||
if (g != null) {
|
|
||||||
try {
|
|
||||||
paint(g, 0, 0, bounds.width, bounds.height);
|
|
||||||
} finally {
|
|
||||||
g.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void handleExposeEvent(XEvent xev) {
|
|
||||||
super.handleExposeEvent(xev);
|
|
||||||
|
|
||||||
XExposeEvent xe = xev.get_xexpose();
|
|
||||||
final int x = scaleDown(xe.get_x());
|
|
||||||
final int y = scaleDown(xe.get_y());
|
|
||||||
final int width = scaleDown(xe.get_width());
|
|
||||||
final int height = scaleDown(xe.get_height());
|
|
||||||
SunToolkit.executeOnEventHandlerThread(target,
|
|
||||||
new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
final Graphics g = getGraphics();
|
|
||||||
if (g != null) {
|
|
||||||
try {
|
|
||||||
paint(g, x, y, width, height);
|
|
||||||
} finally {
|
|
||||||
g.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean isEventDisabled(XEvent e) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Send a synthetic UnmapNotify in order to withdraw the window.
|
|
||||||
*/
|
|
||||||
private void withdraw() {
|
|
||||||
XEvent req = new XEvent();
|
|
||||||
try {
|
|
||||||
long root;
|
|
||||||
XToolkit.awtLock();
|
|
||||||
try {
|
|
||||||
root = XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber());
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
XToolkit.awtUnlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
req.set_type(XConstants.UnmapNotify);
|
|
||||||
|
|
||||||
XUnmapEvent umev = req.get_xunmap();
|
|
||||||
|
|
||||||
umev.set_event(root);
|
|
||||||
umev.set_window(getWindow());
|
|
||||||
umev.set_from_configure(false);
|
|
||||||
|
|
||||||
XToolkit.awtLock();
|
|
||||||
try {
|
|
||||||
XlibWrapper.XSendEvent(XToolkit.getDisplay(),
|
|
||||||
root,
|
|
||||||
false,
|
|
||||||
XConstants.SubstructureRedirectMask | XConstants.SubstructureNotifyMask,
|
|
||||||
req.pData);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
XToolkit.awtUnlock();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
req.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void stateChanged(long time, int oldState, int newState) {
|
|
||||||
if (newState == XUtilConstants.IconicState) {
|
|
||||||
super.xSetVisible(false);
|
|
||||||
withdraw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void setMouseAbove(boolean above) {
|
|
||||||
super.setMouseAbove(above);
|
|
||||||
XWindowPeer p = ownerPeer.get();
|
|
||||||
if (p != null) {
|
|
||||||
p.updateSecurityWarningVisibility();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void enterNotify(long window) {
|
|
||||||
super.enterNotify(window);
|
|
||||||
if (window == getWindow()) {
|
|
||||||
tooltip.enter();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void leaveNotify(long window) {
|
|
||||||
super.leaveNotify(window);
|
|
||||||
if (window == getWindow()) {
|
|
||||||
tooltip.exit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void xSetVisible(boolean visible) {
|
|
||||||
super.xSetVisible(visible);
|
|
||||||
|
|
||||||
// The _NET_WM_STATE_SKIP_TASKBAR got reset upon hiding/showing,
|
|
||||||
// so we request it every time whenever we change the visibility.
|
|
||||||
requestNoTaskbar();
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Runnable hidingTask = new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
xSetVisible(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private final Runnable showingTask = new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
if (!isVisible()) {
|
|
||||||
xSetVisible(true);
|
|
||||||
updateIconSize();
|
|
||||||
XWindowPeer peer = ownerPeer.get();
|
|
||||||
if (peer != null) {
|
|
||||||
peer.repositionSecurityWarning();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
repaint();
|
|
||||||
if (currentIcon > 0) {
|
|
||||||
currentIcon--;
|
|
||||||
XToolkit.schedule(showingTask, SHOWING_DELAY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public void setSecurityWarningVisible(boolean visible, boolean doSchedule) {
|
|
||||||
if (visible) {
|
|
||||||
XToolkit.remove(hidingTask);
|
|
||||||
XToolkit.remove(showingTask);
|
|
||||||
if (isVisible()) {
|
|
||||||
currentIcon = 0;
|
|
||||||
} else {
|
|
||||||
currentIcon = 3;
|
|
||||||
}
|
|
||||||
if (doSchedule) {
|
|
||||||
XToolkit.schedule(showingTask, 1);
|
|
||||||
} else {
|
|
||||||
showingTask.run();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
XToolkit.remove(showingTask);
|
|
||||||
XToolkit.remove(hidingTask);
|
|
||||||
if (!isVisible()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (doSchedule) {
|
|
||||||
XToolkit.schedule(hidingTask, HIDING_DELAY);
|
|
||||||
} else {
|
|
||||||
hidingTask.run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1488,8 +1488,8 @@ class XWindow extends XBaseWindow implements X11ComponentPeer {
|
|||||||
static native int getKeySymForAWTKeyCode(int keycode);
|
static native int getKeySymForAWTKeyCode(int keycode);
|
||||||
|
|
||||||
/* These two methods are actually applicable to toplevel windows only.
|
/* These two methods are actually applicable to toplevel windows only.
|
||||||
* However, the functionality is required by both the XWindowPeer and
|
* However, the functionality is required by XWindowPeer
|
||||||
* XWarningWindow, both of which have the XWindow as a common ancestor.
|
* which has XWindow as an ancestor.
|
||||||
* See XWM.setMotifDecor() for details.
|
* See XWM.setMotifDecor() for details.
|
||||||
*/
|
*/
|
||||||
public PropMwmHints getMWMHints() {
|
public PropMwmHints getMWMHints() {
|
||||||
|
@ -79,7 +79,6 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
|||||||
|
|
||||||
|
|
||||||
private boolean cachedFocusableWindow;
|
private boolean cachedFocusableWindow;
|
||||||
XWarningWindow warningWindow;
|
|
||||||
|
|
||||||
private boolean alwaysOnTop;
|
private boolean alwaysOnTop;
|
||||||
private boolean locationByPlatform;
|
private boolean locationByPlatform;
|
||||||
@ -277,15 +276,6 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init warning window(for applets)
|
|
||||||
if (((Window)target).getWarningString() != null) {
|
|
||||||
// accessSystemTray permission allows to display TrayIcon, TrayIcon tooltip
|
|
||||||
// and TrayIcon balloon windows without a warning window.
|
|
||||||
if (!AWTAccessor.getWindowAccessor().isTrayIconWindow((Window)target)) {
|
|
||||||
warningWindow = new XWarningWindow((Window)target, getWindow(), this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setSaveUnder(true);
|
setSaveUnder(true);
|
||||||
|
|
||||||
updateIconImages();
|
updateIconImages();
|
||||||
@ -502,9 +492,6 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
|||||||
|
|
||||||
boolean isResized = !bounds.getSize().equals(oldBounds.getSize());
|
boolean isResized = !bounds.getSize().equals(oldBounds.getSize());
|
||||||
boolean isMoved = !bounds.getLocation().equals(oldBounds.getLocation());
|
boolean isMoved = !bounds.getLocation().equals(oldBounds.getLocation());
|
||||||
if (isMoved || isResized) {
|
|
||||||
repositionSecurityWarning();
|
|
||||||
}
|
|
||||||
if (isResized) {
|
if (isResized) {
|
||||||
postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_RESIZED));
|
postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_RESIZED));
|
||||||
}
|
}
|
||||||
@ -807,7 +794,6 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
|||||||
AWTAccessor.getComponentAccessor().setLocation(target, x, y);
|
AWTAccessor.getComponentAccessor().setLocation(target, x, y);
|
||||||
postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_MOVED));
|
postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_MOVED));
|
||||||
}
|
}
|
||||||
repositionSecurityWarning();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final void requestXFocus(long time) {
|
final void requestXFocus(long time) {
|
||||||
@ -1101,9 +1087,6 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
|||||||
}
|
}
|
||||||
updateFocusability();
|
updateFocusability();
|
||||||
promoteDefaultPosition();
|
promoteDefaultPosition();
|
||||||
if (!vis && warningWindow != null) {
|
|
||||||
warningWindow.setSecurityWarningVisible(false, false);
|
|
||||||
}
|
|
||||||
boolean refreshChildsTransientFor = isVisible() != vis;
|
boolean refreshChildsTransientFor = isVisible() != vis;
|
||||||
super.setVisible(vis);
|
super.setVisible(vis);
|
||||||
if (refreshChildsTransientFor) {
|
if (refreshChildsTransientFor) {
|
||||||
@ -1153,7 +1136,6 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
|||||||
if (isOverrideRedirect() && vis) {
|
if (isOverrideRedirect() && vis) {
|
||||||
updateChildrenSizes();
|
updateChildrenSizes();
|
||||||
}
|
}
|
||||||
repositionSecurityWarning();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void suppressWmTakeFocus(boolean doSuppress) {
|
protected void suppressWmTakeFocus(boolean doSuppress) {
|
||||||
@ -1162,9 +1144,6 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
|||||||
final boolean isSimpleWindow() {
|
final boolean isSimpleWindow() {
|
||||||
return !(target instanceof Frame || target instanceof Dialog);
|
return !(target instanceof Frame || target instanceof Dialog);
|
||||||
}
|
}
|
||||||
boolean hasWarningWindow() {
|
|
||||||
return ((Window)target).getWarningString() != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The height of menu bar window
|
// The height of menu bar window
|
||||||
int getMenuBarHeight() {
|
int getMenuBarHeight() {
|
||||||
@ -1176,68 +1155,14 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
|||||||
void updateChildrenSizes() {
|
void updateChildrenSizes() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void repositionSecurityWarning() {
|
|
||||||
// NOTE: On KWin if the window/border snapping option is enabled,
|
|
||||||
// the Java window may be swinging while it's being moved.
|
|
||||||
// This doesn't make the application unusable though looks quite ugly.
|
|
||||||
// Probably we need to find some hint to assign to our Security
|
|
||||||
// Warning window in order to exclude it from the snapping option.
|
|
||||||
// We are not currently aware of existence of such a property.
|
|
||||||
if (warningWindow != null) {
|
|
||||||
// We can't use the coordinates stored in the XBaseWindow since
|
|
||||||
// they are zeros for decorated frames.
|
|
||||||
ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
|
|
||||||
int x = compAccessor.getX(target);
|
|
||||||
int y = compAccessor.getY(target);
|
|
||||||
int width = compAccessor.getWidth(target);
|
|
||||||
int height = compAccessor.getHeight(target);
|
|
||||||
warningWindow.reposition(x, y, width, height);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setMouseAbove(boolean above) {
|
protected void setMouseAbove(boolean above) {
|
||||||
super.setMouseAbove(above);
|
super.setMouseAbove(above);
|
||||||
updateSecurityWarningVisibility();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFullScreenExclusiveModeState(boolean state) {
|
public void setFullScreenExclusiveModeState(boolean state) {
|
||||||
super.setFullScreenExclusiveModeState(state);
|
super.setFullScreenExclusiveModeState(state);
|
||||||
updateSecurityWarningVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateSecurityWarningVisibility() {
|
|
||||||
if (warningWindow == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isVisible()) {
|
|
||||||
return; // The warning window should already be hidden.
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean show = false;
|
|
||||||
|
|
||||||
if (!isFullScreenExclusiveMode()) {
|
|
||||||
int state = getWMState();
|
|
||||||
|
|
||||||
// getWMState() always returns 0 (Withdrawn) for simple windows. Hence
|
|
||||||
// we ignore the state for such windows.
|
|
||||||
if (isVisible() && (state == XUtilConstants.NormalState || isSimpleWindow())) {
|
|
||||||
if (XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow() ==
|
|
||||||
getTarget())
|
|
||||||
{
|
|
||||||
show = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isMouseAbove() || warningWindow.isMouseAbove())
|
|
||||||
{
|
|
||||||
show = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
warningWindow.setSecurityWarningVisible(show, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isOverrideRedirect() {
|
boolean isOverrideRedirect() {
|
||||||
@ -1266,10 +1191,6 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
|||||||
SunToolkit.awtUnlock();
|
SunToolkit.awtUnlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (warningWindow != null) {
|
|
||||||
warningWindow.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
removeRootPropertyEventDispatcher();
|
removeRootPropertyEventDispatcher();
|
||||||
mustControlStackPosition = false;
|
mustControlStackPosition = false;
|
||||||
super.dispose();
|
super.dispose();
|
||||||
@ -1299,7 +1220,6 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
|||||||
// if (ve.get_state() == XlibWrapper.VisibilityUnobscured) {
|
// if (ve.get_state() == XlibWrapper.VisibilityUnobscured) {
|
||||||
// // raiseInputMethodWindow
|
// // raiseInputMethodWindow
|
||||||
// }
|
// }
|
||||||
repositionSecurityWarning();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleRootPropertyNotify(XEvent xev) {
|
void handleRootPropertyNotify(XEvent xev) {
|
||||||
@ -1475,8 +1395,6 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
|||||||
for (ToplevelStateListener topLevelListenerTmp : toplevelStateListeners) {
|
for (ToplevelStateListener topLevelListenerTmp : toplevelStateListeners) {
|
||||||
topLevelListenerTmp.stateChangedICCCM(oldState, newState);
|
topLevelListenerTmp.stateChangedICCCM(oldState, newState);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSecurityWarningVisibility();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isWithdrawn() {
|
boolean isWithdrawn() {
|
||||||
|
@ -651,17 +651,10 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
|
|||||||
private native void nativeGrab();
|
private native void nativeGrab();
|
||||||
private native void nativeUngrab();
|
private native void nativeUngrab();
|
||||||
|
|
||||||
private boolean hasWarningWindow() {
|
|
||||||
return ((Window)target).getWarningString() != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isTargetUndecorated() {
|
boolean isTargetUndecorated() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public native void repositionSecurityWarning();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void print(Graphics g) {
|
public void print(Graphics g) {
|
||||||
// We assume we print the whole frame,
|
// We assume we print the whole frame,
|
||||||
|
@ -27,10 +27,3 @@
|
|||||||
|
|
||||||
AWT_ICON ICON DISCARDABLE "awt.ico"
|
AWT_ICON ICON DISCARDABLE "awt.ico"
|
||||||
CHECK_BITMAP BITMAP DISCARDABLE "check.bmp"
|
CHECK_BITMAP BITMAP DISCARDABLE "check.bmp"
|
||||||
|
|
||||||
// Note: the number of icons used is specified in the
|
|
||||||
// securityWarningIconCounter constant in awt_Toolkit.cpp.
|
|
||||||
SECURITY_WARNING_0 ICON DISCARDABLE "security_warning_bw.ico"
|
|
||||||
SECURITY_WARNING_1 ICON DISCARDABLE "security_warning_int.ico"
|
|
||||||
SECURITY_WARNING_2 ICON DISCARDABLE "security_warning.ico"
|
|
||||||
|
|
||||||
|
@ -6420,10 +6420,7 @@ void AwtComponent::PostUngrabEvent() {
|
|||||||
|
|
||||||
void AwtComponent::SetFocusedWindow(HWND window)
|
void AwtComponent::SetFocusedWindow(HWND window)
|
||||||
{
|
{
|
||||||
HWND old = sm_focusedWindow;
|
|
||||||
sm_focusedWindow = window;
|
sm_focusedWindow = window;
|
||||||
|
|
||||||
AwtWindow::FocusedWindowChanged(old, window);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
|
@ -910,9 +910,6 @@ MsgRouting AwtFrame::WmWindowPosChanging(LPARAM windowPos) {
|
|||||||
MsgRouting AwtFrame::WmSize(UINT type, int w, int h)
|
MsgRouting AwtFrame::WmSize(UINT type, int w, int h)
|
||||||
{
|
{
|
||||||
currentWmSizeState = type;
|
currentWmSizeState = type;
|
||||||
if (currentWmSizeState == SIZE_MINIMIZED) {
|
|
||||||
UpdateSecurityWarningVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_ignoreWmSize) {
|
if (m_ignoreWmSize) {
|
||||||
return mrDoDefault;
|
return mrDoDefault;
|
||||||
|
@ -1438,24 +1438,6 @@ LRESULT CALLBACK AwtToolkit::MouseLowLevelHook(int code,
|
|||||||
}
|
}
|
||||||
|
|
||||||
tk.m_lastWindowUnderMouse = hwnd;
|
tk.m_lastWindowUnderMouse = hwnd;
|
||||||
|
|
||||||
if (fw) {
|
|
||||||
fw->UpdateSecurityWarningVisibility();
|
|
||||||
}
|
|
||||||
// ... however, because we use GA_ROOT, we may find the warningIcon
|
|
||||||
// which is not a Java windows.
|
|
||||||
if (AwtWindow::IsWarningWindow(hwnd)) {
|
|
||||||
hwnd = ::GetParent(hwnd);
|
|
||||||
if (hwnd) {
|
|
||||||
tw = (AwtWindow*)AwtComponent::GetComponent(hwnd);
|
|
||||||
}
|
|
||||||
tk.m_lastWindowUnderMouse = hwnd;
|
|
||||||
}
|
|
||||||
if (tw) {
|
|
||||||
tw->UpdateSecurityWarningVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1909,48 +1891,6 @@ HICON AwtToolkit::GetAwtIconSm()
|
|||||||
return defaultIconSm;
|
return defaultIconSm;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The icon at index 0 must be gray. See AwtWindow::GetSecurityWarningIcon()
|
|
||||||
HICON AwtToolkit::GetSecurityWarningIcon(UINT index, UINT w, UINT h)
|
|
||||||
{
|
|
||||||
//Note: should not exceed 10 because of the current implementation.
|
|
||||||
static const int securityWarningIconCounter = 3;
|
|
||||||
|
|
||||||
static HICON securityWarningIcon[securityWarningIconCounter] = {NULL, NULL, NULL};
|
|
||||||
static UINT securityWarningIconWidth[securityWarningIconCounter] = {0, 0, 0};
|
|
||||||
static UINT securityWarningIconHeight[securityWarningIconCounter] = {0, 0, 0};
|
|
||||||
|
|
||||||
index = AwtToolkit::CalculateWave(index, securityWarningIconCounter);
|
|
||||||
|
|
||||||
if (securityWarningIcon[index] == NULL ||
|
|
||||||
w != securityWarningIconWidth[index] ||
|
|
||||||
h != securityWarningIconHeight[index])
|
|
||||||
{
|
|
||||||
if (securityWarningIcon[index] != NULL)
|
|
||||||
{
|
|
||||||
::DestroyIcon(securityWarningIcon[index]);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const wchar_t securityWarningIconName[] = L"SECURITY_WARNING_";
|
|
||||||
wchar_t iconResourceName[sizeof(securityWarningIconName) + 2];
|
|
||||||
::ZeroMemory(iconResourceName, sizeof(iconResourceName));
|
|
||||||
wcscpy(iconResourceName, securityWarningIconName);
|
|
||||||
|
|
||||||
wchar_t strIndex[2];
|
|
||||||
::ZeroMemory(strIndex, sizeof(strIndex));
|
|
||||||
strIndex[0] = L'0' + index;
|
|
||||||
|
|
||||||
wcscat(iconResourceName, strIndex);
|
|
||||||
|
|
||||||
securityWarningIcon[index] = (HICON)::LoadImage(GetModuleHandle(),
|
|
||||||
iconResourceName,
|
|
||||||
IMAGE_ICON, w, h, LR_DEFAULTCOLOR);
|
|
||||||
securityWarningIconWidth[index] = w;
|
|
||||||
securityWarningIconHeight[index] = h;
|
|
||||||
}
|
|
||||||
|
|
||||||
return securityWarningIcon[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
void throw_if_shutdown(void)
|
void throw_if_shutdown(void)
|
||||||
{
|
{
|
||||||
AwtToolkit::GetInstance().VerifyActive();
|
AwtToolkit::GetInstance().VerifyActive();
|
||||||
|
@ -394,8 +394,6 @@ public:
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
HICON GetSecurityWarningIcon(UINT index, UINT w, UINT h);
|
|
||||||
|
|
||||||
/* Turns on/off dialog modality for the system. */
|
/* Turns on/off dialog modality for the system. */
|
||||||
INLINE AwtDialog* SetModal(AwtDialog* frame) {
|
INLINE AwtDialog* SetModal(AwtDialog* frame) {
|
||||||
AwtDialog* previousDialog = m_pModalDialog;
|
AwtDialog* previousDialog = m_pModalDialog;
|
||||||
|
@ -137,10 +137,6 @@ struct RequestWindowFocusStruct {
|
|||||||
jobject component;
|
jobject component;
|
||||||
jboolean isMouseEventCause;
|
jboolean isMouseEventCause;
|
||||||
};
|
};
|
||||||
// struct for _RepositionSecurityWarning() method
|
|
||||||
struct RepositionSecurityWarningStruct {
|
|
||||||
jobject window;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SetFullScreenExclusiveModeStateStruct {
|
struct SetFullScreenExclusiveModeStateStruct {
|
||||||
jobject window;
|
jobject window;
|
||||||
@ -156,24 +152,18 @@ struct OverrideHandle {
|
|||||||
* AwtWindow fields
|
* AwtWindow fields
|
||||||
*/
|
*/
|
||||||
|
|
||||||
jfieldID AwtWindow::warningStringID;
|
|
||||||
jfieldID AwtWindow::locationByPlatformID;
|
jfieldID AwtWindow::locationByPlatformID;
|
||||||
jfieldID AwtWindow::autoRequestFocusID;
|
jfieldID AwtWindow::autoRequestFocusID;
|
||||||
jfieldID AwtWindow::securityWarningWidthID;
|
|
||||||
jfieldID AwtWindow::securityWarningHeightID;
|
|
||||||
|
|
||||||
jfieldID AwtWindow::windowTypeID;
|
jfieldID AwtWindow::windowTypeID;
|
||||||
jmethodID AwtWindow::notifyWindowStateChangedMID;
|
jmethodID AwtWindow::notifyWindowStateChangedMID;
|
||||||
|
|
||||||
jmethodID AwtWindow::getWarningStringMID;
|
|
||||||
jmethodID AwtWindow::calculateSecurityWarningPositionMID;
|
|
||||||
jmethodID AwtWindow::windowTypeNameMID;
|
jmethodID AwtWindow::windowTypeNameMID;
|
||||||
|
|
||||||
int AwtWindow::ms_instanceCounter = 0;
|
int AwtWindow::ms_instanceCounter = 0;
|
||||||
HHOOK AwtWindow::ms_hCBTFilter;
|
HHOOK AwtWindow::ms_hCBTFilter;
|
||||||
AwtWindow * AwtWindow::m_grabbedWindow = NULL;
|
AwtWindow * AwtWindow::m_grabbedWindow = NULL;
|
||||||
BOOL AwtWindow::sm_resizing = FALSE;
|
BOOL AwtWindow::sm_resizing = FALSE;
|
||||||
UINT AwtWindow::untrustedWindowsCounter = 0;
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* AwtWindow class methods
|
* AwtWindow class methods
|
||||||
@ -189,7 +179,6 @@ AwtWindow::AwtWindow() {
|
|||||||
m_iconInherited = FALSE;
|
m_iconInherited = FALSE;
|
||||||
VERIFY(::SetRectEmpty(&m_insets));
|
VERIFY(::SetRectEmpty(&m_insets));
|
||||||
VERIFY(::SetRectEmpty(&m_old_insets));
|
VERIFY(::SetRectEmpty(&m_old_insets));
|
||||||
VERIFY(::SetRectEmpty(&m_warningRect));
|
|
||||||
|
|
||||||
// what's the best initial value?
|
// what's the best initial value?
|
||||||
m_screenNum = -1;
|
m_screenNum = -1;
|
||||||
@ -208,11 +197,6 @@ AwtWindow::AwtWindow() {
|
|||||||
m_opaque = TRUE;
|
m_opaque = TRUE;
|
||||||
m_opacity = 0xff;
|
m_opacity = 0xff;
|
||||||
|
|
||||||
|
|
||||||
warningString = NULL;
|
|
||||||
warningWindow = NULL;
|
|
||||||
securityTooltipWindow = NULL;
|
|
||||||
securityWarningAnimationStage = 0;
|
|
||||||
currentWmSizeState = SIZE_RESTORED;
|
currentWmSizeState = SIZE_RESTORED;
|
||||||
|
|
||||||
hContentBitmap = NULL;
|
hContentBitmap = NULL;
|
||||||
@ -232,9 +216,6 @@ AwtWindow::AwtWindow() {
|
|||||||
|
|
||||||
AwtWindow::~AwtWindow()
|
AwtWindow::~AwtWindow()
|
||||||
{
|
{
|
||||||
if (warningString != NULL) {
|
|
||||||
delete [] warningString;
|
|
||||||
}
|
|
||||||
DeleteContentBitmap();
|
DeleteContentBitmap();
|
||||||
::DeleteCriticalSection(&contentBitmapCS);
|
::DeleteCriticalSection(&contentBitmapCS);
|
||||||
}
|
}
|
||||||
@ -355,19 +336,6 @@ MsgRouting AwtWindow::WmWindowPosChanging(LPARAM windowPos) {
|
|||||||
return mrDoDefault;
|
return mrDoDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AwtWindow::RepositionSecurityWarning(JNIEnv *env)
|
|
||||||
{
|
|
||||||
RECT rect;
|
|
||||||
CalculateWarningWindowBounds(env, &rect);
|
|
||||||
|
|
||||||
::SetWindowPos(warningWindow, IsAlwaysOnTop() ? HWND_TOPMOST : HWND_NOTOPMOST,
|
|
||||||
rect.left, rect.top,
|
|
||||||
rect.right - rect.left, rect.bottom - rect.top,
|
|
||||||
SWP_ASYNCWINDOWPOS | SWP_NOACTIVATE |
|
|
||||||
SWP_NOOWNERZORDER
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
MsgRouting AwtWindow::WmWindowPosChanged(LPARAM windowPos) {
|
MsgRouting AwtWindow::WmWindowPosChanged(LPARAM windowPos) {
|
||||||
WINDOWPOS * wp = (WINDOWPOS *)windowPos;
|
WINDOWPOS * wp = (WINDOWPOS *)windowPos;
|
||||||
|
|
||||||
@ -385,19 +353,6 @@ MsgRouting AwtWindow::WmWindowPosChanged(LPARAM windowPos) {
|
|||||||
prevScaleRec.scaleY = -1.0f;
|
prevScaleRec.scaleY = -1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reposition the warning window
|
|
||||||
if (IsUntrusted() && warningWindow != NULL) {
|
|
||||||
if (wp->flags & SWP_HIDEWINDOW) {
|
|
||||||
UpdateSecurityWarningVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
RepositionSecurityWarning((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2));
|
|
||||||
|
|
||||||
if (wp->flags & SWP_SHOWWINDOW) {
|
|
||||||
UpdateSecurityWarningVisibility();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wp->flags & SWP_HIDEWINDOW) {
|
if (wp->flags & SWP_HIDEWINDOW) {
|
||||||
EnableTranslucency(FALSE);
|
EnableTranslucency(FALSE);
|
||||||
}
|
}
|
||||||
@ -424,29 +379,13 @@ void AwtWindow::FillClassInfo(WNDCLASSEX *lpwc)
|
|||||||
lpwc->cbWndExtra = DLGWINDOWEXTRA;
|
lpwc->cbWndExtra = DLGWINDOWEXTRA;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AwtWindow::IsWarningWindow(HWND hWnd)
|
|
||||||
{
|
|
||||||
const UINT len = 128;
|
|
||||||
TCHAR windowClassName[len];
|
|
||||||
|
|
||||||
::RealGetWindowClass(hWnd, windowClassName, len);
|
|
||||||
return 0 == _tcsncmp(windowClassName,
|
|
||||||
AwtWindow::GetWarningWindowClassName(), len);
|
|
||||||
}
|
|
||||||
|
|
||||||
LRESULT CALLBACK AwtWindow::CBTFilter(int nCode, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK AwtWindow::CBTFilter(int nCode, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if (nCode == HCBT_ACTIVATE || nCode == HCBT_SETFOCUS) {
|
if (nCode == HCBT_ACTIVATE || nCode == HCBT_SETFOCUS) {
|
||||||
HWND hWnd = (HWND)wParam;
|
HWND hWnd = (HWND)wParam;
|
||||||
AwtComponent *comp = AwtComponent::GetComponent(hWnd);
|
AwtComponent *comp = AwtComponent::GetComponent(hWnd);
|
||||||
|
|
||||||
if (comp == NULL) {
|
if (comp != NULL) {
|
||||||
// Check if it's a security warning icon
|
|
||||||
// See: 5091224, 6181725, 6732583
|
|
||||||
if (AwtWindow::IsWarningWindow(hWnd)) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (comp->IsTopLevel()) {
|
if (comp->IsTopLevel()) {
|
||||||
AwtWindow* win = (AwtWindow*)comp;
|
AwtWindow* win = (AwtWindow*)comp;
|
||||||
|
|
||||||
@ -461,21 +400,6 @@ LRESULT CALLBACK AwtWindow::CBTFilter(int nCode, WPARAM wParam, LPARAM lParam)
|
|||||||
return ::CallNextHookEx(AwtWindow::ms_hCBTFilter, nCode, wParam, lParam);
|
return ::CallNextHookEx(AwtWindow::ms_hCBTFilter, nCode, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AwtWindow::InitSecurityWarningSize(JNIEnv *env)
|
|
||||||
{
|
|
||||||
warningWindowWidth = ::GetSystemMetrics(SM_CXSMICON);
|
|
||||||
warningWindowHeight = ::GetSystemMetrics(SM_CYSMICON);
|
|
||||||
|
|
||||||
jobject target = GetTarget(env);
|
|
||||||
|
|
||||||
env->SetIntField(target, AwtWindow::securityWarningWidthID,
|
|
||||||
warningWindowWidth);
|
|
||||||
env->SetIntField(target, AwtWindow::securityWarningHeightID,
|
|
||||||
warningWindowHeight);
|
|
||||||
|
|
||||||
env->DeleteLocalRef(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AwtWindow::CreateHWnd(JNIEnv *env, LPCWSTR title,
|
void AwtWindow::CreateHWnd(JNIEnv *env, LPCWSTR title,
|
||||||
DWORD windowStyle,
|
DWORD windowStyle,
|
||||||
DWORD windowExStyle,
|
DWORD windowExStyle,
|
||||||
@ -485,25 +409,6 @@ void AwtWindow::CreateHWnd(JNIEnv *env, LPCWSTR title,
|
|||||||
COLORREF colorBackground,
|
COLORREF colorBackground,
|
||||||
jobject peer)
|
jobject peer)
|
||||||
{
|
{
|
||||||
// Retrieve the warning string
|
|
||||||
// Note: we need to get it before CreateHWnd() happens because
|
|
||||||
// the isUntrusted() method may be invoked while the HWND
|
|
||||||
// is being created in response to some window messages.
|
|
||||||
jobject target = env->GetObjectField(peer, AwtObject::targetID);
|
|
||||||
jstring javaWarningString =
|
|
||||||
(jstring)env->CallObjectMethod(target, AwtWindow::getWarningStringMID);
|
|
||||||
|
|
||||||
if (javaWarningString != NULL) {
|
|
||||||
size_t length = env->GetStringLength(javaWarningString) + 1;
|
|
||||||
warningString = new WCHAR[length];
|
|
||||||
env->GetStringRegion(javaWarningString, 0,
|
|
||||||
static_cast<jsize>(length - 1), reinterpret_cast<jchar*>(warningString));
|
|
||||||
warningString[length-1] = L'\0';
|
|
||||||
|
|
||||||
env->DeleteLocalRef(javaWarningString);
|
|
||||||
}
|
|
||||||
env->DeleteLocalRef(target);
|
|
||||||
|
|
||||||
InitType(env, peer);
|
InitType(env, peer);
|
||||||
JNU_CHECK_EXCEPTION(env);
|
JNU_CHECK_EXCEPTION(env);
|
||||||
|
|
||||||
@ -517,330 +422,13 @@ void AwtWindow::CreateHWnd(JNIEnv *env, LPCWSTR title,
|
|||||||
colorForeground,
|
colorForeground,
|
||||||
colorBackground,
|
colorBackground,
|
||||||
peer);
|
peer);
|
||||||
|
|
||||||
// Now we need to create the warning window.
|
|
||||||
CreateWarningWindow(env);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AwtWindow::CreateWarningWindow(JNIEnv *env)
|
|
||||||
{
|
|
||||||
if (!IsUntrusted()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (++AwtWindow::untrustedWindowsCounter == 1) {
|
|
||||||
AwtToolkit::GetInstance().InstallMouseLowLevelHook();
|
|
||||||
}
|
|
||||||
|
|
||||||
InitSecurityWarningSize(env);
|
|
||||||
|
|
||||||
RECT rect;
|
|
||||||
CalculateWarningWindowBounds(env, &rect);
|
|
||||||
|
|
||||||
RegisterWarningWindowClass();
|
|
||||||
warningWindow = ::CreateWindowEx(
|
|
||||||
WS_EX_NOACTIVATE,
|
|
||||||
GetWarningWindowClassName(),
|
|
||||||
warningString,
|
|
||||||
WS_POPUP,
|
|
||||||
rect.left, rect.top,
|
|
||||||
rect.right - rect.left, rect.bottom - rect.top,
|
|
||||||
GetHWnd(), // owner
|
|
||||||
NULL, // menu
|
|
||||||
AwtToolkit::GetInstance().GetModuleHandle(),
|
|
||||||
NULL // lParam
|
|
||||||
);
|
|
||||||
if (warningWindow == NULL) {
|
|
||||||
//XXX: actually this is bad... We didn't manage to create the window.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
HICON hIcon = GetSecurityWarningIcon();
|
|
||||||
|
|
||||||
ICONINFO ii;
|
|
||||||
::GetIconInfo(hIcon, &ii);
|
|
||||||
|
|
||||||
//Note: we assume that every security icon has exactly the same shape.
|
|
||||||
HRGN rgn = BitmapUtil::BitmapToRgn(ii.hbmColor);
|
|
||||||
if (rgn) {
|
|
||||||
::SetWindowRgn(warningWindow, rgn, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now we need to create the tooltip control for this window.
|
|
||||||
if (!ComCtl32Util::GetInstance().IsToolTipControlInitialized()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
securityTooltipWindow = ::CreateWindowEx(
|
|
||||||
WS_EX_TOPMOST,
|
|
||||||
TOOLTIPS_CLASS,
|
|
||||||
NULL,
|
|
||||||
WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
|
|
||||||
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
|
||||||
warningWindow,
|
|
||||||
NULL,
|
|
||||||
AwtToolkit::GetInstance().GetModuleHandle(),
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
::SetWindowPos(securityTooltipWindow,
|
|
||||||
HWND_TOPMOST, 0, 0, 0, 0,
|
|
||||||
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
|
|
||||||
|
|
||||||
|
|
||||||
// We currently don't expect changing the size of the window,
|
|
||||||
// hence we may not care of updating the TOOL position/size.
|
|
||||||
::GetClientRect(warningWindow, &rect);
|
|
||||||
|
|
||||||
TOOLINFO ti;
|
|
||||||
|
|
||||||
ti.cbSize = sizeof(ti);
|
|
||||||
ti.uFlags = TTF_SUBCLASS;
|
|
||||||
ti.hwnd = warningWindow;
|
|
||||||
ti.hinst = AwtToolkit::GetInstance().GetModuleHandle();
|
|
||||||
ti.uId = 0;
|
|
||||||
ti.lpszText = warningString;
|
|
||||||
ti.rect.left = rect.left;
|
|
||||||
ti.rect.top = rect.top;
|
|
||||||
ti.rect.right = rect.right;
|
|
||||||
ti.rect.bottom = rect.bottom;
|
|
||||||
|
|
||||||
::SendMessage(securityTooltipWindow, TTM_ADDTOOL,
|
|
||||||
0, (LPARAM) (LPTOOLINFO) &ti);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AwtWindow::DestroyWarningWindow()
|
|
||||||
{
|
|
||||||
if (!IsUntrusted()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (--AwtWindow::untrustedWindowsCounter == 0) {
|
|
||||||
AwtToolkit::GetInstance().UninstallMouseLowLevelHook();
|
|
||||||
}
|
|
||||||
if (warningWindow != NULL) {
|
|
||||||
// Note that the warningWindow is an owned window, and hence
|
|
||||||
// it would be destroyed automatically. However, the window
|
|
||||||
// class may only be unregistered if there's no any single
|
|
||||||
// window left using this class. Thus, we're destroying the
|
|
||||||
// warning window manually. Note that the tooltip window
|
|
||||||
// will be destroyed automatically because it's an owned
|
|
||||||
// window as well.
|
|
||||||
::DestroyWindow(warningWindow);
|
|
||||||
warningWindow = NULL;
|
|
||||||
securityTooltipWindow = NULL;
|
|
||||||
UnregisterWarningWindowClass();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AwtWindow::DestroyHWnd()
|
void AwtWindow::DestroyHWnd()
|
||||||
{
|
{
|
||||||
DestroyWarningWindow();
|
|
||||||
AwtCanvas::DestroyHWnd();
|
AwtCanvas::DestroyHWnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
LPCTSTR AwtWindow::GetWarningWindowClassName()
|
|
||||||
{
|
|
||||||
return TEXT("SunAwtWarningWindow");
|
|
||||||
}
|
|
||||||
|
|
||||||
void AwtWindow::FillWarningWindowClassInfo(WNDCLASS *lpwc)
|
|
||||||
{
|
|
||||||
lpwc->style = 0L;
|
|
||||||
lpwc->lpfnWndProc = (WNDPROC)WarningWindowProc;
|
|
||||||
lpwc->cbClsExtra = 0;
|
|
||||||
lpwc->cbWndExtra = 0;
|
|
||||||
lpwc->hInstance = AwtToolkit::GetInstance().GetModuleHandle(),
|
|
||||||
lpwc->hIcon = AwtToolkit::GetInstance().GetAwtIcon();
|
|
||||||
lpwc->hCursor = ::LoadCursor(NULL, IDC_ARROW);
|
|
||||||
lpwc->hbrBackground = NULL;
|
|
||||||
lpwc->lpszMenuName = NULL;
|
|
||||||
lpwc->lpszClassName = AwtWindow::GetWarningWindowClassName();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AwtWindow::RegisterWarningWindowClass()
|
|
||||||
{
|
|
||||||
WNDCLASS wc;
|
|
||||||
|
|
||||||
::ZeroMemory(&wc, sizeof(wc));
|
|
||||||
|
|
||||||
if (!::GetClassInfo(AwtToolkit::GetInstance().GetModuleHandle(),
|
|
||||||
AwtWindow::GetWarningWindowClassName(), &wc))
|
|
||||||
{
|
|
||||||
AwtWindow::FillWarningWindowClassInfo(&wc);
|
|
||||||
ATOM atom = ::RegisterClass(&wc);
|
|
||||||
DASSERT(atom != 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AwtWindow::UnregisterWarningWindowClass()
|
|
||||||
{
|
|
||||||
::UnregisterClass(AwtWindow::GetWarningWindowClassName(), AwtToolkit::GetInstance().GetModuleHandle());
|
|
||||||
}
|
|
||||||
|
|
||||||
HICON AwtWindow::GetSecurityWarningIcon()
|
|
||||||
{
|
|
||||||
// It is assumed that the icon at index 0 is gray
|
|
||||||
const UINT index = securityAnimationKind == akShow ?
|
|
||||||
securityWarningAnimationStage : 0;
|
|
||||||
HICON ico = AwtToolkit::GetInstance().GetSecurityWarningIcon(index,
|
|
||||||
warningWindowWidth, warningWindowHeight);
|
|
||||||
return ico;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This function calculates the bounds of the warning window and stores them
|
|
||||||
// into the RECT structure pointed by the argument rect.
|
|
||||||
void AwtWindow::CalculateWarningWindowBounds(JNIEnv *env, LPRECT rect)
|
|
||||||
{
|
|
||||||
RECT windowBounds;
|
|
||||||
AwtToolkit::GetWindowRect(GetHWnd(), &windowBounds);
|
|
||||||
|
|
||||||
jobject target = GetTarget(env);
|
|
||||||
jobject point2D = env->CallObjectMethod(target,
|
|
||||||
calculateSecurityWarningPositionMID,
|
|
||||||
(jdouble)windowBounds.left, (jdouble)windowBounds.top,
|
|
||||||
(jdouble)(windowBounds.right - windowBounds.left),
|
|
||||||
(jdouble)(windowBounds.bottom - windowBounds.top));
|
|
||||||
env->DeleteLocalRef(target);
|
|
||||||
|
|
||||||
static jclass point2DClassID = NULL;
|
|
||||||
static jmethodID point2DGetXMID = NULL;
|
|
||||||
static jmethodID point2DGetYMID = NULL;
|
|
||||||
|
|
||||||
if (point2DClassID == NULL) {
|
|
||||||
jclass point2DClassIDLocal = env->FindClass("java/awt/geom/Point2D");
|
|
||||||
if (point2DClassIDLocal == NULL) {
|
|
||||||
env->DeleteLocalRef(point2D);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
point2DClassID = (jclass)env->NewGlobalRef(point2DClassIDLocal);
|
|
||||||
env->DeleteLocalRef(point2DClassIDLocal);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (point2DGetXMID == NULL) {
|
|
||||||
point2DGetXMID = env->GetMethodID(point2DClassID, "getX", "()D");
|
|
||||||
if (point2DGetXMID == NULL) {
|
|
||||||
env->DeleteLocalRef(point2D);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (point2DGetYMID == NULL) {
|
|
||||||
point2DGetYMID = env->GetMethodID(point2DClassID, "getY", "()D");
|
|
||||||
if (point2DGetYMID == NULL) {
|
|
||||||
env->DeleteLocalRef(point2D);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int x = (int)env->CallDoubleMethod(point2D, point2DGetXMID);
|
|
||||||
int y = (int)env->CallDoubleMethod(point2D, point2DGetYMID);
|
|
||||||
|
|
||||||
env->DeleteLocalRef(point2D);
|
|
||||||
|
|
||||||
rect->left = x;
|
|
||||||
rect->top = y;
|
|
||||||
rect->right = rect->left + warningWindowWidth;
|
|
||||||
rect->bottom = rect->top + warningWindowHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
LRESULT CALLBACK AwtWindow::WarningWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
switch (uMsg) {
|
|
||||||
case WM_PAINT:
|
|
||||||
PaintWarningWindow(hwnd);
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
case WM_MOUSEACTIVATE:
|
|
||||||
{
|
|
||||||
// Retrieve the owner of the warning window.
|
|
||||||
HWND javaWindow = ::GetParent(hwnd);
|
|
||||||
if (javaWindow) {
|
|
||||||
// If the window is blocked by a modal dialog, substitute
|
|
||||||
// its handle with the topmost blocker.
|
|
||||||
HWND topmostBlocker = GetTopmostModalBlocker(javaWindow);
|
|
||||||
if (::IsWindow(topmostBlocker)) {
|
|
||||||
javaWindow = topmostBlocker;
|
|
||||||
}
|
|
||||||
|
|
||||||
::BringWindowToTop(javaWindow);
|
|
||||||
|
|
||||||
AwtWindow * window =
|
|
||||||
(AwtWindow*)AwtComponent::GetComponent(javaWindow);
|
|
||||||
if (window == NULL) {
|
|
||||||
// Quite unlikely to go into here, but it's way better
|
|
||||||
// than getting a crash.
|
|
||||||
::SetForegroundWindow(javaWindow);
|
|
||||||
} else {
|
|
||||||
// Activate the window if it is focusable and inactive
|
|
||||||
if (window->IsFocusableWindow() &&
|
|
||||||
javaWindow != ::GetActiveWindow()) {
|
|
||||||
::SetForegroundWindow(javaWindow);
|
|
||||||
} else {
|
|
||||||
// ...otherwise just start the animation.
|
|
||||||
window->StartSecurityAnimation(akShow);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// In every case if there's a top-most blocker, we need to
|
|
||||||
// enable modal animation.
|
|
||||||
if (::IsWindow(topmostBlocker)) {
|
|
||||||
AwtDialog::AnimateModalBlocker(topmostBlocker);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return MA_NOACTIVATEANDEAT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ::DefWindowProc(hwnd, uMsg, wParam, lParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AwtWindow::PaintWarningWindow(HWND warningWindow)
|
|
||||||
{
|
|
||||||
RECT updateRect;
|
|
||||||
|
|
||||||
if (!::GetUpdateRect(warningWindow, &updateRect, FALSE)) {
|
|
||||||
// got nothing to update
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PAINTSTRUCT ps;
|
|
||||||
HDC hdc = ::BeginPaint(warningWindow, &ps);
|
|
||||||
if (hdc == NULL) {
|
|
||||||
// indicates an error
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PaintWarningWindow(warningWindow, hdc);
|
|
||||||
|
|
||||||
::EndPaint(warningWindow, &ps);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AwtWindow::PaintWarningWindow(HWND warningWindow, HDC hdc)
|
|
||||||
{
|
|
||||||
HWND javaWindow = ::GetParent(warningWindow);
|
|
||||||
|
|
||||||
AwtWindow * window = (AwtWindow*)AwtComponent::GetComponent(javaWindow);
|
|
||||||
if (window == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
::DrawIconEx(hdc, 0, 0, window->GetSecurityWarningIcon(),
|
|
||||||
window->warningWindowWidth, window->warningWindowHeight,
|
|
||||||
0, NULL, DI_NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const UINT_PTR IDT_AWT_SECURITYANIMATION = 0x102;
|
|
||||||
|
|
||||||
// Approximately 6 times a second. 0.75 seconds total.
|
|
||||||
static const UINT securityAnimationTimerElapse = 150;
|
|
||||||
static const UINT securityAnimationMaxIterations = 5;
|
|
||||||
|
|
||||||
void AwtWindow::RepaintWarningWindow()
|
|
||||||
{
|
|
||||||
HDC hdc = ::GetDC(warningWindow);
|
|
||||||
PaintWarningWindow(warningWindow, hdc);
|
|
||||||
::ReleaseDC(warningWindow, hdc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AwtWindow::SetLayered(HWND window, bool layered)
|
void AwtWindow::SetLayered(HWND window, bool layered)
|
||||||
{
|
{
|
||||||
const LONG ex_style = ::GetWindowLong(window, GWL_EXSTYLE);
|
const LONG ex_style = ::GetWindowLong(window, GWL_EXSTYLE);
|
||||||
@ -854,195 +442,9 @@ bool AwtWindow::IsLayered(HWND window)
|
|||||||
return ex_style & WS_EX_LAYERED;
|
return ex_style & WS_EX_LAYERED;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AwtWindow::StartSecurityAnimation(AnimationKind kind)
|
|
||||||
{
|
|
||||||
if (!IsUntrusted()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (warningWindow == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
securityAnimationKind = kind;
|
|
||||||
|
|
||||||
securityWarningAnimationStage = 1;
|
|
||||||
::SetTimer(GetHWnd(), IDT_AWT_SECURITYANIMATION,
|
|
||||||
securityAnimationTimerElapse, NULL);
|
|
||||||
|
|
||||||
if (securityAnimationKind == akShow) {
|
|
||||||
::SetWindowPos(warningWindow,
|
|
||||||
IsAlwaysOnTop() ? HWND_TOPMOST : HWND_NOTOPMOST,
|
|
||||||
0, 0, 0, 0,
|
|
||||||
SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE |
|
|
||||||
SWP_SHOWWINDOW | SWP_NOOWNERZORDER);
|
|
||||||
|
|
||||||
::SetLayeredWindowAttributes(warningWindow, RGB(0, 0, 0),
|
|
||||||
0xFF, LWA_ALPHA);
|
|
||||||
AwtWindow::SetLayered(warningWindow, false);
|
|
||||||
::RedrawWindow(warningWindow, NULL, NULL,
|
|
||||||
RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
|
|
||||||
} else if (securityAnimationKind == akPreHide) {
|
|
||||||
// Pre-hiding means fading-out. We have to make the window layered.
|
|
||||||
// Note: Some VNC clients do not support layered windows, hence
|
|
||||||
// we dynamically turn it on and off. See 6805231.
|
|
||||||
AwtWindow::SetLayered(warningWindow, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AwtWindow::StopSecurityAnimation()
|
|
||||||
{
|
|
||||||
if (!IsUntrusted()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (warningWindow == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
securityWarningAnimationStage = 0;
|
|
||||||
::KillTimer(GetHWnd(), IDT_AWT_SECURITYANIMATION);
|
|
||||||
|
|
||||||
switch (securityAnimationKind) {
|
|
||||||
case akHide:
|
|
||||||
case akPreHide:
|
|
||||||
::SetWindowPos(warningWindow, HWND_NOTOPMOST, 0, 0, 0, 0,
|
|
||||||
SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE |
|
|
||||||
SWP_HIDEWINDOW | SWP_NOOWNERZORDER);
|
|
||||||
break;
|
|
||||||
case akShow:
|
|
||||||
RepaintWarningWindow();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
securityAnimationKind = akNone;
|
|
||||||
}
|
|
||||||
|
|
||||||
MsgRouting AwtWindow::WmTimer(UINT_PTR timerID)
|
MsgRouting AwtWindow::WmTimer(UINT_PTR timerID)
|
||||||
{
|
{
|
||||||
if (timerID != IDT_AWT_SECURITYANIMATION) {
|
return mrPassAlong;
|
||||||
return mrPassAlong;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (securityWarningAnimationStage == 0) {
|
|
||||||
return mrConsume;
|
|
||||||
}
|
|
||||||
|
|
||||||
securityWarningAnimationStage++;
|
|
||||||
if (securityWarningAnimationStage >= securityAnimationMaxIterations) {
|
|
||||||
if (securityAnimationKind == akPreHide) {
|
|
||||||
// chain real hiding
|
|
||||||
StartSecurityAnimation(akHide);
|
|
||||||
} else {
|
|
||||||
StopSecurityAnimation();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
switch (securityAnimationKind) {
|
|
||||||
case akHide:
|
|
||||||
{
|
|
||||||
BYTE opacity = ((int)0xFF *
|
|
||||||
(securityAnimationMaxIterations -
|
|
||||||
securityWarningAnimationStage)) /
|
|
||||||
securityAnimationMaxIterations;
|
|
||||||
::SetLayeredWindowAttributes(warningWindow,
|
|
||||||
RGB(0, 0, 0), opacity, LWA_ALPHA);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case akShow:
|
|
||||||
case akNone: // quite unlikely, but quite safe
|
|
||||||
RepaintWarningWindow();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return mrConsume;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The security warning is visible if:
|
|
||||||
// 1. The window has the keyboard window focus, OR
|
|
||||||
// 2. The mouse pointer is located within the window bounds,
|
|
||||||
// or within the security warning icon.
|
|
||||||
void AwtWindow::UpdateSecurityWarningVisibility()
|
|
||||||
{
|
|
||||||
if (!IsUntrusted()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (warningWindow == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool show = false;
|
|
||||||
|
|
||||||
if (IsVisible() && currentWmSizeState != SIZE_MINIMIZED &&
|
|
||||||
!isFullScreenExclusiveMode())
|
|
||||||
{
|
|
||||||
if (AwtComponent::GetFocusedWindow() == GetHWnd()) {
|
|
||||||
show = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
HWND hwnd = AwtToolkit::GetInstance().GetWindowUnderMouse();
|
|
||||||
if (hwnd == GetHWnd()) {
|
|
||||||
show = true;
|
|
||||||
}
|
|
||||||
if (hwnd == warningWindow) {
|
|
||||||
show = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (show && (!::IsWindowVisible(warningWindow) ||
|
|
||||||
securityAnimationKind == akHide ||
|
|
||||||
securityAnimationKind == akPreHide)) {
|
|
||||||
StartSecurityAnimation(akShow);
|
|
||||||
}
|
|
||||||
if (!show && ::IsWindowVisible(warningWindow)) {
|
|
||||||
StartSecurityAnimation(akPreHide);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AwtWindow::FocusedWindowChanged(HWND from, HWND to)
|
|
||||||
{
|
|
||||||
AwtWindow * fw = (AwtWindow *)AwtComponent::GetComponent(from);
|
|
||||||
AwtWindow * tw = (AwtWindow *)AwtComponent::GetComponent(to);
|
|
||||||
|
|
||||||
if (fw != NULL) {
|
|
||||||
fw->UpdateSecurityWarningVisibility();
|
|
||||||
}
|
|
||||||
if (tw != NULL) {
|
|
||||||
tw->UpdateSecurityWarningVisibility();
|
|
||||||
|
|
||||||
// Flash on receiving the keyboard focus even if the warning
|
|
||||||
// has already been shown (e.g. by hovering with the mouse)
|
|
||||||
tw->StartSecurityAnimation(akShow);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AwtWindow::_RepositionSecurityWarning(void* param)
|
|
||||||
{
|
|
||||||
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
|
|
||||||
|
|
||||||
RepositionSecurityWarningStruct *rsws =
|
|
||||||
static_cast<RepositionSecurityWarningStruct *>(param);
|
|
||||||
jobject self = rsws->window;
|
|
||||||
|
|
||||||
AwtWindow *window = NULL;
|
|
||||||
|
|
||||||
if (self == NULL) {
|
|
||||||
env->ExceptionClear();
|
|
||||||
JNU_ThrowNullPointerException(env, "self");
|
|
||||||
delete rsws;
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
window = (AwtWindow *)JNI_GET_PDATA(self);
|
|
||||||
if (window == NULL) {
|
|
||||||
THROW_NULL_PDATA_IF_NOT_DESTROYED(self);
|
|
||||||
env->DeleteGlobalRef(self);
|
|
||||||
delete rsws;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
window->RepositionSecurityWarning(env);
|
|
||||||
|
|
||||||
env->DeleteGlobalRef(self);
|
|
||||||
delete rsws;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AwtWindow::InitType(JNIEnv *env, jobject peer)
|
void AwtWindow::InitType(JNIEnv *env, jobject peer)
|
||||||
@ -1919,7 +1321,6 @@ MsgRouting AwtWindow::WmSize(UINT type, int w, int h)
|
|||||||
currentWmSizeState = type;
|
currentWmSizeState = type;
|
||||||
|
|
||||||
if (type == SIZE_MINIMIZED) {
|
if (type == SIZE_MINIMIZED) {
|
||||||
UpdateSecurityWarningVisibility();
|
|
||||||
return mrDoDefault;
|
return mrDoDefault;
|
||||||
}
|
}
|
||||||
// Check for the new screen and update the java peer
|
// Check for the new screen and update the java peer
|
||||||
@ -3356,20 +2757,10 @@ Java_java_awt_Window_initIDs(JNIEnv *env, jclass cls)
|
|||||||
{
|
{
|
||||||
TRY;
|
TRY;
|
||||||
|
|
||||||
CHECK_NULL(AwtWindow::warningStringID =
|
|
||||||
env->GetFieldID(cls, "warningString", "Ljava/lang/String;"));
|
|
||||||
CHECK_NULL(AwtWindow::locationByPlatformID =
|
CHECK_NULL(AwtWindow::locationByPlatformID =
|
||||||
env->GetFieldID(cls, "locationByPlatform", "Z"));
|
env->GetFieldID(cls, "locationByPlatform", "Z"));
|
||||||
CHECK_NULL(AwtWindow::securityWarningWidthID =
|
|
||||||
env->GetFieldID(cls, "securityWarningWidth", "I"));
|
|
||||||
CHECK_NULL(AwtWindow::securityWarningHeightID =
|
|
||||||
env->GetFieldID(cls, "securityWarningHeight", "I"));
|
|
||||||
CHECK_NULL(AwtWindow::getWarningStringMID =
|
|
||||||
env->GetMethodID(cls, "getWarningString", "()Ljava/lang/String;"));
|
|
||||||
CHECK_NULL(AwtWindow::autoRequestFocusID =
|
CHECK_NULL(AwtWindow::autoRequestFocusID =
|
||||||
env->GetFieldID(cls, "autoRequestFocus", "Z"));
|
env->GetFieldID(cls, "autoRequestFocus", "Z"));
|
||||||
CHECK_NULL(AwtWindow::calculateSecurityWarningPositionMID =
|
|
||||||
env->GetMethodID(cls, "calculateSecurityWarningPosition", "(DDDD)Ljava/awt/geom/Point2D;"));
|
|
||||||
|
|
||||||
jclass windowTypeClass = env->FindClass("java/awt/Window$Type");
|
jclass windowTypeClass = env->FindClass("java/awt/Window$Type");
|
||||||
CHECK_NULL(windowTypeClass);
|
CHECK_NULL(windowTypeClass);
|
||||||
@ -4016,28 +3407,6 @@ JNIEXPORT jboolean JNICALL Java_sun_awt_windows_WWindowPeer_requestWindowFocus
|
|||||||
CATCH_BAD_ALLOC_RET(JNI_FALSE);
|
CATCH_BAD_ALLOC_RET(JNI_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: sun_awt_windows_WWindowPeer
|
|
||||||
* Method: repositionSecurityWarning
|
|
||||||
* Signature: ()V
|
|
||||||
*/
|
|
||||||
JNIEXPORT void JNICALL
|
|
||||||
Java_sun_awt_windows_WWindowPeer_repositionSecurityWarning(JNIEnv *env,
|
|
||||||
jobject self)
|
|
||||||
{
|
|
||||||
TRY;
|
|
||||||
|
|
||||||
RepositionSecurityWarningStruct *rsws =
|
|
||||||
new RepositionSecurityWarningStruct;
|
|
||||||
rsws->window = env->NewGlobalRef(self);
|
|
||||||
|
|
||||||
AwtToolkit::GetInstance().InvokeFunction(
|
|
||||||
AwtWindow::_RepositionSecurityWarning, rsws);
|
|
||||||
// global refs and mds are deleted in _RepositionSecurityWarning
|
|
||||||
|
|
||||||
CATCH_BAD_ALLOC;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: sun_awt_windows_WLightweightFramePeer
|
* Class: sun_awt_windows_WLightweightFramePeer
|
||||||
* Method: overrideNativeHandle
|
* Method: overrideNativeHandle
|
||||||
|
@ -50,20 +50,15 @@ class AwtWindow : public AwtCanvas {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
/* java.awt.Window field ids */
|
/* java.awt.Window field ids */
|
||||||
static jfieldID warningStringID;
|
|
||||||
static jfieldID locationByPlatformID;
|
static jfieldID locationByPlatformID;
|
||||||
static jfieldID screenID; /* screen number passed over from WindowPeer */
|
static jfieldID screenID; /* screen number passed over from WindowPeer */
|
||||||
static jfieldID autoRequestFocusID;
|
static jfieldID autoRequestFocusID;
|
||||||
static jfieldID securityWarningWidthID;
|
|
||||||
static jfieldID securityWarningHeightID;
|
|
||||||
|
|
||||||
/* sun.awt.windows.WWindowPeer field and method IDs */
|
/* sun.awt.windows.WWindowPeer field and method IDs */
|
||||||
static jfieldID windowTypeID;
|
static jfieldID windowTypeID;
|
||||||
static jmethodID notifyWindowStateChangedMID;
|
static jmethodID notifyWindowStateChangedMID;
|
||||||
|
|
||||||
/* java.awt.Window method IDs */
|
/* java.awt.Window method IDs */
|
||||||
static jmethodID getWarningStringMID;
|
|
||||||
static jmethodID calculateSecurityWarningPositionMID;
|
|
||||||
static jmethodID windowTypeNameMID;
|
static jmethodID windowTypeNameMID;
|
||||||
|
|
||||||
AwtWindow();
|
AwtWindow();
|
||||||
@ -240,7 +235,6 @@ public:
|
|||||||
static void _SetOpacity(void* param);
|
static void _SetOpacity(void* param);
|
||||||
static void _SetOpaque(void* param);
|
static void _SetOpaque(void* param);
|
||||||
static void _UpdateWindow(void* param);
|
static void _UpdateWindow(void* param);
|
||||||
static void _RepositionSecurityWarning(void* param);
|
|
||||||
static void _SetFullScreenExclusiveModeState(void* param);
|
static void _SetFullScreenExclusiveModeState(void* param);
|
||||||
static void _GetNativeWindowSize(void* param);
|
static void _GetNativeWindowSize(void* param);
|
||||||
static void _OverrideHandle(void *param);
|
static void _OverrideHandle(void *param);
|
||||||
@ -257,8 +251,6 @@ public:
|
|||||||
jobject peer);
|
jobject peer);
|
||||||
virtual void DestroyHWnd();
|
virtual void DestroyHWnd();
|
||||||
|
|
||||||
static void FocusedWindowChanged(HWND from, HWND to);
|
|
||||||
|
|
||||||
inline HWND GetOverriddenHWnd() { return m_overriddenHwnd; }
|
inline HWND GetOverriddenHWnd() { return m_overriddenHwnd; }
|
||||||
inline void OverrideHWnd(HWND hwnd) { m_overriddenHwnd = hwnd; }
|
inline void OverrideHWnd(HWND hwnd) { m_overriddenHwnd = hwnd; }
|
||||||
|
|
||||||
@ -304,58 +296,15 @@ private:
|
|||||||
void RedrawWindow();
|
void RedrawWindow();
|
||||||
void DeleteContentBitmap();
|
void DeleteContentBitmap();
|
||||||
|
|
||||||
static UINT untrustedWindowsCounter;
|
|
||||||
|
|
||||||
WCHAR * warningString;
|
|
||||||
|
|
||||||
// The warning icon
|
|
||||||
HWND warningWindow;
|
|
||||||
// The tooltip that appears when hovering the icon
|
|
||||||
HWND securityTooltipWindow;
|
|
||||||
|
|
||||||
//Allows substitute parent window with JavaFX stage to make it below a dialog
|
//Allows substitute parent window with JavaFX stage to make it below a dialog
|
||||||
HWND m_overriddenHwnd;
|
HWND m_overriddenHwnd;
|
||||||
|
|
||||||
UINT warningWindowWidth;
|
|
||||||
UINT warningWindowHeight;
|
|
||||||
void InitSecurityWarningSize(JNIEnv *env);
|
|
||||||
HICON GetSecurityWarningIcon();
|
|
||||||
|
|
||||||
void CreateWarningWindow(JNIEnv *env);
|
|
||||||
void DestroyWarningWindow();
|
|
||||||
static LPCTSTR GetWarningWindowClassName();
|
|
||||||
void FillWarningWindowClassInfo(WNDCLASS *lpwc);
|
|
||||||
void RegisterWarningWindowClass();
|
|
||||||
void UnregisterWarningWindowClass();
|
|
||||||
static LRESULT CALLBACK WarningWindowProc(
|
|
||||||
HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
|
||||||
|
|
||||||
static void PaintWarningWindow(HWND warningWindow);
|
|
||||||
static void PaintWarningWindow(HWND warningWindow, HDC hdc);
|
|
||||||
void RepaintWarningWindow();
|
|
||||||
void CalculateWarningWindowBounds(JNIEnv *env, LPRECT rect);
|
|
||||||
|
|
||||||
void AnimateSecurityWarning(bool enable);
|
|
||||||
UINT securityWarningAnimationStage;
|
|
||||||
|
|
||||||
enum AnimationKind {
|
|
||||||
akNone, akShow, akPreHide, akHide
|
|
||||||
};
|
|
||||||
|
|
||||||
AnimationKind securityAnimationKind;
|
|
||||||
|
|
||||||
void StartSecurityAnimation(AnimationKind kind);
|
|
||||||
void StopSecurityAnimation();
|
|
||||||
|
|
||||||
void RepositionSecurityWarning(JNIEnv *env);
|
|
||||||
|
|
||||||
static void SetLayered(HWND window, bool layered);
|
static void SetLayered(HWND window, bool layered);
|
||||||
static bool IsLayered(HWND window);
|
static bool IsLayered(HWND window);
|
||||||
|
|
||||||
BOOL fullScreenExclusiveModeState;
|
BOOL fullScreenExclusiveModeState;
|
||||||
inline void setFullScreenExclusiveModeState(BOOL isEntered) {
|
inline void setFullScreenExclusiveModeState(BOOL isEntered) {
|
||||||
fullScreenExclusiveModeState = isEntered;
|
fullScreenExclusiveModeState = isEntered;
|
||||||
UpdateSecurityWarningVisibility();
|
|
||||||
}
|
}
|
||||||
inline BOOL isFullScreenExclusiveMode() {
|
inline BOOL isFullScreenExclusiveMode() {
|
||||||
return fullScreenExclusiveModeState;
|
return fullScreenExclusiveModeState;
|
||||||
@ -363,8 +312,6 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void UpdateSecurityWarningVisibility();
|
|
||||||
static bool IsWarningWindow(HWND hWnd);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BOOL m_isResizable;
|
BOOL m_isResizable;
|
||||||
@ -374,10 +321,6 @@ protected:
|
|||||||
BOOL m_iconInherited; /* TRUE if icon is inherited from the owner */
|
BOOL m_iconInherited; /* TRUE if icon is inherited from the owner */
|
||||||
BOOL m_filterFocusAndActivation; /* Used in the WH_CBT hook */
|
BOOL m_filterFocusAndActivation; /* Used in the WH_CBT hook */
|
||||||
|
|
||||||
inline BOOL IsUntrusted() {
|
|
||||||
return warningString != NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
UINT currentWmSizeState;
|
UINT currentWmSizeState;
|
||||||
|
|
||||||
void EnableTranslucency(BOOL enable);
|
void EnableTranslucency(BOOL enable);
|
||||||
|
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 17 KiB |
@ -465,7 +465,6 @@ java/awt/event/MouseEvent/FrameMouseEventAbsoluteCoordsTest/FrameMouseEventAbsol
|
|||||||
|
|
||||||
# Several tests which fail sometimes on macos11
|
# Several tests which fail sometimes on macos11
|
||||||
java/awt/Window/MainKeyWindowTest/TestMainKeyWindow.java 8265985 macosx-all
|
java/awt/Window/MainKeyWindowTest/TestMainKeyWindow.java 8265985 macosx-all
|
||||||
java/awt/security/WarningWindowDisposeTest/WarningWindowDisposeTest.java 8266059 macosx-all
|
|
||||||
java/awt/Robot/Delay/InterruptOfDelay.java 8265986 macosx-all
|
java/awt/Robot/Delay/InterruptOfDelay.java 8265986 macosx-all
|
||||||
java/awt/Robot/InfiniteLoopException.java 8342638 windows-all
|
java/awt/Robot/InfiniteLoopException.java 8342638 windows-all
|
||||||
java/awt/MenuBar/TestNoScreenMenuBar.java 8265987 macosx-all
|
java/awt/MenuBar/TestNoScreenMenuBar.java 8265987 macosx-all
|
||||||
|