提交 ab95234e 编写于 作者: Y yan

Merge

...@@ -92,6 +92,7 @@ sanity-all:: sanity-base \ ...@@ -92,6 +92,7 @@ sanity-all:: sanity-base \
sane-ld_run_path \ sane-ld_run_path \
sane-alt_bootdir \ sane-alt_bootdir \
sane-bootdir \ sane-bootdir \
sane-local-bootdir \
sane-alsa-headers \ sane-alsa-headers \
sane-jibx sane-jibx
......
...@@ -431,9 +431,11 @@ DEVTOOLS_PATH:=$(call AltCheckSpaces,DEVTOOLS_PATH) ...@@ -431,9 +431,11 @@ DEVTOOLS_PATH:=$(call AltCheckSpaces,DEVTOOLS_PATH)
# _BOOTDIR1: First choice for a Bootstrap JDK, previous released JDK. # _BOOTDIR1: First choice for a Bootstrap JDK, previous released JDK.
# _BOOTDIR2: Second choice # _BOOTDIR2: Second choice
# The _BOOTDIR3 is defind optionally.
ifndef ALT_BOOTDIR ifndef ALT_BOOTDIR
_BOOTDIR1 =$(_system_drive)/jdk$(PREVIOUS_JDK_VERSION) _BOOTDIR1 =$(_system_drive)/jdk$(PREVIOUS_JDK_VERSION)
_BOOTDIR2 =$(USRJDKINSTANCES_PATH)/jdk$(PREVIOUS_JDK_VERSION) _BOOTDIR2 =$(USRJDKINSTANCES_PATH)/jdk$(PREVIOUS_JDK_VERSION)
_BOOTDIR3 =$(SLASH_JAVA)/re/jdk/$(PREVIOUS_JDK_VERSION)/archive/fcs/binaries/$(PLATFORM)-$(ARCH)
endif endif
# 32 bit always needs 2 runtimes, 64 bit usually does too # 32 bit always needs 2 runtimes, 64 bit usually does too
......
...@@ -94,6 +94,21 @@ $(shell \ ...@@ -94,6 +94,21 @@ $(shell \
fi) fi)
endef endef
# Select a directory if it exists, or the alternate 2, or the alternate 3, or the alternate 4
define DirExists4
$(shell \
if [ -d "$1" ]; then \
echo "$1"; \
elif [ -d "$2" ]; then \
echo "$2"; \
elif [ -d "$3" ]; then \
echo "$3"; \
else \
echo "$4"; \
fi)
endef
# Select a writable directory if it exists and is writable, or the alternate # Select a writable directory if it exists and is writable, or the alternate
define WriteDirExists define WriteDirExists
$(shell \ $(shell \
...@@ -356,10 +371,15 @@ endif ...@@ -356,10 +371,15 @@ endif
# BOOTDIR: Bootstrap JDK, previous released JDK. # BOOTDIR: Bootstrap JDK, previous released JDK.
# _BOOTDIR1 and _BOOTDIR2 picked by platform # _BOOTDIR1 and _BOOTDIR2 picked by platform
# Platform may optionally define _BOOTDIR3 as well.
ifdef ALT_BOOTDIR ifdef ALT_BOOTDIR
BOOTDIR =$(ALT_BOOTDIR) BOOTDIR =$(ALT_BOOTDIR)
else else
BOOTDIR :=$(call DirExists,$(_BOOTDIR1),$(_BOOTDIR2),/NO_BOOTDIR) ifdef _BOOTDIR3
BOOTDIR :=$(call DirExists4,$(_BOOTDIR1),$(_BOOTDIR2),$(_BOOTDIR3),/NO_BOOTDIR)
else
BOOTDIR :=$(call DirExists,$(_BOOTDIR1),$(_BOOTDIR2),/NO_BOOTDIR)
endif
endif endif
export BOOTDIR export BOOTDIR
BOOTDIR:=$(call AltCheckSpaces,BOOTDIR) BOOTDIR:=$(call AltCheckSpaces,BOOTDIR)
......
...@@ -194,7 +194,8 @@ include $(JDK_MAKE_SHARED_DIR)/Sanity-Settings.gmk ...@@ -194,7 +194,8 @@ include $(JDK_MAKE_SHARED_DIR)/Sanity-Settings.gmk
sane-outputdir \ sane-outputdir \
sane-alt_bootdir \ sane-alt_bootdir \
sane-bootdir \ sane-bootdir \
sane-cups \ sane-local-bootdir \
sane-cups \
sane-devtools_path \ sane-devtools_path \
sane-compiler_path \ sane-compiler_path \
sane-unixcommand_path \ sane-unixcommand_path \
...@@ -766,6 +767,23 @@ sane-bootdir: ...@@ -766,6 +767,23 @@ sane-bootdir:
"" >> $(ERROR_FILE) ; \ "" >> $(ERROR_FILE) ; \
fi fi
######################################################
# BOOTDIR is recommended to reside on a local drive
######################################################
sane-local-bootdir:
ifeq ($(PLATFORM), windows)
@if [ `$(ECHO) $(BOOTDIR) | $(EGREP) -ci '^J:'` -ne 0 ]; then \
$(ECHO) "WARNING: Your BOOTDIR is located on the J: drive. Often the J:\n" \
" drive is mapped over a network. Using a mapped drive for\n" \
" the BOOTDIR may significantly slow down the build process.\n" \
" You may want to consider using the ALT_BOOTDIR variable\n" \
" to point the build to another location for the BOOTDIR instead. \n" \
" Your current BOOTDIR is:\n" \
" $(BOOTDIR) \n" \
"" >> $(WARNING_FILE) ; \
fi
endif
###################################################### ######################################################
# CACERTS_FILE must be absoulte path and readable # CACERTS_FILE must be absoulte path and readable
###################################################### ######################################################
......
...@@ -128,6 +128,7 @@ SUNWprivate_1.1 { ...@@ -128,6 +128,7 @@ SUNWprivate_1.1 {
Java_sun_awt_X11_XlibWrapper_SetToolkitErrorHandler; Java_sun_awt_X11_XlibWrapper_SetToolkitErrorHandler;
Java_sun_awt_X11_XlibWrapper_XSetErrorHandler; Java_sun_awt_X11_XlibWrapper_XSetErrorHandler;
Java_sun_awt_X11_XlibWrapper_CallErrorHandler; Java_sun_awt_X11_XlibWrapper_CallErrorHandler;
Java_sun_awt_X11_XlibWrapper_PrintXErrorEvent;
Java_sun_awt_X11_XlibWrapper_XInternAtoms; Java_sun_awt_X11_XlibWrapper_XInternAtoms;
Java_sun_awt_X11_XlibWrapper_XChangeWindowAttributes; Java_sun_awt_X11_XlibWrapper_XChangeWindowAttributes;
Java_sun_awt_X11_XlibWrapper_XDeleteProperty; Java_sun_awt_X11_XlibWrapper_XDeleteProperty;
...@@ -154,7 +155,7 @@ SUNWprivate_1.1 { ...@@ -154,7 +155,7 @@ SUNWprivate_1.1 {
Java_sun_awt_X11_XRobotPeer_mouseReleaseImpl; Java_sun_awt_X11_XRobotPeer_mouseReleaseImpl;
Java_sun_awt_X11_XRobotPeer_mouseWheelImpl; Java_sun_awt_X11_XRobotPeer_mouseWheelImpl;
Java_sun_awt_X11_XRobotPeer_setup; Java_sun_awt_X11_XRobotPeer_setup;
Java_sun_awt_X11_XRobotPeer_getNumberOfButtonsImpl; Java_sun_awt_X11_XToolkit_getNumberOfButtonsImpl;
Java_java_awt_Component_initIDs; Java_java_awt_Component_initIDs;
Java_java_awt_Container_initIDs; Java_java_awt_Container_initIDs;
Java_java_awt_Button_initIDs; Java_java_awt_Button_initIDs;
...@@ -276,7 +277,6 @@ SUNWprivate_1.1 { ...@@ -276,7 +277,6 @@ SUNWprivate_1.1 {
Java_sun_awt_X11_XToolkit_getDefaultXColormap; Java_sun_awt_X11_XToolkit_getDefaultXColormap;
Java_sun_awt_X11_XToolkit_getDefaultScreenData; Java_sun_awt_X11_XToolkit_getDefaultScreenData;
Java_sun_awt_X11_XToolkit_getEnv; Java_sun_awt_X11_XToolkit_getEnv;
Java_sun_awt_X11_XToolkit_setNoisyXErrorHandler;
Java_sun_awt_X11_XlibWrapper_XCreateBitmapFromData; Java_sun_awt_X11_XlibWrapper_XCreateBitmapFromData;
Java_sun_awt_X11_XlibWrapper_XFreePixmap; Java_sun_awt_X11_XlibWrapper_XFreePixmap;
Java_sun_awt_X11_XlibWrapper_XAllocColor; Java_sun_awt_X11_XlibWrapper_XAllocColor;
......
...@@ -1038,15 +1038,25 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -1038,15 +1038,25 @@ public abstract class Component implements ImageObserver, MenuContainer,
void setGraphicsConfiguration(GraphicsConfiguration gc) { void setGraphicsConfiguration(GraphicsConfiguration gc) {
synchronized(getTreeLock()) { synchronized(getTreeLock()) {
graphicsConfig = gc; if (updateGraphicsData(gc)) {
removeNotify();
ComponentPeer peer = getPeer(); addNotify();
if (peer != null) {
peer.updateGraphicsData(gc);
} }
} }
} }
boolean updateGraphicsData(GraphicsConfiguration gc) {
checkTreeLock();
graphicsConfig = gc;
ComponentPeer peer = getPeer();
if (peer != null) {
return peer.updateGraphicsData(gc);
}
return false;
}
/** /**
* Checks that this component's <code>GraphicsDevice</code> * Checks that this component's <code>GraphicsDevice</code>
* <code>idString</code> matches the string argument. * <code>idString</code> matches the string argument.
......
...@@ -1113,16 +1113,17 @@ public class Container extends Component { ...@@ -1113,16 +1113,17 @@ public class Container extends Component {
} }
@Override @Override
void setGraphicsConfiguration(GraphicsConfiguration gc) { boolean updateGraphicsData(GraphicsConfiguration gc) {
synchronized (getTreeLock()) { checkTreeLock();
super.setGraphicsConfiguration(gc);
for (Component comp : component) { boolean ret = super.updateGraphicsData(gc);
if (comp != null) {
comp.setGraphicsConfiguration(gc); for (Component comp : component) {
} if (comp != null) {
ret |= comp.updateGraphicsData(gc);
} }
} }
return ret;
} }
/** /**
......
...@@ -436,7 +436,7 @@ public abstract class GraphicsConfiguration { ...@@ -436,7 +436,7 @@ public abstract class GraphicsConfiguration {
} }
/** /**
* Returns whether this GraphicsConfiguration supports * Returns whether this {@code GraphicsConfiguration} supports
* the {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT * the {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT
* PERPIXEL_TRANSLUCENT} kind of translucency. * PERPIXEL_TRANSLUCENT} kind of translucency.
* *
......
...@@ -246,7 +246,7 @@ public abstract class GraphicsDevice { ...@@ -246,7 +246,7 @@ public abstract class GraphicsDevice {
* Simulated full-screen mode resizes * Simulated full-screen mode resizes
* the window to the size of the screen and positions it at (0,0). * the window to the size of the screen and positions it at (0,0).
* <p> * <p>
* When entering full-screen mode, if the window to be used as the * When entering full-screen mode, if the window to be used as a
* full-screen window is not visible, this method will make it visible. * full-screen window is not visible, this method will make it visible.
* It will remain visible when returning to windowed mode. * It will remain visible when returning to windowed mode.
* <p> * <p>
...@@ -261,9 +261,9 @@ public abstract class GraphicsDevice { ...@@ -261,9 +261,9 @@ public abstract class GraphicsDevice {
* *
* @param w a window to use as the full-screen window; {@code null} * @param w a window to use as the full-screen window; {@code null}
* if returning to windowed mode. Some platforms expect the * if returning to windowed mode. Some platforms expect the
* fullscreen window to be a top-level component (i.e., a Frame); * fullscreen window to be a top-level component (i.e., a {@code Frame});
* therefore it is preferable to use a Frame here rather than a * therefore it is preferable to use a {@code Frame} here rather than a
* Window. * {@code Window}.
* *
* @see #isFullScreenSupported * @see #isFullScreenSupported
* @see #getFullScreenWindow * @see #getFullScreenWindow
......
...@@ -96,9 +96,13 @@ public class Robot { ...@@ -96,9 +96,13 @@ public class Robot {
init(GraphicsEnvironment.getLocalGraphicsEnvironment() init(GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice()); .getDefaultScreenDevice());
int tmpMask = 0; int tmpMask = 0;
if (Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){ if (Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){
for (int i = 0; i < peer.getNumberOfButtons(); i++){ if (Toolkit.getDefaultToolkit() instanceof SunToolkit) {
tmpMask |= InputEvent.getMaskForButton(i+1); final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons();
for (int i = 0; i < buttonsNumber; i++){
tmpMask |= InputEvent.getMaskForButton(i+1);
}
} }
} }
tmpMask |= InputEvent.BUTTON1_MASK| tmpMask |= InputEvent.BUTTON1_MASK|
......
...@@ -296,7 +296,7 @@ public class Window extends Container implements Accessible { ...@@ -296,7 +296,7 @@ public class Window extends Container implements Accessible {
transient boolean isInShow = false; transient boolean isInShow = false;
/* /*
* Opacity level of the window * The opacity level of the window
* *
* @serial * @serial
* @see #setOpacity(float) * @see #setOpacity(float)
...@@ -306,7 +306,7 @@ public class Window extends Container implements Accessible { ...@@ -306,7 +306,7 @@ public class Window extends Container implements Accessible {
private float opacity = 1.0f; private float opacity = 1.0f;
/* /*
* The shape assigned to this window. This field is set to null if * The shape assigned to this window. This field is set to {@code null} if
* no shape is set (rectangular window). * no shape is set (rectangular window).
* *
* @serial * @serial
...@@ -3592,10 +3592,10 @@ public class Window extends Container implements Accessible { ...@@ -3592,10 +3592,10 @@ public class Window extends Container implements Accessible {
@Override @Override
public void setBackground(Color bgColor) { public void setBackground(Color bgColor) {
Color oldBg = getBackground(); Color oldBg = getBackground();
super.setBackground(bgColor);
if (oldBg != null && oldBg.equals(bgColor)) { if (oldBg != null && oldBg.equals(bgColor)) {
return; return;
} }
super.setBackground(bgColor);
int oldAlpha = oldBg != null ? oldBg.getAlpha() : 255; int oldAlpha = oldBg != null ? oldBg.getAlpha() : 255;
int alpha = bgColor.getAlpha(); int alpha = bgColor.getAlpha();
if ((oldAlpha == 255) && (alpha < 255)) { // non-opaque window if ((oldAlpha == 255) && (alpha < 255)) { // non-opaque window
...@@ -3623,16 +3623,37 @@ public class Window extends Container implements Accessible { ...@@ -3623,16 +3623,37 @@ public class Window extends Container implements Accessible {
} }
} }
private void updateWindow(BufferedImage backBuffer) { private void updateWindow() {
synchronized (getTreeLock()) { synchronized (getTreeLock()) {
WindowPeer peer = (WindowPeer)getPeer(); WindowPeer peer = (WindowPeer)getPeer();
if (peer != null) { if (peer != null) {
peer.updateWindow(backBuffer); peer.updateWindow();
} }
} }
} }
private static final Color TRANSPARENT_BACKGROUND_COLOR = new Color(0, 0, 0, 0); /**
* {@inheritDoc}
*
* @since 1.7
*/
@Override
public void paint(Graphics g) {
Color bgColor = getBackground();
if ((bgColor != null) && (bgColor.getAlpha() < 255)) {
Graphics gg = g.create();
try {
if (gg instanceof Graphics2D) {
gg.setColor(bgColor);
((Graphics2D)gg).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC));
gg.fillRect(0, 0, getWidth(), getHeight());
}
} finally {
gg.dispose();
}
}
super.paint(g);
}
private static void setLayersOpaque(Component component, boolean isOpaque) { private static void setLayersOpaque(Component component, boolean isOpaque) {
// Shouldn't use instanceof to avoid loading Swing classes // Shouldn't use instanceof to avoid loading Swing classes
...@@ -3644,18 +3665,10 @@ public class Window extends Container implements Accessible { ...@@ -3644,18 +3665,10 @@ public class Window extends Container implements Accessible {
Container c = root.getContentPane(); Container c = root.getContentPane();
javax.swing.JComponent content = javax.swing.JComponent content =
(c instanceof javax.swing.JComponent) ? (javax.swing.JComponent)c : null; (c instanceof javax.swing.JComponent) ? (javax.swing.JComponent)c : null;
javax.swing.JComponent gp =
(rpc.getGlassPane() instanceof javax.swing.JComponent) ?
(javax.swing.JComponent)rpc.getGlassPane() : null;
if (gp != null) {
gp.setDoubleBuffered(isOpaque);
}
lp.setOpaque(isOpaque); lp.setOpaque(isOpaque);
root.setOpaque(isOpaque); root.setOpaque(isOpaque);
root.setDoubleBuffered(isOpaque);
if (content != null) { if (content != null) {
content.setOpaque(isOpaque); content.setOpaque(isOpaque);
content.setDoubleBuffered(isOpaque);
// Iterate down one level to see whether we have a JApplet // Iterate down one level to see whether we have a JApplet
// (which is also a RootPaneContainer) which requires processing // (which is also a RootPaneContainer) which requires processing
...@@ -3748,8 +3761,8 @@ public class Window extends Container implements Accessible { ...@@ -3748,8 +3761,8 @@ public class Window extends Container implements Accessible {
window.setBackground(new Color(bg.getRed(), bg.getGreen(), bg.getBlue(), window.setBackground(new Color(bg.getRed(), bg.getGreen(), bg.getBlue(),
opaque ? 255 : 0)); opaque ? 255 : 0));
} }
public void updateWindow(Window window, BufferedImage backBuffer) { public void updateWindow(Window window) {
window.updateWindow(backBuffer); window.updateWindow();
} }
public Dimension getSecurityWarningSize(Window window) { public Dimension getSecurityWarningSize(Window window) {
......
...@@ -157,6 +157,8 @@ public abstract class InputEvent extends ComponentEvent { ...@@ -157,6 +157,8 @@ public abstract class InputEvent extends ComponentEvent {
/** /**
* An array of extended modifiers for additional buttons. * An array of extended modifiers for additional buttons.
* @see getButtonDownMasks * @see getButtonDownMasks
* There are twenty buttons fit into 4byte space.
* one more bit is reserved for FIRST_HIGH_BIT.
* @since 7.0 * @since 7.0
*/ */
private static final int [] BUTTON_DOWN_MASK = new int [] { BUTTON1_DOWN_MASK, private static final int [] BUTTON_DOWN_MASK = new int [] { BUTTON1_DOWN_MASK,
...@@ -169,7 +171,16 @@ public abstract class InputEvent extends ComponentEvent { ...@@ -169,7 +171,16 @@ public abstract class InputEvent extends ComponentEvent {
1<<18, 1<<18,
1<<19, 1<<19,
1<<20, 1<<20,
1<<21 }; 1<<21,
1<<22,
1<<23,
1<<24,
1<<25,
1<<26,
1<<27,
1<<28,
1<<29,
1<<30};
/** /**
* A method to access an array of extended modifiers for additional buttons. * A method to access an array of extended modifiers for additional buttons.
...@@ -240,7 +251,7 @@ public abstract class InputEvent extends ComponentEvent { ...@@ -240,7 +251,7 @@ public abstract class InputEvent extends ComponentEvent {
// in fact, it is undesirable to add modifier bits // in fact, it is undesirable to add modifier bits
// to the same field as this may break applications // to the same field as this may break applications
// see bug# 5066958 // see bug# 5066958
static final int FIRST_HIGH_BIT = 1 << 22; static final int FIRST_HIGH_BIT = 1 << 31;
static final int JDK_1_3_MODIFIERS = SHIFT_DOWN_MASK - 1; static final int JDK_1_3_MODIFIERS = SHIFT_DOWN_MASK - 1;
static final int HIGH_MODIFIERS = ~( FIRST_HIGH_BIT - 1 ); static final int HIGH_MODIFIERS = ~( FIRST_HIGH_BIT - 1 );
......
...@@ -33,6 +33,7 @@ import java.io.IOException; ...@@ -33,6 +33,7 @@ import java.io.IOException;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.awt.IllegalComponentStateException; import java.awt.IllegalComponentStateException;
import java.awt.MouseInfo; import java.awt.MouseInfo;
import sun.awt.SunToolkit;
/** /**
* An event which indicates that a mouse action occurred in a component. * An event which indicates that a mouse action occurred in a component.
...@@ -379,12 +380,25 @@ public class MouseEvent extends InputEvent { ...@@ -379,12 +380,25 @@ public class MouseEvent extends InputEvent {
*/ */
private static final long serialVersionUID = -991214153494842848L; private static final long serialVersionUID = -991214153494842848L;
/**
* A number of buttons available on the mouse at the {@code Toolkit} machinery startup.
*/
private static int cachedNumberOfButtons;
static { static {
/* ensure that the necessary native libraries are loaded */ /* ensure that the necessary native libraries are loaded */
NativeLibLoader.loadLibraries(); NativeLibLoader.loadLibraries();
if (!GraphicsEnvironment.isHeadless()) { if (!GraphicsEnvironment.isHeadless()) {
initIDs(); initIDs();
} }
final Toolkit tk = Toolkit.getDefaultToolkit();
if (tk instanceof SunToolkit) {
cachedNumberOfButtons = ((SunToolkit)tk).getNumberOfButtons();
} else {
//It's expected that some toolkits (Headless,
//whatever besides SunToolkit) could also operate.
cachedNumberOfButtons = 3;
}
} }
/** /**
...@@ -411,15 +425,6 @@ public class MouseEvent extends InputEvent { ...@@ -411,15 +425,6 @@ public class MouseEvent extends InputEvent {
return new Point(xAbs, yAbs); 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. * Returns the absolute horizontal x position of the event.
* In a virtual device multi-screen environment in which the * In a virtual device multi-screen environment in which the
...@@ -735,7 +740,6 @@ public class MouseEvent extends InputEvent { ...@@ -735,7 +740,6 @@ public class MouseEvent extends InputEvent {
if (button < NOBUTTON){ if (button < NOBUTTON){
throw new IllegalArgumentException("Invalid button value :" + button); throw new IllegalArgumentException("Invalid button value :" + button);
} }
//TODO: initialize MouseInfo.cachedNumber on toolkit creation.
if (button > BUTTON3) { if (button > BUTTON3) {
if (!Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){ if (!Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){
throw new IllegalArgumentException("Extra mouse events are disabled " + button); throw new IllegalArgumentException("Extra mouse events are disabled " + button);
......
...@@ -548,7 +548,8 @@ public interface ComponentPeer { ...@@ -548,7 +548,8 @@ public interface ComponentPeer {
/** /**
* Updates internal data structures related to the component's GC. * Updates internal data structures related to the component's GC.
* *
* @return if the peer needs to be recreated for the changes to take effect
* @since 1.7 * @since 1.7
*/ */
void updateGraphicsData(GraphicsConfiguration gc); boolean updateGraphicsData(GraphicsConfiguration gc);
} }
...@@ -121,11 +121,4 @@ public interface RobotPeer ...@@ -121,11 +121,4 @@ public interface RobotPeer
* Disposes the robot peer when it is not needed anymore. * Disposes the robot peer when it is not needed anymore.
*/ */
void dispose(); void dispose();
/**
* Returns the number of buttons that the robot simulates.
*
* @return the number of buttons that the robot simulates
*/
int getNumberOfButtons();
} }
...@@ -110,12 +110,11 @@ public interface WindowPeer extends ContainerPeer { ...@@ -110,12 +110,11 @@ public interface WindowPeer extends ContainerPeer {
void setOpaque(boolean isOpaque); void setOpaque(boolean isOpaque);
/** /**
* Updates the native part of non-opaque window using * Updates the native part of non-opaque window.
* the given image with color+alpha values for each pixel.
* *
* @see Window#setBackground(Color) * @see Window#setBackground(Color)
*/ */
void updateWindow(BufferedImage backBuffer); void updateWindow();
/** /**
* Instructs the peer to update the position of the security warning. * Instructs the peer to update the position of the security warning.
......
...@@ -34,6 +34,9 @@ import java.awt.event.ComponentListener; ...@@ -34,6 +34,9 @@ import java.awt.event.ComponentListener;
import java.awt.event.ComponentAdapter; import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent; import java.awt.event.ComponentEvent;
import sun.awt.AWTAccessor;
import sun.awt.SunToolkit;
/** This is an implementation of the <code>DesktopManager</code>. /** This is an implementation of the <code>DesktopManager</code>.
* It currently implements the basic behaviors for managing * It currently implements the basic behaviors for managing
* <code>JInternalFrame</code>s in an arbitrary parent. * <code>JInternalFrame</code>s in an arbitrary parent.
...@@ -361,7 +364,7 @@ public class DefaultDesktopManager implements DesktopManager, java.io.Serializab ...@@ -361,7 +364,7 @@ public class DefaultDesktopManager implements DesktopManager, java.io.Serializab
g.dispose(); g.dispose();
} }
} else if (dragMode == FASTER_DRAG_MODE) { } else if (dragMode == FASTER_DRAG_MODE) {
dragFrameFaster(f, newX, newY); dragFrameFaster(f, newX, newY);
} else { } else {
setBoundsForFrame(f, newX, newY, f.getWidth(), f.getHeight()); setBoundsForFrame(f, newX, newY, f.getWidth(), f.getHeight());
} }
...@@ -634,13 +637,8 @@ public class DefaultDesktopManager implements DesktopManager, java.io.Serializab ...@@ -634,13 +637,8 @@ public class DefaultDesktopManager implements DesktopManager, java.io.Serializab
boolean floaterCollision = isFloaterCollision(previousBounds, currentBounds); boolean floaterCollision = isFloaterCollision(previousBounds, currentBounds);
// System.out.println(previousBounds);
JComponent parent = (JComponent)f.getParent(); JComponent parent = (JComponent)f.getParent();
Rectangle visBounds = previousBounds.intersection(desktopBounds); Rectangle visBounds = previousBounds.intersection(desktopBounds);
// System.out.println(previousBounds);
// System.out.println(visBounds);
RepaintManager currentManager = RepaintManager.currentManager(f); RepaintManager currentManager = RepaintManager.currentManager(f);
...@@ -682,7 +680,6 @@ public class DefaultDesktopManager implements DesktopManager, java.io.Serializab ...@@ -682,7 +680,6 @@ public class DefaultDesktopManager implements DesktopManager, java.io.Serializab
} else { } else {
dirtyRects = new Rectangle[1]; dirtyRects = new Rectangle[1];
dirtyRects[0] = previousBounds; dirtyRects[0] = previousBounds;
// System.out.println("no intersection");
}; };
// Fix the damage // Fix the damage
...@@ -701,14 +698,22 @@ public class DefaultDesktopManager implements DesktopManager, java.io.Serializab ...@@ -701,14 +698,22 @@ public class DefaultDesktopManager implements DesktopManager, java.io.Serializab
parent.paintImmediately(dirtyRects[i]); parent.paintImmediately(dirtyRects[i]);
((JInternalFrame)f).isDragging = true; ((JInternalFrame)f).isDragging = true;
// System.out.println(dirtyRects[i]);
} }
} }
} finally { } finally {
currentManager.endPaint(); currentManager.endPaint();
} }
// update window if it's non-opaque
Window topLevel = SwingUtilities.getWindowAncestor(f);
Toolkit tk = Toolkit.getDefaultToolkit();
if (!AWTAccessor.getWindowAccessor().isOpaque(topLevel) &&
(tk instanceof SunToolkit) &&
((SunToolkit)tk).needUpdateWindow())
{
AWTAccessor.getWindowAccessor().updateWindow(topLevel);
}
} }
private boolean isFloaterCollision(Rectangle moveFrom, Rectangle moveTo) { private boolean isFloaterCollision(Rectangle moveFrom, Rectangle moveTo) {
......
...@@ -1021,8 +1021,10 @@ public abstract class JComponent extends Container implements Serializable, ...@@ -1021,8 +1021,10 @@ public abstract class JComponent extends Container implements Serializable,
int bw,bh; int bw,bh;
boolean printing = getFlag(IS_PRINTING); boolean printing = getFlag(IS_PRINTING);
if(!printing && repaintManager.isDoubleBufferingEnabled() && if (!printing && repaintManager.isDoubleBufferingEnabled() &&
!getFlag(ANCESTOR_USING_BUFFER) && isDoubleBuffered()) { !getFlag(ANCESTOR_USING_BUFFER) && isDoubleBuffered() &&
(getFlag(IS_REPAINTING) || repaintManager.isPainting()))
{
repaintManager.beginPaint(); repaintManager.beginPaint();
try { try {
repaintManager.paint(this, this, co, clipX, clipY, clipW, repaintManager.paint(this, this, co, clipX, clipY, clipW,
......
...@@ -43,7 +43,6 @@ import sun.security.action.GetPropertyAction; ...@@ -43,7 +43,6 @@ import sun.security.action.GetPropertyAction;
import com.sun.java.swing.SwingUtilities3; import com.sun.java.swing.SwingUtilities3;
/** /**
* This class manages repaint requests, allowing the number * This class manages repaint requests, allowing the number
* of repaints to be minimized, for example by collapsing multiple * of repaints to be minimized, for example by collapsing multiple
...@@ -717,14 +716,12 @@ public class RepaintManager ...@@ -717,14 +716,12 @@ public class RepaintManager
} }
} }
private Map<Component,Rectangle> private void updateWindows(Map<Component,Rectangle> dirtyComponents) {
updateWindows(Map<Component,Rectangle> dirtyComponents)
{
Toolkit toolkit = Toolkit.getDefaultToolkit(); Toolkit toolkit = Toolkit.getDefaultToolkit();
if (!(toolkit instanceof SunToolkit && if (!(toolkit instanceof SunToolkit &&
((SunToolkit)toolkit).needUpdateWindow())) ((SunToolkit)toolkit).needUpdateWindow()))
{ {
return dirtyComponents; return;
} }
Set<Window> windows = new HashSet<Window>(); Set<Window> windows = new HashSet<Window>();
...@@ -734,25 +731,20 @@ public class RepaintManager ...@@ -734,25 +731,20 @@ public class RepaintManager
Window window = dirty instanceof Window ? Window window = dirty instanceof Window ?
(Window)dirty : (Window)dirty :
SwingUtilities.getWindowAncestor(dirty); SwingUtilities.getWindowAncestor(dirty);
if (window != null && if (window != null &&
!AWTAccessor.getWindowAccessor().isOpaque(window)) !AWTAccessor.getWindowAccessor().isOpaque(window))
{ {
// if this component's toplevel is perpixel translucent, it will
// be repainted below
it.remove();
// add to the set of windows to update (so that we don't update
// the window many times for each component to be repainted that
// belongs to this window)
windows.add(window); windows.add(window);
} }
} }
for (Window window : windows) { for (Window window : windows) {
AWTAccessor.getWindowAccessor().updateWindow(window, null); AWTAccessor.getWindowAccessor().updateWindow(window);
} }
}
return dirtyComponents; boolean isPainting() {
return painting;
} }
/** /**
...@@ -788,10 +780,6 @@ public class RepaintManager ...@@ -788,10 +780,6 @@ public class RepaintManager
int localBoundsW; int localBoundsW;
Enumeration keys; Enumeration keys;
// the components belonging to perpixel-translucent windows will be
// removed from the list
tmpDirtyComponents = updateWindows(tmpDirtyComponents);
roots = new ArrayList<Component>(count); roots = new ArrayList<Component>(count);
for (Component dirty : tmpDirtyComponents.keySet()) { for (Component dirty : tmpDirtyComponents.keySet()) {
...@@ -799,13 +787,11 @@ public class RepaintManager ...@@ -799,13 +787,11 @@ public class RepaintManager
} }
count = roots.size(); count = roots.size();
// System.out.println("roots size is " + count);
painting = true; painting = true;
try { try {
for(i=0 ; i < count ; i++) { for(i=0 ; i < count ; i++) {
dirtyComponent = roots.get(i); dirtyComponent = roots.get(i);
rect = tmpDirtyComponents.get(dirtyComponent); rect = tmpDirtyComponents.get(dirtyComponent);
// System.out.println("Should refresh :" + rect);
localBoundsH = dirtyComponent.getHeight(); localBoundsH = dirtyComponent.getHeight();
localBoundsW = dirtyComponent.getWidth(); localBoundsW = dirtyComponent.getWidth();
...@@ -848,6 +834,9 @@ public class RepaintManager ...@@ -848,6 +834,9 @@ public class RepaintManager
} finally { } finally {
painting = false; painting = false;
} }
updateWindows(tmpDirtyComponents);
tmpDirtyComponents.clear(); tmpDirtyComponents.clear();
} }
...@@ -1004,6 +993,16 @@ public class RepaintManager ...@@ -1004,6 +993,16 @@ public class RepaintManager
return delegate.getVolatileOffscreenBuffer(c, proposedWidth, return delegate.getVolatileOffscreenBuffer(c, proposedWidth,
proposedHeight); proposedHeight);
} }
// If the window is non-opaque, it's double-buffered at peer's level
Window w = (c instanceof Window) ? (Window)c : SwingUtilities.getWindowAncestor(c);
if (!AWTAccessor.getWindowAccessor().isOpaque(w)) {
Toolkit tk = Toolkit.getDefaultToolkit();
if ((tk instanceof SunToolkit) && (((SunToolkit)tk).needUpdateWindow())) {
return null;
}
}
GraphicsConfiguration config = c.getGraphicsConfiguration(); GraphicsConfiguration config = c.getGraphicsConfiguration();
if (config == null) { if (config == null) {
config = GraphicsEnvironment.getLocalGraphicsEnvironment(). config = GraphicsEnvironment.getLocalGraphicsEnvironment().
...@@ -1031,6 +1030,15 @@ public class RepaintManager ...@@ -1031,6 +1030,15 @@ public class RepaintManager
DoubleBufferInfo doubleBuffer; DoubleBufferInfo doubleBuffer;
int width, height; int width, height;
// If the window is non-opaque, it's double-buffered at peer's level
Window w = (c instanceof Window) ? (Window)c : SwingUtilities.getWindowAncestor(c);
if (!AWTAccessor.getWindowAccessor().isOpaque(w)) {
Toolkit tk = Toolkit.getDefaultToolkit();
if ((tk instanceof SunToolkit) && (((SunToolkit)tk).needUpdateWindow())) {
return null;
}
}
if (standardDoubleBuffer == null) { if (standardDoubleBuffer == null) {
standardDoubleBuffer = new DoubleBufferInfo(); standardDoubleBuffer = new DoubleBufferInfo();
} }
......
...@@ -132,7 +132,7 @@ public final class AWTAccessor { ...@@ -132,7 +132,7 @@ public final class AWTAccessor {
/* /*
* Update the image of a non-opaque (translucent) window. * Update the image of a non-opaque (translucent) window.
*/ */
void updateWindow(Window window, BufferedImage backBuffer); void updateWindow(Window window);
/** Get the size of the security warning. /** Get the size of the security warning.
*/ */
......
...@@ -592,8 +592,9 @@ public abstract class EmbeddedFrame extends Frame ...@@ -592,8 +592,9 @@ public abstract class EmbeddedFrame extends Frame
public void setOpaque(boolean isOpaque) { public void setOpaque(boolean isOpaque) {
} }
public void updateWindow(BufferedImage bi) { public void updateWindow() {
} }
public void repositionSecurityWarning() { public void repositionSecurityWarning() {
} }
} }
......
...@@ -179,9 +179,15 @@ public class HeadlessToolkit extends Toolkit ...@@ -179,9 +179,15 @@ public class HeadlessToolkit extends Toolkit
throw new HeadlessException(); throw new HeadlessException();
} }
public KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager) public KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager) {
throws HeadlessException { // See 6833019.
throw new HeadlessException(); return
new KeyboardFocusManagerPeer() {
public Window getCurrentFocusedWindow() { return null; }
public void setCurrentFocusOwner(Component comp) {}
public Component getCurrentFocusOwner() { return null; }
public void clearGlobalFocusOwner(Window activeWindow) {}
};
} }
public TrayIconPeer createTrayIcon(TrayIcon target) public TrayIconPeer createTrayIcon(TrayIcon target)
......
...@@ -300,7 +300,9 @@ public class NullComponentPeer implements LightweightPeer, ...@@ -300,7 +300,9 @@ public class NullComponentPeer implements LightweightPeer,
public void setZOrder(ComponentPeer above) { public void setZOrder(ComponentPeer above) {
} }
public void updateGraphicsData(GraphicsConfiguration gc) {} public boolean updateGraphicsData(GraphicsConfiguration gc) {
return false;
}
public GraphicsConfiguration getAppropriateGraphicsConfiguration( public GraphicsConfiguration getAppropriateGraphicsConfiguration(
GraphicsConfiguration gc) GraphicsConfiguration gc)
......
...@@ -89,6 +89,25 @@ public abstract class SunToolkit extends Toolkit ...@@ -89,6 +89,25 @@ public abstract class SunToolkit extends Toolkit
*/ */
private static final String POST_EVENT_QUEUE_KEY = "PostEventQueue"; private static final String POST_EVENT_QUEUE_KEY = "PostEventQueue";
/**
* 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.
*/
protected 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.
* InputEvent.BUTTON_DOWN_MASK may contain only 21 masks due to
* the 4-bytes limit for the int type. (CR 6799099)
* One more bit is reserved for FIRST_HIGH_BIT.
*/
public final static int MAX_BUTTONS_SUPPORTED = 20;
public SunToolkit() { public SunToolkit() {
/* If awt.threadgroup is set to class name the instance of /* If awt.threadgroup is set to class name the instance of
* this class is created (should be subclass of ThreadGroup) * this class is created (should be subclass of ThreadGroup)
...@@ -2079,6 +2098,12 @@ public abstract class SunToolkit extends Toolkit ...@@ -2079,6 +2098,12 @@ public abstract class SunToolkit extends Toolkit
return false; return false;
} }
/**
* Descendants of the SunToolkit should override and put their own logic here.
*/
public int getNumberOfButtons(){
return 3;
}
} // class SunToolkit } // class SunToolkit
......
...@@ -120,7 +120,7 @@ class MotifDnDConstants { ...@@ -120,7 +120,7 @@ class MotifDnDConstants {
false, false,
XConstants.AnyPropertyType); XConstants.AnyPropertyType);
try { try {
int status = wpg.execute(XToolkit.IgnoreBadWindowHandler); int status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status == XConstants.Success && if (status == XConstants.Success &&
wpg.getData() != 0 && wpg.getData() != 0 &&
...@@ -190,7 +190,7 @@ class MotifDnDConstants { ...@@ -190,7 +190,7 @@ class MotifDnDConstants {
try { try {
Native.putLong(data, motifWindow); Native.putLong(data, motifWindow);
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XlibWrapper.XChangeProperty(XToolkit.getDisplay(), XlibWrapper.XChangeProperty(XToolkit.getDisplay(),
defaultRootWindow, defaultRootWindow,
XA_MOTIF_DRAG_WINDOW.getAtom(), XA_MOTIF_DRAG_WINDOW.getAtom(),
...@@ -280,7 +280,7 @@ class MotifDnDConstants { ...@@ -280,7 +280,7 @@ class MotifDnDConstants {
false, false,
XA_MOTIF_DRAG_TARGETS.getAtom()); XA_MOTIF_DRAG_TARGETS.getAtom());
try { try {
int status = wpg.execute(XToolkit.IgnoreBadWindowHandler); int status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status != XConstants.Success if (status != XConstants.Success
|| wpg.getActualType() != XA_MOTIF_DRAG_TARGETS.getAtom() || wpg.getActualType() != XA_MOTIF_DRAG_TARGETS.getAtom()
...@@ -394,7 +394,7 @@ class MotifDnDConstants { ...@@ -394,7 +394,7 @@ class MotifDnDConstants {
} }
} }
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XlibWrapper.XChangeProperty(XToolkit.getDisplay(), XlibWrapper.XChangeProperty(XToolkit.getDisplay(),
motifWindow, motifWindow,
XA_MOTIF_DRAG_TARGETS.getAtom(), XA_MOTIF_DRAG_TARGETS.getAtom(),
...@@ -410,7 +410,7 @@ class MotifDnDConstants { ...@@ -410,7 +410,7 @@ class MotifDnDConstants {
// Create a new motif window and retry. // Create a new motif window and retry.
motifWindow = createMotifWindow(); motifWindow = createMotifWindow();
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XlibWrapper.XChangeProperty(XToolkit.getDisplay(), XlibWrapper.XChangeProperty(XToolkit.getDisplay(),
motifWindow, motifWindow,
XA_MOTIF_DRAG_TARGETS.getAtom(), XA_MOTIF_DRAG_TARGETS.getAtom(),
...@@ -534,7 +534,7 @@ class MotifDnDConstants { ...@@ -534,7 +534,7 @@ class MotifDnDConstants {
// CARD32 icc_handle // CARD32 icc_handle
unsafe.putInt(structData + 4, (int)XA_MOTIF_ATOM_0.getAtom()); unsafe.putInt(structData + 4, (int)XA_MOTIF_ATOM_0.getAtom());
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XlibWrapper.XChangeProperty(XToolkit.getDisplay(), window, XlibWrapper.XChangeProperty(XToolkit.getDisplay(), window,
XA_MOTIF_ATOM_0.getAtom(), XA_MOTIF_ATOM_0.getAtom(),
XA_MOTIF_DRAG_INITIATOR_INFO.getAtom(), XA_MOTIF_DRAG_INITIATOR_INFO.getAtom(),
...@@ -567,7 +567,7 @@ class MotifDnDConstants { ...@@ -567,7 +567,7 @@ class MotifDnDConstants {
unsafe.putShort(data + 10, (short)0); /* pad */ unsafe.putShort(data + 10, (short)0); /* pad */
unsafe.putInt(data + 12, dataSize); unsafe.putInt(data + 12, dataSize);
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XlibWrapper.XChangeProperty(XToolkit.getDisplay(), window, XlibWrapper.XChangeProperty(XToolkit.getDisplay(), window,
XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(), XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(),
XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(), XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(),
......
...@@ -184,7 +184,7 @@ class MotifDnDDragSourceProtocol extends XDragSourceProtocol ...@@ -184,7 +184,7 @@ class MotifDnDDragSourceProtocol extends XDragSourceProtocol
XConstants.AnyPropertyType); XConstants.AnyPropertyType);
try { try {
int status = wpg.execute(XToolkit.IgnoreBadWindowHandler); int status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
/* /*
* DragICCI.h: * DragICCI.h:
......
...@@ -102,7 +102,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -102,7 +102,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol {
XConstants.AnyPropertyType); XConstants.AnyPropertyType);
try { try {
status = wpg.execute(XToolkit.IgnoreBadWindowHandler); status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
/* /*
* DragICCI.h: * DragICCI.h:
...@@ -162,7 +162,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -162,7 +162,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol {
unsafe.putInt(data + 12, dataSize); unsafe.putInt(data + 12, dataSize);
} }
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XlibWrapper.XChangeProperty(XToolkit.getDisplay(), embedder, XlibWrapper.XChangeProperty(XToolkit.getDisplay(), embedder,
MotifDnDConstants.XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(), MotifDnDConstants.XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(),
MotifDnDConstants.XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(), MotifDnDConstants.XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(),
...@@ -204,7 +204,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -204,7 +204,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol {
XConstants.AnyPropertyType); XConstants.AnyPropertyType);
try { try {
status = wpg.execute(XToolkit.IgnoreBadWindowHandler); status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
/* /*
* DragICCI.h: * DragICCI.h:
...@@ -236,7 +236,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -236,7 +236,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol {
unsafe.putInt(data + 4, tproxy); unsafe.putInt(data + 4, tproxy);
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XlibWrapper.XChangeProperty(XToolkit.getDisplay(), embedder, XlibWrapper.XChangeProperty(XToolkit.getDisplay(), embedder,
MotifDnDConstants.XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(), MotifDnDConstants.XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(),
MotifDnDConstants.XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(), MotifDnDConstants.XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(),
...@@ -276,7 +276,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -276,7 +276,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol {
XConstants.AnyPropertyType); XConstants.AnyPropertyType);
try { try {
status = wpg.execute(XToolkit.IgnoreBadWindowHandler); status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
/* /*
* DragICCI.h: * DragICCI.h:
...@@ -325,7 +325,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -325,7 +325,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol {
XConstants.AnyPropertyType); XConstants.AnyPropertyType);
try { try {
int status = wpg.execute(XToolkit.IgnoreBadWindowHandler); int status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status == (int)XConstants.Success && wpg.getData() != 0 && if (status == (int)XConstants.Success && wpg.getData() != 0 &&
wpg.getActualType() != 0 && wpg.getActualFormat() == 8 && wpg.getActualType() != 0 && wpg.getActualFormat() == 8 &&
...@@ -375,7 +375,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -375,7 +375,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol {
MotifDnDConstants.XA_MOTIF_DRAG_INITIATOR_INFO.getAtom()); MotifDnDConstants.XA_MOTIF_DRAG_INITIATOR_INFO.getAtom());
try { try {
int status = wpg.execute(XToolkit.IgnoreBadWindowHandler); int status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status == XConstants.Success && wpg.getData() != 0 && if (status == XConstants.Success && wpg.getData() != 0 &&
wpg.getActualType() == wpg.getActualType() ==
...@@ -412,7 +412,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -412,7 +412,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol {
*/ */
XWindowAttributes wattr = new XWindowAttributes(); XWindowAttributes wattr = new XWindowAttributes();
try { try {
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(), int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
source_win, wattr.pData); source_win, wattr.pData);
...@@ -429,7 +429,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -429,7 +429,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol {
wattr.dispose(); wattr.dispose();
} }
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
XlibWrapper.XSelectInput(XToolkit.getDisplay(), source_win, XlibWrapper.XSelectInput(XToolkit.getDisplay(), source_win,
source_win_mask | source_win_mask |
XConstants.StructureNotifyMask); XConstants.StructureNotifyMask);
...@@ -1020,7 +1020,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -1020,7 +1020,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol {
if (sourceWindow != 0) { if (sourceWindow != 0) {
XToolkit.awtLock(); XToolkit.awtLock();
try { try {
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
XlibWrapper.XSelectInput(XToolkit.getDisplay(), sourceWindow, XlibWrapper.XSelectInput(XToolkit.getDisplay(), sourceWindow,
sourceWindowMask); sourceWindowMask);
XToolkit.RESTORE_XERROR_HANDLER(); XToolkit.RESTORE_XERROR_HANDLER();
......
...@@ -75,7 +75,7 @@ public class WindowPropertyGetter { ...@@ -75,7 +75,7 @@ public class WindowPropertyGetter {
public int execute() { public int execute() {
return execute(null); return execute(null);
} }
public int execute(XToolkit.XErrorHandler errorHandler) { public int execute(XErrorHandler errorHandler) {
XToolkit.awtLock(); XToolkit.awtLock();
try { try {
...@@ -94,7 +94,7 @@ public class WindowPropertyGetter { ...@@ -94,7 +94,7 @@ public class WindowPropertyGetter {
// Fix for performance problem - IgnodeBadWindowHandler is // Fix for performance problem - IgnodeBadWindowHandler is
// used too much without reason, just ignore it // used too much without reason, just ignore it
if (errorHandler == XToolkit.IgnoreBadWindowHandler) { if (errorHandler instanceof XErrorHandler.IgnoreBadWindowHandler) {
errorHandler = null; errorHandler = null;
} }
......
...@@ -126,7 +126,7 @@ class XAWTXSettings extends XSettings implements XMSelectionListener { ...@@ -126,7 +126,7 @@ class XAWTXSettings extends XSettings implements XMSelectionListener {
new WindowPropertyGetter(owner, xSettingsPropertyAtom, 0, MAX_LENGTH, new WindowPropertyGetter(owner, xSettingsPropertyAtom, 0, MAX_LENGTH,
false, xSettingsPropertyAtom.getAtom() ); false, xSettingsPropertyAtom.getAtom() );
try { try {
int status = getter.execute(XToolkit.IgnoreBadWindowHandler); int status = getter.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status != XConstants.Success || getter.getData() == 0) { if (status != XConstants.Success || getter.getData() == 0) {
if (log.isLoggable(Level.FINE)) log.fine("OH OH : getter failed status = " + status ); if (log.isLoggable(Level.FINE)) log.fine("OH OH : getter failed status = " + status );
......
...@@ -989,8 +989,17 @@ public class XBaseWindow { ...@@ -989,8 +989,17 @@ public class XBaseWindow {
*/ */
public void handleButtonPressRelease(XEvent xev) { public void handleButtonPressRelease(XEvent xev) {
XButtonEvent xbe = xev.get_xbutton(); XButtonEvent xbe = xev.get_xbutton();
/*
* Ignore the buttons above 20 due to the bit limit for
* InputEvent.BUTTON_DOWN_MASK.
* One more bit is reserved for FIRST_HIGH_BIT.
*/
if (xbe.get_button() > SunToolkit.MAX_BUTTONS_SUPPORTED) {
return;
}
int buttonState = 0; int buttonState = 0;
for (int i = 0; i<XToolkit.getNumMouseButtons(); i++){ final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons();
for (int i = 0; i<buttonsNumber; i++){
// A bug in WM implementation: extra buttons doesn't have state!=0 as they should on Release message. // A bug in WM implementation: extra buttons doesn't have state!=0 as they should on Release message.
if ((i != 4) && (i != 5)){ if ((i != 4) && (i != 5)){
buttonState |= (xbe.get_state() & XConstants.buttonsMask[i]); buttonState |= (xbe.get_state() & XConstants.buttonsMask[i]);
...@@ -1026,7 +1035,9 @@ public class XBaseWindow { ...@@ -1026,7 +1035,9 @@ public class XBaseWindow {
* Checks ButtonRelease released all Mouse buttons * Checks ButtonRelease released all Mouse buttons
*/ */
static boolean isFullRelease(int buttonState, int button) { static boolean isFullRelease(int buttonState, int button) {
if (button < 0 || button > XToolkit.getNumMouseButtons()) { final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons();
if (button < 0 || button > buttonsNumber) {
return buttonState == 0; return buttonState == 0;
} else { } else {
return buttonState == XConstants.buttonsMask[button - 1]; return buttonState == XConstants.buttonsMask[button - 1];
......
...@@ -1429,7 +1429,26 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget ...@@ -1429,7 +1429,26 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
} }
} }
public void updateGraphicsData(GraphicsConfiguration gc) { public boolean updateGraphicsData(GraphicsConfiguration gc) {
int oldVisual = -1, newVisual = -1;
if (graphicsConfig != null) {
oldVisual = graphicsConfig.getVisual();
}
if (gc != null && gc instanceof X11GraphicsConfig) {
newVisual = ((X11GraphicsConfig)gc).getVisual();
}
// If the new visual differs from the old one, the peer must be
// recreated because X11 does not allow changing the visual on the fly.
// So we even skip the initGraphicsConfiguration() call.
// The initial assignment should happen though, hence the != -1 thing.
if (oldVisual != -1 && oldVisual != newVisual) {
return true;
}
initGraphicsConfiguration(); initGraphicsConfiguration();
doValidateSurface();
return false;
} }
} }
...@@ -1100,7 +1100,8 @@ abstract class XDecoratedPeer extends XWindowPeer { ...@@ -1100,7 +1100,8 @@ abstract class XDecoratedPeer extends XWindowPeer {
} }
boolean isOverrideRedirect() { boolean isOverrideRedirect() {
return false; // return false;
return ((XToolkit)Toolkit.getDefaultToolkit()).isOverrideRedirect((Window)target);
} }
public boolean requestWindowFocus(long time, boolean timeProvided) { public boolean requestWindowFocus(long time, boolean timeProvided) {
......
...@@ -96,7 +96,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol { ...@@ -96,7 +96,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol {
action_count++; action_count++;
} }
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XDnDConstants.XA_XdndActionList.setAtomData(window, XDnDConstants.XA_XdndActionList.setAtomData(window,
XAtom.XA_ATOM, XAtom.XA_ATOM,
data, action_count); data, action_count);
...@@ -117,7 +117,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol { ...@@ -117,7 +117,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol {
try { try {
Native.put(data, formats); Native.put(data, formats);
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XDnDConstants.XA_XdndTypeList.setAtomData(window, XDnDConstants.XA_XdndTypeList.setAtomData(window,
XAtom.XA_ATOM, XAtom.XA_ATOM,
data, formats.length); data, formats.length);
...@@ -195,7 +195,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol { ...@@ -195,7 +195,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol {
new WindowPropertyGetter(window, XDnDConstants.XA_XdndAware, 0, 1, new WindowPropertyGetter(window, XDnDConstants.XA_XdndAware, 0, 1,
false, XConstants.AnyPropertyType); false, XConstants.AnyPropertyType);
int status = wpg1.execute(XToolkit.IgnoreBadWindowHandler); int status = wpg1.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status == XConstants.Success && if (status == XConstants.Success &&
wpg1.getData() != 0 && wpg1.getActualType() == XAtom.XA_ATOM) { wpg1.getData() != 0 && wpg1.getActualType() == XAtom.XA_ATOM) {
...@@ -215,7 +215,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol { ...@@ -215,7 +215,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol {
0, 1, false, XAtom.XA_WINDOW); 0, 1, false, XAtom.XA_WINDOW);
try { try {
status = wpg2.execute(XToolkit.IgnoreBadWindowHandler); status = wpg2.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status == XConstants.Success && if (status == XConstants.Success &&
wpg2.getData() != 0 && wpg2.getData() != 0 &&
...@@ -233,7 +233,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol { ...@@ -233,7 +233,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol {
0, 1, false, XAtom.XA_WINDOW); 0, 1, false, XAtom.XA_WINDOW);
try { try {
status = wpg3.execute(XToolkit.IgnoreBadWindowHandler); status = wpg3.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status != XConstants.Success || if (status != XConstants.Success ||
wpg3.getData() == 0 || wpg3.getData() == 0 ||
...@@ -249,7 +249,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol { ...@@ -249,7 +249,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol {
XConstants.AnyPropertyType); XConstants.AnyPropertyType);
try { try {
status = wpg4.execute(XToolkit.IgnoreBadWindowHandler); status = wpg4.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status != XConstants.Success || if (status != XConstants.Success ||
wpg4.getData() == 0 || wpg4.getData() == 0 ||
......
...@@ -88,7 +88,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -88,7 +88,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
try { try {
Native.putLong(data, 0, XDnDConstants.XDND_PROTOCOL_VERSION); Native.putLong(data, 0, XDnDConstants.XDND_PROTOCOL_VERSION);
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XDnDConstants.XA_XdndAware.setAtomData(window, XAtom.XA_ATOM, data, 1); XDnDConstants.XA_XdndAware.setAtomData(window, XAtom.XA_ATOM, data, 1);
XToolkit.RESTORE_XERROR_HANDLER(); XToolkit.RESTORE_XERROR_HANDLER();
...@@ -122,7 +122,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -122,7 +122,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
false, XConstants.AnyPropertyType); false, XConstants.AnyPropertyType);
try { try {
status = wpg1.execute(XToolkit.IgnoreBadWindowHandler); status = wpg1.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status == XConstants.Success && if (status == XConstants.Success &&
wpg1.getData() != 0 && wpg1.getActualType() == XAtom.XA_ATOM) { wpg1.getData() != 0 && wpg1.getActualType() == XAtom.XA_ATOM) {
...@@ -141,7 +141,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -141,7 +141,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
0, 1, false, XAtom.XA_WINDOW); 0, 1, false, XAtom.XA_WINDOW);
try { try {
status = wpg2.execute(XToolkit.IgnoreBadWindowHandler); status = wpg2.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status == XConstants.Success && if (status == XConstants.Success &&
wpg2.getData() != 0 && wpg2.getData() != 0 &&
...@@ -159,7 +159,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -159,7 +159,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
0, 1, false, XAtom.XA_WINDOW); 0, 1, false, XAtom.XA_WINDOW);
try { try {
status = wpg3.execute(XToolkit.IgnoreBadWindowHandler); status = wpg3.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status != XConstants.Success || if (status != XConstants.Success ||
wpg3.getData() == 0 || wpg3.getData() == 0 ||
...@@ -175,7 +175,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -175,7 +175,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
XConstants.AnyPropertyType); XConstants.AnyPropertyType);
try { try {
status = wpg4.execute(XToolkit.IgnoreBadWindowHandler); status = wpg4.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status != XConstants.Success || if (status != XConstants.Success ||
wpg4.getData() == 0 || wpg4.getData() == 0 ||
...@@ -205,7 +205,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -205,7 +205,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
/* The proxy window must have the XdndAware set, as XDnD protocol /* The proxy window must have the XdndAware set, as XDnD protocol
prescribes to check the proxy window for XdndAware. */ prescribes to check the proxy window for XdndAware. */
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XDnDConstants.XA_XdndAware.setAtomData(newProxy, XAtom.XA_ATOM, XDnDConstants.XA_XdndAware.setAtomData(newProxy, XAtom.XA_ATOM,
data, 1); data, 1);
XToolkit.RESTORE_XERROR_HANDLER(); XToolkit.RESTORE_XERROR_HANDLER();
...@@ -219,7 +219,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -219,7 +219,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
Native.putLong(data, 0, newProxy); Native.putLong(data, 0, newProxy);
/* The proxy window must have the XdndProxy set to point to itself.*/ /* The proxy window must have the XdndProxy set to point to itself.*/
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XDnDConstants.XA_XdndProxy.setAtomData(newProxy, XAtom.XA_WINDOW, XDnDConstants.XA_XdndProxy.setAtomData(newProxy, XAtom.XA_WINDOW,
data, 1); data, 1);
XToolkit.RESTORE_XERROR_HANDLER(); XToolkit.RESTORE_XERROR_HANDLER();
...@@ -232,7 +232,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -232,7 +232,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
Native.putLong(data, 0, XDnDConstants.XDND_PROTOCOL_VERSION); Native.putLong(data, 0, XDnDConstants.XDND_PROTOCOL_VERSION);
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XDnDConstants.XA_XdndAware.setAtomData(embedder, XAtom.XA_ATOM, XDnDConstants.XA_XdndAware.setAtomData(embedder, XAtom.XA_ATOM,
data, 1); data, 1);
XToolkit.RESTORE_XERROR_HANDLER(); XToolkit.RESTORE_XERROR_HANDLER();
...@@ -245,7 +245,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -245,7 +245,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
Native.putLong(data, 0, newProxy); Native.putLong(data, 0, newProxy);
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XDnDConstants.XA_XdndProxy.setAtomData(embedder, XAtom.XA_WINDOW, XDnDConstants.XA_XdndProxy.setAtomData(embedder, XAtom.XA_WINDOW,
data, 1); data, 1);
XToolkit.RESTORE_XERROR_HANDLER(); XToolkit.RESTORE_XERROR_HANDLER();
...@@ -278,7 +278,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -278,7 +278,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
try { try {
Native.putLong(data, 0, entry.getVersion()); Native.putLong(data, 0, entry.getVersion());
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XDnDConstants.XA_XdndAware.setAtomData(embedder, XAtom.XA_ATOM, XDnDConstants.XA_XdndAware.setAtomData(embedder, XAtom.XA_ATOM,
data, 1); data, 1);
XToolkit.RESTORE_XERROR_HANDLER(); XToolkit.RESTORE_XERROR_HANDLER();
...@@ -291,7 +291,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -291,7 +291,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
Native.putLong(data, 0, (int)entry.getProxy()); Native.putLong(data, 0, (int)entry.getProxy());
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XDnDConstants.XA_XdndProxy.setAtomData(embedder, XAtom.XA_WINDOW, XDnDConstants.XA_XdndProxy.setAtomData(embedder, XAtom.XA_WINDOW,
data, 1); data, 1);
XToolkit.RESTORE_XERROR_HANDLER(); XToolkit.RESTORE_XERROR_HANDLER();
...@@ -329,7 +329,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -329,7 +329,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
false, XConstants.AnyPropertyType); false, XConstants.AnyPropertyType);
try { try {
status = wpg1.execute(XToolkit.IgnoreBadWindowHandler); status = wpg1.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status == XConstants.Success && if (status == XConstants.Success &&
wpg1.getData() != 0 && wpg1.getActualType() == XAtom.XA_ATOM) { wpg1.getData() != 0 && wpg1.getActualType() == XAtom.XA_ATOM) {
...@@ -348,7 +348,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -348,7 +348,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
0, 1, false, XAtom.XA_WINDOW); 0, 1, false, XAtom.XA_WINDOW);
try { try {
status = wpg2.execute(XToolkit.IgnoreBadWindowHandler); status = wpg2.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status == XConstants.Success && if (status == XConstants.Success &&
wpg2.getData() != 0 && wpg2.getData() != 0 &&
...@@ -366,7 +366,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -366,7 +366,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
0, 1, false, XAtom.XA_WINDOW); 0, 1, false, XAtom.XA_WINDOW);
try { try {
status = wpg3.execute(XToolkit.IgnoreBadWindowHandler); status = wpg3.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status != XConstants.Success || if (status != XConstants.Success ||
wpg3.getData() == 0 || wpg3.getData() == 0 ||
...@@ -382,7 +382,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -382,7 +382,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
XConstants.AnyPropertyType); XConstants.AnyPropertyType);
try { try {
status = wpg4.execute(XToolkit.IgnoreBadWindowHandler); status = wpg4.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status != XConstants.Success || if (status != XConstants.Success ||
wpg4.getData() == 0 || wpg4.getData() == 0 ||
...@@ -411,7 +411,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -411,7 +411,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
false, XConstants.AnyPropertyType); false, XConstants.AnyPropertyType);
try { try {
int status = wpg1.execute(XToolkit.IgnoreBadWindowHandler); int status = wpg1.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status == XConstants.Success && if (status == XConstants.Success &&
wpg1.getData() != 0 && wpg1.getActualType() == XAtom.XA_ATOM) { wpg1.getData() != 0 && wpg1.getActualType() == XAtom.XA_ATOM) {
...@@ -473,7 +473,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -473,7 +473,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
0, 0xFFFF, false, 0, 0xFFFF, false,
XAtom.XA_ATOM); XAtom.XA_ATOM);
try { try {
wpg.execute(XToolkit.IgnoreBadWindowHandler); wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (wpg.getActualType() == XAtom.XA_ATOM && if (wpg.getActualType() == XAtom.XA_ATOM &&
wpg.getActualFormat() == 32) { wpg.getActualFormat() == 32) {
...@@ -505,7 +505,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -505,7 +505,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
0, 0xFFFF, false, 0, 0xFFFF, false,
XAtom.XA_ATOM); XAtom.XA_ATOM);
try { try {
wpg.execute(XToolkit.IgnoreBadWindowHandler); wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (wpg.getActualType() == XAtom.XA_ATOM && if (wpg.getActualType() == XAtom.XA_ATOM &&
wpg.getActualFormat() == 32) { wpg.getActualFormat() == 32) {
...@@ -541,7 +541,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -541,7 +541,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
*/ */
XWindowAttributes wattr = new XWindowAttributes(); XWindowAttributes wattr = new XWindowAttributes();
try { try {
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(), int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
source_win, wattr.pData); source_win, wattr.pData);
...@@ -558,7 +558,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -558,7 +558,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
wattr.dispose(); wattr.dispose();
} }
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
XlibWrapper.XSelectInput(XToolkit.getDisplay(), source_win, XlibWrapper.XSelectInput(XToolkit.getDisplay(), source_win,
source_win_mask | source_win_mask |
XConstants.StructureNotifyMask); XConstants.StructureNotifyMask);
...@@ -963,7 +963,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -963,7 +963,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
if (sourceWindow != 0) { if (sourceWindow != 0) {
XToolkit.awtLock(); XToolkit.awtLock();
try { try {
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
XlibWrapper.XSelectInput(XToolkit.getDisplay(), sourceWindow, XlibWrapper.XSelectInput(XToolkit.getDisplay(), sourceWindow,
sourceWindowMask); sourceWindowMask);
XToolkit.RESTORE_XERROR_HANDLER(); XToolkit.RESTORE_XERROR_HANDLER();
...@@ -1104,14 +1104,14 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -1104,14 +1104,14 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
0, 0xFFFF, false, 0, 0xFFFF, false,
XAtom.XA_ATOM); XAtom.XA_ATOM);
try { try {
wpg.execute(XToolkit.IgnoreBadWindowHandler); wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (wpg.getActualType() == XAtom.XA_ATOM && if (wpg.getActualType() == XAtom.XA_ATOM &&
wpg.getActualFormat() == 32) { wpg.getActualFormat() == 32) {
XToolkit.awtLock(); XToolkit.awtLock();
try { try {
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XDnDConstants.XA_XdndTypeList.setAtomData(xclient.get_window(), XDnDConstants.XA_XdndTypeList.setAtomData(xclient.get_window(),
XAtom.XA_ATOM, XAtom.XA_ATOM,
wpg.getData(), wpg.getData(),
......
...@@ -42,6 +42,7 @@ import sun.awt.ComponentAccessor; ...@@ -42,6 +42,7 @@ import sun.awt.ComponentAccessor;
import sun.awt.dnd.SunDragSourceContextPeer; import sun.awt.dnd.SunDragSourceContextPeer;
import sun.awt.dnd.SunDropTargetContextPeer; import sun.awt.dnd.SunDropTargetContextPeer;
import sun.awt.SunToolkit;
/** /**
* The XDragSourceContextPeer class is the class responsible for handling * The XDragSourceContextPeer class is the class responsible for handling
...@@ -665,6 +666,15 @@ public final class XDragSourceContextPeer ...@@ -665,6 +666,15 @@ public final class XDragSourceContextPeer
return true; return true;
case XConstants.ButtonRelease: { case XConstants.ButtonRelease: {
XButtonEvent xbutton = ev.get_xbutton(); XButtonEvent xbutton = ev.get_xbutton();
/*
* Ignore the buttons above 20 due to the bit limit for
* InputEvent.BUTTON_DOWN_MASK.
* One more bit is reserved for FIRST_HIGH_BIT.
*/
if (xbutton.get_button() > SunToolkit.MAX_BUTTONS_SUPPORTED) {
return true;
}
/* /*
* On some X servers it could happen that ButtonRelease coordinates * On some X servers it could happen that ButtonRelease coordinates
* differ from the latest MotionNotify coordinates, so we need to * differ from the latest MotionNotify coordinates, so we need to
......
...@@ -181,7 +181,7 @@ abstract class XDragSourceProtocol { ...@@ -181,7 +181,7 @@ abstract class XDragSourceProtocol {
long time) { long time) {
XWindowAttributes wattr = new XWindowAttributes(); XWindowAttributes wattr = new XWindowAttributes();
try { try {
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(), int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
targetWindow, wattr.pData); targetWindow, wattr.pData);
...@@ -198,7 +198,7 @@ abstract class XDragSourceProtocol { ...@@ -198,7 +198,7 @@ abstract class XDragSourceProtocol {
wattr.dispose(); wattr.dispose();
} }
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
XlibWrapper.XSelectInput(XToolkit.getDisplay(), targetWindow, XlibWrapper.XSelectInput(XToolkit.getDisplay(), targetWindow,
targetWindowMask | targetWindowMask |
XConstants.StructureNotifyMask); XConstants.StructureNotifyMask);
...@@ -214,7 +214,7 @@ abstract class XDragSourceProtocol { ...@@ -214,7 +214,7 @@ abstract class XDragSourceProtocol {
} }
protected final void finalizeDrop() { protected final void finalizeDrop() {
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
XlibWrapper.XSelectInput(XToolkit.getDisplay(), targetWindow, XlibWrapper.XSelectInput(XToolkit.getDisplay(), targetWindow,
targetWindowMask); targetWindowMask);
XToolkit.RESTORE_XERROR_HANDLER(); XToolkit.RESTORE_XERROR_HANDLER();
......
...@@ -168,7 +168,7 @@ final class XDropTargetRegistry { ...@@ -168,7 +168,7 @@ final class XDropTargetRegistry {
if (dest_x >= 0 && dest_y >= 0) { if (dest_x >= 0 && dest_y >= 0) {
XWindowAttributes wattr = new XWindowAttributes(); XWindowAttributes wattr = new XWindowAttributes();
try { try {
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(), int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
window, wattr.pData); window, wattr.pData);
XToolkit.RESTORE_XERROR_HANDLER(); XToolkit.RESTORE_XERROR_HANDLER();
...@@ -222,7 +222,7 @@ final class XDropTargetRegistry { ...@@ -222,7 +222,7 @@ final class XDropTargetRegistry {
long event_mask = 0; long event_mask = 0;
XWindowAttributes wattr = new XWindowAttributes(); XWindowAttributes wattr = new XWindowAttributes();
try { try {
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(), int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
embedder, wattr.pData); embedder, wattr.pData);
XToolkit.RESTORE_XERROR_HANDLER(); XToolkit.RESTORE_XERROR_HANDLER();
...@@ -240,7 +240,7 @@ final class XDropTargetRegistry { ...@@ -240,7 +240,7 @@ final class XDropTargetRegistry {
} }
if ((event_mask & XConstants.PropertyChangeMask) == 0) { if ((event_mask & XConstants.PropertyChangeMask) == 0) {
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
XlibWrapper.XSelectInput(XToolkit.getDisplay(), embedder, XlibWrapper.XSelectInput(XToolkit.getDisplay(), embedder,
event_mask | XConstants.PropertyChangeMask); event_mask | XConstants.PropertyChangeMask);
XToolkit.RESTORE_XERROR_HANDLER(); XToolkit.RESTORE_XERROR_HANDLER();
...@@ -394,7 +394,7 @@ final class XDropTargetRegistry { ...@@ -394,7 +394,7 @@ final class XDropTargetRegistry {
/* Restore the original event mask for the embedder. */ /* Restore the original event mask for the embedder. */
if ((event_mask & XConstants.PropertyChangeMask) == 0) { if ((event_mask & XConstants.PropertyChangeMask) == 0) {
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
XlibWrapper.XSelectInput(XToolkit.getDisplay(), embedder, XlibWrapper.XSelectInput(XToolkit.getDisplay(), embedder,
event_mask); event_mask);
XToolkit.RESTORE_XERROR_HANDLER(); XToolkit.RESTORE_XERROR_HANDLER();
......
...@@ -301,7 +301,7 @@ public class XEmbedCanvasPeer extends XCanvasPeer implements WindowFocusListener ...@@ -301,7 +301,7 @@ public class XEmbedCanvasPeer extends XCanvasPeer implements WindowFocusListener
try { try {
XWindowAttributes wattr = new XWindowAttributes(); XWindowAttributes wattr = new XWindowAttributes();
try { try {
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(), int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
xembed.handle, wattr.pData); xembed.handle, wattr.pData);
......
...@@ -386,5 +386,7 @@ public class XEmbedChildProxyPeer implements ComponentPeer, XEventDispatcher{ ...@@ -386,5 +386,7 @@ public class XEmbedChildProxyPeer implements ComponentPeer, XEventDispatcher{
public void setZOrder(ComponentPeer above) { public void setZOrder(ComponentPeer above) {
} }
public void updateGraphicsData(GraphicsConfiguration gc) {} public boolean updateGraphicsData(GraphicsConfiguration gc) {
return false;
}
} }
/*
* 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.X11;
public abstract class XErrorHandler {
/*
* Called under AWT lock
*/
public abstract int handleError(long display, XErrorEvent err);
/*
* Forwards all the errors to saved error handler (which was
* set before XToolkit had been initialized).
*/
public static class XBaseErrorHandler extends XErrorHandler {
@Override
public int handleError(long display, XErrorEvent err) {
return XToolkit.SAVED_ERROR_HANDLER(display, err);
}
}
/*
* Instead of validating window id, we simply call XGetWindowProperty,
* but temporary install this function as the error handler to ignore
* BadWindow error.
*/
public static class IgnoreBadWindowHandler extends XBaseErrorHandler {
@Override
public int handleError(long display, XErrorEvent err) {
if (err.get_error_code() == XConstants.BadWindow) {
return 0;
}
return super.handleError(display, err);
}
// Shared instance
private static IgnoreBadWindowHandler theInstance = new IgnoreBadWindowHandler();
public static IgnoreBadWindowHandler getInstance() {
return theInstance;
}
}
public static class VerifyChangePropertyHandler extends XBaseErrorHandler {
@Override
public int handleError(long display, XErrorEvent err) {
if (err.get_request_code() == XProtocolConstants.X_ChangeProperty) {
return 0;
}
return super.handleError(display, err);
}
// Shared instance
private static IgnoreBadWindowHandler theInstance = new IgnoreBadWindowHandler();
public static IgnoreBadWindowHandler getInstance() {
return theInstance;
}
}
}
...@@ -29,6 +29,9 @@ package sun.awt.X11; ...@@ -29,6 +29,9 @@ package sun.awt.X11;
import java.util.Hashtable; import java.util.Hashtable;
import sun.misc.Unsafe; import sun.misc.Unsafe;
import java.util.logging.Level;
import java.util.logging.Logger;
public class XKeysym { public class XKeysym {
public static void main( String args[] ) { public static void main( String args[] ) {
...@@ -67,6 +70,7 @@ public class XKeysym { ...@@ -67,6 +70,7 @@ public class XKeysym {
static Hashtable<Integer, Long> javaKeycode2KeysymHash = new Hashtable<Integer, Long>(); static Hashtable<Integer, Long> javaKeycode2KeysymHash = new Hashtable<Integer, Long>();
static long keysym_lowercase = unsafe.allocateMemory(Native.getLongSize()); static long keysym_lowercase = unsafe.allocateMemory(Native.getLongSize());
static long keysym_uppercase = unsafe.allocateMemory(Native.getLongSize()); static long keysym_uppercase = unsafe.allocateMemory(Native.getLongSize());
private static Logger keyEventLog = Logger.getLogger("sun.awt.X11.kye.XKeysym");
public static char convertKeysym( long ks, int state ) { public static char convertKeysym( long ks, int state ) {
/* First check for Latin-1 characters (1:1 mapping) */ /* First check for Latin-1 characters (1:1 mapping) */
...@@ -107,8 +111,15 @@ public class XKeysym { ...@@ -107,8 +111,15 @@ public class XKeysym {
// clearly means that caller needs a so called primary keysym. // clearly means that caller needs a so called primary keysym.
mods ^= XConstants.ShiftMask; mods ^= XConstants.ShiftMask;
} }
XlibWrapper.XkbTranslateKeyCode(XToolkit.getXKBKbdDesc(), ev.get_keycode(), long kbdDesc = XToolkit.getXKBKbdDesc();
if( kbdDesc != 0 ) {
XlibWrapper.XkbTranslateKeyCode(kbdDesc, ev.get_keycode(),
mods, XlibWrapper.iarg1, XlibWrapper.larg3); mods, XlibWrapper.iarg1, XlibWrapper.larg3);
}else{
// xkb resources already gone
keyEventLog.fine("Thread race: Toolkit shutdown before the end of a key event processing.");
return 0;
}
//XXX unconsumed modifiers? //XXX unconsumed modifiers?
return Native.getLong(XlibWrapper.larg3); return Native.getLong(XlibWrapper.larg3);
} finally { } finally {
......
...@@ -35,20 +35,6 @@ class XProtocol { ...@@ -35,20 +35,6 @@ class XProtocol {
private Map<XAtom, XAtomList> atomToList = new HashMap<XAtom, XAtomList>(); private Map<XAtom, XAtomList> atomToList = new HashMap<XAtom, XAtomList>();
private Map<XAtom, Long> atomToAnchor = new HashMap<XAtom, Long>(); private Map<XAtom, Long> atomToAnchor = new HashMap<XAtom, Long>();
/*
* Temporary error handler that ensures that we know if
* XChangeProperty succeeded or not.
*/
static XToolkit.XErrorHandler VerifyChangePropertyHandler = new XToolkit.XErrorHandler() {
public int handleError(long display, XErrorEvent err) {
XToolkit.XERROR_SAVE(err);
if (err.get_request_code() == XProtocolConstants.X_ChangeProperty) {
return 0;
} else {
return XToolkit.SAVED_ERROR_HANDLER(display, err);
}
}
};
volatile boolean firstCheck = true; volatile boolean firstCheck = true;
/* /*
* Check that that the list of protocols specified by WM in property * Check that that the list of protocols specified by WM in property
......
...@@ -52,7 +52,7 @@ public class XQueryTree { ...@@ -52,7 +52,7 @@ public class XQueryTree {
public int execute() { public int execute() {
return execute(null); return execute(null);
} }
public int execute(XToolkit.XErrorHandler errorHandler) { public int execute(XErrorHandler errorHandler) {
XToolkit.awtLock(); XToolkit.awtLock();
try { try {
if (isDisposed()) { if (isDisposed()) {
......
...@@ -81,16 +81,11 @@ class XRobotPeer implements RobotPeer { ...@@ -81,16 +81,11 @@ class XRobotPeer implements RobotPeer {
return pixelArray; return pixelArray;
} }
public int getNumberOfButtons(){
return getNumberOfButtonsImpl();
}
private static native synchronized void setup(); private static native synchronized void setup();
private static native synchronized void mouseMoveImpl(X11GraphicsConfig xgc, int x, int y); 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 mousePressImpl(int buttons);
private static native synchronized void mouseReleaseImpl(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 mouseWheelImpl(int wheelAmt);
private static native synchronized void keyPressImpl(int keycode); private static native synchronized void keyPressImpl(int keycode);
......
...@@ -84,21 +84,6 @@ public final class XToolkit extends UNIXToolkit implements Runnable { ...@@ -84,21 +84,6 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
//Set to true by default. //Set to true by default.
private static boolean areExtraMouseButtonsEnabled = true; 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. * True when the x settings have been loaded.
*/ */
...@@ -149,63 +134,78 @@ public final class XToolkit extends UNIXToolkit implements Runnable { ...@@ -149,63 +134,78 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
setBackingStoreType(); setBackingStoreType();
} }
m_removeSourceEvents = SunToolkit.getMethod(EventQueue.class, "removeSourceEvents", new Class[] {Object.class, Boolean.TYPE}) ; m_removeSourceEvents = SunToolkit.getMethod(EventQueue.class, "removeSourceEvents", new Class[] {Object.class, Boolean.TYPE}) ;
noisyAwtHandler = AccessController.doPrivileged(new GetBooleanAction("sun.awt.noisyerrorhandler"));
} }
// Error handler stuff //---- ERROR HANDLER CODE ----//
static XErrorEvent saved_error;
static long saved_error_handler; /*
static XErrorHandler curErrorHandler; * Error handler at the moment of XToolkit initialization
// Should be called under LOCK, before releasing LOCK RESTORE_XERROR_HANDLER should be called */
static void WITH_XERROR_HANDLER(XErrorHandler handler) { private static long saved_error_handler;
/*
* XErrorEvent being handled
*/
static volatile XErrorEvent saved_error;
/*
* Current error handler or null if no error handler is set
*/
private static XErrorHandler current_error_handler;
/*
* Value of sun.awt.noisyerrorhandler system property
*/
private static boolean noisyAwtHandler;
public static void WITH_XERROR_HANDLER(XErrorHandler handler) {
saved_error = null; saved_error = null;
curErrorHandler = handler; current_error_handler = handler;
XSync();
saved_error_handler = XlibWrapper.SetToolkitErrorHandler();
}
static void XERROR_SAVE(XErrorEvent event) {
saved_error = event;
} }
// Should be called under LOCK
static void RESTORE_XERROR_HANDLER() { public static void RESTORE_XERROR_HANDLER() {
XSync(); current_error_handler = null;
XlibWrapper.XSetErrorHandler(saved_error_handler);
curErrorHandler = null;
} }
// Should be called under LOCK // Should be called under LOCK
static int SAVED_ERROR_HANDLER(long display, XErrorEvent error) { public static int SAVED_ERROR_HANDLER(long display, XErrorEvent error) {
return XlibWrapper.CallErrorHandler(saved_error_handler, display, error.pData); if (saved_error_handler != 0) {
} // Default XErrorHandler may just terminate the process. Don't call it.
interface XErrorHandler { // return XlibWrapper.CallErrorHandler(saved_error_handler, display, error.pData);
int handleError(long display, XErrorEvent err); }
if (log.isLoggable(Level.FINE)) {
log.log(Level.FINE, "Unhandled XErrorEvent: " +
"id=" + error.get_resourceid() + ", " +
"serial=" + error.get_serial() + ", " +
"ec=" + error.get_error_code() + ", " +
"rc=" + error.get_request_code() + ", " +
"mc=" + error.get_minor_code());
}
return 0;
} }
static int GlobalErrorHandler(long display, long event_ptr) {
// Called from the native code when an error occurs
private static int globalErrorHandler(long display, long event_ptr) {
if (noisyAwtHandler) {
XlibWrapper.PrintXErrorEvent(display, event_ptr);
}
XErrorEvent event = new XErrorEvent(event_ptr); XErrorEvent event = new XErrorEvent(event_ptr);
saved_error = event;
try { try {
if (curErrorHandler != null) { if (current_error_handler != null) {
return curErrorHandler.handleError(display, event); return current_error_handler.handleError(display, event);
} else { } else {
return SAVED_ERROR_HANDLER(display, event); return SAVED_ERROR_HANDLER(display, event);
} }
} finally { } catch (Throwable z) {
log.log(Level.FINE, "Error in GlobalErrorHandler", z);
} }
return 0;
} }
/* //---- END OF ERROR HANDLER CODE ----//
* Instead of validating window id, we simply call XGetWindowProperty,
* but temporary install this function as the error handler to ignore
* BadWindow error.
*/
static XErrorHandler IgnoreBadWindowHandler = new XErrorHandler() {
public int handleError(long display, XErrorEvent err) {
XERROR_SAVE(err);
if (err.get_error_code() == XConstants.BadWindow) {
return 0;
} else {
return SAVED_ERROR_HANDLER(display, err);
}
}
};
private native static void initIDs(); private native static void initIDs();
native static void waitForEvents(long nextTaskTime); native static void waitForEvents(long nextTaskTime);
...@@ -302,25 +302,34 @@ public final class XToolkit extends UNIXToolkit implements Runnable { ...@@ -302,25 +302,34 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
areExtraMouseButtonsEnabled = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons", "true")); areExtraMouseButtonsEnabled = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons", "true"));
//set system property if not yet assigned //set system property if not yet assigned
System.setProperty("sun.awt.enableExtraMouseButtons", ""+areExtraMouseButtonsEnabled); System.setProperty("sun.awt.enableExtraMouseButtons", ""+areExtraMouseButtonsEnabled);
saved_error_handler = XlibWrapper.SetToolkitErrorHandler();
} finally { } finally {
awtUnlock(); awtUnlock();
} }
Runtime.getRuntime().addShutdownHook(new Thread() { Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() { public void run() {
XSystemTrayPeer peer = XSystemTrayPeer.getPeerInstance(); XSystemTrayPeer peer = XSystemTrayPeer.getPeerInstance();
if (peer != null) { if (peer != null) {
peer.dispose(); peer.dispose();
}
if (xs != null) {
((XAWTXSettings)xs).dispose();
}
freeXKB();
if (log.isLoggable(Level.FINE)) {
dumpPeers();
}
} }
}); if (xs != null) {
((XAWTXSettings)xs).dispose();
}
freeXKB();
if (log.isLoggable(Level.FINE)) {
dumpPeers();
}
awtLock();
try {
XlibWrapper.XSetErrorHandler(saved_error_handler);
} finally {
awtUnlock();
}
}
});
} }
static String getCorrectXIDString(String val) { static String getCorrectXIDString(String val) {
...@@ -1434,19 +1443,26 @@ public final class XToolkit extends UNIXToolkit implements Runnable { ...@@ -1434,19 +1443,26 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
desktopProperties.put("awt.multiClickInterval", desktopProperties.put("awt.multiClickInterval",
Integer.valueOf(getMultiClickTime())); Integer.valueOf(getMultiClickTime()));
desktopProperties.put("awt.mouse.numButtons", desktopProperties.put("awt.mouse.numButtons",
Integer.valueOf(getNumMouseButtons())); Integer.valueOf(getNumberOfButtons()));
} }
} }
public static int getNumMouseButtons() { /**
* This method runs through the XPointer and XExtendedPointer array.
* XExtendedPointer has priority because on some systems XPointer
* (which is assigned to the virtual pointer) reports the maximum
* capabilities of the mouse pointer (i.e. 32 physical buttons).
*/
private native synchronized int getNumberOfButtonsImpl();
@Override
public int getNumberOfButtons(){
awtLock(); awtLock();
try { try {
if (numberOfButtons == 0) { if (numberOfButtons == 0) {
numberOfButtons = Math.min( numberOfButtons = getNumberOfButtonsImpl();
XlibWrapper.XGetPointerMapping(XToolkit.getDisplay(), 0, 0),
MAX_BUTTONS_SUPPORT);
} }
return numberOfButtons; return (numberOfButtons > MAX_BUTTONS_SUPPORTED)? MAX_BUTTONS_SUPPORTED : numberOfButtons;
} finally { } finally {
awtUnlock(); awtUnlock();
} }
...@@ -2239,6 +2255,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable { ...@@ -2239,6 +2255,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
try { try {
if (awt_UseXKB_Calls && awt_XKBDescPtr != 0) { if (awt_UseXKB_Calls && awt_XKBDescPtr != 0) {
XlibWrapper.XkbFreeKeyboard(awt_XKBDescPtr, 0xFF, true); XlibWrapper.XkbFreeKeyboard(awt_XKBDescPtr, 0xFF, true);
awt_XKBDescPtr = 0;
} }
} finally { } finally {
awtUnlock(); awtUnlock();
...@@ -2409,8 +2426,6 @@ public final class XToolkit extends UNIXToolkit implements Runnable { ...@@ -2409,8 +2426,6 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
return new XDesktopPeer(); return new XDesktopPeer();
} }
public static native void setNoisyXErrorHandler();
public boolean areExtraMouseButtonsEnabled() throws HeadlessException { public boolean areExtraMouseButtonsEnabled() throws HeadlessException {
return areExtraMouseButtonsEnabled; return areExtraMouseButtonsEnabled;
} }
......
...@@ -57,7 +57,7 @@ public class XTranslateCoordinates { ...@@ -57,7 +57,7 @@ public class XTranslateCoordinates {
public int execute() { public int execute() {
return execute(null); return execute(null);
} }
public int execute(XToolkit.XErrorHandler errorHandler) { public int execute(XErrorHandler errorHandler) {
XToolkit.awtLock(); XToolkit.awtLock();
try { try {
if (isDisposed()) { if (isDisposed()) {
......
...@@ -276,7 +276,7 @@ final class XWM ...@@ -276,7 +276,7 @@ final class XWM
winmgr_running = false; winmgr_running = false;
substruct.set_event_mask(XConstants.SubstructureRedirectMask); substruct.set_event_mask(XConstants.SubstructureRedirectMask);
XToolkit.WITH_XERROR_HANDLER(DetectWMHandler); XToolkit.WITH_XERROR_HANDLER(detectWMHandler);
XlibWrapper.XChangeWindowAttributes(XToolkit.getDisplay(), XlibWrapper.XChangeWindowAttributes(XToolkit.getDisplay(),
XToolkit.getDefaultRootWindow(), XToolkit.getDefaultRootWindow(),
XConstants.CWEventMask, XConstants.CWEventMask,
...@@ -321,7 +321,7 @@ final class XWM ...@@ -321,7 +321,7 @@ final class XWM
new WindowPropertyGetter(window, XA_ENLIGHTENMENT_COMMS, 0, 14, false, new WindowPropertyGetter(window, XA_ENLIGHTENMENT_COMMS, 0, 14, false,
XAtom.XA_STRING); XAtom.XA_STRING);
try { try {
int status = getter.execute(XToolkit.IgnoreBadWindowHandler); int status = getter.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status != XConstants.Success || getter.getData() == 0) { if (status != XConstants.Success || getter.getData() == 0) {
return 0; return 0;
} }
...@@ -439,7 +439,7 @@ final class XWM ...@@ -439,7 +439,7 @@ final class XWM
new WindowPropertyGetter(wmwin, XA_DT_SM_STATE_INFO, 0, 1, new WindowPropertyGetter(wmwin, XA_DT_SM_STATE_INFO, 0, 1,
false, XA_DT_SM_STATE_INFO); false, XA_DT_SM_STATE_INFO);
try { try {
status = getter2.execute(XToolkit.IgnoreBadWindowHandler); status = getter2.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status != XConstants.Success || getter2.getData() == 0) { if (status != XConstants.Success || getter2.getData() == 0) {
...@@ -570,21 +570,6 @@ final class XWM ...@@ -570,21 +570,6 @@ final class XWM
return (XWM.getWMID() == XWM.COMPIZ_WM || XWM.getWMID() == XWM.LG3D_WM); return (XWM.getWMID() == XWM.COMPIZ_WM || XWM.getWMID() == XWM.LG3D_WM);
} }
/*
* Temporary error handler that ensures that we know if
* XChangeProperty succeeded or not.
*/
static XToolkit.XErrorHandler VerifyChangePropertyHandler = new XToolkit.XErrorHandler() {
public int handleError(long display, XErrorEvent err) {
XToolkit.XERROR_SAVE(err);
if (err.get_request_code() == XProtocolConstants.X_ChangeProperty) {
return 0;
} else {
return XToolkit.SAVED_ERROR_HANDLER(display, err);
}
}
};
/* /*
* Prepare IceWM check. * Prepare IceWM check.
* *
...@@ -617,7 +602,7 @@ final class XWM ...@@ -617,7 +602,7 @@ final class XWM
XToolkit.awtLock(); XToolkit.awtLock();
try { try {
XToolkit.WITH_XERROR_HANDLER(VerifyChangePropertyHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XlibWrapper.XChangePropertyS(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), XlibWrapper.XChangePropertyS(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(),
XA_ICEWM_WINOPTHINT.getAtom(), XA_ICEWM_WINOPTHINT.getAtom(),
XA_ICEWM_WINOPTHINT.getAtom(), XA_ICEWM_WINOPTHINT.getAtom(),
...@@ -682,20 +667,19 @@ final class XWM ...@@ -682,20 +667,19 @@ final class XWM
* Temporary error handler that checks if selecting for * Temporary error handler that checks if selecting for
* SubstructureRedirect failed. * SubstructureRedirect failed.
*/ */
static boolean winmgr_running = false; private static boolean winmgr_running = false;
static XToolkit.XErrorHandler DetectWMHandler = new XToolkit.XErrorHandler() { private static XErrorHandler detectWMHandler = new XErrorHandler.XBaseErrorHandler() {
public int handleError(long display, XErrorEvent err) { @Override
XToolkit.XERROR_SAVE(err); public int handleError(long display, XErrorEvent err) {
if (err.get_request_code() == XProtocolConstants.X_ChangeWindowAttributes if ((err.get_request_code() == XProtocolConstants.X_ChangeWindowAttributes) &&
&& err.get_error_code() == XConstants.BadAccess) (err.get_error_code() == XConstants.BadAccess))
{ {
winmgr_running = true; winmgr_running = true;
return 0; return 0;
} else {
return XToolkit.SAVED_ERROR_HANDLER(display, err);
}
} }
}; return super.handleError(display, err);
}
};
/* /*
* Make an educated guess about running window manager. * Make an educated guess about running window manager.
......
...@@ -34,74 +34,68 @@ import sun.awt.AWTAccessor; ...@@ -34,74 +34,68 @@ import sun.awt.AWTAccessor;
import sun.awt.SunToolkit; import sun.awt.SunToolkit;
class XWarningWindow extends XWindow { class XWarningWindow extends XWindow {
private final static int showingDelay = 330; private final static int SHOWING_DELAY = 330;
private final static int hidingDelay = 2000; private final static int HIDING_DELAY = 2000;
private final Window ownerWindow; private final Window ownerWindow;
private WeakReference<XWindowPeer> ownerPeer; private WeakReference<XWindowPeer> ownerPeer;
public final Window getOwnerWindow() {
return ownerWindow;
}
private long parentWindow; private long parentWindow;
private final static String OWNER = "OWNER"; private final static String OWNER = "OWNER";
private static XIconInfo[][] icons;
private InfoWindow.Tooltip tooltip; private InfoWindow.Tooltip tooltip;
private static synchronized XIconInfo getSecurityIconInfo(int size, int num) { /**
if (icons == null) { * Animation stage.
icons = new XIconInfo[4][3]; */
if (XlibWrapper.dataModel == 32) {
icons[0][0] = new XIconInfo(XAWTIcon32_security_icon_bw16_png.security_icon_bw16_png);
icons[0][1] = new XIconInfo(XAWTIcon32_security_icon_interim16_png.security_icon_interim16_png);
icons[0][2] = new XIconInfo(XAWTIcon32_security_icon_yellow16_png.security_icon_yellow16_png);
icons[1][0] = new XIconInfo(XAWTIcon32_security_icon_bw24_png.security_icon_bw24_png);
icons[1][1] = new XIconInfo(XAWTIcon32_security_icon_interim24_png.security_icon_interim24_png);
icons[1][2] = new XIconInfo(XAWTIcon32_security_icon_yellow24_png.security_icon_yellow24_png);
icons[2][0] = new XIconInfo(XAWTIcon32_security_icon_bw32_png.security_icon_bw32_png);
icons[2][1] = new XIconInfo(XAWTIcon32_security_icon_interim32_png.security_icon_interim32_png);
icons[2][2] = new XIconInfo(XAWTIcon32_security_icon_yellow32_png.security_icon_yellow32_png);
icons[3][0] = new XIconInfo(XAWTIcon32_security_icon_bw48_png.security_icon_bw48_png);
icons[3][1] = new XIconInfo(XAWTIcon32_security_icon_interim48_png.security_icon_interim48_png);
icons[3][2] = new XIconInfo(XAWTIcon32_security_icon_yellow48_png.security_icon_yellow48_png);
} else {
icons[0][0] = new XIconInfo(XAWTIcon64_security_icon_bw16_png.security_icon_bw16_png);
icons[0][1] = new XIconInfo(XAWTIcon64_security_icon_interim16_png.security_icon_interim16_png);
icons[0][2] = new XIconInfo(XAWTIcon64_security_icon_yellow16_png.security_icon_yellow16_png);
icons[1][0] = new XIconInfo(XAWTIcon64_security_icon_bw24_png.security_icon_bw24_png);
icons[1][1] = new XIconInfo(XAWTIcon64_security_icon_interim24_png.security_icon_interim24_png);
icons[1][2] = new XIconInfo(XAWTIcon64_security_icon_yellow24_png.security_icon_yellow24_png);
icons[2][0] = new XIconInfo(XAWTIcon64_security_icon_bw32_png.security_icon_bw32_png);
icons[2][1] = new XIconInfo(XAWTIcon64_security_icon_interim32_png.security_icon_interim32_png);
icons[2][2] = new XIconInfo(XAWTIcon64_security_icon_yellow32_png.security_icon_yellow32_png);
icons[3][0] = new XIconInfo(XAWTIcon64_security_icon_bw48_png.security_icon_bw48_png);
icons[3][1] = new XIconInfo(XAWTIcon64_security_icon_interim48_png.security_icon_interim48_png);
icons[3][2] = new XIconInfo(XAWTIcon64_security_icon_yellow48_png.security_icon_yellow48_png);
}
}
final int sizeIndex = size % icons.length;
return icons[sizeIndex][num % icons[sizeIndex].length];
}
private volatile int currentIcon = 0; private volatile int currentIcon = 0;
/* -1 - uninitialized yet /* -1 - uninitialized.
* 0 - 16x16 * 0 - 16x16
* 1 - 24x24 * 1 - 24x24
* 2 - 32x32 * 2 - 32x32
* 3 - 48x48 * 3 - 48x48
*/ */
private volatile int currentSize = -1; private int currentSize = -1;
private static XIconInfo[][] icons;
/** Indicates whether the shape of the window must be updated private static XIconInfo getSecurityIconInfo(int size, int num) {
*/ synchronized (XWarningWindow.class) {
private volatile boolean sizeUpdated = true; if (icons == null) {
icons = new XIconInfo[4][3];
if (XlibWrapper.dataModel == 32) {
icons[0][0] = new XIconInfo(XAWTIcon32_security_icon_bw16_png.security_icon_bw16_png);
icons[0][1] = new XIconInfo(XAWTIcon32_security_icon_interim16_png.security_icon_interim16_png);
icons[0][2] = new XIconInfo(XAWTIcon32_security_icon_yellow16_png.security_icon_yellow16_png);
icons[1][0] = new XIconInfo(XAWTIcon32_security_icon_bw24_png.security_icon_bw24_png);
icons[1][1] = new XIconInfo(XAWTIcon32_security_icon_interim24_png.security_icon_interim24_png);
icons[1][2] = new XIconInfo(XAWTIcon32_security_icon_yellow24_png.security_icon_yellow24_png);
icons[2][0] = new XIconInfo(XAWTIcon32_security_icon_bw32_png.security_icon_bw32_png);
icons[2][1] = new XIconInfo(XAWTIcon32_security_icon_interim32_png.security_icon_interim32_png);
icons[2][2] = new XIconInfo(XAWTIcon32_security_icon_yellow32_png.security_icon_yellow32_png);
icons[3][0] = new XIconInfo(XAWTIcon32_security_icon_bw48_png.security_icon_bw48_png);
icons[3][1] = new XIconInfo(XAWTIcon32_security_icon_interim48_png.security_icon_interim48_png);
icons[3][2] = new XIconInfo(XAWTIcon32_security_icon_yellow48_png.security_icon_yellow48_png);
} else {
icons[0][0] = new XIconInfo(XAWTIcon64_security_icon_bw16_png.security_icon_bw16_png);
icons[0][1] = new XIconInfo(XAWTIcon64_security_icon_interim16_png.security_icon_interim16_png);
icons[0][2] = new XIconInfo(XAWTIcon64_security_icon_yellow16_png.security_icon_yellow16_png);
icons[1][0] = new XIconInfo(XAWTIcon64_security_icon_bw24_png.security_icon_bw24_png);
icons[1][1] = new XIconInfo(XAWTIcon64_security_icon_interim24_png.security_icon_interim24_png);
icons[1][2] = new XIconInfo(XAWTIcon64_security_icon_yellow24_png.security_icon_yellow24_png);
icons[2][0] = new XIconInfo(XAWTIcon64_security_icon_bw32_png.security_icon_bw32_png);
icons[2][1] = new XIconInfo(XAWTIcon64_security_icon_interim32_png.security_icon_interim32_png);
icons[2][2] = new XIconInfo(XAWTIcon64_security_icon_yellow32_png.security_icon_yellow32_png);
icons[3][0] = new XIconInfo(XAWTIcon64_security_icon_bw48_png.security_icon_bw48_png);
icons[3][1] = new XIconInfo(XAWTIcon64_security_icon_interim48_png.security_icon_interim48_png);
icons[3][2] = new XIconInfo(XAWTIcon64_security_icon_yellow48_png.security_icon_yellow48_png);
}
}
}
final int sizeIndex = size % icons.length;
return icons[sizeIndex][num % icons[sizeIndex].length];
}
private synchronized boolean updateIconSize() { private void updateIconSize() {
int newSize = currentSize; int newSize = -1;
if (ownerWindow != null) { if (ownerWindow != null) {
Insets insets = ownerWindow.getInsets(); Insets insets = ownerWindow.getInsets();
...@@ -117,14 +111,32 @@ class XWarningWindow extends XWindow { ...@@ -117,14 +111,32 @@ class XWarningWindow extends XWindow {
newSize = 3; newSize = 3;
} }
} }
if (newSize != currentSize) { // Make sure we have a valid size
currentSize = newSize; if (newSize == -1) {
sizeUpdated = true; newSize = 0;
}
// Note: this is not the most wise solution to use awtLock here,
// this should have been sync'ed with the stateLock. However,
// the awtLock must be taken first (see XBaseWindow.getStateLock()),
// and we need the awtLock anyway to update the shape of the icon.
// So it's easier to use just one lock instead.
XToolkit.awtLock();
try {
if (newSize != currentSize) {
currentSize = newSize;
XIconInfo ico = getSecurityIconInfo(currentSize, 0);
XlibWrapper.SetBitmapShape(XToolkit.getDisplay(), getWindow(),
ico.getWidth(), ico.getHeight(), ico.getIntData());
AWTAccessor.getWindowAccessor().setSecurityWarningSize(
ownerWindow, ico.getWidth(), ico.getHeight());
}
} finally {
XToolkit.awtUnlock();
} }
return sizeUpdated;
} }
private synchronized XIconInfo getSecurityIconInfo() { private XIconInfo getSecurityIconInfo() {
updateIconSize(); updateIconSize();
return getSecurityIconInfo(currentSize, currentIcon); return getSecurityIconInfo(currentSize, currentIcon);
} }
...@@ -183,28 +195,6 @@ class XWarningWindow extends XWindow { ...@@ -183,28 +195,6 @@ class XWarningWindow extends XWindow {
} }
} }
private void updateWarningWindowBounds() {
XWindowPeer peer = ownerPeer.get();
if (peer != null) {
synchronized (this) {
if (updateIconSize()) {
XIconInfo ico = getSecurityIconInfo();
XToolkit.awtLock();
try {
XlibWrapper.SetBitmapShape(XToolkit.getDisplay(), getWindow(),
ico.getWidth(), ico.getHeight(), ico.getIntData());
} finally {
XToolkit.awtUnlock();
}
sizeUpdated = false;
AWTAccessor.getWindowAccessor().setSecurityWarningSize(
ownerWindow, ico.getWidth(), ico.getHeight());
}
}
peer.repositionSecurityWarning();
}
}
/** /**
* @param x,y,w,h coordinates of the untrusted window * @param x,y,w,h coordinates of the untrusted window
*/ */
...@@ -376,25 +366,22 @@ class XWarningWindow extends XWindow { ...@@ -376,25 +366,22 @@ class XWarningWindow extends XWindow {
private final Runnable showingTask = new Runnable() { private final Runnable showingTask = new Runnable() {
public void run() { public void run() {
new Thread() { if (!isVisible()) {
public void run() { xSetVisible(true);
if (!isVisible()) { updateIconSize();
xSetVisible(true); XWindowPeer peer = ownerPeer.get();
updateWarningWindowBounds(); if (peer != null) {
} peer.repositionSecurityWarning();
repaint(); }
if (currentIcon > 0) { }
currentIcon--; repaint();
XToolkit.schedule(showingTask, showingDelay); if (currentIcon > 0) {
} currentIcon--;
}}.start(); XToolkit.schedule(showingTask, SHOWING_DELAY);
}
} }
}; };
public void setSecurityWarningVisible(boolean visible) {
setSecurityWarningVisible(visible, true);
}
public void setSecurityWarningVisible(boolean visible, boolean doSchedule) { public void setSecurityWarningVisible(boolean visible, boolean doSchedule) {
if (visible) { if (visible) {
XToolkit.remove(hidingTask); XToolkit.remove(hidingTask);
...@@ -416,7 +403,7 @@ class XWarningWindow extends XWindow { ...@@ -416,7 +403,7 @@ class XWarningWindow extends XWindow {
return; return;
} }
if (doSchedule) { if (doSchedule) {
XToolkit.schedule(hidingTask, hidingDelay); XToolkit.schedule(hidingTask, HIDING_DELAY);
} else { } else {
hidingTask.run(); hidingTask.run();
} }
......
...@@ -677,6 +677,14 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { ...@@ -677,6 +677,14 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
int button=0; int button=0;
boolean wheel_mouse = false; boolean wheel_mouse = false;
int lbutton = xbe.get_button(); int lbutton = xbe.get_button();
/*
* Ignore the buttons above 20 due to the bit limit for
* InputEvent.BUTTON_DOWN_MASK.
* One more bit is reserved for FIRST_HIGH_BIT.
*/
if (lbutton > SunToolkit.MAX_BUTTONS_SUPPORTED) {
return;
}
int type = xev.get_type(); int type = xev.get_type();
when = xbe.get_time(); when = xbe.get_time();
long jWhen = XToolkit.nowMillisUTC_offset(when); long jWhen = XToolkit.nowMillisUTC_offset(when);
...@@ -795,8 +803,9 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { ...@@ -795,8 +803,9 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
//this doesn't work for extra buttons because Xsystem is sending state==0 for every extra button event. //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) // we can't correct it in MouseEvent class as we done it with modifiers, because exact type (DRAG|MOVE)
// should be passed from XWindow. // should be passed from XWindow.
//TODO: eliminate it with some other value obtained w/o AWTLock. final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons();
for (int i = 0; i < XToolkit.getNumMouseButtons(); i++){
for (int i = 0; i < buttonsNumber; i++){
// TODO : here is the bug in WM: extra buttons doesn't have state!=0 as they should. // TODO : here is the bug in WM: extra buttons doesn't have state!=0 as they should.
if ((i != 4) && (i != 5)) { if ((i != 4) && (i != 5)) {
mouseKeyState = mouseKeyState | (xme.get_state() & XConstants.buttonsMask[i]); mouseKeyState = mouseKeyState | (xme.get_state() & XConstants.buttonsMask[i]);
...@@ -1343,18 +1352,23 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { ...@@ -1343,18 +1352,23 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
setSizeHints(flags, x, y, width, height); setSizeHints(flags, x, y, width, height);
} }
void validateSurface() { void validateSurface() {
if ((width != oldWidth) || (height != oldHeight)) { if ((width != oldWidth) || (height != oldHeight)) {
SurfaceData oldData = surfaceData; doValidateSurface();
if (oldData != null) {
surfaceData = graphicsConfig.createSurfaceData(this);
oldData.invalidate();
}
oldWidth = width; oldWidth = width;
oldHeight = height; oldHeight = height;
} }
} }
final void doValidateSurface() {
SurfaceData oldData = surfaceData;
if (oldData != null) {
surfaceData = graphicsConfig.createSurfaceData(this);
oldData.invalidate();
}
}
public SurfaceData getSurfaceData() { public SurfaceData getSurfaceData() {
return surfaceData; return surfaceData;
} }
......
...@@ -1108,7 +1108,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, ...@@ -1108,7 +1108,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
} }
} }
warningWindow.setSecurityWarningVisible(show); warningWindow.setSecurityWarningVisible(show, true);
} }
boolean isOverrideRedirect() { boolean isOverrideRedirect() {
...@@ -1894,7 +1894,9 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, ...@@ -1894,7 +1894,9 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
} }
if (isGrabbed()) { if (isGrabbed()) {
boolean dragging = false; boolean dragging = false;
for (int i = 0; i<XToolkit.getNumMouseButtons(); i++){ final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons();
for (int i = 0; i < buttonsNumber; i++){
// here is the bug in WM: extra buttons doesn't have state!=0 as they should. // here is the bug in WM: extra buttons doesn't have state!=0 as they should.
if ((i != 4) && (i != 5)){ if ((i != 4) && (i != 5)){
dragging = dragging || ((xme.get_state() & XConstants.buttonsMask[i]) != 0); dragging = dragging || ((xme.get_state() & XConstants.buttonsMask[i]) != 0);
...@@ -1940,6 +1942,15 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, ...@@ -1940,6 +1942,15 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
public void handleButtonPressRelease(XEvent xev) { public void handleButtonPressRelease(XEvent xev) {
XButtonEvent xbe = xev.get_xbutton(); XButtonEvent xbe = xev.get_xbutton();
/*
* Ignore the buttons above 20 due to the bit limit for
* InputEvent.BUTTON_DOWN_MASK.
* One more bit is reserved for FIRST_HIGH_BIT.
*/
if (xbe.get_button() > SunToolkit.MAX_BUTTONS_SUPPORTED) {
return;
}
if (grabLog.isLoggable(Level.FINE)) { if (grabLog.isLoggable(Level.FINE)) {
grabLog.log(Level.FINE, "{0}, when grabbed {1}, contains {2} ({3}, {4}, {5}x{6})", grabLog.log(Level.FINE, "{0}, when grabbed {1}, contains {2} ({3}, {4}, {5}x{6})",
new Object[] {xbe, isGrabbed(), containsGlobal(xbe.get_x_root(), xbe.get_y_root()), getAbsoluteX(), getAbsoluteY(), getWidth(), getHeight()}); new Object[] {xbe, isGrabbed(), containsGlobal(xbe.get_x_root(), xbe.get_y_root()), getAbsoluteX(), getAbsoluteY(), getWidth(), getHeight()});
...@@ -2058,7 +2069,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, ...@@ -2058,7 +2069,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
} }
@Override @Override
public void updateWindow(BufferedImage backBuffer) { public void updateWindow() {
// no-op // no-op
} }
} }
...@@ -149,7 +149,7 @@ public class XlibUtil ...@@ -149,7 +149,7 @@ public class XlibUtil
new XTranslateCoordinates(src, dst, p.x, p.y); new XTranslateCoordinates(src, dst, p.x, p.y);
try try
{ {
int status = xtc.execute(XToolkit.IgnoreBadWindowHandler); int status = xtc.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if ((status != 0) && if ((status != 0) &&
((XToolkit.saved_error == null) || ((XToolkit.saved_error == null) ||
(XToolkit.saved_error.get_error_code() == XConstants.Success))) (XToolkit.saved_error.get_error_code() == XConstants.Success)))
...@@ -306,7 +306,7 @@ public class XlibUtil ...@@ -306,7 +306,7 @@ public class XlibUtil
XWM.XA_WM_STATE); XWM.XA_WM_STATE);
try try
{ {
wpg.execute(XToolkit.IgnoreBadWindowHandler); wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (wpg.getActualType() == XWM.XA_WM_STATE.getAtom()) if (wpg.getActualType() == XWM.XA_WM_STATE.getAtom())
{ {
return true; return true;
...@@ -345,7 +345,7 @@ public class XlibUtil ...@@ -345,7 +345,7 @@ public class XlibUtil
XWindowAttributes wattr = new XWindowAttributes(); XWindowAttributes wattr = new XWindowAttributes();
try try
{ {
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler); XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(), int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
window, wattr.pData); window, wattr.pData);
XToolkit.RESTORE_XERROR_HANDLER(); XToolkit.RESTORE_XERROR_HANDLER();
......
...@@ -646,4 +646,6 @@ static native String XSetLocaleModifiers(String modifier_list); ...@@ -646,4 +646,6 @@ static native String XSetLocaleModifiers(String modifier_list);
String javaVersion = XToolkit.getSystemProperty("java.version"); String javaVersion = XToolkit.getSystemProperty("java.version");
return javaVersion != null && javaVersion.contains("internal"); return javaVersion != null && javaVersion.contains("internal");
} }
static native void PrintXErrorEvent(long display, long event_ptr);
} }
...@@ -186,6 +186,15 @@ XEvent.xerror 0 ...@@ -186,6 +186,15 @@ XEvent.xerror 0
XEvent.xkeymap 0 XEvent.xkeymap 0
XEvent.pad 0 XEvent.pad 0
XEvent 192 XEvent 192
XRenderDirectFormat.red 0
XRenderDirectFormat.redMask 2
XRenderDirectFormat.green 4
XRenderDirectFormat.greenMask 6
XRenderDirectFormat.blue 8
XRenderDirectFormat.blueMask 10
XRenderDirectFormat.alpha 12
XRenderDirectFormat.alphaMask 14
XRenderDirectFormat 16
ColorData.awt_Colors 0 ColorData.awt_Colors 0
ColorData.awt_numICMcolors 8 ColorData.awt_numICMcolors 8
ColorData.awt_icmLUT 16 ColorData.awt_icmLUT 16
...@@ -440,6 +449,12 @@ XSetWindowAttributes.override_redirect 88 ...@@ -440,6 +449,12 @@ XSetWindowAttributes.override_redirect 88
XSetWindowAttributes.colormap 96 XSetWindowAttributes.colormap 96
XSetWindowAttributes.cursor 104 XSetWindowAttributes.cursor 104
XSetWindowAttributes 112 XSetWindowAttributes 112
XRenderPictFormat.id 0
XRenderPictFormat.type 8
XRenderPictFormat.depth 12
XRenderPictFormat.direct 16
XRenderPictFormat.colormap 32
XRenderPictFormat 40
XReparentEvent.type 0 XReparentEvent.type 0
XReparentEvent.serial 8 XReparentEvent.serial 8
XReparentEvent.send_event 16 XReparentEvent.send_event 16
...@@ -985,7 +1000,8 @@ AwtGraphicsConfigData.pixelStride 136 ...@@ -985,7 +1000,8 @@ AwtGraphicsConfigData.pixelStride 136
AwtGraphicsConfigData.color_data 144 AwtGraphicsConfigData.color_data 144
AwtGraphicsConfigData.glxInfo 152 AwtGraphicsConfigData.glxInfo 152
AwtGraphicsConfigData.isTranslucencySupported 160 AwtGraphicsConfigData.isTranslucencySupported 160
AwtGraphicsConfigData 168 AwtGraphicsConfigData.renderPictFormat 168
AwtGraphicsConfigData 208
XColor.pixel 0 XColor.pixel 0
XColor.red 8 XColor.red 8
XColor.green 10 XColor.green 10
......
...@@ -245,6 +245,21 @@ XVisualInfo ...@@ -245,6 +245,21 @@ XVisualInfo
blue_mask long blue_mask long
colormap_size int colormap_size int
bits_per_rgb int bits_per_rgb int
XRenderDirectFormat
red short
redMask short
green short
greenMask short
blue short
blueMask short
alpha short
alphaMask short
XRenderPictFormat
id long
type int
depth int
direct struct XRenderDirectFormat
colormap long
XIMHotKeyTrigger XIMHotKeyTrigger
keysym long keysym long
modifier int modifier int
...@@ -751,6 +766,7 @@ AwtGraphicsConfigData ...@@ -751,6 +766,7 @@ AwtGraphicsConfigData
color_data pointer ColorData color_data pointer ColorData
glxInfo pointer glxInfo pointer
isTranslucencySupported int isTranslucencySupported int
renderPictFormat struct XRenderPictFormat
AwtScreenData AwtScreenData
numConfigs int numConfigs int
......
...@@ -67,6 +67,9 @@ tojava package sun.awt.X11; ...@@ -67,6 +67,9 @@ tojava package sun.awt.X11;
tojava import java.util.Hashtable; tojava import java.util.Hashtable;
tojava import sun.misc.Unsafe; tojava import sun.misc.Unsafe;
tojava tojava
tojava import java.util.logging.Level;
tojava import java.util.logging.Logger;
tojava
tojava public class XKeysym { tojava public class XKeysym {
tojava tojava
tojava public static void main( String args[] ) { tojava public static void main( String args[] ) {
...@@ -105,6 +108,7 @@ tojava // Another use for reverse lookup: query keyboard state, for some key ...@@ -105,6 +108,7 @@ tojava // Another use for reverse lookup: query keyboard state, for some key
tojava static Hashtable<Integer, Long> javaKeycode2KeysymHash = new Hashtable<Integer, Long>(); tojava static Hashtable<Integer, Long> javaKeycode2KeysymHash = new Hashtable<Integer, Long>();
tojava static long keysym_lowercase = unsafe.allocateMemory(Native.getLongSize()); tojava static long keysym_lowercase = unsafe.allocateMemory(Native.getLongSize());
tojava static long keysym_uppercase = unsafe.allocateMemory(Native.getLongSize()); tojava static long keysym_uppercase = unsafe.allocateMemory(Native.getLongSize());
tojava private static Logger keyEventLog = Logger.getLogger("sun.awt.X11.kye.XKeysym");
tojava public static char convertKeysym( long ks, int state ) { tojava public static char convertKeysym( long ks, int state ) {
tojava tojava
tojava /* First check for Latin-1 characters (1:1 mapping) */ tojava /* First check for Latin-1 characters (1:1 mapping) */
...@@ -145,8 +149,15 @@ tojava // and don't want to speculate. But this particular case ...@@ -145,8 +149,15 @@ tojava // and don't want to speculate. But this particular case
tojava // clearly means that caller needs a so called primary keysym. tojava // clearly means that caller needs a so called primary keysym.
tojava mods ^= XConstants.ShiftMask; tojava mods ^= XConstants.ShiftMask;
tojava } tojava }
tojava XlibWrapper.XkbTranslateKeyCode(XToolkit.getXKBKbdDesc(), ev.get_keycode(), tojava long kbdDesc = XToolkit.getXKBKbdDesc();
tojava if( kbdDesc != 0 ) {
tojava XlibWrapper.XkbTranslateKeyCode(kbdDesc, ev.get_keycode(),
tojava mods, XlibWrapper.iarg1, XlibWrapper.larg3); tojava mods, XlibWrapper.iarg1, XlibWrapper.larg3);
tojava }else{
tojava // xkb resources already gone
tojava keyEventLog.fine("Thread race: Toolkit shutdown before the end of a key event processing.");
tojava return 0;
tojava }
tojava //XXX unconsumed modifiers? tojava //XXX unconsumed modifiers?
tojava return Native.getLong(XlibWrapper.larg3); tojava return Native.getLong(XlibWrapper.larg3);
tojava } finally { tojava } finally {
......
...@@ -37,7 +37,10 @@ import java.awt.ImageCapabilities; ...@@ -37,7 +37,10 @@ import java.awt.ImageCapabilities;
import java.awt.Transparency; import java.awt.Transparency;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.awt.image.ColorModel; import java.awt.image.ColorModel;
import java.awt.color.ColorSpace;
import java.awt.image.ComponentColorModel;
import java.awt.image.DirectColorModel; import java.awt.image.DirectColorModel;
import java.awt.image.DataBuffer;
import java.awt.image.VolatileImage; import java.awt.image.VolatileImage;
import java.awt.image.WritableRaster; import java.awt.image.WritableRaster;
import java.awt.geom.AffineTransform; import java.awt.geom.AffineTransform;
...@@ -230,6 +233,22 @@ public class X11GraphicsConfig extends GraphicsConfiguration ...@@ -230,6 +233,22 @@ public class X11GraphicsConfig extends GraphicsConfiguration
} }
} }
public static DirectColorModel createDCM32(int rMask, int gMask, int bMask,
int aMask, boolean aPre) {
return new DirectColorModel(
ColorSpace.getInstance(ColorSpace.CS_sRGB),
32, rMask, gMask, bMask, aMask, aPre, DataBuffer.TYPE_INT);
}
public static ComponentColorModel createABGRCCM() {
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
int[] nBits = {8, 8, 8, 8};
int[] bOffs = {3, 2, 1, 0};
return new ComponentColorModel(cs, nBits, true, true,
Transparency.TRANSLUCENT,
DataBuffer.TYPE_BYTE);
}
/** /**
* Returns the default Transform for this configuration. This * Returns the default Transform for this configuration. This
* Transform is typically the Identity transform for most normal * Transform is typically the Identity transform for most normal
......
/* /*
* Copyright 1995-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1995-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -624,7 +624,6 @@ public class MToolkit extends UNIXToolkit implements Runnable { ...@@ -624,7 +624,6 @@ public class MToolkit extends UNIXToolkit implements Runnable {
} }
private native int getMulticlickTime(); private native int getMulticlickTime();
private native int getNumMouseButtons();
protected void initializeDesktopProperties() { protected void initializeDesktopProperties() {
desktopProperties.put("DnD.Autoscroll.initialDelay", Integer.valueOf(50)); desktopProperties.put("DnD.Autoscroll.initialDelay", Integer.valueOf(50));
...@@ -643,7 +642,7 @@ public class MToolkit extends UNIXToolkit implements Runnable { ...@@ -643,7 +642,7 @@ public class MToolkit extends UNIXToolkit implements Runnable {
desktopProperties.put("awt.multiClickInterval", desktopProperties.put("awt.multiClickInterval",
Integer.valueOf(getMulticlickTime())); Integer.valueOf(getMulticlickTime()));
desktopProperties.put("awt.mouse.numButtons", desktopProperties.put("awt.mouse.numButtons",
Integer.valueOf(getNumMouseButtons())); Integer.valueOf(getNumberOfButtons()));
} }
} }
......
...@@ -70,6 +70,10 @@ public class X11PMBlitBgLoops extends BlitBg { ...@@ -70,6 +70,10 @@ public class X11PMBlitBgLoops extends BlitBg {
X11SurfaceData.UShort565RgbX11), X11SurfaceData.UShort565RgbX11),
new X11PMBlitBgLoops(X11SurfaceData.UShortIndexedX11_BM, new X11PMBlitBgLoops(X11SurfaceData.UShortIndexedX11_BM,
X11SurfaceData.UShortIndexedX11), X11SurfaceData.UShortIndexedX11),
new X11PMBlitBgLoops(X11SurfaceData.IntRgbX11_BM,
X11SurfaceData.IntArgbPreX11),
new X11PMBlitBgLoops(X11SurfaceData.IntBgrX11_BM,
X11SurfaceData.FourByteAbgrPreX11),
}; };
GraphicsPrimitiveMgr.register(primitives); GraphicsPrimitiveMgr.register(primitives);
} }
......
...@@ -95,6 +95,22 @@ public class X11PMBlitLoops extends Blit { ...@@ -95,6 +95,22 @@ public class X11PMBlitLoops extends Blit {
new X11PMBlitLoops(X11SurfaceData.UShortIndexedX11_BM, new X11PMBlitLoops(X11SurfaceData.UShortIndexedX11_BM,
X11SurfaceData.UShortIndexedX11, true), X11SurfaceData.UShortIndexedX11, true),
new X11PMBlitLoops(X11SurfaceData.IntRgbX11,
X11SurfaceData.IntArgbPreX11, true),
new X11PMBlitLoops(X11SurfaceData.IntRgbX11,
X11SurfaceData.IntArgbPreX11, false),
new X11PMBlitLoops(X11SurfaceData.IntRgbX11_BM,
X11SurfaceData.IntArgbPreX11, true),
new X11PMBlitLoops(X11SurfaceData.IntBgrX11,
X11SurfaceData.FourByteAbgrPreX11, true),
new X11PMBlitLoops(X11SurfaceData.IntBgrX11,
X11SurfaceData.FourByteAbgrPreX11, false),
new X11PMBlitLoops(X11SurfaceData.IntBgrX11_BM,
X11SurfaceData.FourByteAbgrPreX11, true),
// delegate loops // delegate loops
new DelegateBlitLoop(X11SurfaceData.IntBgrX11_BM, new DelegateBlitLoop(X11SurfaceData.IntBgrX11_BM,
X11SurfaceData.IntBgrX11), X11SurfaceData.IntBgrX11),
......
...@@ -81,6 +81,13 @@ public abstract class X11SurfaceData extends SurfaceData { ...@@ -81,6 +81,13 @@ public abstract class X11SurfaceData extends SurfaceData {
DESC_INT_BGR_X11 = "Integer BGR Pixmap"; DESC_INT_BGR_X11 = "Integer BGR Pixmap";
public static final String public static final String
DESC_INT_RGB_X11 = "Integer RGB Pixmap"; DESC_INT_RGB_X11 = "Integer RGB Pixmap";
public static final String
DESC_4BYTE_ABGR_PRE_X11 = "4 byte ABGR Pixmap with pre-multplied alpha";
public static final String
DESC_INT_ARGB_PRE_X11 = "Integer ARGB Pixmap with pre-multiplied " +
"alpha";
public static final String public static final String
DESC_BYTE_IND_OPQ_X11 = "Byte Indexed Opaque Pixmap"; DESC_BYTE_IND_OPQ_X11 = "Byte Indexed Opaque Pixmap";
...@@ -133,6 +140,11 @@ public abstract class X11SurfaceData extends SurfaceData { ...@@ -133,6 +140,11 @@ public abstract class X11SurfaceData extends SurfaceData {
public static final SurfaceType IntRgbX11 = public static final SurfaceType IntRgbX11 =
SurfaceType.IntRgb.deriveSubType(DESC_INT_RGB_X11); SurfaceType.IntRgb.deriveSubType(DESC_INT_RGB_X11);
public static final SurfaceType FourByteAbgrPreX11 =
SurfaceType.FourByteAbgrPre.deriveSubType(DESC_4BYTE_ABGR_PRE_X11);
public static final SurfaceType IntArgbPreX11 =
SurfaceType.IntArgbPre.deriveSubType(DESC_INT_ARGB_PRE_X11);
public static final SurfaceType ThreeByteRgbX11 = public static final SurfaceType ThreeByteRgbX11 =
SurfaceType.ThreeByteRgb.deriveSubType(DESC_3BYTE_RGB_X11); SurfaceType.ThreeByteRgb.deriveSubType(DESC_3BYTE_RGB_X11);
public static final SurfaceType ThreeByteBgrX11 = public static final SurfaceType ThreeByteBgrX11 =
...@@ -413,7 +425,7 @@ public abstract class X11SurfaceData extends SurfaceData { ...@@ -413,7 +425,7 @@ public abstract class X11SurfaceData extends SurfaceData {
int transparency) int transparency)
{ {
return new X11PixmapSurfaceData(gc, width, height, image, return new X11PixmapSurfaceData(gc, width, height, image,
getSurfaceType(gc, transparency), getSurfaceType(gc, transparency, true),
cm, drawable, transparency); cm, drawable, transparency);
} }
...@@ -497,6 +509,13 @@ public abstract class X11SurfaceData extends SurfaceData { ...@@ -497,6 +509,13 @@ public abstract class X11SurfaceData extends SurfaceData {
public static SurfaceType getSurfaceType(X11GraphicsConfig gc, public static SurfaceType getSurfaceType(X11GraphicsConfig gc,
int transparency) int transparency)
{
return getSurfaceType(gc, transparency, false);
}
public static SurfaceType getSurfaceType(X11GraphicsConfig gc,
int transparency,
boolean pixmapSurface)
{ {
boolean transparent = (transparency == Transparency.BITMASK); boolean transparent = (transparency == Transparency.BITMASK);
SurfaceType sType; SurfaceType sType;
...@@ -524,11 +543,21 @@ public abstract class X11SurfaceData extends SurfaceData { ...@@ -524,11 +543,21 @@ public abstract class X11SurfaceData extends SurfaceData {
// Fall through for 32 bit case // Fall through for 32 bit case
case 32: case 32:
if (cm instanceof DirectColorModel) { if (cm instanceof DirectColorModel) {
if (((DirectColorModel)cm).getRedMask() == 0xff0000) { if (((SunToolkit)java.awt.Toolkit.getDefaultToolkit()
sType = transparent ? X11SurfaceData.IntRgbX11_BM : X11SurfaceData.IntRgbX11; ).isTranslucencyCapable(gc) && !pixmapSurface)
{
sType = X11SurfaceData.IntArgbPreX11;
} else { } else {
sType = transparent ? X11SurfaceData.IntBgrX11_BM : X11SurfaceData.IntBgrX11; if (((DirectColorModel)cm).getRedMask() == 0xff0000) {
sType = transparent ? X11SurfaceData.IntRgbX11_BM :
X11SurfaceData.IntRgbX11;
} else {
sType = transparent ? X11SurfaceData.IntBgrX11_BM :
X11SurfaceData.IntBgrX11;
}
} }
} else if (cm instanceof ComponentColorModel) {
sType = X11SurfaceData.FourByteAbgrPreX11;
} else { } else {
throw new sun.java2d.InvalidPipeException("Unsupported bit " + throw new sun.java2d.InvalidPipeException("Unsupported bit " +
......
...@@ -886,6 +886,27 @@ awt_allocate_colors(AwtGraphicsConfigDataPtr awt_data) ...@@ -886,6 +886,27 @@ awt_allocate_colors(AwtGraphicsConfigDataPtr awt_data)
#define blue(v) (((v) >> 0) & 0xFF) #define blue(v) (((v) >> 0) & 0xFF)
#ifndef HEADLESS #ifndef HEADLESS
jobject getColorSpace(JNIEnv* env, jint csID) {
jclass clazz;
jobject cspaceL;
jmethodID mid;
clazz = (*env)->FindClass(env,"java/awt/color/ColorSpace");
mid = (*env)->GetStaticMethodID(env, clazz, "getInstance",
"(I)Ljava/awt/color/ColorSpace;");
if (mid == NULL) {
return NULL;
}
/* SECURITY: This is safe, because static methods cannot
* be overridden, and this method does not invoke
* client code
*/
return (*env)->CallStaticObjectMethod(env, clazz, mid, csID);
}
jobject awtJNI_GetColorModel(JNIEnv *env, AwtGraphicsConfigDataPtr aData) jobject awtJNI_GetColorModel(JNIEnv *env, AwtGraphicsConfigDataPtr aData)
{ {
jobject awt_colormodel = NULL; jobject awt_colormodel = NULL;
...@@ -899,20 +920,60 @@ jobject awtJNI_GetColorModel(JNIEnv *env, AwtGraphicsConfigDataPtr aData) ...@@ -899,20 +920,60 @@ jobject awtJNI_GetColorModel(JNIEnv *env, AwtGraphicsConfigDataPtr aData)
(aData->awt_depth >= 15)) (aData->awt_depth >= 15))
{ {
clazz = (*env)->FindClass(env,"java/awt/image/DirectColorModel"); clazz = (*env)->FindClass(env,"java/awt/image/DirectColorModel");
if (!aData->isTranslucencySupported) {
mid = (*env)->GetMethodID(env,clazz,"<init>","(IIIII)V"); mid = (*env)->GetMethodID(env,clazz,"<init>","(IIIII)V");
if (mid == NULL) { if (mid == NULL) {
(*env)->PopLocalFrame(env, 0); (*env)->PopLocalFrame(env, 0);
return NULL; return NULL;
} }
awt_colormodel = (*env)->NewObject(env,clazz, mid,
aData->awt_visInfo.depth,
aData->awt_visInfo.red_mask,
aData->awt_visInfo.green_mask,
aData->awt_visInfo.blue_mask,
0);
} else {
clazz = (*env)->FindClass(env,"sun/awt/X11GraphicsConfig");
if (clazz == NULL) {
(*env)->PopLocalFrame(env, 0);
return NULL;
}
awt_colormodel = (*env)->NewObject(env,clazz, mid, if (aData->renderPictFormat.direct.red == 16) {
aData->awt_visInfo.depth, mid = (*env)->GetStaticMethodID( env,clazz,"createDCM32",
aData->awt_visInfo.red_mask, "(IIIIZ)Ljava/awt/image/DirectColorModel;");
aData->awt_visInfo.green_mask,
aData->awt_visInfo.blue_mask, if (mid == NULL) {
0); (*env)->PopLocalFrame(env, 0);
return NULL;
}
awt_colormodel = (*env)->CallStaticObjectMethod(
env,clazz, mid,
aData->renderPictFormat.direct.redMask
<< aData->renderPictFormat.direct.red,
aData->renderPictFormat.direct.greenMask
<< aData->renderPictFormat.direct.green,
aData->renderPictFormat.direct.blueMask
<< aData->renderPictFormat.direct.blue,
aData->renderPictFormat.direct.alphaMask
<< aData->renderPictFormat.direct.alpha,
JNI_TRUE);
} else {
mid = (*env)->GetStaticMethodID( env,clazz,"createABGRCCM",
"()Ljava/awt/image/ComponentColorModel;");
if (mid == NULL) {
(*env)->PopLocalFrame(env, 0);
return NULL;
}
awt_colormodel = (*env)->CallStaticObjectMethod(
env,clazz, mid);
}
}
if(awt_colormodel == NULL) if(awt_colormodel == NULL)
{ {
...@@ -923,25 +984,13 @@ jobject awtJNI_GetColorModel(JNIEnv *env, AwtGraphicsConfigDataPtr aData) ...@@ -923,25 +984,13 @@ jobject awtJNI_GetColorModel(JNIEnv *env, AwtGraphicsConfigDataPtr aData)
} }
else if (aData->awt_visInfo.class == StaticGray && else if (aData->awt_visInfo.class == StaticGray &&
aData->awt_num_colors == 256) { aData->awt_num_colors == 256) {
jclass clazz1;
jobject cspace = NULL; jobject cspace = NULL;
jint bits[1]; jint bits[1];
jintArray bitsArray; jintArray bitsArray;
jboolean falseboolean = JNI_FALSE; jboolean falseboolean = JNI_FALSE;
clazz1 = (*env)->FindClass(env,"java/awt/color/ColorSpace"); cspace = getColorSpace(env, java_awt_color_ColorSpace_CS_GRAY);
mid = (*env)->GetStaticMethodID(env, clazz1, "getInstance",
"(I)Ljava/awt/color/ColorSpace;");
if (mid == NULL) {
(*env)->PopLocalFrame(env, 0);
return NULL;
}
/* SECURITY: This is safe, because static methods cannot
* be overridden, and this method does not invoke
* client code
*/
cspace = (*env)->CallStaticObjectMethod(env, clazz1, mid,
java_awt_color_ColorSpace_CS_GRAY);
if (cspace == NULL) { if (cspace == NULL) {
(*env)->PopLocalFrame(env, 0); (*env)->PopLocalFrame(env, 0);
return NULL; return NULL;
......
...@@ -175,42 +175,11 @@ Java_sun_awt_X11GraphicsDevice_initIDs (JNIEnv *env, jclass cls) ...@@ -175,42 +175,11 @@ Java_sun_awt_X11GraphicsDevice_initIDs (JNIEnv *env, jclass cls)
} }
#ifndef HEADLESS #ifndef HEADLESS
/* /*
* error handlers * XIOErrorHandler
*/ */
static int xioerror_handler(Display *disp)
int
xerror_handler(Display * disp, XErrorEvent * err)
{
/* #ifdef DEBUG */
char msg[128];
char buf[128];
char *ev = getenv("NOISY_AWT");
if (!ev || !ev[0])
return 0;
XGetErrorText(disp, err->error_code, msg, sizeof(msg));
jio_fprintf(stderr, "Xerror %s, XID %x, ser# %d\n", msg, err->resourceid, err->serial);
jio_snprintf(buf, sizeof(buf), "%d", err->request_code);
XGetErrorDatabaseText(disp, "XRequest", buf, "Unknown", msg, sizeof(msg));
jio_fprintf(stderr, "Major opcode %d (%s)\n", err->request_code, msg);
if (err->request_code > 128) {
jio_fprintf(stderr, "Minor opcode %d\n", err->minor_code);
}
if (awtLockInited) {
/*SignalError(lockedee->lastpc, lockedee, "fp/ade/gui/GUIException", msg); */
}
if (strcasecmp(ev, "abort") == 0) {
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
(*env)->FatalError(env, "xerror_handler abort");
}
/* #endif */
return 0;
}
static int
xioerror_handler(Display * disp)
{ {
if (awtLockInited) { if (awtLockInited) {
if (errno == EPIPE) { if (errno == EPIPE) {
...@@ -354,48 +323,6 @@ makeDefaultConfig(JNIEnv *env, int screen) { ...@@ -354,48 +323,6 @@ makeDefaultConfig(JNIEnv *env, int screen) {
return NULL; return NULL;
} }
/* Note: until we include the <X11/extensions/Xrender.h> explicitly
* we have to define a couple of things ourselves.
*/
typedef unsigned long PictFormat;
#define PictTypeIndexed 0
#define PictTypeDirect 1
typedef struct {
short red;
short redMask;
short green;
short greenMask;
short blue;
short blueMask;
short alpha;
short alphaMask;
} XRenderDirectFormat;
typedef struct {
PictFormat id;
int type;
int depth;
XRenderDirectFormat direct;
Colormap colormap;
} XRenderPictFormat;
#define PictFormatID (1 << 0)
#define PictFormatType (1 << 1)
#define PictFormatDepth (1 << 2)
#define PictFormatRed (1 << 3)
#define PictFormatRedMask (1 << 4)
#define PictFormatGreen (1 << 5)
#define PictFormatGreenMask (1 << 6)
#define PictFormatBlue (1 << 7)
#define PictFormatBlueMask (1 << 8)
#define PictFormatAlpha (1 << 9)
#define PictFormatAlphaMask (1 << 10)
#define PictFormatColormap (1 << 11)
typedef XRenderPictFormat *
XRenderFindVisualFormatFunc (Display *dpy, _Xconst Visual *visual);
static void static void
getAllConfigs (JNIEnv *env, int screen, AwtScreenDataPtr screenDataPtr) { getAllConfigs (JNIEnv *env, int screen, AwtScreenDataPtr screenDataPtr) {
...@@ -535,6 +462,8 @@ getAllConfigs (JNIEnv *env, int screen, AwtScreenDataPtr screenDataPtr) { ...@@ -535,6 +462,8 @@ getAllConfigs (JNIEnv *env, int screen, AwtScreenDataPtr screenDataPtr) {
format->direct.alphaMask) format->direct.alphaMask)
{ {
graphicsConfigs [ind]->isTranslucencySupported = 1; graphicsConfigs [ind]->isTranslucencySupported = 1;
memcpy(&graphicsConfigs [ind]->renderPictFormat, format,
sizeof(*format));
} }
} }
} }
...@@ -886,7 +815,6 @@ awt_init_Display(JNIEnv *env, jobject this) ...@@ -886,7 +815,6 @@ awt_init_Display(JNIEnv *env, jobject this)
return NULL; return NULL;
} }
XSetErrorHandler(xerror_handler);
XSetIOErrorHandler(xioerror_handler); XSetIOErrorHandler(xioerror_handler);
/* set awt_numScreens, and whether or not we're using Xinerama */ /* set awt_numScreens, and whether or not we're using Xinerama */
......
...@@ -1458,7 +1458,6 @@ static void CommitStringCallback(XIC ic, XPointer client_data, XPointer call_dat ...@@ -1458,7 +1458,6 @@ static void CommitStringCallback(XIC ic, XPointer client_data, XPointer call_dat
} }
static void OpenXIMCallback(Display *display, XPointer client_data, XPointer call_data) { static void OpenXIMCallback(Display *display, XPointer client_data, XPointer call_data) {
extern int xerror_handler();
XIMCallback ximCallback; XIMCallback ximCallback;
X11im = XOpenIM(display, NULL, NULL, NULL); X11im = XOpenIM(display, NULL, NULL, NULL);
...@@ -1469,13 +1468,6 @@ static void OpenXIMCallback(Display *display, XPointer client_data, XPointer cal ...@@ -1469,13 +1468,6 @@ static void OpenXIMCallback(Display *display, XPointer client_data, XPointer cal
ximCallback.callback = (XIMProc)DestroyXIMCallback; ximCallback.callback = (XIMProc)DestroyXIMCallback;
ximCallback.client_data = NULL; ximCallback.client_data = NULL;
XSetIMValues(X11im, XNDestroyCallback, &ximCallback, NULL); XSetIMValues(X11im, XNDestroyCallback, &ximCallback, NULL);
/* Workaround for Solaris 2.6 bug 4097754. We're affected by this problem
* because Motif also calls XOpenIM for us. Re-registering the error handler
* that MToolkit has registered already after calling XOpenIM avoids the
* problem.
*/
XSetErrorHandler(xerror_handler);
} }
static void DestroyXIMCallback(XIM im, XPointer client_data, XPointer call_data) { static void DestroyXIMCallback(XIM im, XPointer client_data, XPointer call_data) {
......
...@@ -1926,26 +1926,6 @@ processOneEvent(XtInputMask iMask) { ...@@ -1926,26 +1926,6 @@ processOneEvent(XtInputMask iMask) {
XtAppProcessEvent(awt_appContext, iMask & ~XtIMXEvent); XtAppProcessEvent(awt_appContext, iMask & ~XtIMXEvent);
} }
/*
** Bug #4361799: Forte4J sometimes crashes on Solaris:
** There is an underlying bug in Selection.c in Xt lib.
** The routine HandleSelectionEvents, can call EndProtectedSection()
** more than StartProtectedSection(), and then EndProtectedSection
** will restore the default XError handler. As a result awt's
** XError handler gets removed and we later crash on an XError.
**
** This happens when we call XtAppProcessEvent with event type 1e
** (SelectionRequest) when running two copies of Forte
**
** XSetErrorHandler can safely be called repeatedly, so we are
** fixing this with the sledgehammer, and resetting our XError
** handler every time through the loop:
*/
{
extern int32_t xerror_handler();
XSetErrorHandler(xerror_handler);
}
} /* processOneEvent() */ } /* processOneEvent() */
/* /*
...@@ -3186,21 +3166,6 @@ JNIEXPORT jint JNICALL Java_sun_awt_motif_MToolkit_getMulticlickTime ...@@ -3186,21 +3166,6 @@ JNIEXPORT jint JNICALL Java_sun_awt_motif_MToolkit_getMulticlickTime
return awt_multiclick_time; return awt_multiclick_time;
} }
/*
* Class: sun_awt_motif_MToolkit
* Method: getNumMouseButtons
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_sun_awt_motif_MToolkit_getNumMouseButtons
(JNIEnv *env, jobject this)
{
jint res = 0;
AWT_LOCK();
res = XGetPointerMapping(awt_display, NULL, 0);
AWT_UNLOCK();
return res;
}
/* /*
* Class: sun_awt_motif_MToolkit * Class: sun_awt_motif_MToolkit
* Method: loadXSettings * Method: loadXSettings
......
...@@ -51,9 +51,8 @@ ...@@ -51,9 +51,8 @@
extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs; extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
// 2 would be more correct, however that's how Robot originally worked extern int32_t getNumButtons();
// and tests start to fail if this value is changed
static int32_t num_buttons = 3;
static jint * masks; static jint * masks;
static int32_t isXTestAvailable() { static int32_t isXTestAvailable() {
...@@ -90,46 +89,6 @@ static int32_t isXTestAvailable() { ...@@ -90,46 +89,6 @@ static int32_t isXTestAvailable() {
return isXTestAvailable; return isXTestAvailable;
} }
static void getNumButtons() {
int32_t major_opcode, first_event, first_error;
int32_t xinputAvailable;
int32_t numDevices, devIdx, clsIdx;
XDeviceInfo* devices;
XDeviceInfo* aDevice;
XButtonInfo* bInfo;
/* 4700242:
* If XTest is asked to press a non-existant mouse button
* (i.e. press Button3 on a system configured with a 2-button mouse),
* then a crash may happen. To avoid this, we use the XInput
* extension to query for the number of buttons on the XPointer, and check
* before calling XTestFakeButtonEvent().
*/
xinputAvailable = XQueryExtension(awt_display, INAME, &major_opcode, &first_event, &first_error);
DTRACE_PRINTLN3("RobotPeer: XQueryExtension(XINPUT) returns major_opcode = %d, first_event = %d, first_error = %d",
major_opcode, first_event, first_error);
if (xinputAvailable) {
devices = XListInputDevices(awt_display, &numDevices);
for (devIdx = 0; devIdx < numDevices; devIdx++) {
aDevice = &(devices[devIdx]);
if (aDevice->use == IsXPointer) {
for (clsIdx = 0; clsIdx < aDevice->num_classes; clsIdx++) {
if (aDevice->inputclassinfo[clsIdx].class == ButtonClass) {
bInfo = (XButtonInfo*)(&(aDevice->inputclassinfo[clsIdx]));
num_buttons = bInfo->num_buttons;
DTRACE_PRINTLN1("RobotPeer: XPointer has %d buttons", num_buttons);
break;
}
}
break;
}
}
XFreeDeviceList(devices);
}
else {
DTRACE_PRINTLN1("RobotPeer: XINPUT extension is unavailable, assuming %d mouse buttons", num_buttons);
}
}
static XImage *getWindowImage(Display * display, Window window, static XImage *getWindowImage(Display * display, Window window,
int32_t x, int32_t y, int32_t x, int32_t y,
...@@ -241,17 +200,10 @@ Java_sun_awt_X11_XRobotPeer_setup (JNIEnv * env, jclass cls) { ...@@ -241,17 +200,10 @@ Java_sun_awt_X11_XRobotPeer_setup (JNIEnv * env, jclass cls) {
return; return;
} }
getNumButtons();
finally: finally:
AWT_UNLOCK(); 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 JNIEXPORT void JNICALL
Java_sun_awt_X11_XRobotPeer_getRGBPixelsImpl( JNIEnv *env, Java_sun_awt_X11_XRobotPeer_getRGBPixelsImpl( JNIEnv *env,
...@@ -386,6 +338,8 @@ void mouseAction(JNIEnv *env, ...@@ -386,6 +338,8 @@ void mouseAction(JNIEnv *env,
{ {
AWT_LOCK(); AWT_LOCK();
int32_t num_buttons = getNumButtons(); //from XToolkit.c
DTRACE_PRINTLN1("RobotPeer: mouseAction(%i)", buttonMask); DTRACE_PRINTLN1("RobotPeer: mouseAction(%i)", buttonMask);
DTRACE_PRINTLN1("RobotPeer: mouseAction, press = %d", isMousePress); DTRACE_PRINTLN1("RobotPeer: mouseAction, press = %d", isMousePress);
......
...@@ -119,6 +119,50 @@ typedef struct _DamageRect { ...@@ -119,6 +119,50 @@ typedef struct _DamageRect {
} DamageRect; } DamageRect;
#ifndef HEADLESS #ifndef HEADLESS
/* Note: until we include the <X11/extensions/Xrender.h> explicitly
* we have to define a couple of things ourselves.
*/
typedef unsigned long PictFormat;
#define PictTypeIndexed 0
#define PictTypeDirect 1
typedef struct {
short red;
short redMask;
short green;
short greenMask;
short blue;
short blueMask;
short alpha;
short alphaMask;
} XRenderDirectFormat;
typedef struct {
PictFormat id;
int type;
int depth;
XRenderDirectFormat direct;
Colormap colormap;
} XRenderPictFormat;
#define PictFormatID (1 << 0)
#define PictFormatType (1 << 1)
#define PictFormatDepth (1 << 2)
#define PictFormatRed (1 << 3)
#define PictFormatRedMask (1 << 4)
#define PictFormatGreen (1 << 5)
#define PictFormatGreenMask (1 << 6)
#define PictFormatBlue (1 << 7)
#define PictFormatBlueMask (1 << 8)
#define PictFormatAlpha (1 << 9)
#define PictFormatAlphaMask (1 << 10)
#define PictFormatColormap (1 << 11)
typedef XRenderPictFormat *
XRenderFindVisualFormatFunc (Display *dpy, _Xconst Visual *visual);
/* END OF Xrender.h chunk */
typedef struct _AwtGraphicsConfigData { typedef struct _AwtGraphicsConfigData {
int awt_depth; int awt_depth;
Colormap awt_cmap; Colormap awt_cmap;
...@@ -136,6 +180,7 @@ typedef struct _AwtGraphicsConfigData { ...@@ -136,6 +180,7 @@ typedef struct _AwtGraphicsConfigData {
ColorData *color_data; ColorData *color_data;
struct _GLXGraphicsConfigInfo *glxInfo; struct _GLXGraphicsConfigInfo *glxInfo;
int isTranslucencySupported; /* Uses Xrender to find this out. */ int isTranslucencySupported; /* Uses Xrender to find this out. */
XRenderPictFormat renderPictFormat; /*Used only if translucency supported*/
} AwtGraphicsConfigData; } AwtGraphicsConfigData;
typedef AwtGraphicsConfigData* AwtGraphicsConfigDataPtr; typedef AwtGraphicsConfigData* AwtGraphicsConfigDataPtr;
......
...@@ -45,10 +45,14 @@ ...@@ -45,10 +45,14 @@
#include "sun_awt_X11_XToolkit.h" #include "sun_awt_X11_XToolkit.h"
#include "java_awt_SystemColor.h" #include "java_awt_SystemColor.h"
#include "java_awt_TrayIcon.h" #include "java_awt_TrayIcon.h"
#include <X11/extensions/XTest.h>
uint32_t awt_NumLockMask = 0; uint32_t awt_NumLockMask = 0;
Boolean awt_ModLockIsShiftLock = False; Boolean awt_ModLockIsShiftLock = False;
static int32_t num_buttons = 0;
int32_t getNumButtons();
extern JavaVM *jvm; extern JavaVM *jvm;
// Tracing level // Tracing level
...@@ -575,7 +579,6 @@ performPoll(JNIEnv *env, jlong nextTaskTime) { ...@@ -575,7 +579,6 @@ performPoll(JNIEnv *env, jlong nextTaskTime) {
pollFds[1].revents = 0; pollFds[1].revents = 0;
} }
AWT_NOFLUSH_UNLOCK(); AWT_NOFLUSH_UNLOCK();
/* ACTUALLY DO THE POLL() */ /* ACTUALLY DO THE POLL() */
...@@ -684,8 +687,6 @@ JNIEXPORT jstring JNICALL Java_sun_awt_X11_XToolkit_getEnv ...@@ -684,8 +687,6 @@ JNIEXPORT jstring JNICALL Java_sun_awt_X11_XToolkit_getEnv
return ret; return ret;
} }
static XErrorHandler saved_error_handler = NULL;
#ifdef __linux__ #ifdef __linux__
void print_stack(void) void print_stack(void)
{ {
...@@ -706,38 +707,6 @@ void print_stack(void) ...@@ -706,38 +707,6 @@ void print_stack(void)
} }
#endif #endif
static int NoisyXErrorHandler(Display * dpy, XErrorEvent * event) {
fprintf(stderr, "id=%x, serial=%x, ec=%d, rc=%d, mc=%d\n",
event->resourceid, event->serial, event->error_code,
event->request_code, event->minor_code);
/*
#ifdef __linux__
print_stack();
#endif
*/
if (jvm != NULL) {
JNIEnv * env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
JNU_CallStaticMethodByName(env, NULL, "java/lang/Thread", "dumpStack", "()V");
}
if (!saved_error_handler) {
return saved_error_handler(dpy, event);
}
return 0;
}
/*
* Class: sun_awt_X11_XToolkit
* Method: setNoisyXErrorHandler
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_sun_awt_X11_XToolkit_setNoisyXErrorHandler
(JNIEnv *env , jclass clazz)
{
(*env)->GetJavaVM(env, &jvm);
saved_error_handler = XSetErrorHandler(NoisyXErrorHandler);
}
Window get_xawt_root_shell(JNIEnv *env) { Window get_xawt_root_shell(JNIEnv *env) {
static jclass classXRootWindow = NULL; static jclass classXRootWindow = NULL;
static jmethodID methodGetXRootWindow = NULL; static jmethodID methodGetXRootWindow = NULL;
...@@ -943,3 +912,80 @@ Java_java_awt_Cursor_finalizeImpl(JNIEnv *env, jclass clazz, jlong pData) ...@@ -943,3 +912,80 @@ Java_java_awt_Cursor_finalizeImpl(JNIEnv *env, jclass clazz, jlong pData)
AWT_UNLOCK(); AWT_UNLOCK();
} }
} }
/*
* Class: sun_awt_X11_XToolkit
* Method: getNumberOfButtonsImpl
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_sun_awt_X11_XToolkit_getNumberOfButtonsImpl
(JNIEnv * env, jobject cls){
if (num_buttons == 0) {
num_buttons = getNumButtons();
}
return num_buttons;
}
int32_t getNumButtons() {
int32_t major_opcode, first_event, first_error;
int32_t xinputAvailable;
int32_t numDevices, devIdx, clsIdx;
XDeviceInfo* devices;
XDeviceInfo* aDevice;
XButtonInfo* bInfo;
int32_t local_num_buttons = 0;
/* 4700242:
* If XTest is asked to press a non-existant mouse button
* (i.e. press Button3 on a system configured with a 2-button mouse),
* then a crash may happen. To avoid this, we use the XInput
* extension to query for the number of buttons on the XPointer, and check
* before calling XTestFakeButtonEvent().
*/
xinputAvailable = XQueryExtension(awt_display, INAME, &major_opcode, &first_event, &first_error);
DTRACE_PRINTLN3("RobotPeer: XQueryExtension(XINPUT) returns major_opcode = %d, first_event = %d, first_error = %d",
major_opcode, first_event, first_error);
if (xinputAvailable) {
devices = XListInputDevices(awt_display, &numDevices);
for (devIdx = 0; devIdx < numDevices; devIdx++) {
aDevice = &(devices[devIdx]);
#ifdef IsXExtensionPointer
if (aDevice->use == IsXExtensionPointer) {
for (clsIdx = 0; clsIdx < aDevice->num_classes; clsIdx++) {
if (aDevice->inputclassinfo[clsIdx].class == ButtonClass) {
bInfo = (XButtonInfo*)(&(aDevice->inputclassinfo[clsIdx]));
local_num_buttons = bInfo->num_buttons;
DTRACE_PRINTLN1("RobotPeer: XPointer has %d buttons", num_buttons);
break;
}
}
break;
}
#endif
if (local_num_buttons <= 0 ) {
if (aDevice->use == IsXPointer) {
for (clsIdx = 0; clsIdx < aDevice->num_classes; clsIdx++) {
if (aDevice->inputclassinfo[clsIdx].class == ButtonClass) {
bInfo = (XButtonInfo*)(&(aDevice->inputclassinfo[clsIdx]));
local_num_buttons = bInfo->num_buttons;
DTRACE_PRINTLN1("RobotPeer: XPointer has %d buttons", num_buttons);
break;
}
}
break;
}
}
}
XFreeDeviceList(devices);
}
else {
DTRACE_PRINTLN1("RobotPeer: XINPUT extension is unavailable, assuming %d mouse buttons", num_buttons);
}
if (local_num_buttons == 0 ) {
local_num_buttons = 3;
}
return local_num_buttons;
}
...@@ -1186,7 +1186,7 @@ JavaVM* jvm = NULL; ...@@ -1186,7 +1186,7 @@ JavaVM* jvm = NULL;
static int ToolkitErrorHandler(Display * dpy, XErrorEvent * event) { static int ToolkitErrorHandler(Display * dpy, XErrorEvent * event) {
if (jvm != NULL) { if (jvm != NULL) {
JNIEnv * env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); JNIEnv * env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
return JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XToolkit", "GlobalErrorHandler", "(JJ)I", return JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XToolkit", "globalErrorHandler", "(JJ)I",
ptr_to_jlong(dpy), ptr_to_jlong(event)).i; ptr_to_jlong(dpy), ptr_to_jlong(event)).i;
} else { } else {
return 0; return 0;
...@@ -1229,6 +1229,28 @@ JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_CallErrorHandler ...@@ -1229,6 +1229,28 @@ JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_CallErrorHandler
return (*(XErrorHandler)jlong_to_ptr(handler))((Display*) jlong_to_ptr(display), (XErrorEvent*) jlong_to_ptr(event_ptr)); return (*(XErrorHandler)jlong_to_ptr(handler))((Display*) jlong_to_ptr(display), (XErrorEvent*) jlong_to_ptr(event_ptr));
} }
/*
* Class: sun_awt_X11_XlibWrapper
* Method: PrintXErrorEvent
* Signature: (JJ)V
*/
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_PrintXErrorEvent
(JNIEnv *env, jclass clazz, jlong display, jlong event_ptr)
{
char msg[128];
char buf[128];
XErrorEvent* err = (XErrorEvent *)jlong_to_ptr(event_ptr);
XGetErrorText((Display *)jlong_to_ptr(display), err->error_code, msg, sizeof(msg));
jio_fprintf(stderr, "Xerror %s, XID %x, ser# %d\n", msg, err->resourceid, err->serial);
jio_snprintf(buf, sizeof(buf), "%d", err->request_code);
XGetErrorDatabaseText((Display *)jlong_to_ptr(display), "XRequest", buf, "Unknown", msg, sizeof(msg));
jio_fprintf(stderr, "Major opcode %d (%s)\n", err->request_code, msg);
if (err->request_code > 128) {
jio_fprintf(stderr, "Minor opcode %d\n", err->minor_code);
}
}
/* /*
......
...@@ -105,9 +105,10 @@ public abstract class TranslucentWindowPainter { ...@@ -105,9 +105,10 @@ public abstract class TranslucentWindowPainter {
} }
/** /**
* Creates (if needed), clears and returns the buffer for this painter. * Creates (if needed), clears (if requested) and returns the buffer
* for this painter.
*/ */
protected abstract Image getBackBuffer(); protected abstract Image getBackBuffer(boolean clear);
/** /**
* Updates the the window associated with this painter with the contents * Updates the the window associated with this painter with the contents
...@@ -123,31 +124,16 @@ public abstract class TranslucentWindowPainter { ...@@ -123,31 +124,16 @@ public abstract class TranslucentWindowPainter {
public abstract void flush(); public abstract void flush();
/** /**
* Updates the window associated with the painter given the passed image. * Updates the window associated with the painter.
* If the passed image is null the painter will use its own buffer for
* rendering the contents of the window into it and updating the window.
* *
* If the passed buffer has dimensions different from the window, it is * @param repaint indicates if the window should be completely repainted
* copied into the internal buffer first and the latter is used to update * to the back buffer using {@link java.awt.Window#paintAll} before update.
* the window.
*
* @param bb the image to update the non opaque window with, or null.
* If not null, the image must be of ARGB_PRE type.
*/ */
public void updateWindow(Image bb) { public void updateWindow(boolean repaint) {
boolean done = false; boolean done = false;
if (bb != null && (window.getWidth() != bb.getWidth(null) || Image bb = getBackBuffer(repaint);
window.getHeight() != bb.getHeight(null))) while (!done) {
{ if (repaint) {
Image ourBB = getBackBuffer();
Graphics2D g = (Graphics2D)ourBB.getGraphics();
g.drawImage(bb, 0, 0, null);
g.dispose();
bb = ourBB;
}
do {
if (bb == null) {
bb = getBackBuffer();
Graphics2D g = (Graphics2D)bb.getGraphics(); Graphics2D g = (Graphics2D)bb.getGraphics();
try { try {
window.paintAll(g); window.paintAll(g);
...@@ -156,17 +142,12 @@ public abstract class TranslucentWindowPainter { ...@@ -156,17 +142,12 @@ public abstract class TranslucentWindowPainter {
} }
} }
peer.paintAppletWarning((Graphics2D)bb.getGraphics(),
bb.getWidth(null), bb.getHeight(null));
done = update(bb); done = update(bb);
// in case they passed us a lost VI, next time around we'll use our
// own bb because we can not validate and restore the contents of
// their VI
if (!done) { if (!done) {
bb = null; repaint = true;
bb = getBackBuffer(true);
} }
} while (!done); }
} }
private static final Image clearImage(Image bb) { private static final Image clearImage(Image bb) {
...@@ -190,30 +171,24 @@ public abstract class TranslucentWindowPainter { ...@@ -190,30 +171,24 @@ public abstract class TranslucentWindowPainter {
* method (VI, BI, regular Images). * method (VI, BI, regular Images).
*/ */
private static class BIWindowPainter extends TranslucentWindowPainter { private static class BIWindowPainter extends TranslucentWindowPainter {
private WeakReference<BufferedImage> biRef; private BufferedImage backBuffer;
protected BIWindowPainter(WWindowPeer peer) { protected BIWindowPainter(WWindowPeer peer) {
super(peer); super(peer);
} }
private BufferedImage getBIBackBuffer() { @Override
protected Image getBackBuffer(boolean clear) {
int w = window.getWidth(); int w = window.getWidth();
int h = window.getHeight(); int h = window.getHeight();
BufferedImage bb = biRef == null ? null : biRef.get(); if (backBuffer == null ||
if (bb == null || bb.getWidth() != w || bb.getHeight() != h) { backBuffer.getWidth() != w ||
if (bb != null) { backBuffer.getHeight() != h)
bb.flush(); {
bb = null; flush();
} backBuffer = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE);
bb = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE);
biRef = new WeakReference<BufferedImage>(bb);
} }
return (BufferedImage)clearImage(bb); return clear ? (BufferedImage)clearImage(backBuffer) : backBuffer;
}
@Override
protected Image getBackBuffer() {
return getBIBackBuffer();
} }
@Override @Override
...@@ -246,10 +221,7 @@ public abstract class TranslucentWindowPainter { ...@@ -246,10 +221,7 @@ public abstract class TranslucentWindowPainter {
} }
// copy the passed image into our own buffer, then upload // copy the passed image into our own buffer, then upload
BufferedImage bi = getBIBackBuffer(); BufferedImage bi = (BufferedImage)clearImage(backBuffer);
Graphics2D g = (Graphics2D)bi.getGraphics();
g.setComposite(AlphaComposite.Src);
g.drawImage(bb, 0, 0, null);
int data[] = int data[] =
((DataBufferInt)bi.getRaster().getDataBuffer()).getData(); ((DataBufferInt)bi.getRaster().getDataBuffer()).getData();
...@@ -259,8 +231,9 @@ public abstract class TranslucentWindowPainter { ...@@ -259,8 +231,9 @@ public abstract class TranslucentWindowPainter {
} }
public void flush() { public void flush() {
if (biRef != null) { if (backBuffer != null) {
biRef.clear(); backBuffer.flush();
backBuffer = null;
} }
} }
} }
...@@ -271,27 +244,22 @@ public abstract class TranslucentWindowPainter { ...@@ -271,27 +244,22 @@ public abstract class TranslucentWindowPainter {
* Java heap-based buffer (which is then uploaded to the layered window) * Java heap-based buffer (which is then uploaded to the layered window)
*/ */
private static class VIWindowPainter extends BIWindowPainter { private static class VIWindowPainter extends BIWindowPainter {
private WeakReference<VolatileImage> viRef; private VolatileImage viBB;
protected VIWindowPainter(WWindowPeer peer) { protected VIWindowPainter(WWindowPeer peer) {
super(peer); super(peer);
} }
@Override @Override
protected Image getBackBuffer() { protected Image getBackBuffer(boolean clear) {
int w = window.getWidth(); int w = window.getWidth();
int h = window.getHeight(); int h = window.getHeight();
GraphicsConfiguration gc = peer.getGraphicsConfiguration(); GraphicsConfiguration gc = peer.getGraphicsConfiguration();
VolatileImage viBB = viRef == null ? null : viRef.get();
if (viBB == null || viBB.getWidth() != w || viBB.getHeight() != h || if (viBB == null || viBB.getWidth() != w || viBB.getHeight() != h ||
viBB.validate(gc) == IMAGE_INCOMPATIBLE) viBB.validate(gc) == IMAGE_INCOMPATIBLE)
{ {
if (viBB != null) { flush();
viBB.flush();
viBB = null;
}
if (gc instanceof AccelGraphicsConfig) { if (gc instanceof AccelGraphicsConfig) {
AccelGraphicsConfig agc = ((AccelGraphicsConfig)gc); AccelGraphicsConfig agc = ((AccelGraphicsConfig)gc);
...@@ -303,21 +271,16 @@ public abstract class TranslucentWindowPainter { ...@@ -303,21 +271,16 @@ public abstract class TranslucentWindowPainter {
viBB = gc.createCompatibleVolatileImage(w, h, TRANSLUCENT); viBB = gc.createCompatibleVolatileImage(w, h, TRANSLUCENT);
} }
viBB.validate(gc); viBB.validate(gc);
viRef = new WeakReference<VolatileImage>(viBB);
} }
return clearImage(viBB); return clear ? clearImage(viBB) : viBB;
} }
@Override @Override
public void flush() { public void flush() {
if (viRef != null) { if (viBB != null) {
VolatileImage viBB = viRef.get(); viBB.flush();
if (viBB != null) { viBB = null;
viBB.flush();
viBB = null;
}
viRef.clear();
} }
} }
} }
......
...@@ -78,25 +78,6 @@ class WCanvasPeer extends WComponentPeer implements CanvasPeer { ...@@ -78,25 +78,6 @@ class WCanvasPeer extends WComponentPeer implements CanvasPeer {
super.paint(g); super.paint(g);
} }
public void print(Graphics g) {
if (!(target instanceof Window) ||
AWTAccessor.getWindowAccessor().isOpaque((Window)target))
{
Dimension d = ((Component)target).getSize();
if (g instanceof Graphics2D ||
g instanceof sun.awt.Graphics2Delegate) {
// background color is setup correctly, so just use clearRect
g.clearRect(0, 0, d.width, d.height);
} else {
// emulate clearRect
g.setColor(((Component)target).getBackground());
g.fillRect(0, 0, d.width, d.height);
g.setColor(((Component)target).getForeground());
}
}
super.print(g);
}
public boolean shouldClearRectBeforePaint() { public boolean shouldClearRectBeforePaint() {
return eraseBackground; return eraseBackground;
} }
......
...@@ -239,7 +239,8 @@ public abstract class WComponentPeer extends WObjectPeer ...@@ -239,7 +239,8 @@ public abstract class WComponentPeer extends WObjectPeer
private static final double BANDING_DIVISOR = 4.0; private static final double BANDING_DIVISOR = 4.0;
private native int[] createPrintedPixels(int srcX, int srcY, private native int[] createPrintedPixels(int srcX, int srcY,
int srcW, int srcH); int srcW, int srcH,
int alpha);
public void print(Graphics g) { public void print(Graphics g) {
Component comp = (Component)target; Component comp = (Component)target;
...@@ -261,7 +262,9 @@ public abstract class WComponentPeer extends WObjectPeer ...@@ -261,7 +262,9 @@ public abstract class WComponentPeer extends WObjectPeer
} }
int h = endY - startY + 1; int h = endY - startY + 1;
int[] pix = createPrintedPixels(0, startY, totalW, h); Color bgColor = comp.getBackground();
int[] pix = createPrintedPixels(0, startY, totalW, h,
bgColor == null ? 255 : bgColor.getAlpha());
if (pix != null) { if (pix != null) {
BufferedImage bim = new BufferedImage(totalW, h, BufferedImage bim = new BufferedImage(totalW, h,
BufferedImage.TYPE_INT_ARGB); BufferedImage.TYPE_INT_ARGB);
...@@ -488,13 +491,14 @@ public abstract class WComponentPeer extends WObjectPeer ...@@ -488,13 +491,14 @@ public abstract class WComponentPeer extends WObjectPeer
} }
} }
public void updateGraphicsData(GraphicsConfiguration gc) { public boolean updateGraphicsData(GraphicsConfiguration gc) {
winGraphicsConfig = (Win32GraphicsConfig)gc; winGraphicsConfig = (Win32GraphicsConfig)gc;
try { try {
replaceSurfaceData(); replaceSurfaceData();
} catch (InvalidPipeException e) { } catch (InvalidPipeException e) {
// REMIND : what do we do if our surface creation failed? // REMIND : what do we do if our surface creation failed?
} }
return false;
} }
//This will return null for Components not yet added to a Container //This will return null for Components not yet added to a Container
......
...@@ -42,6 +42,9 @@ abstract class WObjectPeer { ...@@ -42,6 +42,9 @@ abstract class WObjectPeer {
// set from JNI if any errors in creating the peer occur // set from JNI if any errors in creating the peer occur
protected Error createError = null; protected Error createError = null;
// used to synchronize the state of this peer
private final Object stateLock = new Object();
public static WObjectPeer getPeerForTarget(Object t) { public static WObjectPeer getPeerForTarget(Object t) {
WObjectPeer peer = (WObjectPeer) WToolkit.targetToPeer(t); WObjectPeer peer = (WObjectPeer) WToolkit.targetToPeer(t);
return peer; return peer;
...@@ -55,6 +58,10 @@ abstract class WObjectPeer { ...@@ -55,6 +58,10 @@ abstract class WObjectPeer {
return target; return target;
} }
public final Object getStateLock() {
return stateLock;
}
/* /*
* Subclasses should override disposeImpl() instead of dispose(). Client * Subclasses should override disposeImpl() instead of dispose(). Client
* code should always invoke dispose(), never disposeImpl(). * code should always invoke dispose(), never disposeImpl().
......
...@@ -60,8 +60,6 @@ class WRobotPeer extends WObjectPeer implements RobotPeer ...@@ -60,8 +60,6 @@ class WRobotPeer extends WObjectPeer implements RobotPeer
} }
public native int getRGBPixelImpl(int x, int y); public native int getRGBPixelImpl(int x, int y);
public native int getNumberOfButtons();
public int [] getRGBPixels(Rectangle bounds) { public int [] getRGBPixels(Rectangle bounds) {
int pixelArray[] = new int[bounds.width*bounds.height]; int pixelArray[] = new int[bounds.width*bounds.height];
getRGBPixels(bounds.x, bounds.y, bounds.width, bounds.height, pixelArray); getRGBPixels(bounds.x, bounds.y, bounds.width, bounds.height, pixelArray);
......
...@@ -982,6 +982,16 @@ public class WToolkit extends SunToolkit implements Runnable { ...@@ -982,6 +982,16 @@ public class WToolkit extends SunToolkit implements Runnable {
return areExtraMouseButtonsEnabled; return areExtraMouseButtonsEnabled;
} }
private native synchronized int getNumberOfButtonsImpl();
@Override
public int getNumberOfButtons(){
if (numberOfButtons == 0) {
numberOfButtons = getNumberOfButtonsImpl();
}
return (numberOfButtons > MAX_BUTTONS_SUPPORTED)? MAX_BUTTONS_SUPPORTED : numberOfButtons;
}
@Override @Override
public boolean isWindowOpacitySupported() { public boolean isWindowOpacitySupported() {
// supported in Win2K and later // supported in Win2K and later
......
...@@ -54,7 +54,7 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer, ...@@ -54,7 +54,7 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
private boolean isOpaque; private boolean isOpaque;
private volatile TranslucentWindowPainter painter; private TranslucentWindowPainter painter;
/* /*
* A key used for storing a list of active windows in AppContext. The value * A key used for storing a list of active windows in AppContext. The value
...@@ -106,11 +106,13 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer, ...@@ -106,11 +106,13 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
GraphicsConfiguration gc = getGraphicsConfiguration(); GraphicsConfiguration gc = getGraphicsConfiguration();
((Win32GraphicsDevice)gc.getDevice()).removeDisplayChangedListener(this); ((Win32GraphicsDevice)gc.getDevice()).removeDisplayChangedListener(this);
TranslucentWindowPainter currentPainter = painter; synchronized (getStateLock()) {
if (currentPainter != null) { TranslucentWindowPainter currentPainter = painter;
currentPainter.flush(); if (currentPainter != null) {
// don't set the current one to null here; reduces the chances of currentPainter.flush();
// MT issues (like NPEs) // don't set the current one to null here; reduces the chances of
// MT issues (like NPEs)
}
} }
super.disposeImpl(); super.disposeImpl();
...@@ -178,9 +180,23 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer, ...@@ -178,9 +180,23 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
updateIconImages(); updateIconImages();
updateShape(); Shape shape = ((Window)target).getShape();
updateOpacity(); if (shape != null) {
updateOpaque(); applyShape(Region.getInstance(shape, null));
}
float opacity = ((Window)target).getOpacity();
if (opacity < 1.0f) {
setOpacity(opacity);
}
synchronized (getStateLock()) {
// default value of a boolean field is 'false', so set isOpaque to
// true here explicitly
this.isOpaque = true;
Color bgColor = ((Window)target).getBackground();
setOpaque((bgColor == null) || (bgColor.getAlpha() == 255));
}
} }
native void createAwtWindow(WComponentPeer parent); native void createAwtWindow(WComponentPeer parent);
...@@ -214,7 +230,11 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer, ...@@ -214,7 +230,11 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
setAlwaysOnTop(alwaysOnTop); setAlwaysOnTop(alwaysOnTop);
} }
updateWindow(null); synchronized (getStateLock()) {
if (!isOpaque) {
updateWindow(true);
}
}
} }
// Synchronize the insets members (here & in helper) with actual window // Synchronize the insets members (here & in helper) with actual window
...@@ -334,29 +354,6 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer, ...@@ -334,29 +354,6 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
} }
} }
private void updateShape() {
Shape shape = ((Window)target).getShape();
if (shape != null) {
applyShape(Region.getInstance(shape, null));
}
}
private void updateOpacity() {
float opacity = ((Window)target).getOpacity();
if (opacity < 1.0f) {
setOpacity(opacity);
}
}
private void updateOpaque() {
this.isOpaque = true;
// boolean opaque = ((Window)target).isOpaque();
boolean opaque = AWTAccessor.getWindowAccessor().isOpaque((Window)target);
if (!opaque) {
setOpaque(opaque);
}
}
native void setMinSize(int width, int height); native void setMinSize(int width, int height);
/* /*
...@@ -579,6 +576,26 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer, ...@@ -579,6 +576,26 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
} }
} }
@Override
public Graphics getGraphics() {
synchronized (getStateLock()) {
if (!isOpaque) {
return painter.getBackBuffer(false).getGraphics();
}
}
return super.getGraphics();
}
@Override
public void setBackground(Color c) {
super.setBackground(c);
synchronized (getStateLock()) {
if (!isOpaque && ((Window)target).isVisible()) {
updateWindow(true);
}
}
}
private native void setOpacity(int iOpacity); private native void setOpacity(int iOpacity);
public void setOpacity(float opacity) { public void setOpacity(float opacity) {
...@@ -600,12 +617,23 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer, ...@@ -600,12 +617,23 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
} }
setOpacity(iOpacity); setOpacity(iOpacity);
updateWindow(null);
synchronized (getStateLock()) {
if (!isOpaque && ((Window)target).isVisible()) {
updateWindow(true);
}
}
} }
private native void setOpaqueImpl(boolean isOpaque); private native void setOpaqueImpl(boolean isOpaque);
public void setOpaque(boolean isOpaque) { public void setOpaque(boolean isOpaque) {
synchronized (getStateLock()) {
if (this.isOpaque == isOpaque) {
return;
}
}
Window target = (Window)getTarget(); Window target = (Window)getTarget();
if (!isOpaque) { if (!isOpaque) {
...@@ -617,20 +645,17 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer, ...@@ -617,20 +645,17 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
} }
} }
boolean opaqueChanged = this.isOpaque != isOpaque;
boolean isVistaOS = Win32GraphicsEnvironment.isVistaOS(); boolean isVistaOS = Win32GraphicsEnvironment.isVistaOS();
if (opaqueChanged && !isVistaOS){ if (!isVistaOS) {
// non-Vista OS: only replace the surface data if the opacity // non-Vista OS: only replace the surface data if the opacity
// status changed (see WComponentPeer.isAccelCapable() for more) // status changed (see WComponentPeer.isAccelCapable() for more)
replaceSurfaceDataRecursively(target); replaceSurfaceDataRecursively(target);
} }
this.isOpaque = isOpaque; synchronized (getStateLock()) {
this.isOpaque = isOpaque;
setOpaqueImpl(isOpaque); setOpaqueImpl(isOpaque);
if (opaqueChanged) {
if (isOpaque) { if (isOpaque) {
TranslucentWindowPainter currentPainter = painter; TranslucentWindowPainter currentPainter = painter;
if (currentPainter != null) { if (currentPainter != null) {
...@@ -642,7 +667,7 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer, ...@@ -642,7 +667,7 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
} }
} }
if (opaqueChanged && isVistaOS) { if (isVistaOS) {
// On Vista: setting the window non-opaque makes the window look // On Vista: setting the window non-opaque makes the window look
// rectangular, though still catching the mouse clicks within // rectangular, though still catching the mouse clicks within
// its shape only. To restore the correct visual appearance // its shape only. To restore the correct visual appearance
...@@ -654,42 +679,33 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer, ...@@ -654,42 +679,33 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
} }
} }
updateWindow(null); if (((Window)target).isVisible()) {
updateWindow(true);
}
} }
public native void updateWindowImpl(int[] data, int width, int height); public native void updateWindowImpl(int[] data, int width, int height);
public void updateWindow(BufferedImage backBuffer) { public void updateWindow() {
if (isOpaque) { updateWindow(false);
return;
}
Component target = (Component)this.target;
if (target.getWidth() <= 0 || target.getHeight() <= 0) {
return;
}
TranslucentWindowPainter currentPainter = painter;
if (currentPainter != null) {
currentPainter.updateWindow(backBuffer);
} else if (log.isLoggable(Level.FINER)) {
log.log(Level.FINER,
"Translucent window painter is null in updateWindow");
}
} }
/** private void updateWindow(boolean repaint) {
* Paints the Applet Warning into the passed Graphics2D. This method is Window w = (Window)target;
* called by the TranslucentWindowPainter before updating the layered synchronized (getStateLock()) {
* window. if (isOpaque || !w.isVisible() ||
* (w.getWidth() <= 0) || (w.getHeight() <= 0))
* @param g Graphics context to paint the warning to {
* @param w the width of the area return;
* @param h the height of the area }
* @see TranslucentWindowPainter TranslucentWindowPainter currentPainter = painter;
*/ if (currentPainter != null) {
public void paintAppletWarning(Graphics2D g, int w, int h) { currentPainter.updateWindow(repaint);
// REMIND: the applet warning needs to be painted here } else if (log.isLoggable(Level.FINER)) {
log.log(Level.FINER,
"Translucent window painter is null in updateWindow");
}
}
} }
/* /*
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "jlong.h" #include "jlong.h"
#include "awt_AWTEvent.h" #include "awt_AWTEvent.h"
#include "awt_BitmapUtil.h"
#include "awt_Component.h" #include "awt_Component.h"
#include "awt_Cursor.h" #include "awt_Cursor.h"
#include "awt_Dimension.h" #include "awt_Dimension.h"
...@@ -127,6 +128,7 @@ struct CreatePrintedPixelsStruct { ...@@ -127,6 +128,7 @@ struct CreatePrintedPixelsStruct {
jobject component; jobject component;
int srcx, srcy; int srcx, srcy;
int srcw, srch; int srcw, srch;
jint alpha;
}; };
// Struct for _SetRectangularShape() method // Struct for _SetRectangularShape() method
struct SetRectangularShapeStruct { struct SetRectangularShapeStruct {
...@@ -361,8 +363,8 @@ AwtComponent* AwtComponent::GetComponent(HWND hWnd) { ...@@ -361,8 +363,8 @@ AwtComponent* AwtComponent::GetComponent(HWND hWnd) {
AwtComponent* AwtComponent::GetComponentImpl(HWND hWnd) { AwtComponent* AwtComponent::GetComponentImpl(HWND hWnd) {
AwtComponent *component = AwtComponent *component =
(AwtComponent *)::GetWindowLongPtr(hWnd, GWLP_USERDATA); (AwtComponent *)::GetWindowLongPtr(hWnd, GWLP_USERDATA);
DASSERT( !IsBadReadPtr(component, sizeof(AwtComponent)) ); DASSERT(!component || !IsBadReadPtr(component, sizeof(AwtComponent)) );
DASSERT( component->GetHWnd() == hWnd ); DASSERT(!component || component->GetHWnd() == hWnd );
return component; return component;
} }
...@@ -1918,11 +1920,14 @@ LRESULT AwtComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) ...@@ -1918,11 +1920,14 @@ LRESULT AwtComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
mr = mrConsume; mr = mrConsume;
break; break;
} }
case WM_AWT_CREATE_PRINTED_PIXELS: case WM_AWT_CREATE_PRINTED_PIXELS: {
retValue = (LRESULT)CreatePrintedPixels(*((SIZE *)wParam), CreatePrintedPixelsStruct* cpps = (CreatePrintedPixelsStruct*)wParam;
*((SIZE *)lParam)); SIZE loc = { cpps->srcx, cpps->srcy };
SIZE size = { cpps->srcw, cpps->srch };
retValue = (LRESULT)CreatePrintedPixels(loc, size, cpps->alpha);
mr = mrConsume; mr = mrConsume;
break; break;
}
case WM_UNDOCUMENTED_CLICKMENUBAR: case WM_UNDOCUMENTED_CLICKMENUBAR:
{ {
if (::IsWindow(AwtWindow::GetModalBlocker(GetHWnd()))) { if (::IsWindow(AwtWindow::GetModalBlocker(GetHWnd()))) {
...@@ -4526,18 +4531,20 @@ void AwtComponent::FillBackground(HDC hMemoryDC, SIZE &size) ...@@ -4526,18 +4531,20 @@ void AwtComponent::FillBackground(HDC hMemoryDC, SIZE &size)
void AwtComponent::FillAlpha(void *bitmapBits, SIZE &size, BYTE alpha) void AwtComponent::FillAlpha(void *bitmapBits, SIZE &size, BYTE alpha)
{ {
if (bitmapBits) { if (!bitmapBits) {
DWORD* dest = (DWORD*)bitmapBits; return;
//XXX: might be optimized to use one loop (cy*cx -> 0). }
for (int i = 0; i < size.cy; i++ ) {
for (int j = 0; j < size.cx; j++ ) { DWORD* dest = (DWORD*)bitmapBits;
((BYTE*)(dest++))[3] = alpha; //XXX: might be optimized to use one loop (cy*cx -> 0)
} for (int i = 0; i < size.cy; i++ ) {
for (int j = 0; j < size.cx; j++ ) {
((BYTE*)(dest++))[3] = alpha;
} }
} }
} }
jintArray AwtComponent::CreatePrintedPixels(SIZE &loc, SIZE &size) { jintArray AwtComponent::CreatePrintedPixels(SIZE &loc, SIZE &size, int alpha) {
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
if (!::IsWindowVisible(GetHWnd())) { if (!::IsWindowVisible(GetHWnd())) {
...@@ -4549,12 +4556,12 @@ jintArray AwtComponent::CreatePrintedPixels(SIZE &loc, SIZE &size) { ...@@ -4549,12 +4556,12 @@ jintArray AwtComponent::CreatePrintedPixels(SIZE &loc, SIZE &size) {
return NULL; return NULL;
} }
HDC hMemoryDC = ::CreateCompatibleDC(hdc); HDC hMemoryDC = ::CreateCompatibleDC(hdc);
HBITMAP hBitmap = ::CreateCompatibleBitmap(hdc, size.cx, size.cy); void *bitmapBits = NULL;
HBITMAP hBitmap = BitmapUtil::CreateARGBBitmap(size.cx, size.cy, &bitmapBits);
HBITMAP hOldBitmap = (HBITMAP)::SelectObject(hMemoryDC, hBitmap); HBITMAP hOldBitmap = (HBITMAP)::SelectObject(hMemoryDC, hBitmap);
SendMessage(WM_AWT_RELEASEDC, (WPARAM)hdc); SendMessage(WM_AWT_RELEASEDC, (WPARAM)hdc);
RECT eraseR = { 0, 0, size.cx, size.cy }; FillBackground(hMemoryDC, size);
VERIFY(::FillRect(hMemoryDC, &eraseR, GetBackgroundBrush()));
VERIFY(::SetWindowOrgEx(hMemoryDC, loc.cx, loc.cy, NULL)); VERIFY(::SetWindowOrgEx(hMemoryDC, loc.cx, loc.cy, NULL));
...@@ -4562,6 +4569,14 @@ jintArray AwtComponent::CreatePrintedPixels(SIZE &loc, SIZE &size) { ...@@ -4562,6 +4569,14 @@ jintArray AwtComponent::CreatePrintedPixels(SIZE &loc, SIZE &size) {
// above. // above.
SendMessage(WM_PRINT, (WPARAM)hMemoryDC, PRF_CLIENT | PRF_NONCLIENT); SendMessage(WM_PRINT, (WPARAM)hMemoryDC, PRF_CLIENT | PRF_NONCLIENT);
// First make sure the system completed any drawing to the bitmap.
::GdiFlush();
// WM_PRINT does not fill the alpha-channel of the ARGB bitmap
// leaving it equal to zero. Hence we need to fill it manually. Otherwise
// the pixels will be considered transparent when interpreting the data.
FillAlpha(bitmapBits, size, alpha);
::SelectObject(hMemoryDC, hOldBitmap); ::SelectObject(hMemoryDC, hOldBitmap);
BITMAPINFO bmi; BITMAPINFO bmi;
...@@ -5937,10 +5952,6 @@ jintArray AwtComponent::_CreatePrintedPixels(void *param) ...@@ -5937,10 +5952,6 @@ jintArray AwtComponent::_CreatePrintedPixels(void *param)
CreatePrintedPixelsStruct *cpps = (CreatePrintedPixelsStruct *)param; CreatePrintedPixelsStruct *cpps = (CreatePrintedPixelsStruct *)param;
jobject self = cpps->component; jobject self = cpps->component;
jint srcx = cpps->srcx;
jint srcy = cpps->srcy;
jint srcw = cpps->srcw;
jint srch = cpps->srch;
jintArray result = NULL; jintArray result = NULL;
AwtComponent *c = NULL; AwtComponent *c = NULL;
...@@ -5950,12 +5961,7 @@ jintArray AwtComponent::_CreatePrintedPixels(void *param) ...@@ -5950,12 +5961,7 @@ jintArray AwtComponent::_CreatePrintedPixels(void *param)
c = (AwtComponent *)pData; c = (AwtComponent *)pData;
if (::IsWindow(c->GetHWnd())) if (::IsWindow(c->GetHWnd()))
{ {
SIZE loc = { srcx, srcy }; result = (jintArray)c->SendMessage(WM_AWT_CREATE_PRINTED_PIXELS, (WPARAM)cpps, 0);
SIZE size = { srcw, srch };
result = (jintArray)
c->SendMessage(WM_AWT_CREATE_PRINTED_PIXELS, (WPARAM)&loc,
(LPARAM)&size);
} }
ret: ret:
env->DeleteGlobalRef(self); env->DeleteGlobalRef(self);
...@@ -6749,7 +6755,7 @@ Java_sun_awt_windows_WComponentPeer_getTargetGC(JNIEnv* env, jobject theThis) ...@@ -6749,7 +6755,7 @@ Java_sun_awt_windows_WComponentPeer_getTargetGC(JNIEnv* env, jobject theThis)
*/ */
JNIEXPORT jintArray JNICALL JNIEXPORT jintArray JNICALL
Java_sun_awt_windows_WComponentPeer_createPrintedPixels(JNIEnv* env, Java_sun_awt_windows_WComponentPeer_createPrintedPixels(JNIEnv* env,
jobject self, jint srcX, jint srcY, jint srcW, jint srcH) jobject self, jint srcX, jint srcY, jint srcW, jint srcH, jint alpha)
{ {
TRY; TRY;
...@@ -6761,6 +6767,7 @@ Java_sun_awt_windows_WComponentPeer_createPrintedPixels(JNIEnv* env, ...@@ -6761,6 +6767,7 @@ Java_sun_awt_windows_WComponentPeer_createPrintedPixels(JNIEnv* env,
cpps->srcy = srcY; cpps->srcy = srcY;
cpps->srcw = srcW; cpps->srcw = srcW;
cpps->srch = srcH; cpps->srch = srcH;
cpps->alpha = alpha;
jintArray globalRef = (jintArray)AwtToolkit::GetInstance().SyncCall( jintArray globalRef = (jintArray)AwtToolkit::GetInstance().SyncCall(
(void*(*)(void*))AwtComponent::_CreatePrintedPixels, cpps); (void*(*)(void*))AwtComponent::_CreatePrintedPixels, cpps);
......
...@@ -596,7 +596,7 @@ public: ...@@ -596,7 +596,7 @@ public:
void UpdateColorModel(); void UpdateColorModel();
jintArray CreatePrintedPixels(SIZE &loc, SIZE &size); jintArray CreatePrintedPixels(SIZE &loc, SIZE &size, int alpha);
/* /*
* HWND, AwtComponent and Java Peer interaction * HWND, AwtComponent and Java Peer interaction
...@@ -738,7 +738,6 @@ protected: ...@@ -738,7 +738,6 @@ protected:
virtual void SetDragCapture(UINT flags); virtual void SetDragCapture(UINT flags);
virtual void ReleaseDragCapture(UINT flags); virtual void ReleaseDragCapture(UINT flags);
//These functions are overridden in AwtWindow to handle non-opaque windows.
virtual void FillBackground(HDC hMemoryDC, SIZE &size); virtual void FillBackground(HDC hMemoryDC, SIZE &size);
virtual void FillAlpha(void *bitmapBits, SIZE &size, BYTE alpha); virtual void FillAlpha(void *bitmapBits, SIZE &size, BYTE alpha);
......
...@@ -437,9 +437,3 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WRobotPeer_keyRelease( ...@@ -437,9 +437,3 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WRobotPeer_keyRelease(
CATCH_BAD_ALLOC; CATCH_BAD_ALLOC;
} }
JNIEXPORT jint JNICALL Java_sun_awt_windows_WRobotPeer_getNumberOfButtons(
JNIEnv *, jobject self)
{
return GetSystemMetrics(SM_CMOUSEBUTTONS);
}
...@@ -2259,3 +2259,8 @@ extern "C" JNIEXPORT void JNICALL Java_sun_awt_windows_WToolkit_setExtraMouseBut ...@@ -2259,3 +2259,8 @@ extern "C" JNIEXPORT void JNICALL Java_sun_awt_windows_WToolkit_setExtraMouseBut
void AwtToolkit::setExtraMouseButtonsEnabled(BOOL enable) { void AwtToolkit::setExtraMouseButtonsEnabled(BOOL enable) {
m_areExtraMouseButtonsEnabled = enable; m_areExtraMouseButtonsEnabled = enable;
} }
JNIEXPORT jint JNICALL Java_sun_awt_windows_WToolkit_getNumberOfButtonsImpl
(JNIEnv *, jobject self) {
return GetSystemMetrics(SM_CMOUSEBUTTONS);
}
...@@ -464,7 +464,7 @@ void AwtWindow::CreateHWnd(JNIEnv *env, LPCWSTR title, ...@@ -464,7 +464,7 @@ void AwtWindow::CreateHWnd(JNIEnv *env, LPCWSTR title,
size_t length = env->GetStringLength(javaWarningString) + 1; size_t length = env->GetStringLength(javaWarningString) + 1;
warningString = new WCHAR[length]; warningString = new WCHAR[length];
env->GetStringRegion(javaWarningString, 0, env->GetStringRegion(javaWarningString, 0,
static_cast<jsize>(length - 1), warningString); static_cast<jsize>(length - 1), reinterpret_cast<jchar*>(warningString));
warningString[length-1] = L'\0'; warningString[length-1] = L'\0';
env->DeleteLocalRef(javaWarningString); env->DeleteLocalRef(javaWarningString);
...@@ -2651,20 +2651,6 @@ void AwtWindow::UpdateWindow(JNIEnv* env, jintArray data, int width, int height, ...@@ -2651,20 +2651,6 @@ void AwtWindow::UpdateWindow(JNIEnv* env, jintArray data, int width, int height,
::LeaveCriticalSection(&contentBitmapCS); ::LeaveCriticalSection(&contentBitmapCS);
} }
void AwtWindow::FillBackground(HDC hMemoryDC, SIZE &size)
{
if (isOpaque()) {
AwtCanvas::FillBackground(hMemoryDC, size);
}
}
void AwtWindow::FillAlpha(void *bitmapBits, SIZE &size, BYTE alpha)
{
if (isOpaque()) {
AwtCanvas::FillAlpha(bitmapBits, size, alpha);
}
}
/* /*
* Fixed 6353381: it's improved fix for 4792958 * Fixed 6353381: it's improved fix for 4792958
* which was backed-out to avoid 5059656 * which was backed-out to avoid 5059656
......
...@@ -343,11 +343,6 @@ protected: ...@@ -343,11 +343,6 @@ protected:
BOOL m_iconInherited; /* TRUE if icon is inherited from the owner */ BOOL m_iconInherited; /* TRUE if icon is inherited from the owner */
BOOL m_filterFocusAndActivation; /* Used in the WH_CBT hook */ BOOL m_filterFocusAndActivation; /* Used in the WH_CBT hook */
//These are used in AwtComponent::CreatePrintedPixels. They are overridden
//here to handle non-opaque windows.
virtual void FillBackground(HDC hMemoryDC, SIZE &size);
virtual void FillAlpha(void *bitmapBits, SIZE &size, BYTE alpha);
inline BOOL IsUntrusted() { inline BOOL IsUntrusted() {
return warningString != NULL; return warningString != NULL;
} }
......
/* @test
@bug 6683775 6794764
@summary Painting artifacts is seen when panel is made setOpaque(false) for a translucent window
@author Alexander Potochkin
@run main bug6683775
*/
import com.sun.awt.AWTUtilities;
import sun.awt.SunToolkit;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
public class bug6683775 {
public static void main(String[] args) throws Exception {
GraphicsConfiguration gc = getGC();
if (!AWTUtilities.isTranslucencySupported(
AWTUtilities.Translucency.PERPIXEL_TRANSLUCENT)
|| gc == null) {
return;
}
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
final JFrame testFrame = new JFrame(gc);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFrame backgroundFrame = new JFrame("Background frame");
backgroundFrame.setUndecorated(true);
JPanel panel = new JPanel();
panel.setBackground(Color.RED);
backgroundFrame.add(panel);
backgroundFrame.setSize(200, 200);
backgroundFrame.setVisible(true);
testFrame.setUndecorated(true);
JPanel p = new JPanel();
p.setOpaque(false);
testFrame.add(p);
AWTUtilities.setWindowOpaque(testFrame, false);
testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
testFrame.setSize(400, 400);
testFrame.setLocation(0, 0);
testFrame.setVisible(true);
}
});
toolkit.realSync();
//robot.getPixelColor() didn't work right for some reason
BufferedImage capture = robot.createScreenCapture(new Rectangle(100, 100));
int redRGB = Color.RED.getRGB();
if (redRGB != capture.getRGB(10, 10)) {
throw new RuntimeException("Transparent frame is not transparent!");
}
}
private static GraphicsConfiguration getGC() {
GraphicsConfiguration transparencyCapableGC =
GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice().getDefaultConfiguration();
if (!AWTUtilities.isTranslucencyCapable(transparencyCapableGC)) {
transparencyCapableGC = null;
GraphicsEnvironment env =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] devices = env.getScreenDevices();
for (int i = 0; i < devices.length && transparencyCapableGC == null; i++) {
GraphicsConfiguration[] configs = devices[i].getConfigurations();
for (int j = 0; j < configs.length && transparencyCapableGC == null; j++) {
if (AWTUtilities.isTranslucencyCapable(configs[j])) {
transparencyCapableGC = configs[j];
}
}
}
}
return transparencyCapableGC;
}
}
<html>
<body>
<applet code="bug6726866.class" width=400 height=100></applet>
Drag the internal frame inside the green undecorated window,
if you can drag it the test passes, otherwise fails.
</body>
</html>
/* @test
@bug 6726866
@summary Repainting artifacts when resizing or dragging JInternalFrames in non-opaque toplevel
@author Alexander Potochkin
@run applet/manual=yesno bug6726866.html
*/
import javax.swing.*;
import java.awt.*;
import java.lang.reflect.Method;
public class bug6726866 extends JApplet {
public void init() {
JFrame frame = new JFrame("bug6726866");
frame.setUndecorated(true);
setWindowNonOpaque(frame);
JDesktopPane desktop = new JDesktopPane();
desktop.setBackground(Color.GREEN);
JInternalFrame iFrame = new JInternalFrame("Test", true, true, true, true);
iFrame.add(new JLabel("internal Frame"));
iFrame.setBounds(10, 10, 300, 200);
iFrame.setVisible(true);
desktop.add(iFrame);
frame.add(desktop);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 400);
frame.setVisible(true);
frame.toFront();
}
private void setWindowNonOpaque(Window w) {
try {
Class<?> c = Class.forName("com.sun.awt.AWTUtilities");
Method m = c.getMethod("setWindowOpaque", Window.class, boolean.class);
m.invoke(null, w, false);
}
catch (Exception e) {
e.printStackTrace();
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册