提交 f4368654 编写于 作者: L lana

Merge

......@@ -153,7 +153,6 @@ FILES_cpp = \
awt_Menu.cpp \
awt_MenuBar.cpp \
awt_MenuItem.cpp \
awt_MMStub.cpp \
awt_MouseEvent.cpp \
awt_Object.cpp \
awt_Palette.cpp \
......@@ -171,7 +170,6 @@ FILES_cpp = \
awt_TextComponent.cpp \
awt_TextField.cpp \
awt_Toolkit.cpp \
awt_Unicode.cpp \
awt_Window.cpp \
awt_Win32GraphicsEnv.cpp \
awt_Win32GraphicsDevice.cpp \
......@@ -202,6 +200,4 @@ FILES_cpp = \
ThemeReader.cpp \
ComCtl32Util.cpp \
initIDs.cpp \
awt_dlls.cpp \
UnicowsLoader.cpp \
MouseInfo.cpp
......@@ -47,7 +47,7 @@ OTHER_CFLAGS += -D__MEDIALIB_OLD_NAMES -D__USE_J2D_NAMES
# sun/awt/resources handled by java/awt/Makefile
# sun/java2d/pisces handled by sun/pisces/Makefile
#
AUTO_FILES_JAVA_DIRS = sun/awt sun/java2d
AUTO_FILES_JAVA_DIRS = sun/awt sun/java2d com/sun/awt
AUTO_JAVA_PRUNE = resources pisces
ifeq ($(PLATFORM), windows)
......@@ -247,8 +247,14 @@ endif # PLATFORM
ifeq ($(PLATFORM), windows)
# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv WINDOWS
OTHER_LDLIBS = kernel32.lib user32.lib gdi32.lib winspool.lib \
imm32.lib ole32.lib uuid.lib $(JVMLIB) \
shell32.lib
imm32.lib ole32.lib uuid.lib shell32.lib \
comdlg32.lib winmm.lib comctl32.lib delayimp.lib \
$(JVMLIB) \
/DELAYLOAD:user32.dll /DELAYLOAD:gdi32.dll \
/DELAYLOAD:shell32.dll /DELAYLOAD:winmm.dll \
/DELAYLOAD:winspool.drv /DELAYLOAD:imm32.dll \
/DELAYLOAD:ole32.dll /DELAYLOAD:comdlg32.dll \
/DELAYLOAD:comctl32.dll
clean:: awt.clean
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
$(OBJDIR)/jawt.obj:: $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_AWTEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Component.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Dimension.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Event.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Font.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_FocusEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_KeyEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_MouseEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_WindowEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_FontDescriptor.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_PlatformFont.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WComponentPeer.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WFontMetrics.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WObjectPeer.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WToolkit.h ../../../src/share/javavm/export/jawt.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/awt/image/cvutils/img_globals.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jawt_md.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.h ../../../src/windows/native/sun/windows/Devices.h ../../../src/windows/native/sun/windows/GDIHashtable.h ../../../src/windows/native/sun/windows/Hashtable.h ../../../src/windows/native/sun/windows/ObjectList.h ../../../src/windows/native/sun/windows/UnicowsLoader.h ../../../src/windows/native/sun/windows/alloc.h ../../../src/windows/native/sun/windows/awt.h ../../../src/windows/native/sun/windows/awt_Brush.h ../../../src/windows/native/sun/windows/awt_Component.h ../../../src/windows/native/sun/windows/awt_Debug.h ../../../src/windows/native/sun/windows/awt_DrawingSurface.h ../../../src/windows/native/sun/windows/awt_Font.h ../../../src/windows/native/sun/windows/awt_GDIObject.h ../../../src/windows/native/sun/windows/awt_MMStub.h ../../../src/windows/native/sun/windows/awt_Multimon.h ../../../src/windows/native/sun/windows/awt_Object.h ../../../src/windows/native/sun/windows/awt_Palette.h ../../../src/windows/native/sun/windows/awt_Pen.h ../../../src/windows/native/sun/windows/awt_Toolkit.h ../../../src/windows/native/sun/windows/awt_Unicode.h ../../../src/windows/native/sun/windows/awt_Win32GraphicsDevice.h ../../../src/windows/native/sun/windows/awtmsg.h ../../../src/windows/native/sun/windows/colordata.h ../../../src/windows/native/sun/windows/stdhdrs.h
$(OBJDIR)/jawt.obj:: $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_AWTEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Component.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Dimension.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Event.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Font.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_FocusEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_KeyEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_MouseEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_WindowEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_FontDescriptor.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_PlatformFont.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WComponentPeer.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WFontMetrics.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WObjectPeer.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WToolkit.h ../../../src/share/javavm/export/jawt.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/awt/image/cvutils/img_globals.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jawt_md.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.h ../../../src/windows/native/sun/windows/Devices.h ../../../src/windows/native/sun/windows/GDIHashtable.h ../../../src/windows/native/sun/windows/Hashtable.h ../../../src/windows/native/sun/windows/ObjectList.h ../../../src/windows/native/sun/windows/alloc.h ../../../src/windows/native/sun/windows/awt.h ../../../src/windows/native/sun/windows/awt_Brush.h ../../../src/windows/native/sun/windows/awt_Component.h ../../../src/windows/native/sun/windows/awt_Debug.h ../../../src/windows/native/sun/windows/awt_DrawingSurface.h ../../../src/windows/native/sun/windows/awt_Font.h ../../../src/windows/native/sun/windows/awt_GDIObject.h ../../../src/windows/native/sun/windows/awt_Object.h ../../../src/windows/native/sun/windows/awt_Palette.h ../../../src/windows/native/sun/windows/awt_Pen.h ../../../src/windows/native/sun/windows/awt_Toolkit.h ../../../src/windows/native/sun/windows/awt_Win32GraphicsDevice.h ../../../src/windows/native/sun/windows/awtmsg.h ../../../src/windows/native/sun/windows/colordata.h ../../../src/windows/native/sun/windows/stdhdrs.h
......@@ -67,7 +67,7 @@ ifneq ($(PLATFORM), windows)
OTHER_LDLIBS += -L$(OPENWIN_LIB) -lX11 -lXext $(LIBM) -lpthread
else # PLATFORM
CFLAGS += -DWITH_WIN32
OTHER_LDLIBS += kernel32.lib user32.lib gdi32.lib
OTHER_LDLIBS += kernel32.lib user32.lib gdi32.lib delayimp.lib /DELAYLOAD:user32.dll
#$(JVMLIB) $(OBJDIR)/../../jpeg/$(OBJDIRNAME)/jpeg$(SUFFIX).lib
endif # PLATFORM
......@@ -85,13 +85,6 @@ vpath %.c $(PLATFORM_SRC)/native/$(PKGDIR)/splashscreen
CPPFLAGS += -I$(PLATFORM_SRC)/native/$(PKGDIR)/splashscreen -I$(SHARE_SRC)/native/$(PKGDIR)/splashscreen
CPPFLAGS += -I$(SHARE_SRC)/native/$(PKGDIR)/image/jpeg -I$(SHARE_SRC)/native/java/util/zip/zlib-1.1.3
ifeq ($(PLATFORM), linux)
ifeq ($(ARCH_DATA_MODEL), 64)
# 64-bit gcc has problems compiling MMX instructions.
# Google it for more details. Possibly the newer versions of
# the PNG-library and/or the new compiler will not need this
# option in the future.
CPPFLAGS += -DPNG_NO_MMX_CODE
endif
endif
# Shun the less than portable MMX assembly code in pnggccrd.c,
# and use alternative implementations in C.
CPPFLAGS += -DPNG_NO_MMX_CODE
......@@ -151,6 +151,7 @@ SUNWprivate_1.1 {
Java_sun_awt_X11_XRobotPeer_mouseReleaseImpl;
Java_sun_awt_X11_XRobotPeer_mouseWheelImpl;
Java_sun_awt_X11_XRobotPeer_setup;
Java_sun_awt_X11_XRobotPeer_getNumberOfButtonsImpl;
Java_java_awt_Component_initIDs;
Java_java_awt_Container_initIDs;
Java_java_awt_Button_initIDs;
......@@ -288,6 +289,7 @@ SUNWprivate_1.1 {
Java_sun_awt_X11_XlibWrapper_XGetIconSizes;
Java_sun_awt_X11_XlibWrapper_XKeycodeToKeysym;
Java_sun_awt_X11_XlibWrapper_XKeysymToKeycode;
Java_sun_awt_X11_XlibWrapper_XQueryKeymap;
Java_sun_awt_X11_XlibWrapper_XGetModifierMapping;
Java_sun_awt_X11_XlibWrapper_XFreeModifiermap;
Java_sun_awt_X11_XlibWrapper_XChangeActivePointerGrab;
......
......@@ -1718,6 +1718,7 @@ javax/swing/plaf/basic/BasicToolBarSeparatorUI
sun/awt/color/CMM
java/applet/Applet
java/awt/Panel
com/sun/awt/AWTUtilities
javax/swing/KeyboardManager$ComponentKeyStrokePair
sun/awt/EmbeddedFrame
sun/awt/im/InputMethodContext
......
......@@ -961,6 +961,7 @@ sun/awt/SunToolkit$3
javax/swing/SystemEventQueueUtilities$ComponentWorkRequest
java/applet/Applet
java/awt/Panel
com/sun/awt/AWTUtilities
sun/awt/X11/XExposeEvent
java/util/jar/Manifest
java/io/ByteArrayInputStream
......
......@@ -1621,6 +1621,7 @@ javax/swing/plaf/basic/BasicToolBarSeparatorUI
sun/font/FontDesignMetrics$MetricsKey
java/applet/Applet
java/awt/Panel
com/sun/awt/AWTUtilities
javax/swing/KeyboardManager$ComponentKeyStrokePair
sun/awt/im/InputMethodContext
java/awt/im/spi/InputMethodContext
......
/*
* Copyright 2009 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package com.sun.awt;
import java.awt.*;
import sun.awt.AWTAccessor;
/**
* A collection of utility methods for AWT.
*
* The functionality provided by the static methods of the class includes:
* <ul>
* <li>Setting a 'mixing-cutout' shape for a component.
* </ul>
* <p>
* <b>WARNING</b>: This class is an implementation detail and only meant
* for limited use outside of the core platform. This API may change
* drastically between update release, and it may even be
* removed or be moved in some other package(s)/class(es).
*/
public final class AWTUtilities {
/**
* The AWTUtilities class should not be instantiated
*/
private AWTUtilities() {
}
/**
* Sets a 'mixing-cutout' shape for the given component.
*
* By default a lightweight component is treated as an opaque rectangle for
* the purposes of the Heavyweight/Lightweight Components Mixing feature.
* This method enables developers to set an arbitrary shape to be cut out
* from heavyweight components positioned underneath the lightweight
* component in the z-order.
* <p>
* The {@code shape} argument may have the following values:
* <ul>
* <li>{@code null} - reverts the default cutout shape (the rectangle equal
* to the component's {@code getBounds()})
* <li><i>empty-shape</i> - does not cut out anything from heavyweight
* components. This makes the given lightweight component effectively
* transparent. Note that descendants of the lightweight component still
* affect the shapes of heavyweight components. An example of an
* <i>empty-shape</i> is {@code new Rectangle()}.
* <li><i>non-empty-shape</i> - the given shape will be cut out from
* heavyweight components.
* </ul>
* <p>
* The most common example when the 'mixing-cutout' shape is needed is a
* glass pane component. The {@link JRootPane#setGlassPane()} method
* automatically sets the <i>empty-shape</i> as the 'mixing-cutout' shape
* for the given glass pane component. If a developer needs some other
* 'mixing-cutout' shape for the glass pane (which is rare), this must be
* changed manually after installing the glass pane to the root pane.
* <p>
* Note that the 'mixing-cutout' shape neither affects painting, nor the
* mouse events handling for the given component. It is used exclusively
* for the purposes of the Heavyweight/Lightweight Components Mixing
* feature.
*
* @param component the component that needs non-default
* 'mixing-cutout' shape
* @param shape the new 'mixing-cutout' shape
* @throws NullPointerException if the component argument is {@code null}
*/
public static void setComponentMixingCutoutShape(Component component,
Shape shape)
{
if (component == null) {
throw new NullPointerException(
"The component argument should not be null.");
}
AWTAccessor.getComponentAccessor().setMixingCutoutShape(component,
shape);
}
}
......@@ -228,7 +228,7 @@ public class Choice extends Component implements ItemSelectable, Accessible {
pItems.insertElementAt(item, index);
ChoicePeer peer = (ChoicePeer)this.peer;
if (peer != null) {
peer.addItem(item, index);
peer.add(item, index);
}
// no selection or selection shifted up
if (selectedIndex < 0 || selectedIndex >= index) {
......
......@@ -343,7 +343,7 @@ public class Container extends Component {
ComponentPeer peer = this.peer;
if (peer instanceof ContainerPeer) {
ContainerPeer cpeer = (ContainerPeer)peer;
return (Insets)cpeer.insets().clone();
return (Insets)cpeer.getInsets().clone();
}
return new Insets(0, 0, 0, 0);
}
......@@ -569,7 +569,7 @@ public class Container extends Component {
* @return true if there is at least one heavyweight children in a container, false otherwise
* @since 1.5
*/
private boolean hasHeavyweightDescendants() {
final boolean hasHeavyweightDescendants() {
checkTreeLock();
return numOfHWComponents > 0;
}
......@@ -580,7 +580,7 @@ public class Container extends Component {
* @return true if there is at least one lightweight children in a container, false otherwise
* @since 1.7
*/
private boolean hasLightweightDescendants() {
final boolean hasLightweightDescendants() {
checkTreeLock();
return numOfLWComponents > 0;
}
......@@ -3861,6 +3861,28 @@ public class Container extends Component {
return -1;
}
/*
* This method is overriden to handle opaque children in non-opaque
* containers.
*/
@Override
final Region getOpaqueShape() {
checkTreeLock();
if (isLightweight() && isNonOpaqueForMixing()
&& hasLightweightDescendants())
{
Region s = Region.EMPTY_REGION;
for (int index = 0; index < getComponentCount(); index++) {
Component c = getComponent(index);
if (c.isLightweight() && c.isShowing()) {
s = s.getUnion(c.getOpaqueShape());
}
}
return s.getIntersection(getNormalShape());
}
return super.getOpaqueShape();
}
final void recursiveSubtractAndApplyShape(Region shape) {
recursiveSubtractAndApplyShape(shape, getTopmostComponentIndex(), getBottommostComponentIndex());
}
......@@ -3878,6 +3900,15 @@ public class Container extends Component {
if (fromZorder == -1) {
return;
}
if (shape.isEmpty()) {
return;
}
// An invalid container with not-null layout should be ignored
// by the mixing code, the container will be validated later
// and the mixing code will be executed later.
if (getLayout() != null && !isValid()) {
return;
}
for (int index = fromZorder; index <= toZorder; index++) {
Component comp = getComponent(index);
if (!comp.isLightweight()) {
......@@ -3906,10 +3937,19 @@ public class Container extends Component {
if (fromZorder == -1) {
return;
}
// An invalid container with not-null layout should be ignored
// by the mixing code, the container will be validated later
// and the mixing code will be executed later.
if (getLayout() != null && !isValid()) {
return;
}
for (int index = fromZorder; index <= toZorder; index++) {
Component comp = getComponent(index);
if (!comp.isLightweight()) {
comp.applyCurrentShape();
if (comp instanceof Container && ((Container)comp).getLayout() == null) {
((Container)comp).recursiveApplyCurrentShape();
}
} else if (comp instanceof Container &&
((Container)comp).hasHeavyweightDescendants()) {
((Container)comp).recursiveApplyCurrentShape();
......@@ -3931,7 +3971,7 @@ public class Container extends Component {
if (comp.isVisible()) {
ComponentPeer peer = comp.getPeer();
if (peer != null) {
peer.show();
peer.setVisible(true);
}
}
}
......@@ -3952,7 +3992,7 @@ public class Container extends Component {
if (comp.isVisible()) {
ComponentPeer peer = comp.getPeer();
if (peer != null) {
peer.hide();
peer.setVisible(false);
}
}
}
......@@ -4000,6 +4040,10 @@ public class Container extends Component {
mixingLog.fine("this = " + this);
}
if (!isMixingNeeded()) {
return;
}
boolean isLightweight = isLightweight();
if (isLightweight && isRecursivelyVisibleUpToHeavyweightContainer()) {
......@@ -4034,6 +4078,9 @@ public class Container extends Component {
if (mixingLog.isLoggable(Level.FINE)) {
mixingLog.fine("this = " + this);
}
boolean isMixingNeeded = isMixingNeeded();
if (isLightweight() && hasHeavyweightDescendants()) {
final Point origin = new Point(getX(), getY());
for (Container cont = getContainer();
......@@ -4044,7 +4091,18 @@ public class Container extends Component {
}
recursiveRelocateHeavyweightChildren(origin);
if (!isMixingNeeded) {
return;
}
recursiveApplyCurrentShape();
}
if (!isMixingNeeded) {
return;
}
super.mixOnReshaping();
}
}
......@@ -4057,6 +4115,10 @@ public class Container extends Component {
"; oldZ=" + oldZorder + "; newZ=" + newZorder);
}
if (!isMixingNeeded()) {
return;
}
boolean becameHigher = newZorder < oldZorder;
if (becameHigher && isLightweight() && hasHeavyweightDescendants()) {
......@@ -4073,10 +4135,18 @@ public class Container extends Component {
mixingLog.fine("this = " + this);
}
if (!isMixingNeeded()) {
return;
}
if (hasHeavyweightDescendants()) {
recursiveApplyCurrentShape();
}
if (isLightweight() && isNonOpaqueForMixing()) {
subtractAndApplyShapeBelowMe();
}
super.mixOnValidating();
}
}
......
......@@ -941,7 +941,7 @@ public class Dialog extends Window {
// does not invoke the super.show(). So wried... :(
mixOnShowing();
peer.show(); // now guaranteed never to block
peer.setVisible(true); // now guaranteed never to block
if (isModalBlocked()) {
modalBlocker.toFront();
}
......
......@@ -300,119 +300,19 @@ class EventDispatchThread extends Thread {
}
// Can get and throw only unchecked exceptions
catch (RuntimeException e) {
processException(e, modalFiltersCount > 0);
processException(e);
} catch (Error e) {
processException(e, modalFiltersCount > 0);
processException(e);
}
return true;
}
private void processException(Throwable e, boolean isModal) {
private void processException(Throwable e) {
if (eventLog.isLoggable(Level.FINE)) {
eventLog.log(Level.FINE, "Processing exception: " + e +
", isModal = " + isModal);
eventLog.log(Level.FINE, "Processing exception: " + e);
}
if (!handleException(e)) {
// See bug ID 4499199.
// If we are in a modal dialog, we cannot throw
// an exception for the ThreadGroup to handle (as added
// in RFE 4063022). If we did, the message pump of
// the modal dialog would be interrupted.
// We instead choose to handle the exception ourselves.
// It may be useful to add either a runtime flag or API
// later if someone would like to instead dispose the
// dialog and allow the thread group to handle it.
if (isModal) {
System.err.println(
"Exception occurred during event dispatching:");
e.printStackTrace();
} else if (e instanceof RuntimeException) {
throw (RuntimeException)e;
} else if (e instanceof Error) {
throw (Error)e;
}
}
}
private static final String handlerPropName = "sun.awt.exception.handler";
private static String handlerClassName = null;
private static String NO_HANDLER = new String();
/**
* Handles an exception thrown in the event-dispatch thread.
*
* <p> If the system property "sun.awt.exception.handler" is defined, then
* when this method is invoked it will attempt to do the following:
*
* <ol>
* <li> Load the class named by the value of that property, using the
* current thread's context class loader,
* <li> Instantiate that class using its zero-argument constructor,
* <li> Find the resulting handler object's <tt>public void handle</tt>
* method, which should take a single argument of type
* <tt>Throwable</tt>, and
* <li> Invoke the handler's <tt>handle</tt> method, passing it the
* <tt>thrown</tt> argument that was passed to this method.
* </ol>
*
* If any of the first three steps fail then this method will return
* <tt>false</tt> and all following invocations of this method will return
* <tt>false</tt> immediately. An exception thrown by the handler object's
* <tt>handle</tt> will be caught, and will cause this method to return
* <tt>false</tt>. If the handler's <tt>handle</tt> method is successfully
* invoked, then this method will return <tt>true</tt>. This method will
* never throw any sort of exception.
*
* <p> <i>Note:</i> This method is a temporary hack to work around the
* absence of a real API that provides the ability to replace the
* event-dispatch thread. The magic "sun.awt.exception.handler" property
* <i>will be removed</i> in a future release.
*
* @param thrown The Throwable that was thrown in the event-dispatch
* thread
*
* @return <tt>false</tt> if any of the above steps failed, otherwise
* <tt>true</tt>
*/
private boolean handleException(Throwable thrown) {
try {
if (handlerClassName == NO_HANDLER) {
return false; /* Already tried, and failed */
}
/* Look up the class name */
if (handlerClassName == null) {
handlerClassName = ((String) AccessController.doPrivileged(
new GetPropertyAction(handlerPropName)));
if (handlerClassName == null) {
handlerClassName = NO_HANDLER; /* Do not try this again */
return false;
}
}
/* Load the class, instantiate it, and find its handle method */
Method m;
Object h;
try {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
Class c = Class.forName(handlerClassName, true, cl);
m = c.getMethod("handle", new Class[] { Throwable.class });
h = c.newInstance();
} catch (Throwable x) {
handlerClassName = NO_HANDLER; /* Do not try this again */
return false;
}
/* Finally, invoke the handler */
m.invoke(h, new Object[] { thrown });
} catch (Throwable x) {
return false;
}
return true;
getUncaughtExceptionHandler().uncaughtException(this, e);
// don't rethrow the exception to avoid EDT recreation
}
boolean isDispatching(EventQueue eq) {
......
......@@ -378,7 +378,7 @@ public class List extends Component implements ItemSelectable, Accessible {
ListPeer peer = (ListPeer)this.peer;
if (peer != null) {
peer.addItem(item, index);
peer.add(item, index);
}
}
......@@ -413,7 +413,7 @@ public class List extends Component implements ItemSelectable, Accessible {
public synchronized void clear() {
ListPeer peer = (ListPeer)this.peer;
if (peer != null) {
peer.clear();
peer.removeAll();
}
items = new Vector();
selected = new int[0];
......@@ -718,7 +718,7 @@ public class List extends Component implements ItemSelectable, Accessible {
multipleMode = b;
ListPeer peer = (ListPeer)this.peer;
if (peer != null) {
peer.setMultipleSelections(b);
peer.setMultipleMode(b);
}
}
}
......@@ -768,7 +768,7 @@ public class List extends Component implements ItemSelectable, Accessible {
synchronized (getTreeLock()) {
ListPeer peer = (ListPeer)this.peer;
return (peer != null) ?
peer.preferredSize(rows) :
peer.getPreferredSize(rows) :
super.preferredSize();
}
}
......@@ -818,7 +818,7 @@ public class List extends Component implements ItemSelectable, Accessible {
synchronized (getTreeLock()) {
ListPeer peer = (ListPeer)this.peer;
return (peer != null) ?
peer.minimumSize(rows) :
peer.getMinimumSize(rows) :
super.minimumSize();
}
}
......
......@@ -268,7 +268,7 @@ public class MenuItem extends MenuComponent implements Accessible {
enabled = true;
MenuItemPeer peer = (MenuItemPeer)this.peer;
if (peer != null) {
peer.enable();
peer.setEnabled(true);
}
}
......@@ -294,7 +294,7 @@ public class MenuItem extends MenuComponent implements Accessible {
enabled = false;
MenuItemPeer peer = (MenuItemPeer)this.peer;
if (peer != null) {
peer.disable();
peer.setEnabled(false);
}
}
......
......@@ -70,10 +70,7 @@ public class Robot {
private RobotPeer peer;
private boolean isAutoWaitForIdle = false;
private int autoDelay = 0;
private static final int LEGAL_BUTTON_MASK =
InputEvent.BUTTON1_MASK|
InputEvent.BUTTON2_MASK|
InputEvent.BUTTON3_MASK;
private static int LEGAL_BUTTON_MASK;
// location of robot's GC, used in mouseMove(), getPixelColor() and captureScreenImage()
private Point gdLoc;
......@@ -98,6 +95,19 @@ public class Robot {
}
init(GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice());
int tmpMask = 0;
if (Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){
for (int i = 0; i < peer.getNumberOfButtons(); i++){
tmpMask |= InputEvent.getMaskForButton(i+1);
}
}
tmpMask |= InputEvent.BUTTON1_MASK|
InputEvent.BUTTON2_MASK|
InputEvent.BUTTON3_MASK|
InputEvent.BUTTON1_DOWN_MASK|
InputEvent.BUTTON2_DOWN_MASK|
InputEvent.BUTTON3_DOWN_MASK;
LEGAL_BUTTON_MASK = tmpMask;
}
/**
......@@ -187,18 +197,55 @@ public class Robot {
/**
* Presses one or more mouse buttons. The mouse buttons should
* be released using the <code>mouseRelease</code> method.
* be released using the {@link #mouseRelease(int)} method.
*
* @param buttons the Button mask; a combination of one or more
* mouse button masks.
* <p>
* It is allowed to use only a combination of valid values as a {@code buttons} parameter.
* A valid combination consists of {@code InputEvent.BUTTON1_DOWN_MASK},
* {@code InputEvent.BUTTON2_DOWN_MASK}, {@code InputEvent.BUTTON3_DOWN_MASK}
* and values returned by the
* {@link InputEvent#getMaskForButton(int) InputEvent.getMaskForButton(button)} method.
*
* @param buttons the Button mask; a combination of one or more
* of these flags:
* The valid combination also depends on a
* {@link Toolkit#areExtraMouseButtonsEnabled() Toolkit.areExtraMouseButtonsEnabled()} value as follows:
* <ul>
* <li> If support for extended mouse buttons is
* {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
* then it is allowed to use only the following standard button masks:
* {@code InputEvent.BUTTON1_DOWN_MASK}, {@code InputEvent.BUTTON2_DOWN_MASK},
* {@code InputEvent.BUTTON3_DOWN_MASK}.
* <li> If support for extended mouse buttons is
* {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java
* then it is allowed to use the standard button masks
* and masks for existing extended mouse buttons, if the mouse has more then three buttons.
* In that way, it is allowed to use the button masks corresponding to the buttons
* in the range from 1 to {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}.
* <br>
* It is recommended to use the {@link InputEvent#getMaskForButton(int) InputEvent.getMaskForButton(button)}
* method to obtain the mask for any mouse button by its number.
* </ul>
* <p>
* The following standard button masks are also accepted:
* <ul>
* <li><code>InputEvent.BUTTON1_MASK</code>
* <li><code>InputEvent.BUTTON2_MASK</code>
* <li><code>InputEvent.BUTTON3_MASK</code>
* <li>{@code InputEvent.BUTTON1_MASK}
* <li>{@code InputEvent.BUTTON2_MASK}
* <li>{@code InputEvent.BUTTON3_MASK}
* </ul>
* @throws IllegalArgumentException if the button mask is not a
* valid combination
* However, it is recommended to use {@code InputEvent.BUTTON1_DOWN_MASK},
* {@code InputEvent.BUTTON2_DOWN_MASK}, {@code InputEvent.BUTTON3_DOWN_MASK} instead.
* Either extended {@code _DOWN_MASK} or old {@code _MASK} values
* should be used, but both those models should not be mixed.
* @throws IllegalArgumentException if the {@code buttons} mask contains the mask for extra mouse button
* and support for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
* @throws IllegalArgumentException if the {@code buttons} mask contains the mask for extra mouse button
* that does not exist on the mouse and support for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java
* @see #mouseRelease(int)
* @see InputEvent#getMaskForButton(int)
* @see Toolkit#areExtraMouseButtonsEnabled()
* @see java.awt.MouseInfo#getNumberOfButtons()
* @see java.awt.event.MouseEvent
*/
public synchronized void mousePress(int buttons) {
checkButtonsArgument(buttons);
......@@ -209,16 +256,53 @@ public class Robot {
/**
* Releases one or more mouse buttons.
*
* @param buttons the Button mask; a combination of one or more
* of these flags:
* @param buttons the Button mask; a combination of one or more
* mouse button masks.
* <p>
* It is allowed to use only a combination of valid values as a {@code buttons} parameter.
* A valid combination consists of {@code InputEvent.BUTTON1_DOWN_MASK},
* {@code InputEvent.BUTTON2_DOWN_MASK}, {@code InputEvent.BUTTON3_DOWN_MASK}
* and values returned by the
* {@link InputEvent#getMaskForButton(int) InputEvent.getMaskForButton(button)} method.
*
* The valid combination also depends on a
* {@link Toolkit#areExtraMouseButtonsEnabled() Toolkit.areExtraMouseButtonsEnabled()} value as follows:
* <ul>
* <li> If the support for extended mouse buttons is
* {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
* then it is allowed to use only the following standard button masks:
* {@code InputEvent.BUTTON1_DOWN_MASK}, {@code InputEvent.BUTTON2_DOWN_MASK},
* {@code InputEvent.BUTTON3_DOWN_MASK}.
* <li> If the support for extended mouse buttons is
* {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java
* then it is allowed to use the standard button masks
* and masks for existing extended mouse buttons, if the mouse has more then three buttons.
* In that way, it is allowed to use the button masks corresponding to the buttons
* in the range from 1 to {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}.
* <br>
* It is recommended to use the {@link InputEvent#getMaskForButton(int) InputEvent.getMaskForButton(button)}
* method to obtain the mask for any mouse button by its number.
* </ul>
* <p>
* The following standard button masks are also accepted:
* <ul>
* <li><code>InputEvent.BUTTON1_MASK</code>
* <li><code>InputEvent.BUTTON2_MASK</code>
* <li><code>InputEvent.BUTTON3_MASK</code>
* <li>{@code InputEvent.BUTTON1_MASK}
* <li>{@code InputEvent.BUTTON2_MASK}
* <li>{@code InputEvent.BUTTON3_MASK}
* </ul>
* However, it is recommended to use {@code InputEvent.BUTTON1_DOWN_MASK},
* {@code InputEvent.BUTTON2_DOWN_MASK}, {@code InputEvent.BUTTON3_DOWN_MASK} instead.
* Either extended {@code _DOWN_MASK} or old {@code _MASK} values
* should be used, but both those models should not be mixed.
* @throws IllegalArgumentException if the {@code buttons} mask contains the mask for extra mouse button
* and support for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
* @throws IllegalArgumentException if the {@code buttons} mask contains the mask for extra mouse button
* that does not exist on the mouse and support for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java
* @see #mousePress(int)
* @throws IllegalArgumentException if the button mask is not a valid
* combination
* @see InputEvent#getMaskForButton(int)
* @see Toolkit#areExtraMouseButtonsEnabled()
* @see java.awt.MouseInfo#getNumberOfButtons()
* @see java.awt.event.MouseEvent
*/
public synchronized void mouseRelease(int buttons) {
checkButtonsArgument(buttons);
......
......@@ -321,7 +321,7 @@ public class TextArea extends TextComponent {
public synchronized void insertText(String str, int pos) {
TextAreaPeer peer = (TextAreaPeer)this.peer;
if (peer != null) {
peer.insertText(str, pos);
peer.insert(str, pos);
} else {
text = text.substring(0, pos) + str + text.substring(pos);
}
......@@ -385,7 +385,7 @@ public class TextArea extends TextComponent {
public synchronized void replaceText(String str, int start, int end) {
TextAreaPeer peer = (TextAreaPeer)this.peer;
if (peer != null) {
peer.replaceText(str, start, end);
peer.replaceRange(str, start, end);
} else {
text = text.substring(0, start) + str + text.substring(end);
}
......@@ -500,7 +500,7 @@ public class TextArea extends TextComponent {
synchronized (getTreeLock()) {
TextAreaPeer peer = (TextAreaPeer)this.peer;
return (peer != null) ?
peer.preferredSize(rows, columns) :
peer.getPreferredSize(rows, columns) :
super.preferredSize();
}
}
......@@ -552,7 +552,7 @@ public class TextArea extends TextComponent {
synchronized (getTreeLock()) {
TextAreaPeer peer = (TextAreaPeer)this.peer;
return (peer != null) ?
peer.minimumSize(rows, columns) :
peer.getMinimumSize(rows, columns) :
super.minimumSize();
}
}
......
......@@ -281,7 +281,7 @@ public class TextField extends TextComponent {
echoChar = c;
TextFieldPeer peer = (TextFieldPeer)this.peer;
if (peer != null) {
peer.setEchoCharacter(c);
peer.setEchoChar(c);
}
}
}
......@@ -376,7 +376,7 @@ public class TextField extends TextComponent {
synchronized (getTreeLock()) {
TextFieldPeer peer = (TextFieldPeer)this.peer;
return (peer != null) ?
peer.preferredSize(columns) :
peer.getPreferredSize(columns) :
super.preferredSize();
}
}
......@@ -424,7 +424,7 @@ public class TextField extends TextComponent {
synchronized (getTreeLock()) {
TextFieldPeer peer = (TextFieldPeer)this.peer;
return (peer != null) ?
peer.minimumSize(columns) :
peer.getMinimumSize(columns) :
super.minimumSize();
}
}
......
/*
* Copyright 1995-2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1995-2008 Sun Microsystems, Inc. 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
......@@ -2550,4 +2550,37 @@ public abstract class Toolkit {
}
}
}
/**
* Reports whether events from extra mouse buttons are allowed to be processed and posted into
* {@code EventQueue}.
* <br>
* To change the returned value it is necessary to set the {@code sun.awt.enableExtraMouseButtons}
* property before the {@code Toolkit} class initialization. This setting could be done on the application
* startup by the following command:
* <pre>
* java -Dsun.awt.enableExtraMouseButtons=false Application
* </pre>
* Alternatively, the property could be set in the application by using the following code:
* <pre>
* System.setProperty("sun.awt.enableExtraMouseButtons", "true");
* </pre>
* before the {@code Toolkit} class initialization.
* If not set by the time of the {@code Toolkit} class initialization, this property will be
* initialized with {@code true}.
* Changing this value after the {@code Toolkit} class initialization will have no effect.
* <p>
* The current value could be queried by using the
* {@code System.getProperty("sun.awt.enableExtraMouseButtons")} method.
* @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true
* @return {@code true} if events from extra mouse buttons are allowed to be processed and posted;
* {@code false} otherwise
* @see System#getProperty(String propertyName)
* @see System#setProperty(String propertyName, String value)
* @see java.awt.EventQueue
* @since 1.7
*/
public boolean areExtraMouseButtonsEnabled() throws HeadlessException {
return Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled();
}
}
......@@ -53,6 +53,7 @@ import sun.awt.AppContext;
import sun.awt.CausedFocusEvent;
import sun.awt.SunToolkit;
import sun.awt.util.IdentityArrayList;
import sun.java2d.Disposer;
import sun.java2d.pipe.Region;
import sun.security.action.GetPropertyAction;
import sun.security.util.SecurityConstants;
......@@ -409,8 +410,6 @@ public class Window extends Container implements Accessible {
}
modalExclusionType = Dialog.ModalExclusionType.NO_EXCLUDE;
sun.java2d.Disposer.addRecord(anchor, new WindowDisposerRecord(appContext, this));
}
/**
......@@ -540,6 +539,10 @@ public class Window extends Container implements Accessible {
if (owner != null) {
owner.addOwnedWindow(weakThis);
}
// Fix for 6758673: this call is moved here from init(gc), because
// WindowDisposerRecord requires a proper value of parent field.
Disposer.addRecord(anchor, new WindowDisposerRecord(appContext, this));
}
/**
......
<!--
Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
Copyright 2005-2008 Sun Microsystems, Inc. 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
......@@ -64,6 +64,11 @@ here, and their value types.
<td valign="TOP"><a href="../../util/Map.html">java.util.Map<a/></td>
<td valign="TOP">Font smoothing (text antialiasing) settings.<a/></td>
</tr>
<tr>
<td valign="TOP"><A href=#"sun.awt.enableExtraMouseButtons">sun.awt.enableExtraMouseButtons</A</td>
<td valign="TOP"><a href="../../lang/Boolean.html">java.lang.Boolean<a/></td>
<td valign="TOP">Controls if mouse events from extra buttons are to be generated or not<a/></td>
</tr>
</table>
<p>
<h2>Desktop Font Rendering Hints</h2>
......@@ -219,5 +224,50 @@ So to determine if there are per-device settings it is sufficient to
determine that there is a non-null return for any screen device using
the per-device property name.
</ul>
<h2>Mouse Functionality</h2>
<b>Desktop Property: <A name="sun.awt.enableExtraMouseButtons">"sun.awt.enableExtraMouseButtons"</A></b>
<p>
This property determines if events from extra mouse buttons (if they are exist and are
enabled by the underlying operating system) are allowed to be processed and posted into
{@code EventQueue}.
<br>
The value could be changed by passing "sun.awt.enableExtraMouseButtons"
property value into java before application starts. This could be done with the following command:
<pre>
java -Dsun.awt.enableExtraMouseButtons=false Application
</pre>
Once set on application startup, it is impossible to change this value after.
<br>
Current value could also be queried using getDesktopProperty("sun.awt.enableExtraMouseButtons")
method.
<br>
If the property is set to {@code true} then
<ul>
<li> it is still legal to create {@code MouseEvent} objects with
standard buttons and, if the mouse has more
then three buttons, it is also legal to use buttons from the range started
from 0 up to {@link java.awt.MouseInfo#getNumberOfButtons() getNumberOfButtons()}.
<li> it is legal to use standard button masks when using {@code Robot.mousePress()}
and {@code Robot.mouseRelease()} methods and, if the mouse has more then three buttons,
it is also legal to use masks for existing extended mouse buttons.
That way, if there are more then three buttons on the mouse then it is allowed to
use button masks corresponding to the buttons
in the range from 1 up to {@link java.awt.MouseInfo#getNumberOfButtons() getNumberOfButtons()}
</ul>
<br>
If the property is set to {@code false} then
<ul>
<li> it is legal to create {@code MouseEvent} objects with standard buttons
only: {@code NOBUTTON}, {@code BUTTON1}, {@code BUTTON2} and
{@code BUTTON3}
<li> it is legal to use standard button masks only:
{@code InputEvent.BUTTON1_DOWN_MASK}, {@code InputEvent.BUTTON2_DOWN_MASK},
{@code InputEvent.BUTTON3_DOWN_MASK}
</ul>
This property should be used when there is no need in listening mouse events fired as a result of
activity with extra mouse button.
By default this property is set to {@code true}.
</body>
</html>
......@@ -31,6 +31,7 @@ import java.awt.GraphicsEnvironment;
import java.awt.Toolkit;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.util.Arrays;
/**
* The root event class for all component-level input events.
......@@ -153,13 +154,93 @@ public abstract class InputEvent extends ComponentEvent {
*/
public static final int ALT_GRAPH_DOWN_MASK = 1 << 13;
/**
* An array of extended modifiers for additional buttons.
* @see getButtonDownMasks
* @since 7.0
*/
private static final int [] BUTTON_DOWN_MASK = new int [] { BUTTON1_DOWN_MASK,
BUTTON2_DOWN_MASK,
BUTTON3_DOWN_MASK,
1<<14, //4th phisical button (this is not a wheel!)
1<<15, //(this is not a wheel!)
1<<16,
1<<17,
1<<18,
1<<19,
1<<20,
1<<21 };
/**
* A method to access an array of extended modifiers for additional buttons.
* @since 7.0
*/
private static int [] getButtonDownMasks(){
return Arrays.copyOf(BUTTON_DOWN_MASK, BUTTON_DOWN_MASK.length);
}
/**
* A method to obtain a mask for any existing mouse button.
* The returned mask may be used for different purposes. Following are some of them:
* <ul>
* <li> {@link java.awt.Robot#mousePress(int) mousePress(buttons)} and
* {@link java.awt.Robot#mouseRelease(int) mouseRelease(buttons)}
* <li> as a {@code modifiers} parameter when creating a new {@link MouseEvent} instance
* <li> to check {@link MouseEvent#getModifiersEx() modifiersEx} of existing {@code MouseEvent}
* </ul>
* @param button is a number to represent a button starting from 1.
* For example,
* <pre>
* int button = InputEvent.getMaskForButton(1);
* </pre>
* will have the same meaning as
* <pre>
* int button = InputEvent.getMaskForButton(MouseEvent.BUTTON1);
* </pre>
* because {@link MouseEvent#BUTTON1 MouseEvent.BUTTON1} equals to 1.
* If a mouse has three enabled buttons(see {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()})
* then the values from the left column passed into the method will return
* corresponding values from the right column:
* <PRE>
* <b>button </b> <b>returned mask</b>
* {@link MouseEvent#BUTTON1 BUTTON1} {@link MouseEvent#BUTTON1_DOWN_MASK BUTTON1_DOWN_MASK}
* {@link MouseEvent#BUTTON2 BUTTON2} {@link MouseEvent#BUTTON2_DOWN_MASK BUTTON2_DOWN_MASK}
* {@link MouseEvent#BUTTON3 BUTTON3} {@link MouseEvent#BUTTON3_DOWN_MASK BUTTON3_DOWN_MASK}
* </PRE>
* If a mouse has more than three enabled buttons then more values
* are admissible (4, 5, etc.). There is no assigned constants for these extended buttons.
* The button masks for the extra buttons returned by this method have no assigned names like the
* first three button masks.
* <p>
* This method has the following implementation restriction.
* It returns masks for a limited number of buttons only. The maximum number is
* implementation dependent and may vary.
* This limit is defined by the relevant number
* of buttons that may hypothetically exist on the mouse but it is greater than the
* {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}.
* <p>
* @throws IllegalArgumentException if {@code button} is less than zero or greater than the number
* of button masks reserved for buttons
* @since 7.0
* @see java.awt.MouseInfo#getNumberOfButtons()
* @see Toolkit#areExtraMouseButtonsEnabled()
* @see MouseEvent#getModifiers()
* @see MouseEvent#getModifiersEx()
*/
public static int getMaskForButton(int button) {
if (button <= 0 || button > BUTTON_DOWN_MASK.length) {
throw new IllegalArgumentException("button doesn\'t exist " + button);
}
return BUTTON_DOWN_MASK[button - 1];
}
// the constant below MUST be updated if any extra modifier
// bits are to be added!
// in fact, it is undesirable to add modifier bits
// to the same field as this may break applications
// see bug# 5066958
static final int FIRST_HIGH_BIT = 1 << 14;
static final int FIRST_HIGH_BIT = 1 << 22;
static final int JDK_1_3_MODIFIERS = SHIFT_DOWN_MASK - 1;
static final int HIGH_MODIFIERS = ~( FIRST_HIGH_BIT - 1 );
......@@ -382,7 +463,7 @@ public abstract class InputEvent extends ComponentEvent {
* cause the returning an empty string.
*
* @param modifiers a modifier mask describing the extended
* modifier keys and mouse buttons for the event
* modifier keys and mouse buttons for the event
* @return a text description of the combination of extended
* modifier keys and mouse buttons that were held down
* during the event.
......@@ -410,17 +491,14 @@ public abstract class InputEvent extends ComponentEvent {
buf.append(Toolkit.getProperty("AWT.altGraph", "Alt Graph"));
buf.append("+");
}
if ((modifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) {
buf.append(Toolkit.getProperty("AWT.button1", "Button1"));
buf.append("+");
}
if ((modifiers & InputEvent.BUTTON2_DOWN_MASK) != 0) {
buf.append(Toolkit.getProperty("AWT.button2", "Button2"));
buf.append("+");
}
if ((modifiers & InputEvent.BUTTON3_DOWN_MASK) != 0) {
buf.append(Toolkit.getProperty("AWT.button3", "Button3"));
buf.append("+");
int buttonNumber = 1;
for (int mask : InputEvent.BUTTON_DOWN_MASK){
if ((modifiers & mask) != 0) {
buf.append(Toolkit.getProperty("AWT.button"+buttonNumber, "Button"+buttonNumber));
buf.append("+");
}
buttonNumber++;
}
if (buf.length() > 0) {
buf.setLength(buf.length()-1); // remove trailing '+'
......
......@@ -32,6 +32,7 @@ import java.awt.Toolkit;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.awt.IllegalComponentStateException;
import java.awt.MouseInfo;
/**
* An event which indicates that a mouse action occurred in a component.
......@@ -135,7 +136,15 @@ import java.awt.IllegalComponentStateException;
* for <code>BUTTON2_MASK</code> arrives first,
* followed by the pair for <code>BUTTON1_MASK</code>.
* <p>
*
* Some extra mouse buttons are added to extend the standard set of buttons
* represented by the following constants:{@code BUTTON1}, {@code BUTTON2}, and {@code BUTTON3}.
* Extra buttons have no assigned {@code BUTTONx}
* constants as well as their button masks have no assigned {@code BUTTONx_DOWN_MASK}
* constants. Nevertheless, ordinal numbers starting from 4 may be
* used as button numbers (button ids). Values obtained by the
* {@link InputEvent#getMaskForButton(int) getMaskForButton(button)} method may be used
* as button masks.
* <p>
* <code>MOUSE_DRAGGED</code> events are delivered to the <code>Component</code>
* in which the mouse button was pressed until the mouse button is released
* (regardless of whether the mouse position is within the bounds of the
......@@ -324,13 +333,31 @@ public class MouseEvent extends InputEvent {
/**
* Indicates which, if any, of the mouse buttons has changed state.
*
* The only legal values are the following constants:
* <code>NOBUTTON</code>,
* <code>BUTTON1</code>,
* <code>BUTTON2</code> or
* <code>BUTTON3</code>.
* The valid values are ranged from 0 to the value returned by the
* {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()} method.
* This range already includes constants {@code NOBUTTON}, {@code BUTTON1},
* {@code BUTTON2}, and {@code BUTTON3}
* if these buttons are present. So it is allowed to use these constants too.
* For example, for a mouse with two buttons this field may contain the following values:
* <ul>
* <li> 0 ({@code NOBUTTON})
* <li> 1 ({@code BUTTON1})
* <li> 2 ({@code BUTTON2})
* </ul>
* If a mouse has 5 buttons, this field may contain the following values:
* <ul>
* <li> 0 ({@code NOBUTTON})
* <li> 1 ({@code BUTTON1})
* <li> 2 ({@code BUTTON2})
* <li> 3 ({@code BUTTON3})
* <li> 4
* <li> 5
* </ul>
* If support for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled()} disabled by Java
* then the field may not contain the value larger than {@code BUTTON3}.
* @serial
* @see #getButton().
* @see #getButton()
* @see java.awt.Toolkit#areExtraMouseButtonsEnabled()
*/
int button;
......@@ -384,6 +411,15 @@ public class MouseEvent extends InputEvent {
return new Point(xAbs, yAbs);
}
/**
* A number of buttons available on the mouse at the {@code Toolkit} machinery startup.
*/
private static int cachedNumberOfButtons;
static {
cachedNumberOfButtons = MouseInfo.getNumberOfButtons();
}
/**
* Returns the absolute horizontal x position of the event.
* In a virtual device multi-screen environment in which the
......@@ -421,7 +457,8 @@ public class MouseEvent extends InputEvent {
/**
* Constructs a <code>MouseEvent</code> object with the
* specified source component,
* type, modifiers, coordinates, and click count.
* type, time, modifiers, coordinates, click count, popupTrigger flag,
* and button number.
* <p>
* Creating an invalid event (such
* as by using more than one of the old _MASKs, or modifier/button
......@@ -464,7 +501,33 @@ public class MouseEvent extends InputEvent {
* @param popupTrigger A boolean that equals {@code true} if this event
* is a trigger for a popup menu
* @param button An integer that indicates, which of the mouse buttons has
* changed its state
* changed its state.
* The following rules are applied to this parameter:
* <ul>
* <li>If support for the extended mouse buttons is
* {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
* then it is allowed to create {@code MouseEvent} objects only with the standard buttons:
* {@code NOBUTTON}, {@code BUTTON1}, {@code BUTTON2}, and
* {@code BUTTON3}.
* <li> If support for the extended mouse buttons is
* {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java
* then it is allowed to create {@code MouseEvent} objects with
* the standard buttons.
* In case the support for extended mouse buttons is
* {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java, then
* in addition to the standard buttons, {@code MouseEvent} objects can be created
* using buttons from the range starting from 4 to
* {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}
* if the mouse has more than three buttons.
* </ul>
* @throws IllegalArgumentException if {@code button} is less then zero
* @throws IllegalArgumentException if <code>source</code> is null
* @throws IllegalArgumentException if {@code button} is greater then BUTTON3 and the support for extended mouse buttons is
* {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
* @throws IllegalArgumentException if {@code button} is greater then the
* {@link java.awt.MouseInfo#getNumberOfButtons() current number of buttons} and the support
* for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() enabled}
* by Java
* @throws IllegalArgumentException if an invalid <code>button</code>
* value is passed in
* @throws IllegalArgumentException if <code>source</code> is null
......@@ -498,7 +561,7 @@ public class MouseEvent extends InputEvent {
/**
* Constructs a <code>MouseEvent</code> object with the
* specified source component,
* type, modifiers, coordinates, and click count.
* type, modifiers, coordinates, click count, and popupTrigger flag.
* An invocation of the form
* <tt>MouseEvent(source, id, when, modifiers, x, y, clickCount, popupTrigger)</tt>
* behaves in exactly the same way as the invocation
......@@ -551,10 +614,26 @@ public class MouseEvent extends InputEvent {
}
/* if the button is an extra button and it is released or clicked then in Xsystem its state
is not modified. Exclude this button number from ExtModifiers mask.*/
transient private boolean shouldExcludeButtonFromExtModifiers = false;
/**
* {@inheritDoc}
*/
public int getModifiersEx() {
int tmpModifiers = modifiers;
if (shouldExcludeButtonFromExtModifiers) {
tmpModifiers &= ~(InputEvent.getMaskForButton(getButton()));
}
return tmpModifiers & ~JDK_1_3_MODIFIERS;
}
/**
* Constructs a <code>MouseEvent</code> object with the
* specified source component,
* type, modifiers, coordinates, absolute coordinates, and click count.
* type, time, modifiers, coordinates, absolute coordinates, click count, popupTrigger flag,
* and button number.
* <p>
* Creating an invalid event (such
* as by using more than one of the old _MASKs, or modifier/button
......@@ -595,7 +674,33 @@ public class MouseEvent extends InputEvent {
* @param popupTrigger A boolean that equals {@code true} if this event
* is a trigger for a popup menu
* @param button An integer that indicates, which of the mouse buttons has
* changed its state
* changed its state.
* The following rules are applied to this parameter:
* <ul>
* <li>If support for the extended mouse buttons is
* {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
* then it is allowed to create {@code MouseEvent} objects only with the standard buttons:
* {@code NOBUTTON}, {@code BUTTON1}, {@code BUTTON2}, and
* {@code BUTTON3}.
* <li> If support for the extended mouse buttons is
* {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java
* then it is allowed to create {@code MouseEvent} objects with
* the standard buttons.
* In case the support for extended mouse buttons is
* {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java, then
* in addition to the standard buttons, {@code MouseEvent} objects can be created
* using buttons from the range starting from 4 to
* {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}
* if the mouse has more than three buttons.
* </ul>
* @throws IllegalArgumentException if {@code button} is less then zero
* @throws IllegalArgumentException if <code>source</code> is null
* @throws IllegalArgumentException if {@code button} is greater then BUTTON3 and the support for extended mouse buttons is
* {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
* @throws IllegalArgumentException if {@code button} is greater then the
* {@link java.awt.MouseInfo#getNumberOfButtons() current number of buttons} and the support
* for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() enabled}
* by Java
* @throws IllegalArgumentException if an invalid <code>button</code>
* value is passed in
* @throws IllegalArgumentException if <code>source</code> is null
......@@ -610,6 +715,10 @@ public class MouseEvent extends InputEvent {
* @see #getClickCount()
* @see #isPopupTrigger()
* @see #getButton()
* @see #button
* @see Toolkit#areExtraMouseButtonsEnabled()
* @see java.awt.MouseInfo#getNumberOfButtons()
* @see InputEvent#getMaskForButton(int)
* @since 1.6
*/
public MouseEvent(Component source, int id, long when, int modifiers,
......@@ -623,14 +732,41 @@ public class MouseEvent extends InputEvent {
this.yAbs = yAbs;
this.clickCount = clickCount;
this.popupTrigger = popupTrigger;
if (button < NOBUTTON || button >BUTTON3) {
throw new IllegalArgumentException("Invalid button value");
if (button < NOBUTTON){
throw new IllegalArgumentException("Invalid button value :" + button);
}
//TODO: initialize MouseInfo.cachedNumber on toolkit creation.
if (button > BUTTON3) {
if (!Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){
throw new IllegalArgumentException("Extra mouse events are disabled " + button);
} else {
if (button > cachedNumberOfButtons) {
throw new IllegalArgumentException("Nonexistent button " + button);
}
}
// XToolkit: extra buttons are not reporting about their state correctly.
// Being pressed they report the state=0 both on the press and on the release.
// For 1-3 buttons the state value equals zero on press and non-zero on release.
// Other modifiers like Shift, ALT etc seem report well with extra buttons.
// The problem reveals as follows: one button is pressed and then another button is pressed and released.
// So, the getModifiersEx() would not be zero due to a first button and we will skip this modifier.
// This may have to be moved into the peer code instead if possible.
if (getModifiersEx() != 0) { //There is at least one more button in a pressed state.
if (id == MouseEvent.MOUSE_RELEASED || id == MouseEvent.MOUSE_CLICKED){
System.out.println("MEvent. CASE!");
shouldExcludeButtonFromExtModifiers = true;
}
}
}
this.button = button;
if ((getModifiers() != 0) && (getModifiersEx() == 0)) {
setNewModifiers();
} else if ((getModifiers() == 0) &&
(getModifiersEx() != 0 || button != NOBUTTON))
(getModifiersEx() != 0 || button != NOBUTTON) &&
(button <= BUTTON3))
{
setOldModifiers();
}
......@@ -701,13 +837,55 @@ public class MouseEvent extends InputEvent {
/**
* Returns which, if any, of the mouse buttons has changed state.
* The returned value is ranged
* from 0 to the {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}
* value.
* The returned value includes at least the following constants:
* <ul>
* <li> {@code NOBUTTON}
* <li> {@code BUTTON1}
* <li> {@code BUTTON2}
* <li> {@code BUTTON3}
* </ul>
* It is allowed to use those constants to compare with the returned button number in the application.
* For example,
* <pre>
* if (anEvent.getButton() == MouseEvent.BUTTON1) {
* </pre>
* In particular, for a mouse with one, two, or three buttons this method may return the following values:
* <ul>
* <li> 0 ({@code NOBUTTON})
* <li> 1 ({@code BUTTON1})
* <li> 2 ({@code BUTTON2})
* <li> 3 ({@code BUTTON3})
* </ul>
* Button numbers greater then {@code BUTTON3} have no constant identifier. So if a mouse with five buttons is
* installed, this method may return the following values:
* <ul>
* <li> 0 ({@code NOBUTTON})
* <li> 1 ({@code BUTTON1})
* <li> 2 ({@code BUTTON2})
* <li> 3 ({@code BUTTON3})
* <li> 4
* <li> 5
* </ul>
* <p>
* Note: If support for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
* then the AWT event subsystem does not produce mouse events for the extended mouse
* buttons. So it is not expected that this method returns anything except {@code NOBUTTON}, {@code BUTTON1},
* {@code BUTTON2}, {@code BUTTON3}.
*
* @return one of the following constants:
* <code>NOBUTTON</code>,
* <code>BUTTON1</code>,
* <code>BUTTON2</code> or
* <code>BUTTON3</code>.
* @return one of the values from 0 to {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}
* if support for the extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java.
* That range includes {@code NOBUTTON}, {@code BUTTON1}, {@code BUTTON2}, {@code BUTTON3};
* <br>
* {@code NOBUTTON}, {@code BUTTON1}, {@code BUTTON2} or {@code BUTTON3}
* if support for the extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
* @since 1.4
* @see Toolkit#areExtraMouseButtonsEnabled()
* @see java.awt.MouseInfo#getNumberOfButtons()
* @see #MouseEvent(Component, int, long, int, int, int, int, int, int, boolean, int)
* @see InputEvent#getMaskForButton(int)
*/
public int getButton() {
return button;
......@@ -746,7 +924,7 @@ public class MouseEvent extends InputEvent {
* and will cause the returning an unspecified string.
* Zero parameter means that no modifiers were passed and will
* cause the returning an empty string.
*
* <p>
* @param modifiers A modifier mask describing the modifier keys and
* mouse buttons that were down during the event
* @return string string text description of the combination of modifier
......@@ -788,6 +966,24 @@ public class MouseEvent extends InputEvent {
buf.append(Toolkit.getProperty("AWT.button3", "Button3"));
buf.append("+");
}
int mask;
// TODO: add a toolkit field that holds a number of button on the mouse.
// As the method getMouseModifiersText() is static and obtain
// an integer as a parameter then we may not restrict this with the number
// of buttons installed on the mouse.
// It's a temporary solution. We need to somehow hold the number of buttons somewhere else.
for (int i = 1; i <= cachedNumberOfButtons; i++){
mask = InputEvent.getMaskForButton(i);
if ((modifiers & mask) != 0 &&
buf.indexOf(Toolkit.getProperty("AWT.button"+i, "Button"+i)) == -1) //1,2,3 buttons may already be there; so don't duplicate it.
{
buf.append(Toolkit.getProperty("AWT.button"+i, "Button"+i));
buf.append("+");
}
}
if (buf.length() > 0) {
buf.setLength(buf.length()-1); // remove trailing '+'
}
......@@ -836,14 +1032,18 @@ public class MouseEvent extends InputEvent {
str.append(",(").append(x).append(",").append(y).append(")");
str.append(",absolute(").append(xAbs).append(",").append(yAbs).append(")");
str.append(",button=").append(getButton());
if (id != MOUSE_DRAGGED && id != MOUSE_MOVED){
str.append(",button=").append(getButton());
}
if (getModifiers() != 0) {
str.append(",modifiers=").append(getMouseModifiersText(modifiers));
}
if (getModifiersEx() != 0) {
str.append(",extModifiers=").append(getModifiersExText(modifiers));
//Using plain "modifiers" here does show an excluded extended buttons in the string event representation.
//getModifiersEx() solves the problem.
str.append(",extModifiers=").append(getModifiersExText(getModifiersEx()));
}
str.append(",clickCount=").append(clickCount);
......
......@@ -25,7 +25,11 @@
package java.awt.peer;
import java.awt.Button;
/**
* The peer interface for {@link Button}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
......@@ -33,5 +37,14 @@ package java.awt.peer;
* instances.
*/
public interface ButtonPeer extends ComponentPeer {
/**
* Sets the label that is displayed on the button. Can be {@code null}
* when the button should not display a label.
*
* @param label the label string to set
*
* @see Button#setLabel
*/
void setLabel(String label);
}
......@@ -24,7 +24,11 @@
*/
package java.awt.peer;
import java.awt.Canvas;
/**
* The peer interface for {@link Canvas}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
......
......@@ -24,7 +24,11 @@
*/
package java.awt.peer;
import java.awt.CheckboxMenuItem;
/**
* The peer interface for {@link CheckboxMenuItem}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
......@@ -32,5 +36,14 @@ package java.awt.peer;
* instances.
*/
public interface CheckboxMenuItemPeer extends MenuItemPeer {
/**
* Sets the state of the checkbox to be checked ({@code true}) or
* unchecked ({@code false}).
*
* @param t the state to set on the checkbox
*
* @see CheckboxMenuItemPeer#setState(boolean)
*/
void setState(boolean t);
}
......@@ -27,6 +27,8 @@ package java.awt.peer;
import java.awt.*;
/**
* The peer interface for {@link Checkbox}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
......@@ -34,7 +36,36 @@ import java.awt.*;
* instances.
*/
public interface CheckboxPeer extends ComponentPeer {
/**
* Sets the state of the checkbox to be checked ({@code true}) or
* unchecked ({@code false}).
*
* @param t the state to set on the checkbox
*
* @see Checkbox#setState(boolean)
*/
void setState(boolean state);
/**
* Sets the checkbox group for this checkbox. Checkboxes in one checkbox
* group can only be selected exclusively (like radio buttons). A value
* of {@code null} removes this checkbox from any checkbox group.
*
* @param g the checkbox group to set, or {@code null} when this
* checkbox should not be placed in any group
*
* @see Checkbox#setCheckboxGroup(CheckboxGroup)
*/
void setCheckboxGroup(CheckboxGroup g);
/**
* Sets the label that should be displayed on the ckeckbox. A value of
* {@code null} means that no label should be displayed.
*
* @param label the label to be displayed on the checkbox, or
* {@code null} when no label should be displayed.
*/
void setLabel(String label);
}
......@@ -24,7 +24,11 @@
*/
package java.awt.peer;
import java.awt.Choice;
/**
* The peer interface for {@link Choice}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
......@@ -32,13 +36,41 @@ package java.awt.peer;
* instances.
*/
public interface ChoicePeer extends ComponentPeer {
/**
* Adds an item with the string {@code item} to the combo box list
* at index {@code index}.
*
* @param item the label to be added to the list
* @param index the index where to add the item
*
* @see Choice#add(String)
*/
void add(String item, int index);
/**
* Removes the item at index {@code index} from the combo box list.
*
* @param index the index where to remove the item
*
* @see Choice#remove(int)
*/
void remove(int index);
/**
* Removes all items from the combo box list.
*
* @see Choice#removeAll()
*/
void removeAll();
void select(int index);
/*
* DEPRECATED: Replaced by add(String, int).
/**
* Selects the item at index {@code index}.
*
* @param index the index which should be selected
*
* @see Choice#select(int)
*/
void addItem(String item, int index);
void select(int index);
}
......@@ -37,6 +37,12 @@ import sun.java2d.pipe.Region;
/**
* The peer interface for {@link Component}. This is the top level peer
* interface for widgets and defines the bulk of methods for AWT component
* peers. Most component peers have to implement this interface (via one
* of the subinterfaces), except menu components, which implement
* {@link MenuComponentPeer}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
......@@ -44,115 +50,493 @@ import sun.java2d.pipe.Region;
* instances.
*/
public interface ComponentPeer {
public static final int SET_LOCATION = 1,
SET_SIZE = 2,
SET_BOUNDS = 3,
SET_CLIENT_SIZE = 4,
RESET_OPERATION = 5,
NO_EMBEDDED_CHECK = (1 << 14),
DEFAULT_OPERATION = SET_BOUNDS;
/**
* Operation for {@link #setBounds(int, int, int, int, int)}, indicating
* a change in the component location only.
*
* @see #setBounds(int, int, int, int, int)
*/
public static final int SET_LOCATION = 1;
/**
* Operation for {@link #setBounds(int, int, int, int, int)}, indicating
* a change in the component size only.
*
* @see #setBounds(int, int, int, int, int)
*/
public static final int SET_SIZE = 2;
/**
* Operation for {@link #setBounds(int, int, int, int, int)}, indicating
* a change in the component size and location.
*
* @see #setBounds(int, int, int, int, int)
*/
public static final int SET_BOUNDS = 3;
/**
* Operation for {@link #setBounds(int, int, int, int, int)}, indicating
* a change in the component client size. This is used for setting
* the 'inside' size of windows, without the border insets.
*
* @see #setBounds(int, int, int, int, int)
*/
public static final int SET_CLIENT_SIZE = 4;
/**
* Resets the setBounds() operation to DEFAULT_OPERATION. This is not
* passed into {@link #setBounds(int, int, int, int, int)}.
*
* TODO: This is only used internally and should probably be moved outside
* the peer interface.
*
* @see Component#setBoundsOp
*/
public static final int RESET_OPERATION = 5;
/**
* A flag that is used to suppress checks for embedded frames.
*
* TODO: This is only used internally and should probably be moved outside
* the peer interface.
*/
public static final int NO_EMBEDDED_CHECK = (1 << 14);
/**
* The default operation, which is to set size and location.
*
* TODO: This is only used internally and should probably be moved outside
* the peer interface.
*
* @see Component#setBoundsOp
*/
public static final int DEFAULT_OPERATION = SET_BOUNDS;
/**
* Determines if a component has been obscured, i.e. by an overlapping
* window or similar. This is used by JViewport for optimizing performance.
* This doesn't have to be implemented, when
* {@link #canDetermineObscurity()} returns {@code false}.
*
* @return {@code true} when the component has been obscured,
* {@code false} otherwise
*
* @see #canDetermineObscurity()
* @see javax.swing.JViewport#needsRepaintAfterBlit
*/
boolean isObscured();
/**
* Returns {@code true} when the peer can determine if a component
* has been obscured, {@code false} false otherwise.
*
* @return {@code true} when the peer can determine if a component
* has been obscured, {@code false} false otherwise
*
* @see #isObscured()
* @see javax.swing.JViewport#needsRepaintAfterBlit
*/
boolean canDetermineObscurity();
void setVisible(boolean b);
void setEnabled(boolean b);
void paint(Graphics g);
void repaint(long tm, int x, int y, int width, int height);
void print(Graphics g);
void setBounds(int x, int y, int width, int height, int op);
void handleEvent(AWTEvent e);
void coalescePaintEvent(PaintEvent e);
Point getLocationOnScreen();
Dimension getPreferredSize();
Dimension getMinimumSize();
ColorModel getColorModel();
Toolkit getToolkit();
Graphics getGraphics();
FontMetrics getFontMetrics(Font font);
void dispose();
void setForeground(Color c);
void setBackground(Color c);
void setFont(Font f);
void updateCursorImmediately();
boolean requestFocus(Component lightweightChild,
boolean temporary,
boolean focusedWindowChangeAllowed,
long time, CausedFocusEvent.Cause cause);
boolean isFocusable();
Image createImage(ImageProducer producer);
Image createImage(int width, int height);
VolatileImage createVolatileImage(int width, int height);
boolean prepareImage(Image img, int w, int h, ImageObserver o);
int checkImage(Image img, int w, int h, ImageObserver o);
GraphicsConfiguration getGraphicsConfiguration();
boolean handlesWheelScrolling();
void createBuffers(int numBuffers, BufferCapabilities caps) throws AWTException;
Image getBackBuffer();
void flip(int x1, int y1, int x2, int y2, BufferCapabilities.FlipContents flipAction);
void destroyBuffers();
/**
* Reparents this peer to the new parent referenced by <code>newContainer</code> peer
* Implementation depends on toolkit and container.
* @param newContainer peer of the new parent container
* @since 1.5
* Makes a component visible or invisible.
*
* @param v {@code true} to make a component visible,
* {@code false} to make it invisible
*
* @see Component#setVisible(boolean)
*/
void reparent(ContainerPeer newContainer);
void setVisible(boolean v);
/**
* Returns whether this peer supports reparenting to another parent withour destroying the peer
* @return true if appropriate reparent is supported, false otherwise
* @since 1.5
* Enables or disables a component. Disabled components are usually grayed
* out and cannot be activated.
*
* @param e {@code true} to enable the component, {@code false}
* to disable it
*
* @see Component#setEnabled(boolean)
*/
boolean isReparentSupported();
void setEnabled(boolean e);
/**
* Used by lightweight implementations to tell a ComponentPeer to layout
* its sub-elements. For instance, a lightweight Checkbox needs to layout
* the box, as well as the text label.
* Paints the component to the specified graphics context. This is called
* by {@link Component#paintAll(Graphics)} to paint the component.
*
* @param g the graphics context to paint to
*
* @see Component#paintAll(Graphics)
*/
void layout();
void paint(Graphics g);
/**
* Prints the component to the specified graphics context. This is called
* by {@link Component#printAll(Graphics)} to print the component.
*
* @param g the graphics context to print to
*
* @see Component#printAll(Graphics)
*/
void print(Graphics g);
Rectangle getBounds();
/**
* Sets the location or size or both of the component. The location is
* specified relative to the component's parent. The {@code op}
* parameter specifies which properties change. If it is
* {@link #SET_LOCATION}, then only the location changes (and the size
* parameters can be ignored). If {@code op} is {@link #SET_SIZE},
* then only the size changes (and the location can be ignored). If
* {@code op} is {@link #SET_BOUNDS}, then both change. There is a
* special value {@link #SET_CLIENT_SIZE}, which is used only for
* window-like components to set the size of the client (i.e. the 'inner'
* size, without the insets of the window borders).
*
* @param x the X location of the component
* @param y the Y location of the component
* @param width the width of the component
* @param height the height of the component
* @param op the operation flag
*
* @see #SET_BOUNDS
* @see #SET_LOCATION
* @see #SET_SIZE
* @see #SET_CLIENT_SIZE
*/
void setBounds(int x, int y, int width, int height, int op);
/**
* Applies the shape to the native component window.
* @since 1.7
* Called to let the component peer handle events.
*
* @param e the AWT event to handle
*
* @see Component#dispatchEvent(AWTEvent)
*/
void applyShape(Region shape);
void handleEvent(AWTEvent e);
/**
* Called to coalesce paint events.
*
* @param e the paint event to consider to coalesce
*
* @see EventQueue#coalescePaintEvent
*/
void coalescePaintEvent(PaintEvent e);
/**
* DEPRECATED: Replaced by getPreferredSize().
* Determines the location of the component on the screen.
*
* @return the location of the component on the screen
*
* @see Component#getLocationOnScreen()
*/
Dimension preferredSize();
Point getLocationOnScreen();
/**
* DEPRECATED: Replaced by getMinimumSize().
* Determines the preferred size of the component.
*
* @return the preferred size of the component
*
* @see Component#getPreferredSize()
*/
Dimension minimumSize();
Dimension getPreferredSize();
/**
* DEPRECATED: Replaced by setVisible(boolean).
* Determines the minimum size of the component.
*
* @return the minimum size of the component
*
* @see Component#getMinimumSize()
*/
void show();
Dimension getMinimumSize();
/**
* DEPRECATED: Replaced by setVisible(boolean).
* Returns the color model used by the component.
*
* @return the color model used by the component
*
* @see Component#getColorModel()
*/
void hide();
ColorModel getColorModel();
/**
* DEPRECATED: Replaced by setEnabled(boolean).
* Returns the toolkit that is responsible for the component.
*
* @return the toolkit that is responsible for the component
*
* @see Component#getToolkit()
*/
void enable();
Toolkit getToolkit();
/**
* DEPRECATED: Replaced by setEnabled(boolean).
* Returns a graphics object to paint on the component.
*
* @return a graphics object to paint on the component
*
* @see Component#getGraphics()
*/
void disable();
// TODO: Maybe change this to force Graphics2D, since many things will
// break with plain Graphics nowadays.
Graphics getGraphics();
/**
* DEPRECATED: Replaced by setBounds(int, int, int, int).
* Returns a font metrics object to determine the metrics properties of
* the specified font.
*
* @param font the font to determine the metrics for
*
* @return a font metrics object to determine the metrics properties of
* the specified font
*
* @see Component#getFontMetrics(Font)
*/
void reshape(int x, int y, int width, int height);
FontMetrics getFontMetrics(Font font);
/**
* Disposes all resources held by the component peer. This is called
* when the component has been disconnected from the component hierarchy
* and is about to be garbage collected.
*
* @see Component#removeNotify()
*/
void dispose();
/**
* Sets the foreground color of this component.
*
* @param c the foreground color to set
*
* @see Component#setForeground(Color)
*/
void setForeground(Color c);
/**
* Sets the background color of this component.
*
* @param c the background color to set
*
* @see Component#setBackground(Color)
*/
void setBackground(Color c);
/**
* Sets the font of this component.
*
* @param f the font of this component
*
* @see Component#setFont(Font)
*/
void setFont(Font f);
/**
* Updates the cursor of the component.
*
* @see Component#updateCursorImmediately
*/
void updateCursorImmediately();
/**
* Requests focus on this component.
*
* @param lightweightChild the actual lightweight child that requests the
* focus
* @param temporary {@code true} if the focus change is temporary,
* {@code false} otherwise
* @param focusedWindowChangeAllowed {@code true} if changing the
* focus of the containing window is allowed or not
* @param time the time of the focus change request
* @param cause the cause of the focus change request
*
* @return {@code true} if the focus change is guaranteed to be
* granted, {@code false} otherwise
*/
boolean requestFocus(Component lightweightChild, boolean temporary,
boolean focusedWindowChangeAllowed, long time,
CausedFocusEvent.Cause cause);
/**
* Returns {@code true} when the component takes part in the focus
* traversal, {@code false} otherwise.
*
* @return {@code true} when the component takes part in the focus
* traversal, {@code false} otherwise
*/
boolean isFocusable();
/**
* Creates an image using the specified image producer.
*
* @param producer the image producer from which the image pixels will be
* produced
*
* @return the created image
*
* @see Component#createImage(ImageProducer)
*/
Image createImage(ImageProducer producer);
/**
* Creates an empty image with the specified width and height. This is
* generally used as a non-accelerated backbuffer for drawing onto the
* component (e.g. by Swing).
*
* @param width the width of the image
* @param height the height of the image
*
* @return the created image
*
* @see Component#createImage(int, int)
*/
// TODO: Maybe make that return a BufferedImage, because some stuff will
// break if a different kind of image is returned.
Image createImage(int width, int height);
/**
* Creates an empty volatile image with the specified width and height.
* This is generally used as an accelerated backbuffer for drawing onto
* the component (e.g. by Swing).
*
* @param width the width of the image
* @param height the height of the image
*
* @return the created volatile image
*
* @see Component#createVolatileImage(int, int)
*/
// TODO: Include capabilities here and fix Component#createVolatileImage
VolatileImage createVolatileImage(int width, int height);
/**
* Prepare the specified image for rendering on this component. This should
* start loading the image (if not already loaded) and create an
* appropriate screen representation.
*
* @param img the image to prepare
* @param w the width of the screen representation
* @param h the height of the screen representation
* @param o an image observer to observe the progress
*
* @return {@code true} if the image is already fully prepared,
* {@code false} otherwise
*
* @see Component#prepareImage(Image, int, int, ImageObserver)
*/
boolean prepareImage(Image img, int w, int h, ImageObserver o);
/**
* Determines the status of the construction of the screen representaion
* of the specified image.
*
* @param img the image to check
* @param w the target width
* @param h the target height
* @param o the image observer to notify
*
* @return the status as bitwise ORed ImageObserver flags
*
* @see Component#checkImage(Image, int, int, ImageObserver)
*/
int checkImage(Image img, int w, int h, ImageObserver o);
/**
* Returns the graphics configuration that corresponds to this component.
*
* @return the graphics configuration that corresponds to this component
*
* @see Component#getGraphicsConfiguration()
*/
GraphicsConfiguration getGraphicsConfiguration();
/**
* Determines if the component handles wheel scrolling itself. Otherwise
* it is delegated to the component's parent.
*
* @return {@code true} if the component handles wheel scrolling,
* {@code false} otherwise
*
* @see Component#dispatchEventImpl(AWTEvent)
*/
boolean handlesWheelScrolling();
/**
* Create {@code numBuffers} flipping buffers with the specified
* buffer capabilities.
*
* @param numBuffers the number of buffers to create
* @param caps the buffer capabilities
*
* @throws AWTException if flip buffering is not supported
*
* @see Component.FlipBufferStrategy#createBuffers
*/
void createBuffers(int numBuffers, BufferCapabilities caps)
throws AWTException;
/**
* Returns the back buffer as image.
*
* @return the back buffer as image
*
* @see Component.FlipBufferStrategy#getBackBuffer
*/
Image getBackBuffer();
/**
* Move the back buffer to the front buffer.
*
* @param x1 the area to be flipped, upper left X coordinate
* @param y1 the area to be flipped, upper left Y coordinate
* @param x2 the area to be flipped, lower right X coordinate
* @param y2 the area to be flipped, lower right Y coordinate
* @param flipAction the flip action to perform
*
* @see Component.FlipBufferStrategy#flip
*/
void flip(int x1, int y1, int x2, int y2, BufferCapabilities.FlipContents flipAction);
/**
* Destroys all created buffers.
*
* @see Component.FlipBufferStrategy#destroyBuffers
*/
void destroyBuffers();
/**
* Reparents this peer to the new parent referenced by
* {@code newContainer} peer. Implementation depends on toolkit and
* container.
*
* @param newContainer peer of the new parent container
*
* @since 1.5
*/
void reparent(ContainerPeer newContainer);
/**
* Returns whether this peer supports reparenting to another parent without
* destroying the peer.
*
* @return true if appropriate reparent is supported, false otherwise
*
* @since 1.5
*/
boolean isReparentSupported();
/**
* Used by lightweight implementations to tell a ComponentPeer to layout
* its sub-elements. For instance, a lightweight Checkbox needs to layout
* the box, as well as the text label.
*
* @see Component#validate()
*/
void layout();
/**
* Applies the shape to the native component window.
* @since 1.7
*
* @see Component#applyCompoundShape
*/
void applyShape(Region shape);
}
......@@ -27,6 +27,9 @@ package java.awt.peer;
import java.awt.*;
/**
* The peer interface for {@link Container}. This is the parent interface
* for all container like widgets.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
......@@ -34,30 +37,60 @@ import java.awt.*;
* instances.
*/
public interface ContainerPeer extends ComponentPeer {
/**
* Returns the insets of this container. Insets usually is the space that
* is occupied by things like borders.
*
* @return the insets of this container
*/
Insets getInsets();
/**
* Notifies the peer that validation of the component tree is about to
* begin.
*
* @see Container#validate()
*/
void beginValidate();
/**
* Notifies the peer that validation of the component tree is finished.
*
* @see Container#validate()
*/
void endValidate();
/**
* Notifies the peer that layout is about to begin. This is called
* before the container itself and its children are laid out.
*
* @see Container#validateTree()
*/
void beginLayout();
/**
* Notifies the peer that layout is finished. This is called after the
* container and its children have been laid out.
*
* @see Container#validateTree()
*/
void endLayout();
boolean isPaintPending();
/**
* Restacks native windows - children of this native window - according to Java container order
* Restacks native windows - children of this native window - according to
* Java container order.
*
* @since 1.5
*/
void restack();
/**
* Indicates availabiltity of restacking operation in this container.
* Indicates availability of restacking operation in this container.
*
* @return Returns true if restack is supported, false otherwise
*
* @since 1.5
*/
boolean isRestackSupported();
/**
* DEPRECATED: Replaced by getInsets().
*/
Insets insets();
}
......@@ -32,7 +32,7 @@ import java.net.URI;
import java.awt.Desktop.Action;
/**
* The <code>DesktopPeer</code> interface provides methods for the operation
* The {@code DesktopPeer} interface provides methods for the operation
* of open, edit, print, browse and mail with the given URL or file, by
* launching the associated application.
* <p>
......@@ -40,14 +40,15 @@ import java.awt.Desktop.Action;
*
*/
public interface DesktopPeer {
/**
* Returns whether the given action is supported on the current platform.
* @param action the action type to be tested if it's supported on the
* current platform.
* @return <code>true</code> if the given action is supported on
* the current platform; <code>false</code> otherwise.
* @return {@code true} if the given action is supported on
* the current platform; {@code false} otherwise.
*/
public boolean isSupported(Action action);
boolean isSupported(Action action);
/**
* Launches the associated application to open the given file. The
......@@ -58,7 +59,7 @@ public interface DesktopPeer {
* @throws IOException If the given file has no associated application,
* or the associated application fails to be launched.
*/
public void open(File file) throws IOException;
void open(File file) throws IOException;
/**
* Launches the associated editor and opens the given file for editing. The
......@@ -69,7 +70,7 @@ public interface DesktopPeer {
* @throws IOException If the given file has no associated editor, or
* the associated application fails to be launched.
*/
public void edit(File file) throws IOException;
void edit(File file) throws IOException;
/**
* Prints the given file with the native desktop printing facility, using
......@@ -79,7 +80,7 @@ public interface DesktopPeer {
* @throws IOException If the given file has no associated application
* that can be used to print it.
*/
public void print(File file) throws IOException;
void print(File file) throws IOException;
/**
* Launches the mail composing window of the user default mail client,
......@@ -93,7 +94,7 @@ public interface DesktopPeer {
* @throws IOException If the user default mail client is not found,
* or it fails to be launched.
*/
public void mail(URI mailtoURL) throws IOException;
void mail(URI mailtoURL) throws IOException;
/**
* Launches the user default browser to display the given URI.
......@@ -102,5 +103,5 @@ public interface DesktopPeer {
* @throws IOException If the user default browser is not found,
* or it fails to be launched.
*/
public void browse(URI url) throws IOException;
void browse(URI url) throws IOException;
}
......@@ -28,6 +28,9 @@ package java.awt.peer;
import java.awt.*;
/**
* The peer interface for {@link Dialog}. This adds a couple of dialog specific
* features to the {@link WindowPeer} interface.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
......@@ -35,7 +38,33 @@ import java.awt.*;
* instances.
*/
public interface DialogPeer extends WindowPeer {
/**
* Sets the title on the dialog window.
*
* @param title the title to set
*
* @see Dialog#setTitle(String)
*/
void setTitle(String title);
/**
* Sets if the dialog should be resizable or not.
*
* @param resizeable {@code true} when the dialog should be resizable,
* {@code false} if not
*
* @see Dialog#setResizable(boolean)
*/
void setResizable(boolean resizeable);
/**
* Block the specified windows. This is used for modal dialogs.
*
* @param windows the windows to block
*
* @see Dialog#modalShow()
* @see Dialog#blockWindows()
*/
void blockWindows(java.util.List<Window> windows);
}
......@@ -25,9 +25,12 @@
package java.awt.peer;
import java.awt.FileDialog;
import java.io.FilenameFilter;
/**
* The peer interface for {@link FileDialog}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
......@@ -35,7 +38,32 @@ import java.io.FilenameFilter;
* instances.
*/
public interface FileDialogPeer extends DialogPeer {
/**
* Sets the selected file for this file dialog.
*
* @param file the file to set as selected file, or {@code null} for
* no selected file
*
* @see FileDialog#setFile(String)
*/
void setFile(String file);
/**
* Sets the current directory for this file dialog.
*
* @param dir the directory to set
*
* @see FileDialog#setDirectory(String)
*/
void setDirectory(String dir);
/**
* Sets the filename filter for filtering the displayed files.
*
* @param filter the filter to set
*
* @see FileDialog#setFilenameFilter(FilenameFilter)
*/
void setFilenameFilter(FilenameFilter filter);
}
......@@ -26,6 +26,9 @@
package java.awt.peer;
/**
* The peer interface for fonts. This is only a marker interface and not
* used by AWT itself.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
......
......@@ -27,7 +27,12 @@ package java.awt.peer;
import java.awt.*;
import sun.awt.EmbeddedFrame;
/**
* The peer interface for {@link Frame}. This adds a couple of frame specific
* methods to the {@link WindowPeer} interface.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
......@@ -35,12 +40,89 @@ import java.awt.*;
* instances.
*/
public interface FramePeer extends WindowPeer {
/**
* Sets the title on the frame.
*
* @param title the title to set
*
* @see Frame#setTitle(String)
*/
void setTitle(String title);
/**
* Sets the menu bar for the frame.
*
* @param mb the menu bar to set
*
* @see Frame#setMenuBar(MenuBar)
*/
void setMenuBar(MenuBar mb);
/**
* Sets if the frame should be resizable or not.
*
* @param resizeable {@code true} when the frame should be resizable,
* {@code false} if not
*
* @see Frame#setResizable(boolean)
*/
void setResizable(boolean resizeable);
/**
* Changes the state of the frame.
*
* @param state the new state
*
* @see Frame#setExtendedState(int)
*/
void setState(int state);
int getState();
void setMaximizedBounds(Rectangle bounds); // XXX
/**
* Returns the current state of the frame.
*
* @return the current state of the frame
*
* @see Frame#getExtendedState()
*/
int getState();
/**
* Sets the bounds of the frame when it becomes maximized.
*
* @param bounds the maximized bounds of the frame
*
* @see Frame#setMaximizedBounds(Rectangle)
*/
void setMaximizedBounds(Rectangle bounds);
/**
* Sets the size and location for embedded frames. (On embedded frames,
* setLocation() and setBounds() always set the frame to (0,0) for
* backwards compatibility.
*
* @param x the X location
* @param y the Y location
* @param width the width of the frame
* @param height the height of the frame
*
* @see EmbeddedFrame#setBoundsPrivate(int, int, int, int)
*/
// TODO: This is only used in EmbeddedFrame, and should probably be moved
// into an EmbeddedFramePeer which would extend FramePeer
void setBoundsPrivate(int x, int y, int width, int height);
/**
* Returns the size and location for embedded frames. (On embedded frames,
* setLocation() and setBounds() always set the frame to (0,0) for
* backwards compatibility.
*
* @return the bounds of an embedded frame
*
* @see EmbeddedFrame#getBoundsPrivate()
*/
// TODO: This is only used in EmbeddedFrame, and should probably be moved
// into an EmbeddedFramePeer which would extend FramePeer
Rectangle getBoundsPrivate();
}
......@@ -28,11 +28,45 @@ package java.awt.peer;
import java.awt.Component;
import java.awt.Window;
/**
* The native peer interface for {@link KeyboardFocusManager}.
*/
public interface KeyboardFocusManagerPeer {
/**
* Returns the currently focused window.
*
* @return the currently focused window
*
* @see KeyboardFocusManager#getNativeFocusedWindow()
*/
Window getCurrentFocusedWindow();
/**
* Sets the component that should become the focus owner.
*
* @param comp the component to become the focus owner
*
* @see KeyboardFocusManager#setNativeFocusOwner(Component)
*/
void setCurrentFocusOwner(Component comp);
/**
* Returns the component that currently owns the input focus.
*
* @return the component that currently owns the input focus
*
* @see KeyboardFocusManager#getNativeFocusOwner()
*/
Component getCurrentFocusOwner();
/**
* Clears the current global focus owner.
*
* @param activeWindow
*
* @see KeyboardFocusManager#clearGlobalFocusOwner()
*/
void clearGlobalFocusOwner(Window activeWindow);
}
......@@ -24,7 +24,11 @@
*/
package java.awt.peer;
import java.awt.Label;
/**
* The peer interface for {@link Label}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
......@@ -32,6 +36,25 @@ package java.awt.peer;
* instances.
*/
public interface LabelPeer extends ComponentPeer {
/**
* Sets the text to be displayed on the label.
*
* @param label the text to be displayed on the label
*
* @see Label#setText
*/
void setText(String label);
/**
* Sets the alignment of the label text.
*
* @param alignment the alignment of the label text
*
* @see Label#setAlignment(int)
* @see Label#CENTER
* @see Label#RIGHT
* @see Label#LEFT
*/
void setAlignment(int alignment);
}
......@@ -25,8 +25,11 @@
package java.awt.peer;
import java.awt.Dimension;
import java.awt.List;
/**
* The peer interface for {@link List}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
......@@ -34,39 +37,102 @@ import java.awt.Dimension;
* instances.
*/
public interface ListPeer extends ComponentPeer {
/**
* Returns the indices of the list items that are currently selected.
* The returned array is not required to be a copy, the callers of this
* method already make sure it is not modified.
*
* @return the indices of the list items that are currently selected
*
* @see List#getSelectedIndexes()
*/
int[] getSelectedIndexes();
/**
* Adds an item to the list at the specified index.
*
* @param item the item to add to the list
* @param index the index where to add the item into the list
*
* @see List#add(String, int)
*/
void add(String item, int index);
/**
* Deletes items from the list. All items from start to end should are
* deleted, including the item at the start and end indices.
*
* @param start the first item to be deleted
* @param end the last item to be deleted
*/
void delItems(int start, int end);
/**
* Removes all items from the list.
*
* @see List#removeAll()
*/
void removeAll();
/**
* Selects the item at the specified {@code index}.
*
* @param index the index of the item to select
*
* @see List#select(int)
*/
void select(int index);
void deselect(int index);
void makeVisible(int index);
void setMultipleMode(boolean b);
Dimension getPreferredSize(int rows);
Dimension getMinimumSize(int rows);
/**
* DEPRECATED: Replaced by add(String, int).
* De-selects the item at the specified {@code index}.
*
* @param index the index of the item to de-select
*
* @see List#deselect(int)
*/
void addItem(String item, int index);
void deselect(int index);
/**
* DEPRECATED: Replaced by removeAll().
* Makes sure that the item at the specified {@code index} is visible,
* by scrolling the list or similar.
*
* @param index the index of the item to make visible
*
* @see List#makeVisible(int)
*/
void clear();
void makeVisible(int index);
/**
* DEPRECATED: Replaced by setMultipleMode(boolean).
* Toggles multiple selection mode on or off.
*
* @param m {@code true} for multiple selection mode,
* {@code false} for single selection mode
*
* @see List#setMultipleMode(boolean)
*/
void setMultipleSelections(boolean v);
void setMultipleMode(boolean m);
/**
* DEPRECATED: Replaced by getPreferredSize(int).
* Returns the preferred size for a list with the specified number of rows.
*
* @param rows the number of rows
*
* @return the preferred size of the list
*
* @see List#getPreferredSize(int)
*/
Dimension preferredSize(int v);
Dimension getPreferredSize(int rows);
/**
* DEPRECATED: Replaced by getMinimumSize(int).
* Returns the minimum size for a list with the specified number of rows.
*
* @param rows the number of rows
*
* @return the minimum size of the list
*
* @see List#getMinimumSize(int)
*/
Dimension minimumSize(int v);
Dimension getMinimumSize(int rows);
}
......@@ -25,8 +25,11 @@
package java.awt.peer;
import java.awt.Menu;
import java.awt.MenuBar;
/**
* The peer interface for {@link MenuBar}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
......@@ -34,7 +37,31 @@ import java.awt.Menu;
* instances.
*/
public interface MenuBarPeer extends MenuComponentPeer {
/**
* Adds a menu to the menu bar.
*
* @param m the menu to add
*
* @see MenuBar#add(Menu)
*/
void addMenu(Menu m);
/**
* Deletes a menu from the menu bar.
*
* @param index the index of the menu to remove
*
* @see MenuBar#remove(int)
*/
void delMenu(int index);
/**
* Adds a help menu to the menu bar.
*
* @param m the help menu to add
*
* @see MenuBar#setHelpMenu(Menu)
*/
void addHelpMenu(Menu m);
}
......@@ -25,8 +25,12 @@
package java.awt.peer;
import java.awt.Font;
import java.awt.MenuComponent;
/**
* The base interface for all kinds of menu components. This is used by
* {@link MenuComponent}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
......@@ -34,6 +38,20 @@ import java.awt.Font;
* instances.
*/
public interface MenuComponentPeer {
/**
* Disposes the menu component.
*
* @see MenuComponent#removeNotify()
*/
void dispose();
/**
* Sets the font for the menu component.
*
* @param f the font to use for the menu component
*
* @see MenuComponent#setFont(Font)
*/
void setFont(Font f);
}
......@@ -24,7 +24,11 @@
*/
package java.awt.peer;
import java.awt.MenuItem;
/**
* The peer interface for menu items. This is used by {@link MenuItem}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
......@@ -32,16 +36,20 @@ package java.awt.peer;
* instances.
*/
public interface MenuItemPeer extends MenuComponentPeer {
void setLabel(String label);
void setEnabled(boolean b);
/**
* DEPRECATED: Replaced by setEnabled(boolean).
* Sets the label to be displayed in this menu item.
*
* @param label the label to be displayed
*/
void enable();
void setLabel(String label);
/**
* DEPRECATED: Replaced by setEnabled(boolean).
* Enables or disables the menu item.
*
* @param e {@code true} to enable the menu item, {@code false}
* to disable it
*/
void disable();
void setEnabled(boolean e);
}
......@@ -24,9 +24,12 @@
*/
package java.awt.peer;
import java.awt.Menu;
import java.awt.MenuItem;
/**
* The peer interface for menus. This is used by {@link Menu}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
......@@ -34,7 +37,29 @@ import java.awt.MenuItem;
* instances.
*/
public interface MenuPeer extends MenuItemPeer {
/**
* Adds a separator (e.g. a horizontal line or similar) to the menu.
*
* @see Menu#addSeparator()
*/
void addSeparator();
/**
* Adds the specified menu item to the menu.
*
* @param item the menu item to add
*
* @see Menu#add(MenuItem)
*/
void addItem(MenuItem item);
/**
* Removes the menu item at the specified index.
*
* @param index the index of the item to remove
*
* @see Menu#remove(int)
*/
void delItem(int index);
}
......@@ -29,6 +29,9 @@ import java.awt.Window;
import java.awt.Point;
/**
* Peer interface for {@link MouseInfo}. This is used to get some additional
* information about the mouse.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
......
......@@ -25,6 +25,10 @@
package java.awt.peer;
/**
* The peer interface for {@link Panel}. This is a subinterface of
* ContainerPeer and does not declare any additional methods because a Panel
* is just that, a concrete Container.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
......
......@@ -25,8 +25,11 @@
package java.awt.peer;
import java.awt.Event;
import java.awt.PopupMenu;
/**
* The peer interface for {@link PopupMenu}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
......@@ -34,5 +37,14 @@ import java.awt.Event;
* instances.
*/
public interface PopupMenuPeer extends MenuPeer {
/**
* Shows the popup menu.
*
* @param e a synthetic event describing the origin and location of the
* popup menu
*
* @see PopupMenu#show(java.awt.Component, int, int)
*/
void show(Event e);
}
/*
* Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1999-2008 Sun Microsystems, Inc. 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
......@@ -39,17 +39,93 @@ import java.awt.*;
*/
public interface RobotPeer
{
public void mouseMove(int x, int y);
public void mousePress(int buttons);
public void mouseRelease(int buttons);
/**
* Moves the mouse pointer to the specified screen location.
*
* @param x the X location on screen
* @param y the Y location on screen
*
* @see Robot#mouseMove(int, int)
*/
void mouseMove(int x, int y);
public void mouseWheel(int wheelAmt);
/**
* Simulates a mouse press with the specified button(s).
*
* @param buttons the button mask
*
* @see Robot#mousePress(int)
*/
void mousePress(int buttons);
public void keyPress(int keycode);
public void keyRelease(int keycode);
/**
* Simulates a mouse release with the specified button(s).
*
* @param buttons the button mask
*
* @see Robot#mouseRelease(int)
*/
void mouseRelease(int buttons);
public int getRGBPixel(int x, int y);
public int [] getRGBPixels(Rectangle bounds);
/**
* Simulates mouse wheel action.
*
* @param wheelAmt number of notches to move the mouse wheel
*
* @see Robot#mouseWheel(int)
*/
void mouseWheel(int wheelAmt);
public void dispose();
/**
* Simulates a key press of the specified key.
*
* @param keycode the key code to press
*
* @see Robot#keyPress(int)
*/
void keyPress(int keycode);
/**
* Simulates a key release of the specified key.
*
* @param keycode the key code to release
*
* @see Robot#keyRelease(int)
*/
void keyRelease(int keycode);
/**
* Gets the RGB value of the specified pixel on screen.
*
* @param x the X screen coordinate
* @param y the Y screen coordinate
*
* @return the RGB value of the specified pixel on screen
*
* @see Robot#getPixelColor(int, int)
*/
int getRGBPixel(int x, int y);
/**
* Gets the RGB values of the specified screen area as an array.
*
* @param bounds the screen area to capture the RGB values from
*
* @return the RGB values of the specified screen area
*
* @see Robot#createScreenCapture(Rectangle)
*/
int[] getRGBPixels(Rectangle bounds);
/**
* Disposes the robot peer when it is not needed anymore.
*/
void dispose();
/**
* Returns the number of buttons that the robot simulates.
*
* @return the number of buttons that the robot simulates
*/
int getNumberOfButtons();
}
......@@ -25,8 +25,12 @@
package java.awt.peer;
import java.awt.Adjustable;
import java.awt.ScrollPane;
import java.awt.ScrollPaneAdjustable;
/**
* The peer interface for {@link ScrollPane}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
......@@ -34,10 +38,60 @@ import java.awt.Adjustable;
* instances.
*/
public interface ScrollPanePeer extends ContainerPeer {
/**
* Returns the height of the horizontal scroll bar.
*
* @return the height of the horizontal scroll bar
*
* @see ScrollPane#getHScrollbarHeight()
*/
int getHScrollbarHeight();
/**
* Returns the width of the vertical scroll bar.
*
* @return the width of the vertical scroll bar
*
* @see ScrollPane#getVScrollbarWidth()
*/
int getVScrollbarWidth();
/**
* Sets the scroll position of the child.
*
* @param x the X coordinate of the scroll position
* @param y the Y coordinate of the scroll position
*
* @see ScrollPane#setScrollPosition(int, int)
*/
void setScrollPosition(int x, int y);
/**
* Called when the child component changes its size.
*
* @param w the new width of the child component
* @param h the new height of the child component
*
* @see ScrollPane#layout()
*/
void childResized(int w, int h);
/**
* Sets the unit increment of one of the scroll pane's adjustables.
*
* @param adj the scroll pane adjustable object
* @param u the unit increment
*
* @see ScrollPaneAdjustable#setUnitIncrement(int)
*/
void setUnitIncrement(Adjustable adj, int u);
/**
* Sets the value for one of the scroll pane's adjustables.
*
* @param adj the scroll pane adjustable object
* @param v the value to set
*/
void setValue(Adjustable adj, int v);
}
......@@ -24,7 +24,11 @@
*/
package java.awt.peer;
import java.awt.Scrollbar;
/**
* The peer interface for {@link Scrollbar}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
......@@ -32,7 +36,34 @@ package java.awt.peer;
* instances.
*/
public interface ScrollbarPeer extends ComponentPeer {
/**
* Sets the parameters for the scrollbar.
*
* @param value the current value
* @param visible how much of the whole scale is visible
* @param minimum the minimum value
* @param maximum the maximum value
*
* @see Scrollbar#setValues(int, int, int, int)
*/
void setValues(int value, int visible, int minimum, int maximum);
/**
* Sets the line increment of the scrollbar.
*
* @param l the line increment
*
* @see Scrollbar#setLineIncrement(int)
*/
void setLineIncrement(int l);
/**
* Sets the page increment of the scrollbar.
*
* @param l the page increment
*
* @see Scrollbar#setPageIncrement(int)
*/
void setPageIncrement(int l);
}
......@@ -26,7 +26,20 @@
package java.awt.peer;
import java.awt.Dimension;
import java.awt.SystemTray;
/**
* The peer interface for {@link SystemTray}. This doesn't need to be
* implemented if {@link SystemTray#isSupported()} returns false.
*/
public interface SystemTrayPeer {
/**
* Returns the size of the system tray icon.
*
* @return the size of the system tray icon
*
* @see SystemTray#getTrayIconSize()
*/
Dimension getTrayIconSize();
}
......@@ -25,8 +25,11 @@
package java.awt.peer;
import java.awt.Dimension;
import java.awt.TextArea;
/**
* The peer interface for {@link TexTArea}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
......@@ -34,28 +37,52 @@ import java.awt.Dimension;
* instances.
*/
public interface TextAreaPeer extends TextComponentPeer {
void insert(String text, int pos);
void replaceRange(String text, int start, int end);
Dimension getPreferredSize(int rows, int columns);
Dimension getMinimumSize(int rows, int columns);
/**
* DEPRECATED: Replaced by insert(String, int).
* Inserts the specified text at the specified position in the document.
*
* @param text the text to insert
* @param pos the position to insert
*
* @see TextArea#insert(String, int)
*/
void insertText(String txt, int pos);
void insert(String text, int pos);
/**
* DEPRECATED: Replaced by ReplaceRange(String, int, int).
* Replaces a range of text by the specified string
*
* @param text the replacement string
* @param start the begin of the range to replace
* @param end the end of the range to replace
*
* @see TextArea#replaceRange(String, int, int)
*/
void replaceText(String txt, int start, int end);
void replaceRange(String text, int start, int end);
/**
* DEPRECATED: Replaced by getPreferredSize(int, int).
* Returns the preferred size of a textarea with the specified number of
* columns and rows.
*
* @param rows the number of rows
* @param columns the number of columns
*
* @return the preferred size of a textarea
*
* @see TextArea#getPreferredSize(int, int)
*/
Dimension preferredSize(int rows, int cols);
Dimension getPreferredSize(int rows, int columns);
/**
* DEPRECATED: Replaced by getMinimumSize(int, int).
* Returns the minimum size of a textarea with the specified number of
* columns and rows.
*
* @param rows the number of rows
* @param columns the number of columns
*
* @return the minimum size of a textarea
*
* @see TextArea#getMinimumSize(int, int)
*/
Dimension minimumSize(int rows, int cols);
Dimension getMinimumSize(int rows, int columns);
}
......@@ -24,10 +24,12 @@
*/
package java.awt.peer;
import java.awt.Rectangle;
import java.awt.TextComponent;
import java.awt.im.InputMethodRequests;
/**
* The peer interface for {@link TextComponent}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
......@@ -35,16 +37,85 @@ import java.awt.im.InputMethodRequests;
* instances.
*/
public interface TextComponentPeer extends ComponentPeer {
/**
* Sets if the text component should be editable or not.
*
* @param editable {@code true} for editable text components,
* {@code false} for non-editable text components
*
* @see TextComponent#setEditable(boolean)
*/
void setEditable(boolean editable);
/**
* Returns the current content of the text component.
*
* @return the current content of the text component
*
* @see TextComponent#getText()
*/
String getText();
/**
* Sets the content for the text component.
*
* @param l the content to set
*
* @see TextComponent#setText(String)
*/
void setText(String l);
/**
* Returns the start index of the current selection.
*
* @return the start index of the current selection
*
* @see TextComponent#getSelectionStart()
*/
int getSelectionStart();
/**
* Returns the end index of the current selection.
*
* @return the end index of the current selection
*
* @see TextComponent#getSelectionEnd()
*/
int getSelectionEnd();
/**
* Selects an area of the text component.
*
* @param selStart the start index of the new selection
* @param selEnd the end index of the new selection
*
* @see TextComponent#select(int, int)
*/
void select(int selStart, int selEnd);
/**
* Sets the caret position of the text component.
*
* @param pos the caret position to set
*
* @see TextComponent#setCaretPosition(int)
*/
void setCaretPosition(int pos);
/**
* Returns the current caret position.
*
* @return the current caret position
*
* @see TextComponent#getCaretPosition()
*/
int getCaretPosition();
int getIndexAtPoint(int x, int y);
Rectangle getCharacterBounds(int i);
long filterEvents(long mask);
/**
* Returns the input method requests.
*
* @return the input method requests
*/
InputMethodRequests getInputMethodRequests();
}
......@@ -25,8 +25,11 @@
package java.awt.peer;
import java.awt.Dimension;
import java.awt.TextField;
/**
* The peer interface for {@link TextField}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
......@@ -34,22 +37,38 @@ import java.awt.Dimension;
* instances.
*/
public interface TextFieldPeer extends TextComponentPeer {
void setEchoChar(char echoChar);
Dimension getPreferredSize(int columns);
Dimension getMinimumSize(int columns);
/**
* DEPRECATED: Replaced by setEchoChar(char echoChar).
* Sets the echo character.
*
* @param echoChar the echo character to set
*
* @see TextField#getEchoChar()
*/
void setEchoCharacter(char c);
void setEchoChar(char echoChar);
/**
* DEPRECATED: Replaced by getPreferredSize(int).
* Returns the preferred size of the text field with the specified number
* of columns.
*
* @param columns the number of columns
*
* @return the preferred size of the text field
*
* @see TextField#getPreferredSize(int)
*/
Dimension preferredSize(int cols);
Dimension getPreferredSize(int columns);
/**
* DEPRECATED: Replaced by getMinimumSize(int).
* Returns the minimum size of the text field with the specified number
* of columns.
*
* @param columns the number of columns
*
* @return the minimum size of the text field
*
* @see TextField#getMinimumSize(int)
*/
Dimension minimumSize(int cols);
Dimension getMinimumSize(int columns);
}
......@@ -25,10 +25,56 @@
package java.awt.peer;
import java.awt.SystemTray;
import java.awt.TrayIcon;
/**
* The peer interface for the {@link TrayIcon}. This doesn't need to be
* implemented if {@link SystemTray#isSupported()} returns false.
*/
public interface TrayIconPeer {
/**
* Disposes the tray icon and releases and resources held by it.
*
* @see TrayIcon#removeNotify()
*/
void dispose();
/**
* Sets the tool tip for the tray icon.
*
* @param tooltip the tooltip to set
*
* @see TrayIcon#setToolTip(String)
*/
void setToolTip(String tooltip);
/**
* Updates the icon image. This is supposed to display the current icon
* from the TrayIcon component in the actual tray icon.
*
* @see TrayIcon#setImage(java.awt.Image)
* @see TrayIcon#setImageAutoSize(boolean)
*/
void updateImage();
/**
* Displays a message at the tray icon.
*
* @param caption the message caption
* @param text the actual message text
* @param messageType the message type
*
* @see TrayIcon#displayMessage(String, String, java.awt.TrayIcon.MessageType)
*/
void displayMessage(String caption, String text, String messageType);
/**
* Shows the popup menu of this tray icon at the specified position.
*
* @param x the X location for the popup menu
* @param y the Y location for the popup menu
*/
void showPopupMenu(int x, int y);
}
......@@ -28,6 +28,8 @@ package java.awt.peer;
import java.awt.*;
/**
* The peer interface for {@link Window}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
......@@ -35,12 +37,59 @@ import java.awt.*;
* instances.
*/
public interface WindowPeer extends ContainerPeer {
/**
* Makes this window the topmost window on the desktop.
*
* @see Window#toFront()
*/
void toFront();
/**
* Makes this window the bottommost window on the desktop.
*
* @see Window#toBack()
*/
void toBack();
/**
* Sets if the window should always stay on top of all other windows or
* not.
*
* @param alwaysOnTop if the window should always stay on top of all other
* windows or not
*
* @see Window#setAlwaysOnTop(boolean)
*/
void setAlwaysOnTop(boolean alwaysOnTop);
/**
* Updates the window's focusable state.
*
* @see Window#setFocusableWindowState(boolean)
*/
void updateFocusableWindowState();
boolean requestWindowFocus();
/**
* Sets if this window is blocked by a modal dialog or not.
*
* @param blocker the blocking modal dialog
* @param blocked {@code true} to block the window, {@code false}
* to unblock it
*/
void setModalBlocked(Dialog blocker, boolean blocked);
/**
* Updates the minimum size on the peer.
*
* @see Window#setMinimumSize(Dimension)
*/
void updateMinimumSize();
/**
* Updates the icons for the window.
*
* @see Window#setIconImages(java.util.List)
*/
void updateIconImages();
}
......@@ -34,6 +34,7 @@ import javax.swing.plaf.RootPaneUI;
import java.util.Vector;
import java.io.Serializable;
import javax.swing.border.*;
import sun.awt.AWTAccessor;
import sun.security.action.GetBooleanAction;
......@@ -688,6 +689,9 @@ public class JRootPane extends JComponent implements Accessible {
throw new NullPointerException("glassPane cannot be set to null.");
}
AWTAccessor.getComponentAccessor().setMixingCutoutShape(glass,
new Rectangle());
boolean visible = false;
if (glassPane != null && glassPane.getParent() == this) {
this.remove(glassPane);
......
/*
* Copyright 1996-2003 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2009 Sun Microsystems, Inc. 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,28 +23,55 @@
* have any questions.
*/
/*
* Unicode to ANSI string conversion macros, based on a slide from a
* presentation by Asmus Freytag. These must be macros, since the
* alloca() has to be in the caller's stack space.
package sun.awt;
import java.awt.*;
import sun.misc.Unsafe;
/** The AWTAccessor utility class.
* The main purpose of this class is to enable accessing
* private and package-private fields of classes from
* different classes/packages. See sun.misc.SharedSecretes
* for another example.
*/
public final class AWTAccessor {
private static final Unsafe unsafe = Unsafe.getUnsafe();
#ifndef AWT_UNICODE_H
#define AWT_UNICODE_H
/** We don't need any objects of this class.
* It's rather a collection of static methods
* and interfaces.
*/
private AWTAccessor() {
}
#include <malloc.h>
/** An accessor for the java.awt.Component class.
*/
public interface ComponentAccessor {
// See 6797587
// Also see: 6776743, 6768307, and 6768332.
/**
* Sets the shape of a lw component to cut out from hw components.
*/
void setMixingCutoutShape(Component comp, Shape shape);
}
// Get a Unicode string copy of a Java String object (Java String aren't
// null-terminated).
extern LPWSTR J2WHelper(LPWSTR lpw, LPWSTR lpj, int nChars);
extern LPWSTR J2WHelper1(LPWSTR lpw, LPWSTR lpj, int offset, int nChars);
/* The java.awt.Component class accessor object.
*/
private static ComponentAccessor componentAccessor;
extern LPWSTR JNI_J2WHelper1(JNIEnv *env, LPWSTR lpw, jstring jstr);
/** Set an accessor object for the java.awt.Component class.
*/
public static void setComponentAccessor(ComponentAccessor ca) {
componentAccessor = ca;
}
#define TO_WSTRING(jstr) \
((jstr == NULL) ? NULL : \
(JNI_J2WHelper1(env, (LPWSTR) alloca((env->GetStringLength(jstr)+1)*2), \
jstr) \
))
/** Retrieve the accessor object for the java.awt.Window class.
*/
public static ComponentAccessor getComponentAccessor() {
if (componentAccessor == null) {
unsafe.ensureClassInitialized(Component.class);
}
#endif // AWT_UNICODE_H
return componentAccessor;
}
}
/*
* Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2000-2008 Sun Microsystems, Inc. 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
......@@ -456,6 +456,10 @@ public class HeadlessToolkit extends Toolkit
return tk.getAWTEventListeners();
}
public AWTEventListener[] getAWTEventListeners(long eventMask) {
return tk.getAWTEventListeners(eventMask);
}
public boolean isDesktopSupported() {
return false;
}
......@@ -464,4 +468,8 @@ public class HeadlessToolkit extends Toolkit
throws HeadlessException{
throw new HeadlessException();
}
public boolean areExtraMouseButtonsEnabled() throws HeadlessException{
throw new HeadlessException();
}
}
......@@ -1972,6 +1972,21 @@ public abstract class SunToolkit extends Toolkit
AWTAutoShutdown.getInstance().dumpPeers(aLog);
}
private static Boolean sunAwtDisableMixing = null;
/**
* Returns the value of "sun.awt.disableMixing" property. Default
* value is {@code false}.
*/
public synchronized static boolean getSunAwtDisableMixing() {
if (sunAwtDisableMixing == null) {
sunAwtDisableMixing = Boolean.valueOf(
AccessController.doPrivileged(
new GetBooleanAction("sun.awt.disableMixing")));
}
return sunAwtDisableMixing.booleanValue();
}
/**
* Returns true if the native GTK libraries are available. The
* default implementation returns false, but UNIXToolkit overrides this
......@@ -2008,26 +2023,12 @@ class PostEventQueue {
/*
* Continually post pending AWTEvents to the Java EventQueue.
*/
public void flush() {
if (queueHead != null) {
EventQueueItem tempQueue;
/*
* We have to execute the loop inside the synchronized block
* to ensure that the flush is completed before a new event
* can be posted to this queue.
*/
synchronized (this) {
tempQueue = queueHead;
queueHead = queueTail = null;
/*
* If this PostEventQueue is flushed in parallel on two
* different threads tempQueue will be null for one of them.
*/
while (tempQueue != null) {
eventQueue.postEvent(tempQueue.event);
tempQueue = tempQueue.next;
}
}
public synchronized void flush() {
EventQueueItem tempQueue = queueHead;
queueHead = queueTail = null;
while (tempQueue != null) {
eventQueue.postEvent(tempQueue.event);
tempQueue = tempQueue.next;
}
}
......
......@@ -28,6 +28,7 @@ package sun.java2d.pipe;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.RectangularShape;
/**
* This class encapsulates a definition of a two dimensional region which
......@@ -63,11 +64,28 @@ public class Region {
static final int INIT_SIZE = 50;
static final int GROW_SIZE = 50;
static final Region EMPTY_REGION = new Region(0, 0, 0, 0);
static final Region WHOLE_REGION = new Region(Integer.MIN_VALUE,
Integer.MIN_VALUE,
Integer.MAX_VALUE,
Integer.MAX_VALUE);
/**
* Immutable Region.
*/
private static final class ImmutableRegion extends Region {
protected ImmutableRegion(int lox, int loy, int hix, int hiy) {
super(lox, loy, hix, hiy);
}
// Override all the methods that mutate the object
public void appendSpans(sun.java2d.pipe.SpanIterator si) {}
public void setOutputArea(java.awt.Rectangle r) {}
public void setOutputAreaXYWH(int x, int y, int w, int h) {}
public void setOutputArea(int[] box) {}
public void setOutputAreaXYXY(int lox, int loy, int hix, int hiy) {}
}
public static final Region EMPTY_REGION = new ImmutableRegion(0, 0, 0, 0);
public static final Region WHOLE_REGION = new ImmutableRegion(
Integer.MIN_VALUE,
Integer.MIN_VALUE,
Integer.MAX_VALUE,
Integer.MAX_VALUE);
int lox;
int loy;
......@@ -113,7 +131,7 @@ public class Region {
return newv;
}
private Region(int lox, int loy, int hix, int hiy) {
protected Region(int lox, int loy, int hix, int hiy) {
this.lox = lox;
this.loy = loy;
this.hix = hix;
......@@ -194,6 +212,13 @@ public class Region {
public static Region getInstance(Region devBounds, boolean normalize,
Shape s, AffineTransform at)
{
// Optimize for empty shapes to avoid involving the SpanIterator
if (s instanceof RectangularShape &&
((RectangularShape)s).isEmpty())
{
return EMPTY_REGION;
}
int box[] = new int[4];
ShapeSpanIterator sr = new ShapeSpanIterator(normalize);
try {
......@@ -1206,7 +1231,7 @@ public class Region {
return false;
}
if (r.lox != this.lox || r.loy != this.loy ||
r.hiy != this.hiy || r.hiy != this.hiy)
r.hix != this.hix || r.hiy != this.hiy)
{
return false;
}
......
......@@ -32,10 +32,18 @@ class WindowDimensions {
private Insets insets;
private boolean isClientSizeSet;
/**
* If isClient is true, the bounds represent the client window area.
* Otherwise, they represent the entire window area, with the insets included
*/
public WindowDimensions(int x, int y, int width, int height, boolean isClient) {
this(new Rectangle(x, y, width, height), null, isClient);
}
/**
* If isClient is true, the bounds represent the client window area.
* Otherwise, they represent the entire window area, with the insets included
*/
public WindowDimensions(Rectangle rec, Insets ins, boolean isClient) {
if (rec == null) {
throw new IllegalArgumentException("Client bounds can't be null");
......@@ -46,10 +54,18 @@ class WindowDimensions {
setInsets(ins);
}
/**
* If isClient is true, the bounds represent the client window area.
* Otherwise, they represent the entire window area, with the insets included
*/
public WindowDimensions(Point loc, Dimension size, Insets in, boolean isClient) {
this(new Rectangle(loc, size), in, isClient);
}
/**
* If isClient is true, the bounds represent the client window area.
* Otherwise, they represent the entire window area, with the insets included
*/
public WindowDimensions(Rectangle bounds, boolean isClient) {
this(bounds, null, isClient);
}
......
......@@ -979,8 +979,13 @@ public class XBaseWindow {
*/
public void handleButtonPressRelease(XEvent xev) {
XButtonEvent xbe = xev.get_xbutton();
final int buttonState = xbe.get_state() & (XConstants.Button1Mask | XConstants.Button2Mask
| XConstants.Button3Mask | XConstants.Button4Mask | XConstants.Button5Mask);
int buttonState = 0;
for (int i = 0; i<XToolkit.getNumMouseButtons(); i++){
// A bug in WM implementation: extra buttons doesn't have state!=0 as they should on Release message.
if ((i != 4) && (i != 5)){
buttonState |= (xbe.get_state() & XConstants.buttonsMask[i]);
}
}
switch (xev.get_type()) {
case XConstants.ButtonPress:
if (buttonState == 0) {
......@@ -1011,19 +1016,11 @@ public class XBaseWindow {
* Checks ButtonRelease released all Mouse buttons
*/
static boolean isFullRelease(int buttonState, int button) {
switch (button) {
case XConstants.Button1:
return buttonState == XConstants.Button1Mask;
case XConstants.Button2:
return buttonState == XConstants.Button2Mask;
case XConstants.Button3:
return buttonState == XConstants.Button3Mask;
case XConstants.Button4:
return buttonState == XConstants.Button4Mask;
case XConstants.Button5:
return buttonState == XConstants.Button5Mask;
if (button < 0 || button > XToolkit.getNumMouseButtons()) {
return buttonState == 0;
} else {
return buttonState == XConstants.buttonsMask[button - 1];
}
return buttonState == 0;
}
static boolean isGrabbedEvent(XEvent ev, XBaseWindow target) {
......
......@@ -1534,13 +1534,23 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
}
XToolkit.awtLock();
try {
XlibWrapper.SetRectangularShape(
XToolkit.getDisplay(),
getWindow(),
shape.getLoX(), shape.getLoY(),
shape.getHiX(), shape.getHiY(),
(shape.isRectangular() ? null : shape)
);
if (shape != null) {
XlibWrapper.SetRectangularShape(
XToolkit.getDisplay(),
getWindow(),
shape.getLoX(), shape.getLoY(),
shape.getHiX(), shape.getHiY(),
(shape.isRectangular() ? null : shape)
);
} else {
XlibWrapper.SetRectangularShape(
XToolkit.getDisplay(),
getWindow(),
0, 0,
0, 0,
null
);
}
} finally {
XToolkit.awtUnlock();
}
......
......@@ -197,12 +197,30 @@ final public class XConstants {
/* button masks. Used in same manner as Key masks above. Not to be confused
with button names below. */
public static final int Button1Mask = (1<<8) ;
public static final int Button2Mask = (1<<9) ;
public static final int Button3Mask = (1<<10) ;
public static final int Button4Mask = (1<<11) ;
public static final int Button5Mask = (1<<12) ;
public static final int [] buttonsMask = new int []{ 1<<8,
1<<9,
1<<10,
1<<11,
1<<12,
1<<13,
1<<14,
1<<15,
1<<16,
1<<17,
1<<18,
1<<19,
1<<20,
1<<21,
1<<22,
1<<23,
1<<24,
1<<25,
1<<26,
1<<27,
1<<28,
1<<29,
1<<30,
1<<31 };
public static final int AnyModifier = (1<<15) ; /* used in GrabButton, GrabKey */
......@@ -211,11 +229,7 @@ final public class XConstants {
and ButtonRelease events. Not to be confused with button masks above.
Note that 0 is already defined above as "AnyButton". */
public static final int Button1 = 1 ;
public static final int Button2 = 2 ;
public static final int Button3 = 3 ;
public static final int Button4 = 4 ;
public static final int Button5 = 5 ;
public static final int buttons [] = new int [] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
/* Notify modes */
......
......@@ -492,7 +492,14 @@ abstract class XDecoratedPeer extends XWindowPeer {
// do nothing but accept it.
Rectangle reqBounds = newDimensions.getBounds();
Rectangle newBounds = constrainBounds(reqBounds.x, reqBounds.y, reqBounds.width, reqBounds.height);
newDimensions = new WindowDimensions(newBounds, newDimensions.getInsets(), newDimensions.isClientSizeSet());
Insets insets = newDimensions.getInsets();
// Inherit isClientSizeSet from newDimensions
if (newDimensions.isClientSizeSet()) {
newBounds = new Rectangle(newBounds.x, newBounds.y,
newBounds.width - insets.left - insets.right,
newBounds.height - insets.top - insets.bottom);
}
newDimensions = new WindowDimensions(newBounds, insets, newDimensions.isClientSizeSet());
}
XToolkit.awtLock();
try {
......
......@@ -694,8 +694,8 @@ public final class XDragSourceContextPeer
} finally {
xmotion.dispose();
}
if (xbutton.get_button() == XConstants.Button1
|| xbutton.get_button() == XConstants.Button2) {
if (xbutton.get_button() == XConstants.buttons[0]
|| xbutton.get_button() == XConstants.buttons[1]) {
// drag is initiated with Button1 or Button2 pressed and
// ended on release of either of these buttons (as the same
// behavior was with our old Motif DnD-based implementation)
......
......@@ -31,6 +31,9 @@ import sun.awt.SunToolkit;
import java.awt.Component;
import java.awt.Container;
import sun.awt.X11GraphicsConfig;
import sun.awt.X11GraphicsDevice;
/**
* Helper class implementing XEmbed protocol handling routines(client side)
* Window which wants to participate in a protocol should create an instance,
......@@ -39,20 +42,34 @@ import java.awt.Container;
public class XEmbedClientHelper extends XEmbedHelper implements XEventDispatcher {
private static final Logger xembedLog = Logger.getLogger("sun.awt.X11.xembed.XEmbedClientHelper");
private XEmbeddedFramePeer embedded;
private XEmbeddedFramePeer embedded; // XEmbed client
private long server; // XEmbed server
private boolean active;
private long server;
private boolean applicationActive;
XEmbedClientHelper() {
super();
}
void install(XEmbeddedFramePeer embedded) {
this.embedded = embedded;
void setClient(XEmbeddedFramePeer client) {
if (xembedLog.isLoggable(Level.FINE)) {
xembedLog.fine("XEmbed client: " + client);
}
if (embedded != null) {
XToolkit.removeEventDispatcher(embedded.getWindow(), this);
active = false;
}
embedded = client;
if (embedded != null) {
XToolkit.addEventDispatcher(embedded.getWindow(), this);
}
}
if (xembedLog.isLoggable(Level.FINE)) xembedLog.fine("Installing xembedder on " + embedded);
XToolkit.addEventDispatcher(embedded.getWindow(), this);
void install() {
if (xembedLog.isLoggable(Level.FINE)) {
xembedLog.fine("Installing xembedder on " + embedded);
}
long[] info = new long[] { XEMBED_VERSION, XEMBED_MAPPED };
long data = Native.card32ToData(info);
try {
......@@ -155,7 +172,24 @@ public class XEmbedClientHelper extends XEmbedHelper implements XEventDispatcher
}
public void handleReparentNotify(XEvent xev) {
XReparentEvent re = xev.get_xreparent();
server = re.get_parent();
long newParent = re.get_parent();
if (active) {
// unregister accelerators, etc. for old parent
embedded.notifyStopped();
// check if newParent is a root window
X11GraphicsConfig gc = (X11GraphicsConfig)embedded.getGraphicsConfiguration();
X11GraphicsDevice gd = (X11GraphicsDevice)gc.getDevice();
if ((newParent == XlibUtil.getRootWindow(gd.getScreen())) ||
(newParent == XToolkit.getDefaultRootWindow()))
{
// reparenting to root means XEmbed termination
active = false;
} else {
// continue XEmbed with a new parent
server = newParent;
embedded.notifyStarted();
}
}
}
boolean requestFocus() {
if (active && embedded.focusAllowedFor()) {
......@@ -201,12 +235,16 @@ public class XEmbedClientHelper extends XEmbedHelper implements XEventDispatcher
}
void registerAccelerator(AWTKeyStroke stroke, int id) {
long sym = getX11KeySym(stroke);
long mods = getX11Mods(stroke);
sendMessage(server, XEMBED_REGISTER_ACCELERATOR, id, sym, mods);
if (active) {
long sym = getX11KeySym(stroke);
long mods = getX11Mods(stroke);
sendMessage(server, XEMBED_REGISTER_ACCELERATOR, id, sym, mods);
}
}
void unregisterAccelerator(int id) {
sendMessage(server, XEMBED_UNREGISTER_ACCELERATOR, id, 0, 0);
if (active) {
sendMessage(server, XEMBED_UNREGISTER_ACCELERATOR, id, 0, 0);
}
}
long getX11KeySym(AWTKeyStroke stroke) {
......
......@@ -63,7 +63,10 @@ public class XEmbeddedFramePeer extends XFramePeer {
void postInit(XCreateWindowParams params) {
super.postInit(params);
if (embedder != null) {
embedder.install(this);
// install X11 event dispatcher
embedder.setClient(this);
// reparent to XEmbed server
embedder.install();
} else if (getParentWindowHandle() != 0) {
XToolkit.awtLock();
try {
......@@ -77,6 +80,15 @@ public class XEmbeddedFramePeer extends XFramePeer {
}
}
@Override
public void dispose() {
if (embedder != null) {
// uninstall X11 event dispatcher
embedder.setClient(null);
}
super.dispose();
}
public void updateMinimumSize() {
}
......@@ -249,6 +261,14 @@ public class XEmbeddedFramePeer extends XFramePeer {
// XEmbed.
updateDropTarget();
}
void notifyStopped() {
if (embedder != null && embedder.isActive()) {
for (int i = strokes.size() - 1; i >= 0; i--) {
embedder.unregisterAccelerator(i);
}
}
}
long getFocusTargetWindow() {
return getWindow();
}
......
......@@ -63,6 +63,8 @@ public class XKeysym {
// TODO: or not to do: add reverse lookup javakeycode2keysym,
// for robot only it seems to me. After that, we can remove lookup table
// from XWindow.c altogether.
// Another use for reverse lookup: query keyboard state, for some keys.
static Hashtable<Integer, Long> javaKeycode2KeysymHash = new Hashtable<Integer, Long>();
static long keysym_lowercase = unsafe.allocateMemory(Native.getLongSize());
static long keysym_uppercase = unsafe.allocateMemory(Native.getLongSize());
public static char convertKeysym( long ks, int state ) {
......@@ -196,6 +198,10 @@ public class XKeysym {
Keysym2JavaKeycode jkc = getJavaKeycode( ev );
return jkc == null ? java.awt.event.KeyEvent.VK_UNDEFINED : jkc.getJavaKeycode();
}
static long javaKeycode2Keysym( int jkey ) {
Long ks = javaKeycode2KeysymHash.get( jkey );
return (ks == null ? 0 : ks.longValue());
}
/**
Return keysym derived from a keycode and modifiers.
Usually an input method does this. However non-system input methods (e.g. Java IMs) do not.
......@@ -1583,6 +1589,14 @@ public class XKeysym {
keysym2JavaKeycodeHash.put( Long.valueOf(XKeySymConstants.hpXK_mute_asciitilde), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_DEAD_TILDE, java.awt.event.KeyEvent.KEY_LOCATION_STANDARD));
keysym2JavaKeycodeHash.put( Long.valueOf(XConstants.NoSymbol), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_UNDEFINED, java.awt.event.KeyEvent.KEY_LOCATION_UNKNOWN));
/* Reverse search of keysym by keycode. */
/* Add keyboard locking codes. */
javaKeycode2KeysymHash.put( java.awt.event.KeyEvent.VK_CAPS_LOCK, XKeySymConstants.XK_Caps_Lock);
javaKeycode2KeysymHash.put( java.awt.event.KeyEvent.VK_NUM_LOCK, XKeySymConstants.XK_Num_Lock);
javaKeycode2KeysymHash.put( java.awt.event.KeyEvent.VK_SCROLL_LOCK, XKeySymConstants.XK_Scroll_Lock);
javaKeycode2KeysymHash.put( java.awt.event.KeyEvent.VK_KANA_LOCK, XKeySymConstants.XK_Kana_Lock);
};
}
/*
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2003-2008 Sun Microsystems, Inc. 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
......@@ -81,11 +81,16 @@ class XRobotPeer implements RobotPeer {
return pixelArray;
}
public int getNumberOfButtons(){
return getNumberOfButtonsImpl();
}
private static native synchronized void setup();
private static native synchronized void mouseMoveImpl(X11GraphicsConfig xgc, int x, int y);
private static native synchronized void mousePressImpl(int buttons);
private static native synchronized void mouseReleaseImpl(int buttons);
private static native synchronized int getNumberOfButtonsImpl();
private static native synchronized void mouseWheelImpl(int wheelAmt);
private static native synchronized void keyPressImpl(int keycode);
......
......@@ -27,6 +27,7 @@ package sun.awt.X11;
import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.awt.event.KeyEvent;
import java.awt.datatransfer.Clipboard;
import java.awt.dnd.DragSource;
import java.awt.dnd.DragGestureListener;
......@@ -61,6 +62,10 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
private static Logger keyEventLog = Logger.getLogger("sun.awt.X11.kye.XToolkit");
private static final Logger backingStoreLog = Logger.getLogger("sun.awt.X11.backingStore.XToolkit");
//There is 400 ms is set by default on Windows and 500 by default on KDE and GNOME.
//We use the same hardcoded constant.
private final static int AWT_MULTICLICK_DEFAULT_TIME = 500;
static final boolean PRIMARY_LOOP = false;
static final boolean SECONDARY_LOOP = true;
......@@ -74,6 +79,25 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
// Dynamic Layout Resize client code setting
protected static boolean dynamicLayoutSetting = false;
//Is it allowed to generate events assigned to extra mouse buttons.
//Set to true by default.
private static boolean areExtraMouseButtonsEnabled = true;
/**
* Number of buttons.
* By default it's taken from the system. If system value does not
* fit into int type range, use our own MAX_BUTTONS_SUPPORT value.
*/
private static int numberOfButtons = 0;
/* XFree standard mention 24 buttons as maximum:
* http://www.xfree86.org/current/mouse.4.html
* We workaround systems supporting more than 24 buttons.
* Otherwise, we have to use long type values as masks
* which leads to API change.
*/
private static int MAX_BUTTONS_SUPPORT = 24;
/**
* True when the x settings have been loaded.
*/
......@@ -273,6 +297,9 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
arrowCursor = XlibWrapper.XCreateFontCursor(XToolkit.getDisplay(),
XCursorFontConstants.XC_arrow);
areExtraMouseButtonsEnabled = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons", "true"));
//set system property if not yet assigned
System.setProperty("sun.awt.enableExtraMouseButtons", ""+areExtraMouseButtonsEnabled);
} finally {
awtUnlock();
}
......@@ -1080,6 +1107,19 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
public Map mapInputMethodHighlight(InputMethodHighlight highlight) {
return XInputMethod.mapInputMethodHighlight(highlight);
}
@Override
public boolean getLockingKeyState(int key) {
if (! (key == KeyEvent.VK_CAPS_LOCK || key == KeyEvent.VK_NUM_LOCK ||
key == KeyEvent.VK_SCROLL_LOCK || key == KeyEvent.VK_KANA_LOCK)) {
throw new IllegalArgumentException("invalid key for Toolkit.getLockingKeyState");
}
awtLock();
try {
return getModifierState( key );
} finally {
awtUnlock();
}
}
public Clipboard getSystemClipboard() {
SecurityManager security = System.getSecurityManager();
......@@ -1216,7 +1256,6 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
String multiclick_time_query = XlibWrapper.XGetDefault(XToolkit.getDisplay(), "*", "multiClickTime");
if (multiclick_time_query != null) {
awt_multiclick_time = (int)Long.parseLong(multiclick_time_query);
// awt_multiclick_time = XtGetMultiClickTime(awt_display);
} else {
multiclick_time_query = XlibWrapper.XGetDefault(XToolkit.getDisplay(),
"OpenWindows", "MultiClickTimeout");
......@@ -1226,20 +1265,19 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
milliseconds */
awt_multiclick_time = (int)Long.parseLong(multiclick_time_query) * 100;
} else {
awt_multiclick_time = 200;
// awt_multiclick_time = XtGetMultiClickTime(awt_display);
awt_multiclick_time = AWT_MULTICLICK_DEFAULT_TIME;
}
}
} catch (NumberFormatException nf) {
awt_multiclick_time = 200;
awt_multiclick_time = AWT_MULTICLICK_DEFAULT_TIME;
} catch (NullPointerException npe) {
awt_multiclick_time = 200;
awt_multiclick_time = AWT_MULTICLICK_DEFAULT_TIME;
}
} finally {
awtUnlock();
}
if (awt_multiclick_time == 0) {
awt_multiclick_time = 200;
awt_multiclick_time = AWT_MULTICLICK_DEFAULT_TIME;
}
}
......@@ -1383,10 +1421,15 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
}
}
private int getNumMouseButtons() {
public static int getNumMouseButtons() {
awtLock();
try {
return XlibWrapper.XGetPointerMapping(XToolkit.getDisplay(), 0, 0);
if (numberOfButtons == 0) {
numberOfButtons = Math.min(
XlibWrapper.XGetPointerMapping(XToolkit.getDisplay(), 0, 0),
MAX_BUTTONS_SUPPORT);
}
return numberOfButtons;
} finally {
awtUnlock();
}
......@@ -1542,6 +1585,66 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
awtUnlock();
}
}
static boolean getModifierState( int jkc ) {
int iKeyMask = 0;
long ks = XKeysym.javaKeycode2Keysym( jkc );
int kc = XlibWrapper.XKeysymToKeycode(getDisplay(), ks);
if (kc == 0) {
return false;
}
awtLock();
try {
XModifierKeymap modmap = new XModifierKeymap(
XlibWrapper.XGetModifierMapping(getDisplay()));
int nkeys = modmap.get_max_keypermod();
long map_ptr = modmap.get_modifiermap();
for( int k = 0; k < 8; k++ ) {
for (int i = 0; i < nkeys; ++i) {
int keycode = Native.getUByte(map_ptr, k * nkeys + i);
if (keycode == 0) {
continue; // ignore zero keycode
}
if (kc == keycode) {
iKeyMask = 1 << k;
break;
}
}
if( iKeyMask != 0 ) {
break;
}
}
XlibWrapper.XFreeModifiermap(modmap.pData);
if (iKeyMask == 0 ) {
return false;
}
// Now we know to which modifier is assigned the keycode
// correspondent to the keysym correspondent to the java
// keycode. We are going to check a state of this modifier.
// If a modifier is a weird one, we cannot help it.
long window = 0;
try{
// get any application window
window = ((Long)(winMap.firstKey())).longValue();
}catch(NoSuchElementException nex) {
// get root window
window = getDefaultRootWindow();
}
boolean res = XlibWrapper.XQueryPointer(getDisplay(), window,
XlibWrapper.larg1, //root
XlibWrapper.larg2, //child
XlibWrapper.larg3, //root_x
XlibWrapper.larg4, //root_y
XlibWrapper.larg5, //child_x
XlibWrapper.larg6, //child_y
XlibWrapper.larg7);//mask
int mask = Native.getInt(XlibWrapper.larg7);
return ((mask & iKeyMask) != 0);
} finally {
awtUnlock();
}
}
/* Assign meaning - alt, meta, etc. - to X modifiers mod1 ... mod5.
* Only consider primary symbols on keycodes attached to modifiers.
......@@ -2166,4 +2269,8 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
}
public static native void setNoisyXErrorHandler();
public boolean areExtraMouseButtonsEnabled() throws HeadlessException {
return areExtraMouseButtonsEnabled;
}
}
......@@ -553,6 +553,10 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
}
static int getModifiers(int state, int button, int keyCode) {
return getModifiers(state, button, keyCode, 0, false);
}
static int getModifiers(int state, int button, int keyCode, int type, boolean wheel_mouse) {
int modifiers = 0;
if (((state & XConstants.ShiftMask) != 0) ^ (keyCode == KeyEvent.VK_SHIFT)) {
......@@ -570,14 +574,23 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
if (((state & XToolkit.modeSwitchMask) != 0) ^ (keyCode == KeyEvent.VK_ALT_GRAPH)) {
modifiers |= InputEvent.ALT_GRAPH_DOWN_MASK;
}
if (((state & XConstants.Button1Mask) != 0) ^ (button == MouseEvent.BUTTON1)) {
modifiers |= InputEvent.BUTTON1_DOWN_MASK;
}
if (((state & XConstants.Button2Mask) != 0) ^ (button == MouseEvent.BUTTON2)) {
modifiers |= InputEvent.BUTTON2_DOWN_MASK;
}
if (((state & XConstants.Button3Mask) != 0) ^ (button == MouseEvent.BUTTON3)) {
modifiers |= InputEvent.BUTTON3_DOWN_MASK;
//InputEvent.BUTTON_DOWN_MASK array is starting from BUTTON1_DOWN_MASK on index == 0.
// button currently reflects a real button number and starts from 1. (except NOBUTTON which is zero )
/* this is an attempt to refactor button IDs in : MouseEvent, InputEvent, XlibWrapper and XWindow.*/
//reflects a button number similar to MouseEvent.BUTTON1, 2, 3 etc.
for (int i = 0; i < XConstants.buttonsMask.length; i ++){
//modifier should be added if :
// 1) current button is now still in PRESSED state (means that user just pressed mouse but not released yet) or
// 2) if Xsystem reports that "state" represents that button was just released. This only happens on RELEASE with 1,2,3 buttons.
// ONLY one of these conditions should be TRUE to add that modifier.
if (((state & XConstants.buttonsMask[i]) != 0) != (button == XConstants.buttons[i])){
//exclude wheel buttons from adding their numbers as modifiers
if (!wheel_mouse) {
modifiers |= InputEvent.getMaskForButton(i+1);
}
}
}
return modifiers;
}
......@@ -603,17 +616,6 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
return res;
}
private static int getButtonMask(long mouseButton) {
if (mouseButton == XConstants.Button1) {
return XConstants.Button1Mask;
} else if (mouseButton == XConstants.Button2) {
return XConstants.Button2Mask;
} else if (mouseButton == XConstants.Button3) {
return XConstants.Button3Mask;
}
return 0;
}
/**
* Returns true if this event is disabled and shouldn't be passed to Java.
* Default implementation returns false for all events.
......@@ -648,7 +650,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
boolean popupTrigger = false;
int button=0;
boolean wheel_mouse = false;
long lbutton = xbe.get_button();
int lbutton = xbe.get_button();
int type = xev.get_type();
when = xbe.get_time();
long jWhen = XToolkit.nowMillisUTC_offset(when);
......@@ -663,7 +665,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
if (type == XConstants.ButtonPress) {
//Allow this mouse button to generate CLICK event on next ButtonRelease
mouseButtonClickAllowed |= getButtonMask(lbutton);
mouseButtonClickAllowed |= XConstants.buttonsMask[lbutton];
XWindow lastWindow = (lastWindowRef != null) ? ((XWindow)lastWindowRef.get()):(null);
/*
multiclick checking
......@@ -693,21 +695,22 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
}
}
if (lbutton == XConstants.Button1)
button = MouseEvent.BUTTON1;
else if (lbutton == XConstants.Button2 )
button = MouseEvent.BUTTON2;
else if (lbutton == XConstants.Button3)
button = MouseEvent.BUTTON3;
else if (lbutton == XConstants.Button4) {
button = 4;
wheel_mouse = true;
} else if (lbutton == XConstants.Button5) {
button = 5;
button = XConstants.buttons[lbutton - 1];
// 4 and 5 buttons are usually considered assigned to a first wheel
if (lbutton == XConstants.buttons[3] ||
lbutton == XConstants.buttons[4]) {
wheel_mouse = true;
}
modifiers = getModifiers(xbe.get_state(),button,0);
// mapping extra buttons to numbers starting from 4.
if ((button > XConstants.buttons[4]) && (!Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled())){
return;
}
if (button > XConstants.buttons[4]){
button -= 2;
}
modifiers = getModifiers(xbe.get_state(),button,0, type, wheel_mouse);
if (!wheel_mouse) {
MouseEvent me = new MouseEvent((Component)getEventSource(),
......@@ -720,7 +723,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
postEventToEventQueue(me);
if ((type == XConstants.ButtonRelease) &&
((mouseButtonClickAllowed & getButtonMask(lbutton)) != 0) ) // No up-button in the drag-state
((mouseButtonClickAllowed & XConstants.buttonsMask[lbutton]) != 0) ) // No up-button in the drag-state
{
postEventToEventQueue(me = new MouseEvent((Component)getEventSource(),
MouseEvent.MOUSE_CLICKED,
......@@ -750,7 +753,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
/* Update the state variable AFTER the CLICKED event post. */
if (type == XConstants.ButtonRelease) {
/* Exclude this mouse button from allowed list.*/
mouseButtonClickAllowed &= ~getButtonMask(lbutton);
mouseButtonClickAllowed &= ~XConstants.buttonsMask[lbutton];
}
}
......@@ -761,7 +764,19 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
return;
}
int mouseKeyState = (xme.get_state() & (XConstants.Button1Mask | XConstants.Button2Mask | XConstants.Button3Mask));
int mouseKeyState = 0; //(xme.get_state() & (XConstants.buttonsMask[0] | XConstants.buttonsMask[1] | XConstants.buttonsMask[2]));
//this doesn't work for extra buttons because Xsystem is sending state==0 for every extra button event.
// we can't correct it in MouseEvent class as we done it with modifiers, because exact type (DRAG|MOVE)
// should be passed from XWindow.
//TODO: eliminate it with some other value obtained w/o AWTLock.
for (int i = 0; i < XToolkit.getNumMouseButtons(); i++){
// TODO : here is the bug in WM: extra buttons doesn't have state!=0 as they should.
if ((i != 4) && (i != 5)) {
mouseKeyState = mouseKeyState | (xme.get_state() & XConstants.buttonsMask[i]);
}
}
boolean isDragging = (mouseKeyState != 0);
int mouseEventType = 0;
......
......@@ -1936,7 +1936,13 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
new Object[] {xme, isGrabbed(), containsGlobal(xme.get_x_root(), xme.get_y_root())});
}
if (isGrabbed()) {
boolean dragging = (xme.get_state() & (XConstants.Button1Mask | XConstants.Button2Mask | XConstants.Button3Mask)) != 0;
boolean dragging = false;
for (int i = 0; i<XToolkit.getNumMouseButtons(); i++){
// here is the bug in WM: extra buttons doesn't have state!=0 as they should.
if ((i != 4) && (i != 5)){
dragging = dragging || ((xme.get_state() & XConstants.buttonsMask[i]) != 0);
}
}
// When window is grabbed, all events are dispatched to
// it. Retarget them to the corresponding windows (notice
// that XBaseWindow.dispatchEvent does the opposite
......@@ -1990,12 +1996,12 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
try {
grabLog.log(Level.FINER, " - Grab event target {0} (press target {1})", new Object[] {target, pressTarget});
if (xbe.get_type() == XConstants.ButtonPress
&& xbe.get_button() == XConstants.Button1)
&& xbe.get_button() == XConstants.buttons[0])
{
// need to keep it to retarget mouse release
pressTarget = target;
} else if (xbe.get_type() == XConstants.ButtonRelease
&& xbe.get_button() == XConstants.Button1
&& xbe.get_button() == XConstants.buttons[0]
&& pressTarget != target)
{
// during grab we do receive mouse release on different component (not on the source
......
......@@ -485,6 +485,7 @@ static native String XSetLocaleModifiers(String modifier_list);
static native int XdbeEndIdiom(long display);
static native int XdbeSwapBuffers(long display, long swap_info, int num_windows);
static native void XQueryKeymap(long display, long vector);
static native long XKeycodeToKeysym(long display, int keycode, int index);
static native int XKeysymToKeycode(long display, long keysym);
......
......@@ -101,6 +101,8 @@ tojava static Hashtable<Long, Long> uppercaseHash = new Hashtable<Long, Long
tojava // TODO: or not to do: add reverse lookup javakeycode2keysym,
tojava // for robot only it seems to me. After that, we can remove lookup table
tojava // from XWindow.c altogether.
tojava // Another use for reverse lookup: query keyboard state, for some keys.
tojava static Hashtable<Integer, Long> javaKeycode2KeysymHash = new Hashtable<Integer, Long>();
tojava static long keysym_lowercase = unsafe.allocateMemory(Native.getLongSize());
tojava static long keysym_uppercase = unsafe.allocateMemory(Native.getLongSize());
tojava public static char convertKeysym( long ks, int state ) {
......@@ -234,6 +236,10 @@ tojava static int getJavaKeycodeOnly( XKeyEvent ev ) {
tojava Keysym2JavaKeycode jkc = getJavaKeycode( ev );
tojava return jkc == null ? java.awt.event.KeyEvent.VK_UNDEFINED : jkc.getJavaKeycode();
tojava }
tojava static long javaKeycode2Keysym( int jkey ) {
tojava Long ks = javaKeycode2KeysymHash.get( jkey );
tojava return (ks == null ? 0 : ks.longValue());
tojava }
tojava /**
tojava Return keysym derived from a keycode and modifiers.
tojava Usually an input method does this. However non-system input methods (e.g. Java IMs) do not.
......@@ -2634,6 +2640,14 @@ tojava keysym2JavaKeycodeHash.put( Long.valueOf(XKeySymConstants.hpXK_mu
tojava keysym2JavaKeycodeHash.put( Long.valueOf(XKeySymConstants.hpXK_mute_asciitilde), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_DEAD_TILDE, java.awt.event.KeyEvent.KEY_LOCATION_STANDARD));
tojava
tojava keysym2JavaKeycodeHash.put( Long.valueOf(XConstants.NoSymbol), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_UNDEFINED, java.awt.event.KeyEvent.KEY_LOCATION_UNKNOWN));
tojava
tojava /* Reverse search of keysym by keycode. */
tojava
tojava /* Add keyboard locking codes. */
tojava javaKeycode2KeysymHash.put( java.awt.event.KeyEvent.VK_CAPS_LOCK, XKeySymConstants.XK_Caps_Lock);
tojava javaKeycode2KeysymHash.put( java.awt.event.KeyEvent.VK_NUM_LOCK, XKeySymConstants.XK_Num_Lock);
tojava javaKeycode2KeysymHash.put( java.awt.event.KeyEvent.VK_SCROLL_LOCK, XKeySymConstants.XK_Scroll_Lock);
tojava javaKeycode2KeysymHash.put( java.awt.event.KeyEvent.VK_KANA_LOCK, XKeySymConstants.XK_Kana_Lock);
tojava };
tojava
tojava }
/*
* Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1998-2008 Sun Microsystems, Inc. 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
......@@ -60,6 +60,8 @@ class WRobotPeer extends WObjectPeer implements RobotPeer
}
public native int getRGBPixelImpl(int x, int y);
public native int getNumberOfButtons();
public int [] getRGBPixels(Rectangle bounds) {
int pixelArray[] = new int[bounds.width*bounds.height];
getRGBPixels(bounds.x, bounds.y, bounds.width, bounds.height, pixelArray);
......
......@@ -23,8 +23,8 @@
* have any questions.
*/
#include "D3DPipeline.h"
#include <malloc.h>
#include <jni.h>
#include "sun_java2d_pipe_BufferedOpCodes.h"
#include "jlong.h"
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册