提交 9c787302 编写于 作者: D dholmes

7030063: AWT support for SE-Embedded integration

Summary: AWT support for SE-Embedded
Reviewed-by: anthony, art, bobv, collins, alanb
上级 4885bba5
# #
# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -44,8 +44,17 @@ $(MAKE) -f Makefile.launcher \ ...@@ -44,8 +44,17 @@ $(MAKE) -f Makefile.launcher \
endef endef
# Run MAKE $@ for all generic launchers # Run MAKE $@ for all generic launchers
define make-all-launchers ifndef BUILD_HEADLESS_ONLY
define make-appletviewer
$(call make-launcher, appletviewer, sun.applet.Main, , ) $(call make-launcher, appletviewer, sun.applet.Main, , )
endef
else
define make-appletviewer
endef
endif
define make-all-launchers
$(make-appletviewer)
$(call make-launcher, apt, com.sun.tools.apt.Main, , ) $(call make-launcher, apt, com.sun.tools.apt.Main, , )
$(call make-launcher, extcheck, com.sun.tools.extcheck.Main, , ) $(call make-launcher, extcheck, com.sun.tools.extcheck.Main, , )
$(call make-launcher, idlj, com.sun.tools.corba.se.idl.toJavaPortable.Compile, , ) $(call make-launcher, idlj, com.sun.tools.corba.se.idl.toJavaPortable.Compile, , )
......
# #
# Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -69,10 +69,17 @@ endif ...@@ -69,10 +69,17 @@ endif
# nio need to be compiled before awt to have all charsets ready # nio need to be compiled before awt to have all charsets ready
SUBDIRS = jar security javazic misc net nio text launcher SUBDIRS = jar security javazic misc net nio text launcher
ifdef BUILD_HEADLESS_ONLY
DISPLAY_LIBS = awt $(HEADLESS_SUBDIR)
DISPLAY_TOOLS =
else
DISPLAY_LIBS = awt splashscreen $(XAWT_SUBDIR) $(HEADLESS_SUBDIR)
DISPLAY_TOOLS = applet
endif
SUBDIRS_desktop = audio $(RENDER_SUBDIR) image \ SUBDIRS_desktop = audio $(RENDER_SUBDIR) image \
awt splashscreen $(XAWT_SUBDIR) \ $(DISPLAY_LIBS) $(DGA_SUBDIR) \
$(HEADLESS_SUBDIR) $(DGA_SUBDIR) \ jawt font jpeg cmm $(DISPLAY_TOOLS) beans
jawt font jpeg cmm applet beans
SUBDIRS_management = management SUBDIRS_management = management
SUBDIRS_misc = $(ORG_SUBDIR) rmi $(JDBC_SUBDIR) tracing SUBDIRS_misc = $(ORG_SUBDIR) rmi $(JDBC_SUBDIR) tracing
SUBDIRS_tools = native2ascii serialver tools jconsole SUBDIRS_tools = native2ascii serialver tools jconsole
......
# #
# Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -149,13 +149,13 @@ ifeq ($(PLATFORM), linux) ...@@ -149,13 +149,13 @@ ifeq ($(PLATFORM), linux)
LIBXT = -lXt LIBXT = -lXt
else else
# Allows for builds on Debian GNU Linux, X11 is in a different place # Allows for builds on Debian GNU Linux, X11 is in a different place
LIBXT = $(firstword $(wildcard /usr/X11R6/lib/libXt.a) \ LIBXT = $(firstword $(wildcard $(OPENWIN_LIB)/libXt.a) \
$(wildcard /usr/lib/libXt.a)) $(wildcard /usr/lib/libXt.a))
LIBSM = $(firstword $(wildcard /usr/X11R6/lib/libSM.a) \ LIBSM = $(firstword $(wildcard $(OPENWIN_LIB)/libSM.a) \
$(wildcard /usr/lib/libSM.a)) $(wildcard /usr/lib/libSM.a))
LIBICE = $(firstword $(wildcard /usr/X11R6/lib/libICE.a) \ LIBICE = $(firstword $(wildcard $(OPENWIN_LIB)/libICE.a) \
$(wildcard /usr/lib/libICE.a)) $(wildcard /usr/lib/libICE.a))
LIBXTST = $(firstword $(wildcard /usr/X11R6/lib/libXtst.a) \ LIBXTST = $(firstword $(wildcard $(OPENWIN_LIB)/libXtst.a) \
$(wildcard /usr/lib/libXtst.a)) $(wildcard /usr/lib/libXtst.a))
endif endif
endif endif
...@@ -224,9 +224,9 @@ CPPFLAGS += -I$(SHARE_SRC)/native/$(PKGDIR)/debug \ ...@@ -224,9 +224,9 @@ CPPFLAGS += -I$(SHARE_SRC)/native/$(PKGDIR)/debug \
$(EVENT_MODEL) $(EVENT_MODEL)
ifeq ($(PLATFORM), linux) ifeq ($(PLATFORM), linux)
# Checking for the X11/extensions headers at the additional location # Checking for the X11/extensions headers at the additional location
CPPFLAGS += -I/X11R6/include/X11/extensions \ CPPFLAGS += -I$(firstword $(wildcard $(OPENWIN_HOME)/include/X11/extensions) \
-I/usr/include/X11/extensions $(wildcard /usr/include/X11/extensions))
endif endif
ifeq ($(PLATFORM), solaris) ifeq ($(PLATFORM), solaris)
......
# #
# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -112,11 +112,20 @@ CPPFLAGS += -I$(OPENWIN_HOME)/include \ ...@@ -112,11 +112,20 @@ CPPFLAGS += -I$(OPENWIN_HOME)/include \
# Libraries to link in. # Libraries to link in.
# #
ifeq ($(PLATFORM), solaris) ifeq ($(PLATFORM), solaris)
OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -L$(OPENWIN_LIB) -L$(LIBDIR)/$(LIBARCH)/xawt -lmawt -L/usr/openwin/sfw/lib$(ISA_DIR) -lXrender ifndef BUILD_HEADLESS_ONLY
OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -L$(OPENWIN_LIB) -L$(LIBDIR)/$(LIBARCH)/xawt -lmawt -L/usr/openwin/sfw/lib$(ISA_DIR) -lXrender
else
OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -L$(OPENWIN_LIB) -L$(LIBDIR)/$(LIBARCH)/headless -lmawt -L/usr/openwin/sfw/lib$(ISA_DIR) -lXrender
endif
endif # PLATFORM endif # PLATFORM
ifeq ($(PLATFORM), linux) ifeq ($(PLATFORM), linux)
OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -lawt -L$(LIBDIR)/$(LIBARCH)/xawt -lmawt ifndef BUILD_HEADLESS_ONLY
OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -lawt -L$(LIBDIR)/$(LIBARCH)/xawt -lmawt
else
OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -lawt -L$(LIBDIR)/$(LIBARCH)/headless -lmawt
CFLAGS += -DHEADLESS
endif
endif # PLATFORM endif # PLATFORM
endif # PLATFORM endif # PLATFORM
......
...@@ -73,9 +73,10 @@ ifeq ($(PLATFORM), linux) ...@@ -73,9 +73,10 @@ ifeq ($(PLATFORM), linux)
# Recommended way to avoid such warning is to declare the variable as # Recommended way to avoid such warning is to declare the variable as
# volatile to prevent the optimization. However, this approach does not # volatile to prevent the optimization. However, this approach does not
# work because we have to declare all variables as volatile in result. # work because we have to declare all variables as volatile in result.
ifndef CROSS_COMPILE_ARCH
OTHER_CFLAGS += -Wno-clobbered OTHER_CFLAGS += -Wno-clobbered
endif endif
endif
include $(BUILDDIR)/common/Mapfile-vers.gmk include $(BUILDDIR)/common/Mapfile-vers.gmk
include $(BUILDDIR)/common/Library.gmk include $(BUILDDIR)/common/Library.gmk
......
# #
# Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -46,5 +46,7 @@ include $(BUILDDIR)/common/Classes.gmk ...@@ -46,5 +46,7 @@ include $(BUILDDIR)/common/Classes.gmk
build: build:
$(call make-launcher, keytool, sun.security.tools.KeyTool, , ) $(call make-launcher, keytool, sun.security.tools.KeyTool, , )
ifndef BUILD_HEADLESS_ONLY
$(call make-launcher, policytool, sun.security.tools.policytool.PolicyTool, , ) $(call make-launcher, policytool, sun.security.tools.policytool.PolicyTool, , )
endif
# #
# Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -129,10 +129,17 @@ CPPFLAGS += -DXAWT -DXAWT_HACK \ ...@@ -129,10 +129,17 @@ CPPFLAGS += -DXAWT -DXAWT_HACK \
-I$(PLATFORM_SRC)/native/sun/awt -I$(PLATFORM_SRC)/native/sun/awt
ifeq ($(PLATFORM), linux) ifeq ($(PLATFORM), linux)
# Allows for builds on Debian GNU Linux, X11 is in a different place ifndef CROSS_COMPILE_ARCH
CPPFLAGS += -I/usr/X11R6/include/X11/extensions \ # Allows for builds on Debian GNU Linux, X11 is in a different place
-I/usr/include/X11/extensions \ # This should really be handled at a higher-level so we don't have to
-I$(OPENWIN_HOME)/include # work-around this when cross-compiling
CPPFLAGS += -I/usr/X11R6/include/X11/extensions \
-I/usr/include/X11/extensions \
-I$(OPENWIN_HOME)/include
else
CPPFLAGS += -I$(OPENWIN_HOME)/include/X11/extensions \
-I$(OPENWIN_HOME)/include
endif
endif endif
# We have some odd logic here because some Solaris 10 updates # We have some odd logic here because some Solaris 10 updates
...@@ -245,7 +252,11 @@ XLIBTYPES=$(PLATFORM_SRC)/classes/sun/awt/X11/generator/xlibtypes.txt ...@@ -245,7 +252,11 @@ XLIBTYPES=$(PLATFORM_SRC)/classes/sun/awt/X11/generator/xlibtypes.txt
$(SIZERS): $(SIZERS_C) $(SIZERS): $(SIZERS_C)
$(prep-target) $(prep-target)
ifndef CROSS_COMPILE_ARCH
$(CC) $(CFLAGS_$(subst .,,$(suffix $@))) $(CPPFLAGS) -o $@ $(SIZER)$(suffix $@).c $(CC) $(CFLAGS_$(subst .,,$(suffix $@))) $(CPPFLAGS) -o $@ $(SIZER)$(suffix $@).c
else
$(HOST_CC) $(CPPFLAGS) -o $@ $(SIZER)$(suffix $@).c
endif
$(WRAPPER_GENERATOR_CLASS): $(WRAPPER_GENERATOR_JAVA) $(WRAPPER_GENERATOR_CLASS): $(WRAPPER_GENERATOR_JAVA)
$(prep-target) $(prep-target)
......
/* /*
* Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -858,7 +858,7 @@ public abstract class Toolkit { ...@@ -858,7 +858,7 @@ public abstract class Toolkit {
String nm = null; String nm = null;
Class cls = null; Class cls = null;
try { try {
nm = System.getProperty("awt.toolkit", "sun.awt.X11.XToolkit"); nm = System.getProperty("awt.toolkit");
try { try {
cls = Class.forName(nm); cls = Class.forName(nm);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
......
/*
* Copyright (c) 2011, 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;
import java.awt.*;
import java.awt.dnd.*;
import java.awt.dnd.peer.DragSourceContextPeer;
import java.awt.im.InputMethodHighlight;
import java.awt.im.spi.InputMethodDescriptor;
import java.awt.image.*;
import java.awt.datatransfer.Clipboard;
import java.awt.peer.*;
import java.util.Map;
import java.util.Properties;
/*
* HToolkit is a platform independent Toolkit used
* with the HeadlessToolkit. It is primarily used
* in embedded JRE's that do not have sun/awt/X11 classes.
*/
public class HToolkit extends SunToolkit
implements ComponentFactory {
public HToolkit() {
}
/*
* Component peer objects - unsupported.
*/
public WindowPeer createWindow(Window target)
throws HeadlessException {
throw new HeadlessException();
}
public FramePeer createFrame(Frame target)
throws HeadlessException {
throw new HeadlessException();
}
public DialogPeer createDialog(Dialog target)
throws HeadlessException {
throw new HeadlessException();
}
public ButtonPeer createButton(Button target)
throws HeadlessException {
throw new HeadlessException();
}
public TextFieldPeer createTextField(TextField target)
throws HeadlessException {
throw new HeadlessException();
}
public ChoicePeer createChoice(Choice target)
throws HeadlessException {
throw new HeadlessException();
}
public LabelPeer createLabel(Label target)
throws HeadlessException {
throw new HeadlessException();
}
public ListPeer createList(List target)
throws HeadlessException {
throw new HeadlessException();
}
public CheckboxPeer createCheckbox(Checkbox target)
throws HeadlessException {
throw new HeadlessException();
}
public ScrollbarPeer createScrollbar(Scrollbar target)
throws HeadlessException {
throw new HeadlessException();
}
public ScrollPanePeer createScrollPane(ScrollPane target)
throws HeadlessException {
throw new HeadlessException();
}
public TextAreaPeer createTextArea(TextArea target)
throws HeadlessException {
throw new HeadlessException();
}
public FileDialogPeer createFileDialog(FileDialog target)
throws HeadlessException {
throw new HeadlessException();
}
public MenuBarPeer createMenuBar(MenuBar target)
throws HeadlessException {
throw new HeadlessException();
}
public MenuPeer createMenu(Menu target)
throws HeadlessException {
throw new HeadlessException();
}
public PopupMenuPeer createPopupMenu(PopupMenu target)
throws HeadlessException {
throw new HeadlessException();
}
public MenuItemPeer createMenuItem(MenuItem target)
throws HeadlessException {
throw new HeadlessException();
}
public CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target)
throws HeadlessException {
throw new HeadlessException();
}
public DragSourceContextPeer createDragSourceContextPeer(
DragGestureEvent dge)
throws InvalidDnDOperationException {
throw new InvalidDnDOperationException("Headless environment");
}
public RobotPeer createRobot(Robot target, GraphicsDevice screen)
throws AWTException, HeadlessException {
throw new HeadlessException();
}
public KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager) {
// See 6833019.
return
new KeyboardFocusManagerPeer() {
public Window getCurrentFocusedWindow() { return null; }
public void setCurrentFocusOwner(Component comp) {}
public Component getCurrentFocusOwner() { return null; }
public void clearGlobalFocusOwner(Window activeWindow) {}
};
}
public TrayIconPeer createTrayIcon(TrayIcon target)
throws HeadlessException {
throw new HeadlessException();
}
public SystemTrayPeer createSystemTray(SystemTray target)
throws HeadlessException {
throw new HeadlessException();
}
public boolean isTraySupported() {
return false;
}
public GlobalCursorManager getGlobalCursorManager()
throws HeadlessException {
throw new HeadlessException();
}
/*
* Headless toolkit - unsupported.
*/
protected void loadSystemColors(int[] systemColors)
throws HeadlessException {
throw new HeadlessException();
}
public ColorModel getColorModel()
throws HeadlessException {
throw new HeadlessException();
}
public int getScreenResolution()
throws HeadlessException {
throw new HeadlessException();
}
public Map mapInputMethodHighlight(InputMethodHighlight highlight)
throws HeadlessException {
throw new HeadlessException();
}
public int getMenuShortcutKeyMask()
throws HeadlessException {
throw new HeadlessException();
}
public boolean getLockingKeyState(int keyCode)
throws UnsupportedOperationException {
throw new HeadlessException();
}
public void setLockingKeyState(int keyCode, boolean on)
throws UnsupportedOperationException {
throw new HeadlessException();
}
public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
throws IndexOutOfBoundsException, HeadlessException {
throw new HeadlessException();
}
public Dimension getBestCursorSize(int preferredWidth, int preferredHeight)
throws HeadlessException {
throw new HeadlessException();
}
public int getMaximumCursorColors()
throws HeadlessException {
throw new HeadlessException();
}
public <T extends DragGestureRecognizer> T
createDragGestureRecognizer(Class<T> abstractRecognizerClass,
DragSource ds, Component c,
int srcActions, DragGestureListener dgl)
{
return null;
}
public int getScreenHeight()
throws HeadlessException {
throw new HeadlessException();
}
public int getScreenWidth()
throws HeadlessException {
throw new HeadlessException();
}
public Dimension getScreenSize()
throws HeadlessException {
throw new HeadlessException();
}
public Insets getScreenInsets(GraphicsConfiguration gc)
throws HeadlessException {
throw new HeadlessException();
}
public void setDynamicLayout(boolean dynamic)
throws HeadlessException {
throw new HeadlessException();
}
protected boolean isDynamicLayoutSet()
throws HeadlessException {
throw new HeadlessException();
}
public boolean isDynamicLayoutActive()
throws HeadlessException {
throw new HeadlessException();
}
public Clipboard getSystemClipboard()
throws HeadlessException {
throw new HeadlessException();
}
/*
* Printing
*/
public PrintJob getPrintJob(Frame frame, String jobtitle,
JobAttributes jobAttributes,
PageAttributes pageAttributes) {
if (frame != null) {
// Should never happen
throw new HeadlessException();
}
throw new IllegalArgumentException(
"PrintJob not supported in a headless environment");
}
public PrintJob getPrintJob(Frame frame, String doctitle, Properties props)
{
if (frame != null) {
// Should never happen
throw new HeadlessException();
}
throw new IllegalArgumentException(
"PrintJob not supported in a headless environment");
}
/*
* Headless toolkit - supported.
*/
public void sync() {
// Do nothing
}
protected boolean syncNativeQueue(final long timeout) {
return false;
}
public void beep() {
// Send alert character
System.out.write(0x07);
}
/*
* Fonts
*/
public FontPeer getFontPeer(String name, int style) {
return (FontPeer)null;
}
/*
* Modality
*/
public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) {
return false;
}
public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType exclusionType) {
return false;
}
public boolean isDesktopSupported() {
return false;
}
public DesktopPeer createDesktopPeer(Desktop target)
throws HeadlessException{
throw new HeadlessException();
}
public boolean isWindowOpacityControlSupported() {
return false;
}
public boolean isWindowShapingSupported() {
return false;
}
public boolean isWindowTranslucencySupported() {
return false;
}
public void grab(Window w) { }
public void ungrab(Window w) { }
protected boolean syncNativeQueue() { return false; }
public InputMethodDescriptor getInputMethodAdapterDescriptor()
throws AWTException
{
return (InputMethodDescriptor)null;
}
}
/* /*
* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -135,6 +135,12 @@ public final class XToolkit extends UNIXToolkit implements Runnable { ...@@ -135,6 +135,12 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
noisyAwtHandler = AccessController.doPrivileged(new GetBooleanAction("sun.awt.noisyerrorhandler")); noisyAwtHandler = AccessController.doPrivileged(new GetBooleanAction("sun.awt.noisyerrorhandler"));
} }
/*
* Return (potentially) platform specific display timeout for the
* tray icon
*/
static native long getTrayIconDisplayTimeout();
//---- ERROR HANDLER CODE ----// //---- ERROR HANDLER CODE ----//
/* /*
......
/* /*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -230,7 +230,7 @@ public class XTrayIconPeer implements TrayIconPeer, ...@@ -230,7 +230,7 @@ public class XTrayIconPeer implements TrayIconPeer,
// Wait till the EmbeddedFrame is reparented // Wait till the EmbeddedFrame is reparented
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
final long PERIOD = 2000L; final long PERIOD = XToolkit.getTrayIconDisplayTimeout();
XToolkit.awtLock(); XToolkit.awtLock();
try { try {
while (!isTrayIconDisplayed) { while (!isTrayIconDisplayed) {
......
/* /*
* Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -55,6 +55,11 @@ ...@@ -55,6 +55,11 @@
#endif #endif
#endif #endif
#ifdef JAVASE_EMBEDDED
#include <dlfcn.h>
#include <sys/stat.h>
#endif
/* Take an array of string pairs (map of key->value) and a string (key). /* Take an array of string pairs (map of key->value) and a string (key).
* Examine each pair in the map to see if the first string (key) matches the * Examine each pair in the map to see if the first string (key) matches the
* string. If so, store the second string of the pair (value) in the value and * string. If so, store the second string of the pair (value) in the value and
...@@ -304,6 +309,36 @@ static int ParseLocale(int cat, char ** std_language, char ** std_script, ...@@ -304,6 +309,36 @@ static int ParseLocale(int cat, char ** std_language, char ** std_script,
return 1; return 1;
} }
#ifdef JAVASE_EMBEDDED
/* Determine the default embedded toolkit based on whether lib/xawt/
* exists in the JRE. This can still be overridden by -Dawt.toolkit=XXX
*/
static char* getEmbeddedToolkit() {
Dl_info dlinfo;
char buf[MAXPATHLEN];
int32_t len;
char *p;
struct stat statbuf;
/* Get address of this library and the directory containing it. */
dladdr((void *)getEmbeddedToolkit, &dlinfo);
realpath((char *)dlinfo.dli_fname, buf);
len = strlen(buf);
p = strrchr(buf, '/');
/* Default AWT Toolkit on Linux and Solaris is XAWT. */
strncpy(p, "/xawt/", MAXPATHLEN-len-1);
/* Check if it exists */
if (stat(buf, &statbuf) == -1 && errno == ENOENT) {
/* No - this is a reduced-headless-jre so use special HToolkit */
return "sun.awt.HToolkit";
}
else {
/* Yes - this is a headful JRE so fallback to SE defaults */
return NULL;
}
}
#endif
/* This function gets called very early, before VM_CALLS are setup. /* This function gets called very early, before VM_CALLS are setup.
* Do not use any of the VM_CALLS entries!!! * Do not use any of the VM_CALLS entries!!!
*/ */
...@@ -328,7 +363,12 @@ GetJavaProperties(JNIEnv *env) ...@@ -328,7 +363,12 @@ GetJavaProperties(JNIEnv *env)
/* Java 2D properties */ /* Java 2D properties */
sprops.graphics_env = "sun.awt.X11GraphicsEnvironment"; sprops.graphics_env = "sun.awt.X11GraphicsEnvironment";
sprops.awt_toolkit = NULL;
#ifdef JAVASE_EMBEDDED
sprops.awt_toolkit = getEmbeddedToolkit();
if (sprops.awt_toolkit == NULL) // default as below
#endif
sprops.awt_toolkit = "sun.awt.X11.XToolkit";
/* This is used only for debugging of font problems. */ /* This is used only for debugging of font problems. */
v = getenv("JAVA2D_FONTPATH"); v = getenv("JAVA2D_FONTPATH");
......
/* /*
* Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -33,6 +33,10 @@ ...@@ -33,6 +33,10 @@
*/ */
JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt) JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt)
{ {
#if defined(JAVASE_EMBEDDED) && defined(HEADLESS)
/* there are no AWT libs available at all */
return JNI_FALSE;
#else
if (awt == NULL) { if (awt == NULL) {
return JNI_FALSE; return JNI_FALSE;
} }
...@@ -51,4 +55,5 @@ JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt) ...@@ -51,4 +55,5 @@ JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt)
} }
return JNI_TRUE; return JNI_TRUE;
#endif
} }
/* /*
* Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -110,6 +110,21 @@ Java_sun_awt_X11_XToolkit_initIDs ...@@ -110,6 +110,21 @@ Java_sun_awt_X11_XToolkit_initIDs
awt_ModLockIsShiftLock = (*env)->GetStaticIntField(env, clazz, fid) != 0 ? True : False; awt_ModLockIsShiftLock = (*env)->GetStaticIntField(env, clazz, fid) != 0 ? True : False;
} }
/*
* Class: sun_awt_X11_XToolkit
* Method: getTrayIconDisplayTimeout
* Signature: ()J
*/
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XToolkit_getTrayIconDisplayTimeout
(JNIEnv *env, jclass clazz)
{
#ifndef JAVASE_EMBEDDED
return (jlong) 2000;
#else
return (jlong) 10000;
#endif
}
/* /*
* Class: sun_awt_X11_XToolkit * Class: sun_awt_X11_XToolkit
* Method: getDefaultXColormap * Method: getDefaultXColormap
...@@ -340,15 +355,34 @@ static uint32_t get_poll_timeout(jlong nextTaskTime); ...@@ -340,15 +355,34 @@ static uint32_t get_poll_timeout(jlong nextTaskTime);
#define AWT_READPIPE (awt_pipe_fds[0]) #define AWT_READPIPE (awt_pipe_fds[0])
#define AWT_WRITEPIPE (awt_pipe_fds[1]) #define AWT_WRITEPIPE (awt_pipe_fds[1])
#define DEF_AWT_MAX_POLL_TIMEOUT ((uint32_t)500) /* milliseconds */ #ifdef JAVASE_EMBEDDED
#define DEF_AWT_MAX_POLL_TIMEOUT ((uint32_t)4000000000) /* milliseconds */
#else
#define DEF_AWT_MAX_POLL_TIMEOUT ((uint32_t)500) /* milliseconds */
#endif
#define DEF_AWT_FLUSH_TIMEOUT ((uint32_t)100) /* milliseconds */ #define DEF_AWT_FLUSH_TIMEOUT ((uint32_t)100) /* milliseconds */
#define AWT_MIN_POLL_TIMEOUT ((uint32_t)0) /* milliseconds */ #define AWT_MIN_POLL_TIMEOUT ((uint32_t)0) /* milliseconds */
#define TIMEOUT_TIMEDOUT 0 #define TIMEOUT_TIMEDOUT 0
#define TIMEOUT_EVENTS 1 #define TIMEOUT_EVENTS 1
/* awt_poll_alg - AWT Poll Events Aging Algorithms */
#define AWT_POLL_FALSE 1
#define AWT_POLL_AGING_SLOW 2
#define AWT_POLL_AGING_FAST 3
#define AWT_POLL_THRESHOLD 1000 // msec, Block if delay is larger
#define AWT_POLL_BLOCK -1 // cause poll() block
// Static fields // Static fields
#ifdef JAVASE_EMBEDDED
static int awt_poll_alg = AWT_POLL_AGING_FAST;
#else
static int awt_poll_alg = AWT_POLL_AGING_SLOW;
#endif
static uint32_t AWT_FLUSH_TIMEOUT = DEF_AWT_FLUSH_TIMEOUT; /* milliseconds */ static uint32_t AWT_FLUSH_TIMEOUT = DEF_AWT_FLUSH_TIMEOUT; /* milliseconds */
static uint32_t AWT_MAX_POLL_TIMEOUT = DEF_AWT_MAX_POLL_TIMEOUT; /* milliseconds */ static uint32_t AWT_MAX_POLL_TIMEOUT = DEF_AWT_MAX_POLL_TIMEOUT; /* milliseconds */
static pthread_t awt_MainThread = 0; static pthread_t awt_MainThread = 0;
...@@ -417,6 +451,7 @@ awt_pipe_init() { ...@@ -417,6 +451,7 @@ awt_pipe_init() {
*/ */
static void readEnv() { static void readEnv() {
char * value; char * value;
int tmp_poll_alg;
static Boolean env_read = False; static Boolean env_read = False;
if (env_read) return; if (env_read) return;
...@@ -451,6 +486,23 @@ static void readEnv() { ...@@ -451,6 +486,23 @@ static void readEnv() {
if (static_poll_timeout != 0) { if (static_poll_timeout != 0) {
curPollTimeout = static_poll_timeout; curPollTimeout = static_poll_timeout;
} }
// non-blocking poll()
value = getenv("_AWT_POLL_ALG");
if (value != NULL) {
tmp_poll_alg = atoi(value);
switch(tmp_poll_alg) {
case AWT_POLL_FALSE:
case AWT_POLL_AGING_SLOW:
case AWT_POLL_AGING_FAST:
awt_poll_alg = tmp_poll_alg;
break;
default:
PRINT("Unknown value of _AWT_POLL_ALG, assuming Slow Aging Algorithm by default");
awt_poll_alg = AWT_POLL_AGING_SLOW;
break;
}
}
} }
/** /**
...@@ -478,14 +530,29 @@ static void update_poll_timeout(int timeout_control) { ...@@ -478,14 +530,29 @@ static void update_poll_timeout(int timeout_control) {
if (static_poll_timeout != 0) return; if (static_poll_timeout != 0) return;
// Update it otherwise // Update it otherwise
if (timeout_control == TIMEOUT_TIMEDOUT) {
/* add 1/4 (plus 1, in case the division truncates to 0) */ switch(awt_poll_alg) {
curPollTimeout += ((curPollTimeout>>2) + 1); case AWT_POLL_AGING_SLOW:
curPollTimeout = min(AWT_MAX_POLL_TIMEOUT, curPollTimeout); if (timeout_control == TIMEOUT_TIMEDOUT) {
} else if (timeout_control == TIMEOUT_EVENTS) { /* add 1/4 (plus 1, in case the division truncates to 0) */
/* subtract 1/4 (plus 1, in case the division truncates to 0) */ curPollTimeout += ((curPollTimeout>>2) + 1);
curPollTimeout -= ((curPollTimeout>>2) + 1); curPollTimeout = min(AWT_MAX_POLL_TIMEOUT, curPollTimeout);
curPollTimeout = max(AWT_MIN_POLL_TIMEOUT, curPollTimeout); } else if (timeout_control == TIMEOUT_EVENTS) {
/* subtract 1/4 (plus 1, in case the division truncates to 0) */
curPollTimeout -= ((curPollTimeout>>2) + 1);
curPollTimeout = max(AWT_MIN_POLL_TIMEOUT, curPollTimeout);
}
break;
case AWT_POLL_AGING_FAST:
if (timeout_control == TIMEOUT_TIMEDOUT) {
curPollTimeout += ((curPollTimeout>>2) + 1);
curPollTimeout = min(AWT_MAX_POLL_TIMEOUT, curPollTimeout);
if((int)curPollTimeout > AWT_POLL_THRESHOLD || (int)curPollTimeout == AWT_POLL_BLOCK)
curPollTimeout = AWT_POLL_BLOCK;
} else if (timeout_control == TIMEOUT_EVENTS) {
curPollTimeout = max(AWT_MIN_POLL_TIMEOUT, 1);
}
break;
} }
} }
...@@ -497,16 +564,37 @@ static void update_poll_timeout(int timeout_control) { ...@@ -497,16 +564,37 @@ static void update_poll_timeout(int timeout_control) {
*/ */
static uint32_t get_poll_timeout(jlong nextTaskTime) static uint32_t get_poll_timeout(jlong nextTaskTime)
{ {
uint32_t ret_timeout;
uint32_t timeout;
uint32_t taskTimeout;
uint32_t flushTimeout;
jlong curTime = awtJNI_TimeMillis(); jlong curTime = awtJNI_TimeMillis();
uint32_t timeout = curPollTimeout; timeout = curPollTimeout;
uint32_t taskTimeout = (nextTaskTime == -1) ? AWT_MAX_POLL_TIMEOUT : (uint32_t)max(0, (int32_t)(nextTaskTime - curTime)); switch(awt_poll_alg) {
uint32_t flushTimeout = (awt_next_flush_time > 0) ? (uint32_t)max(0, (int32_t)(awt_next_flush_time - curTime)) : AWT_MAX_POLL_TIMEOUT; case AWT_POLL_AGING_SLOW:
case AWT_POLL_AGING_FAST:
taskTimeout = (nextTaskTime == -1) ? AWT_MAX_POLL_TIMEOUT : (uint32_t)max(0, (int32_t)(nextTaskTime - curTime));
flushTimeout = (awt_next_flush_time > 0) ? (uint32_t)max(0, (int32_t)(awt_next_flush_time - curTime)) : AWT_MAX_POLL_TIMEOUT;
PRINT2("to: %d, ft: %d, to: %d, tt: %d, mil: %d\n", taskTimeout, flushTimeout, timeout, (int)nextTaskTime, (int)curTime);
// Adjust timeout to flush_time and task_time
ret_timeout = min(flushTimeout, min(taskTimeout, timeout));
if((int)curPollTimeout == AWT_POLL_BLOCK)
ret_timeout = AWT_POLL_BLOCK;
break;
case AWT_POLL_FALSE:
ret_timeout = (nextTaskTime > curTime) ?
(nextTaskTime - curTime) :
((nextTaskTime == -1) ? -1 : 0);
break;
}
PRINT2("to: %d, ft: %d, to: %d, tt: %d, mil: %d\n", taskTimeout, flushTimeout, timeout, (int)nextTaskTime, (int)curTime); return ret_timeout;
// Adjust timeout to flush_time and task_time } /* get_poll_timeout() */
return min(flushTimeout, min(taskTimeout, timeout));
} /* awt_get_poll_timeout() */
/* /*
* Waits for X/Xt events to appear on the pipe. Returns only when * Waits for X/Xt events to appear on the pipe. Returns only when
...@@ -598,6 +686,8 @@ performPoll(JNIEnv *env, jlong nextTaskTime) { ...@@ -598,6 +686,8 @@ performPoll(JNIEnv *env, jlong nextTaskTime) {
if (result == 0) { if (result == 0) {
/* poll() timed out -- update timeout value */ /* poll() timed out -- update timeout value */
update_poll_timeout(TIMEOUT_TIMEDOUT); update_poll_timeout(TIMEOUT_TIMEDOUT);
PRINT2("%s(): TIMEOUT_TIMEDOUT curPollTimeout = %d \n",
performPoll, curPollTimeout);
} }
if (pollFds[1].revents) { if (pollFds[1].revents) {
int count; int count;
...@@ -606,10 +696,14 @@ performPoll(JNIEnv *env, jlong nextTaskTime) { ...@@ -606,10 +696,14 @@ performPoll(JNIEnv *env, jlong nextTaskTime) {
do { do {
count = read(AWT_READPIPE, read_buf, AWT_POLL_BUFSIZE ); count = read(AWT_READPIPE, read_buf, AWT_POLL_BUFSIZE );
} while (count == AWT_POLL_BUFSIZE ); } while (count == AWT_POLL_BUFSIZE );
PRINT2("%s(): data on the AWT pipe: curPollTimeout = %d \n",
performPoll, curPollTimeout);
} }
if (pollFds[0].revents) { if (pollFds[0].revents) {
// Events in X pipe // Events in X pipe
update_poll_timeout(TIMEOUT_EVENTS); update_poll_timeout(TIMEOUT_EVENTS);
PRINT2("%s(): TIMEOUT_EVENTS curPollTimeout = %ld \n",
performPoll, curPollTimeout);
} }
return; return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册