Merge
This commit is contained in:
commit
0b8159d689
@ -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
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
$(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
|
||||
|
104
jdk/src/share/classes/com/sun/awt/AWTUtilities.java
Normal file
104
jdk/src/share/classes/com/sun/awt/AWTUtilities.java
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* 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) {
|
||||
|
@ -65,8 +65,10 @@ import java.applet.Applet;
|
||||
|
||||
import sun.security.action.GetPropertyAction;
|
||||
import sun.awt.AppContext;
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.awt.ConstrainableGraphics;
|
||||
import sun.awt.SubRegionShowable;
|
||||
import sun.awt.SunToolkit;
|
||||
import sun.awt.WindowClosingListener;
|
||||
import sun.awt.CausedFocusEvent;
|
||||
import sun.awt.EmbeddedFrame;
|
||||
@ -758,22 +760,26 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
* The shape set with the applyCompoundShape() method. It uncludes the result
|
||||
* of the HW/LW mixing related shape computation. It may also include
|
||||
* the user-specified shape of the component.
|
||||
* The 'null' value means the component has normal shape (or has no shape at all)
|
||||
* and applyCompoundShape() will skip the following shape identical to normal.
|
||||
*/
|
||||
private transient Region compoundShape = null;
|
||||
|
||||
/*
|
||||
* Represents the shape of this lightweight component to be cut out from
|
||||
* heavyweight components should they intersect. Possible values:
|
||||
* 1. null - consider the shape rectangular
|
||||
* 2. EMPTY_REGION - nothing gets cut out (children still get cut out)
|
||||
* 3. non-empty - this shape gets cut out.
|
||||
*/
|
||||
private transient Region mixingCutoutRegion = null;
|
||||
|
||||
/*
|
||||
* Indicates whether addNotify() is complete
|
||||
* (i.e. the peer is created).
|
||||
*/
|
||||
private transient boolean isAddNotifyComplete = false;
|
||||
|
||||
private static final PropertyChangeListener opaquePropertyChangeListener =
|
||||
new PropertyChangeListener() {
|
||||
public void propertyChange(java.beans.PropertyChangeEvent evt) {
|
||||
((Component)evt.getSource()).mixOnOpaqueChanging();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Should only be used in subclass getBounds to check that part of bounds
|
||||
* is actualy changing
|
||||
@ -793,6 +799,39 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
AWTAccessor.setComponentAccessor(new AWTAccessor.ComponentAccessor() {
|
||||
public void setMixingCutoutShape(Component comp, Shape shape) {
|
||||
Region region = shape == null ? null :
|
||||
Region.getInstance(shape, null);
|
||||
|
||||
synchronized (comp.getTreeLock()) {
|
||||
boolean needShowing = false;
|
||||
boolean needHiding = false;
|
||||
|
||||
if (!comp.isNonOpaqueForMixing()) {
|
||||
needHiding = true;
|
||||
}
|
||||
|
||||
comp.mixingCutoutRegion = region;
|
||||
|
||||
if (!comp.isNonOpaqueForMixing()) {
|
||||
needShowing = true;
|
||||
}
|
||||
|
||||
if (comp.isMixingNeeded()) {
|
||||
if (needHiding) {
|
||||
comp.mixOnHiding(comp.isLightweight());
|
||||
}
|
||||
if (needShowing) {
|
||||
comp.mixOnShowing();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new component. Class <code>Component</code> can be
|
||||
* extended directly to create a lightweight component that does not
|
||||
@ -1306,7 +1345,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
enabled = true;
|
||||
ComponentPeer peer = this.peer;
|
||||
if (peer != null) {
|
||||
peer.enable();
|
||||
peer.setEnabled(true);
|
||||
if (visible) {
|
||||
updateCursorImmediately();
|
||||
}
|
||||
@ -1355,7 +1394,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
}
|
||||
ComponentPeer peer = this.peer;
|
||||
if (peer != null) {
|
||||
peer.disable();
|
||||
peer.setEnabled(false);
|
||||
if (visible) {
|
||||
updateCursorImmediately();
|
||||
}
|
||||
@ -1447,7 +1486,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
mixOnShowing();
|
||||
ComponentPeer peer = this.peer;
|
||||
if (peer != null) {
|
||||
peer.show();
|
||||
peer.setVisible(true);
|
||||
createHierarchyEvents(HierarchyEvent.HIERARCHY_CHANGED,
|
||||
this, parent,
|
||||
HierarchyEvent.SHOWING_CHANGED,
|
||||
@ -1517,7 +1556,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
}
|
||||
ComponentPeer peer = this.peer;
|
||||
if (peer != null) {
|
||||
peer.hide();
|
||||
peer.setVisible(false);
|
||||
createHierarchyEvents(HierarchyEvent.HIERARCHY_CHANGED,
|
||||
this, parent,
|
||||
HierarchyEvent.SHOWING_CHANGED,
|
||||
@ -2414,7 +2453,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
if (dim == null || !(isPreferredSizeSet() || isValid())) {
|
||||
synchronized (getTreeLock()) {
|
||||
prefSize = (peer != null) ?
|
||||
peer.preferredSize() :
|
||||
peer.getPreferredSize() :
|
||||
getMinimumSize();
|
||||
dim = prefSize;
|
||||
}
|
||||
@ -2484,7 +2523,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
if (dim == null || !(isMinimumSizeSet() || isValid())) {
|
||||
synchronized (getTreeLock()) {
|
||||
minSize = (peer != null) ?
|
||||
peer.minimumSize() :
|
||||
peer.getMinimumSize() :
|
||||
size();
|
||||
dim = minSize;
|
||||
}
|
||||
@ -3171,7 +3210,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
private Insets getInsets_NoClientCode() {
|
||||
ComponentPeer peer = this.peer;
|
||||
if (peer instanceof ContainerPeer) {
|
||||
return (Insets)((ContainerPeer)peer).insets().clone();
|
||||
return (Insets)((ContainerPeer)peer).getInsets().clone();
|
||||
}
|
||||
return new Insets(0, 0, 0, 0);
|
||||
}
|
||||
@ -6643,7 +6682,6 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
}
|
||||
|
||||
if (!isAddNotifyComplete) {
|
||||
addPropertyChangeListener("opaque", opaquePropertyChangeListener);
|
||||
mixOnShowing();
|
||||
}
|
||||
|
||||
@ -6722,7 +6760,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
|
||||
// Hide peer first to stop system events such as cursor moves.
|
||||
if (visible) {
|
||||
p.hide();
|
||||
p.setVisible(false);
|
||||
}
|
||||
|
||||
peer = null; // Stop peer updates.
|
||||
@ -6735,9 +6773,11 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
p.dispose();
|
||||
|
||||
mixOnHiding(isLightweight);
|
||||
removePropertyChangeListener("opaque", opaquePropertyChangeListener);
|
||||
|
||||
isAddNotifyComplete = false;
|
||||
// Nullifying compoundShape means that the component has normal shape
|
||||
// (or has no shape at all).
|
||||
this.compoundShape = null;
|
||||
}
|
||||
|
||||
if (hierarchyListener != null ||
|
||||
@ -9401,10 +9441,9 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
* Null-layout of the container or absence of the container mean
|
||||
* the bounds of the component are final and can be trusted.
|
||||
*/
|
||||
private boolean areBoundsValid() {
|
||||
final boolean areBoundsValid() {
|
||||
Container cont = getContainer();
|
||||
return cont == null || cont.isValid()
|
||||
|| cont.getLayout() == null;
|
||||
return cont == null || cont.isValid() || cont.getLayout() == null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -9413,6 +9452,14 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
*/
|
||||
void applyCompoundShape(Region shape) {
|
||||
checkTreeLock();
|
||||
|
||||
if (!areBoundsValid()) {
|
||||
if (mixingLog.isLoggable(Level.FINE)) {
|
||||
mixingLog.fine("this = " + this + "; areBoundsValid = " + areBoundsValid());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isLightweight()) {
|
||||
ComponentPeer peer = getPeer();
|
||||
if (peer != null) {
|
||||
@ -9422,22 +9469,31 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
// with some incorrect Region object with loX being
|
||||
// greater than the hiX for instance.
|
||||
if (shape.isEmpty()) {
|
||||
shape = Region.getInstanceXYWH(0, 0, 0, 0);
|
||||
shape = Region.EMPTY_REGION;
|
||||
}
|
||||
|
||||
|
||||
// Note: the shape is not really copied/cloned. We create
|
||||
// the Region object ourselves, so there's no any possibility
|
||||
// to modify the object outside of the mixing code.
|
||||
this.compoundShape = shape;
|
||||
|
||||
if (areBoundsValid()) {
|
||||
// Nullifying compoundShape means that the component has normal shape
|
||||
// (or has no shape at all).
|
||||
if (shape.equals(getNormalShape())) {
|
||||
if (this.compoundShape == null) {
|
||||
return;
|
||||
}
|
||||
this.compoundShape = null;
|
||||
peer.applyShape(null);
|
||||
} else {
|
||||
if (shape.equals(getAppliedShape())) {
|
||||
return;
|
||||
}
|
||||
this.compoundShape = shape;
|
||||
Point compAbsolute = getLocationOnWindow();
|
||||
|
||||
if (mixingLog.isLoggable(Level.FINER)) {
|
||||
mixingLog.fine("this = " + this +
|
||||
"; compAbsolute=" + compAbsolute + "; shape=" + shape);
|
||||
"; compAbsolute=" + compAbsolute + "; shape=" + shape);
|
||||
}
|
||||
|
||||
peer.applyShape(shape.getTranslatedRegion(-compAbsolute.x, -compAbsolute.y));
|
||||
}
|
||||
}
|
||||
@ -9460,7 +9516,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
Point curLocation = getLocation();
|
||||
|
||||
for (Container parent = getContainer();
|
||||
parent != null;
|
||||
parent != null && !(parent instanceof Window);
|
||||
parent = parent.getContainer())
|
||||
{
|
||||
curLocation.x += parent.getX();
|
||||
@ -9486,7 +9542,28 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
);
|
||||
}
|
||||
|
||||
private int getSiblingIndexAbove() {
|
||||
/**
|
||||
* Returns the "opaque shape" of the component.
|
||||
*
|
||||
* The opaque shape of a lightweight components is the actual shape that
|
||||
* needs to be cut off of the heavyweight components in order to mix this
|
||||
* lightweight component correctly with them.
|
||||
*
|
||||
* The method is overriden in the java.awt.Container to handle non-opaque
|
||||
* containers containing opaque children.
|
||||
*
|
||||
* See 6637655 for details.
|
||||
*/
|
||||
Region getOpaqueShape() {
|
||||
checkTreeLock();
|
||||
if (mixingCutoutRegion != null) {
|
||||
return mixingCutoutRegion;
|
||||
} else {
|
||||
return getNormalShape();
|
||||
}
|
||||
}
|
||||
|
||||
final int getSiblingIndexAbove() {
|
||||
checkTreeLock();
|
||||
Container parent = getContainer();
|
||||
if (parent == null) {
|
||||
@ -9498,7 +9575,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
return nextAbove < 0 ? -1 : nextAbove;
|
||||
}
|
||||
|
||||
private int getSiblingIndexBelow() {
|
||||
final int getSiblingIndexBelow() {
|
||||
checkTreeLock();
|
||||
Container parent = getContainer();
|
||||
if (parent == null) {
|
||||
@ -9510,6 +9587,11 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
return nextBelow >= parent.getComponentCount() ? -1 : nextBelow;
|
||||
}
|
||||
|
||||
final boolean isNonOpaqueForMixing() {
|
||||
return mixingCutoutRegion != null &&
|
||||
mixingCutoutRegion.isEmpty();
|
||||
}
|
||||
|
||||
private Region calculateCurrentShape() {
|
||||
checkTreeLock();
|
||||
Region s = getNormalShape();
|
||||
@ -9532,8 +9614,8 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
* implementation of the Container class.
|
||||
*/
|
||||
Component c = cont.getComponent(index);
|
||||
if (c.isLightweight() && c.isShowing() && c.isOpaque()) {
|
||||
s = s.getDifference(c.getNormalShape());
|
||||
if (c.isLightweight() && c.isShowing()) {
|
||||
s = s.getDifference(c.getOpaqueShape());
|
||||
}
|
||||
}
|
||||
|
||||
@ -9558,6 +9640,9 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
void applyCurrentShape() {
|
||||
checkTreeLock();
|
||||
if (!areBoundsValid()) {
|
||||
if (mixingLog.isLoggable(Level.FINE)) {
|
||||
mixingLog.fine("this = " + this + "; areBoundsValid = " + areBoundsValid());
|
||||
}
|
||||
return; // Because applyCompoundShape() ignores such components anyway
|
||||
}
|
||||
if (mixingLog.isLoggable(Level.FINE)) {
|
||||
@ -9576,16 +9661,54 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
applyCompoundShape(getAppliedShape().getDifference(s));
|
||||
}
|
||||
|
||||
private final void applyCurrentShapeBelowMe() {
|
||||
checkTreeLock();
|
||||
Container parent = getContainer();
|
||||
if (parent != null && parent.isShowing()) {
|
||||
// First, reapply shapes of my siblings
|
||||
parent.recursiveApplyCurrentShape(getSiblingIndexBelow());
|
||||
|
||||
// Second, if my container is non-opaque, reapply shapes of siblings of my container
|
||||
Container parent2 = parent.getContainer();
|
||||
while (!parent.isOpaque() && parent2 != null) {
|
||||
parent2.recursiveApplyCurrentShape(parent.getSiblingIndexBelow());
|
||||
|
||||
parent = parent2;
|
||||
parent2 = parent.getContainer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final void subtractAndApplyShapeBelowMe() {
|
||||
checkTreeLock();
|
||||
Container parent = getContainer();
|
||||
if (parent != null && isShowing()) {
|
||||
Region opaqueShape = getOpaqueShape();
|
||||
|
||||
// First, cut my siblings
|
||||
parent.recursiveSubtractAndApplyShape(opaqueShape, getSiblingIndexBelow());
|
||||
|
||||
// Second, if my container is non-opaque, cut siblings of my container
|
||||
Container parent2 = parent.getContainer();
|
||||
while (!parent.isOpaque() && parent2 != null) {
|
||||
parent2.recursiveSubtractAndApplyShape(opaqueShape, parent.getSiblingIndexBelow());
|
||||
|
||||
parent = parent2;
|
||||
parent2 = parent.getContainer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mixOnShowing() {
|
||||
synchronized (getTreeLock()) {
|
||||
if (mixingLog.isLoggable(Level.FINE)) {
|
||||
mixingLog.fine("this = " + this);
|
||||
}
|
||||
if (!isMixingNeeded()) {
|
||||
return;
|
||||
}
|
||||
if (isLightweight()) {
|
||||
Container parent = getContainer();
|
||||
if (parent != null && isShowing() && isOpaque()) {
|
||||
parent.recursiveSubtractAndApplyShape(getNormalShape(), getSiblingIndexBelow());
|
||||
}
|
||||
subtractAndApplyShapeBelowMe();
|
||||
} else {
|
||||
applyCurrentShape();
|
||||
}
|
||||
@ -9599,12 +9722,12 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
if (mixingLog.isLoggable(Level.FINE)) {
|
||||
mixingLog.fine("this = " + this + "; isLightweight = " + isLightweight);
|
||||
}
|
||||
if (!isMixingNeeded()) {
|
||||
return;
|
||||
}
|
||||
if (isLightweight) {
|
||||
Container parent = getContainer();
|
||||
if (parent != null) {
|
||||
parent.recursiveApplyCurrentShape(getSiblingIndexBelow());
|
||||
}
|
||||
} //XXX: else applyNormalShape() ???
|
||||
applyCurrentShapeBelowMe();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -9613,11 +9736,11 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
if (mixingLog.isLoggable(Level.FINE)) {
|
||||
mixingLog.fine("this = " + this);
|
||||
}
|
||||
if (!isMixingNeeded()) {
|
||||
return;
|
||||
}
|
||||
if (isLightweight()) {
|
||||
Container parent = getContainer();
|
||||
if (parent != null) {
|
||||
parent.recursiveApplyCurrentShape(parent.getComponentZOrder(this));
|
||||
}
|
||||
applyCurrentShapeBelowMe();
|
||||
} else {
|
||||
applyCurrentShape();
|
||||
}
|
||||
@ -9633,11 +9756,13 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
mixingLog.fine("this = " + this +
|
||||
"; oldZorder=" + oldZorder + "; newZorder=" + newZorder + "; parent=" + parent);
|
||||
}
|
||||
|
||||
if (!isMixingNeeded()) {
|
||||
return;
|
||||
}
|
||||
if (isLightweight()) {
|
||||
if (becameHigher) {
|
||||
if (parent != null && isShowing() && isOpaque()) {
|
||||
parent.recursiveSubtractAndApplyShape(getNormalShape(), getSiblingIndexBelow(), oldZorder);
|
||||
if (parent != null && isShowing()) {
|
||||
parent.recursiveSubtractAndApplyShape(getOpaqueShape(), getSiblingIndexBelow(), oldZorder);
|
||||
}
|
||||
} else {
|
||||
if (parent != null) {
|
||||
@ -9653,8 +9778,8 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
|
||||
for (int index = oldZorder; index < newZorder; index++) {
|
||||
Component c = parent.getComponent(index);
|
||||
if (c.isLightweight() && c.isShowing() && c.isOpaque()) {
|
||||
shape = shape.getDifference(c.getNormalShape());
|
||||
if (c.isLightweight() && c.isShowing()) {
|
||||
shape = shape.getDifference(c.getOpaqueShape());
|
||||
}
|
||||
}
|
||||
applyCompoundShape(shape);
|
||||
@ -9664,21 +9789,42 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
}
|
||||
}
|
||||
|
||||
void mixOnOpaqueChanging() {
|
||||
if (mixingLog.isLoggable(Level.FINE)) {
|
||||
mixingLog.fine("this = " + this);
|
||||
}
|
||||
if (isOpaque()) {
|
||||
mixOnShowing();
|
||||
} else {
|
||||
mixOnHiding(isLightweight());
|
||||
}
|
||||
}
|
||||
|
||||
void mixOnValidating() {
|
||||
// This method gets overriden in the Container. Obviously, a plain
|
||||
// non-container components don't need to handle validation.
|
||||
}
|
||||
|
||||
final boolean isMixingNeeded() {
|
||||
if (SunToolkit.getSunAwtDisableMixing()) {
|
||||
if (mixingLog.isLoggable(Level.FINEST)) {
|
||||
mixingLog.finest("this = " + this + "; Mixing disabled via sun.awt.disableMixing");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (!areBoundsValid()) {
|
||||
if (mixingLog.isLoggable(Level.FINE)) {
|
||||
mixingLog.fine("this = " + this + "; areBoundsValid = " + areBoundsValid());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Window window = getContainingWindow();
|
||||
if (window != null) {
|
||||
if (!window.hasHeavyweightDescendants() || !window.hasLightweightDescendants()) {
|
||||
if (mixingLog.isLoggable(Level.FINE)) {
|
||||
mixingLog.fine("containing window = " + window +
|
||||
"; has h/w descendants = " + window.hasHeavyweightDescendants() +
|
||||
"; has l/w descendants = " + window.hasLightweightDescendants());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (mixingLog.isLoggable(Level.FINE)) {
|
||||
mixingLog.finest("this = " + this + "; containing window is null");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// ****************** END OF MIXING CODE ********************************
|
||||
}
|
||||
|
@ -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
|
||||
* 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><code>InputEvent.BUTTON1_MASK</code>
|
||||
* <li><code>InputEvent.BUTTON2_MASK</code>
|
||||
* <li><code>InputEvent.BUTTON3_MASK</code>
|
||||
* <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>
|
||||
* @throws IllegalArgumentException if the button mask is not a
|
||||
* valid combination
|
||||
* <p>
|
||||
* The following standard button masks are also accepted:
|
||||
* <ul>
|
||||
* <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 #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><code>InputEvent.BUTTON1_MASK</code>
|
||||
* <li><code>InputEvent.BUTTON2_MASK</code>
|
||||
* <li><code>InputEvent.BUTTON3_MASK</code>
|
||||
* <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}
|
||||
* <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();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
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();
|
||||
|
||||
/**
|
||||
* Selects the item at index {@code index}.
|
||||
*
|
||||
* @param index the index which should be selected
|
||||
*
|
||||
* @see Choice#select(int)
|
||||
*/
|
||||
void select(int index);
|
||||
|
||||
/*
|
||||
* DEPRECATED: Replaced by add(String, int).
|
||||
*/
|
||||
void addItem(String item, 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,63 +50,474 @@ 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;
|
||||
boolean isObscured();
|
||||
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);
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* 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 setVisible(boolean v);
|
||||
|
||||
/**
|
||||
* 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)
|
||||
*/
|
||||
void setEnabled(boolean e);
|
||||
|
||||
/**
|
||||
* 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 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Called to let the component peer handle events.
|
||||
*
|
||||
* @param e the AWT event to handle
|
||||
*
|
||||
* @see Component#dispatchEvent(AWTEvent)
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* Determines the location of the component on the screen.
|
||||
*
|
||||
* @return the location of the component on the screen
|
||||
*
|
||||
* @see Component#getLocationOnScreen()
|
||||
*/
|
||||
Point getLocationOnScreen();
|
||||
|
||||
/**
|
||||
* Determines the preferred size of the component.
|
||||
*
|
||||
* @return the preferred size of the component
|
||||
*
|
||||
* @see Component#getPreferredSize()
|
||||
*/
|
||||
Dimension getPreferredSize();
|
||||
|
||||
/**
|
||||
* Determines the minimum size of the component.
|
||||
*
|
||||
* @return the minimum size of the component
|
||||
*
|
||||
* @see Component#getMinimumSize()
|
||||
*/
|
||||
Dimension getMinimumSize();
|
||||
|
||||
/**
|
||||
* Returns the color model used by the component.
|
||||
*
|
||||
* @return the color model used by the component
|
||||
*
|
||||
* @see Component#getColorModel()
|
||||
*/
|
||||
ColorModel getColorModel();
|
||||
|
||||
/**
|
||||
* Returns the toolkit that is responsible for the component.
|
||||
*
|
||||
* @return the toolkit that is responsible for the component
|
||||
*
|
||||
* @see Component#getToolkit()
|
||||
*/
|
||||
Toolkit getToolkit();
|
||||
|
||||
/**
|
||||
* Returns a graphics object to paint on the component.
|
||||
*
|
||||
* @return a graphics object to paint on the component
|
||||
*
|
||||
* @see Component#getGraphics()
|
||||
*/
|
||||
// TODO: Maybe change this to force Graphics2D, since many things will
|
||||
// break with plain Graphics nowadays.
|
||||
Graphics getGraphics();
|
||||
|
||||
/**
|
||||
* 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)
|
||||
*/
|
||||
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();
|
||||
boolean handlesWheelScrolling();
|
||||
void createBuffers(int numBuffers, BufferCapabilities caps) throws AWTException;
|
||||
|
||||
/**
|
||||
* 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</code> peer
|
||||
* Implementation depends on toolkit and container.
|
||||
* 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 withour destroying the peer
|
||||
* 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();
|
||||
@ -109,50 +526,17 @@ public interface ComponentPeer {
|
||||
* 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();
|
||||
|
||||
|
||||
Rectangle getBounds();
|
||||
void layout();
|
||||
|
||||
/**
|
||||
* Applies the shape to the native component window.
|
||||
* @since 1.7
|
||||
*
|
||||
* @see Component#applyCompoundShape
|
||||
*/
|
||||
void applyShape(Region shape);
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by getPreferredSize().
|
||||
*/
|
||||
Dimension preferredSize();
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by getMinimumSize().
|
||||
*/
|
||||
Dimension minimumSize();
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by setVisible(boolean).
|
||||
*/
|
||||
void show();
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by setVisible(boolean).
|
||||
*/
|
||||
void hide();
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by setEnabled(boolean).
|
||||
*/
|
||||
void enable();
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by setEnabled(boolean).
|
||||
*/
|
||||
void disable();
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by setBounds(int, int, int, int).
|
||||
*/
|
||||
void reshape(int x, int y, int width, int height);
|
||||
}
|
||||
|
@ -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 {
|
||||
Insets getInsets();
|
||||
void beginValidate();
|
||||
void endValidate();
|
||||
void beginLayout();
|
||||
void endLayout();
|
||||
boolean isPaintPending();
|
||||
|
||||
/**
|
||||
* Restacks native windows - children of this native window - according to Java container order
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* De-selects the item at the specified {@code index}.
|
||||
*
|
||||
* @param index the index of the item to de-select
|
||||
*
|
||||
* @see List#deselect(int)
|
||||
*/
|
||||
void deselect(int index);
|
||||
|
||||
/**
|
||||
* 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 makeVisible(int index);
|
||||
void setMultipleMode(boolean b);
|
||||
|
||||
/**
|
||||
* 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 setMultipleMode(boolean m);
|
||||
|
||||
/**
|
||||
* 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 getPreferredSize(int rows);
|
||||
|
||||
/**
|
||||
* 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 getMinimumSize(int rows);
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by add(String, int).
|
||||
*/
|
||||
void addItem(String item, int index);
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by removeAll().
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by setMultipleMode(boolean).
|
||||
*/
|
||||
void setMultipleSelections(boolean v);
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by getPreferredSize(int).
|
||||
*/
|
||||
Dimension preferredSize(int v);
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by getMinimumSize(int).
|
||||
*/
|
||||
Dimension minimumSize(int v);
|
||||
}
|
||||
|
@ -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 {
|
||||
|
||||
/**
|
||||
* Sets the label to be displayed in this menu item.
|
||||
*
|
||||
* @param label the label to be displayed
|
||||
*/
|
||||
void setLabel(String label);
|
||||
void setEnabled(boolean b);
|
||||
|
||||
/**
|
||||
* 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 enable();
|
||||
void setEnabled(boolean e);
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by setEnabled(boolean).
|
||||
*/
|
||||
void disable();
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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 {
|
||||
|
||||
/**
|
||||
* 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 insert(String text, int pos);
|
||||
|
||||
/**
|
||||
* 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 replaceRange(String text, int start, int end);
|
||||
|
||||
/**
|
||||
* 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 getPreferredSize(int rows, int columns);
|
||||
|
||||
/**
|
||||
* 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 getMinimumSize(int rows, int columns);
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by insert(String, int).
|
||||
*/
|
||||
void insertText(String txt, int pos);
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by ReplaceRange(String, int, int).
|
||||
*/
|
||||
void replaceText(String txt, int start, int end);
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by getPreferredSize(int, int).
|
||||
*/
|
||||
Dimension preferredSize(int rows, int cols);
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by getMinimumSize(int, int).
|
||||
*/
|
||||
Dimension minimumSize(int rows, int cols);
|
||||
}
|
||||
|
@ -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 {
|
||||
|
||||
/**
|
||||
* Sets the echo character.
|
||||
*
|
||||
* @param echoChar the echo character to set
|
||||
*
|
||||
* @see TextField#getEchoChar()
|
||||
*/
|
||||
void setEchoChar(char echoChar);
|
||||
|
||||
/**
|
||||
* 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 getPreferredSize(int columns);
|
||||
|
||||
/**
|
||||
* 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 getMinimumSize(int columns);
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by setEchoChar(char echoChar).
|
||||
*/
|
||||
void setEchoCharacter(char c);
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by getPreferredSize(int).
|
||||
*/
|
||||
Dimension preferredSize(int cols);
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by getMinimumSize(int).
|
||||
*/
|
||||
Dimension minimumSize(int cols);
|
||||
}
|
||||
|
@ -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);
|
||||
|
77
jdk/src/share/classes/sun/awt/AWTAccessor.java
Normal file
77
jdk/src/share/classes/sun/awt/AWTAccessor.java
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* 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 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();
|
||||
|
||||
/** We don't need any objects of this class.
|
||||
* It's rather a collection of static methods
|
||||
* and interfaces.
|
||||
*/
|
||||
private AWTAccessor() {
|
||||
}
|
||||
|
||||
/** 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);
|
||||
}
|
||||
|
||||
/* The java.awt.Component class accessor object.
|
||||
*/
|
||||
private static ComponentAccessor componentAccessor;
|
||||
|
||||
/** Set an accessor object for the java.awt.Component class.
|
||||
*/
|
||||
public static void setComponentAccessor(ComponentAccessor ca) {
|
||||
componentAccessor = ca;
|
||||
}
|
||||
|
||||
/** Retrieve the accessor object for the java.awt.Window class.
|
||||
*/
|
||||
public static ComponentAccessor getComponentAccessor() {
|
||||
if (componentAccessor == null) {
|
||||
unsafe.ensureClassInitialized(Component.class);
|
||||
}
|
||||
|
||||
return componentAccessor;
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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 }
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1999-2006 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
|
||||
@ -54,6 +54,7 @@ extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
|
||||
// 2 would be more correct, however that's how Robot originally worked
|
||||
// and tests start to fail if this value is changed
|
||||
static int32_t num_buttons = 3;
|
||||
static jint * masks;
|
||||
|
||||
static int32_t isXTestAvailable() {
|
||||
int32_t major_opcode, first_event, first_error;
|
||||
@ -208,6 +209,26 @@ JNIEXPORT void JNICALL
|
||||
Java_sun_awt_X11_XRobotPeer_setup (JNIEnv * env, jclass cls) {
|
||||
int32_t xtestAvailable;
|
||||
|
||||
// this should be called from XRobotPeer constructor
|
||||
jclass inputEventClazz = (*env)->FindClass(env, "java/awt/event/InputEvent");
|
||||
jmethodID getButtonDownMasksID = (*env)->GetStaticMethodID(env, inputEventClazz, "getButtonDownMasks", "()[I");
|
||||
jintArray obj = (jintArray)(*env)->CallStaticObjectMethod(env, inputEventClazz, getButtonDownMasksID);
|
||||
jsize len = (*env)->GetArrayLength(env, obj);
|
||||
jint * tmp = (*env)->GetIntArrayElements(env, obj, JNI_FALSE);
|
||||
|
||||
masks = (jint *)malloc(sizeof(jint)*len);
|
||||
if (masks == (jint *) NULL) {
|
||||
JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), NULL);
|
||||
goto finally;
|
||||
}
|
||||
|
||||
int i;
|
||||
for (i = 0; i < len; i++) {
|
||||
masks[i] = tmp[i];
|
||||
}
|
||||
(*env)->ReleaseIntArrayElements(env, obj, tmp, 0);
|
||||
(*env)->DeleteLocalRef(env, obj);
|
||||
|
||||
DTRACE_PRINTLN("RobotPeer: setup()");
|
||||
|
||||
AWT_LOCK();
|
||||
@ -221,10 +242,17 @@ Java_sun_awt_X11_XRobotPeer_setup (JNIEnv * env, jclass cls) {
|
||||
}
|
||||
|
||||
getNumButtons();
|
||||
|
||||
finally:
|
||||
AWT_UNLOCK();
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_sun_awt_X11_XRobotPeer_getNumberOfButtonsImpl(JNIEnv *env,
|
||||
jclass cls) {
|
||||
// At the moment this routine being called we already should have an initialized num_buttons variable.
|
||||
return num_buttons;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_sun_awt_X11_XRobotPeer_getRGBPixelsImpl( JNIEnv *env,
|
||||
jclass cls,
|
||||
@ -348,52 +376,65 @@ Java_sun_awt_X11_XRobotPeer_mouseMoveImpl (JNIEnv *env,
|
||||
AWT_UNLOCK();
|
||||
}
|
||||
|
||||
/*
|
||||
* Function joining the code of mousePressImpl and mouseReleaseImpl
|
||||
*/
|
||||
void mouseAction(JNIEnv *env,
|
||||
jclass cls,
|
||||
jint buttonMask,
|
||||
Bool isMousePress)
|
||||
{
|
||||
AWT_LOCK();
|
||||
|
||||
DTRACE_PRINTLN1("RobotPeer: mouseAction(%i)", buttonMask);
|
||||
DTRACE_PRINTLN1("RobotPeer: mouseAction, press = %d", isMousePress);
|
||||
|
||||
if (buttonMask & java_awt_event_InputEvent_BUTTON1_MASK ||
|
||||
buttonMask & java_awt_event_InputEvent_BUTTON1_DOWN_MASK )
|
||||
{
|
||||
XTestFakeButtonEvent(awt_display, 1, isMousePress, CurrentTime);
|
||||
}
|
||||
if ((buttonMask & java_awt_event_InputEvent_BUTTON2_MASK ||
|
||||
buttonMask & java_awt_event_InputEvent_BUTTON2_DOWN_MASK) &&
|
||||
(num_buttons >= 2)) {
|
||||
XTestFakeButtonEvent(awt_display, 2, isMousePress, CurrentTime);
|
||||
}
|
||||
if ((buttonMask & java_awt_event_InputEvent_BUTTON3_MASK ||
|
||||
buttonMask & java_awt_event_InputEvent_BUTTON3_DOWN_MASK) &&
|
||||
(num_buttons >= 3)) {
|
||||
XTestFakeButtonEvent(awt_display, 3, isMousePress, CurrentTime);
|
||||
}
|
||||
|
||||
if (num_buttons > 3){
|
||||
int32_t i;
|
||||
int32_t button = 0;
|
||||
for (i = 3; i<num_buttons; i++){
|
||||
if ((buttonMask & masks[i])) {
|
||||
// arrays starts from zero index => +1
|
||||
// users wants to affect 4 or 5 button but they are assigned
|
||||
// to the wheel so => we have to shift it to the right by 2.
|
||||
button = i + 3;
|
||||
XTestFakeButtonEvent(awt_display, button, isMousePress, CurrentTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XSync(awt_display, False);
|
||||
AWT_UNLOCK();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_sun_awt_X11_XRobotPeer_mousePressImpl (JNIEnv *env,
|
||||
jclass cls,
|
||||
jint buttonMask) {
|
||||
AWT_LOCK();
|
||||
|
||||
DTRACE_PRINTLN1("RobotPeer: mousePressImpl(%i)", buttonMask);
|
||||
|
||||
if (buttonMask & java_awt_event_InputEvent_BUTTON1_MASK) {
|
||||
XTestFakeButtonEvent(awt_display, 1, True, CurrentTime);
|
||||
}
|
||||
if ((buttonMask & java_awt_event_InputEvent_BUTTON2_MASK) &&
|
||||
(num_buttons >= 2)) {
|
||||
XTestFakeButtonEvent(awt_display, 2, True, CurrentTime);
|
||||
}
|
||||
if ((buttonMask & java_awt_event_InputEvent_BUTTON3_MASK) &&
|
||||
(num_buttons >= 3)) {
|
||||
XTestFakeButtonEvent(awt_display, 3, True, CurrentTime);
|
||||
}
|
||||
XSync(awt_display, False);
|
||||
|
||||
AWT_UNLOCK();
|
||||
mouseAction(env, cls, buttonMask, True);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_sun_awt_X11_XRobotPeer_mouseReleaseImpl (JNIEnv *env,
|
||||
jclass cls,
|
||||
jint buttonMask) {
|
||||
AWT_LOCK();
|
||||
|
||||
DTRACE_PRINTLN1("RobotPeer: mouseReleaseImpl(%i)", buttonMask);
|
||||
|
||||
if (buttonMask & java_awt_event_InputEvent_BUTTON1_MASK) {
|
||||
XTestFakeButtonEvent(awt_display, 1, False, CurrentTime);
|
||||
}
|
||||
if ((buttonMask & java_awt_event_InputEvent_BUTTON2_MASK) &&
|
||||
(num_buttons >= 2)) {
|
||||
XTestFakeButtonEvent(awt_display, 2, False, CurrentTime);
|
||||
}
|
||||
if ((buttonMask & java_awt_event_InputEvent_BUTTON3_MASK) &&
|
||||
(num_buttons >= 3)) {
|
||||
XTestFakeButtonEvent(awt_display, 3, False, CurrentTime);
|
||||
}
|
||||
XSync(awt_display, False);
|
||||
|
||||
AWT_UNLOCK();
|
||||
mouseAction(env, cls, buttonMask, False);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
|
@ -1641,6 +1641,13 @@ JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XdbeSwapBuffers
|
||||
AWT_CHECK_HAVE_LOCK();
|
||||
return XdbeSwapBuffers((Display*) jlong_to_ptr(display), (XdbeSwapInfo *) jlong_to_ptr(swap_info), num_windows);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XQueryKeymap
|
||||
(JNIEnv *env, jclass clazz, jlong display, jlong vector)
|
||||
{
|
||||
|
||||
AWT_CHECK_HAVE_LOCK();
|
||||
XQueryKeymap( (Display *) jlong_to_ptr(display), (char *) jlong_to_ptr(vector));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_sun_awt_X11_XlibWrapper_XKeycodeToKeysym(JNIEnv *env, jclass clazz,
|
||||
@ -1911,19 +1918,30 @@ Java_sun_awt_X11_XlibWrapper_SetRectangularShape
|
||||
jint x1, jint y1, jint x2, jint y2,
|
||||
jobject region)
|
||||
{
|
||||
XRectangle rects[256];
|
||||
XRectangle *pRect = rects;
|
||||
int numrects;
|
||||
|
||||
AWT_CHECK_HAVE_LOCK();
|
||||
|
||||
numrects = RegionToYXBandedRectangles(env, x1, y1, x2, y2, region,
|
||||
&pRect, 256);
|
||||
// If all the params are zeros, the shape must be simply reset.
|
||||
// Otherwise, the shape may be not rectangular.
|
||||
if (region || x1 || x2 || y1 || y2) {
|
||||
XRectangle rects[256];
|
||||
XRectangle *pRect = rects;
|
||||
|
||||
XShapeCombineRectangles((Display *)jlong_to_ptr(display), (Window)jlong_to_ptr(window),
|
||||
int numrects = RegionToYXBandedRectangles(env, x1, y1, x2, y2, region,
|
||||
&pRect, 256);
|
||||
|
||||
XShapeCombineRectangles((Display *)jlong_to_ptr(display), (Window)jlong_to_ptr(window),
|
||||
ShapeClip, 0, 0, pRect, numrects, ShapeSet, YXBanded);
|
||||
XShapeCombineRectangles((Display *)jlong_to_ptr(display), (Window)jlong_to_ptr(window),
|
||||
ShapeBounding, 0, 0, pRect, numrects, ShapeSet, YXBanded);
|
||||
|
||||
if (pRect != rects) {
|
||||
free(pRect);
|
||||
if (pRect != rects) {
|
||||
free(pRect);
|
||||
}
|
||||
} else {
|
||||
// Reset the shape to a rectangular form.
|
||||
XShapeCombineMask((Display *)jlong_to_ptr(display), (Window)jlong_to_ptr(window),
|
||||
ShapeClip, 0, 0, None, ShapeSet);
|
||||
XShapeCombineMask((Display *)jlong_to_ptr(display), (Window)jlong_to_ptr(window),
|
||||
ShapeBounding, 0, 0, None, ShapeSet);
|
||||
}
|
||||
}
|
||||
|
@ -68,13 +68,6 @@ public abstract class WComponentPeer extends WObjectPeer
|
||||
private static final Logger log = Logger.getLogger("sun.awt.windows.WComponentPeer");
|
||||
private static final Logger shapeLog = Logger.getLogger("sun.awt.windows.shape.WComponentPeer");
|
||||
|
||||
static {
|
||||
wheelInit();
|
||||
}
|
||||
|
||||
// Only actually does stuff if running on 95
|
||||
native static void wheelInit();
|
||||
|
||||
// ComponentPeer implementation
|
||||
SurfaceData surfaceData;
|
||||
|
||||
@ -964,8 +957,12 @@ public abstract class WComponentPeer extends WObjectPeer
|
||||
+ "; SHAPE: " + shape);
|
||||
}
|
||||
|
||||
setRectangularShape(shape.getLoX(), shape.getLoY(), shape.getHiX(), shape.getHiY(),
|
||||
(shape.isRectangular() ? null : shape));
|
||||
if (shape != null) {
|
||||
setRectangularShape(shape.getLoX(), shape.getLoY(), shape.getHiX(), shape.getHiY(),
|
||||
(shape.isRectangular() ? null : shape));
|
||||
} else {
|
||||
setRectangularShape(0, 0, 0, 0, null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -548,11 +548,15 @@ public class WInputMethod extends InputMethodAdapter
|
||||
|
||||
public void inquireCandidatePosition()
|
||||
{
|
||||
Component source = getClientComponent();
|
||||
if (source == null) {
|
||||
return;
|
||||
}
|
||||
// This call should return immediately just to cause
|
||||
// InputMethodRequests.getTextLocation be called within
|
||||
// AWT Event thread. Otherwise, a potential deadlock
|
||||
// could happen.
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
Runnable r = new Runnable() {
|
||||
public void run() {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
@ -573,7 +577,9 @@ public class WInputMethod extends InputMethodAdapter
|
||||
|
||||
openCandidateWindow(awtFocussedComponentPeer, x, y);
|
||||
}
|
||||
});
|
||||
};
|
||||
WToolkit.postEvent(WToolkit.targetToAppContext(source),
|
||||
new InvocationEvent(source, r));
|
||||
}
|
||||
|
||||
// java.awt.Toolkit#getNativeContainer() is not available
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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);
|
||||
|
@ -80,6 +80,10 @@ public class WToolkit extends SunToolkit implements Runnable {
|
||||
// Dynamic Layout Resize client code setting
|
||||
protected boolean dynamicLayoutSetting = false;
|
||||
|
||||
//Is it allowed to generate events assigned to extra mouse buttons.
|
||||
//Set to true by default.
|
||||
private static boolean areExtraMouseButtonsEnabled = true;
|
||||
|
||||
/**
|
||||
* Initialize JNI field and method IDs
|
||||
*/
|
||||
@ -249,6 +253,11 @@ public class WToolkit extends SunToolkit implements Runnable {
|
||||
// Enabled "live resizing" by default. It remains controlled
|
||||
// by the native system though.
|
||||
setDynamicLayout(true);
|
||||
|
||||
areExtraMouseButtonsEnabled = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons", "true"));
|
||||
//set system property if not yet assigned
|
||||
System.setProperty("sun.awt.enableExtraMouseButtons", ""+areExtraMouseButtonsEnabled);
|
||||
setExtraMouseButtonsEnabledNative(areExtraMouseButtonsEnabled);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
@ -961,4 +970,9 @@ public class WToolkit extends SunToolkit implements Runnable {
|
||||
return new WDesktopPeer();
|
||||
}
|
||||
|
||||
public static native void setExtraMouseButtonsEnabledNative(boolean enable);
|
||||
|
||||
public boolean areExtraMouseButtonsEnabled() throws HeadlessException {
|
||||
return areExtraMouseButtonsEnabled;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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
|
||||
@ -23,24 +23,21 @@
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
// copy from awt.h
|
||||
#ifndef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0600
|
||||
#endif
|
||||
|
||||
// copy from awt.h
|
||||
#ifndef _WIN32_IE
|
||||
#define _WIN32_IE 0x0600
|
||||
#endif
|
||||
|
||||
#include "splashscreen_impl.h"
|
||||
#include <windowsx.h>
|
||||
#include <windows.h>
|
||||
#include <winuser.h>
|
||||
|
||||
/* layered windows api prototypes. wouldn't be needed if we could use an updated version of the MS PSDK. */
|
||||
|
||||
typedef BOOL WINAPI UpdateLayeredWindowT(HWND hwnd, // handle to layered window
|
||||
HDC hdcDst, // handle to screen DC
|
||||
POINT * pptDst, // new screen position
|
||||
SIZE * psize, // new size of the layered window
|
||||
HDC hdcSrc, // handle to surface DC
|
||||
POINT * pptSrc, // layer position
|
||||
COLORREF crKey, // color key
|
||||
BLENDFUNCTION * pblend, // blend function
|
||||
DWORD dwFlags // options
|
||||
);
|
||||
|
||||
#ifndef WS_EX_LAYERED
|
||||
#define WS_EX_LAYERED 0x80000
|
||||
#endif
|
||||
@ -57,21 +54,6 @@ typedef BOOL WINAPI UpdateLayeredWindowT(HWND hwnd, // handle to layered win
|
||||
#define AC_SRC_ALPHA 0x01
|
||||
#endif
|
||||
|
||||
static UpdateLayeredWindowT *UpdateLayeredWindow = NULL;
|
||||
|
||||
/* Get/SetWindowLongPtr prototypes, for the case we're compiling with old headers for a 32-bit platform
|
||||
copied from Component.cpp
|
||||
FIXME: remove this as soon as the build process is using up-to-date headers */
|
||||
#if !defined(__int3264)
|
||||
#define GetWindowLongPtr GetWindowLong
|
||||
#define SetWindowLongPtr SetWindowLong
|
||||
#define GWLP_USERDATA GWL_USERDATA
|
||||
#define GWLP_WNDPROC GWL_WNDPROC
|
||||
typedef __int32 LONG_PTR;
|
||||
typedef unsigned __int32 ULONG_PTR;
|
||||
#endif // __int3264
|
||||
|
||||
|
||||
#define WM_SPLASHUPDATE WM_USER+1
|
||||
#define WM_SPLASHRECONFIGURE WM_USER+2
|
||||
|
||||
@ -436,16 +418,11 @@ SplashUnlock(Splash * splash)
|
||||
void
|
||||
SplashInitPlatform(Splash * splash)
|
||||
{
|
||||
HMODULE user32 = LoadLibrary("user32.dll");
|
||||
HDC hdc;
|
||||
int paletteMode;
|
||||
|
||||
InitializeCriticalSection(&splash->lock);
|
||||
splash->isLayered = FALSE;
|
||||
if (user32) {
|
||||
UpdateLayeredWindow = (UpdateLayeredWindowT *)
|
||||
GetProcAddress(user32, "UpdateLayeredWindow");
|
||||
}
|
||||
hdc = GetDC(NULL);
|
||||
paletteMode = (GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) != 0;
|
||||
if (UpdateLayeredWindow && !paletteMode) {
|
||||
|
@ -184,7 +184,7 @@ void D3DPipelineManager::NotifyAdapterEventListeners(UINT adapter,
|
||||
pMgr = D3DPipelineManager::GetInstance();
|
||||
RETURN_IF_NULL(pMgr);
|
||||
hMon = pMgr->pd3d9->GetAdapterMonitor(adapter);
|
||||
gdiScreen = AwtWin32GraphicsDevice::GetScreenFromMHND((MHND)hMon);
|
||||
gdiScreen = AwtWin32GraphicsDevice::GetScreenFromHMONITOR(hMon);
|
||||
|
||||
JNU_CallStaticMethodByName(env, NULL,
|
||||
"sun/java2d/pipe/hw/AccelDeviceEventNotifier",
|
||||
@ -194,21 +194,21 @@ void D3DPipelineManager::NotifyAdapterEventListeners(UINT adapter,
|
||||
|
||||
UINT D3DPipelineManager::GetAdapterOrdinalForScreen(jint gdiScreen)
|
||||
{
|
||||
MHND mHnd = AwtWin32GraphicsDevice::GetMonitor(gdiScreen);
|
||||
if (mHnd == (MHND)0) {
|
||||
HMONITOR mHnd = AwtWin32GraphicsDevice::GetMonitor(gdiScreen);
|
||||
if (mHnd == (HMONITOR)0) {
|
||||
return D3DADAPTER_DEFAULT;
|
||||
}
|
||||
return GetAdapterOrdinalByHmon((HMONITOR)mHnd);
|
||||
}
|
||||
|
||||
// static
|
||||
HRESULT D3DPipelineManager::HandleAdaptersChange(HMONITOR *pMHNDs, UINT monNum)
|
||||
HRESULT D3DPipelineManager::HandleAdaptersChange(HMONITOR *pHMONITORs, UINT monNum)
|
||||
{
|
||||
HRESULT res = S_OK;
|
||||
BOOL bResetD3D = FALSE, bFound;
|
||||
|
||||
D3DPipelineManager *pMgr = D3DPipelineManager::GetInstance();
|
||||
RETURN_STATUS_IF_NULL(pMHNDs, E_FAIL);
|
||||
RETURN_STATUS_IF_NULL(pHMONITORs, E_FAIL);
|
||||
if (pMgr == NULL) {
|
||||
// NULL pMgr is valid when the pipeline is not enabled or if it hasn't
|
||||
// been created yet
|
||||
@ -234,7 +234,7 @@ HRESULT D3DPipelineManager::HandleAdaptersChange(HMONITOR *pMHNDs, UINT monNum)
|
||||
}
|
||||
bFound = FALSE;
|
||||
for (UINT mon = 0; mon < monNum; mon++) {
|
||||
if (pMHNDs[mon] == hMon) {
|
||||
if (pHMONITORs[mon] == hMon) {
|
||||
J2dTraceLn3(J2D_TRACE_VERBOSE,
|
||||
" adapter %d: found hmnd[%d]=0x%x", i, mon, hMon);
|
||||
bFound = TRUE;
|
||||
@ -364,8 +364,8 @@ D3DPipelineManager::CheckOSVersion()
|
||||
HRESULT
|
||||
D3DPipelineManager::GDICheckForBadHardware()
|
||||
{
|
||||
_DISPLAY_DEVICE dd;
|
||||
dd.dwSize = sizeof(DISPLAY_DEVICE);
|
||||
DISPLAY_DEVICE dd;
|
||||
dd.cb = sizeof(DISPLAY_DEVICE);
|
||||
|
||||
int failedDevices = 0;
|
||||
int attachedDevices = 0;
|
||||
@ -379,9 +379,9 @@ D3DPipelineManager::GDICheckForBadHardware()
|
||||
|
||||
// i<20 is to guard against buggy drivers
|
||||
while (EnumDisplayDevices(NULL, i, &dd, 0) && i < 20) {
|
||||
if (dd.dwFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) {
|
||||
if (dd.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) {
|
||||
attachedDevices++;
|
||||
id = dd.deviceID;
|
||||
id = dd.DeviceID;
|
||||
if (wcslen(id) > 21) {
|
||||
// get vendor ID
|
||||
wcsncpy(vendorId, id+8, 4);
|
||||
@ -796,7 +796,7 @@ HWND D3DPipelineManager::CreateDefaultFocusWindow()
|
||||
ZeroMemory(&mi, sizeof(MONITORINFO));
|
||||
mi.cbSize = sizeof(MONITORINFO);
|
||||
HMONITOR hMon = pd3d9->GetAdapterMonitor(adapterOrdinal);
|
||||
if (hMon == 0 || !GetMonitorInfo(hMon, (PMONITOR_INFO)&mi)) {
|
||||
if (hMon == 0 || !GetMonitorInfo(hMon, (LPMONITORINFO)&mi)) {
|
||||
J2dRlsTraceLn1(J2D_TRACE_ERROR,
|
||||
"D3DPPLM::CreateDefaultFocusWindow: "\
|
||||
"error getting monitor info for adapter=%d", adapterOrdinal);
|
||||
|
@ -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"
|
||||
|
@ -23,6 +23,8 @@
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
#include "D3DPipeline.h"
|
||||
|
||||
#include "sun_java2d_d3d_D3DRenderer.h"
|
||||
|
||||
#include "D3DContext.h"
|
||||
|
@ -23,8 +23,7 @@
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
#include <jni_util.h>
|
||||
#include "D3DPipeline.h"
|
||||
#include <jlong.h>
|
||||
#include "D3DSurfaceData.h"
|
||||
#include "D3DPipelineManager.h"
|
||||
|
@ -23,6 +23,7 @@
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
#include "awt.h"
|
||||
#include <sun_java2d_windows_GDIBlitLoops.h>
|
||||
#include "gdefs.h"
|
||||
#include "Trace.h"
|
||||
|
@ -23,6 +23,7 @@
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
#include "awt.h"
|
||||
#include "sun_java2d_windows_GDIRenderer.h"
|
||||
#include "java_awt_geom_PathIterator.h"
|
||||
|
||||
@ -31,11 +32,8 @@
|
||||
#include "awt_Pen.h"
|
||||
#include "awt_Brush.h"
|
||||
|
||||
#include "jni.h"
|
||||
|
||||
#include "GraphicsPrimitiveMgr.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <math.h> /* for cos(), sin(), etc */
|
||||
|
||||
#define MAX_CLAMP_BND (1<<26)
|
||||
|
@ -246,7 +246,7 @@ static BOOL GDIWinSD_CheckMonitorArea(GDIWinSDOps *wsdo,
|
||||
}
|
||||
if( numScreens > 1 ) {
|
||||
|
||||
MONITOR_INFO *miInfo;
|
||||
LPMONITORINFO miInfo;
|
||||
RECT rSect ={0,0,0,0};
|
||||
RECT rView ={bounds->x1, bounds->y1, bounds->x2, bounds->y2};
|
||||
retCode = FALSE;
|
||||
@ -258,7 +258,7 @@ static BOOL GDIWinSD_CheckMonitorArea(GDIWinSDOps *wsdo,
|
||||
::OffsetRect(&rView,
|
||||
(ptOrig.x), (ptOrig.y));
|
||||
|
||||
::IntersectRect(&rSect,&rView,&(miInfo->rMonitor));
|
||||
::IntersectRect(&rSect,&rView,&(miInfo->rcMonitor));
|
||||
|
||||
if( FALSE == ::IsRectEmpty(&rSect) ) {
|
||||
if( TRUE == ::EqualRect(&rSect,&rView) ) {
|
||||
|
@ -23,8 +23,6 @@
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
|
||||
#include <jni.h>
|
||||
#include <awt.h>
|
||||
#include "Trace.h"
|
||||
#include "WindowsFlags.h"
|
||||
|
@ -23,54 +23,26 @@
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
#include "awt.h"
|
||||
#include "ComCtl32Util.h"
|
||||
|
||||
ComCtl32Util::ComCtl32Util() {
|
||||
hModComCtl32 = NULL;
|
||||
m_bNewSubclassing = FALSE;
|
||||
|
||||
m_lpfnSetWindowSubclass = NULL;
|
||||
m_lpfnRemoveWindowSubclass = NULL;
|
||||
m_lpfnDefSubclassProc = NULL;
|
||||
}
|
||||
|
||||
ComCtl32Util::~ComCtl32Util() {
|
||||
DASSERT(hModComCtl32 == NULL);
|
||||
}
|
||||
|
||||
void ComCtl32Util::InitLibraries() {
|
||||
if (hModComCtl32 == NULL) {
|
||||
hModComCtl32 = ::LoadLibrary(TEXT("comctl32.dll"));
|
||||
if (hModComCtl32 != NULL) {
|
||||
m_lpfnSetWindowSubclass = (PFNSETWINDOWSUBCLASS)::GetProcAddress(hModComCtl32, "SetWindowSubclass");
|
||||
m_lpfnRemoveWindowSubclass = (PFNREMOVEWINDOWSUBCLASS)::GetProcAddress(hModComCtl32, "RemoveWindowSubclass");
|
||||
m_lpfnDefSubclassProc = (PFNDEFSUBCLASSPROC)::GetProcAddress(hModComCtl32, "DefSubclassProc");
|
||||
|
||||
m_bNewSubclassing = (m_lpfnSetWindowSubclass != NULL) &&
|
||||
(m_lpfnRemoveWindowSubclass != NULL) &&
|
||||
(m_lpfnDefSubclassProc != NULL);
|
||||
|
||||
fn_InitCommonControlsEx = (ComCtl32Util::InitCommonControlsExType)::GetProcAddress(hModComCtl32, "InitCommonControlsEx");
|
||||
InitCommonControls();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ComCtl32Util::FreeLibraries() {
|
||||
if (hModComCtl32 != NULL) {
|
||||
m_lpfnSetWindowSubclass = NULL;
|
||||
m_lpfnRemoveWindowSubclass = NULL;
|
||||
m_lpfnDefSubclassProc = NULL;
|
||||
::FreeLibrary(hModComCtl32);
|
||||
hModComCtl32 = NULL;
|
||||
}
|
||||
INITCOMMONCONTROLSEX iccex;
|
||||
memset(&iccex, 0, sizeof(INITCOMMONCONTROLSEX));
|
||||
iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
|
||||
::InitCommonControlsEx(&iccex);
|
||||
}
|
||||
|
||||
WNDPROC ComCtl32Util::SubclassHWND(HWND hwnd, WNDPROC _WindowProc) {
|
||||
if (m_bNewSubclassing) {
|
||||
DASSERT(hModComCtl32 != NULL);
|
||||
if (IS_WINXP) {
|
||||
const SUBCLASSPROC p = SharedWindowProc; // let compiler check type of SharedWindowProc
|
||||
m_lpfnSetWindowSubclass(hwnd, p, (UINT_PTR)_WindowProc, NULL); // _WindowProc is used as subclass ID
|
||||
::SetWindowSubclass(hwnd, p, (UINT_PTR)_WindowProc, NULL); // _WindowProc is used as subclass ID
|
||||
return NULL;
|
||||
} else {
|
||||
return (WNDPROC)::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)_WindowProc);
|
||||
@ -78,21 +50,17 @@ WNDPROC ComCtl32Util::SubclassHWND(HWND hwnd, WNDPROC _WindowProc) {
|
||||
}
|
||||
|
||||
void ComCtl32Util::UnsubclassHWND(HWND hwnd, WNDPROC _WindowProc, WNDPROC _DefWindowProc) {
|
||||
if (m_bNewSubclassing) {
|
||||
DASSERT(hModComCtl32 != NULL);
|
||||
DASSERT(_DefWindowProc == NULL);
|
||||
if (IS_WINXP) {
|
||||
const SUBCLASSPROC p = SharedWindowProc; // let compiler check type of SharedWindowProc
|
||||
m_lpfnRemoveWindowSubclass(hwnd, p, (UINT_PTR)_WindowProc); // _WindowProc is used as subclass ID
|
||||
::RemoveWindowSubclass(hwnd, p, (UINT_PTR)_WindowProc); // _WindowProc is used as subclass ID
|
||||
} else {
|
||||
::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)_DefWindowProc);
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT ComCtl32Util::DefWindowProc(WNDPROC _DefWindowProc, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||
if (m_bNewSubclassing) {
|
||||
DASSERT(hModComCtl32 != NULL);
|
||||
DASSERT(_DefWindowProc == NULL);
|
||||
return m_lpfnDefSubclassProc(hwnd, msg, wParam, lParam);
|
||||
if (IS_WINXP) {
|
||||
return ::DefSubclassProc(hwnd, msg, wParam, lParam);
|
||||
} else if (_DefWindowProc != NULL) {
|
||||
return ::CallWindowProc(_DefWindowProc, hwnd, msg, wParam, lParam);
|
||||
} else {
|
||||
@ -111,15 +79,3 @@ LRESULT ComCtl32Util::SharedWindowProc(HWND hwnd, UINT msg,
|
||||
|
||||
CATCH_BAD_ALLOC_RET(0);
|
||||
}
|
||||
|
||||
void ComCtl32Util::InitCommonControls()
|
||||
{
|
||||
if (fn_InitCommonControlsEx == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
INITCOMMONCONTROLSEX iccex;
|
||||
memset(&iccex, 0, sizeof(INITCOMMONCONTROLSEX));
|
||||
iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
|
||||
fn_InitCommonControlsEx(&iccex);
|
||||
}
|
||||
|
@ -30,20 +30,6 @@
|
||||
#ifndef _COMCTL32UTIL_H
|
||||
#define _COMCTL32UTIL_H
|
||||
|
||||
|
||||
/*
|
||||
* comctl32.dll version 6 subclassing - taken from PlatformSDK/Include/commctrl.h
|
||||
*/
|
||||
typedef LRESULT (CALLBACK *SUBCLASSPROC)(HWND hWnd, UINT uMsg, WPARAM wParam, \
|
||||
LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData);
|
||||
|
||||
typedef BOOL (WINAPI *PFNSETWINDOWSUBCLASS)(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR uIdSubclass, \
|
||||
DWORD_PTR dwRefData);
|
||||
typedef BOOL (WINAPI *PFNREMOVEWINDOWSUBCLASS)(HWND hWnd, SUBCLASSPROC pfnSubclass, \
|
||||
UINT_PTR uIdSubclass);
|
||||
|
||||
typedef LRESULT (WINAPI *PFNDEFSUBCLASSPROC)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
class ComCtl32Util
|
||||
{
|
||||
public:
|
||||
@ -52,21 +38,8 @@ class ComCtl32Util
|
||||
return theInstance;
|
||||
}
|
||||
|
||||
// loads comctl32.dll and checks if required routines are available
|
||||
// called from AwtToolkit::AwtToolkit()
|
||||
void InitLibraries();
|
||||
// unloads comctl32.dll
|
||||
// called from AwtToolkit::Dispose()
|
||||
void FreeLibraries();
|
||||
|
||||
//-- comctl32.dll version 6 subclassing API --//
|
||||
|
||||
INLINE BOOL IsNewSubclassing() {
|
||||
return m_bNewSubclassing;
|
||||
}
|
||||
|
||||
// if comctl32.dll version 6 is used returns NULL, otherwise
|
||||
// returns default window proc
|
||||
WNDPROC SubclassHWND(HWND hwnd, WNDPROC _WindowProc);
|
||||
// DefWindowProc is the same as returned from SubclassHWND
|
||||
void UnsubclassHWND(HWND hwnd, WNDPROC _WindowProc, WNDPROC _DefWindowProc);
|
||||
@ -77,19 +50,6 @@ class ComCtl32Util
|
||||
ComCtl32Util();
|
||||
~ComCtl32Util();
|
||||
|
||||
HMODULE hModComCtl32;
|
||||
|
||||
PFNSETWINDOWSUBCLASS m_lpfnSetWindowSubclass;
|
||||
PFNREMOVEWINDOWSUBCLASS m_lpfnRemoveWindowSubclass;
|
||||
PFNDEFSUBCLASSPROC m_lpfnDefSubclassProc;
|
||||
|
||||
typedef BOOL (WINAPI * InitCommonControlsExType)(const LPINITCOMMONCONTROLSEX lpInitCtrls);
|
||||
InitCommonControlsExType fn_InitCommonControlsEx;
|
||||
|
||||
void InitCommonControls();
|
||||
|
||||
BOOL m_bNewSubclassing;
|
||||
|
||||
// comctl32.dll version 6 window proc
|
||||
static LRESULT CALLBACK SharedWindowProc(HWND hwnd, UINT message,
|
||||
WPARAM wParam, LPARAM lParam,
|
||||
|
@ -83,9 +83,83 @@
|
||||
|
||||
#include "Devices.h"
|
||||
#include "Trace.h"
|
||||
#include "awt_Multimon.h"
|
||||
#include "D3DPipelineManager.h"
|
||||
|
||||
|
||||
/* Some helper functions (from awt_MMStub.h/cpp) */
|
||||
|
||||
int g_nMonitorCounter;
|
||||
int g_nMonitorLimit;
|
||||
HMONITOR* g_hmpMonitors;
|
||||
|
||||
// Callback for CountMonitors below
|
||||
BOOL WINAPI clb_fCountMonitors(HMONITOR hMon, HDC hDC, LPRECT rRect, LPARAM lP)
|
||||
{
|
||||
g_nMonitorCounter ++;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int WINAPI CountMonitors(void)
|
||||
{
|
||||
g_nMonitorCounter = 0;
|
||||
::EnumDisplayMonitors(NULL, NULL, clb_fCountMonitors, 0L);
|
||||
return g_nMonitorCounter;
|
||||
|
||||
}
|
||||
|
||||
// Callback for CollectMonitors below
|
||||
BOOL WINAPI clb_fCollectMonitors(HMONITOR hMon, HDC hDC, LPRECT rRect, LPARAM lP)
|
||||
{
|
||||
|
||||
if ((g_nMonitorCounter < g_nMonitorLimit) && (NULL != g_hmpMonitors)) {
|
||||
g_hmpMonitors[g_nMonitorCounter] = hMon;
|
||||
g_nMonitorCounter ++;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int WINAPI CollectMonitors(HMONITOR* hmpMonitors, int nNum)
|
||||
{
|
||||
int retCode = 0;
|
||||
|
||||
if (NULL != hmpMonitors) {
|
||||
|
||||
g_nMonitorCounter = 0;
|
||||
g_nMonitorLimit = nNum;
|
||||
g_hmpMonitors = hmpMonitors;
|
||||
|
||||
::EnumDisplayMonitors(NULL, NULL, clb_fCollectMonitors, 0L);
|
||||
|
||||
retCode = g_nMonitorCounter;
|
||||
|
||||
g_nMonitorCounter = 0;
|
||||
g_nMonitorLimit = 0;
|
||||
g_hmpMonitors = NULL;
|
||||
|
||||
}
|
||||
return retCode;
|
||||
}
|
||||
|
||||
BOOL WINAPI MonitorBounds(HMONITOR hmMonitor, RECT* rpBounds)
|
||||
{
|
||||
BOOL retCode = FALSE;
|
||||
|
||||
if ((NULL != hmMonitor) && (NULL != rpBounds)) {
|
||||
MONITORINFOEX miInfo;
|
||||
|
||||
memset((void*)(&miInfo), 0, sizeof(MONITORINFOEX));
|
||||
miInfo.cbSize = sizeof(MONITORINFOEX);
|
||||
|
||||
if (TRUE == (retCode = ::GetMonitorInfo(hmMonitor, &miInfo))) {
|
||||
(*rpBounds) = miInfo.rcMonitor;
|
||||
}
|
||||
}
|
||||
return retCode;
|
||||
}
|
||||
|
||||
/* End of helper functions */
|
||||
|
||||
Devices* Devices::theInstance = NULL;
|
||||
CriticalSection Devices::arrayLock;
|
||||
|
||||
@ -113,9 +187,9 @@ BOOL Devices::UpdateInstance(JNIEnv *env)
|
||||
{
|
||||
J2dTraceLn(J2D_TRACE_INFO, "Devices::UpdateInstance");
|
||||
|
||||
int numScreens = ::CountMonitors();
|
||||
MHND *monHds = (MHND *)safe_Malloc(numScreens * sizeof(MHND));
|
||||
if (numScreens != ::CollectMonitors(monHds, numScreens)) {
|
||||
int numScreens = CountMonitors();
|
||||
HMONITOR *monHds = (HMONITOR *)safe_Malloc(numScreens * sizeof(HMONITOR));
|
||||
if (numScreens != CollectMonitors(monHds, numScreens)) {
|
||||
J2dRlsTraceLn(J2D_TRACE_ERROR,
|
||||
"Devices::UpdateInstance: Failed to get all "\
|
||||
"monitor handles.");
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2001-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
|
||||
@ -70,4 +70,8 @@ static CriticalSection arrayLock;
|
||||
|
||||
};
|
||||
|
||||
// Some helper functions (from awt_MMStub.h/cpp)
|
||||
|
||||
BOOL WINAPI MonitorBounds (HMONITOR, RECT*);
|
||||
|
||||
#endif _DEVICES_H_
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1999-2005 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
|
||||
@ -25,7 +25,6 @@
|
||||
|
||||
#include "GDIHashtable.h"
|
||||
#include "awt_GDIObject.h"
|
||||
#include "awt_dlls.h"
|
||||
|
||||
GDIHashtable::BatchDestructionManager GDIHashtable::manager;
|
||||
|
||||
@ -46,7 +45,6 @@ void GDIHashtable::release(void* key) {
|
||||
DASSERT(value != NULL);
|
||||
m_deleteProc(value);
|
||||
}
|
||||
manager.update();
|
||||
}
|
||||
|
||||
void GDIHashtable::flush() {
|
||||
@ -128,9 +126,6 @@ void GDIHashtable::List::clear() {
|
||||
}
|
||||
}
|
||||
|
||||
#undef GFSR_GDIRESOURCES
|
||||
#define GFSR_GDIRESOURCES 0x0001
|
||||
|
||||
GDIHashtable::BatchDestructionManager::BatchDestructionManager(UINT nFirstThreshold,
|
||||
UINT nSecondThreshold,
|
||||
UINT nDestroyPeriod) :
|
||||
@ -138,48 +133,6 @@ GDIHashtable::BatchDestructionManager::BatchDestructionManager(UINT nFirstThresh
|
||||
m_nSecondThreshold(nSecondThreshold),
|
||||
m_nDestroyPeriod(nDestroyPeriod),
|
||||
m_nCounter(0),
|
||||
m_bBatchingEnabled(TRUE) {
|
||||
load_rsrc32_procs();
|
||||
}
|
||||
|
||||
void GDIHashtable::BatchDestructionManager::update() {
|
||||
|
||||
if (get_free_system_resources != NULL) {
|
||||
|
||||
CriticalSection::Lock l(m_managerLock);
|
||||
|
||||
if (m_nCounter < 0) {
|
||||
UINT nFreeResources = (*get_free_system_resources)(GFSR_GDIRESOURCES);
|
||||
/*
|
||||
* If m_bBatchingEnabled is FALSE there is no need
|
||||
* to flush since we have been destroying all
|
||||
* GDI resources as soon as they were released.
|
||||
*/
|
||||
if (m_bBatchingEnabled) {
|
||||
if (nFreeResources < m_nFirstThreshold) {
|
||||
flushAll();
|
||||
nFreeResources = (*get_free_system_resources)(GFSR_GDIRESOURCES);
|
||||
}
|
||||
}
|
||||
if (nFreeResources < m_nSecondThreshold) {
|
||||
m_bBatchingEnabled = FALSE;
|
||||
m_nCounter = m_nDestroyPeriod;
|
||||
} else {
|
||||
m_bBatchingEnabled = TRUE;
|
||||
/*
|
||||
* The frequency of checks must depend on the currect amount
|
||||
* of free space in GDI heaps. Otherwise we can run into the
|
||||
* Resource Meter warning dialog when GDI resources are low.
|
||||
* This is a heuristic rule that provides this dependency.
|
||||
* These numbers have been chosen because:
|
||||
* Resource Meter posts a warning dialog when less than 10%
|
||||
* of GDI resources are free.
|
||||
* 5 pens/brushes take 1%. So 3 is the upper bound.
|
||||
* When changing this rule you should check that performance
|
||||
* isn't affected (with Caffeine Mark and JMark).
|
||||
*/
|
||||
m_nCounter = (nFreeResources - 10) * 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_bBatchingEnabled(TRUE)
|
||||
{
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1999 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
|
||||
@ -151,12 +151,6 @@ class GDIHashtable : public Hashtable {
|
||||
*/
|
||||
INLINE void decrementCounter() { m_nCounter--; }
|
||||
|
||||
/**
|
||||
* Depending on the amount of free space in GDI heaps flushes
|
||||
* all GDIHashtables and sets the initial counter value.
|
||||
*/
|
||||
void update();
|
||||
|
||||
INLINE CriticalSection& getLock() { return m_managerLock; }
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2006 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
|
||||
@ -31,17 +31,27 @@
|
||||
// This file should stand independent of AWT and should ultimately be
|
||||
// put into its own DLL.
|
||||
#include <awt.h>
|
||||
#endif
|
||||
#else
|
||||
// Include jni_util.h first, so JNU_* macros can be redefined
|
||||
#include "jni_util.h"
|
||||
// Borrow some macros from awt.h
|
||||
#define JNU_NewStringPlatform(env, x) env->NewString(reinterpret_cast<jchar*>(x), static_cast<jsize>(_tcslen(x)))
|
||||
#define JNU_GetStringPlatformChars(env, x, y) reinterpret_cast<LPCWSTR>(env->GetStringChars(x, y))
|
||||
#define JNU_ReleaseStringPlatformChars(env, x, y) env->ReleaseStringChars(x, reinterpret_cast<const jchar*>(y))
|
||||
#endif // DEBUG
|
||||
|
||||
#include <windows.h>
|
||||
#include <shlobj.h>
|
||||
#include <shellapi.h>
|
||||
#include "jni_util.h"
|
||||
#include "jlong.h"
|
||||
#include "alloc.h"
|
||||
|
||||
#include "stdhdrs.h"
|
||||
#include "UnicowsLoader.h"
|
||||
|
||||
// Copy from shlguid.h which is no longer in PlatformSDK
|
||||
#ifndef DEFINE_SHLGUID
|
||||
#define DEFINE_SHLGUID(name, l, w1, w2) DEFINE_GUID(name, l, w1, w2, 0xC0, 0, 0, 0, 0, 0, 0, 0x46)
|
||||
#endif
|
||||
|
||||
// {93F2F68C-1D1B-11d3-A30E-00C04F79ABD1}
|
||||
DEFINE_GUID(IID_IShellFolder2, 0x93f2f68c, 0x1d1b, 0x11d3, 0xa3, 0xe, 0x0, 0xc0, 0x4f, 0x79, 0xab, 0xd1);
|
||||
@ -86,13 +96,15 @@ static jfieldID FID_folderType;
|
||||
static IMalloc* pMalloc;
|
||||
static IShellFolder* pDesktop;
|
||||
|
||||
static BOOL isXP;
|
||||
|
||||
// copied from awt.h, because it is not included in release
|
||||
#if defined (WIN32)
|
||||
#define IS_WINVISTA (!(::GetVersion() & 0x80000000) && LOBYTE(LOWORD(::GetVersion())) >= 6)
|
||||
#else
|
||||
#define IS_WINVISTA FALSE
|
||||
// Some macros from awt.h, because it is not included in release
|
||||
#ifndef IS_WIN2000
|
||||
#define IS_WIN2000 (LOBYTE(LOWORD(::GetVersion())) >= 5)
|
||||
#endif
|
||||
#ifndef IS_WINXP
|
||||
#define IS_WINXP ((IS_WIN2000 && HIBYTE(LOWORD(::GetVersion())) >= 1) || LOBYTE(LOWORD(::GetVersion())) > 5)
|
||||
#endif
|
||||
#ifndef IS_WINVISTA
|
||||
#define IS_WINVISTA (!(::GetVersion() & 0x80000000) && LOBYTE(LOWORD(::GetVersion())) >= 6)
|
||||
#endif
|
||||
|
||||
|
||||
@ -103,7 +115,6 @@ static BOOL initShellProcs()
|
||||
static HMODULE libShell32 = NULL;
|
||||
static HMODULE libUser32 = NULL;
|
||||
static HMODULE libComCtl32 = NULL;
|
||||
static HMODULE libUnicows = UnicowsLoader::GetModuleHandle();
|
||||
// If already initialized, return TRUE
|
||||
if (libShell32 != NULL && libUser32 != NULL) {
|
||||
return TRUE;
|
||||
@ -130,7 +141,7 @@ static BOOL initShellProcs()
|
||||
|
||||
// Set up procs - libShell32
|
||||
fn_FindExecutable = (FindExecutableType)GetProcAddress(
|
||||
(libUnicows ? libUnicows : libShell32), "FindExecutableW");
|
||||
libShell32, "FindExecutableW");
|
||||
if (fn_FindExecutable == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
@ -140,7 +151,7 @@ static BOOL initShellProcs()
|
||||
return FALSE;
|
||||
}
|
||||
fn_SHGetFileInfo = (SHGetFileInfoType)GetProcAddress(
|
||||
(libUnicows ? libUnicows : libShell32), "SHGetFileInfoW");
|
||||
libShell32, "SHGetFileInfoW");
|
||||
if (fn_SHGetFileInfo == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
@ -154,7 +165,7 @@ static BOOL initShellProcs()
|
||||
return FALSE;
|
||||
}
|
||||
fn_SHGetPathFromIDList = (SHGetPathFromIDListType)GetProcAddress(
|
||||
(libUnicows ? libUnicows : libShell32), "SHGetPathFromIDListW");
|
||||
libShell32, "SHGetPathFromIDListW");
|
||||
if (fn_SHGetPathFromIDList == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
@ -181,19 +192,19 @@ static BOOL initShellProcs()
|
||||
static jstring jstringFromSTRRET(JNIEnv* env, LPITEMIDLIST pidl, STRRET* pStrret) {
|
||||
switch (pStrret->uType) {
|
||||
case STRRET_CSTR :
|
||||
return JNU_NewStringPlatform(env, pStrret->cStr);
|
||||
return JNU_NewStringPlatform(env, reinterpret_cast<const char*>(pStrret->cStr));
|
||||
case STRRET_OFFSET :
|
||||
// Note : this may need to be WCHAR instead
|
||||
return JNU_NewStringPlatform(env,
|
||||
(CHAR*)pidl + pStrret->uOffset);
|
||||
case STRRET_WSTR :
|
||||
return env->NewString(pStrret->pOleStr,
|
||||
return env->NewString(reinterpret_cast<const jchar*>(pStrret->pOleStr),
|
||||
static_cast<jsize>(wcslen(pStrret->pOleStr)));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
// restoring the original definition
|
||||
#define JNU_NewStringPlatform(env, x) env->NewString(x, static_cast<jsize>(_tcslen(x)))
|
||||
#define JNU_NewStringPlatform(env, x) env->NewString(reinterpret_cast<jchar*>(x), static_cast<jsize>(_tcslen(x)))
|
||||
|
||||
/*
|
||||
* Class: sun_awt_shell_Win32ShellFolder2
|
||||
@ -212,13 +223,6 @@ JNIEXPORT void JNICALL Java_sun_awt_shell_Win32ShellFolder2_initIDs
|
||||
MID_relativePIDL = env->GetMethodID(cls, "setRelativePIDL", "(J)V");
|
||||
FID_displayName = env->GetFieldID(cls, "displayName", "Ljava/lang/String;");
|
||||
FID_folderType = env->GetFieldID(cls, "folderType", "Ljava/lang/String;");
|
||||
|
||||
// Find out if we are on XP or later
|
||||
long version = GetVersion();
|
||||
isXP = (!(version & 0x80000000) &&
|
||||
(LOBYTE(LOWORD(version)) == 5 &&
|
||||
HIBYTE(LOWORD(version)) >= 1) ||
|
||||
LOBYTE(LOWORD(version)) > 5);
|
||||
}
|
||||
|
||||
static IShellIcon* getIShellIcon(IShellFolder* pIShellFolder) {
|
||||
@ -669,46 +673,24 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getLinkLocation
|
||||
if (!CoInit(doCoUninit)) {
|
||||
return 0;
|
||||
}
|
||||
if (IS_NT) {
|
||||
IShellLinkW* psl;
|
||||
hres = ::CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLinkW, (LPVOID *)&psl);
|
||||
IShellLinkW* psl;
|
||||
hres = ::CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLinkW, (LPVOID *)&psl);
|
||||
if (SUCCEEDED(hres)) {
|
||||
IPersistFile* ppf;
|
||||
hres = psl->QueryInterface(IID_IPersistFile, (void**)&ppf);
|
||||
if (SUCCEEDED(hres)) {
|
||||
IPersistFile* ppf;
|
||||
hres = psl->QueryInterface(IID_IPersistFile, (void**)&ppf);
|
||||
hres = ppf->Load(wstr, STGM_READ);
|
||||
if (SUCCEEDED(hres)) {
|
||||
hres = ppf->Load(wstr, STGM_READ);
|
||||
if (SUCCEEDED(hres)) {
|
||||
if (resolve) {
|
||||
hres = psl->Resolve(NULL, 0);
|
||||
// Ignore failure
|
||||
}
|
||||
pidl = (LPITEMIDLIST)NULL;
|
||||
hres = psl->GetIDList(&pidl);
|
||||
if (resolve) {
|
||||
hres = psl->Resolve(NULL, 0);
|
||||
// Ignore failure
|
||||
}
|
||||
ppf->Release();
|
||||
pidl = (LPITEMIDLIST)NULL;
|
||||
hres = psl->GetIDList(&pidl);
|
||||
}
|
||||
psl->Release();
|
||||
}
|
||||
} else {
|
||||
IShellLinkA* psl;
|
||||
hres = ::CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLinkA, (LPVOID *)&psl);
|
||||
if (SUCCEEDED(hres)) {
|
||||
IPersistFile* ppf;
|
||||
hres = psl->QueryInterface(IID_IPersistFile, (void**)&ppf);
|
||||
if (SUCCEEDED(hres)) {
|
||||
hres = ppf->Load(wstr, STGM_READ);
|
||||
if (SUCCEEDED(hres)) {
|
||||
if (resolve) {
|
||||
hres = psl->Resolve(NULL, 0);
|
||||
// Ignore failure
|
||||
}
|
||||
pidl = (LPITEMIDLIST)NULL;
|
||||
hres = psl->GetIDList(&pidl);
|
||||
}
|
||||
ppf->Release();
|
||||
}
|
||||
psl->Release();
|
||||
ppf->Release();
|
||||
}
|
||||
psl->Release();
|
||||
}
|
||||
if (doCoUninit) {
|
||||
::CoUninitialize();
|
||||
@ -742,10 +724,10 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_parseDisplayName0
|
||||
int nLength = env->GetStringLength(jname);
|
||||
jchar* wszPath = new jchar[nLength + 1];
|
||||
const jchar* strPath = env->GetStringChars(jname, NULL);
|
||||
wcsncpy(wszPath, strPath, nLength);
|
||||
wcsncpy(reinterpret_cast<LPWSTR>(wszPath), reinterpret_cast<LPCWSTR>(strPath), nLength);
|
||||
wszPath[nLength] = 0;
|
||||
HRESULT res = pIShellFolder->ParseDisplayName(NULL, NULL,
|
||||
const_cast<jchar*>(wszPath), NULL, &pIDL, NULL);
|
||||
reinterpret_cast<LPWSTR>(wszPath), NULL, &pIDL, NULL);
|
||||
if (res != S_OK) {
|
||||
JNU_ThrowIOException(env, "Could not parse name");
|
||||
pIDL = 0;
|
||||
@ -804,7 +786,7 @@ JNIEXPORT jstring JNICALL Java_sun_awt_shell_Win32ShellFolder2_getExecutableType
|
||||
(JNIEnv* env, jobject folder, jstring path)
|
||||
{
|
||||
TCHAR szBuf[MAX_PATH];
|
||||
LPCTSTR szPath = (LPCTSTR)JNU_GetStringPlatformChars(env, path, NULL);
|
||||
LPCTSTR szPath = JNU_GetStringPlatformChars(env, path, NULL);
|
||||
if (szPath == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@ -827,7 +809,7 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getIcon
|
||||
{
|
||||
HICON hIcon = NULL;
|
||||
SHFILEINFO fileInfo;
|
||||
LPCTSTR pathStr = (LPCTSTR)JNU_GetStringPlatformChars(env, absolutePath, NULL);
|
||||
LPCTSTR pathStr = JNU_GetStringPlatformChars(env, absolutePath, NULL);
|
||||
if (fn_SHGetFileInfo(pathStr, 0L, &fileInfo, sizeof(fileInfo),
|
||||
SHGFI_ICON | (getLargeIcon ? 0 : SHGFI_SMALLICON)) != 0) {
|
||||
hIcon = fileInfo.hIcon;
|
||||
@ -890,52 +872,27 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_extractIcon
|
||||
}
|
||||
|
||||
HRESULT hres;
|
||||
if (IS_NT) {
|
||||
IExtractIconW* pIcon;
|
||||
hres = pIShellFolder->GetUIObjectOf(NULL, 1, const_cast<LPCITEMIDLIST*>(&pidl),
|
||||
IExtractIconW* pIcon;
|
||||
hres = pIShellFolder->GetUIObjectOf(NULL, 1, const_cast<LPCITEMIDLIST*>(&pidl),
|
||||
IID_IExtractIconW, NULL, (void**)&pIcon);
|
||||
if (SUCCEEDED(hres)) {
|
||||
WCHAR szBuf[MAX_PATH];
|
||||
INT index;
|
||||
UINT flags;
|
||||
hres = pIcon->GetIconLocation(GIL_FORSHELL, szBuf, MAX_PATH, &index, &flags);
|
||||
if (SUCCEEDED(hres)) {
|
||||
WCHAR szBuf[MAX_PATH];
|
||||
INT index;
|
||||
UINT flags;
|
||||
hres = pIcon->GetIconLocation(GIL_FORSHELL, szBuf, MAX_PATH, &index, &flags);
|
||||
HICON hIconLarge;
|
||||
hres = pIcon->Extract(szBuf, index, &hIconLarge, &hIcon, (16 << 16) + 32);
|
||||
if (SUCCEEDED(hres)) {
|
||||
HICON hIconLarge;
|
||||
hres = pIcon->Extract(szBuf, index, &hIconLarge, &hIcon, (16 << 16) + 32);
|
||||
if (SUCCEEDED(hres)) {
|
||||
if (getLargeIcon) {
|
||||
fn_DestroyIcon((HICON)hIcon);
|
||||
hIcon = hIconLarge;
|
||||
} else {
|
||||
fn_DestroyIcon((HICON)hIconLarge);
|
||||
}
|
||||
if (getLargeIcon) {
|
||||
fn_DestroyIcon((HICON)hIcon);
|
||||
hIcon = hIconLarge;
|
||||
} else {
|
||||
fn_DestroyIcon((HICON)hIconLarge);
|
||||
}
|
||||
}
|
||||
pIcon->Release();
|
||||
}
|
||||
} else {
|
||||
IExtractIconA* pIcon;
|
||||
hres = pIShellFolder->GetUIObjectOf(NULL, 1, const_cast<LPCITEMIDLIST*>(&pidl),
|
||||
IID_IExtractIconA, NULL, (void**)&pIcon);
|
||||
if (SUCCEEDED(hres)) {
|
||||
CHAR szBuf[MAX_PATH];
|
||||
INT index;
|
||||
UINT flags;
|
||||
hres = pIcon->GetIconLocation(GIL_FORSHELL, szBuf, MAX_PATH, &index, &flags);
|
||||
if (SUCCEEDED(hres)) {
|
||||
HICON hIconLarge;
|
||||
hres = pIcon->Extract(szBuf, index, &hIconLarge, &hIcon, (16 << 16) + 32);
|
||||
if (SUCCEEDED(hres)) {
|
||||
if (getLargeIcon) {
|
||||
fn_DestroyIcon((HICON)hIcon);
|
||||
hIcon = hIconLarge;
|
||||
} else {
|
||||
fn_DestroyIcon((HICON)hIconLarge);
|
||||
}
|
||||
}
|
||||
}
|
||||
pIcon->Release();
|
||||
}
|
||||
pIcon->Release();
|
||||
}
|
||||
if (doCoUninit) {
|
||||
::CoUninitialize();
|
||||
@ -987,7 +944,7 @@ JNIEXPORT jintArray JNICALL Java_sun_awt_shell_Win32ShellFolder2_getIconBits
|
||||
// XP supports alpha in some icons, and depending on device.
|
||||
// This should take precedence over the icon mask bits.
|
||||
BOOL hasAlpha = FALSE;
|
||||
if (isXP) {
|
||||
if (IS_WINXP) {
|
||||
for (int i = 0; i < nBits; i++) {
|
||||
if ((colorBits[i] & 0xff000000) != 0) {
|
||||
hasAlpha = TRUE;
|
||||
@ -1127,9 +1084,9 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getIconResource
|
||||
(JNIEnv* env, jclass cls, jstring libName, jint iconID,
|
||||
jint cxDesired, jint cyDesired, jboolean useVGAColors)
|
||||
{
|
||||
HINSTANCE libHandle = LoadLibrary(env->GetStringChars(libName, NULL));
|
||||
HINSTANCE libHandle = LoadLibrary(JNU_GetStringPlatformChars(env, libName, NULL));
|
||||
if (libHandle != NULL) {
|
||||
UINT fuLoad = (useVGAColors && !isXP) ? LR_VGACOLOR : 0;
|
||||
UINT fuLoad = (useVGAColors && !IS_WINXP) ? LR_VGACOLOR : 0;
|
||||
return ptr_to_jlong(LoadImage(libHandle, MAKEINTRESOURCE(iconID),
|
||||
IMAGE_ICON, cxDesired, cyDesired,
|
||||
fuLoad));
|
||||
|
@ -1,430 +0,0 @@
|
||||
/*
|
||||
* Copyright 2003-2005 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.
|
||||
*/
|
||||
|
||||
#include <float.h>
|
||||
#include "alloc.h"
|
||||
#include "UnicowsLoader.h"
|
||||
|
||||
/*
|
||||
* Support functions for the Microsoft Layer for Unicode (MSLU).
|
||||
*
|
||||
* The MSLU maps the wide char version of Windows APIs with strings
|
||||
* to their ANSI version equivalent on Win98/ME platforms.
|
||||
*
|
||||
* For more details on the MSLU, please refer to the MSDN webpage at:
|
||||
* http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mslu/winprog/microsoft_layer_for_unicode_on_windows_95_98_me_systems.asp
|
||||
*/
|
||||
|
||||
// The MSLU module handle. Only initialized on Win9x/ME.
|
||||
HMODULE UnicowsLoader::hmodUnicows = NULL;
|
||||
|
||||
// MSLU loader entry point, which is called when the module
|
||||
// is initialized.
|
||||
extern "C" HMODULE (__stdcall *_PfnLoadUnicows)(void) =
|
||||
&UnicowsLoader::LoadUnicows;
|
||||
|
||||
// Overriede APIs that are not supported by MSLU.
|
||||
extern "C" FARPROC Unicows_GetPrinterW =
|
||||
(FARPROC)&UnicowsLoader::GetPrinterWImpl;
|
||||
extern "C" FARPROC Unicows_EnumPrintersW =
|
||||
(FARPROC)&UnicowsLoader::EnumPrintersWImpl;
|
||||
|
||||
HMODULE __stdcall UnicowsLoader::LoadUnicows(void)
|
||||
{
|
||||
if (hmodUnicows != NULL) {
|
||||
return hmodUnicows;
|
||||
}
|
||||
|
||||
// Unfortunately, some DLLs that are loaded in conjunction with
|
||||
// unicows.dll may blow the FPU's control word. So save it here.
|
||||
unsigned int fpu_cw = _CW_DEFAULT;
|
||||
fpu_cw = _control87(0, 0);
|
||||
|
||||
// Loads the DLL, assuming that the DLL resides in the same directory
|
||||
// as the AWT(_G).DLL. We cannot use "sun.boot.library.path" system
|
||||
// property since there is no way to issue JNI calls at this point
|
||||
// (JNI_OnLoad is not yet called so it cannot obtain JavaVM structure)
|
||||
//
|
||||
// To obtain the AWT module handle, call GetModuleHandleA() directly,
|
||||
// instead of AwtToolkit.GetModuleHandle(). Otherwise it could cause
|
||||
// an infinite loop if some W call were made inside AwtToolkit class
|
||||
// initialization.
|
||||
HMODULE hmodAWT = GetModuleHandleA("awt");
|
||||
LPSTR abspath = (LPSTR)safe_Malloc(MAX_PATH);
|
||||
if (abspath != NULL) {
|
||||
GetModuleFileNameA(hmodAWT, abspath, MAX_PATH);
|
||||
*strrchr(abspath, '\\') = '\0';
|
||||
strcat(abspath, "\\unicows.dll");
|
||||
hmodUnicows = LoadLibraryA(abspath);
|
||||
free(abspath);
|
||||
}
|
||||
|
||||
// Restore the FPU control word if needed.
|
||||
if ( _control87(0, 0) != fpu_cw) {
|
||||
_control87(fpu_cw, 0xfffff);
|
||||
}
|
||||
|
||||
return hmodUnicows;
|
||||
}
|
||||
|
||||
HMODULE UnicowsLoader::GetModuleHandle(void)
|
||||
{
|
||||
return hmodUnicows;
|
||||
}
|
||||
|
||||
|
||||
// Convenient functions to convert DEVMODEA -> DEVMODEW
|
||||
void UnicowsLoader::DevModeA2DevModeW(
|
||||
const DEVMODEA * dma,
|
||||
DEVMODEW * dmw)
|
||||
{
|
||||
// convert string portions
|
||||
::MultiByteToWideChar(CP_ACP, 0, (CHAR *)dma->dmDeviceName, CCHDEVICENAME,
|
||||
dmw->dmDeviceName, CCHDEVICENAME);
|
||||
::MultiByteToWideChar(CP_ACP, 0, (CHAR *)dma->dmFormName, CCHDEVICENAME,
|
||||
dmw->dmFormName, CCHDEVICENAME);
|
||||
|
||||
// copy driver specific data if exists
|
||||
if (dma->dmDriverExtra != 0) {
|
||||
PBYTE pExtraA = (PBYTE)(dma + 1);
|
||||
PBYTE pExtraW = (PBYTE)(dmw + 1);
|
||||
memcpy(pExtraW, pExtraA, dma->dmDriverExtra);
|
||||
}
|
||||
|
||||
// copy normal struct members
|
||||
dmw->dmSpecVersion = dma->dmSpecVersion;
|
||||
dmw->dmDriverVersion = dma->dmDriverVersion;
|
||||
dmw->dmSize = dma->dmSize;
|
||||
dmw->dmDriverExtra = dma->dmDriverExtra;
|
||||
dmw->dmFields = dma->dmFields;
|
||||
dmw->dmPosition = dma->dmPosition;
|
||||
dmw->dmScale = dma->dmScale;
|
||||
dmw->dmCopies = dma->dmCopies;
|
||||
dmw->dmDefaultSource = dma->dmDefaultSource;
|
||||
dmw->dmPrintQuality = dma->dmPrintQuality;
|
||||
dmw->dmColor = dma->dmColor;
|
||||
dmw->dmDuplex = dma->dmDuplex;
|
||||
dmw->dmYResolution = dma->dmYResolution;
|
||||
dmw->dmTTOption = dma->dmTTOption;
|
||||
dmw->dmCollate = dma->dmCollate;
|
||||
dmw->dmLogPixels = dma->dmLogPixels;
|
||||
dmw->dmBitsPerPel = dma->dmBitsPerPel;
|
||||
dmw->dmPelsWidth = dma->dmPelsWidth;
|
||||
dmw->dmPelsHeight = dma->dmPelsHeight;
|
||||
dmw->dmDisplayFlags = dma->dmDisplayFlags;
|
||||
dmw->dmDisplayFrequency = dma->dmDisplayFrequency;
|
||||
#if(WINVER >= 0x0400)
|
||||
dmw->dmICMMethod = dma->dmICMMethod;
|
||||
dmw->dmICMIntent = dma->dmICMIntent;
|
||||
dmw->dmMediaType = dma->dmMediaType;
|
||||
dmw->dmDitherType = dma->dmDitherType;
|
||||
dmw->dmReserved1 = dma->dmReserved1;
|
||||
dmw->dmReserved2 = dma->dmReserved2;
|
||||
#if (WINVER >= 0x0500) || (_WIN32_WINNT >= 0x0400)
|
||||
dmw->dmPanningWidth = dma->dmPanningWidth;
|
||||
dmw->dmPanningHeight = dma->dmPanningHeight;
|
||||
#endif
|
||||
#endif /* WINVER >= 0x0400 */
|
||||
}
|
||||
|
||||
// PRINTER_INFO_1 struct converter
|
||||
void UnicowsLoader::PrinterInfo1A2W(
|
||||
const LPPRINTER_INFO_1A pi1A,
|
||||
LPPRINTER_INFO_1W pi1W,
|
||||
const DWORD num)
|
||||
{
|
||||
LPWSTR pwstrbuf = (LPWSTR)(pi1W + num);
|
||||
DWORD current;
|
||||
|
||||
// loop through all structures
|
||||
for (current = 0; current < num; current ++) {
|
||||
LPPRINTER_INFO_1A curPi1A = pi1A + current;
|
||||
LPPRINTER_INFO_1W curPi1W = pi1W + current;
|
||||
|
||||
// copy the structure itself
|
||||
memcpy(curPi1W, curPi1A, sizeof(_PRINTER_INFO_1W));
|
||||
|
||||
// copy string members
|
||||
StringA2W(curPi1A->pDescription, &(curPi1W->pDescription), &pwstrbuf);
|
||||
StringA2W(curPi1A->pName, &(curPi1W->pName), &pwstrbuf);
|
||||
StringA2W(curPi1A->pComment, &(curPi1W->pComment), &pwstrbuf);
|
||||
}
|
||||
}
|
||||
|
||||
// PRINTER_INFO_2 struct converter
|
||||
void UnicowsLoader::PrinterInfo2A2W(
|
||||
const LPPRINTER_INFO_2A pi2A,
|
||||
LPPRINTER_INFO_2W pi2W,
|
||||
const DWORD num)
|
||||
{
|
||||
PBYTE pbytebuf = (PBYTE)(pi2W + num);
|
||||
DWORD current;
|
||||
|
||||
// loop through all structures
|
||||
for (current = 0; current < num; current ++) {
|
||||
LPPRINTER_INFO_2A curPi2A = pi2A + current;
|
||||
LPPRINTER_INFO_2W curPi2W = pi2W + current;
|
||||
// copy the structure itself
|
||||
memcpy(curPi2W, curPi2A, sizeof(_PRINTER_INFO_2W));
|
||||
|
||||
// copy string members
|
||||
StringA2W(curPi2A->pServerName, &(curPi2W->pServerName), (LPWSTR *)&pbytebuf);
|
||||
StringA2W(curPi2A->pPrinterName, &(curPi2W->pPrinterName), (LPWSTR *)&pbytebuf);
|
||||
StringA2W(curPi2A->pShareName, &(curPi2W->pShareName), (LPWSTR *)&pbytebuf);
|
||||
StringA2W(curPi2A->pPortName, &(curPi2W->pPortName), (LPWSTR *)&pbytebuf);
|
||||
StringA2W(curPi2A->pDriverName, &(curPi2W->pDriverName), (LPWSTR *)&pbytebuf);
|
||||
StringA2W(curPi2A->pComment, &(curPi2W->pComment), (LPWSTR *)&pbytebuf);
|
||||
StringA2W(curPi2A->pLocation, &(curPi2W->pLocation), (LPWSTR *)&pbytebuf);
|
||||
StringA2W(curPi2A->pSepFile, &(curPi2W->pSepFile), (LPWSTR *)&pbytebuf);
|
||||
StringA2W(curPi2A->pPrintProcessor, &(curPi2W->pPrintProcessor), (LPWSTR *)&pbytebuf);
|
||||
StringA2W(curPi2A->pDatatype, &(curPi2W->pDatatype), (LPWSTR *)&pbytebuf);
|
||||
StringA2W(curPi2A->pParameters, &(curPi2W->pParameters), (LPWSTR *)&pbytebuf);
|
||||
|
||||
// copy DEVMODE structure
|
||||
if (curPi2A->pDevMode != NULL) {
|
||||
curPi2W->pDevMode = (LPDEVMODEW)pbytebuf;
|
||||
DevModeA2DevModeW(curPi2A->pDevMode, curPi2W->pDevMode);
|
||||
pbytebuf += sizeof(DEVMODEW) + curPi2A->pDevMode->dmDriverExtra;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PRINTER_INFO_5 struct converter
|
||||
void UnicowsLoader::PrinterInfo5A2W(
|
||||
const LPPRINTER_INFO_5A pi5A,
|
||||
LPPRINTER_INFO_5W pi5W,
|
||||
const DWORD num)
|
||||
{
|
||||
LPWSTR pbuf = (LPWSTR)(pi5W + num);
|
||||
DWORD current;
|
||||
|
||||
// loop through all structures
|
||||
for (current = 0; current < num; current ++) {
|
||||
LPPRINTER_INFO_5A curPi5A = pi5A + current;
|
||||
LPPRINTER_INFO_5W curPi5W = pi5W + current;
|
||||
|
||||
// copy the structure itself
|
||||
memcpy(curPi5W, curPi5A, sizeof(_PRINTER_INFO_5W));
|
||||
|
||||
// copy string members
|
||||
StringA2W(curPi5A->pPrinterName, &(curPi5W->pPrinterName), &pbuf);
|
||||
StringA2W(curPi5A->pPortName, &(curPi5W->pPortName), &pbuf);
|
||||
}
|
||||
}
|
||||
|
||||
// PRINTER_INFO_* struct converter. Supported levels are 1, 2, and 5.
|
||||
void UnicowsLoader::PrinterInfoA2W(
|
||||
const PVOID piA,
|
||||
PVOID piW,
|
||||
const DWORD Level,
|
||||
const DWORD num)
|
||||
{
|
||||
switch (Level) {
|
||||
case 1:
|
||||
PrinterInfo1A2W((LPPRINTER_INFO_1A)piA, (LPPRINTER_INFO_1W)piW, num);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
PrinterInfo2A2W((LPPRINTER_INFO_2A)piA, (LPPRINTER_INFO_2W)piW, num);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
PrinterInfo5A2W((LPPRINTER_INFO_5A)piA, (LPPRINTER_INFO_5W)piW, num);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// converts string members in PRINTER_INFO_* struct.
|
||||
void UnicowsLoader::StringA2W(
|
||||
LPCSTR pSrcA,
|
||||
LPWSTR * ppwstrDest,
|
||||
LPWSTR * ppwstrbuf)
|
||||
{
|
||||
if (pSrcA != NULL) {
|
||||
DWORD cchWideChar = ::MultiByteToWideChar(CP_ACP, 0, pSrcA, -1, NULL, 0);
|
||||
*ppwstrDest = *ppwstrbuf;
|
||||
::MultiByteToWideChar(CP_ACP, 0, pSrcA, -1, *ppwstrbuf, cchWideChar);
|
||||
*ppwstrbuf += cchWideChar;
|
||||
} else {
|
||||
*ppwstrDest = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// GetPrinterW implementation. Level 1, 2, and 5 are the only supported levels.
|
||||
BOOL __stdcall UnicowsLoader::GetPrinterWImpl(
|
||||
HANDLE hPrinter,
|
||||
DWORD Level,
|
||||
LPBYTE pPrinter,
|
||||
DWORD cbBuf,
|
||||
LPDWORD pcbNeeded)
|
||||
{
|
||||
if ((Level != 1) && (Level != 2) && (Level != 5)) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DWORD cbBufA = (cbBuf != 0 ? cbBuf / 2 : 0); // dirty estimation...
|
||||
LPBYTE pPrinterA = NULL;
|
||||
DWORD cbNeededA = 0;
|
||||
BOOL ret;
|
||||
|
||||
if (cbBufA != 0) {
|
||||
pPrinterA = (LPBYTE)safe_Malloc(cbBufA);
|
||||
memset(pPrinterA, 0, cbBufA);
|
||||
}
|
||||
|
||||
ret = ::GetPrinterA(hPrinter, Level, pPrinterA, cbBufA, &cbNeededA);
|
||||
*pcbNeeded = cbNeededA * 2; // dirty estimation...
|
||||
|
||||
if (pPrinterA != NULL) {
|
||||
if (ret) {
|
||||
PrinterInfoA2W(pPrinterA, pPrinter, Level, 1);
|
||||
}
|
||||
free(pPrinterA);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// EnumPrintersW implementation. Level 1, 2, and 5 are the only supported levels.
|
||||
BOOL __stdcall UnicowsLoader::EnumPrintersWImpl(
|
||||
DWORD Flags,
|
||||
LPWSTR Name,
|
||||
DWORD Level,
|
||||
LPBYTE pPrinterEnum,
|
||||
DWORD cbBuf,
|
||||
LPDWORD pcbNeeded,
|
||||
LPDWORD pcReturned)
|
||||
{
|
||||
if ((Level != 1) && (Level != 2) && (Level != 5)) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LPSTR pNameA = NULL;
|
||||
DWORD cbBufA = (cbBuf != 0 ? cbBuf / 2 : 0); // dirty estimation...
|
||||
LPBYTE pPrinterEnumA = NULL;
|
||||
DWORD cbNeededA = 0;
|
||||
BOOL ret;
|
||||
|
||||
if (Name != NULL) {
|
||||
DWORD len = static_cast<DWORD>(wcslen(Name)) + 1;
|
||||
pNameA = (LPSTR)safe_Malloc(len);
|
||||
::WideCharToMultiByte(CP_ACP, 0, Name, -1, pNameA, len, NULL, NULL);
|
||||
}
|
||||
|
||||
if (cbBufA != 0) {
|
||||
pPrinterEnumA = (LPBYTE)safe_Malloc(cbBufA);
|
||||
memset(pPrinterEnumA, 0, cbBufA);
|
||||
}
|
||||
|
||||
ret = ::EnumPrintersA(Flags, pNameA, Level, pPrinterEnumA,
|
||||
cbBufA, &cbNeededA, pcReturned);
|
||||
*pcbNeeded = cbNeededA * 2; // dirty estimation...
|
||||
|
||||
if (pPrinterEnumA != NULL) {
|
||||
if (ret) {
|
||||
PrinterInfoA2W(pPrinterEnumA, pPrinterEnum, Level, *pcReturned);
|
||||
}
|
||||
free(pPrinterEnumA);
|
||||
}
|
||||
|
||||
if (pNameA != NULL) {
|
||||
free(pNameA);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// wchar CRT implementations that VC6 does not support on Win9x.
|
||||
// These implementations are used on both Win9x/ME *and* WinNT/2K/XP.
|
||||
#undef _waccess
|
||||
#undef _wchmod
|
||||
#undef _wfullpath
|
||||
#undef _wremove
|
||||
#undef _wrename
|
||||
#undef _wstat
|
||||
#undef _wstati64
|
||||
#undef _wstat64
|
||||
#undef _wunlink
|
||||
#undef _wfopen
|
||||
#undef _wfreopen
|
||||
#undef _wfsopen
|
||||
#undef _wcreat
|
||||
#undef _wopen
|
||||
#undef _wsopen
|
||||
#undef _wfindfirst
|
||||
#undef _wfindfirst64
|
||||
#undef _wfindnext
|
||||
#undef _wfindnext64
|
||||
#undef _wsystem
|
||||
#undef _wexcel
|
||||
#undef _wexcele
|
||||
#undef _wexelp
|
||||
#undef _wexelpe
|
||||
#undef _wexecv
|
||||
#undef _wexecve
|
||||
#undef _wexecvp
|
||||
#undef _wexecvpe
|
||||
#undef _wpopen
|
||||
#undef _wputenv
|
||||
#undef _wspawnl
|
||||
#undef _wspawnle
|
||||
#undef _wspawnlp
|
||||
#undef _wspawnlpe
|
||||
#undef _wspawnv
|
||||
#undef _wspawnve
|
||||
#undef _wspawnvp
|
||||
#undef _wspawnvpe
|
||||
|
||||
// _wfullpath implementation
|
||||
wchar_t * __cdecl UnicowsLoader::_wfullpathImpl(
|
||||
wchar_t * absPath,
|
||||
const wchar_t * relPath,
|
||||
size_t maxLength)
|
||||
{
|
||||
if (IS_NT) {
|
||||
return _wfullpath(absPath, relPath, maxLength);
|
||||
} else {
|
||||
wchar_t * ret = NULL;
|
||||
char * absPathA = (char *)safe_Malloc(maxLength);
|
||||
char * relPathA = (char *)safe_Malloc(maxLength);
|
||||
::WideCharToMultiByte(CP_ACP, 0, relPath, -1, relPathA,
|
||||
static_cast<DWORD>(maxLength), NULL, NULL);
|
||||
|
||||
char * retA = _fullpath(absPathA, relPathA, maxLength);
|
||||
|
||||
if (retA != NULL) {
|
||||
::MultiByteToWideChar(CP_ACP, 0, absPathA, -1,
|
||||
absPath, static_cast<DWORD>(maxLength));
|
||||
ret = absPath;
|
||||
}
|
||||
|
||||
free(absPathA);
|
||||
free(relPathA);
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
@ -1,198 +0,0 @@
|
||||
/*
|
||||
* Copyright 2003-2004 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.
|
||||
*/
|
||||
|
||||
#ifndef UNICOWSLOADER_H
|
||||
#define UNICOWSLOADER_H
|
||||
|
||||
#if !defined(UNICODE) || !defined(_UNICODE)
|
||||
#error UnicowsLoader module needs UNICODE and _UNICODE flags to be set on compiling
|
||||
#endif
|
||||
|
||||
#include <winspool.h>
|
||||
|
||||
// A class to load the Microsoft Layer for Unicode (unicows.dll)
|
||||
class UnicowsLoader {
|
||||
public:
|
||||
// this is called when the client DLL (this case, AWT) is loaded
|
||||
static HMODULE __stdcall LoadUnicows(void);
|
||||
|
||||
// this is provided to pass the MSLU module handle
|
||||
static HMODULE GetModuleHandle(void);
|
||||
|
||||
// member functions that implements functions that MSLU does not support
|
||||
static BOOL __stdcall GetPrinterWImpl(HANDLE, DWORD, LPBYTE, DWORD, LPDWORD);
|
||||
static BOOL __stdcall EnumPrintersWImpl(DWORD, LPWSTR, DWORD, LPBYTE,
|
||||
DWORD, LPDWORD, LPDWORD);
|
||||
|
||||
// member functions that implements functions that VC6 CRT does not support
|
||||
// on Win9x
|
||||
static wchar_t * __cdecl _wfullpathImpl(wchar_t *, const wchar_t *, size_t);
|
||||
|
||||
private:
|
||||
// The module handle
|
||||
static HMODULE hmodUnicows;
|
||||
|
||||
// utility member functions
|
||||
static void DevModeA2DevModeW(const DEVMODEA *, DEVMODEW *);
|
||||
static void PrinterInfo1A2W(const LPPRINTER_INFO_1A, LPPRINTER_INFO_1W, const DWORD);
|
||||
static void PrinterInfo2A2W(const LPPRINTER_INFO_2A, LPPRINTER_INFO_2W, const DWORD);
|
||||
static void PrinterInfo5A2W(const LPPRINTER_INFO_5A, LPPRINTER_INFO_5W, const DWORD);
|
||||
static void PrinterInfoA2W(const PVOID, PVOID, DWORD, DWORD);
|
||||
static void StringA2W(LPCSTR, LPWSTR *, LPWSTR *);
|
||||
};
|
||||
|
||||
#ifndef AWT_H
|
||||
// copied from awt.h
|
||||
#if defined (WIN32)
|
||||
#define IS_WIN32 TRUE
|
||||
#else
|
||||
#define IS_WIN32 FALSE
|
||||
#endif
|
||||
#define IS_NT (IS_WIN32 && !(::GetVersion() & 0x80000000))
|
||||
#endif // AWT_H
|
||||
|
||||
// Now the platform encoding is Unicode (UTF-16), re-define JNU_ functions
|
||||
// to proper JNI functions.
|
||||
#define JNU_NewStringPlatform(env, x) env->NewString(x, static_cast<jsize>(_tcslen(x)))
|
||||
#define JNU_GetStringPlatformChars(env, x, y) (LPWSTR)env->GetStringChars(x, y)
|
||||
#define JNU_ReleaseStringPlatformChars(env, x, y) env->ReleaseStringChars(x, y)
|
||||
|
||||
// The following Windows W-APIs are not supported by the MSLU.
|
||||
// You need to implement a stub to use these APIs. Or, if it is
|
||||
// apparent that the API is used only on WindowsNT/2K/XP, wrap
|
||||
// the call site with #undef - #define, e.g:
|
||||
//
|
||||
// #undef SomeFunctionW
|
||||
// call SomeFunctionW
|
||||
// #define SomeFunctionW NotSupportedByMSLU
|
||||
|
||||
#define AcquireCredentialsHandleW NotSupportedByMSLU
|
||||
#define CreateNamedPipeW NotSupportedByMSLU
|
||||
#define CryptAcquireContextW NotSupportedByMSLU
|
||||
#define CryptEnumProvidersW NotSupportedByMSLU
|
||||
#define CryptEnumProviderTypesW NotSupportedByMSLU
|
||||
#define CryptGetDefaultProviderW NotSupportedByMSLU
|
||||
#define CryptSetProviderW NotSupportedByMSLU
|
||||
#define CryptSetProviderExW NotSupportedByMSLU
|
||||
#define CryptSignHashW NotSupportedByMSLU
|
||||
#define CryptVerifySignatureW NotSupportedByMSLU
|
||||
#define EnumerateSecurityPackagesW NotSupportedByMSLU
|
||||
#define EnumMonitorsW NotSupportedByMSLU
|
||||
#define EnumPortsW NotSupportedByMSLU
|
||||
#define EnumPrinterDriversW NotSupportedByMSLU
|
||||
//#define EnumPrintersW NotSupportedByMSLU
|
||||
#define EnumPrintProcessorDatatypesW NotSupportedByMSLU
|
||||
#define EnumPrintProcessorsW NotSupportedByMSLU
|
||||
#define FreeContextBufferW NotSupportedByMSLU
|
||||
#define GetCharABCWidthsFloatW NotSupportedByMSLU
|
||||
#define GetJobW NotSupportedByMSLU
|
||||
#define GetOpenFileNamePreviewW NotSupportedByMSLU
|
||||
//#define GetPrinterW NotSupportedByMSLU
|
||||
#define GetPrinterDataW NotSupportedByMSLU
|
||||
#define GetPrinterDriverW NotSupportedByMSLU
|
||||
#define GetSaveFileNamePreviewW NotSupportedByMSLU
|
||||
#define InitializeSecurityContextW NotSupportedByMSLU
|
||||
#define mciSendCommandW NotSupportedByMSLU
|
||||
#define mixerGetControlDetailsW NotSupportedByMSLU
|
||||
#define mixerGetLineControlsW NotSupportedByMSLU
|
||||
#define mixerGetLineInfoW NotSupportedByMSLU
|
||||
#define mmioInstallIOProcW NotSupportedByMSLU
|
||||
#define OleUIChangeSourceW NotSupportedByMSLU
|
||||
#define OleUIConvertW NotSupportedByMSLU
|
||||
#define OleUIEditLinksW NotSupportedByMSLU
|
||||
#define OleUIInsertObjectW NotSupportedByMSLU
|
||||
#define OleUIObjectPropertiesW NotSupportedByMSLU
|
||||
#define OleUIPasteSpecialW NotSupportedByMSLU
|
||||
#define OleUIPromptUserW NotSupportedByMSLU
|
||||
#define OleUIUpdateLinksW NotSupportedByMSLU
|
||||
#define PolyTextOutW NotSupportedByMSLU
|
||||
#define QueryContextAttributesW NotSupportedByMSLU
|
||||
#define QueryCredentialsAttributesW NotSupportedByMSLU
|
||||
#define QuerySecurityPackageInfoW NotSupportedByMSLU
|
||||
#define RasDeleteSubEntryW NotSupportedByMSLU
|
||||
#define RasSetSubEntryPropertiesW NotSupportedByMSLU
|
||||
#define ResetPrinterW NotSupportedByMSLU
|
||||
|
||||
// The following Shell COM interfaces are not supported by the MSLU.
|
||||
// See ShellFolder2.cpp
|
||||
#define IID_IFileViewerW NotSupportedByMSLU
|
||||
#define IID_IShellLinkW NotSupportedByMSLU
|
||||
#define IID_IExtractIconW NotSupportedByMSLU
|
||||
#define IID_IShellCopyHookW NotSupportedByMSLU
|
||||
#define IID_IShellExecuteHookW NotSupportedByMSLU
|
||||
#define IID_INewShortcutHookW NotSupportedByMSLU
|
||||
|
||||
// The following CRT functions should fail on compiling, as it does not work on
|
||||
// Win9x/ME platform. If you need these CRTs, write a wrapper for ANSI version
|
||||
// equivalents, in which it converts to/from Unicode using WideCharToMultiByte.
|
||||
//
|
||||
// Or, if it is apparent that the function is used only on WindowsNT/2K/XP, wrap
|
||||
// the call site with #undef - #define, e.g:
|
||||
//
|
||||
// #undef _wsomefunc
|
||||
// call _wsomefunc
|
||||
// #define _wsomefunc NotSupportedOnWin9X
|
||||
|
||||
#define _waccess NotSupportedOnWin9X
|
||||
#define _wchmod NotSupportedOnWin9X
|
||||
#define _wfullpath UnicowsLoader::_wfullpathImpl
|
||||
#define _wremove NotSupportedOnWin9X
|
||||
#define _wrename NotSupportedOnWin9X
|
||||
#define _wstat NotSupportedOnWin9X
|
||||
#define _wstati64 NotSupportedOnWin9X
|
||||
#define _wstat64 NotSupportedOnWin9X
|
||||
#define _wunlink NotSupportedOnWin9X
|
||||
#define _wfopen NotSupportedOnWin9X
|
||||
#define _wfreopen NotSupportedOnWin9X
|
||||
#define _wfsopen NotSupportedOnWin9X
|
||||
#define _wcreat NotSupportedOnWin9X
|
||||
#define _wopen NotSupportedOnWin9X
|
||||
#define _wsopen NotSupportedOnWin9X
|
||||
#define _wfindfirst NotSupportedOnWin9X
|
||||
#define _wfindfirst64 NotSupportedOnWin9X
|
||||
#define _wfindnext NotSupportedOnWin9X
|
||||
#define _wfindnext64 NotSupportedOnWin9X
|
||||
#define _wsystem NotSupportedOnWin9X
|
||||
#define _wexcel NotSupportedOnWin9X
|
||||
#define _wexcele NotSupportedOnWin9X
|
||||
#define _wexelp NotSupportedOnWin9X
|
||||
#define _wexelpe NotSupportedOnWin9X
|
||||
#define _wexecv NotSupportedOnWin9X
|
||||
#define _wexecve NotSupportedOnWin9X
|
||||
#define _wexecvp NotSupportedOnWin9X
|
||||
#define _wexecvpe NotSupportedOnWin9X
|
||||
#define _wpopen NotSupportedOnWin9X
|
||||
#define _wputenv NotSupportedOnWin9X
|
||||
#define _wspawnl NotSupportedOnWin9X
|
||||
#define _wspawnle NotSupportedOnWin9X
|
||||
#define _wspawnlp NotSupportedOnWin9X
|
||||
#define _wspawnlpe NotSupportedOnWin9X
|
||||
#define _wspawnv NotSupportedOnWin9X
|
||||
#define _wspawnve NotSupportedOnWin9X
|
||||
#define _wspawnvp NotSupportedOnWin9X
|
||||
#define _wspawnvpe NotSupportedOnWin9X
|
||||
|
||||
|
||||
#endif // UNICOWSLOADER_H
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user