提交 a0438fa9 编写于 作者: L leonidr

8003559: Update display of applet windows

Summary: Implemented applet security warning for OS X port
Reviewed-by: art, anthony, serb, skoivu
上级 2eb59b22
#
# Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1995, 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
......@@ -38,6 +38,10 @@ include $(BUILDDIR)/common/Defs.gmk
OTHER_CFLAGS += -D__MEDIALIB_OLD_NAMES -D__USE_J2D_NAMES
ifneq ($(PLATFORM), windows)
CLASSES_INIT += $(TEMPDIR)/.gen_icons
endif
#
# Files
#
......@@ -208,6 +212,79 @@ ifdef ALT_COMPILEFONTCONFIG_FLAGS
endif
build: fontconfigs
ifneq ($(PLATFORM), windows)
GEN_DIR=$(GENSRCDIR)/sun/awt/
ifdef OPENJDK
ICONS_PATH_PREFIX=$(PLATFORM_SRC)
else
ICONS_PATH_PREFIX=$(CLOSED_SRC)/solaris
endif
ICONS = \
$(ICONS_PATH_PREFIX)/classes/sun/awt/X11/java-icon16.png \
$(ICONS_PATH_PREFIX)/classes/sun/awt/X11/java-icon24.png \
$(ICONS_PATH_PREFIX)/classes/sun/awt/X11/java-icon32.png \
$(ICONS_PATH_PREFIX)/classes/sun/awt/X11/java-icon48.png
ICONPATH=$(SHARE_SRC)/classes/sun/awt/resources
ICONS += \
$(ICONPATH)/security-icon-bw16.png \
$(ICONPATH)/security-icon-interim16.png \
$(ICONPATH)/security-icon-yellow16.png \
$(ICONPATH)/security-icon-bw24.png \
$(ICONPATH)/security-icon-interim24.png \
$(ICONPATH)/security-icon-yellow24.png \
$(ICONPATH)/security-icon-bw32.png \
$(ICONPATH)/security-icon-interim32.png \
$(ICONPATH)/security-icon-yellow32.png \
$(ICONPATH)/security-icon-bw48.png \
$(ICONPATH)/security-icon-interim48.png \
$(ICONPATH)/security-icon-yellow48.png
TEMPDIR_CLASSES = $(TEMPDIR)/classes
generated.clean:
$(RM) -r $(GEN_DIR)/*.java
$(RM) -r $(TEMPDIR)/.gen_icons
$(TEMPDIR_CLASSES)/sun/awt/ToBin.class: ToBin.java
@$(prep-target)
$(BOOT_JAVAC_CMD) -d $(TEMPDIR_CLASSES) $<
$(TEMPDIR)/.gen_icons: $(TEMPDIR_CLASSES)/sun/awt/ToBin.class $(ICONS)
$(prep-target)
for i in $(ICONS); do \
filename=`basename $$i`; \
name=`$(ECHO) $$filename | $(TR) '\-.' '__'`; \
classname=$(GEN_DIR)/AWTIcon32_$$name.java; \
$(RM) $$classname; \
$(ECHO) "package sun.awt;" >> $$classname ; \
$(ECHO) "public class AWTIcon32_$$name {" >> $$classname; \
$(ECHO) "public final static int[] $$name = { " >> $$classname; \
$(CAT) $$i | \
$(BOOT_JAVA_CMD) -cp $(TEMPDIR_CLASSES) \
-Djava.awt.headless=true \
sun.awt.ToBin >> $$classname; \
$(ECHO) "}; }" >> $$classname; \
classname=$(GEN_DIR)/AWTIcon64_$$name.java; \
$(RM) $$classname; \
$(ECHO) "package sun.awt;" >> $$classname ; \
$(ECHO) "public class AWTIcon64_$$name {" >> $$classname; \
$(ECHO) "public final static long[] $$name = { " >> $$classname; \
$(CAT) $$i | \
$(BOOT_JAVA_CMD) -cp $(TEMPDIR_CLASSES) \
-Djava.awt.headless=true \
sun.awt.ToBin >> $$classname; \
$(ECHO) "}; }" >> $$classname; \
done
$(TOUCH) $@
clean clobber:: generated.clean
endif
ifeq ($(PLATFORM), windows)
# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv WINDOWS
......@@ -565,5 +642,5 @@ CLASSES.export += java.io.InputStream \
java.lang.Integer \
java.lang.ThreadGroup
.PHONY: dgalibs dgalib.clean fontconfigs fontconfigs.clean
.PHONY: dgalibs dgalib.clean fontconfigs fontconfigs.clean generated.clean
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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
......@@ -23,7 +23,7 @@
* questions.
*/
package sun.awt.X11;
package sun.awt;
import java.io.*;
import java.awt.image.*;
......
#
# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 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
......@@ -109,6 +109,7 @@ FILES_export = \
sun/lwawt/LWToolkit.java \
sun/lwawt/LWWindowPeer.java \
sun/lwawt/PlatformWindow.java \
sun/lwawt/SecurityWarningWindow.java \
sun/lwawt/SelectionClearListener.java \
sun/lwawt/macosx/CPrinterDevice.java \
sun/lwawt/macosx/CPrinterDialog.java \
......@@ -143,6 +144,7 @@ FILES_export = \
sun/lwawt/macosx/CMouseInfoPeer.java \
sun/lwawt/macosx/CPlatformView.java \
sun/lwawt/macosx/CPlatformWindow.java \
sun/lwawt/macosx/CWarningWindow.java \
sun/lwawt/macosx/CPlatformComponent.java \
sun/lwawt/macosx/CEmbeddedFrame.java \
sun/lwawt/macosx/CPlatformEmbeddedFrame.java \
......
#
# Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2002, 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
......@@ -32,7 +32,7 @@ include $(BUILDDIR)/common/Defs.gmk
GEN_DIR=$(GENSRCDIR)/sun/awt/X11
CLASSES_INIT += $(TEMPDIR)/.gen.wrappers $(TEMPDIR)/.gen_icons touch.wrappers
CLASSES_INIT += $(TEMPDIR)/.gen.wrappers touch.wrappers
.PHONY: generated.clean
......@@ -317,70 +317,7 @@ generated.clean:
$(RM) -r $(WRAPPER_GENERATOR_TEMPDIR)
$(RM) -r $(WRAPPER_GENERATOR_DIR)
$(RM) -r $(GEN_DIR)/*.java
$(RM) -r $(TEMPDIR)/.gen_icons
ifdef OPENJDK
ICONS_PATH_PREFIX=$(PLATFORM_SRC)
else
ICONS_PATH_PREFIX=$(CLOSED_SRC)/solaris
endif
ICONS = \
$(ICONS_PATH_PREFIX)/classes/sun/awt/X11/java-icon16.png \
$(ICONS_PATH_PREFIX)/classes/sun/awt/X11/java-icon24.png \
$(ICONS_PATH_PREFIX)/classes/sun/awt/X11/java-icon32.png \
$(ICONS_PATH_PREFIX)/classes/sun/awt/X11/java-icon48.png
ICONPATH=$(PLATFORM_SRC)/classes/sun/awt/X11
ICONS += \
$(ICONPATH)/security-icon-bw16.png \
$(ICONPATH)/security-icon-interim16.png \
$(ICONPATH)/security-icon-yellow16.png \
$(ICONPATH)/security-icon-bw24.png \
$(ICONPATH)/security-icon-interim24.png \
$(ICONPATH)/security-icon-yellow24.png \
$(ICONPATH)/security-icon-bw32.png \
$(ICONPATH)/security-icon-interim32.png \
$(ICONPATH)/security-icon-yellow32.png \
$(ICONPATH)/security-icon-bw48.png \
$(ICONPATH)/security-icon-interim48.png \
$(ICONPATH)/security-icon-yellow48.png
TEMPDIR_CLASSES = $(TEMPDIR)/classes
$(TEMPDIR_CLASSES)/sun/awt/X11/ToBin.class: ToBin.java
@$(prep-target)
$(BOOT_JAVAC_CMD) -d $(TEMPDIR_CLASSES) $<
$(TEMPDIR)/.gen_icons: $(TEMPDIR_CLASSES)/sun/awt/X11/ToBin.class $(ICONS)
$(prep-target)
for i in $(ICONS); do \
filename=`basename $$i`; \
name=`$(ECHO) $$filename | $(TR) '\-.' '__'`; \
classname=$(GEN_DIR)/XAWTIcon32_$$name.java; \
$(RM) $$classname; \
$(ECHO) "package sun.awt.X11;" >> $$classname ; \
$(ECHO) "public class XAWTIcon32_$$name {" >> $$classname; \
$(ECHO) "public static int[] $$name = { " >> $$classname; \
$(CAT) $$i | \
$(BOOT_JAVA_CMD) -cp $(TEMPDIR_CLASSES) \
-Djava.awt.headless=true \
sun.awt.X11.ToBin >> $$classname; \
$(ECHO) "}; }" >> $$classname; \
classname=$(GEN_DIR)/XAWTIcon64_$$name.java; \
$(RM) $$classname; \
$(ECHO) "package sun.awt.X11;" >> $$classname ; \
$(ECHO) "public class XAWTIcon64_$$name {" >> $$classname; \
$(ECHO) "public static long[] $$name = { " >> $$classname; \
$(CAT) $$i | \
$(BOOT_JAVA_CMD) -cp $(TEMPDIR_CLASSES) \
-Djava.awt.headless=true \
sun.awt.X11.ToBin >> $$classname; \
$(ECHO) "}; }" >> $$classname; \
done
$(TOUCH) $@
clean clobber:: generated.clean
......
#
# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 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
......@@ -67,7 +67,7 @@ GENSRC += $(GENSRC_EXCEPTIONS)
ifneq ($(OPENJDK_TARGET_OS),windows)
include GensrcIcons.gmk
GENSRC += $(GENSRC_X11_ICONS)
GENSRC += $(GENSRC_AWT_ICONS)
ifeq ($(OPENJDK_TARGET_OS),macosx)
GENSRC += $(GENSRC_OSX_ICONS)
......
#
# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 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
......@@ -23,10 +23,10 @@
# questions.
#
GENSRC_X11_ICONS :=
GENSRC_X11_ICONS_SRC :=
GENSRC_X11_ICONS_TMP := $(JDK_OUTPUTDIR)/gensrc
GENSRC_X11_ICONS_DST := $(GENSRC_X11_ICONS_TMP)/sun/awt/X11
GENSRC_AWT_ICONS :=
GENSRC_AWT_ICONS_SRC :=
GENSRC_AWT_ICONS_TMP := $(JDK_OUTPUTDIR)/gensrc
GENSRC_AWT_ICONS_DST := $(GENSRC_AWT_ICONS_TMP)/sun/awt/
ifdef OPENJDK
X11_ICONS_PATH_PREFIX := $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)
......@@ -34,76 +34,76 @@ else
X11_ICONS_PATH_PREFIX := $(JDK_TOPDIR)/src/closed/solaris
endif
GENSRC_X11_ICONS_SRC += \
GENSRC_AWT_ICONS_SRC += \
$(X11_ICONS_PATH_PREFIX)/classes/sun/awt/X11/java-icon16.png \
$(X11_ICONS_PATH_PREFIX)/classes/sun/awt/X11/java-icon24.png \
$(X11_ICONS_PATH_PREFIX)/classes/sun/awt/X11/java-icon32.png \
$(X11_ICONS_PATH_PREFIX)/classes/sun/awt/X11/java-icon48.png
X11_ICONPATH := $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/classes/sun/awt/X11
AWT_ICONPATH := $(JDK_TOPDIR)/src/share/classes/sun/awt/resources
GENSRC_X11_ICONS_SRC += \
$(X11_ICONPATH)/security-icon-bw16.png \
$(X11_ICONPATH)/security-icon-interim16.png \
$(X11_ICONPATH)/security-icon-yellow16.png \
$(X11_ICONPATH)/security-icon-bw24.png \
$(X11_ICONPATH)/security-icon-interim24.png \
$(X11_ICONPATH)/security-icon-yellow24.png \
$(X11_ICONPATH)/security-icon-bw32.png \
$(X11_ICONPATH)/security-icon-interim32.png \
$(X11_ICONPATH)/security-icon-yellow32.png \
$(X11_ICONPATH)/security-icon-bw48.png \
$(X11_ICONPATH)/security-icon-interim48.png \
$(X11_ICONPATH)/security-icon-yellow48.png
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_X11_ICONS_FILES := $(notdir $(GENSRC_X11_ICONS_SRC))
GENSRC_AWT_ICONS_FILES := $(notdir $(GENSRC_AWT_ICONS_SRC))
GENSRC_X11_ICONS_SHORT_NAME = $(subst .,_,$(subst -,_,$(1)))
GENSRC_X11_ICONS_DST_NAME = XAWTIcon$(2)_$(subst .,_,$(subst -,_,$(1)))
GENSRC_AWT_ICONS_SHORT_NAME = $(subst .,_,$(subst -,_,$(1)))
GENSRC_AWT_ICONS_DST_NAME = AWTIcon$(2)_$(subst .,_,$(subst -,_,$(1)))
###
$(GENSRC_X11_ICONS_TMP)/_the.icons.dir :
$(GENSRC_AWT_ICONS_TMP)/_the.icons.dir :
$(ECHO) Generating icon classes
$(MKDIR) -p $(GENSRC_X11_ICONS_DST)
$(MKDIR) -p $(GENSRC_AWT_ICONS_DST)
$(TOUCH) $@
###
define SetupGensrcX11Icon
define SetupGensrcAWTIcon
# param 1 is for src-file
# param 2 is for src-dir
$1_SHORTNAME := $(call GENSRC_X11_ICONS_SHORT_NAME,$1)
$1_NAME32 := $(call GENSRC_X11_ICONS_DST_NAME,$1,32)
$1_TARGET32 := $(GENSRC_X11_ICONS_DST)/$$($1_NAME32).java
$1_NAME64 := $(call GENSRC_X11_ICONS_DST_NAME,$1,64)
$1_TARGET64 := $(GENSRC_X11_ICONS_DST)/$$($1_NAME64).java
$1_SHORTNAME := $(call GENSRC_AWT_ICONS_SHORT_NAME,$1)
$1_NAME32 := $(call GENSRC_AWT_ICONS_DST_NAME,$1,32)
$1_TARGET32 := $(GENSRC_AWT_ICONS_DST)/$$($1_NAME32).java
$1_NAME64 := $(call GENSRC_AWT_ICONS_DST_NAME,$1,64)
$1_TARGET64 := $(GENSRC_AWT_ICONS_DST)/$$($1_NAME64).java
$$($1_TARGET32) : $2/$1 $(GENSRC_X11_ICONS_TMP)/_the.icons.dir
$$($1_TARGET32) : $2/$1 $(GENSRC_AWT_ICONS_TMP)/_the.icons.dir
$(RM) $$@ $$@.tmp
$(ECHO) "package sun.awt.X11;" > $$@.tmp
$(ECHO) "package sun.awt;" > $$@.tmp
$(ECHO) "public class $$($1_NAME32) {" >> $$@.tmp
$(ECHO) "public static int[] $$($1_SHORTNAME) = { " >> $$@.tmp
$(CAT) $$< | $(TOOL_X11_TOBIN) >> $$@.tmp
$(CAT) $$< | $(TOOL_AWT_TOBIN) >> $$@.tmp
$(ECHO) "}; }" >> $$@.tmp
$(MV) $$@.tmp $$@
GENSRC_X11_ICONS += $$($1_TARGET32)
GENSRC_AWT_ICONS += $$($1_TARGET32)
$$($1_TARGET64) : $2/$1 $(GENSRC_X11_ICONS_TMP)/_the.icons.dir
$$($1_TARGET64) : $2/$1 $(GENSRC_AWT_ICONS_TMP)/_the.icons.dir
$(RM) $$@ $$@.tmp
$(ECHO) "package sun.awt.X11;" > $$@.tmp
$(ECHO) "package sun.awt;" > $$@.tmp
$(ECHO) "public class $$($1_NAME64) {" >> $$@.tmp
$(ECHO) "public static long[] $$($1_SHORTNAME) = { " >> $$@.tmp
$(CAT) $$< | $(TOOL_X11_TOBIN) >> $$@.tmp
$(CAT) $$< | $(TOOL_AWT_TOBIN) >> $$@.tmp
$(ECHO) "}; }" >> $$@.tmp
$(MV) $$@.tmp $$@
GENSRC_X11_ICONS += $$($1_TARGET64)
GENSRC_AWT_ICONS += $$($1_TARGET64)
endef
$(foreach I,$(GENSRC_X11_ICONS_SRC), $(eval $(call SetupGensrcX11Icon,$(notdir $(I)),$(dir $(I)))))
$(foreach I,$(GENSRC_AWT_ICONS_SRC), $(eval $(call SetupGensrcAWTIcon,$(notdir $(I)),$(dir $(I)))))
###
......
#
# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 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
......@@ -29,7 +29,7 @@ $(eval $(call FillCacheFind,$(JDK_TOPDIR)/make/tools \
$(JDK_TOPDIR)/makefiles/sun))
TOOLS_SRC:=$(JDK_TOPDIR)/make/tools/src \
$(JDK_TOPDIR)/makefiles/sun/awt/X11 \
$(JDK_TOPDIR)/makefiles/sun/awt/ \
$(JDK_TOPDIR)/makefiles/sun/osxapp \
$(JDK_TOPDIR)/make/tools/swing-beans
......@@ -128,8 +128,8 @@ TOOL_GENERATENIMBUS=$(JAVA) -cp $(JDK_OUTPUTDIR)/btclasses \
TOOL_WRAPPERGENERATOR=$(JAVA) -cp $(JDK_OUTPUTDIR)/btclasses \
WrapperGenerator
TOOL_X11_TOBIN=$(JAVA) -Djava.awt.headless=true -cp $(JDK_OUTPUTDIR)/btclasses \
sun.awt.X11.ToBin
TOOL_AWT_TOBIN=$(JAVA) -Djava.awt.headless=true -cp $(JDK_OUTPUTDIR)/btclasses \
sun.awt.ToBin
TOOL_OSX_TOBIN=$(JAVA) -Djava.awt.headless=true -cp $(JDK_OUTPUTDIR)/btclasses \
sun.osxapp.ToBin
......
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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
......@@ -23,7 +23,7 @@
* questions.
*/
package sun.awt.X11;
package sun.awt;
import java.io.*;
import java.awt.image.*;
......
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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
......@@ -72,8 +72,7 @@ public class CGLLayer extends CFRetainedResource {
}
public int getTransparency() {
return peer.isTranslucent() ? Transparency.TRANSLUCENT :
Transparency.OPAQUE;
return isOpaque() ? Transparency.OPAQUE : Transparency.TRANSLUCENT;
}
public Object getDestination() {
......@@ -81,14 +80,14 @@ public class CGLLayer extends CFRetainedResource {
}
public SurfaceData replaceSurfaceData() {
if (peer.getBounds().isEmpty()) {
if (getBounds().isEmpty()) {
surfaceData = NullSurfaceData.theInstance;
return surfaceData;
}
// the layer redirects all painting to the buffer's graphics
// and blits the buffer to the layer surface (in drawInCGLContext callback)
CGraphicsConfig gc = (CGraphicsConfig)peer.getGraphicsConfiguration();
CGraphicsConfig gc = (CGraphicsConfig)getGraphicsConfiguration();
surfaceData = gc.createSurfaceData(this);
// the layer holds a reference to the buffer, which in
......
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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
......@@ -44,9 +44,26 @@ public class LWKeyboardFocusManagerPeer extends KeyboardFocusManagerPeerImpl {
@Override
public void setCurrentFocusedWindow(Window win) {
LWWindowPeer from, to;
synchronized (this) {
if (focusedWindow == win) {
return;
}
from = (LWWindowPeer)LWToolkit.targetToPeer(focusedWindow);
to = (LWWindowPeer)LWToolkit.targetToPeer(win);
focusedWindow = win;
}
if (from != null) {
from.updateSecurityWarningVisibility();
}
if (to != null) {
to.updateSecurityWarningVisibility();
}
}
@Override
......
......@@ -491,6 +491,8 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
return clipboard;
}
protected abstract SecurityWarningWindow createSecurityWarning(Window ownerWindow, LWWindowPeer ownerPeer);
// ---- DELEGATES ---- //
public abstract Clipboard createPlatformClipboard();
......
......@@ -41,8 +41,7 @@ import sun.util.logging.PlatformLogger;
public class LWWindowPeer
extends LWContainerPeer<Window, JComponent>
implements WindowPeer, FramePeer, DialogPeer, FullScreenCapable
{
implements WindowPeer, FramePeer, DialogPeer, FullScreenCapable, PlatformEventNotifier {
public static enum PeerType {
SIMPLEWINDOW,
FRAME,
......@@ -111,6 +110,8 @@ public class LWWindowPeer
private final PeerType peerType;
private final SecurityWarningWindow warningWindow;
/**
* Current modal blocker or null.
*
......@@ -157,11 +158,26 @@ public class LWWindowPeer
}
platformWindow.initialize(target, this, ownerDelegate);
// Init warning window(for applets)
SecurityWarningWindow warn = null;
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)) {
LWToolkit toolkit = (LWToolkit)Toolkit.getDefaultToolkit();
warn = toolkit.createSecurityWarning(target, this);
}
}
warningWindow = warn;
}
@Override
void initializeImpl() {
super.initializeImpl();
if (getTarget() instanceof Frame) {
setTitle(((Frame) getTarget()).getTitle());
setState(((Frame) getTarget()).getExtendedState());
......@@ -219,12 +235,20 @@ public class LWWindowPeer
if (isGrabbing()) {
ungrab();
}
if (warningWindow != null) {
warningWindow.dispose();
}
platformWindow.dispose();
super.disposeImpl();
}
@Override
protected void setVisibleImpl(final boolean visible) {
if (!visible && warningWindow != null) {
warningWindow.setVisible(false, false);
}
super.setVisibleImpl(visible);
// TODO: update graphicsConfig, see 4868278
platformWindow.setVisible(visible);
......@@ -455,7 +479,15 @@ public class LWWindowPeer
@Override
public void repositionSecurityWarning() {
throw new RuntimeException("not implemented");
if (warningWindow != null) {
AWTAccessor.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 ---- //
......@@ -515,6 +547,7 @@ public class LWWindowPeer
// ---- PEER NOTIFICATIONS ---- //
@Override
public void notifyIconify(boolean iconify) {
//The toplevel target is Frame and states are applicable to it.
//Otherwise, the target is Window and it don't have state property.
......@@ -539,6 +572,7 @@ public class LWWindowPeer
}
}
@Override
public void notifyZoom(boolean isZoomed) {
int newWindowState = isZoomed ? Frame.MAXIMIZED_BOTH : Frame.NORMAL;
postWindowStateChangedEvent(newWindowState);
......@@ -548,7 +582,8 @@ public class LWWindowPeer
* Called by the {@code PlatformWindow} when any part of the window should
* be repainted.
*/
public final void notifyExpose(final Rectangle r) {
@Override
public void notifyExpose(final Rectangle r) {
repaintPeer(r);
}
......@@ -558,7 +593,8 @@ public class LWWindowPeer
* LWComponentPeer as the only components which could be resized by user are
* top-level windows.
*/
public final void notifyReshape(int x, int y, int w, int h) {
@Override
public void notifyReshape(int x, int y, int w, int h) {
final boolean moved;
final boolean resized;
final boolean invalid = updateInsets(platformWindow.getInsets());
......@@ -593,6 +629,8 @@ public class LWWindowPeer
handleResize(w, h, true);
repaintPeer();
}
repositionSecurityWarning();
}
private void clearBackground(final int w, final int h) {
......@@ -620,16 +658,19 @@ public class LWWindowPeer
}
}
@Override
public void notifyUpdateCursor() {
getLWToolkit().getCursorManager().updateCursorLater(this);
}
@Override
public void notifyActivation(boolean activation, LWWindowPeer opposite) {
Window oppositeWindow = (opposite == null)? null : opposite.getTarget();
changeFocusedWindow(activation, oppositeWindow);
}
// MouseDown in non-client area
@Override
public void notifyNCMouseDown() {
// Ungrab except for a click on a Dialog with the grabbing owner
if (grabbingWindow != null &&
......@@ -646,10 +687,11 @@ public class LWWindowPeer
* coordinates are relative to non-client window are, i.e. the top-left
* point of the client area is (insets.top, insets.left).
*/
public void dispatchMouseEvent(int id, long when, int button,
int x, int y, int screenX, int screenY,
int modifiers, int clickCount, boolean popupTrigger,
byte[] bdata)
@Override
public void notifyMouseEvent(int id, long when, int button,
int x, int y, int screenX, int screenY,
int modifiers, int clickCount, boolean popupTrigger,
byte[] bdata)
{
// TODO: fill "bdata" member of AWTEvent
Rectangle r = getBounds();
......@@ -662,11 +704,9 @@ public class LWWindowPeer
if (lastMouseEventPeer.isEnabled()) {
Point lp = lastMouseEventPeer.windowToLocal(x, y,
this);
postEvent(new MouseEvent(lastMouseEventPeer.getTarget(),
MouseEvent.MOUSE_EXITED, when,
modifiers, lp.x, lp.y, screenX,
screenY, clickCount, popupTrigger,
button));
Component target = lastMouseEventPeer.getTarget();
postMouseExitedEvent(target, when, modifiers, lp,
screenX, screenY, clickCount, popupTrigger, button);
}
// Sometimes we may get MOUSE_EXITED after lastCommonMouseEventPeer is switched
......@@ -682,11 +722,9 @@ public class LWWindowPeer
if (targetPeer != null) {
if (targetPeer.isEnabled()) {
Point lp = targetPeer.windowToLocal(x, y, this);
postEvent(new MouseEvent(targetPeer.getTarget(),
MouseEvent.MOUSE_ENTERED, when,
modifiers, lp.x, lp.y, screenX,
screenY, clickCount, popupTrigger,
button));
Component target = targetPeer.getTarget();
postMouseEnteredEvent(target, when, modifiers, lp,
screenX, screenY, clickCount, popupTrigger, button);
}
lastCommonMouseEventPeer = targetPeer;
lastMouseEventPeer = targetPeer;
......@@ -813,11 +851,9 @@ public class LWWindowPeer
// Generate Mouse Exit for components
if (lastMouseEventPeer != null && lastMouseEventPeer.isEnabled()) {
Point oldp = lastMouseEventPeer.windowToLocal(x, y, this);
postEvent(new MouseEvent(lastMouseEventPeer.getTarget(),
MouseEvent.MOUSE_EXITED,
when, modifiers,
oldp.x, oldp.y, screenX, screenY,
clickCount, popupTrigger, button));
Component target = lastMouseEventPeer.getTarget();
postMouseExitedEvent(target, when, modifiers, oldp, screenX, screenY,
clickCount, popupTrigger, button);
}
lastCommonMouseEventPeer = targetPeer;
lastMouseEventPeer = targetPeer;
......@@ -825,18 +861,42 @@ public class LWWindowPeer
// Generate Mouse Enter for components
if (targetPeer != null && targetPeer.isEnabled()) {
Point newp = targetPeer.windowToLocal(x, y, this);
postEvent(new MouseEvent(targetPeer.getTarget(),
MouseEvent.MOUSE_ENTERED,
when, modifiers,
newp.x, newp.y, screenX, screenY,
clickCount, popupTrigger, button));
Component target = targetPeer.getTarget();
postMouseEnteredEvent(target, when, modifiers, newp, screenX, screenY, clickCount, popupTrigger, button);
}
}
public void dispatchMouseWheelEvent(long when, int x, int y, int modifiers,
int scrollType, int scrollAmount,
int wheelRotation, double preciseWheelRotation,
byte[] bdata)
private void postMouseEnteredEvent(Component target, long when, int modifiers,
Point loc, int xAbs, int yAbs,
int clickCount, boolean popupTrigger, int button) {
updateSecurityWarningVisibility();
postEvent(new MouseEvent(target,
MouseEvent.MOUSE_ENTERED,
when, modifiers,
loc.x, loc.y, xAbs, yAbs,
clickCount, popupTrigger, button));
}
private void postMouseExitedEvent(Component target, long when, int modifiers,
Point loc, int xAbs, int yAbs,
int clickCount, boolean popupTrigger, int button) {
updateSecurityWarningVisibility();
postEvent(new MouseEvent(target,
MouseEvent.MOUSE_EXITED,
when, modifiers,
loc.x, loc.y, xAbs, yAbs,
clickCount, popupTrigger, button));
}
@Override
public void notifyMouseWheelEvent(long when, int x, int y, int modifiers,
int scrollType, int scrollAmount,
int wheelRotation, double preciseWheelRotation,
byte[] bdata)
{
// TODO: could we just use the last mouse event target here?
Rectangle r = getBounds();
......@@ -862,8 +922,9 @@ public class LWWindowPeer
/*
* Called by the delegate when a key is pressed.
*/
public void dispatchKeyEvent(int id, long when, int modifiers,
int keyCode, char keyChar, int keyLocation)
@Override
public void notifyKeyEvent(int id, long when, int modifiers,
int keyCode, char keyChar, int keyLocation)
{
LWKeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
Component focusOwner = kfmPeer.getCurrentFocusOwner();
......@@ -877,7 +938,6 @@ public class LWWindowPeer
postEvent(new KeyEvent(focusOwner, id, when, modifiers, keyCode, keyChar, keyLocation));
}
// ---- UTILITY METHODS ---- //
private void postWindowStateChangedEvent(int newWindowState) {
......@@ -885,11 +945,14 @@ public class LWWindowPeer
AWTAccessor.getFrameAccessor().setExtendedState(
(Frame)getTarget(), newWindowState);
}
WindowEvent stateChangedEvent = new WindowEvent(getTarget(),
WindowEvent.WINDOW_STATE_CHANGED,
windowState, newWindowState);
postEvent(stateChangedEvent);
windowState = newWindowState;
updateSecurityWarningVisibility();
}
private static int getGraphicsConfigScreen(GraphicsConfiguration gc) {
......@@ -1187,10 +1250,12 @@ public class LWWindowPeer
public void enterFullScreenMode() {
platformWindow.enterFullScreenMode();
updateSecurityWarningVisibility();
}
public void exitFullScreenMode() {
platformWindow.exitFullScreenMode();
updateSecurityWarningVisibility();
}
public long getLayerPtr() {
......@@ -1225,6 +1290,33 @@ public class LWWindowPeer
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
public String toString() {
return super.toString() + " [target is " + getTarget() + "]";
......
/*
* 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;
import java.awt.Rectangle;
public interface PlatformEventNotifier {
void notifyIconify(boolean iconify);
void notifyZoom(boolean isZoomed);
void notifyExpose(Rectangle r);
void notifyReshape(int x, int y, int w, int h);
void notifyUpdateCursor();
void notifyActivation(boolean activation, LWWindowPeer opposite);
// MouseDown in non-client area
void notifyNCMouseDown();
/*
* Called by the delegate to dispatch the event to Java. Event
* coordinates are relative to non-client window are, i.e. the top-left
* point of the client area is (insets.top, insets.left).
*/
void notifyMouseEvent(int id, long when, int button,
int x, int y, int screenX, int screenY,
int modifiers, int clickCount, boolean popupTrigger,
byte[] bdata);
void notifyMouseWheelEvent(long when, int x, int y, int modifiers,
int scrollType, int scrollAmount,
int wheelRotation, double preciseWheelRotation,
byte[] bdata);
/*
* Called by the delegate when a key is pressed.
*/
void notifyKeyEvent(int id, long when, int modifiers,
int keyCode, char keyChar, int keyLocation);
}
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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
......@@ -146,6 +146,8 @@ public interface PlatformWindow {
public void exitFullScreenMode();
public boolean isFullScreenMode();
public void setWindowState(int windowState);
public long getLayerPtr();
......
/*
* 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);
}
......@@ -185,6 +185,11 @@ public class CPlatformEmbeddedFrame implements PlatformWindow {
@Override
public void exitFullScreenMode() {}
@Override
public boolean isFullScreenMode() {
return false;
}
@Override
public void setWindowState(int windowState) {}
......
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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
......@@ -27,6 +27,7 @@ package sun.lwawt.macosx;
import sun.awt.SunToolkit;
import sun.lwawt.LWWindowPeer;
import sun.lwawt.PlatformEventNotifier;
import sun.lwawt.macosx.event.NSEvent;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
......@@ -39,11 +40,12 @@ import java.awt.event.KeyEvent;
*/
final class CPlatformResponder {
private final LWWindowPeer peer;
private final PlatformEventNotifier eventNotifier;
private final boolean isNpapiCallback;
CPlatformResponder(final LWWindowPeer peer, final boolean isNpapiCallback) {
this.peer = peer;
CPlatformResponder(final PlatformEventNotifier eventNotifier,
final boolean isNpapiCallback) {
this.eventNotifier = eventNotifier;
this.isNpapiCallback = isNpapiCallback;
}
......@@ -77,9 +79,9 @@ final class CPlatformResponder {
modifierFlags);
boolean jpopupTrigger = NSEvent.isPopupTrigger(jmodifiers);
peer.dispatchMouseEvent(jeventType, System.currentTimeMillis(), jbuttonNumber,
x, y, absoluteX, absoluteY, jmodifiers, jclickCount,
jpopupTrigger, null);
eventNotifier.notifyMouseEvent(jeventType, System.currentTimeMillis(), jbuttonNumber,
x, y, absoluteX, absoluteY, jmodifiers, jclickCount,
jpopupTrigger, null);
}
/**
......@@ -115,8 +117,8 @@ final class CPlatformResponder {
wheelRotation = signum;
}
// invert the wheelRotation for the peer
peer.dispatchMouseWheelEvent(when, x, y, modifiers, scrollType,
scrollAmount, -wheelRotation, -delta, null);
eventNotifier.notifyMouseWheelEvent(when, x, y, modifiers, scrollType,
scrollAmount, -wheelRotation, -delta, null);
}
/**
......@@ -183,8 +185,8 @@ final class CPlatformResponder {
int jmodifiers = NSEvent.nsToJavaKeyModifiers(modifierFlags);
long when = System.currentTimeMillis();
peer.dispatchKeyEvent(jeventType, when, jmodifiers,
jkeyCode, javaChar, jkeyLocation);
eventNotifier.notifyKeyEvent(jeventType, when, jmodifiers,
jkeyCode, javaChar, jkeyLocation);
// Current browser may be sending input events, so don't
// post the KEY_TYPED here.
......@@ -197,9 +199,9 @@ final class CPlatformResponder {
// for clipboard related shortcuts like Meta + [CVX]
boolean isMetaDown = (jmodifiers & KeyEvent.META_DOWN_MASK) != 0;
if (jeventType == KeyEvent.KEY_PRESSED && postsTyped && !isMetaDown) {
peer.dispatchKeyEvent(KeyEvent.KEY_TYPED, when, jmodifiers,
KeyEvent.VK_UNDEFINED, javaChar,
KeyEvent.KEY_LOCATION_UNKNOWN);
eventNotifier.notifyKeyEvent(KeyEvent.KEY_TYPED, when, jmodifiers,
KeyEvent.VK_UNDEFINED, javaChar,
KeyEvent.KEY_LOCATION_UNKNOWN);
}
}
......@@ -209,16 +211,16 @@ final class CPlatformResponder {
char c;
while (index < length) {
c = text.charAt(index);
peer.dispatchKeyEvent(KeyEvent.KEY_TYPED,
System.currentTimeMillis(),
0, KeyEvent.VK_UNDEFINED, c,
KeyEvent.KEY_LOCATION_UNKNOWN);
eventNotifier.notifyKeyEvent(KeyEvent.KEY_TYPED,
System.currentTimeMillis(),
0, KeyEvent.VK_UNDEFINED, c,
KeyEvent.KEY_LOCATION_UNKNOWN);
index++;
}
}
}
void handleWindowFocusEvent(boolean gained, LWWindowPeer opposite) {
peer.notifyActivation(gained, opposite);
eventNotifier.notifyActivation(gained, opposite);
}
}
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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
......@@ -58,14 +58,18 @@ public class CPlatformView extends CFRetainedResource {
this.responder = responder;
if (!LWCToolkit.getSunAwtDisableCALayers()) {
this.windowLayer = new CGLLayer(peer);
this.windowLayer = createCGLayer();
}
setPtr(nativeCreateView(0, 0, 0, 0, getWindowLayerPtr()));
}
public CGLLayer createCGLayer() {
return new CGLLayer(peer);
}
public long getAWTView() {
return ptr;
}
}
public boolean isOpaque() {
return !peer.isTranslucent();
......@@ -96,6 +100,10 @@ public class CPlatformView extends CFRetainedResource {
CWrapper.NSView.exitFullScreenMode(ptr);
}
public void setToolTip(String msg) {
CWrapper.NSView.setToolTip(ptr, msg);
}
// ----------------------------------------------------------------------
// PAINTING METHODS
// ----------------------------------------------------------------------
......@@ -104,7 +112,7 @@ public class CPlatformView extends CFRetainedResource {
surfaceData = windowLayer.replaceSurfaceData();
} else {
if (surfaceData == null) {
CGraphicsConfig graphicsConfig = (CGraphicsConfig)peer.getGraphicsConfiguration();
CGraphicsConfig graphicsConfig = (CGraphicsConfig)getGraphicsConfiguration();
surfaceData = graphicsConfig.createSurfaceData(this);
} else {
validateSurface();
......
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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
......@@ -44,7 +44,7 @@ import com.apple.laf.*;
import com.apple.laf.ClientPropertyApplicator.Property;
import com.sun.awt.AWTUtilities;
public final class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
public class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
private native long nativeCreateNSWindow(long nsViewPtr, long styleBits, double x, double y, double w, double h);
private static native void nativeSetNSWindowStyleBits(long nsWindowPtr, int mask, int data);
private static native void nativeSetNSWindowMenuBar(long nsWindowPtr, long menuBarPtr);
......@@ -200,9 +200,9 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
private Window target;
private LWWindowPeer peer;
private CPlatformView contentView;
private CPlatformWindow owner;
private boolean visible = false; // visibility status from native perspective
protected CPlatformView contentView;
protected CPlatformWindow owner;
protected boolean visible = false; // visibility status from native perspective
private boolean undecorated; // initialized in getInitialStyleBits()
private Rectangle normalBounds = null; // not-null only for undecorated maximized windows
private CPlatformResponder responder;
......@@ -226,20 +226,13 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
final int styleBits = getInitialStyleBits();
// TODO: handle these misc properties
final long parentNSWindowPtr = (owner != null ? owner.getNSWindowPtr() : 0);
String warningString = target.getWarningString();
responder = new CPlatformResponder(peer, false);
contentView = new CPlatformView();
responder = createPlatformResponder();
contentView = createContentView();
contentView.initialize(peer, responder);
final long nativeWindowPtr = nativeCreateNSWindow(contentView.getAWTView(), styleBits, 0, 0, 0, 0);
setPtr(nativeWindowPtr);
// TODO: implement on top of JObjC bridged class
// NSWindow window = JObjC.getInstance().AppKit().NSWindow().getInstance(nativeWindowPtr, JObjCRuntime.getInstance());
if (target instanceof javax.swing.RootPaneContainer) {
final javax.swing.JRootPane rootpane = ((javax.swing.RootPaneContainer)target).getRootPane();
if (rootpane != null) rootpane.addPropertyChangeListener("ancestor", new PropertyChangeListener() {
......@@ -253,7 +246,15 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
validateSurface();
}
private int getInitialStyleBits() {
protected CPlatformResponder createPlatformResponder() {
return new CPlatformResponder(peer, false);
}
protected CPlatformView createContentView() {
return new CPlatformView();
}
protected int getInitialStyleBits() {
// defaults style bits
int styleBits = DECORATED | HAS_SHADOW | CLOSEABLE | MINIMIZABLE | ZOOMABLE | RESIZABLE;
......@@ -452,7 +453,7 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
}
private void maximize() {
if (isMaximized()) {
if (peer == null || isMaximized()) {
return;
}
if (!undecorated) {
......@@ -487,7 +488,7 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
}
}
private boolean isVisible() {
public boolean isVisible() {
return this.visible;
}
......@@ -519,7 +520,7 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
updateFocusabilityForAutoRequestFocus(false);
// Actually show or hide the window
LWWindowPeer blocker = peer.getBlocker();
LWWindowPeer blocker = (peer == null)? null : peer.getBlocker();
if (blocker == null || !visible) {
// If it ain't blocked, or is being hidden, go regular way
if (visible) {
......@@ -711,7 +712,8 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
@Override
public void setOpaque(boolean isOpaque) {
CWrapper.NSWindow.setOpaque(getNSWindowPtr(), isOpaque);
if (!isOpaque && !peer.isTextured()) {
boolean isTextured = (peer == null)? false : peer.isTextured();
if (!isOpaque && !isTextured) {
long clearColor = CWrapper.NSColor.clearColor();
CWrapper.NSWindow.setBackgroundColor(getNSWindowPtr(), clearColor);
}
......@@ -750,9 +752,14 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
isFullScreenMode = false;
}
@Override
public boolean isFullScreenMode() {
return isFullScreenMode;
}
@Override
public void setWindowState(int windowState) {
if (!peer.isVisible()) {
if (peer == null || !peer.isVisible()) {
// setVisible() applies the state
return;
}
......@@ -875,7 +882,7 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
responder.handleWindowFocusEvent(gained, oppositePeer);
}
private void deliverMoveResizeEvent(int x, int y, int width, int height,
protected void deliverMoveResizeEvent(int x, int y, int width, int height,
boolean byUser) {
// when the content view enters the full-screen mode, the native
// move/resize notifications contain a bounds smaller than
......@@ -887,7 +894,11 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
final Rectangle oldB = nativeBounds;
nativeBounds = new Rectangle(x, y, width, height);
peer.notifyReshape(x, y, width, height);
if (peer != null) {
peer.notifyReshape(x, y, width, height);
}
if ((byUser && !oldB.getSize().equals(nativeBounds.getSize()))
|| isFullScreenAnimationOn) {
flushBuffers();
......@@ -895,21 +906,29 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
}
private void deliverWindowClosingEvent() {
if (peer.getBlocker() == null) {
peer.postEvent(new WindowEvent(target, WindowEvent.WINDOW_CLOSING));
if (peer != null) {
if (peer.getBlocker() == null) {
peer.postEvent(new WindowEvent(target, WindowEvent.WINDOW_CLOSING));
}
}
}
private void deliverIconify(final boolean iconify) {
peer.notifyIconify(iconify);
if (peer != null) {
peer.notifyIconify(iconify);
}
}
private void deliverZoom(final boolean isZoomed) {
peer.notifyZoom(isZoomed);
if (peer != null) {
peer.notifyZoom(isZoomed);
}
}
private void deliverNCMouseDown() {
peer.notifyNCMouseDown();
if (peer != null) {
peer.notifyNCMouseDown();
}
}
/*
......@@ -917,6 +936,10 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
* may become natively focusable window.
*/
private boolean isNativelyFocusableWindow() {
if (peer == null) {
return false;
}
return !peer.isSimpleWindow() && target.getFocusableWindowState();
}
......@@ -931,7 +954,7 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
}
private boolean checkBlocking() {
LWWindowPeer blocker = peer.getBlocker();
LWWindowPeer blocker = (peer == null)? null : peer.getBlocker();
if (blocker == null) {
return false;
}
......
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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
......@@ -25,6 +25,7 @@
package sun.lwawt.macosx;
import sun.awt.AWTAccessor;
import sun.awt.SunToolkit;
import sun.lwawt.macosx.event.NSEvent;
......@@ -339,6 +340,9 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer {
dialog.addWindowListener(handler);
// suppress security warning for untrusted windows
AWTAccessor.getWindowAccessor().setTrayIconWindow(dialog, true);
dialog.pack();
return dialog;
......
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 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
......@@ -200,6 +200,11 @@ public class CViewPlatformEmbeddedFrame implements PlatformWindow {
public void exitFullScreenMode() {
}
@Override
public boolean isFullScreenMode() {
return false;
}
@Override
public void setWindowState(int windowState) {
}
......
/*
* 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.macosx;
import sun.awt.AWTAccessor;
import sun.awt.IconInfo;
import sun.awt.SunToolkit;
import sun.java2d.SunGraphics2D;
import sun.java2d.SurfaceData;
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;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
public final class CWarningWindow extends CPlatformWindow
implements SecurityWarningWindow, PlatformEventNotifier {
private static class Lock {};
private final Lock lock = new Lock();
private final static int SHOWING_DELAY = 300;
private final static int HIDING_DELAY = 2000;
private Rectangle bounds = new Rectangle();
private final WeakReference<LWWindowPeer> ownerPeer;
private final Window ownerWindow;
/**
* Animation stage.
*/
private volatile int currentIcon = 0;
/* -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<LWWindowPeer>(_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 (scheduler) {
if (showingTaskHandle != null) {
showingTaskHandle.cancel(false);
showingTaskHandle = null;
}
if (hidingTaskHandle != null) {
hidingTaskHandle.cancel(false);
hidingTaskHandle = null;
}
if (visible) {
if (isVisible()) {
currentIcon = 0;
} else {
currentIcon = 2;
}
showingTaskHandle = scheduler.schedule(showingTask, 50,
TimeUnit.MILLISECONDS);
} else {
if (!isVisible()) {
return;
}
if (doSchedule) {
hidingTaskHandle = scheduler.schedule(hidingTask, HIDING_DELAY,
TimeUnit.MILLISECONDS);
} else {
hidingTaskHandle = scheduler.schedule(hidingTask, 50,
TimeUnit.MILLISECONDS);
}
}
}
}
@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 screenX, int screenY, 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) {
final long nsWindowPtr = getNSWindowPtr();
// Process parent-child relationship when hiding
if (!visible) {
// Unparent myself
if (owner != null && owner.isVisible()) {
CWrapper.NSWindow.removeChildWindow(
owner.getNSWindowPtr(), nsWindowPtr);
}
}
// Actually show or hide the window
if (visible) {
CWrapper.NSWindow.orderFront(nsWindowPtr);
} else {
CWrapper.NSWindow.orderOut(nsWindowPtr);
}
this.visible = visible;
// Manage parent-child relationship when showing
if (visible) {
// Add myself as a child
if (owner != null && owner.isVisible()) {
CWrapper.NSWindow.addChildWindow(owner.getNSWindowPtr(),
nsWindowPtr, CWrapper.NSWindow.NSWindowAbove);
// do not allow security warning to be obscured by other windows
if (ownerWindow.isAlwaysOnTop()) {
CWrapper.NSWindow.setLevel(nsWindowPtr,
CWrapper.NSWindow.NSFloatingWindowLevel);
}
}
}
}
}
@Override
public void notifyMouseWheelEvent(long when, int x, int y, 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) {
}
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);
}
protected 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;
}
};
}
};
}
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 final Graphics getGraphics() {
SurfaceData sd = contentView.getSurfaceData();
if (ownerWindow == null || sd == null) {
return null;
}
return transformGraphics(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 Runnable hidingTask = new Runnable() {
public void run() {
synchronized (lock) {
setVisible(false);
}
synchronized (scheduler) {
hidingTaskHandle = null;
}
}
};
private final Runnable showingTask = new Runnable() {
public void run() {
synchronized (lock) {
if (!isVisible()) {
setVisible(true);
}
repaint();
}
synchronized (scheduler) {
if (currentIcon > 0) {
currentIcon--;
showingTaskHandle = scheduler.schedule(showingTask, SHOWING_DELAY,
TimeUnit.MILLISECONDS);
} else {
showingTaskHandle = null;
}
}
}
};
private final ScheduledExecutorService scheduler =
Executors.newSingleThreadScheduledExecutor();
private ScheduledFuture hidingTaskHandle;
private ScheduledFuture showingTaskHandle;
}
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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
......@@ -87,6 +87,8 @@ public final class CWrapper {
public static native void exitFullScreenMode(long view);
public static native void setHidden(long view, boolean hidden);
public static native void setToolTip(long view, String msg);
}
public static final class NSObject {
......
......@@ -166,6 +166,11 @@ public final class LWCToolkit extends LWToolkit {
}
}
@Override
protected SecurityWarningWindow createSecurityWarning(Window ownerWindow, LWWindowPeer ownerPeer) {
return new CWarningWindow(ownerWindow, ownerPeer);
}
@Override
protected PlatformComponent createPlatformComponent() {
return new CPlatformComponent();
......
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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
......@@ -669,6 +669,27 @@ Java_sun_lwawt_macosx_CWrapper_00024NSView_setHidden
JNF_COCOA_EXIT(env);
}
/*
* Class: sun_lwawt_macosx_CWrapper$NSView
* Method: setToolTip
* Signature: (JLjava/lang/String;)V
*/
JNIEXPORT void JNICALL
Java_sun_lwawt_macosx_CWrapper_00024NSView_setToolTip
(JNIEnv *env, jclass cls, jlong viewPtr, jstring msg)
{
JNF_COCOA_ENTER(env);
NSView *view = (NSView *)jlong_to_ptr(viewPtr);
NSString* s = JNFJavaToNSString(env, msg);
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){
[view setToolTip: s];
}];
JNF_COCOA_EXIT(env);
}
/*
* Class: sun_lwawt_macosx_CWrapper$NSScreen
......@@ -735,7 +756,7 @@ Java_sun_lwawt_macosx_CWrapper_00024NSScreen_screenByDisplayId
{
__block jlong screenPtr = 0L;
JNF_COCOA_ENTER(env);
JNF_COCOA_ENTER(env);
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
NSArray *screens = [NSScreen screens];
......
/*
* Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 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
......@@ -22,7 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.awt.X11;
package sun.awt;
import java.awt.*;
import java.awt.color.*;
import java.awt.image.*;
......@@ -30,17 +30,17 @@ import sun.awt.image.ToolkitImage;
import sun.awt.image.ImageRepresentation;
import java.util.Arrays;
class XIconInfo {
public class IconInfo {
/**
* Representation of image as an int array
* It's being used for _NET_WM_ICON hint
* with 32-bit X data model
* Representation of image as an int array.
* It's used on platforms where icon data
* is expected to be in 32-bit format.
*/
private int[] intIconData;
/**
* Representation of image as an int array
* It's being used for _NET_WM_ICON hint
* with 64-bit X data model
* Representation of image as an long array.
* It's used on platforms where icon data
* is expected to be in 64-bit format.
*/
private long[] longIconData;
/**
......@@ -68,7 +68,7 @@ class XIconInfo {
*/
private int rawLength;
XIconInfo(int[] intIconData) {
public IconInfo(int[] intIconData) {
this.intIconData =
(null == intIconData) ? null : Arrays.copyOf(intIconData, intIconData.length);
this.width = intIconData[0];
......@@ -78,7 +78,7 @@ class XIconInfo {
this.rawLength = width * height + 2;
}
XIconInfo(long[] longIconData) {
public IconInfo(long[] longIconData) {
this.longIconData =
(null == longIconData) ? null : Arrays.copyOf(longIconData, longIconData.length);
this.width = (int)longIconData[0];
......@@ -88,7 +88,7 @@ class XIconInfo {
this.rawLength = width * height + 2;
}
XIconInfo(Image image) {
public IconInfo(Image image) {
this.image = image;
if (image instanceof ToolkitImage) {
ImageRepresentation ir = ((ToolkitImage)image).getImageRep();
......@@ -107,33 +107,33 @@ class XIconInfo {
/*
* It sets size of scaled icon.
*/
void setScaledSize(int width, int height) {
public void setScaledSize(int width, int height) {
this.scaledWidth = width;
this.scaledHeight = height;
this.rawLength = width * height + 2;
}
boolean isValid() {
public boolean isValid() {
return (width > 0 && height > 0);
}
int getWidth() {
public int getWidth() {
return width;
}
int getHeight() {
public int getHeight() {
return height;
}
public String toString() {
return "XIconInfo[w=" + width + ",h=" + height + ",sw=" + scaledWidth + ",sh=" + scaledHeight + "]";
return "IconInfo[w=" + width + ",h=" + height + ",sw=" + scaledWidth + ",sh=" + scaledHeight + "]";
}
int getRawLength() {
public int getRawLength() {
return rawLength;
}
int[] getIntData() {
public int[] getIntData() {
if (this.intIconData == null) {
if (this.longIconData != null) {
this.intIconData = longArrayToIntArray(longIconData);
......@@ -144,7 +144,7 @@ class XIconInfo {
return this.intIconData;
}
long[] getLongData() {
public long[] getLongData() {
if (this.longIconData == null) {
if (this.intIconData != null) {
this.longIconData = intArrayToLongArray(this.intIconData);
......@@ -156,7 +156,7 @@ class XIconInfo {
return this.longIconData;
}
Image getImage() {
public Image getImage() {
if (this.image == null) {
if (this.intIconData != null) {
this.image = intArrayToImage(this.intIconData);
......
/*
* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 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
......@@ -30,6 +30,7 @@ import java.awt.event.ComponentEvent;
import java.awt.event.InvocationEvent;
import java.awt.event.WindowEvent;
import sun.awt.IconInfo;
import sun.util.logging.PlatformLogger;
import sun.awt.AWTAccessor;
......@@ -106,7 +107,7 @@ abstract class XDecoratedPeer extends XWindowPeer {
focusProxy = createFocusProxy();
}
void setIconHints(java.util.List<XIconInfo> icons) {
void setIconHints(java.util.List<IconInfo> icons) {
if (!XWM.getWM().setNetWMIcon(this, icons)) {
if (icons.size() > 0) {
if (iconWindow == null) {
......
/*
* Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
......@@ -26,7 +26,8 @@ package sun.awt.X11;
import java.awt.*;
import java.awt.image.*;
import sun.awt.X11GraphicsConfig;
import sun.awt.IconInfo;
import sun.awt.image.ToolkitImage;
import sun.awt.image.ImageRepresentation;
......@@ -398,12 +399,12 @@ public class XIconWindow extends XBaseWindow {
* Sets icon image by selecting one of the images from the list.
* The selected image is the one having the best matching size.
*/
void setIconImages(java.util.List<XIconInfo> icons) {
void setIconImages(java.util.List<IconInfo> icons) {
if (icons == null || icons.size() == 0) return;
int minDiff = Integer.MAX_VALUE;
Image min = null;
for (XIconInfo iconInfo : icons) {
for (IconInfo iconInfo : icons) {
if (iconInfo.isValid()) {
Image image = iconInfo.getImage();
Dimension dim = calcIconSize(image.getWidth(null), image.getHeight(null));
......
/*
* Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
......@@ -27,6 +27,8 @@
package sun.awt.X11;
import java.awt.Frame;
import sun.awt.IconInfo;
import sun.util.logging.PlatformLogger;
final class XNETProtocol extends XProtocol implements XStateProtocol, XLayerProtocol
......@@ -350,10 +352,10 @@ final class XNETProtocol extends XProtocol implements XStateProtocol, XLayerProt
}
/**
* Sets _NET_WM_ICON property on the window using the List of XIconInfo
* Sets _NET_WM_ICON property on the window using the List of IconInfo
* If icons is null or empty list, removes _NET_WM_ICON property
*/
public void setWMIcons(XWindowPeer window, java.util.List<XIconInfo> icons) {
public void setWMIcons(XWindowPeer window, java.util.List<IconInfo> icons) {
if (window == null) return;
XAtom iconsAtom = XAtom.get("_NET_WM_ICON");
......@@ -363,7 +365,7 @@ final class XNETProtocol extends XProtocol implements XStateProtocol, XLayerProt
}
int length = 0;
for (XIconInfo ii : icons) {
for (IconInfo ii : icons) {
length += ii.getRawLength();
}
int cardinalSize = (XlibWrapper.dataModel == 32) ? 4 : 8;
......@@ -373,7 +375,7 @@ final class XNETProtocol extends XProtocol implements XStateProtocol, XLayerProt
long buffer = XlibWrapper.unsafe.allocateMemory(bufferSize);
try {
long ptr = buffer;
for (XIconInfo ii : icons) {
for (IconInfo ii : icons) {
int size = ii.getRawLength() * cardinalSize;
if (XlibWrapper.dataModel == 32) {
XlibWrapper.copyIntArray(ptr, ii.getIntData(), size);
......
/*
* Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
......@@ -30,6 +30,7 @@
*/
package sun.awt.X11;
import sun.awt.IconInfo;
import sun.misc.Unsafe;
import java.awt.Insets;
import java.awt.Frame;
......@@ -1670,7 +1671,7 @@ final class XWM
*
* @return true if hint was modified successfully, false otherwise
*/
public boolean setNetWMIcon(XWindowPeer window, java.util.List<XIconInfo> icons) {
public boolean setNetWMIcon(XWindowPeer window, java.util.List<IconInfo> icons) {
if (g_net_protocol != null && g_net_protocol.active()) {
g_net_protocol.setWMIcons(window, icons);
return getWMID() != ICE_WM;
......
/*
* Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
......@@ -25,11 +25,10 @@
package sun.awt.X11;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.Point2D;
import java.lang.ref.WeakReference;
import sun.java2d.SunGraphics2D;
import sun.java2d.pipe.Region;
import sun.awt.IconInfo;
import sun.awt.AWTAccessor;
import sun.awt.SunToolkit;
......@@ -56,37 +55,37 @@ class XWarningWindow extends XWindow {
* 3 - 48x48
*/
private int currentSize = -1;
private static XIconInfo[][] icons;
private static XIconInfo getSecurityIconInfo(int size, int num) {
private static IconInfo[][] icons;
private static IconInfo getSecurityIconInfo(int size, int num) {
synchronized (XWarningWindow.class) {
if (icons == null) {
icons = new XIconInfo[4][3];
icons = new IconInfo[4][3];
if (XlibWrapper.dataModel == 32) {
icons[0][0] = new XIconInfo(XAWTIcon32_security_icon_bw16_png.security_icon_bw16_png);
icons[0][1] = new XIconInfo(XAWTIcon32_security_icon_interim16_png.security_icon_interim16_png);
icons[0][2] = new XIconInfo(XAWTIcon32_security_icon_yellow16_png.security_icon_yellow16_png);
icons[1][0] = new XIconInfo(XAWTIcon32_security_icon_bw24_png.security_icon_bw24_png);
icons[1][1] = new XIconInfo(XAWTIcon32_security_icon_interim24_png.security_icon_interim24_png);
icons[1][2] = new XIconInfo(XAWTIcon32_security_icon_yellow24_png.security_icon_yellow24_png);
icons[2][0] = new XIconInfo(XAWTIcon32_security_icon_bw32_png.security_icon_bw32_png);
icons[2][1] = new XIconInfo(XAWTIcon32_security_icon_interim32_png.security_icon_interim32_png);
icons[2][2] = new XIconInfo(XAWTIcon32_security_icon_yellow32_png.security_icon_yellow32_png);
icons[3][0] = new XIconInfo(XAWTIcon32_security_icon_bw48_png.security_icon_bw48_png);
icons[3][1] = new XIconInfo(XAWTIcon32_security_icon_interim48_png.security_icon_interim48_png);
icons[3][2] = new XIconInfo(XAWTIcon32_security_icon_yellow48_png.security_icon_yellow48_png);
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 XIconInfo(XAWTIcon64_security_icon_bw16_png.security_icon_bw16_png);
icons[0][1] = new XIconInfo(XAWTIcon64_security_icon_interim16_png.security_icon_interim16_png);
icons[0][2] = new XIconInfo(XAWTIcon64_security_icon_yellow16_png.security_icon_yellow16_png);
icons[1][0] = new XIconInfo(XAWTIcon64_security_icon_bw24_png.security_icon_bw24_png);
icons[1][1] = new XIconInfo(XAWTIcon64_security_icon_interim24_png.security_icon_interim24_png);
icons[1][2] = new XIconInfo(XAWTIcon64_security_icon_yellow24_png.security_icon_yellow24_png);
icons[2][0] = new XIconInfo(XAWTIcon64_security_icon_bw32_png.security_icon_bw32_png);
icons[2][1] = new XIconInfo(XAWTIcon64_security_icon_interim32_png.security_icon_interim32_png);
icons[2][2] = new XIconInfo(XAWTIcon64_security_icon_yellow32_png.security_icon_yellow32_png);
icons[3][0] = new XIconInfo(XAWTIcon64_security_icon_bw48_png.security_icon_bw48_png);
icons[3][1] = new XIconInfo(XAWTIcon64_security_icon_interim48_png.security_icon_interim48_png);
icons[3][2] = new XIconInfo(XAWTIcon64_security_icon_yellow48_png.security_icon_yellow48_png);
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);
}
}
}
......@@ -125,7 +124,7 @@ class XWarningWindow extends XWindow {
try {
if (newSize != currentSize) {
currentSize = newSize;
XIconInfo ico = getSecurityIconInfo(currentSize, 0);
IconInfo ico = getSecurityIconInfo(currentSize, 0);
XlibWrapper.SetBitmapShape(XToolkit.getDisplay(), getWindow(),
ico.getWidth(), ico.getHeight(), ico.getIntData());
AWTAccessor.getWindowAccessor().setSecurityWarningSize(
......@@ -136,7 +135,7 @@ class XWarningWindow extends XWindow {
}
}
private XIconInfo getSecurityIconInfo() {
private IconInfo getSecurityIconInfo() {
updateIconSize();
return getSecurityIconInfo(currentSize, currentIcon);
}
......
/*
* Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 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
......@@ -23,8 +23,7 @@
* questions.
*/
package sun.awt.X11;
import java.awt.Image;
import java.util.ArrayList;
import sun.awt.IconInfo;
class XWindowAttributesData {
static int NORMAL = 0;
......@@ -51,7 +50,7 @@ class XWindowAttributesData {
boolean initialResizability;
int visibilityState; // updated by native X11 event handling code.
String title;
java.util.List<XIconInfo> icons;
java.util.List<IconInfo> icons;
boolean iconsInherited;
int decorations; // for future expansion to be able to
// specify native decorations
......
......@@ -30,8 +30,6 @@ import java.awt.event.ComponentEvent;
import java.awt.event.FocusEvent;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.awt.peer.ComponentPeer;
import java.awt.peer.WindowPeer;
......@@ -55,6 +53,7 @@ import sun.awt.DisplayChangedListener;
import sun.awt.SunToolkit;
import sun.awt.X11GraphicsDevice;
import sun.awt.X11GraphicsEnvironment;
import sun.awt.IconInfo;
import sun.java2d.pipe.Region;
......@@ -292,7 +291,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
Window target = (Window)this.target;
java.util.List<Image> iconImages = ((Window)target).getIconImages();
XWindowPeer ownerPeer = getOwnerPeer();
winAttr.icons = new ArrayList<XIconInfo>();
winAttr.icons = new ArrayList<IconInfo>();
if (iconImages.size() != 0) {
//read icon images from target
winAttr.iconsInherited = false;
......@@ -304,9 +303,9 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
}
continue;
}
XIconInfo iconInfo;
IconInfo iconInfo;
try {
iconInfo = new XIconInfo(image);
iconInfo = new IconInfo(image);
} catch (Exception e){
if (log.isLoggable(PlatformLogger.FINEST)) {
log.finest("XWindowPeer.updateIconImages: Perhaps the image passed into Java is broken. Skipping this icon.");
......@@ -344,12 +343,12 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
* It does scale some of these icons to appropriate size
* if it's necessary.
*/
static java.util.List<XIconInfo> normalizeIconImages(java.util.List<XIconInfo> icons) {
java.util.List<XIconInfo> result = new ArrayList<XIconInfo>();
static java.util.List<IconInfo> normalizeIconImages(java.util.List<IconInfo> icons) {
java.util.List<IconInfo> result = new ArrayList<IconInfo>();
int totalLength = 0;
boolean haveLargeIcon = false;
for (XIconInfo icon : icons) {
for (IconInfo icon : icons) {
int width = icon.getWidth();
int height = icon.getHeight();
int length = icon.getRawLength();
......@@ -390,16 +389,16 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
/*
* Dumps each icon from the list
*/
static void dumpIcons(java.util.List<XIconInfo> icons) {
static void dumpIcons(java.util.List<IconInfo> icons) {
if (iconLog.isLoggable(PlatformLogger.FINEST)) {
iconLog.finest(">>> Sizes of icon images:");
for (Iterator<XIconInfo> i = icons.iterator(); i.hasNext(); ) {
for (Iterator<IconInfo> i = icons.iterator(); i.hasNext(); ) {
iconLog.finest(" {0}", i.next());
}
}
}
public void recursivelySetIcon(java.util.List<XIconInfo> icons) {
public void recursivelySetIcon(java.util.List<IconInfo> icons) {
dumpIcons(winAttr.icons);
setIconHints(icons);
Window target = (Window)this.target;
......@@ -416,28 +415,28 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
}
}
java.util.List<XIconInfo> getIconInfo() {
java.util.List<IconInfo> getIconInfo() {
return winAttr.icons;
}
void setIconHints(java.util.List<XIconInfo> icons) {
void setIconHints(java.util.List<IconInfo> icons) {
//This does nothing for XWindowPeer,
//It's overriden in XDecoratedPeer
}
private static ArrayList<XIconInfo> defaultIconInfo;
protected synchronized static java.util.List<XIconInfo> getDefaultIconInfo() {
private static ArrayList<IconInfo> defaultIconInfo;
protected synchronized static java.util.List<IconInfo> getDefaultIconInfo() {
if (defaultIconInfo == null) {
defaultIconInfo = new ArrayList<XIconInfo>();
defaultIconInfo = new ArrayList<IconInfo>();
if (XlibWrapper.dataModel == 32) {
defaultIconInfo.add(new XIconInfo(XAWTIcon32_java_icon16_png.java_icon16_png));
defaultIconInfo.add(new XIconInfo(XAWTIcon32_java_icon24_png.java_icon24_png));
defaultIconInfo.add(new XIconInfo(XAWTIcon32_java_icon32_png.java_icon32_png));
defaultIconInfo.add(new XIconInfo(XAWTIcon32_java_icon48_png.java_icon48_png));
defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon32_java_icon16_png.java_icon16_png));
defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon32_java_icon24_png.java_icon24_png));
defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon32_java_icon32_png.java_icon32_png));
defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon32_java_icon48_png.java_icon48_png));
} else {
defaultIconInfo.add(new XIconInfo(XAWTIcon64_java_icon16_png.java_icon16_png));
defaultIconInfo.add(new XIconInfo(XAWTIcon64_java_icon24_png.java_icon24_png));
defaultIconInfo.add(new XIconInfo(XAWTIcon64_java_icon32_png.java_icon32_png));
defaultIconInfo.add(new XIconInfo(XAWTIcon64_java_icon48_png.java_icon48_png));
defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon64_java_icon16_png.java_icon16_png));
defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon64_java_icon24_png.java_icon24_png));
defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon64_java_icon32_png.java_icon32_png));
defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon64_java_icon48_png.java_icon48_png));
}
}
return defaultIconInfo;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册