Merge
authoryan
Mon, 01 Jun 2009 01:05:22 -0700
changeset 12267da360c3baf6
parent 1204 827a93c4d06a
parent 1225 52493efeb137
child 1233 951ecbad4068
Merge
     1.1 --- a/make/common/Sanity.gmk	Thu May 14 10:58:07 2009 -0700
     1.2 +++ b/make/common/Sanity.gmk	Mon Jun 01 01:05:22 2009 -0700
     1.3 @@ -92,6 +92,7 @@
     1.4      sane-ld_run_path \
     1.5      sane-alt_bootdir \
     1.6      sane-bootdir \
     1.7 +    sane-local-bootdir \
     1.8      sane-alsa-headers \
     1.9      sane-jibx
    1.10  
     2.1 --- a/make/common/shared/Defs-windows.gmk	Thu May 14 10:58:07 2009 -0700
     2.2 +++ b/make/common/shared/Defs-windows.gmk	Mon Jun 01 01:05:22 2009 -0700
     2.3 @@ -431,9 +431,11 @@
     2.4  
     2.5  # _BOOTDIR1: First choice for a Bootstrap JDK, previous released JDK.
     2.6  # _BOOTDIR2: Second choice
     2.7 +# The _BOOTDIR3 is defind optionally.
     2.8  ifndef ALT_BOOTDIR
     2.9    _BOOTDIR1  =$(_system_drive)/jdk$(PREVIOUS_JDK_VERSION)
    2.10    _BOOTDIR2  =$(USRJDKINSTANCES_PATH)/jdk$(PREVIOUS_JDK_VERSION)
    2.11 +  _BOOTDIR3  =$(SLASH_JAVA)/re/jdk/$(PREVIOUS_JDK_VERSION)/archive/fcs/binaries/$(PLATFORM)-$(ARCH)
    2.12  endif
    2.13  
    2.14  # 32 bit always needs 2 runtimes, 64 bit usually does too
     3.1 --- a/make/common/shared/Defs.gmk	Thu May 14 10:58:07 2009 -0700
     3.2 +++ b/make/common/shared/Defs.gmk	Mon Jun 01 01:05:22 2009 -0700
     3.3 @@ -94,6 +94,21 @@
     3.4    fi)
     3.5  endef
     3.6  
     3.7 +# Select a directory if it exists, or the alternate 2, or the alternate 3, or the alternate 4
     3.8 +define DirExists4
     3.9 +$(shell \
    3.10 +  if [ -d "$1" ]; then  \
    3.11 +    echo "$1"; \
    3.12 +  elif [ -d "$2" ]; then \
    3.13 +    echo "$2"; \
    3.14 +  elif [ -d "$3" ]; then \
    3.15 +    echo "$3"; \
    3.16 +  else \
    3.17 +    echo "$4"; \
    3.18 +  fi)
    3.19 +endef
    3.20 +
    3.21 +
    3.22  # Select a writable directory if it exists and is writable, or the alternate
    3.23  define WriteDirExists
    3.24  $(shell \
    3.25 @@ -356,10 +371,15 @@
    3.26  
    3.27  # BOOTDIR: Bootstrap JDK, previous released JDK.
    3.28  #   _BOOTDIR1 and _BOOTDIR2 picked by platform
    3.29 +#   Platform may optionally define _BOOTDIR3 as well.
    3.30  ifdef ALT_BOOTDIR
    3.31    BOOTDIR =$(ALT_BOOTDIR)
    3.32  else
    3.33 -  BOOTDIR  :=$(call DirExists,$(_BOOTDIR1),$(_BOOTDIR2),/NO_BOOTDIR)
    3.34 +  ifdef _BOOTDIR3
    3.35 +    BOOTDIR  :=$(call DirExists4,$(_BOOTDIR1),$(_BOOTDIR2),$(_BOOTDIR3),/NO_BOOTDIR)
    3.36 +  else
    3.37 +    BOOTDIR  :=$(call DirExists,$(_BOOTDIR1),$(_BOOTDIR2),/NO_BOOTDIR)
    3.38 +  endif
    3.39  endif
    3.40  export BOOTDIR
    3.41  BOOTDIR:=$(call AltCheckSpaces,BOOTDIR)
     4.1 --- a/make/common/shared/Sanity.gmk	Thu May 14 10:58:07 2009 -0700
     4.2 +++ b/make/common/shared/Sanity.gmk	Mon Jun 01 01:05:22 2009 -0700
     4.3 @@ -194,7 +194,8 @@
     4.4  	sane-outputdir \
     4.5  	sane-alt_bootdir \
     4.6  	sane-bootdir \
     4.7 -        sane-cups \
     4.8 +	sane-local-bootdir \
     4.9 +	sane-cups \
    4.10  	sane-devtools_path \
    4.11  	sane-compiler_path \
    4.12  	sane-unixcommand_path \
    4.13 @@ -767,6 +768,23 @@
    4.14  	fi
    4.15  
    4.16  ######################################################
    4.17 +# BOOTDIR is recommended to reside on a local drive
    4.18 +######################################################
    4.19 +sane-local-bootdir:
    4.20 +ifeq ($(PLATFORM), windows)
    4.21 +	@if [ `$(ECHO) $(BOOTDIR) | $(EGREP) -ci '^J:'` -ne 0 ]; then \
    4.22 +	  $(ECHO) "WARNING: Your BOOTDIR is located on the J: drive. Often the J:\n" \
    4.23 +	    "        drive is mapped over a network. Using a mapped drive for\n" \
    4.24 +	    "        the BOOTDIR may significantly slow down the build process.\n" \
    4.25 +	    "        You may want to consider using the ALT_BOOTDIR variable\n" \
    4.26 +	    "        to point the build to another location for the BOOTDIR instead. \n" \
    4.27 +	    "        Your current BOOTDIR is:\n" \
    4.28 +	    "           $(BOOTDIR) \n" \
    4.29 +	    "" >> $(WARNING_FILE) ; \
    4.30 +	fi
    4.31 +endif
    4.32 +
    4.33 +######################################################
    4.34  # CACERTS_FILE must be absoulte path and readable
    4.35  ######################################################
    4.36  sane-cacerts:
     5.1 --- a/make/sun/xawt/mapfile-vers	Thu May 14 10:58:07 2009 -0700
     5.2 +++ b/make/sun/xawt/mapfile-vers	Mon Jun 01 01:05:22 2009 -0700
     5.3 @@ -128,6 +128,7 @@
     5.4          Java_sun_awt_X11_XlibWrapper_SetToolkitErrorHandler;
     5.5          Java_sun_awt_X11_XlibWrapper_XSetErrorHandler;
     5.6          Java_sun_awt_X11_XlibWrapper_CallErrorHandler;
     5.7 +        Java_sun_awt_X11_XlibWrapper_PrintXErrorEvent;
     5.8          Java_sun_awt_X11_XlibWrapper_XInternAtoms;
     5.9          Java_sun_awt_X11_XlibWrapper_XChangeWindowAttributes;
    5.10          Java_sun_awt_X11_XlibWrapper_XDeleteProperty;
    5.11 @@ -154,7 +155,7 @@
    5.12          Java_sun_awt_X11_XRobotPeer_mouseReleaseImpl;
    5.13          Java_sun_awt_X11_XRobotPeer_mouseWheelImpl;
    5.14          Java_sun_awt_X11_XRobotPeer_setup;
    5.15 -        Java_sun_awt_X11_XRobotPeer_getNumberOfButtonsImpl;
    5.16 +        Java_sun_awt_X11_XToolkit_getNumberOfButtonsImpl;
    5.17          Java_java_awt_Component_initIDs;
    5.18          Java_java_awt_Container_initIDs;
    5.19          Java_java_awt_Button_initIDs;
    5.20 @@ -276,7 +277,6 @@
    5.21          Java_sun_awt_X11_XToolkit_getDefaultXColormap;
    5.22          Java_sun_awt_X11_XToolkit_getDefaultScreenData;
    5.23          Java_sun_awt_X11_XToolkit_getEnv;
    5.24 -        Java_sun_awt_X11_XToolkit_setNoisyXErrorHandler;
    5.25          Java_sun_awt_X11_XlibWrapper_XCreateBitmapFromData;
    5.26          Java_sun_awt_X11_XlibWrapper_XFreePixmap;
    5.27          Java_sun_awt_X11_XlibWrapper_XAllocColor;
     6.1 --- a/src/share/classes/java/awt/Component.java	Thu May 14 10:58:07 2009 -0700
     6.2 +++ b/src/share/classes/java/awt/Component.java	Mon Jun 01 01:05:22 2009 -0700
     6.3 @@ -1038,13 +1038,23 @@
     6.4  
     6.5      void setGraphicsConfiguration(GraphicsConfiguration gc) {
     6.6          synchronized(getTreeLock()) {
     6.7 -            graphicsConfig = gc;
     6.8 -
     6.9 -            ComponentPeer peer = getPeer();
    6.10 -            if (peer != null) {
    6.11 -                peer.updateGraphicsData(gc);
    6.12 -            }
    6.13 -        }
    6.14 +            if (updateGraphicsData(gc)) {
    6.15 +                removeNotify();
    6.16 +                addNotify();
    6.17 +            }
    6.18 +        }
    6.19 +    }
    6.20 +
    6.21 +    boolean updateGraphicsData(GraphicsConfiguration gc) {
    6.22 +        checkTreeLock();
    6.23 +
    6.24 +        graphicsConfig = gc;
    6.25 +
    6.26 +        ComponentPeer peer = getPeer();
    6.27 +        if (peer != null) {
    6.28 +            return peer.updateGraphicsData(gc);
    6.29 +        }
    6.30 +        return false;
    6.31      }
    6.32  
    6.33      /**
     7.1 --- a/src/share/classes/java/awt/Container.java	Thu May 14 10:58:07 2009 -0700
     7.2 +++ b/src/share/classes/java/awt/Container.java	Mon Jun 01 01:05:22 2009 -0700
     7.3 @@ -1113,16 +1113,17 @@
     7.4      }
     7.5  
     7.6      @Override
     7.7 -    void setGraphicsConfiguration(GraphicsConfiguration gc) {
     7.8 -        synchronized (getTreeLock()) {
     7.9 -            super.setGraphicsConfiguration(gc);
    7.10 -
    7.11 -            for (Component comp : component) {
    7.12 -                if (comp != null) {
    7.13 -                    comp.setGraphicsConfiguration(gc);
    7.14 -                }
    7.15 +    boolean updateGraphicsData(GraphicsConfiguration gc) {
    7.16 +        checkTreeLock();
    7.17 +
    7.18 +        boolean ret = super.updateGraphicsData(gc);
    7.19 +
    7.20 +        for (Component comp : component) {
    7.21 +            if (comp != null) {
    7.22 +                ret |= comp.updateGraphicsData(gc);
    7.23              }
    7.24          }
    7.25 +        return ret;
    7.26      }
    7.27  
    7.28      /**
     8.1 --- a/src/share/classes/java/awt/GraphicsConfiguration.java	Thu May 14 10:58:07 2009 -0700
     8.2 +++ b/src/share/classes/java/awt/GraphicsConfiguration.java	Mon Jun 01 01:05:22 2009 -0700
     8.3 @@ -436,7 +436,7 @@
     8.4      }
     8.5  
     8.6      /**
     8.7 -     * Returns whether this GraphicsConfiguration supports
     8.8 +     * Returns whether this {@code GraphicsConfiguration} supports
     8.9       * the {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT
    8.10       * PERPIXEL_TRANSLUCENT} kind of translucency.
    8.11       *
     9.1 --- a/src/share/classes/java/awt/GraphicsDevice.java	Thu May 14 10:58:07 2009 -0700
     9.2 +++ b/src/share/classes/java/awt/GraphicsDevice.java	Mon Jun 01 01:05:22 2009 -0700
     9.3 @@ -246,7 +246,7 @@
     9.4       * Simulated full-screen mode resizes
     9.5       * the window to the size of the screen and positions it at (0,0).
     9.6       * <p>
     9.7 -     * When entering full-screen mode, if the window to be used as the
     9.8 +     * When entering full-screen mode, if the window to be used as a
     9.9       * full-screen window is not visible, this method will make it visible.
    9.10       * It will remain visible when returning to windowed mode.
    9.11       * <p>
    9.12 @@ -261,9 +261,9 @@
    9.13       *
    9.14       * @param w a window to use as the full-screen window; {@code null}
    9.15       * if returning to windowed mode.  Some platforms expect the
    9.16 -     * fullscreen window to be a top-level component (i.e., a Frame);
    9.17 -     * therefore it is preferable to use a Frame here rather than a
    9.18 -     * Window.
    9.19 +     * fullscreen window to be a top-level component (i.e., a {@code Frame});
    9.20 +     * therefore it is preferable to use a {@code Frame} here rather than a
    9.21 +     * {@code Window}.
    9.22       *
    9.23       * @see #isFullScreenSupported
    9.24       * @see #getFullScreenWindow
    10.1 --- a/src/share/classes/java/awt/Robot.java	Thu May 14 10:58:07 2009 -0700
    10.2 +++ b/src/share/classes/java/awt/Robot.java	Mon Jun 01 01:05:22 2009 -0700
    10.3 @@ -96,9 +96,13 @@
    10.4          init(GraphicsEnvironment.getLocalGraphicsEnvironment()
    10.5              .getDefaultScreenDevice());
    10.6          int tmpMask = 0;
    10.7 +
    10.8          if (Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){
    10.9 -            for (int i = 0; i < peer.getNumberOfButtons(); i++){
   10.10 -                tmpMask |= InputEvent.getMaskForButton(i+1);
   10.11 +            if (Toolkit.getDefaultToolkit() instanceof SunToolkit) {
   10.12 +                final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons();
   10.13 +                for (int i = 0; i < buttonsNumber; i++){
   10.14 +                    tmpMask |= InputEvent.getMaskForButton(i+1);
   10.15 +                }
   10.16              }
   10.17          }
   10.18          tmpMask |= InputEvent.BUTTON1_MASK|
    11.1 --- a/src/share/classes/java/awt/Window.java	Thu May 14 10:58:07 2009 -0700
    11.2 +++ b/src/share/classes/java/awt/Window.java	Mon Jun 01 01:05:22 2009 -0700
    11.3 @@ -296,7 +296,7 @@
    11.4      transient boolean isInShow = false;
    11.5  
    11.6      /*
    11.7 -     * Opacity level of the window
    11.8 +     * The opacity level of the window
    11.9       *
   11.10       * @serial
   11.11       * @see #setOpacity(float)
   11.12 @@ -306,7 +306,7 @@
   11.13      private float opacity = 1.0f;
   11.14  
   11.15      /*
   11.16 -     * The shape assigned to this window. This field is set to null if
   11.17 +     * The shape assigned to this window. This field is set to {@code null} if
   11.18       * no shape is set (rectangular window).
   11.19       *
   11.20       * @serial
   11.21 @@ -3592,10 +3592,10 @@
   11.22      @Override
   11.23      public void setBackground(Color bgColor) {
   11.24          Color oldBg = getBackground();
   11.25 +        super.setBackground(bgColor);
   11.26          if (oldBg != null && oldBg.equals(bgColor)) {
   11.27              return;
   11.28          }
   11.29 -        super.setBackground(bgColor);
   11.30          int oldAlpha = oldBg != null ? oldBg.getAlpha() : 255;
   11.31          int alpha = bgColor.getAlpha();
   11.32          if ((oldAlpha == 255) && (alpha < 255)) { // non-opaque window
   11.33 @@ -3623,16 +3623,37 @@
   11.34          }
   11.35      }
   11.36  
   11.37 -    private void updateWindow(BufferedImage backBuffer) {
   11.38 +    private void updateWindow() {
   11.39          synchronized (getTreeLock()) {
   11.40              WindowPeer peer = (WindowPeer)getPeer();
   11.41              if (peer != null) {
   11.42 -                peer.updateWindow(backBuffer);
   11.43 +                peer.updateWindow();
   11.44              }
   11.45          }
   11.46      }
   11.47  
   11.48 -    private static final Color TRANSPARENT_BACKGROUND_COLOR = new Color(0, 0, 0, 0);
   11.49 +    /**
   11.50 +     * {@inheritDoc}
   11.51 +     *
   11.52 +     * @since 1.7
   11.53 +     */
   11.54 +    @Override
   11.55 +    public void paint(Graphics g) {
   11.56 +        Color bgColor = getBackground();
   11.57 +        if ((bgColor != null) && (bgColor.getAlpha() < 255)) {
   11.58 +            Graphics gg = g.create();
   11.59 +            try {
   11.60 +                if (gg instanceof Graphics2D) {
   11.61 +                    gg.setColor(bgColor);
   11.62 +                    ((Graphics2D)gg).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC));
   11.63 +                    gg.fillRect(0, 0, getWidth(), getHeight());
   11.64 +                }
   11.65 +            } finally {
   11.66 +                gg.dispose();
   11.67 +            }
   11.68 +        }
   11.69 +        super.paint(g);
   11.70 +    }
   11.71  
   11.72      private static void setLayersOpaque(Component component, boolean isOpaque) {
   11.73          // Shouldn't use instanceof to avoid loading Swing classes
   11.74 @@ -3644,18 +3665,10 @@
   11.75              Container c = root.getContentPane();
   11.76              javax.swing.JComponent content =
   11.77                  (c instanceof javax.swing.JComponent) ? (javax.swing.JComponent)c : null;
   11.78 -            javax.swing.JComponent gp =
   11.79 -                (rpc.getGlassPane() instanceof javax.swing.JComponent) ?
   11.80 -                (javax.swing.JComponent)rpc.getGlassPane() : null;
   11.81 -            if (gp != null) {
   11.82 -                gp.setDoubleBuffered(isOpaque);
   11.83 -            }
   11.84              lp.setOpaque(isOpaque);
   11.85              root.setOpaque(isOpaque);
   11.86 -            root.setDoubleBuffered(isOpaque);
   11.87              if (content != null) {
   11.88                  content.setOpaque(isOpaque);
   11.89 -                content.setDoubleBuffered(isOpaque);
   11.90  
   11.91                  // Iterate down one level to see whether we have a JApplet
   11.92                  // (which is also a RootPaneContainer) which requires processing
   11.93 @@ -3748,8 +3761,8 @@
   11.94                  window.setBackground(new Color(bg.getRed(), bg.getGreen(), bg.getBlue(),
   11.95                                                 opaque ? 255 : 0));
   11.96              }
   11.97 -            public void updateWindow(Window window, BufferedImage backBuffer) {
   11.98 -                window.updateWindow(backBuffer);
   11.99 +            public void updateWindow(Window window) {
  11.100 +                window.updateWindow();
  11.101              }
  11.102  
  11.103              public Dimension getSecurityWarningSize(Window window) {
    12.1 --- a/src/share/classes/java/awt/event/InputEvent.java	Thu May 14 10:58:07 2009 -0700
    12.2 +++ b/src/share/classes/java/awt/event/InputEvent.java	Mon Jun 01 01:05:22 2009 -0700
    12.3 @@ -157,6 +157,8 @@
    12.4      /**
    12.5       * An array of extended modifiers for additional buttons.
    12.6       * @see getButtonDownMasks
    12.7 +     * There are twenty buttons fit into 4byte space.
    12.8 +     * one more bit is reserved for FIRST_HIGH_BIT.
    12.9       * @since 7.0
   12.10       */
   12.11      private static final int [] BUTTON_DOWN_MASK = new int [] { BUTTON1_DOWN_MASK,
   12.12 @@ -169,7 +171,16 @@
   12.13                                                                 1<<18,
   12.14                                                                 1<<19,
   12.15                                                                 1<<20,
   12.16 -                                                               1<<21 };
   12.17 +                                                               1<<21,
   12.18 +                                                               1<<22,
   12.19 +                                                               1<<23,
   12.20 +                                                               1<<24,
   12.21 +                                                               1<<25,
   12.22 +                                                               1<<26,
   12.23 +                                                               1<<27,
   12.24 +                                                               1<<28,
   12.25 +                                                               1<<29,
   12.26 +                                                               1<<30};
   12.27  
   12.28      /**
   12.29       * A method to access an array of extended modifiers for additional buttons.
   12.30 @@ -240,7 +251,7 @@
   12.31      // in fact, it is undesirable to add modifier bits
   12.32      // to the same field as this may break applications
   12.33      // see bug# 5066958
   12.34 -    static final int FIRST_HIGH_BIT = 1 << 22;
   12.35 +    static final int FIRST_HIGH_BIT = 1 << 31;
   12.36  
   12.37      static final int JDK_1_3_MODIFIERS = SHIFT_DOWN_MASK - 1;
   12.38      static final int HIGH_MODIFIERS = ~( FIRST_HIGH_BIT - 1 );
    13.1 --- a/src/share/classes/java/awt/event/MouseEvent.java	Thu May 14 10:58:07 2009 -0700
    13.2 +++ b/src/share/classes/java/awt/event/MouseEvent.java	Mon Jun 01 01:05:22 2009 -0700
    13.3 @@ -33,6 +33,7 @@
    13.4  import java.io.ObjectInputStream;
    13.5  import java.awt.IllegalComponentStateException;
    13.6  import java.awt.MouseInfo;
    13.7 +import sun.awt.SunToolkit;
    13.8  
    13.9  /**
   13.10   * An event which indicates that a mouse action occurred in a component.
   13.11 @@ -379,12 +380,25 @@
   13.12       */
   13.13      private static final long serialVersionUID = -991214153494842848L;
   13.14  
   13.15 +    /**
   13.16 +     * A number of buttons available on the mouse at the {@code Toolkit} machinery startup.
   13.17 +     */
   13.18 +    private static int cachedNumberOfButtons;
   13.19 +
   13.20      static {
   13.21          /* ensure that the necessary native libraries are loaded */
   13.22          NativeLibLoader.loadLibraries();
   13.23          if (!GraphicsEnvironment.isHeadless()) {
   13.24              initIDs();
   13.25          }
   13.26 +        final Toolkit tk = Toolkit.getDefaultToolkit();
   13.27 +        if (tk instanceof SunToolkit) {
   13.28 +            cachedNumberOfButtons = ((SunToolkit)tk).getNumberOfButtons();
   13.29 +        } else {
   13.30 +            //It's expected that some toolkits (Headless,
   13.31 +            //whatever besides SunToolkit) could also operate.
   13.32 +            cachedNumberOfButtons = 3;
   13.33 +        }
   13.34      }
   13.35  
   13.36      /**
   13.37 @@ -412,15 +426,6 @@
   13.38      }
   13.39  
   13.40      /**
   13.41 -     * A number of buttons available on the mouse at the {@code Toolkit} machinery startup.
   13.42 -     */
   13.43 -    private static int cachedNumberOfButtons;
   13.44 -
   13.45 -    static {
   13.46 -        cachedNumberOfButtons = MouseInfo.getNumberOfButtons();
   13.47 -    }
   13.48 -
   13.49 -    /**
   13.50       * Returns the absolute horizontal x position of the event.
   13.51       * In a virtual device multi-screen environment in which the
   13.52       * desktop area could span multiple physical screen devices,
   13.53 @@ -735,7 +740,6 @@
   13.54          if (button < NOBUTTON){
   13.55              throw new IllegalArgumentException("Invalid button value :" + button);
   13.56          }
   13.57 -        //TODO: initialize MouseInfo.cachedNumber on toolkit creation.
   13.58          if (button > BUTTON3) {
   13.59              if (!Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){
   13.60                  throw new IllegalArgumentException("Extra mouse events are disabled " + button);
    14.1 --- a/src/share/classes/java/awt/peer/ComponentPeer.java	Thu May 14 10:58:07 2009 -0700
    14.2 +++ b/src/share/classes/java/awt/peer/ComponentPeer.java	Mon Jun 01 01:05:22 2009 -0700
    14.3 @@ -548,7 +548,8 @@
    14.4      /**
    14.5       * Updates internal data structures related to the component's GC.
    14.6       *
    14.7 +     * @return if the peer needs to be recreated for the changes to take effect
    14.8       * @since 1.7
    14.9       */
   14.10 -    void updateGraphicsData(GraphicsConfiguration gc);
   14.11 +    boolean updateGraphicsData(GraphicsConfiguration gc);
   14.12  }
    15.1 --- a/src/share/classes/java/awt/peer/RobotPeer.java	Thu May 14 10:58:07 2009 -0700
    15.2 +++ b/src/share/classes/java/awt/peer/RobotPeer.java	Mon Jun 01 01:05:22 2009 -0700
    15.3 @@ -121,11 +121,4 @@
    15.4       * Disposes the robot peer when it is not needed anymore.
    15.5       */
    15.6      void dispose();
    15.7 -
    15.8 -    /**
    15.9 -     * Returns the number of buttons that the robot simulates.
   15.10 -     *
   15.11 -     * @return the number of buttons that the robot simulates
   15.12 -     */
   15.13 -    int getNumberOfButtons();
   15.14  }
    16.1 --- a/src/share/classes/java/awt/peer/WindowPeer.java	Thu May 14 10:58:07 2009 -0700
    16.2 +++ b/src/share/classes/java/awt/peer/WindowPeer.java	Mon Jun 01 01:05:22 2009 -0700
    16.3 @@ -110,12 +110,11 @@
    16.4      void setOpaque(boolean isOpaque);
    16.5  
    16.6      /**
    16.7 -     * Updates the native part of non-opaque window using
    16.8 -     * the given image with color+alpha values for each pixel.
    16.9 +     * Updates the native part of non-opaque window.
   16.10       *
   16.11       * @see Window#setBackground(Color)
   16.12       */
   16.13 -    void updateWindow(BufferedImage backBuffer);
   16.14 +    void updateWindow();
   16.15  
   16.16      /**
   16.17       * Instructs the peer to update the position of the security warning.
    17.1 --- a/src/share/classes/javax/swing/DefaultDesktopManager.java	Thu May 14 10:58:07 2009 -0700
    17.2 +++ b/src/share/classes/javax/swing/DefaultDesktopManager.java	Mon Jun 01 01:05:22 2009 -0700
    17.3 @@ -34,6 +34,9 @@
    17.4  import java.awt.event.ComponentAdapter;
    17.5  import java.awt.event.ComponentEvent;
    17.6  
    17.7 +import sun.awt.AWTAccessor;
    17.8 +import sun.awt.SunToolkit;
    17.9 +
   17.10  /** This is an implementation of the <code>DesktopManager</code>.
   17.11    * It currently implements the basic behaviors for managing
   17.12    * <code>JInternalFrame</code>s in an arbitrary parent.
   17.13 @@ -361,7 +364,7 @@
   17.14                g.dispose();
   17.15              }
   17.16          } else if (dragMode == FASTER_DRAG_MODE) {
   17.17 -          dragFrameFaster(f, newX, newY);
   17.18 +            dragFrameFaster(f, newX, newY);
   17.19          } else {
   17.20              setBoundsForFrame(f, newX, newY, f.getWidth(), f.getHeight());
   17.21          }
   17.22 @@ -634,13 +637,8 @@
   17.23  
   17.24        boolean floaterCollision = isFloaterCollision(previousBounds, currentBounds);
   17.25  
   17.26 -    // System.out.println(previousBounds);
   17.27        JComponent parent = (JComponent)f.getParent();
   17.28        Rectangle visBounds = previousBounds.intersection(desktopBounds);
   17.29 -    //  System.out.println(previousBounds);
   17.30 -
   17.31 -
   17.32 -     // System.out.println(visBounds);
   17.33  
   17.34        RepaintManager currentManager = RepaintManager.currentManager(f);
   17.35  
   17.36 @@ -682,7 +680,6 @@
   17.37            } else {
   17.38                dirtyRects = new Rectangle[1];
   17.39                dirtyRects[0] = previousBounds;
   17.40 -              //  System.out.println("no intersection");
   17.41            };
   17.42  
   17.43            // Fix the damage
   17.44 @@ -701,14 +698,22 @@
   17.45  
   17.46                    parent.paintImmediately(dirtyRects[i]);
   17.47                    ((JInternalFrame)f).isDragging = true;
   17.48 -
   17.49 -                  // System.out.println(dirtyRects[i]);
   17.50                }
   17.51  
   17.52            }
   17.53        } finally {
   17.54            currentManager.endPaint();
   17.55        }
   17.56 +
   17.57 +      // update window if it's non-opaque
   17.58 +      Window topLevel = SwingUtilities.getWindowAncestor(f);
   17.59 +      Toolkit tk = Toolkit.getDefaultToolkit();
   17.60 +      if (!AWTAccessor.getWindowAccessor().isOpaque(topLevel) &&
   17.61 +          (tk instanceof SunToolkit) &&
   17.62 +          ((SunToolkit)tk).needUpdateWindow())
   17.63 +      {
   17.64 +          AWTAccessor.getWindowAccessor().updateWindow(topLevel);
   17.65 +      }
   17.66     }
   17.67  
   17.68     private boolean isFloaterCollision(Rectangle moveFrom, Rectangle moveTo) {
    18.1 --- a/src/share/classes/javax/swing/JComponent.java	Thu May 14 10:58:07 2009 -0700
    18.2 +++ b/src/share/classes/javax/swing/JComponent.java	Mon Jun 01 01:05:22 2009 -0700
    18.3 @@ -1021,8 +1021,10 @@
    18.4  
    18.5              int bw,bh;
    18.6              boolean printing = getFlag(IS_PRINTING);
    18.7 -            if(!printing && repaintManager.isDoubleBufferingEnabled() &&
    18.8 -               !getFlag(ANCESTOR_USING_BUFFER) && isDoubleBuffered()) {
    18.9 +            if (!printing && repaintManager.isDoubleBufferingEnabled() &&
   18.10 +                !getFlag(ANCESTOR_USING_BUFFER) && isDoubleBuffered() &&
   18.11 +                (getFlag(IS_REPAINTING) || repaintManager.isPainting()))
   18.12 +            {
   18.13                  repaintManager.beginPaint();
   18.14                  try {
   18.15                      repaintManager.paint(this, this, co, clipX, clipY, clipW,
    19.1 --- a/src/share/classes/javax/swing/RepaintManager.java	Thu May 14 10:58:07 2009 -0700
    19.2 +++ b/src/share/classes/javax/swing/RepaintManager.java	Mon Jun 01 01:05:22 2009 -0700
    19.3 @@ -43,7 +43,6 @@
    19.4  
    19.5  import com.sun.java.swing.SwingUtilities3;
    19.6  
    19.7 -
    19.8  /**
    19.9   * This class manages repaint requests, allowing the number
   19.10   * of repaints to be minimized, for example by collapsing multiple
   19.11 @@ -717,14 +716,12 @@
   19.12          }
   19.13      }
   19.14  
   19.15 -    private Map<Component,Rectangle>
   19.16 -        updateWindows(Map<Component,Rectangle> dirtyComponents)
   19.17 -    {
   19.18 +    private void updateWindows(Map<Component,Rectangle> dirtyComponents) {
   19.19          Toolkit toolkit = Toolkit.getDefaultToolkit();
   19.20          if (!(toolkit instanceof SunToolkit &&
   19.21                ((SunToolkit)toolkit).needUpdateWindow()))
   19.22          {
   19.23 -            return dirtyComponents;
   19.24 +            return;
   19.25          }
   19.26  
   19.27          Set<Window> windows = new HashSet<Window>();
   19.28 @@ -734,25 +731,20 @@
   19.29              Window window = dirty instanceof Window ?
   19.30                  (Window)dirty :
   19.31                  SwingUtilities.getWindowAncestor(dirty);
   19.32 -
   19.33              if (window != null &&
   19.34                  !AWTAccessor.getWindowAccessor().isOpaque(window))
   19.35              {
   19.36 -                // if this component's toplevel is perpixel translucent, it will
   19.37 -                // be repainted below
   19.38 -                it.remove();
   19.39 -                // add to the set of windows to update (so that we don't update
   19.40 -                // the window many times for each component to be repainted that
   19.41 -                // belongs to this window)
   19.42                  windows.add(window);
   19.43              }
   19.44          }
   19.45  
   19.46          for (Window window : windows) {
   19.47 -            AWTAccessor.getWindowAccessor().updateWindow(window, null);
   19.48 +            AWTAccessor.getWindowAccessor().updateWindow(window);
   19.49          }
   19.50 +    }
   19.51  
   19.52 -        return dirtyComponents;
   19.53 +    boolean isPainting() {
   19.54 +        return painting;
   19.55      }
   19.56  
   19.57      /**
   19.58 @@ -788,10 +780,6 @@
   19.59          int localBoundsW;
   19.60          Enumeration keys;
   19.61  
   19.62 -        // the components belonging to perpixel-translucent windows will be
   19.63 -        // removed from the list
   19.64 -        tmpDirtyComponents = updateWindows(tmpDirtyComponents);
   19.65 -
   19.66          roots = new ArrayList<Component>(count);
   19.67  
   19.68          for (Component dirty : tmpDirtyComponents.keySet()) {
   19.69 @@ -799,13 +787,11 @@
   19.70          }
   19.71  
   19.72          count = roots.size();
   19.73 -        //        System.out.println("roots size is " + count);
   19.74          painting = true;
   19.75          try {
   19.76              for(i=0 ; i < count ; i++) {
   19.77                  dirtyComponent = roots.get(i);
   19.78                  rect = tmpDirtyComponents.get(dirtyComponent);
   19.79 -                //            System.out.println("Should refresh :" + rect);
   19.80                  localBoundsH = dirtyComponent.getHeight();
   19.81                  localBoundsW = dirtyComponent.getWidth();
   19.82  
   19.83 @@ -848,6 +834,9 @@
   19.84          } finally {
   19.85              painting = false;
   19.86          }
   19.87 +
   19.88 +        updateWindows(tmpDirtyComponents);
   19.89 +
   19.90          tmpDirtyComponents.clear();
   19.91      }
   19.92  
   19.93 @@ -1004,6 +993,16 @@
   19.94              return delegate.getVolatileOffscreenBuffer(c, proposedWidth,
   19.95                                                          proposedHeight);
   19.96          }
   19.97 +
   19.98 +        // If the window is non-opaque, it's double-buffered at peer's level
   19.99 +        Window w = (c instanceof Window) ? (Window)c : SwingUtilities.getWindowAncestor(c);
  19.100 +        if (!AWTAccessor.getWindowAccessor().isOpaque(w)) {
  19.101 +            Toolkit tk = Toolkit.getDefaultToolkit();
  19.102 +            if ((tk instanceof SunToolkit) && (((SunToolkit)tk).needUpdateWindow())) {
  19.103 +                return null;
  19.104 +            }
  19.105 +        }
  19.106 +
  19.107          GraphicsConfiguration config = c.getGraphicsConfiguration();
  19.108          if (config == null) {
  19.109              config = GraphicsEnvironment.getLocalGraphicsEnvironment().
  19.110 @@ -1031,6 +1030,15 @@
  19.111          DoubleBufferInfo doubleBuffer;
  19.112          int width, height;
  19.113  
  19.114 +        // If the window is non-opaque, it's double-buffered at peer's level
  19.115 +        Window w = (c instanceof Window) ? (Window)c : SwingUtilities.getWindowAncestor(c);
  19.116 +        if (!AWTAccessor.getWindowAccessor().isOpaque(w)) {
  19.117 +            Toolkit tk = Toolkit.getDefaultToolkit();
  19.118 +            if ((tk instanceof SunToolkit) && (((SunToolkit)tk).needUpdateWindow())) {
  19.119 +                return null;
  19.120 +            }
  19.121 +        }
  19.122 +
  19.123          if (standardDoubleBuffer == null) {
  19.124              standardDoubleBuffer = new DoubleBufferInfo();
  19.125          }
    20.1 --- a/src/share/classes/sun/awt/AWTAccessor.java	Thu May 14 10:58:07 2009 -0700
    20.2 +++ b/src/share/classes/sun/awt/AWTAccessor.java	Mon Jun 01 01:05:22 2009 -0700
    20.3 @@ -132,7 +132,7 @@
    20.4          /*
    20.5           * Update the image of a non-opaque (translucent) window.
    20.6           */
    20.7 -        void updateWindow(Window window, BufferedImage backBuffer);
    20.8 +        void updateWindow(Window window);
    20.9  
   20.10          /** Get the size of the security warning.
   20.11           */
    21.1 --- a/src/share/classes/sun/awt/EmbeddedFrame.java	Thu May 14 10:58:07 2009 -0700
    21.2 +++ b/src/share/classes/sun/awt/EmbeddedFrame.java	Mon Jun 01 01:05:22 2009 -0700
    21.3 @@ -592,8 +592,9 @@
    21.4          public void setOpaque(boolean isOpaque) {
    21.5          }
    21.6  
    21.7 -        public void updateWindow(BufferedImage bi) {
    21.8 +        public void updateWindow() {
    21.9          }
   21.10 +
   21.11          public void repositionSecurityWarning() {
   21.12          }
   21.13       }
    22.1 --- a/src/share/classes/sun/awt/HeadlessToolkit.java	Thu May 14 10:58:07 2009 -0700
    22.2 +++ b/src/share/classes/sun/awt/HeadlessToolkit.java	Mon Jun 01 01:05:22 2009 -0700
    22.3 @@ -179,9 +179,15 @@
    22.4          throw new HeadlessException();
    22.5      }
    22.6  
    22.7 -    public  KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager)
    22.8 -        throws HeadlessException {
    22.9 -        throw new HeadlessException();
   22.10 +    public KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager) {
   22.11 +        // See 6833019.
   22.12 +        return
   22.13 +            new KeyboardFocusManagerPeer() {
   22.14 +                public Window getCurrentFocusedWindow() { return null; }
   22.15 +                public void setCurrentFocusOwner(Component comp) {}
   22.16 +                public Component getCurrentFocusOwner() { return null; }
   22.17 +                public void clearGlobalFocusOwner(Window activeWindow) {}
   22.18 +            };
   22.19      }
   22.20  
   22.21      public TrayIconPeer createTrayIcon(TrayIcon target)
    23.1 --- a/src/share/classes/sun/awt/NullComponentPeer.java	Thu May 14 10:58:07 2009 -0700
    23.2 +++ b/src/share/classes/sun/awt/NullComponentPeer.java	Mon Jun 01 01:05:22 2009 -0700
    23.3 @@ -300,7 +300,9 @@
    23.4      public void setZOrder(ComponentPeer above) {
    23.5      }
    23.6  
    23.7 -    public void updateGraphicsData(GraphicsConfiguration gc) {}
    23.8 +    public boolean updateGraphicsData(GraphicsConfiguration gc) {
    23.9 +        return false;
   23.10 +    }
   23.11  
   23.12      public GraphicsConfiguration getAppropriateGraphicsConfiguration(
   23.13                          GraphicsConfiguration gc)
    24.1 --- a/src/share/classes/sun/awt/SunToolkit.java	Thu May 14 10:58:07 2009 -0700
    24.2 +++ b/src/share/classes/sun/awt/SunToolkit.java	Mon Jun 01 01:05:22 2009 -0700
    24.3 @@ -89,6 +89,25 @@
    24.4       */
    24.5      private static final String POST_EVENT_QUEUE_KEY = "PostEventQueue";
    24.6  
    24.7 +    /**
    24.8 +     * Number of buttons.
    24.9 +     * By default it's taken from the system. If system value does not
   24.10 +     * fit into int type range, use our own MAX_BUTTONS_SUPPORT value.
   24.11 +     */
   24.12 +    protected static int numberOfButtons = 0;
   24.13 +
   24.14 +
   24.15 +    /* XFree standard mention 24 buttons as maximum:
   24.16 +     * http://www.xfree86.org/current/mouse.4.html
   24.17 +     * We workaround systems supporting more than 24 buttons.
   24.18 +     * Otherwise, we have to use long type values as masks
   24.19 +     * which leads to API change.
   24.20 +     * InputEvent.BUTTON_DOWN_MASK may contain only 21 masks due to
   24.21 +     * the 4-bytes limit for the int type. (CR 6799099)
   24.22 +     * One more bit is reserved for FIRST_HIGH_BIT.
   24.23 +     */
   24.24 +    public final static int MAX_BUTTONS_SUPPORTED = 20;
   24.25 +
   24.26      public SunToolkit() {
   24.27          /* If awt.threadgroup is set to class name the instance of
   24.28           * this class is created (should be subclass of ThreadGroup)
   24.29 @@ -2079,6 +2098,12 @@
   24.30          return false;
   24.31      }
   24.32  
   24.33 +    /**
   24.34 +     * Descendants of the SunToolkit should override and put their own logic here.
   24.35 +     */
   24.36 +    public int getNumberOfButtons(){
   24.37 +        return 3;
   24.38 +    }
   24.39  } // class SunToolkit
   24.40  
   24.41  
    25.1 --- a/src/solaris/classes/sun/awt/X11/MotifDnDConstants.java	Thu May 14 10:58:07 2009 -0700
    25.2 +++ b/src/solaris/classes/sun/awt/X11/MotifDnDConstants.java	Mon Jun 01 01:05:22 2009 -0700
    25.3 @@ -120,7 +120,7 @@
    25.4                                                              false,
    25.5                                                              XConstants.AnyPropertyType);
    25.6          try {
    25.7 -            int status = wpg.execute(XToolkit.IgnoreBadWindowHandler);
    25.8 +            int status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
    25.9  
   25.10              if (status == XConstants.Success &&
   25.11                  wpg.getData() != 0 &&
   25.12 @@ -190,7 +190,7 @@
   25.13                  try {
   25.14                      Native.putLong(data, motifWindow);
   25.15  
   25.16 -                    XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
   25.17 +                    XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
   25.18                      XlibWrapper.XChangeProperty(XToolkit.getDisplay(),
   25.19                                                  defaultRootWindow,
   25.20                                                  XA_MOTIF_DRAG_WINDOW.getAtom(),
   25.21 @@ -280,7 +280,7 @@
   25.22                                                              false,
   25.23                                                              XA_MOTIF_DRAG_TARGETS.getAtom());
   25.24          try {
   25.25 -            int status = wpg.execute(XToolkit.IgnoreBadWindowHandler);
   25.26 +            int status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
   25.27  
   25.28              if (status != XConstants.Success
   25.29                  || wpg.getActualType() != XA_MOTIF_DRAG_TARGETS.getAtom()
   25.30 @@ -394,7 +394,7 @@
   25.31                  }
   25.32              }
   25.33  
   25.34 -            XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
   25.35 +            XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
   25.36              XlibWrapper.XChangeProperty(XToolkit.getDisplay(),
   25.37                                          motifWindow,
   25.38                                          XA_MOTIF_DRAG_TARGETS.getAtom(),
   25.39 @@ -410,7 +410,7 @@
   25.40                  // Create a new motif window and retry.
   25.41                  motifWindow = createMotifWindow();
   25.42  
   25.43 -                XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
   25.44 +                XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
   25.45                  XlibWrapper.XChangeProperty(XToolkit.getDisplay(),
   25.46                                              motifWindow,
   25.47                                              XA_MOTIF_DRAG_TARGETS.getAtom(),
   25.48 @@ -534,7 +534,7 @@
   25.49              // CARD32 icc_handle
   25.50              unsafe.putInt(structData + 4, (int)XA_MOTIF_ATOM_0.getAtom());
   25.51  
   25.52 -            XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
   25.53 +            XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
   25.54              XlibWrapper.XChangeProperty(XToolkit.getDisplay(), window,
   25.55                                          XA_MOTIF_ATOM_0.getAtom(),
   25.56                                          XA_MOTIF_DRAG_INITIATOR_INFO.getAtom(),
   25.57 @@ -567,7 +567,7 @@
   25.58              unsafe.putShort(data + 10, (short)0); /* pad */
   25.59              unsafe.putInt(data + 12, dataSize);
   25.60  
   25.61 -            XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
   25.62 +            XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
   25.63              XlibWrapper.XChangeProperty(XToolkit.getDisplay(), window,
   25.64                                          XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(),
   25.65                                          XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(),
    26.1 --- a/src/solaris/classes/sun/awt/X11/MotifDnDDragSourceProtocol.java	Thu May 14 10:58:07 2009 -0700
    26.2 +++ b/src/solaris/classes/sun/awt/X11/MotifDnDDragSourceProtocol.java	Mon Jun 01 01:05:22 2009 -0700
    26.3 @@ -184,7 +184,7 @@
    26.4                                       XConstants.AnyPropertyType);
    26.5  
    26.6          try {
    26.7 -            int status = wpg.execute(XToolkit.IgnoreBadWindowHandler);
    26.8 +            int status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
    26.9  
   26.10              /*
   26.11               * DragICCI.h:
    27.1 --- a/src/solaris/classes/sun/awt/X11/MotifDnDDropTargetProtocol.java	Thu May 14 10:58:07 2009 -0700
    27.2 +++ b/src/solaris/classes/sun/awt/X11/MotifDnDDropTargetProtocol.java	Mon Jun 01 01:05:22 2009 -0700
    27.3 @@ -102,7 +102,7 @@
    27.4                                       XConstants.AnyPropertyType);
    27.5  
    27.6          try {
    27.7 -            status = wpg.execute(XToolkit.IgnoreBadWindowHandler);
    27.8 +            status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
    27.9  
   27.10              /*
   27.11               * DragICCI.h:
   27.12 @@ -162,7 +162,7 @@
   27.13                  unsafe.putInt(data + 12, dataSize);
   27.14              }
   27.15  
   27.16 -            XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
   27.17 +            XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
   27.18              XlibWrapper.XChangeProperty(XToolkit.getDisplay(), embedder,
   27.19                                          MotifDnDConstants.XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(),
   27.20                                          MotifDnDConstants.XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(),
   27.21 @@ -204,7 +204,7 @@
   27.22                                           XConstants.AnyPropertyType);
   27.23  
   27.24              try {
   27.25 -                status = wpg.execute(XToolkit.IgnoreBadWindowHandler);
   27.26 +                status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
   27.27  
   27.28                  /*
   27.29                   * DragICCI.h:
   27.30 @@ -236,7 +236,7 @@
   27.31  
   27.32                      unsafe.putInt(data + 4, tproxy);
   27.33  
   27.34 -                    XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
   27.35 +                    XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
   27.36                      XlibWrapper.XChangeProperty(XToolkit.getDisplay(), embedder,
   27.37                                                  MotifDnDConstants.XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(),
   27.38                                                  MotifDnDConstants.XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(),
   27.39 @@ -276,7 +276,7 @@
   27.40                                       XConstants.AnyPropertyType);
   27.41  
   27.42          try {
   27.43 -            status = wpg.execute(XToolkit.IgnoreBadWindowHandler);
   27.44 +            status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
   27.45  
   27.46              /*
   27.47               * DragICCI.h:
   27.48 @@ -325,7 +325,7 @@
   27.49                                       XConstants.AnyPropertyType);
   27.50  
   27.51          try {
   27.52 -            int status = wpg.execute(XToolkit.IgnoreBadWindowHandler);
   27.53 +            int status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
   27.54  
   27.55              if (status == (int)XConstants.Success && wpg.getData() != 0 &&
   27.56                  wpg.getActualType() != 0 && wpg.getActualFormat() == 8 &&
   27.57 @@ -375,7 +375,7 @@
   27.58                                           MotifDnDConstants.XA_MOTIF_DRAG_INITIATOR_INFO.getAtom());
   27.59  
   27.60              try {
   27.61 -                int status = wpg.execute(XToolkit.IgnoreBadWindowHandler);
   27.62 +                int status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
   27.63  
   27.64                  if (status == XConstants.Success && wpg.getData() != 0 &&
   27.65                      wpg.getActualType() ==
   27.66 @@ -412,7 +412,7 @@
   27.67           */
   27.68          XWindowAttributes wattr = new XWindowAttributes();
   27.69          try {
   27.70 -            XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
   27.71 +            XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
   27.72              int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
   27.73                                                            source_win, wattr.pData);
   27.74  
   27.75 @@ -429,7 +429,7 @@
   27.76              wattr.dispose();
   27.77          }
   27.78  
   27.79 -        XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
   27.80 +        XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
   27.81          XlibWrapper.XSelectInput(XToolkit.getDisplay(), source_win,
   27.82                                   source_win_mask |
   27.83                                   XConstants.StructureNotifyMask);
   27.84 @@ -1020,7 +1020,7 @@
   27.85          if (sourceWindow != 0) {
   27.86              XToolkit.awtLock();
   27.87              try {
   27.88 -                XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
   27.89 +                XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
   27.90                  XlibWrapper.XSelectInput(XToolkit.getDisplay(), sourceWindow,
   27.91                                           sourceWindowMask);
   27.92                  XToolkit.RESTORE_XERROR_HANDLER();
    28.1 --- a/src/solaris/classes/sun/awt/X11/WindowPropertyGetter.java	Thu May 14 10:58:07 2009 -0700
    28.2 +++ b/src/solaris/classes/sun/awt/X11/WindowPropertyGetter.java	Mon Jun 01 01:05:22 2009 -0700
    28.3 @@ -75,7 +75,7 @@
    28.4      public int execute() {
    28.5          return execute(null);
    28.6      }
    28.7 -    public int execute(XToolkit.XErrorHandler errorHandler) {
    28.8 +    public int execute(XErrorHandler errorHandler) {
    28.9  
   28.10          XToolkit.awtLock();
   28.11          try {
   28.12 @@ -94,7 +94,7 @@
   28.13  
   28.14              // Fix for performance problem - IgnodeBadWindowHandler is
   28.15              // used too much without reason, just ignore it
   28.16 -            if (errorHandler == XToolkit.IgnoreBadWindowHandler) {
   28.17 +            if (errorHandler instanceof XErrorHandler.IgnoreBadWindowHandler) {
   28.18                  errorHandler = null;
   28.19              }
   28.20  
    29.1 --- a/src/solaris/classes/sun/awt/X11/XAWTXSettings.java	Thu May 14 10:58:07 2009 -0700
    29.2 +++ b/src/solaris/classes/sun/awt/X11/XAWTXSettings.java	Mon Jun 01 01:05:22 2009 -0700
    29.3 @@ -126,7 +126,7 @@
    29.4                  new WindowPropertyGetter(owner, xSettingsPropertyAtom, 0, MAX_LENGTH,
    29.5                          false, xSettingsPropertyAtom.getAtom() );
    29.6              try {
    29.7 -                int status = getter.execute(XToolkit.IgnoreBadWindowHandler);
    29.8 +                int status = getter.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
    29.9  
   29.10                  if (status != XConstants.Success || getter.getData() == 0) {
   29.11                      if (log.isLoggable(Level.FINE)) log.fine("OH OH : getter failed  status = " + status );
    30.1 --- a/src/solaris/classes/sun/awt/X11/XBaseWindow.java	Thu May 14 10:58:07 2009 -0700
    30.2 +++ b/src/solaris/classes/sun/awt/X11/XBaseWindow.java	Mon Jun 01 01:05:22 2009 -0700
    30.3 @@ -989,8 +989,17 @@
    30.4       */
    30.5      public void handleButtonPressRelease(XEvent xev) {
    30.6          XButtonEvent xbe = xev.get_xbutton();
    30.7 +        /*
    30.8 +         * Ignore the buttons above 20 due to the bit limit for
    30.9 +         * InputEvent.BUTTON_DOWN_MASK.
   30.10 +         * One more bit is reserved for FIRST_HIGH_BIT.
   30.11 +         */
   30.12 +        if (xbe.get_button() > SunToolkit.MAX_BUTTONS_SUPPORTED) {
   30.13 +            return;
   30.14 +        }
   30.15          int buttonState = 0;
   30.16 -        for (int i = 0; i<XToolkit.getNumMouseButtons(); i++){
   30.17 +        final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons();
   30.18 +        for (int i = 0; i<buttonsNumber; i++){
   30.19              // A bug in WM implementation: extra buttons doesn't have state!=0 as they should on Release message.
   30.20              if ((i != 4) && (i != 5)){
   30.21                  buttonState |= (xbe.get_state() & XConstants.buttonsMask[i]);
   30.22 @@ -1026,7 +1035,9 @@
   30.23       * Checks ButtonRelease released all Mouse buttons
   30.24       */
   30.25      static boolean isFullRelease(int buttonState, int button) {
   30.26 -        if (button < 0 || button > XToolkit.getNumMouseButtons()) {
   30.27 +        final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons();
   30.28 +
   30.29 +        if (button < 0 || button > buttonsNumber) {
   30.30              return buttonState == 0;
   30.31          } else {
   30.32              return buttonState == XConstants.buttonsMask[button - 1];
    31.1 --- a/src/solaris/classes/sun/awt/X11/XComponentPeer.java	Thu May 14 10:58:07 2009 -0700
    31.2 +++ b/src/solaris/classes/sun/awt/X11/XComponentPeer.java	Mon Jun 01 01:05:22 2009 -0700
    31.3 @@ -1429,7 +1429,26 @@
    31.4          }
    31.5      }
    31.6  
    31.7 -    public void updateGraphicsData(GraphicsConfiguration gc) {
    31.8 +    public boolean updateGraphicsData(GraphicsConfiguration gc) {
    31.9 +        int oldVisual = -1, newVisual = -1;
   31.10 +
   31.11 +        if (graphicsConfig != null) {
   31.12 +            oldVisual = graphicsConfig.getVisual();
   31.13 +        }
   31.14 +        if (gc != null && gc instanceof X11GraphicsConfig) {
   31.15 +            newVisual = ((X11GraphicsConfig)gc).getVisual();
   31.16 +        }
   31.17 +
   31.18 +        // If the new visual differs from the old one, the peer must be
   31.19 +        // recreated because X11 does not allow changing the visual on the fly.
   31.20 +        // So we even skip the initGraphicsConfiguration() call.
   31.21 +        // The initial assignment should happen though, hence the != -1 thing.
   31.22 +        if (oldVisual != -1 && oldVisual != newVisual) {
   31.23 +            return true;
   31.24 +        }
   31.25 +
   31.26          initGraphicsConfiguration();
   31.27 +        doValidateSurface();
   31.28 +        return false;
   31.29      }
   31.30  }
    32.1 --- a/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java	Thu May 14 10:58:07 2009 -0700
    32.2 +++ b/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java	Mon Jun 01 01:05:22 2009 -0700
    32.3 @@ -1100,7 +1100,8 @@
    32.4      }
    32.5  
    32.6      boolean isOverrideRedirect() {
    32.7 -        return false;
    32.8 +//        return false;
    32.9 +        return ((XToolkit)Toolkit.getDefaultToolkit()).isOverrideRedirect((Window)target);
   32.10      }
   32.11  
   32.12      public boolean requestWindowFocus(long time, boolean timeProvided) {
    33.1 --- a/src/solaris/classes/sun/awt/X11/XDnDDragSourceProtocol.java	Thu May 14 10:58:07 2009 -0700
    33.2 +++ b/src/solaris/classes/sun/awt/X11/XDnDDragSourceProtocol.java	Mon Jun 01 01:05:22 2009 -0700
    33.3 @@ -96,7 +96,7 @@
    33.4                  action_count++;
    33.5              }
    33.6  
    33.7 -            XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
    33.8 +            XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
    33.9              XDnDConstants.XA_XdndActionList.setAtomData(window,
   33.10                                                          XAtom.XA_ATOM,
   33.11                                                          data, action_count);
   33.12 @@ -117,7 +117,7 @@
   33.13          try {
   33.14              Native.put(data, formats);
   33.15  
   33.16 -            XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
   33.17 +            XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
   33.18              XDnDConstants.XA_XdndTypeList.setAtomData(window,
   33.19                                                        XAtom.XA_ATOM,
   33.20                                                        data, formats.length);
   33.21 @@ -195,7 +195,7 @@
   33.22              new WindowPropertyGetter(window, XDnDConstants.XA_XdndAware, 0, 1,
   33.23                                       false, XConstants.AnyPropertyType);
   33.24  
   33.25 -        int status = wpg1.execute(XToolkit.IgnoreBadWindowHandler);
   33.26 +        int status = wpg1.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
   33.27  
   33.28          if (status == XConstants.Success &&
   33.29              wpg1.getData() != 0 && wpg1.getActualType() == XAtom.XA_ATOM) {
   33.30 @@ -215,7 +215,7 @@
   33.31                                               0, 1, false, XAtom.XA_WINDOW);
   33.32  
   33.33                  try {
   33.34 -                    status = wpg2.execute(XToolkit.IgnoreBadWindowHandler);
   33.35 +                    status = wpg2.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
   33.36  
   33.37                      if (status == XConstants.Success &&
   33.38                          wpg2.getData() != 0 &&
   33.39 @@ -233,7 +233,7 @@
   33.40                                                   0, 1, false, XAtom.XA_WINDOW);
   33.41  
   33.42                      try {
   33.43 -                        status = wpg3.execute(XToolkit.IgnoreBadWindowHandler);
   33.44 +                        status = wpg3.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
   33.45  
   33.46                          if (status != XConstants.Success ||
   33.47                              wpg3.getData() == 0 ||
   33.48 @@ -249,7 +249,7 @@
   33.49                                                           XConstants.AnyPropertyType);
   33.50  
   33.51                              try {
   33.52 -                                status = wpg4.execute(XToolkit.IgnoreBadWindowHandler);
   33.53 +                                status = wpg4.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
   33.54  
   33.55                                  if (status != XConstants.Success ||
   33.56                                      wpg4.getData() == 0 ||
    34.1 --- a/src/solaris/classes/sun/awt/X11/XDnDDropTargetProtocol.java	Thu May 14 10:58:07 2009 -0700
    34.2 +++ b/src/solaris/classes/sun/awt/X11/XDnDDropTargetProtocol.java	Mon Jun 01 01:05:22 2009 -0700
    34.3 @@ -88,7 +88,7 @@
    34.4          try {
    34.5              Native.putLong(data, 0, XDnDConstants.XDND_PROTOCOL_VERSION);
    34.6  
    34.7 -            XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
    34.8 +            XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
    34.9              XDnDConstants.XA_XdndAware.setAtomData(window, XAtom.XA_ATOM, data, 1);
   34.10              XToolkit.RESTORE_XERROR_HANDLER();
   34.11  
   34.12 @@ -122,7 +122,7 @@
   34.13                                       false, XConstants.AnyPropertyType);
   34.14  
   34.15          try {
   34.16 -            status = wpg1.execute(XToolkit.IgnoreBadWindowHandler);
   34.17 +            status = wpg1.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
   34.18  
   34.19              if (status == XConstants.Success &&
   34.20                  wpg1.getData() != 0 && wpg1.getActualType() == XAtom.XA_ATOM) {
   34.21 @@ -141,7 +141,7 @@
   34.22                                           0, 1, false, XAtom.XA_WINDOW);
   34.23  
   34.24              try {
   34.25 -                status = wpg2.execute(XToolkit.IgnoreBadWindowHandler);
   34.26 +                status = wpg2.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
   34.27  
   34.28                  if (status == XConstants.Success &&
   34.29                      wpg2.getData() != 0 &&
   34.30 @@ -159,7 +159,7 @@
   34.31                                               0, 1, false, XAtom.XA_WINDOW);
   34.32  
   34.33                  try {
   34.34 -                    status = wpg3.execute(XToolkit.IgnoreBadWindowHandler);
   34.35 +                    status = wpg3.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
   34.36  
   34.37                      if (status != XConstants.Success ||
   34.38                          wpg3.getData() == 0 ||
   34.39 @@ -175,7 +175,7 @@
   34.40                                                       XConstants.AnyPropertyType);
   34.41  
   34.42                          try {
   34.43 -                            status = wpg4.execute(XToolkit.IgnoreBadWindowHandler);
   34.44 +                            status = wpg4.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
   34.45  
   34.46                              if (status != XConstants.Success ||
   34.47                                  wpg4.getData() == 0 ||
   34.48 @@ -205,7 +205,7 @@
   34.49  
   34.50              /* The proxy window must have the XdndAware set, as XDnD protocol
   34.51                 prescribes to check the proxy window for XdndAware. */
   34.52 -            XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
   34.53 +            XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
   34.54              XDnDConstants.XA_XdndAware.setAtomData(newProxy, XAtom.XA_ATOM,
   34.55                                                     data, 1);
   34.56              XToolkit.RESTORE_XERROR_HANDLER();
   34.57 @@ -219,7 +219,7 @@
   34.58              Native.putLong(data, 0, newProxy);
   34.59  
   34.60              /* The proxy window must have the XdndProxy set to point to itself.*/
   34.61 -            XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
   34.62 +            XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
   34.63              XDnDConstants.XA_XdndProxy.setAtomData(newProxy, XAtom.XA_WINDOW,
   34.64                                                     data, 1);
   34.65              XToolkit.RESTORE_XERROR_HANDLER();
   34.66 @@ -232,7 +232,7 @@
   34.67  
   34.68              Native.putLong(data, 0, XDnDConstants.XDND_PROTOCOL_VERSION);
   34.69  
   34.70 -            XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
   34.71 +            XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
   34.72              XDnDConstants.XA_XdndAware.setAtomData(embedder, XAtom.XA_ATOM,
   34.73                                                     data, 1);
   34.74              XToolkit.RESTORE_XERROR_HANDLER();
   34.75 @@ -245,7 +245,7 @@
   34.76  
   34.77              Native.putLong(data, 0, newProxy);
   34.78  
   34.79 -            XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
   34.80 +            XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
   34.81              XDnDConstants.XA_XdndProxy.setAtomData(embedder, XAtom.XA_WINDOW,
   34.82                                                     data, 1);
   34.83              XToolkit.RESTORE_XERROR_HANDLER();
   34.84 @@ -278,7 +278,7 @@
   34.85              try {
   34.86                  Native.putLong(data, 0, entry.getVersion());
   34.87  
   34.88 -                XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
   34.89 +                XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
   34.90                  XDnDConstants.XA_XdndAware.setAtomData(embedder, XAtom.XA_ATOM,
   34.91                                                         data, 1);
   34.92                  XToolkit.RESTORE_XERROR_HANDLER();
   34.93 @@ -291,7 +291,7 @@
   34.94  
   34.95                  Native.putLong(data, 0, (int)entry.getProxy());
   34.96  
   34.97 -                XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
   34.98 +                XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
   34.99                  XDnDConstants.XA_XdndProxy.setAtomData(embedder, XAtom.XA_WINDOW,
  34.100                                                         data, 1);
  34.101                  XToolkit.RESTORE_XERROR_HANDLER();
  34.102 @@ -329,7 +329,7 @@
  34.103                                       false, XConstants.AnyPropertyType);
  34.104  
  34.105          try {
  34.106 -            status = wpg1.execute(XToolkit.IgnoreBadWindowHandler);
  34.107 +            status = wpg1.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
  34.108  
  34.109              if (status == XConstants.Success &&
  34.110                  wpg1.getData() != 0 && wpg1.getActualType() == XAtom.XA_ATOM) {
  34.111 @@ -348,7 +348,7 @@
  34.112                                           0, 1, false, XAtom.XA_WINDOW);
  34.113  
  34.114              try {
  34.115 -                status = wpg2.execute(XToolkit.IgnoreBadWindowHandler);
  34.116 +                status = wpg2.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
  34.117  
  34.118                  if (status == XConstants.Success &&
  34.119                      wpg2.getData() != 0 &&
  34.120 @@ -366,7 +366,7 @@
  34.121                                               0, 1, false, XAtom.XA_WINDOW);
  34.122  
  34.123                  try {
  34.124 -                    status = wpg3.execute(XToolkit.IgnoreBadWindowHandler);
  34.125 +                    status = wpg3.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
  34.126  
  34.127                      if (status != XConstants.Success ||
  34.128                          wpg3.getData() == 0 ||
  34.129 @@ -382,7 +382,7 @@
  34.130                                                       XConstants.AnyPropertyType);
  34.131  
  34.132                          try {
  34.133 -                            status = wpg4.execute(XToolkit.IgnoreBadWindowHandler);
  34.134 +                            status = wpg4.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
  34.135  
  34.136                              if (status != XConstants.Success ||
  34.137                                  wpg4.getData() == 0 ||
  34.138 @@ -411,7 +411,7 @@
  34.139                                       false, XConstants.AnyPropertyType);
  34.140  
  34.141          try {
  34.142 -            int status = wpg1.execute(XToolkit.IgnoreBadWindowHandler);
  34.143 +            int status = wpg1.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
  34.144  
  34.145              if (status == XConstants.Success &&
  34.146                  wpg1.getData() != 0 && wpg1.getActualType() == XAtom.XA_ATOM) {
  34.147 @@ -473,7 +473,7 @@
  34.148                                           0, 0xFFFF, false,
  34.149                                           XAtom.XA_ATOM);
  34.150              try {
  34.151 -                wpg.execute(XToolkit.IgnoreBadWindowHandler);
  34.152 +                wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
  34.153  
  34.154                  if (wpg.getActualType() == XAtom.XA_ATOM &&
  34.155                      wpg.getActualFormat() == 32) {
  34.156 @@ -505,7 +505,7 @@
  34.157                                           0, 0xFFFF, false,
  34.158                                           XAtom.XA_ATOM);
  34.159              try {
  34.160 -                wpg.execute(XToolkit.IgnoreBadWindowHandler);
  34.161 +                wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
  34.162  
  34.163                  if (wpg.getActualType() == XAtom.XA_ATOM &&
  34.164                      wpg.getActualFormat() == 32) {
  34.165 @@ -541,7 +541,7 @@
  34.166           */
  34.167          XWindowAttributes wattr = new XWindowAttributes();
  34.168          try {
  34.169 -            XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
  34.170 +            XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
  34.171              int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
  34.172                                                            source_win, wattr.pData);
  34.173  
  34.174 @@ -558,7 +558,7 @@
  34.175              wattr.dispose();
  34.176          }
  34.177  
  34.178 -        XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
  34.179 +        XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
  34.180          XlibWrapper.XSelectInput(XToolkit.getDisplay(), source_win,
  34.181                                   source_win_mask |
  34.182                                   XConstants.StructureNotifyMask);
  34.183 @@ -963,7 +963,7 @@
  34.184          if (sourceWindow != 0) {
  34.185              XToolkit.awtLock();
  34.186              try {
  34.187 -                XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
  34.188 +                XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
  34.189                  XlibWrapper.XSelectInput(XToolkit.getDisplay(), sourceWindow,
  34.190                                           sourceWindowMask);
  34.191                  XToolkit.RESTORE_XERROR_HANDLER();
  34.192 @@ -1104,14 +1104,14 @@
  34.193                                                   0, 0xFFFF, false,
  34.194                                                   XAtom.XA_ATOM);
  34.195                      try {
  34.196 -                        wpg.execute(XToolkit.IgnoreBadWindowHandler);
  34.197 +                        wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
  34.198  
  34.199                          if (wpg.getActualType() == XAtom.XA_ATOM &&
  34.200                              wpg.getActualFormat() == 32) {
  34.201  
  34.202                              XToolkit.awtLock();
  34.203                              try {
  34.204 -                                XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
  34.205 +                                XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
  34.206                                  XDnDConstants.XA_XdndTypeList.setAtomData(xclient.get_window(),
  34.207                                                                            XAtom.XA_ATOM,
  34.208                                                                            wpg.getData(),
    35.1 --- a/src/solaris/classes/sun/awt/X11/XDragSourceContextPeer.java	Thu May 14 10:58:07 2009 -0700
    35.2 +++ b/src/solaris/classes/sun/awt/X11/XDragSourceContextPeer.java	Mon Jun 01 01:05:22 2009 -0700
    35.3 @@ -42,6 +42,7 @@
    35.4  
    35.5  import sun.awt.dnd.SunDragSourceContextPeer;
    35.6  import sun.awt.dnd.SunDropTargetContextPeer;
    35.7 +import sun.awt.SunToolkit;
    35.8  
    35.9  /**
   35.10   * The XDragSourceContextPeer class is the class responsible for handling
   35.11 @@ -666,6 +667,15 @@
   35.12          case XConstants.ButtonRelease: {
   35.13              XButtonEvent xbutton = ev.get_xbutton();
   35.14              /*
   35.15 +             * Ignore the buttons above 20 due to the bit limit for
   35.16 +             * InputEvent.BUTTON_DOWN_MASK.
   35.17 +             * One more bit is reserved for FIRST_HIGH_BIT.
   35.18 +             */
   35.19 +            if (xbutton.get_button() > SunToolkit.MAX_BUTTONS_SUPPORTED) {
   35.20 +                return true;
   35.21 +            }
   35.22 +
   35.23 +            /*
   35.24               * On some X servers it could happen that ButtonRelease coordinates
   35.25               * differ from the latest MotionNotify coordinates, so we need to
   35.26               * process it as a mouse motion.
    36.1 --- a/src/solaris/classes/sun/awt/X11/XDragSourceProtocol.java	Thu May 14 10:58:07 2009 -0700
    36.2 +++ b/src/solaris/classes/sun/awt/X11/XDragSourceProtocol.java	Mon Jun 01 01:05:22 2009 -0700
    36.3 @@ -181,7 +181,7 @@
    36.4                                     long time) {
    36.5          XWindowAttributes wattr = new XWindowAttributes();
    36.6          try {
    36.7 -            XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
    36.8 +            XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
    36.9              int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
   36.10                                                            targetWindow, wattr.pData);
   36.11  
   36.12 @@ -198,7 +198,7 @@
   36.13              wattr.dispose();
   36.14          }
   36.15  
   36.16 -        XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
   36.17 +        XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
   36.18          XlibWrapper.XSelectInput(XToolkit.getDisplay(), targetWindow,
   36.19                                   targetWindowMask |
   36.20                                   XConstants.StructureNotifyMask);
   36.21 @@ -214,7 +214,7 @@
   36.22      }
   36.23  
   36.24      protected final void finalizeDrop() {
   36.25 -        XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
   36.26 +        XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
   36.27          XlibWrapper.XSelectInput(XToolkit.getDisplay(), targetWindow,
   36.28                                   targetWindowMask);
   36.29          XToolkit.RESTORE_XERROR_HANDLER();
    37.1 --- a/src/solaris/classes/sun/awt/X11/XDropTargetRegistry.java	Thu May 14 10:58:07 2009 -0700
    37.2 +++ b/src/solaris/classes/sun/awt/X11/XDropTargetRegistry.java	Mon Jun 01 01:05:22 2009 -0700
    37.3 @@ -168,7 +168,7 @@
    37.4                  if (dest_x >= 0 && dest_y >= 0) {
    37.5                      XWindowAttributes wattr = new XWindowAttributes();
    37.6                      try {
    37.7 -                        XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
    37.8 +                        XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
    37.9                          int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
   37.10                                                                        window, wattr.pData);
   37.11                          XToolkit.RESTORE_XERROR_HANDLER();
   37.12 @@ -222,7 +222,7 @@
   37.13              long event_mask = 0;
   37.14              XWindowAttributes wattr = new XWindowAttributes();
   37.15              try {
   37.16 -                XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
   37.17 +                XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
   37.18                  int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
   37.19                                                                embedder, wattr.pData);
   37.20                  XToolkit.RESTORE_XERROR_HANDLER();
   37.21 @@ -240,7 +240,7 @@
   37.22              }
   37.23  
   37.24              if ((event_mask & XConstants.PropertyChangeMask) == 0) {
   37.25 -                XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
   37.26 +                XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
   37.27                  XlibWrapper.XSelectInput(XToolkit.getDisplay(), embedder,
   37.28                                           event_mask | XConstants.PropertyChangeMask);
   37.29                  XToolkit.RESTORE_XERROR_HANDLER();
   37.30 @@ -394,7 +394,7 @@
   37.31  
   37.32              /* Restore the original event mask for the embedder. */
   37.33              if ((event_mask & XConstants.PropertyChangeMask) == 0) {
   37.34 -                XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
   37.35 +                XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
   37.36                  XlibWrapper.XSelectInput(XToolkit.getDisplay(), embedder,
   37.37                                           event_mask);
   37.38                  XToolkit.RESTORE_XERROR_HANDLER();
    38.1 --- a/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java	Thu May 14 10:58:07 2009 -0700
    38.2 +++ b/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java	Mon Jun 01 01:05:22 2009 -0700
    38.3 @@ -301,7 +301,7 @@
    38.4          try {
    38.5              XWindowAttributes wattr = new XWindowAttributes();
    38.6              try {
    38.7 -                XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
    38.8 +                XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
    38.9                  int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
   38.10                                                                xembed.handle, wattr.pData);
   38.11  
    39.1 --- a/src/solaris/classes/sun/awt/X11/XEmbedChildProxyPeer.java	Thu May 14 10:58:07 2009 -0700
    39.2 +++ b/src/solaris/classes/sun/awt/X11/XEmbedChildProxyPeer.java	Mon Jun 01 01:05:22 2009 -0700
    39.3 @@ -386,5 +386,7 @@
    39.4      public void setZOrder(ComponentPeer above) {
    39.5      }
    39.6  
    39.7 -    public void updateGraphicsData(GraphicsConfiguration gc) {}
    39.8 +    public boolean updateGraphicsData(GraphicsConfiguration gc) {
    39.9 +        return false;
   39.10 +    }
   39.11  }
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/src/solaris/classes/sun/awt/X11/XErrorHandler.java	Mon Jun 01 01:05:22 2009 -0700
    40.3 @@ -0,0 +1,79 @@
    40.4 +/*
    40.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
    40.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    40.7 + *
    40.8 + * This code is free software; you can redistribute it and/or modify it
    40.9 + * under the terms of the GNU General Public License version 2 only, as
   40.10 + * published by the Free Software Foundation.  Sun designates this
   40.11 + * particular file as subject to the "Classpath" exception as provided
   40.12 + * by Sun in the LICENSE file that accompanied this code.
   40.13 + *
   40.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   40.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   40.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   40.17 + * version 2 for more details (a copy is included in the LICENSE file that
   40.18 + * accompanied this code).
   40.19 + *
   40.20 + * You should have received a copy of the GNU General Public License version
   40.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   40.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   40.23 + *
   40.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   40.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
   40.26 + * have any questions.
   40.27 + */
   40.28 +package sun.awt.X11;
   40.29 +
   40.30 +public abstract class XErrorHandler {
   40.31 +
   40.32 +    /*
   40.33 +     * Called under AWT lock
   40.34 +     */
   40.35 +    public abstract int handleError(long display, XErrorEvent err);
   40.36 +
   40.37 +    /*
   40.38 +     * Forwards all the errors to saved error handler (which was
   40.39 +     * set before XToolkit had been initialized).
   40.40 +     */
   40.41 +    public static class XBaseErrorHandler extends XErrorHandler {
   40.42 +        @Override
   40.43 +        public int handleError(long display, XErrorEvent err) {
   40.44 +            return XToolkit.SAVED_ERROR_HANDLER(display, err);
   40.45 +        }
   40.46 +    }
   40.47 +
   40.48 +    /*
   40.49 +     * Instead of validating window id, we simply call XGetWindowProperty,
   40.50 +     * but temporary install this function as the error handler to ignore
   40.51 +     * BadWindow error.
   40.52 +     */
   40.53 +    public static class IgnoreBadWindowHandler extends XBaseErrorHandler {
   40.54 +        @Override
   40.55 +        public int handleError(long display, XErrorEvent err) {
   40.56 +            if (err.get_error_code() == XConstants.BadWindow) {
   40.57 +                return 0;
   40.58 +            }
   40.59 +            return super.handleError(display, err);
   40.60 +        }
   40.61 +        // Shared instance
   40.62 +        private static IgnoreBadWindowHandler theInstance = new IgnoreBadWindowHandler();
   40.63 +        public static IgnoreBadWindowHandler getInstance() {
   40.64 +            return theInstance;
   40.65 +        }
   40.66 +    }
   40.67 +
   40.68 +    public static class VerifyChangePropertyHandler extends XBaseErrorHandler {
   40.69 +        @Override
   40.70 +        public int handleError(long display, XErrorEvent err) {
   40.71 +            if (err.get_request_code() == XProtocolConstants.X_ChangeProperty) {
   40.72 +                return 0;
   40.73 +            }
   40.74 +            return super.handleError(display, err);
   40.75 +        }
   40.76 +        // Shared instance
   40.77 +        private static IgnoreBadWindowHandler theInstance = new IgnoreBadWindowHandler();
   40.78 +        public static IgnoreBadWindowHandler getInstance() {
   40.79 +            return theInstance;
   40.80 +        }
   40.81 +    }
   40.82 +}
    41.1 --- a/src/solaris/classes/sun/awt/X11/XKeysym.java	Thu May 14 10:58:07 2009 -0700
    41.2 +++ b/src/solaris/classes/sun/awt/X11/XKeysym.java	Mon Jun 01 01:05:22 2009 -0700
    41.3 @@ -29,6 +29,9 @@
    41.4  import java.util.Hashtable;
    41.5  import sun.misc.Unsafe;
    41.6  
    41.7 +import java.util.logging.Level;
    41.8 +import java.util.logging.Logger;
    41.9 +
   41.10  public class XKeysym {
   41.11  
   41.12      public static void main( String args[] ) {
   41.13 @@ -67,6 +70,7 @@
   41.14      static Hashtable<Integer, Long> javaKeycode2KeysymHash = new Hashtable<Integer, Long>();
   41.15      static long keysym_lowercase = unsafe.allocateMemory(Native.getLongSize());
   41.16      static long keysym_uppercase = unsafe.allocateMemory(Native.getLongSize());
   41.17 +    private static Logger keyEventLog = Logger.getLogger("sun.awt.X11.kye.XKeysym");
   41.18      public static char convertKeysym( long ks, int state ) {
   41.19  
   41.20          /* First check for Latin-1 characters (1:1 mapping) */
   41.21 @@ -107,8 +111,15 @@
   41.22                  // clearly means that caller needs a so called primary keysym.
   41.23                  mods ^= XConstants.ShiftMask;
   41.24              }
   41.25 -            XlibWrapper.XkbTranslateKeyCode(XToolkit.getXKBKbdDesc(), ev.get_keycode(),
   41.26 +            long kbdDesc = XToolkit.getXKBKbdDesc();
   41.27 +            if( kbdDesc != 0 ) {
   41.28 +                XlibWrapper.XkbTranslateKeyCode(kbdDesc, ev.get_keycode(),
   41.29                         mods, XlibWrapper.iarg1, XlibWrapper.larg3);
   41.30 +            }else{
   41.31 +                // xkb resources already gone
   41.32 +                keyEventLog.fine("Thread race: Toolkit shutdown before the end of a key event processing.");
   41.33 +                return 0;
   41.34 +            }
   41.35              //XXX unconsumed modifiers?
   41.36              return Native.getLong(XlibWrapper.larg3);
   41.37          } finally {
    42.1 --- a/src/solaris/classes/sun/awt/X11/XProtocol.java	Thu May 14 10:58:07 2009 -0700
    42.2 +++ b/src/solaris/classes/sun/awt/X11/XProtocol.java	Mon Jun 01 01:05:22 2009 -0700
    42.3 @@ -35,20 +35,6 @@
    42.4      private Map<XAtom, XAtomList> atomToList = new HashMap<XAtom, XAtomList>();
    42.5      private Map<XAtom, Long> atomToAnchor = new HashMap<XAtom, Long>();
    42.6  
    42.7 -    /*
    42.8 -     * Temporary error handler that ensures that we know if
    42.9 -     * XChangeProperty succeeded or not.
   42.10 -     */
   42.11 -    static XToolkit.XErrorHandler VerifyChangePropertyHandler = new XToolkit.XErrorHandler() {
   42.12 -            public int handleError(long display, XErrorEvent err) {
   42.13 -                XToolkit.XERROR_SAVE(err);
   42.14 -                if (err.get_request_code() == XProtocolConstants.X_ChangeProperty) {
   42.15 -                    return 0;
   42.16 -                } else {
   42.17 -                    return XToolkit.SAVED_ERROR_HANDLER(display, err);
   42.18 -                }
   42.19 -            }
   42.20 -        };
   42.21      volatile boolean firstCheck = true;
   42.22      /*
   42.23       * Check that that the list of protocols specified by WM in property
    43.1 --- a/src/solaris/classes/sun/awt/X11/XQueryTree.java	Thu May 14 10:58:07 2009 -0700
    43.2 +++ b/src/solaris/classes/sun/awt/X11/XQueryTree.java	Mon Jun 01 01:05:22 2009 -0700
    43.3 @@ -52,7 +52,7 @@
    43.4          public int execute() {
    43.5                  return execute(null);
    43.6          }
    43.7 -        public int execute(XToolkit.XErrorHandler errorHandler) {
    43.8 +        public int execute(XErrorHandler errorHandler) {
    43.9                  XToolkit.awtLock();
   43.10                  try {
   43.11                      if (isDisposed()) {
    44.1 --- a/src/solaris/classes/sun/awt/X11/XRobotPeer.java	Thu May 14 10:58:07 2009 -0700
    44.2 +++ b/src/solaris/classes/sun/awt/X11/XRobotPeer.java	Mon Jun 01 01:05:22 2009 -0700
    44.3 @@ -81,16 +81,11 @@
    44.4          return pixelArray;
    44.5      }
    44.6  
    44.7 -    public int getNumberOfButtons(){
    44.8 -        return getNumberOfButtonsImpl();
    44.9 -    }
   44.10 -
   44.11      private static native synchronized void setup();
   44.12  
   44.13      private static native synchronized void mouseMoveImpl(X11GraphicsConfig xgc, int x, int y);
   44.14      private static native synchronized void mousePressImpl(int buttons);
   44.15      private static native synchronized void mouseReleaseImpl(int buttons);
   44.16 -    private static native synchronized int getNumberOfButtonsImpl();
   44.17      private static native synchronized void mouseWheelImpl(int wheelAmt);
   44.18  
   44.19      private static native synchronized void keyPressImpl(int keycode);
    45.1 --- a/src/solaris/classes/sun/awt/X11/XToolkit.java	Thu May 14 10:58:07 2009 -0700
    45.2 +++ b/src/solaris/classes/sun/awt/X11/XToolkit.java	Mon Jun 01 01:05:22 2009 -0700
    45.3 @@ -85,21 +85,6 @@
    45.4      private static boolean areExtraMouseButtonsEnabled = true;
    45.5  
    45.6      /**
    45.7 -     * Number of buttons.
    45.8 -     * By default it's taken from the system. If system value does not
    45.9 -     * fit into int type range, use our own MAX_BUTTONS_SUPPORT value.
   45.10 -     */
   45.11 -    private static int numberOfButtons = 0;
   45.12 -
   45.13 -    /* XFree standard mention 24 buttons as maximum:
   45.14 -     * http://www.xfree86.org/current/mouse.4.html
   45.15 -     * We workaround systems supporting more than 24 buttons.
   45.16 -     * Otherwise, we have to use long type values as masks
   45.17 -     * which leads to API change.
   45.18 -     */
   45.19 -    private static int MAX_BUTTONS_SUPPORT = 24;
   45.20 -
   45.21 -    /**
   45.22       * True when the x settings have been loaded.
   45.23       */
   45.24      private boolean loadedXSettings;
   45.25 @@ -149,63 +134,78 @@
   45.26              setBackingStoreType();
   45.27          }
   45.28          m_removeSourceEvents = SunToolkit.getMethod(EventQueue.class, "removeSourceEvents", new Class[] {Object.class, Boolean.TYPE}) ;
   45.29 +
   45.30 +        noisyAwtHandler = AccessController.doPrivileged(new GetBooleanAction("sun.awt.noisyerrorhandler"));
   45.31      }
   45.32  
   45.33 -    // Error handler stuff
   45.34 -    static XErrorEvent saved_error;
   45.35 -    static long saved_error_handler;
   45.36 -    static XErrorHandler curErrorHandler;
   45.37 -    // Should be called under LOCK, before releasing LOCK RESTORE_XERROR_HANDLER should be called
   45.38 -    static void WITH_XERROR_HANDLER(XErrorHandler handler) {
   45.39 +    //---- ERROR HANDLER CODE ----//
   45.40 +
   45.41 +    /*
   45.42 +     * Error handler at the moment of XToolkit initialization
   45.43 +     */
   45.44 +    private static long saved_error_handler;
   45.45 +
   45.46 +    /*
   45.47 +     * XErrorEvent being handled
   45.48 +     */
   45.49 +    static volatile XErrorEvent saved_error;
   45.50 +
   45.51 +    /*
   45.52 +     * Current error handler or null if no error handler is set
   45.53 +     */
   45.54 +    private static XErrorHandler current_error_handler;
   45.55 +
   45.56 +    /*
   45.57 +     * Value of sun.awt.noisyerrorhandler system property
   45.58 +     */
   45.59 +    private static boolean noisyAwtHandler;
   45.60 +
   45.61 +    public static void WITH_XERROR_HANDLER(XErrorHandler handler) {
   45.62          saved_error = null;
   45.63 -        curErrorHandler = handler;
   45.64 -        XSync();
   45.65 -        saved_error_handler = XlibWrapper.SetToolkitErrorHandler();
   45.66 +        current_error_handler = handler;
   45.67      }
   45.68 -    static void XERROR_SAVE(XErrorEvent event) {
   45.69 +
   45.70 +    public static void RESTORE_XERROR_HANDLER() {
   45.71 +        current_error_handler = null;
   45.72 +    }
   45.73 +
   45.74 +    // Should be called under LOCK
   45.75 +    public static int SAVED_ERROR_HANDLER(long display, XErrorEvent error) {
   45.76 +        if (saved_error_handler != 0) {
   45.77 +            // Default XErrorHandler may just terminate the process. Don't call it.
   45.78 +            // return XlibWrapper.CallErrorHandler(saved_error_handler, display, error.pData);
   45.79 +        }
   45.80 +        if (log.isLoggable(Level.FINE)) {
   45.81 +            log.log(Level.FINE, "Unhandled XErrorEvent: " +
   45.82 +                    "id=" + error.get_resourceid() + ", " +
   45.83 +                    "serial=" + error.get_serial() + ", " +
   45.84 +                    "ec=" + error.get_error_code() + ", " +
   45.85 +                    "rc=" + error.get_request_code() + ", " +
   45.86 +                    "mc=" + error.get_minor_code());
   45.87 +        }
   45.88 +        return 0;
   45.89 +    }
   45.90 +
   45.91 +    // Called from the native code when an error occurs
   45.92 +    private static int globalErrorHandler(long display, long event_ptr) {
   45.93 +        if (noisyAwtHandler) {
   45.94 +            XlibWrapper.PrintXErrorEvent(display, event_ptr);
   45.95 +        }
   45.96 +        XErrorEvent event = new XErrorEvent(event_ptr);
   45.97          saved_error = event;
   45.98 -    }
   45.99 -    // Should be called under LOCK
  45.100 -    static void RESTORE_XERROR_HANDLER() {
  45.101 -       XSync();
  45.102 -        XlibWrapper.XSetErrorHandler(saved_error_handler);
  45.103 -        curErrorHandler = null;
  45.104 -    }
  45.105 -    // Should be called under LOCK
  45.106 -    static int SAVED_ERROR_HANDLER(long display, XErrorEvent error) {
  45.107 -        return XlibWrapper.CallErrorHandler(saved_error_handler, display, error.pData);
  45.108 -    }
  45.109 -    interface XErrorHandler {
  45.110 -        int handleError(long display, XErrorEvent err);
  45.111 -    }
  45.112 -    static int GlobalErrorHandler(long display, long event_ptr) {
  45.113 -        XErrorEvent event = new XErrorEvent(event_ptr);
  45.114          try {
  45.115 -            if (curErrorHandler != null) {
  45.116 -                return curErrorHandler.handleError(display, event);
  45.117 +            if (current_error_handler != null) {
  45.118 +                return current_error_handler.handleError(display, event);
  45.119              } else {
  45.120                  return SAVED_ERROR_HANDLER(display, event);
  45.121              }
  45.122 -        } finally {
  45.123 +        } catch (Throwable z) {
  45.124 +            log.log(Level.FINE, "Error in GlobalErrorHandler", z);
  45.125          }
  45.126 +        return 0;
  45.127      }
  45.128  
  45.129 -/*
  45.130 - * Instead of validating window id, we simply call XGetWindowProperty,
  45.131 - * but temporary install this function as the error handler to ignore
  45.132 - * BadWindow error.
  45.133 - */
  45.134 -    static XErrorHandler IgnoreBadWindowHandler = new XErrorHandler() {
  45.135 -            public int handleError(long display, XErrorEvent err) {
  45.136 -                XERROR_SAVE(err);
  45.137 -                if (err.get_error_code() == XConstants.BadWindow) {
  45.138 -                    return 0;
  45.139 -                } else {
  45.140 -                    return SAVED_ERROR_HANDLER(display, err);
  45.141 -                }
  45.142 -            }
  45.143 -        };
  45.144 -
  45.145 +    //---- END OF ERROR HANDLER CODE ----//
  45.146  
  45.147      private native static void initIDs();
  45.148      native static void waitForEvents(long nextTaskTime);
  45.149 @@ -302,25 +302,34 @@
  45.150              areExtraMouseButtonsEnabled = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons", "true"));
  45.151              //set system property if not yet assigned
  45.152              System.setProperty("sun.awt.enableExtraMouseButtons", ""+areExtraMouseButtonsEnabled);
  45.153 +
  45.154 +            saved_error_handler = XlibWrapper.SetToolkitErrorHandler();
  45.155          } finally {
  45.156              awtUnlock();
  45.157          }
  45.158  
  45.159          Runtime.getRuntime().addShutdownHook(new Thread() {
  45.160 -                public void run() {
  45.161 -                    XSystemTrayPeer peer = XSystemTrayPeer.getPeerInstance();
  45.162 -                    if (peer != null) {
  45.163 -                        peer.dispose();
  45.164 -                    }
  45.165 -                    if (xs != null) {
  45.166 -                        ((XAWTXSettings)xs).dispose();
  45.167 -                    }
  45.168 -                    freeXKB();
  45.169 -                    if (log.isLoggable(Level.FINE)) {
  45.170 -                        dumpPeers();
  45.171 -                    }
  45.172 +            public void run() {
  45.173 +                XSystemTrayPeer peer = XSystemTrayPeer.getPeerInstance();
  45.174 +                if (peer != null) {
  45.175 +                    peer.dispose();
  45.176                  }
  45.177 -            });
  45.178 +                if (xs != null) {
  45.179 +                    ((XAWTXSettings)xs).dispose();
  45.180 +                }
  45.181 +                freeXKB();
  45.182 +                if (log.isLoggable(Level.FINE)) {
  45.183 +                    dumpPeers();
  45.184 +                }
  45.185 +
  45.186 +                awtLock();
  45.187 +                try {
  45.188 +                    XlibWrapper.XSetErrorHandler(saved_error_handler);
  45.189 +                } finally {
  45.190 +                    awtUnlock();
  45.191 +                }
  45.192 +            }
  45.193 +        });
  45.194      }
  45.195  
  45.196      static String getCorrectXIDString(String val) {
  45.197 @@ -1434,19 +1443,26 @@
  45.198              desktopProperties.put("awt.multiClickInterval",
  45.199                                    Integer.valueOf(getMultiClickTime()));
  45.200              desktopProperties.put("awt.mouse.numButtons",
  45.201 -                                  Integer.valueOf(getNumMouseButtons()));
  45.202 +                                  Integer.valueOf(getNumberOfButtons()));
  45.203          }
  45.204      }
  45.205  
  45.206 -    public static int getNumMouseButtons() {
  45.207 +    /**
  45.208 +     * This method runs through the XPointer and XExtendedPointer array.
  45.209 +     * XExtendedPointer has priority because on some systems XPointer
  45.210 +     * (which is assigned to the virtual pointer) reports the maximum
  45.211 +     * capabilities of the mouse pointer (i.e. 32 physical buttons).
  45.212 +     */
  45.213 +    private native synchronized int getNumberOfButtonsImpl();
  45.214 +
  45.215 +    @Override
  45.216 +    public int getNumberOfButtons(){
  45.217          awtLock();
  45.218          try {
  45.219              if (numberOfButtons == 0) {
  45.220 -                numberOfButtons = Math.min(
  45.221 -                    XlibWrapper.XGetPointerMapping(XToolkit.getDisplay(), 0, 0),
  45.222 -                    MAX_BUTTONS_SUPPORT);
  45.223 +                numberOfButtons = getNumberOfButtonsImpl();
  45.224              }
  45.225 -            return numberOfButtons;
  45.226 +            return (numberOfButtons > MAX_BUTTONS_SUPPORTED)? MAX_BUTTONS_SUPPORTED : numberOfButtons;
  45.227          } finally {
  45.228              awtUnlock();
  45.229          }
  45.230 @@ -2239,6 +2255,7 @@
  45.231          try {
  45.232              if (awt_UseXKB_Calls && awt_XKBDescPtr != 0) {
  45.233                  XlibWrapper.XkbFreeKeyboard(awt_XKBDescPtr, 0xFF, true);
  45.234 +                awt_XKBDescPtr = 0;
  45.235              }
  45.236          } finally {
  45.237              awtUnlock();
  45.238 @@ -2409,8 +2426,6 @@
  45.239          return new XDesktopPeer();
  45.240      }
  45.241  
  45.242 -    public static native void setNoisyXErrorHandler();
  45.243 -
  45.244      public boolean areExtraMouseButtonsEnabled() throws HeadlessException {
  45.245          return areExtraMouseButtonsEnabled;
  45.246      }
    46.1 --- a/src/solaris/classes/sun/awt/X11/XTranslateCoordinates.java	Thu May 14 10:58:07 2009 -0700
    46.2 +++ b/src/solaris/classes/sun/awt/X11/XTranslateCoordinates.java	Mon Jun 01 01:05:22 2009 -0700
    46.3 @@ -57,7 +57,7 @@
    46.4          public int execute() {
    46.5                  return execute(null);
    46.6          }
    46.7 -        public int execute(XToolkit.XErrorHandler errorHandler) {
    46.8 +        public int execute(XErrorHandler errorHandler) {
    46.9                  XToolkit.awtLock();
   46.10                  try {
   46.11                  if (isDisposed()) {
    47.1 --- a/src/solaris/classes/sun/awt/X11/XWM.java	Thu May 14 10:58:07 2009 -0700
    47.2 +++ b/src/solaris/classes/sun/awt/X11/XWM.java	Mon Jun 01 01:05:22 2009 -0700
    47.3 @@ -276,7 +276,7 @@
    47.4              winmgr_running = false;
    47.5              substruct.set_event_mask(XConstants.SubstructureRedirectMask);
    47.6  
    47.7 -            XToolkit.WITH_XERROR_HANDLER(DetectWMHandler);
    47.8 +            XToolkit.WITH_XERROR_HANDLER(detectWMHandler);
    47.9              XlibWrapper.XChangeWindowAttributes(XToolkit.getDisplay(),
   47.10                                                  XToolkit.getDefaultRootWindow(),
   47.11                                                  XConstants.CWEventMask,
   47.12 @@ -321,7 +321,7 @@
   47.13              new WindowPropertyGetter(window, XA_ENLIGHTENMENT_COMMS, 0, 14, false,
   47.14                                       XAtom.XA_STRING);
   47.15          try {
   47.16 -            int status = getter.execute(XToolkit.IgnoreBadWindowHandler);
   47.17 +            int status = getter.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
   47.18              if (status != XConstants.Success || getter.getData() == 0) {
   47.19                  return 0;
   47.20              }
   47.21 @@ -439,7 +439,7 @@
   47.22                  new WindowPropertyGetter(wmwin, XA_DT_SM_STATE_INFO, 0, 1,
   47.23                                           false, XA_DT_SM_STATE_INFO);
   47.24              try {
   47.25 -                status = getter2.execute(XToolkit.IgnoreBadWindowHandler);
   47.26 +                status = getter2.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
   47.27  
   47.28  
   47.29                  if (status != XConstants.Success || getter2.getData() == 0) {
   47.30 @@ -571,21 +571,6 @@
   47.31      }
   47.32  
   47.33      /*
   47.34 -     * Temporary error handler that ensures that we know if
   47.35 -     * XChangeProperty succeeded or not.
   47.36 -     */
   47.37 -    static XToolkit.XErrorHandler VerifyChangePropertyHandler = new XToolkit.XErrorHandler() {
   47.38 -            public int handleError(long display, XErrorEvent err) {
   47.39 -                XToolkit.XERROR_SAVE(err);
   47.40 -                if (err.get_request_code() == XProtocolConstants.X_ChangeProperty) {
   47.41 -                    return 0;
   47.42 -                } else {
   47.43 -                    return XToolkit.SAVED_ERROR_HANDLER(display, err);
   47.44 -                }
   47.45 -            }
   47.46 -        };
   47.47 -
   47.48 -    /*
   47.49       * Prepare IceWM check.
   47.50       *
   47.51       * The only way to detect IceWM, seems to be by setting
   47.52 @@ -617,7 +602,7 @@
   47.53  
   47.54          XToolkit.awtLock();
   47.55          try {
   47.56 -            XToolkit.WITH_XERROR_HANDLER(VerifyChangePropertyHandler);
   47.57 +            XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
   47.58              XlibWrapper.XChangePropertyS(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(),
   47.59                                           XA_ICEWM_WINOPTHINT.getAtom(),
   47.60                                           XA_ICEWM_WINOPTHINT.getAtom(),
   47.61 @@ -682,20 +667,19 @@
   47.62       * Temporary error handler that checks if selecting for
   47.63       * SubstructureRedirect failed.
   47.64       */
   47.65 -    static boolean winmgr_running = false;
   47.66 -    static XToolkit.XErrorHandler DetectWMHandler = new XToolkit.XErrorHandler() {
   47.67 -            public int handleError(long display, XErrorEvent err) {
   47.68 -                XToolkit.XERROR_SAVE(err);
   47.69 -                if (err.get_request_code() == XProtocolConstants.X_ChangeWindowAttributes
   47.70 -                    && err.get_error_code() == XConstants.BadAccess)
   47.71 -                {
   47.72 -                    winmgr_running = true;
   47.73 -                    return 0;
   47.74 -                } else {
   47.75 -                    return XToolkit.SAVED_ERROR_HANDLER(display, err);
   47.76 -                }
   47.77 +    private static boolean winmgr_running = false;
   47.78 +    private static XErrorHandler detectWMHandler = new XErrorHandler.XBaseErrorHandler() {
   47.79 +        @Override
   47.80 +        public int handleError(long display, XErrorEvent err) {
   47.81 +            if ((err.get_request_code() == XProtocolConstants.X_ChangeWindowAttributes) &&
   47.82 +                (err.get_error_code() == XConstants.BadAccess))
   47.83 +            {
   47.84 +                winmgr_running = true;
   47.85 +                return 0;
   47.86              }
   47.87 -        };
   47.88 +            return super.handleError(display, err);
   47.89 +        }
   47.90 +    };
   47.91  
   47.92      /*
   47.93       * Make an educated guess about running window manager.
    48.1 --- a/src/solaris/classes/sun/awt/X11/XWarningWindow.java	Thu May 14 10:58:07 2009 -0700
    48.2 +++ b/src/solaris/classes/sun/awt/X11/XWarningWindow.java	Mon Jun 01 01:05:22 2009 -0700
    48.3 @@ -34,74 +34,68 @@
    48.4  import sun.awt.SunToolkit;
    48.5  
    48.6  class XWarningWindow extends XWindow {
    48.7 -    private final static int showingDelay = 330;
    48.8 -    private final static int hidingDelay = 2000;
    48.9 +    private final static int SHOWING_DELAY = 330;
   48.10 +    private final static int HIDING_DELAY = 2000;
   48.11  
   48.12      private final Window ownerWindow;
   48.13      private WeakReference<XWindowPeer> ownerPeer;
   48.14 -
   48.15 -    public final Window getOwnerWindow() {
   48.16 -        return ownerWindow;
   48.17 -    }
   48.18      private long parentWindow;
   48.19  
   48.20      private final static String OWNER = "OWNER";
   48.21 -
   48.22 -    private static XIconInfo[][] icons;
   48.23 -
   48.24      private InfoWindow.Tooltip tooltip;
   48.25  
   48.26 -    private static synchronized XIconInfo getSecurityIconInfo(int size, int num) {
   48.27 -        if (icons == null) {
   48.28 -            icons = new XIconInfo[4][3];
   48.29 -            if (XlibWrapper.dataModel == 32) {
   48.30 -                icons[0][0] = new XIconInfo(XAWTIcon32_security_icon_bw16_png.security_icon_bw16_png);
   48.31 -                icons[0][1] = new XIconInfo(XAWTIcon32_security_icon_interim16_png.security_icon_interim16_png);
   48.32 -                icons[0][2] = new XIconInfo(XAWTIcon32_security_icon_yellow16_png.security_icon_yellow16_png);
   48.33 -                icons[1][0] = new XIconInfo(XAWTIcon32_security_icon_bw24_png.security_icon_bw24_png);
   48.34 -                icons[1][1] = new XIconInfo(XAWTIcon32_security_icon_interim24_png.security_icon_interim24_png);
   48.35 -                icons[1][2] = new XIconInfo(XAWTIcon32_security_icon_yellow24_png.security_icon_yellow24_png);
   48.36 -                icons[2][0] = new XIconInfo(XAWTIcon32_security_icon_bw32_png.security_icon_bw32_png);
   48.37 -                icons[2][1] = new XIconInfo(XAWTIcon32_security_icon_interim32_png.security_icon_interim32_png);
   48.38 -                icons[2][2] = new XIconInfo(XAWTIcon32_security_icon_yellow32_png.security_icon_yellow32_png);
   48.39 -                icons[3][0] = new XIconInfo(XAWTIcon32_security_icon_bw48_png.security_icon_bw48_png);
   48.40 -                icons[3][1] = new XIconInfo(XAWTIcon32_security_icon_interim48_png.security_icon_interim48_png);
   48.41 -                icons[3][2] = new XIconInfo(XAWTIcon32_security_icon_yellow48_png.security_icon_yellow48_png);
   48.42 -            } else {
   48.43 -                icons[0][0] = new XIconInfo(XAWTIcon64_security_icon_bw16_png.security_icon_bw16_png);
   48.44 -                icons[0][1] = new XIconInfo(XAWTIcon64_security_icon_interim16_png.security_icon_interim16_png);
   48.45 -                icons[0][2] = new XIconInfo(XAWTIcon64_security_icon_yellow16_png.security_icon_yellow16_png);
   48.46 -                icons[1][0] = new XIconInfo(XAWTIcon64_security_icon_bw24_png.security_icon_bw24_png);
   48.47 -                icons[1][1] = new XIconInfo(XAWTIcon64_security_icon_interim24_png.security_icon_interim24_png);
   48.48 -                icons[1][2] = new XIconInfo(XAWTIcon64_security_icon_yellow24_png.security_icon_yellow24_png);
   48.49 -                icons[2][0] = new XIconInfo(XAWTIcon64_security_icon_bw32_png.security_icon_bw32_png);
   48.50 -                icons[2][1] = new XIconInfo(XAWTIcon64_security_icon_interim32_png.security_icon_interim32_png);
   48.51 -                icons[2][2] = new XIconInfo(XAWTIcon64_security_icon_yellow32_png.security_icon_yellow32_png);
   48.52 -                icons[3][0] = new XIconInfo(XAWTIcon64_security_icon_bw48_png.security_icon_bw48_png);
   48.53 -                icons[3][1] = new XIconInfo(XAWTIcon64_security_icon_interim48_png.security_icon_interim48_png);
   48.54 -                icons[3][2] = new XIconInfo(XAWTIcon64_security_icon_yellow48_png.security_icon_yellow48_png);
   48.55 +    /**
   48.56 +     * Animation stage.
   48.57 +     */
   48.58 +    private volatile int currentIcon = 0;
   48.59 +
   48.60 +    /* -1 - uninitialized.
   48.61 +     * 0 - 16x16
   48.62 +     * 1 - 24x24
   48.63 +     * 2 - 32x32
   48.64 +     * 3 - 48x48
   48.65 +     */
   48.66 +    private int currentSize = -1;
   48.67 +    private static XIconInfo[][] icons;
   48.68 +    private static XIconInfo getSecurityIconInfo(int size, int num) {
   48.69 +        synchronized (XWarningWindow.class) {
   48.70 +            if (icons == null) {
   48.71 +                icons = new XIconInfo[4][3];
   48.72 +                if (XlibWrapper.dataModel == 32) {
   48.73 +                    icons[0][0] = new XIconInfo(XAWTIcon32_security_icon_bw16_png.security_icon_bw16_png);
   48.74 +                    icons[0][1] = new XIconInfo(XAWTIcon32_security_icon_interim16_png.security_icon_interim16_png);
   48.75 +                    icons[0][2] = new XIconInfo(XAWTIcon32_security_icon_yellow16_png.security_icon_yellow16_png);
   48.76 +                    icons[1][0] = new XIconInfo(XAWTIcon32_security_icon_bw24_png.security_icon_bw24_png);
   48.77 +                    icons[1][1] = new XIconInfo(XAWTIcon32_security_icon_interim24_png.security_icon_interim24_png);
   48.78 +                    icons[1][2] = new XIconInfo(XAWTIcon32_security_icon_yellow24_png.security_icon_yellow24_png);
   48.79 +                    icons[2][0] = new XIconInfo(XAWTIcon32_security_icon_bw32_png.security_icon_bw32_png);
   48.80 +                    icons[2][1] = new XIconInfo(XAWTIcon32_security_icon_interim32_png.security_icon_interim32_png);
   48.81 +                    icons[2][2] = new XIconInfo(XAWTIcon32_security_icon_yellow32_png.security_icon_yellow32_png);
   48.82 +                    icons[3][0] = new XIconInfo(XAWTIcon32_security_icon_bw48_png.security_icon_bw48_png);
   48.83 +                    icons[3][1] = new XIconInfo(XAWTIcon32_security_icon_interim48_png.security_icon_interim48_png);
   48.84 +                    icons[3][2] = new XIconInfo(XAWTIcon32_security_icon_yellow48_png.security_icon_yellow48_png);
   48.85 +                } else {
   48.86 +                    icons[0][0] = new XIconInfo(XAWTIcon64_security_icon_bw16_png.security_icon_bw16_png);
   48.87 +                    icons[0][1] = new XIconInfo(XAWTIcon64_security_icon_interim16_png.security_icon_interim16_png);
   48.88 +                    icons[0][2] = new XIconInfo(XAWTIcon64_security_icon_yellow16_png.security_icon_yellow16_png);
   48.89 +                    icons[1][0] = new XIconInfo(XAWTIcon64_security_icon_bw24_png.security_icon_bw24_png);
   48.90 +                    icons[1][1] = new XIconInfo(XAWTIcon64_security_icon_interim24_png.security_icon_interim24_png);
   48.91 +                    icons[1][2] = new XIconInfo(XAWTIcon64_security_icon_yellow24_png.security_icon_yellow24_png);
   48.92 +                    icons[2][0] = new XIconInfo(XAWTIcon64_security_icon_bw32_png.security_icon_bw32_png);
   48.93 +                    icons[2][1] = new XIconInfo(XAWTIcon64_security_icon_interim32_png.security_icon_interim32_png);
   48.94 +                    icons[2][2] = new XIconInfo(XAWTIcon64_security_icon_yellow32_png.security_icon_yellow32_png);
   48.95 +                    icons[3][0] = new XIconInfo(XAWTIcon64_security_icon_bw48_png.security_icon_bw48_png);
   48.96 +                    icons[3][1] = new XIconInfo(XAWTIcon64_security_icon_interim48_png.security_icon_interim48_png);
   48.97 +                    icons[3][2] = new XIconInfo(XAWTIcon64_security_icon_yellow48_png.security_icon_yellow48_png);
   48.98 +                }
   48.99              }
  48.100          }
  48.101          final int sizeIndex = size % icons.length;
  48.102          return icons[sizeIndex][num % icons[sizeIndex].length];
  48.103      }
  48.104  
  48.105 -    private volatile int currentIcon = 0;
  48.106 -
  48.107 -    /* -1 - uninitialized yet
  48.108 -     * 0 - 16x16
  48.109 -     * 1 - 24x24
  48.110 -     * 2 - 32x32
  48.111 -     * 3 - 48x48
  48.112 -     */
  48.113 -    private volatile int currentSize = -1;
  48.114 -
  48.115 -    /** Indicates whether the shape of the window must be updated
  48.116 -     */
  48.117 -    private volatile boolean sizeUpdated = true;
  48.118 -
  48.119 -    private synchronized boolean updateIconSize() {
  48.120 -        int newSize = currentSize;
  48.121 +    private void updateIconSize() {
  48.122 +        int newSize = -1;
  48.123  
  48.124          if (ownerWindow != null) {
  48.125              Insets insets = ownerWindow.getInsets();
  48.126 @@ -117,14 +111,32 @@
  48.127                  newSize = 3;
  48.128              }
  48.129          }
  48.130 -        if (newSize != currentSize) {
  48.131 -            currentSize = newSize;
  48.132 -            sizeUpdated = true;
  48.133 +        // Make sure we have a valid size
  48.134 +        if (newSize == -1) {
  48.135 +            newSize = 0;
  48.136          }
  48.137 -        return sizeUpdated;
  48.138 +
  48.139 +        // Note: this is not the most wise solution to use awtLock here,
  48.140 +        // this should have been sync'ed with the stateLock. However,
  48.141 +        // the awtLock must be taken first (see XBaseWindow.getStateLock()),
  48.142 +        // and we need the awtLock anyway to update the shape of the icon.
  48.143 +        // So it's easier to use just one lock instead.
  48.144 +        XToolkit.awtLock();
  48.145 +        try {
  48.146 +            if (newSize != currentSize) {
  48.147 +                currentSize = newSize;
  48.148 +                XIconInfo ico = getSecurityIconInfo(currentSize, 0);
  48.149 +                XlibWrapper.SetBitmapShape(XToolkit.getDisplay(), getWindow(),
  48.150 +                        ico.getWidth(), ico.getHeight(), ico.getIntData());
  48.151 +                AWTAccessor.getWindowAccessor().setSecurityWarningSize(
  48.152 +                        ownerWindow, ico.getWidth(), ico.getHeight());
  48.153 +            }
  48.154 +        } finally {
  48.155 +            XToolkit.awtUnlock();
  48.156 +        }
  48.157      }
  48.158  
  48.159 -    private synchronized XIconInfo getSecurityIconInfo() {
  48.160 +    private XIconInfo getSecurityIconInfo() {
  48.161          updateIconSize();
  48.162          return getSecurityIconInfo(currentSize, currentIcon);
  48.163      }
  48.164 @@ -183,28 +195,6 @@
  48.165          }
  48.166      }
  48.167  
  48.168 -    private void updateWarningWindowBounds() {
  48.169 -        XWindowPeer peer = ownerPeer.get();
  48.170 -        if (peer != null) {
  48.171 -            synchronized (this) {
  48.172 -                if (updateIconSize()) {
  48.173 -                    XIconInfo ico = getSecurityIconInfo();
  48.174 -                    XToolkit.awtLock();
  48.175 -                    try {
  48.176 -                        XlibWrapper.SetBitmapShape(XToolkit.getDisplay(), getWindow(),
  48.177 -                                ico.getWidth(), ico.getHeight(), ico.getIntData());
  48.178 -                    } finally {
  48.179 -                        XToolkit.awtUnlock();
  48.180 -                    }
  48.181 -                    sizeUpdated = false;
  48.182 -                    AWTAccessor.getWindowAccessor().setSecurityWarningSize(
  48.183 -                            ownerWindow, ico.getWidth(), ico.getHeight());
  48.184 -                }
  48.185 -            }
  48.186 -            peer.repositionSecurityWarning();
  48.187 -        }
  48.188 -    }
  48.189 -
  48.190      /**
  48.191       * @param x,y,w,h coordinates of the untrusted window
  48.192       */
  48.193 @@ -376,25 +366,22 @@
  48.194  
  48.195      private final Runnable showingTask = new Runnable() {
  48.196          public void run() {
  48.197 -            new Thread() {
  48.198 -                public void run() {
  48.199 -                    if (!isVisible()) {
  48.200 -                        xSetVisible(true);
  48.201 -                        updateWarningWindowBounds();
  48.202 -                    }
  48.203 -                    repaint();
  48.204 -                    if (currentIcon > 0) {
  48.205 -                        currentIcon--;
  48.206 -                        XToolkit.schedule(showingTask, showingDelay);
  48.207 -                    }
  48.208 -                }}.start();
  48.209 +            if (!isVisible()) {
  48.210 +                xSetVisible(true);
  48.211 +                updateIconSize();
  48.212 +                XWindowPeer peer = ownerPeer.get();
  48.213 +                if (peer != null) {
  48.214 +                    peer.repositionSecurityWarning();
  48.215 +                }
  48.216 +            }
  48.217 +            repaint();
  48.218 +            if (currentIcon > 0) {
  48.219 +                currentIcon--;
  48.220 +                XToolkit.schedule(showingTask, SHOWING_DELAY);
  48.221 +            }
  48.222          }
  48.223      };
  48.224  
  48.225 -    public void setSecurityWarningVisible(boolean visible) {
  48.226 -        setSecurityWarningVisible(visible, true);
  48.227 -    }
  48.228 -
  48.229      public void setSecurityWarningVisible(boolean visible, boolean doSchedule) {
  48.230          if (visible) {
  48.231              XToolkit.remove(hidingTask);
  48.232 @@ -416,7 +403,7 @@
  48.233                  return;
  48.234              }
  48.235              if (doSchedule) {
  48.236 -                XToolkit.schedule(hidingTask, hidingDelay);
  48.237 +                XToolkit.schedule(hidingTask, HIDING_DELAY);
  48.238              } else {
  48.239                  hidingTask.run();
  48.240              }
    49.1 --- a/src/solaris/classes/sun/awt/X11/XWindow.java	Thu May 14 10:58:07 2009 -0700
    49.2 +++ b/src/solaris/classes/sun/awt/X11/XWindow.java	Mon Jun 01 01:05:22 2009 -0700
    49.3 @@ -677,6 +677,14 @@
    49.4          int button=0;
    49.5          boolean wheel_mouse = false;
    49.6          int lbutton = xbe.get_button();
    49.7 +        /*
    49.8 +         * Ignore the buttons above 20 due to the bit limit for
    49.9 +         * InputEvent.BUTTON_DOWN_MASK.
   49.10 +         * One more bit is reserved for FIRST_HIGH_BIT.
   49.11 +         */
   49.12 +        if (lbutton > SunToolkit.MAX_BUTTONS_SUPPORTED) {
   49.13 +            return;
   49.14 +        }
   49.15          int type = xev.get_type();
   49.16          when = xbe.get_time();
   49.17          long jWhen = XToolkit.nowMillisUTC_offset(when);
   49.18 @@ -795,8 +803,9 @@
   49.19          //this doesn't work for extra buttons because Xsystem is sending state==0 for every extra button event.
   49.20          // we can't correct it in MouseEvent class as we done it with modifiers, because exact type (DRAG|MOVE)
   49.21          // should be passed from XWindow.
   49.22 -        //TODO: eliminate it with some other value obtained w/o AWTLock.
   49.23 -        for (int i = 0; i < XToolkit.getNumMouseButtons(); i++){
   49.24 +        final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons();
   49.25 +
   49.26 +        for (int i = 0; i < buttonsNumber; i++){
   49.27              // TODO : here is the bug in WM: extra buttons doesn't have state!=0 as they should.
   49.28              if ((i != 4) && (i != 5)) {
   49.29                  mouseKeyState = mouseKeyState | (xme.get_state() & XConstants.buttonsMask[i]);
   49.30 @@ -1343,18 +1352,23 @@
   49.31          setSizeHints(flags, x, y, width, height);
   49.32      }
   49.33  
   49.34 -      void validateSurface() {
   49.35 +    void validateSurface() {
   49.36          if ((width != oldWidth) || (height != oldHeight)) {
   49.37 -            SurfaceData oldData = surfaceData;
   49.38 -            if (oldData != null) {
   49.39 -                surfaceData = graphicsConfig.createSurfaceData(this);
   49.40 -                oldData.invalidate();
   49.41 -            }
   49.42 +            doValidateSurface();
   49.43 +
   49.44              oldWidth = width;
   49.45              oldHeight = height;
   49.46          }
   49.47      }
   49.48  
   49.49 +    final void doValidateSurface() {
   49.50 +        SurfaceData oldData = surfaceData;
   49.51 +        if (oldData != null) {
   49.52 +            surfaceData = graphicsConfig.createSurfaceData(this);
   49.53 +            oldData.invalidate();
   49.54 +        }
   49.55 +    }
   49.56 +
   49.57      public SurfaceData getSurfaceData() {
   49.58          return surfaceData;
   49.59      }
    50.1 --- a/src/solaris/classes/sun/awt/X11/XWindowPeer.java	Thu May 14 10:58:07 2009 -0700
    50.2 +++ b/src/solaris/classes/sun/awt/X11/XWindowPeer.java	Mon Jun 01 01:05:22 2009 -0700
    50.3 @@ -1108,7 +1108,7 @@
    50.4              }
    50.5          }
    50.6  
    50.7 -        warningWindow.setSecurityWarningVisible(show);
    50.8 +        warningWindow.setSecurityWarningVisible(show, true);
    50.9      }
   50.10  
   50.11      boolean isOverrideRedirect() {
   50.12 @@ -1894,7 +1894,9 @@
   50.13          }
   50.14          if (isGrabbed()) {
   50.15              boolean dragging = false;
   50.16 -            for (int i = 0; i<XToolkit.getNumMouseButtons(); i++){
   50.17 +            final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons();
   50.18 +
   50.19 +            for (int i = 0; i < buttonsNumber; i++){
   50.20                  // here is the bug in WM: extra buttons doesn't have state!=0 as they should.
   50.21                  if ((i != 4) && (i != 5)){
   50.22                      dragging = dragging || ((xme.get_state() & XConstants.buttonsMask[i]) != 0);
   50.23 @@ -1940,6 +1942,15 @@
   50.24  
   50.25      public void handleButtonPressRelease(XEvent xev) {
   50.26          XButtonEvent xbe = xev.get_xbutton();
   50.27 +
   50.28 +        /*
   50.29 +         * Ignore the buttons above 20 due to the bit limit for
   50.30 +         * InputEvent.BUTTON_DOWN_MASK.
   50.31 +         * One more bit is reserved for FIRST_HIGH_BIT.
   50.32 +         */
   50.33 +        if (xbe.get_button() > SunToolkit.MAX_BUTTONS_SUPPORTED) {
   50.34 +            return;
   50.35 +        }
   50.36          if (grabLog.isLoggable(Level.FINE)) {
   50.37              grabLog.log(Level.FINE, "{0}, when grabbed {1}, contains {2} ({3}, {4}, {5}x{6})",
   50.38                          new Object[] {xbe, isGrabbed(), containsGlobal(xbe.get_x_root(), xbe.get_y_root()), getAbsoluteX(), getAbsoluteY(), getWidth(), getHeight()});
   50.39 @@ -2058,7 +2069,7 @@
   50.40      }
   50.41  
   50.42      @Override
   50.43 -    public void updateWindow(BufferedImage backBuffer) {
   50.44 +    public void updateWindow() {
   50.45          // no-op
   50.46      }
   50.47  }
    51.1 --- a/src/solaris/classes/sun/awt/X11/XlibUtil.java	Thu May 14 10:58:07 2009 -0700
    51.2 +++ b/src/solaris/classes/sun/awt/X11/XlibUtil.java	Mon Jun 01 01:05:22 2009 -0700
    51.3 @@ -149,7 +149,7 @@
    51.4                  new XTranslateCoordinates(src, dst, p.x, p.y);
    51.5              try
    51.6              {
    51.7 -                int status = xtc.execute(XToolkit.IgnoreBadWindowHandler);
    51.8 +                int status = xtc.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
    51.9                  if ((status != 0) &&
   51.10                      ((XToolkit.saved_error == null) ||
   51.11                       (XToolkit.saved_error.get_error_code() == XConstants.Success)))
   51.12 @@ -306,7 +306,7 @@
   51.13                                           XWM.XA_WM_STATE);
   51.14              try
   51.15              {
   51.16 -                wpg.execute(XToolkit.IgnoreBadWindowHandler);
   51.17 +                wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
   51.18                  if (wpg.getActualType() == XWM.XA_WM_STATE.getAtom())
   51.19                  {
   51.20                      return true;
   51.21 @@ -345,7 +345,7 @@
   51.22          XWindowAttributes wattr = new XWindowAttributes();
   51.23          try
   51.24          {
   51.25 -            XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
   51.26 +            XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
   51.27              int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
   51.28                                                            window, wattr.pData);
   51.29              XToolkit.RESTORE_XERROR_HANDLER();
    52.1 --- a/src/solaris/classes/sun/awt/X11/XlibWrapper.java	Thu May 14 10:58:07 2009 -0700
    52.2 +++ b/src/solaris/classes/sun/awt/X11/XlibWrapper.java	Mon Jun 01 01:05:22 2009 -0700
    52.3 @@ -646,4 +646,6 @@
    52.4          String javaVersion = XToolkit.getSystemProperty("java.version");
    52.5          return javaVersion != null && javaVersion.contains("internal");
    52.6      }
    52.7 +
    52.8 +    static native void PrintXErrorEvent(long display, long event_ptr);
    52.9  }
    53.1 --- a/src/solaris/classes/sun/awt/X11/generator/sizes.64-solaris-i386	Thu May 14 10:58:07 2009 -0700
    53.2 +++ b/src/solaris/classes/sun/awt/X11/generator/sizes.64-solaris-i386	Mon Jun 01 01:05:22 2009 -0700
    53.3 @@ -186,6 +186,15 @@
    53.4  XEvent.xkeymap	0
    53.5  XEvent.pad	0
    53.6  XEvent	192
    53.7 +XRenderDirectFormat.red	0
    53.8 +XRenderDirectFormat.redMask	2
    53.9 +XRenderDirectFormat.green	4
   53.10 +XRenderDirectFormat.greenMask	6
   53.11 +XRenderDirectFormat.blue	8
   53.12 +XRenderDirectFormat.blueMask	10
   53.13 +XRenderDirectFormat.alpha	12
   53.14 +XRenderDirectFormat.alphaMask	14
   53.15 +XRenderDirectFormat	16
   53.16  ColorData.awt_Colors	0
   53.17  ColorData.awt_numICMcolors	8
   53.18  ColorData.awt_icmLUT	16
   53.19 @@ -440,6 +449,12 @@
   53.20  XSetWindowAttributes.colormap	96
   53.21  XSetWindowAttributes.cursor	104
   53.22  XSetWindowAttributes	112
   53.23 +XRenderPictFormat.id	0
   53.24 +XRenderPictFormat.type	8
   53.25 +XRenderPictFormat.depth	12
   53.26 +XRenderPictFormat.direct	16
   53.27 +XRenderPictFormat.colormap	32
   53.28 +XRenderPictFormat	40
   53.29  XReparentEvent.type	0
   53.30  XReparentEvent.serial	8
   53.31  XReparentEvent.send_event	16
   53.32 @@ -985,7 +1000,8 @@
   53.33  AwtGraphicsConfigData.color_data	144
   53.34  AwtGraphicsConfigData.glxInfo	152
   53.35  AwtGraphicsConfigData.isTranslucencySupported	160
   53.36 -AwtGraphicsConfigData	168
   53.37 +AwtGraphicsConfigData.renderPictFormat	168
   53.38 +AwtGraphicsConfigData	208
   53.39  XColor.pixel	0
   53.40  XColor.red	8
   53.41  XColor.green	10
    54.1 --- a/src/solaris/classes/sun/awt/X11/generator/xlibtypes.txt	Thu May 14 10:58:07 2009 -0700
    54.2 +++ b/src/solaris/classes/sun/awt/X11/generator/xlibtypes.txt	Mon Jun 01 01:05:22 2009 -0700
    54.3 @@ -245,6 +245,21 @@
    54.4      blue_mask	long
    54.5      colormap_size	int
    54.6      bits_per_rgb	int
    54.7 +XRenderDirectFormat
    54.8 +    red         short
    54.9 +    redMask     short
   54.10 +    green       short
   54.11 +    greenMask   short
   54.12 +    blue        short
   54.13 +    blueMask    short
   54.14 +    alpha       short
   54.15 +    alphaMask   short
   54.16 +XRenderPictFormat
   54.17 +    id          long
   54.18 +    type        int
   54.19 +    depth       int
   54.20 +    direct      struct XRenderDirectFormat
   54.21 +    colormap    long
   54.22  XIMHotKeyTrigger
   54.23      keysym	long
   54.24      modifier	int
   54.25 @@ -751,6 +766,7 @@
   54.26      color_data pointer ColorData
   54.27      glxInfo pointer
   54.28      isTranslucencySupported int
   54.29 +    renderPictFormat struct XRenderPictFormat
   54.30  
   54.31  AwtScreenData
   54.32      numConfigs int
    55.1 --- a/src/solaris/classes/sun/awt/X11/keysym2ucs.h	Thu May 14 10:58:07 2009 -0700
    55.2 +++ b/src/solaris/classes/sun/awt/X11/keysym2ucs.h	Mon Jun 01 01:05:22 2009 -0700
    55.3 @@ -67,6 +67,9 @@
    55.4  tojava import java.util.Hashtable;
    55.5  tojava import sun.misc.Unsafe;
    55.6  tojava
    55.7 +tojava import java.util.logging.Level;
    55.8 +tojava import java.util.logging.Logger;
    55.9 +tojava
   55.10  tojava public class XKeysym {
   55.11  tojava
   55.12  tojava     public static void main( String args[] ) {
   55.13 @@ -105,6 +108,7 @@
   55.14  tojava     static Hashtable<Integer, Long> javaKeycode2KeysymHash = new Hashtable<Integer, Long>();
   55.15  tojava     static long keysym_lowercase = unsafe.allocateMemory(Native.getLongSize());
   55.16  tojava     static long keysym_uppercase = unsafe.allocateMemory(Native.getLongSize());
   55.17 +tojava     private static Logger keyEventLog = Logger.getLogger("sun.awt.X11.kye.XKeysym");
   55.18  tojava     public static char convertKeysym( long ks, int state ) {
   55.19  tojava
   55.20  tojava         /* First check for Latin-1 characters (1:1 mapping) */
   55.21 @@ -145,8 +149,15 @@
   55.22  tojava                 // clearly means that caller needs a so called primary keysym.
   55.23  tojava                 mods ^= XConstants.ShiftMask;
   55.24  tojava             }
   55.25 -tojava             XlibWrapper.XkbTranslateKeyCode(XToolkit.getXKBKbdDesc(), ev.get_keycode(),
   55.26 +tojava             long kbdDesc = XToolkit.getXKBKbdDesc();
   55.27 +tojava             if( kbdDesc != 0 ) {
   55.28 +tojava                 XlibWrapper.XkbTranslateKeyCode(kbdDesc, ev.get_keycode(),
   55.29  tojava                        mods, XlibWrapper.iarg1, XlibWrapper.larg3);
   55.30 +tojava             }else{
   55.31 +tojava                 // xkb resources already gone
   55.32 +tojava                 keyEventLog.fine("Thread race: Toolkit shutdown before the end of a key event processing.");
   55.33 +tojava                 return 0;
   55.34 +tojava             }
   55.35  tojava             //XXX unconsumed modifiers?
   55.36  tojava             return Native.getLong(XlibWrapper.larg3);
   55.37  tojava         } finally {
    56.1 --- a/src/solaris/classes/sun/awt/X11GraphicsConfig.java	Thu May 14 10:58:07 2009 -0700
    56.2 +++ b/src/solaris/classes/sun/awt/X11GraphicsConfig.java	Mon Jun 01 01:05:22 2009 -0700
    56.3 @@ -37,7 +37,10 @@
    56.4  import java.awt.Transparency;
    56.5  import java.awt.image.BufferedImage;
    56.6  import java.awt.image.ColorModel;
    56.7 +import java.awt.color.ColorSpace;
    56.8 +import java.awt.image.ComponentColorModel;
    56.9  import java.awt.image.DirectColorModel;
   56.10 +import java.awt.image.DataBuffer;
   56.11  import java.awt.image.VolatileImage;
   56.12  import java.awt.image.WritableRaster;
   56.13  import java.awt.geom.AffineTransform;
   56.14 @@ -230,6 +233,22 @@
   56.15          }
   56.16      }
   56.17  
   56.18 +    public static DirectColorModel createDCM32(int rMask, int gMask, int bMask,
   56.19 +                                               int aMask, boolean aPre) {
   56.20 +        return new DirectColorModel(
   56.21 +            ColorSpace.getInstance(ColorSpace.CS_sRGB),
   56.22 +            32, rMask, gMask, bMask, aMask, aPre, DataBuffer.TYPE_INT);
   56.23 +    }
   56.24 +
   56.25 +    public static ComponentColorModel createABGRCCM() {
   56.26 +        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
   56.27 +        int[] nBits = {8, 8, 8, 8};
   56.28 +        int[] bOffs = {3, 2, 1, 0};
   56.29 +        return new ComponentColorModel(cs, nBits, true, true,
   56.30 +                                       Transparency.TRANSLUCENT,
   56.31 +                                       DataBuffer.TYPE_BYTE);
   56.32 +    }
   56.33 +
   56.34      /**
   56.35       * Returns the default Transform for this configuration.  This
   56.36       * Transform is typically the Identity transform for most normal
    57.1 --- a/src/solaris/classes/sun/awt/motif/MToolkit.java	Thu May 14 10:58:07 2009 -0700
    57.2 +++ b/src/solaris/classes/sun/awt/motif/MToolkit.java	Mon Jun 01 01:05:22 2009 -0700
    57.3 @@ -1,5 +1,5 @@
    57.4  /*
    57.5 - * Copyright 1995-2007 Sun Microsystems, Inc.  All Rights Reserved.
    57.6 + * Copyright 1995-2009 Sun Microsystems, Inc.  All Rights Reserved.
    57.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    57.8   *
    57.9   * This code is free software; you can redistribute it and/or modify it
   57.10 @@ -624,7 +624,6 @@
   57.11      }
   57.12  
   57.13      private native int getMulticlickTime();
   57.14 -    private native int getNumMouseButtons();
   57.15  
   57.16      protected void initializeDesktopProperties() {
   57.17          desktopProperties.put("DnD.Autoscroll.initialDelay",     Integer.valueOf(50));
   57.18 @@ -643,7 +642,7 @@
   57.19              desktopProperties.put("awt.multiClickInterval",
   57.20                                    Integer.valueOf(getMulticlickTime()));
   57.21              desktopProperties.put("awt.mouse.numButtons",
   57.22 -                                  Integer.valueOf(getNumMouseButtons()));
   57.23 +                                  Integer.valueOf(getNumberOfButtons()));
   57.24          }
   57.25      }
   57.26  
    58.1 --- a/src/solaris/classes/sun/java2d/x11/X11PMBlitBgLoops.java	Thu May 14 10:58:07 2009 -0700
    58.2 +++ b/src/solaris/classes/sun/java2d/x11/X11PMBlitBgLoops.java	Mon Jun 01 01:05:22 2009 -0700
    58.3 @@ -70,6 +70,10 @@
    58.4                                   X11SurfaceData.UShort565RgbX11),
    58.5              new X11PMBlitBgLoops(X11SurfaceData.UShortIndexedX11_BM,
    58.6                                   X11SurfaceData.UShortIndexedX11),
    58.7 +            new X11PMBlitBgLoops(X11SurfaceData.IntRgbX11_BM,
    58.8 +                                 X11SurfaceData.IntArgbPreX11),
    58.9 +            new X11PMBlitBgLoops(X11SurfaceData.IntBgrX11_BM,
   58.10 +                                 X11SurfaceData.FourByteAbgrPreX11),
   58.11          };
   58.12          GraphicsPrimitiveMgr.register(primitives);
   58.13      }
    59.1 --- a/src/solaris/classes/sun/java2d/x11/X11PMBlitLoops.java	Thu May 14 10:58:07 2009 -0700
    59.2 +++ b/src/solaris/classes/sun/java2d/x11/X11PMBlitLoops.java	Mon Jun 01 01:05:22 2009 -0700
    59.3 @@ -95,6 +95,22 @@
    59.4              new X11PMBlitLoops(X11SurfaceData.UShortIndexedX11_BM,
    59.5                                 X11SurfaceData.UShortIndexedX11, true),
    59.6  
    59.7 +            new X11PMBlitLoops(X11SurfaceData.IntRgbX11,
    59.8 +                               X11SurfaceData.IntArgbPreX11, true),
    59.9 +            new X11PMBlitLoops(X11SurfaceData.IntRgbX11,
   59.10 +                               X11SurfaceData.IntArgbPreX11, false),
   59.11 +            new X11PMBlitLoops(X11SurfaceData.IntRgbX11_BM,
   59.12 +                               X11SurfaceData.IntArgbPreX11, true),
   59.13 +
   59.14 +            new X11PMBlitLoops(X11SurfaceData.IntBgrX11,
   59.15 +                               X11SurfaceData.FourByteAbgrPreX11, true),
   59.16 +            new X11PMBlitLoops(X11SurfaceData.IntBgrX11,
   59.17 +                               X11SurfaceData.FourByteAbgrPreX11, false),
   59.18 +            new X11PMBlitLoops(X11SurfaceData.IntBgrX11_BM,
   59.19 +                               X11SurfaceData.FourByteAbgrPreX11, true),
   59.20 +
   59.21 +
   59.22 +
   59.23              // delegate loops
   59.24              new DelegateBlitLoop(X11SurfaceData.IntBgrX11_BM,
   59.25                                   X11SurfaceData.IntBgrX11),
    60.1 --- a/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java	Thu May 14 10:58:07 2009 -0700
    60.2 +++ b/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java	Mon Jun 01 01:05:22 2009 -0700
    60.3 @@ -81,6 +81,13 @@
    60.4          DESC_INT_BGR_X11        = "Integer BGR Pixmap";
    60.5      public static final String
    60.6          DESC_INT_RGB_X11        = "Integer RGB Pixmap";
    60.7 +
    60.8 +    public static final String
    60.9 +        DESC_4BYTE_ABGR_PRE_X11 = "4 byte ABGR Pixmap with pre-multplied alpha";
   60.10 +    public static final String
   60.11 +        DESC_INT_ARGB_PRE_X11   = "Integer ARGB Pixmap with pre-multiplied " +
   60.12 +                                  "alpha";
   60.13 +
   60.14      public static final String
   60.15          DESC_BYTE_IND_OPQ_X11   = "Byte Indexed Opaque Pixmap";
   60.16  
   60.17 @@ -133,6 +140,11 @@
   60.18      public static final SurfaceType IntRgbX11 =
   60.19          SurfaceType.IntRgb.deriveSubType(DESC_INT_RGB_X11);
   60.20  
   60.21 +    public static final SurfaceType FourByteAbgrPreX11 =
   60.22 +        SurfaceType.FourByteAbgrPre.deriveSubType(DESC_4BYTE_ABGR_PRE_X11);
   60.23 +    public static final SurfaceType IntArgbPreX11 =
   60.24 +        SurfaceType.IntArgbPre.deriveSubType(DESC_INT_ARGB_PRE_X11);
   60.25 +
   60.26      public static final SurfaceType ThreeByteRgbX11 =
   60.27          SurfaceType.ThreeByteRgb.deriveSubType(DESC_3BYTE_RGB_X11);
   60.28      public static final SurfaceType ThreeByteBgrX11 =
   60.29 @@ -413,7 +425,7 @@
   60.30                                                    int transparency)
   60.31      {
   60.32          return new X11PixmapSurfaceData(gc, width, height, image,
   60.33 -                                        getSurfaceType(gc, transparency),
   60.34 +                                        getSurfaceType(gc, transparency, true),
   60.35                                          cm, drawable, transparency);
   60.36      }
   60.37  
   60.38 @@ -498,6 +510,13 @@
   60.39      public static SurfaceType getSurfaceType(X11GraphicsConfig gc,
   60.40                                               int transparency)
   60.41      {
   60.42 +        return getSurfaceType(gc, transparency, false);
   60.43 +    }
   60.44 +
   60.45 +    public static SurfaceType getSurfaceType(X11GraphicsConfig gc,
   60.46 +                                             int transparency,
   60.47 +                                             boolean pixmapSurface)
   60.48 +    {
   60.49          boolean transparent = (transparency == Transparency.BITMASK);
   60.50          SurfaceType sType;
   60.51          ColorModel cm = gc.getColorModel();
   60.52 @@ -524,11 +543,21 @@
   60.53              // Fall through for 32 bit case
   60.54          case 32:
   60.55              if (cm instanceof DirectColorModel) {
   60.56 -                if (((DirectColorModel)cm).getRedMask() == 0xff0000) {
   60.57 -                    sType = transparent ? X11SurfaceData.IntRgbX11_BM : X11SurfaceData.IntRgbX11;
   60.58 +                if (((SunToolkit)java.awt.Toolkit.getDefaultToolkit()
   60.59 +                     ).isTranslucencyCapable(gc) && !pixmapSurface)
   60.60 +                {
   60.61 +                    sType = X11SurfaceData.IntArgbPreX11;
   60.62                  } else {
   60.63 -                    sType = transparent ? X11SurfaceData.IntBgrX11_BM : X11SurfaceData.IntBgrX11;
   60.64 +                    if (((DirectColorModel)cm).getRedMask() == 0xff0000) {
   60.65 +                        sType = transparent ? X11SurfaceData.IntRgbX11_BM :
   60.66 +                                              X11SurfaceData.IntRgbX11;
   60.67 +                    } else {
   60.68 +                        sType = transparent ? X11SurfaceData.IntBgrX11_BM :
   60.69 +                                              X11SurfaceData.IntBgrX11;
   60.70 +                    }
   60.71                  }
   60.72 +            } else if (cm instanceof ComponentColorModel) {
   60.73 +                   sType = X11SurfaceData.FourByteAbgrPreX11;
   60.74              } else {
   60.75  
   60.76                  throw new sun.java2d.InvalidPipeException("Unsupported bit " +
    61.1 --- a/src/solaris/native/sun/awt/X11Color.c	Thu May 14 10:58:07 2009 -0700
    61.2 +++ b/src/solaris/native/sun/awt/X11Color.c	Mon Jun 01 01:05:22 2009 -0700
    61.3 @@ -886,6 +886,27 @@
    61.4  #define blue(v)         (((v) >>  0) & 0xFF)
    61.5  
    61.6  #ifndef HEADLESS
    61.7 +
    61.8 +jobject getColorSpace(JNIEnv* env, jint csID) {
    61.9 +    jclass clazz;
   61.10 +    jobject cspaceL;
   61.11 +    jmethodID mid;
   61.12 +
   61.13 +    clazz = (*env)->FindClass(env,"java/awt/color/ColorSpace");
   61.14 +    mid = (*env)->GetStaticMethodID(env, clazz, "getInstance",
   61.15 +                                    "(I)Ljava/awt/color/ColorSpace;");
   61.16 +    if (mid == NULL) {
   61.17 +        return NULL;
   61.18 +    }
   61.19 +
   61.20 +    /* SECURITY: This is safe, because static methods cannot
   61.21 +     *           be overridden, and this method does not invoke
   61.22 +     *           client code
   61.23 +     */
   61.24 +
   61.25 +    return (*env)->CallStaticObjectMethod(env, clazz, mid, csID);
   61.26 +}
   61.27 +
   61.28  jobject awtJNI_GetColorModel(JNIEnv *env, AwtGraphicsConfigDataPtr aData)
   61.29  {
   61.30      jobject awt_colormodel = NULL;
   61.31 @@ -899,21 +920,61 @@
   61.32          (aData->awt_depth >= 15))
   61.33      {
   61.34          clazz = (*env)->FindClass(env,"java/awt/image/DirectColorModel");
   61.35 +        if (!aData->isTranslucencySupported) {
   61.36  
   61.37 -        mid = (*env)->GetMethodID(env,clazz,"<init>","(IIIII)V");
   61.38 +            mid = (*env)->GetMethodID(env,clazz,"<init>","(IIIII)V");
   61.39  
   61.40 -        if (mid == NULL) {
   61.41 -            (*env)->PopLocalFrame(env, 0);
   61.42 -            return NULL;
   61.43 +            if (mid == NULL) {
   61.44 +                (*env)->PopLocalFrame(env, 0);
   61.45 +                return NULL;
   61.46 +            }
   61.47 +            awt_colormodel = (*env)->NewObject(env,clazz, mid,
   61.48 +                    aData->awt_visInfo.depth,
   61.49 +                    aData->awt_visInfo.red_mask,
   61.50 +                    aData->awt_visInfo.green_mask,
   61.51 +                    aData->awt_visInfo.blue_mask,
   61.52 +                    0);
   61.53 +        } else {
   61.54 +            clazz = (*env)->FindClass(env,"sun/awt/X11GraphicsConfig");
   61.55 +            if (clazz == NULL) {
   61.56 +                (*env)->PopLocalFrame(env, 0);
   61.57 +                return NULL;
   61.58 +            }
   61.59 +
   61.60 +            if (aData->renderPictFormat.direct.red == 16) {
   61.61 +                mid = (*env)->GetStaticMethodID( env,clazz,"createDCM32",
   61.62 +                        "(IIIIZ)Ljava/awt/image/DirectColorModel;");
   61.63 +
   61.64 +                if (mid == NULL) {
   61.65 +                    (*env)->PopLocalFrame(env, 0);
   61.66 +                    return NULL;
   61.67 +                }
   61.68 +
   61.69 +                awt_colormodel = (*env)->CallStaticObjectMethod(
   61.70 +                        env,clazz, mid,
   61.71 +                        aData->renderPictFormat.direct.redMask
   61.72 +                            << aData->renderPictFormat.direct.red,
   61.73 +                        aData->renderPictFormat.direct.greenMask
   61.74 +                            << aData->renderPictFormat.direct.green,
   61.75 +                        aData->renderPictFormat.direct.blueMask
   61.76 +                            << aData->renderPictFormat.direct.blue,
   61.77 +                        aData->renderPictFormat.direct.alphaMask
   61.78 +                            << aData->renderPictFormat.direct.alpha,
   61.79 +                        JNI_TRUE);
   61.80 +            } else {
   61.81 +                mid = (*env)->GetStaticMethodID( env,clazz,"createABGRCCM",
   61.82 +                        "()Ljava/awt/image/ComponentColorModel;");
   61.83 +
   61.84 +                if (mid == NULL) {
   61.85 +                    (*env)->PopLocalFrame(env, 0);
   61.86 +                    return NULL;
   61.87 +                }
   61.88 +
   61.89 +                awt_colormodel = (*env)->CallStaticObjectMethod(
   61.90 +                        env,clazz, mid);
   61.91 +            }
   61.92          }
   61.93  
   61.94 -        awt_colormodel = (*env)->NewObject(env,clazz, mid,
   61.95 -                                           aData->awt_visInfo.depth,
   61.96 -                                           aData->awt_visInfo.red_mask,
   61.97 -                                           aData->awt_visInfo.green_mask,
   61.98 -                                           aData->awt_visInfo.blue_mask,
   61.99 -                                           0);
  61.100 -
  61.101          if(awt_colormodel == NULL)
  61.102          {
  61.103              (*env)->PopLocalFrame(env, 0);
  61.104 @@ -923,25 +984,13 @@
  61.105      }
  61.106      else if (aData->awt_visInfo.class == StaticGray &&
  61.107               aData->awt_num_colors == 256) {
  61.108 -        jclass clazz1;
  61.109          jobject cspace = NULL;
  61.110          jint bits[1];
  61.111          jintArray bitsArray;
  61.112          jboolean falseboolean = JNI_FALSE;
  61.113  
  61.114 -        clazz1 = (*env)->FindClass(env,"java/awt/color/ColorSpace");
  61.115 -        mid = (*env)->GetStaticMethodID(env, clazz1, "getInstance",
  61.116 -              "(I)Ljava/awt/color/ColorSpace;");
  61.117 -        if (mid == NULL) {
  61.118 -            (*env)->PopLocalFrame(env, 0);
  61.119 -            return NULL;
  61.120 -        }
  61.121 -        /* SECURITY: This is safe, because static methods cannot
  61.122 -         *           be overridden, and this method does not invoke
  61.123 -         *           client code
  61.124 -         */
  61.125 -        cspace = (*env)->CallStaticObjectMethod(env, clazz1, mid,
  61.126 -            java_awt_color_ColorSpace_CS_GRAY);
  61.127 +        cspace = getColorSpace(env, java_awt_color_ColorSpace_CS_GRAY);
  61.128 +
  61.129          if (cspace == NULL) {
  61.130              (*env)->PopLocalFrame(env, 0);
  61.131              return NULL;
    62.1 --- a/src/solaris/native/sun/awt/awt_GraphicsEnv.c	Thu May 14 10:58:07 2009 -0700
    62.2 +++ b/src/solaris/native/sun/awt/awt_GraphicsEnv.c	Mon Jun 01 01:05:22 2009 -0700
    62.3 @@ -175,42 +175,11 @@
    62.4  }
    62.5  
    62.6  #ifndef HEADLESS
    62.7 +
    62.8  /*
    62.9 - * error handlers
   62.10 + * XIOErrorHandler
   62.11   */
   62.12 -
   62.13 -int
   62.14 -xerror_handler(Display * disp, XErrorEvent * err)
   62.15 -{
   62.16 -/* #ifdef DEBUG */
   62.17 -    char msg[128];
   62.18 -    char buf[128];
   62.19 -    char *ev = getenv("NOISY_AWT");
   62.20 -
   62.21 -    if (!ev || !ev[0])
   62.22 -        return 0;
   62.23 -    XGetErrorText(disp, err->error_code, msg, sizeof(msg));
   62.24 -    jio_fprintf(stderr, "Xerror %s, XID %x, ser# %d\n", msg, err->resourceid, err->serial);
   62.25 -    jio_snprintf(buf, sizeof(buf), "%d", err->request_code);
   62.26 -    XGetErrorDatabaseText(disp, "XRequest", buf, "Unknown", msg, sizeof(msg));
   62.27 -    jio_fprintf(stderr, "Major opcode %d (%s)\n", err->request_code, msg);
   62.28 -    if (err->request_code > 128) {
   62.29 -        jio_fprintf(stderr, "Minor opcode %d\n", err->minor_code);
   62.30 -    }
   62.31 -    if (awtLockInited) {
   62.32 -        /*SignalError(lockedee->lastpc, lockedee, "fp/ade/gui/GUIException", msg); */
   62.33 -    }
   62.34 -    if (strcasecmp(ev, "abort") == 0) {
   62.35 -        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
   62.36 -
   62.37 -        (*env)->FatalError(env, "xerror_handler abort");
   62.38 -    }
   62.39 -/* #endif */
   62.40 -    return 0;
   62.41 -}
   62.42 -
   62.43 -static int
   62.44 -xioerror_handler(Display * disp)
   62.45 +static int xioerror_handler(Display *disp)
   62.46  {
   62.47      if (awtLockInited) {
   62.48          if (errno == EPIPE) {
   62.49 @@ -354,48 +323,6 @@
   62.50      return NULL;
   62.51  }
   62.52  
   62.53 -/* Note: until we include the <X11/extensions/Xrender.h> explicitly
   62.54 - * we have to define a couple of things ourselves.
   62.55 - */
   62.56 -typedef unsigned long   PictFormat;
   62.57 -#define PictTypeIndexed             0
   62.58 -#define PictTypeDirect              1
   62.59 -
   62.60 -typedef struct {
   62.61 -    short   red;
   62.62 -    short   redMask;
   62.63 -    short   green;
   62.64 -    short   greenMask;
   62.65 -    short   blue;
   62.66 -    short   blueMask;
   62.67 -    short   alpha;
   62.68 -    short   alphaMask;
   62.69 -} XRenderDirectFormat;
   62.70 -
   62.71 -typedef struct {
   62.72 -    PictFormat      id;
   62.73 -    int         type;
   62.74 -    int         depth;
   62.75 -    XRenderDirectFormat direct;
   62.76 -    Colormap        colormap;
   62.77 -} XRenderPictFormat;
   62.78 -
   62.79 -#define PictFormatID        (1 << 0)
   62.80 -#define PictFormatType      (1 << 1)
   62.81 -#define PictFormatDepth     (1 << 2)
   62.82 -#define PictFormatRed       (1 << 3)
   62.83 -#define PictFormatRedMask   (1 << 4)
   62.84 -#define PictFormatGreen     (1 << 5)
   62.85 -#define PictFormatGreenMask (1 << 6)
   62.86 -#define PictFormatBlue      (1 << 7)
   62.87 -#define PictFormatBlueMask  (1 << 8)
   62.88 -#define PictFormatAlpha     (1 << 9)
   62.89 -#define PictFormatAlphaMask (1 << 10)
   62.90 -#define PictFormatColormap  (1 << 11)
   62.91 -
   62.92 -typedef XRenderPictFormat *
   62.93 -XRenderFindVisualFormatFunc (Display *dpy, _Xconst Visual *visual);
   62.94 -
   62.95  static void
   62.96  getAllConfigs (JNIEnv *env, int screen, AwtScreenDataPtr screenDataPtr) {
   62.97  
   62.98 @@ -535,6 +462,8 @@
   62.99                  format->direct.alphaMask)
  62.100              {
  62.101                  graphicsConfigs [ind]->isTranslucencySupported = 1;
  62.102 +                memcpy(&graphicsConfigs [ind]->renderPictFormat, format,
  62.103 +                        sizeof(*format));
  62.104              }
  62.105          }
  62.106      }
  62.107 @@ -886,7 +815,6 @@
  62.108          return NULL;
  62.109      }
  62.110  
  62.111 -    XSetErrorHandler(xerror_handler);
  62.112      XSetIOErrorHandler(xioerror_handler);
  62.113  
  62.114      /* set awt_numScreens, and whether or not we're using Xinerama */
    63.1 --- a/src/solaris/native/sun/awt/awt_InputMethod.c	Thu May 14 10:58:07 2009 -0700
    63.2 +++ b/src/solaris/native/sun/awt/awt_InputMethod.c	Mon Jun 01 01:05:22 2009 -0700
    63.3 @@ -1458,7 +1458,6 @@
    63.4  }
    63.5  
    63.6  static void OpenXIMCallback(Display *display, XPointer client_data, XPointer call_data) {
    63.7 -    extern int xerror_handler();
    63.8      XIMCallback ximCallback;
    63.9  
   63.10      X11im = XOpenIM(display, NULL, NULL, NULL);
   63.11 @@ -1469,13 +1468,6 @@
   63.12      ximCallback.callback = (XIMProc)DestroyXIMCallback;
   63.13      ximCallback.client_data = NULL;
   63.14      XSetIMValues(X11im, XNDestroyCallback, &ximCallback, NULL);
   63.15 -
   63.16 -    /* Workaround for Solaris 2.6 bug 4097754. We're affected by this problem
   63.17 -     * because Motif also calls XOpenIM for us. Re-registering the error handler
   63.18 -     * that MToolkit has registered already after calling XOpenIM avoids the
   63.19 -     * problem.
   63.20 -     */
   63.21 -    XSetErrorHandler(xerror_handler);
   63.22  }
   63.23  
   63.24  static void DestroyXIMCallback(XIM im, XPointer client_data, XPointer call_data) {
    64.1 --- a/src/solaris/native/sun/awt/awt_MToolkit.c	Thu May 14 10:58:07 2009 -0700
    64.2 +++ b/src/solaris/native/sun/awt/awt_MToolkit.c	Mon Jun 01 01:05:22 2009 -0700
    64.3 @@ -1926,26 +1926,6 @@
    64.4                XtAppProcessEvent(awt_appContext, iMask & ~XtIMXEvent);
    64.5              }
    64.6  
    64.7 -            /*
    64.8 -            ** Bug #4361799: Forte4J sometimes crashes on Solaris:
    64.9 -            ** There is an underlying bug in Selection.c in Xt lib.
   64.10 -            ** The routine HandleSelectionEvents, can call EndProtectedSection()
   64.11 -            ** more than  StartProtectedSection(), and then EndProtectedSection
   64.12 -            ** will restore the default XError handler.  As a result awt's
   64.13 -            ** XError handler gets removed and we later crash on an XError.
   64.14 -            **
   64.15 -            ** This happens when we call XtAppProcessEvent with event type 1e
   64.16 -            ** (SelectionRequest) when running two copies of Forte
   64.17 -            **
   64.18 -            ** XSetErrorHandler can safely be called repeatedly, so we are
   64.19 -            ** fixing this with the sledgehammer, and resetting our XError
   64.20 -            ** handler every time through the loop:
   64.21 -            */
   64.22 -            {
   64.23 -                extern int32_t xerror_handler();
   64.24 -                XSetErrorHandler(xerror_handler);
   64.25 -            }
   64.26 -
   64.27  } /* processOneEvent() */
   64.28  
   64.29  /*
   64.30 @@ -3188,21 +3168,6 @@
   64.31  
   64.32  /*
   64.33   * Class:     sun_awt_motif_MToolkit
   64.34 - * Method:    getNumMouseButtons
   64.35 - * Signature: ()I
   64.36 - */
   64.37 -JNIEXPORT jint JNICALL Java_sun_awt_motif_MToolkit_getNumMouseButtons
   64.38 -  (JNIEnv *env, jobject this)
   64.39 -{
   64.40 -    jint res = 0;
   64.41 -    AWT_LOCK();
   64.42 -    res = XGetPointerMapping(awt_display, NULL, 0);
   64.43 -    AWT_UNLOCK();
   64.44 -    return res;
   64.45 -}
   64.46 -
   64.47 -/*
   64.48 - * Class:     sun_awt_motif_MToolkit
   64.49   * Method:    loadXSettings
   64.50   * Signature: ()V
   64.51   */
    65.1 --- a/src/solaris/native/sun/awt/awt_Robot.c	Thu May 14 10:58:07 2009 -0700
    65.2 +++ b/src/solaris/native/sun/awt/awt_Robot.c	Mon Jun 01 01:05:22 2009 -0700
    65.3 @@ -51,9 +51,8 @@
    65.4  
    65.5  extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
    65.6  
    65.7 -// 2 would be more correct, however that's how Robot originally worked
    65.8 -// and tests start to fail if this value is changed
    65.9 -static int32_t num_buttons = 3;
   65.10 +extern int32_t getNumButtons();
   65.11 +
   65.12  static jint * masks;
   65.13  
   65.14  static int32_t isXTestAvailable() {
   65.15 @@ -90,46 +89,6 @@
   65.16      return isXTestAvailable;
   65.17  }
   65.18  
   65.19 -static void getNumButtons() {
   65.20 -    int32_t major_opcode, first_event, first_error;
   65.21 -    int32_t xinputAvailable;
   65.22 -    int32_t numDevices, devIdx, clsIdx;
   65.23 -    XDeviceInfo* devices;
   65.24 -    XDeviceInfo* aDevice;
   65.25 -    XButtonInfo* bInfo;
   65.26 -
   65.27 -    /* 4700242:
   65.28 -     * If XTest is asked to press a non-existant mouse button
   65.29 -     * (i.e. press Button3 on a system configured with a 2-button mouse),
   65.30 -     * then a crash may happen.  To avoid this, we use the XInput
   65.31 -     * extension to query for the number of buttons on the XPointer, and check
   65.32 -     * before calling XTestFakeButtonEvent().
   65.33 -     */
   65.34 -    xinputAvailable = XQueryExtension(awt_display, INAME, &major_opcode, &first_event, &first_error);
   65.35 -    DTRACE_PRINTLN3("RobotPeer: XQueryExtension(XINPUT) returns major_opcode = %d, first_event = %d, first_error = %d",
   65.36 -                    major_opcode, first_event, first_error);
   65.37 -    if (xinputAvailable) {
   65.38 -        devices = XListInputDevices(awt_display, &numDevices);
   65.39 -        for (devIdx = 0; devIdx < numDevices; devIdx++) {
   65.40 -            aDevice = &(devices[devIdx]);
   65.41 -            if (aDevice->use == IsXPointer) {
   65.42 -                for (clsIdx = 0; clsIdx < aDevice->num_classes; clsIdx++) {
   65.43 -                    if (aDevice->inputclassinfo[clsIdx].class == ButtonClass) {
   65.44 -                        bInfo = (XButtonInfo*)(&(aDevice->inputclassinfo[clsIdx]));
   65.45 -                        num_buttons = bInfo->num_buttons;
   65.46 -                        DTRACE_PRINTLN1("RobotPeer: XPointer has %d buttons", num_buttons);
   65.47 -                        break;
   65.48 -                    }
   65.49 -                }
   65.50 -                break;
   65.51 -            }
   65.52 -        }
   65.53 -        XFreeDeviceList(devices);
   65.54 -    }
   65.55 -    else {
   65.56 -        DTRACE_PRINTLN1("RobotPeer: XINPUT extension is unavailable, assuming %d mouse buttons", num_buttons);
   65.57 -    }
   65.58 -}
   65.59  
   65.60  static XImage *getWindowImage(Display * display, Window window,
   65.61                                int32_t x, int32_t y,
   65.62 @@ -241,17 +200,10 @@
   65.63          return;
   65.64      }
   65.65  
   65.66 -    getNumButtons();
   65.67      finally:
   65.68      AWT_UNLOCK();
   65.69  }
   65.70  
   65.71 -JNIEXPORT jint JNICALL
   65.72 -Java_sun_awt_X11_XRobotPeer_getNumberOfButtonsImpl(JNIEnv *env,
   65.73 -                                                   jclass cls) {
   65.74 -    // At the moment this routine being called we already should have an initialized num_buttons variable.
   65.75 -    return num_buttons;
   65.76 -}
   65.77  
   65.78  JNIEXPORT void JNICALL
   65.79  Java_sun_awt_X11_XRobotPeer_getRGBPixelsImpl( JNIEnv *env,
   65.80 @@ -386,6 +338,8 @@
   65.81  {
   65.82      AWT_LOCK();
   65.83  
   65.84 +    int32_t num_buttons = getNumButtons(); //from XToolkit.c
   65.85 +
   65.86      DTRACE_PRINTLN1("RobotPeer: mouseAction(%i)", buttonMask);
   65.87      DTRACE_PRINTLN1("RobotPeer: mouseAction, press = %d", isMousePress);
   65.88  
    66.1 --- a/src/solaris/native/sun/awt/awt_p.h	Thu May 14 10:58:07 2009 -0700
    66.2 +++ b/src/solaris/native/sun/awt/awt_p.h	Mon Jun 01 01:05:22 2009 -0700
    66.3 @@ -119,6 +119,50 @@
    66.4  } DamageRect;
    66.5  
    66.6  #ifndef HEADLESS
    66.7 +
    66.8 +/* Note: until we include the <X11/extensions/Xrender.h> explicitly
    66.9 + * we have to define a couple of things ourselves.
   66.10 + */
   66.11 +typedef unsigned long   PictFormat;
   66.12 +#define PictTypeIndexed             0
   66.13 +#define PictTypeDirect              1
   66.14 +
   66.15 +typedef struct {
   66.16 +    short   red;
   66.17 +    short   redMask;
   66.18 +    short   green;
   66.19 +    short   greenMask;
   66.20 +    short   blue;
   66.21 +    short   blueMask;
   66.22 +    short   alpha;
   66.23 +    short   alphaMask;
   66.24 +} XRenderDirectFormat;
   66.25 +
   66.26 +typedef struct {
   66.27 +    PictFormat      id;
   66.28 +    int         type;
   66.29 +    int         depth;
   66.30 +    XRenderDirectFormat direct;
   66.31 +    Colormap        colormap;
   66.32 +} XRenderPictFormat;
   66.33 +
   66.34 +#define PictFormatID        (1 << 0)
   66.35 +#define PictFormatType      (1 << 1)
   66.36 +#define PictFormatDepth     (1 << 2)
   66.37 +#define PictFormatRed       (1 << 3)
   66.38 +#define PictFormatRedMask   (1 << 4)
   66.39 +#define PictFormatGreen     (1 << 5)
   66.40 +#define PictFormatGreenMask (1 << 6)
   66.41 +#define PictFormatBlue      (1 << 7)
   66.42 +#define PictFormatBlueMask  (1 << 8)
   66.43 +#define PictFormatAlpha     (1 << 9)
   66.44 +#define PictFormatAlphaMask (1 << 10)
   66.45 +#define PictFormatColormap  (1 << 11)
   66.46 +
   66.47 +typedef XRenderPictFormat *
   66.48 +XRenderFindVisualFormatFunc (Display *dpy, _Xconst Visual *visual);
   66.49 +/* END OF Xrender.h chunk */
   66.50 +
   66.51  typedef struct _AwtGraphicsConfigData  {
   66.52      int         awt_depth;
   66.53      Colormap    awt_cmap;
   66.54 @@ -136,6 +180,7 @@
   66.55      ColorData      *color_data;
   66.56      struct _GLXGraphicsConfigInfo *glxInfo;
   66.57      int         isTranslucencySupported; /* Uses Xrender to find this out. */
   66.58 +    XRenderPictFormat renderPictFormat; /*Used only if translucency supported*/
   66.59  } AwtGraphicsConfigData;
   66.60  
   66.61  typedef AwtGraphicsConfigData* AwtGraphicsConfigDataPtr;
    67.1 --- a/src/solaris/native/sun/xawt/XToolkit.c	Thu May 14 10:58:07 2009 -0700
    67.2 +++ b/src/solaris/native/sun/xawt/XToolkit.c	Mon Jun 01 01:05:22 2009 -0700
    67.3 @@ -45,10 +45,14 @@
    67.4  #include "sun_awt_X11_XToolkit.h"
    67.5  #include "java_awt_SystemColor.h"
    67.6  #include "java_awt_TrayIcon.h"
    67.7 +#include <X11/extensions/XTest.h>
    67.8  
    67.9  uint32_t awt_NumLockMask = 0;
   67.10  Boolean  awt_ModLockIsShiftLock = False;
   67.11  
   67.12 +static int32_t num_buttons = 0;
   67.13 +int32_t getNumButtons();
   67.14 +
   67.15  extern JavaVM *jvm;
   67.16  
   67.17  // Tracing level
   67.18 @@ -575,7 +579,6 @@
   67.19          pollFds[1].revents = 0;
   67.20      }
   67.21  
   67.22 -
   67.23      AWT_NOFLUSH_UNLOCK();
   67.24  
   67.25      /* ACTUALLY DO THE POLL() */
   67.26 @@ -684,8 +687,6 @@
   67.27      return ret;
   67.28  }
   67.29  
   67.30 -static XErrorHandler saved_error_handler = NULL;
   67.31 -
   67.32  #ifdef __linux__
   67.33  void print_stack(void)
   67.34  {
   67.35 @@ -706,38 +707,6 @@
   67.36  }
   67.37  #endif
   67.38  
   67.39 -static int NoisyXErrorHandler(Display * dpy, XErrorEvent * event) {
   67.40 -    fprintf(stderr, "id=%x, serial=%x, ec=%d, rc=%d, mc=%d\n",
   67.41 -            event->resourceid, event->serial, event->error_code,
   67.42 -            event->request_code, event->minor_code);
   67.43 -    /*
   67.44 -    #ifdef __linux__
   67.45 -        print_stack();
   67.46 -    #endif
   67.47 -    */
   67.48 -    if (jvm != NULL) {
   67.49 -      JNIEnv * env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
   67.50 -      JNU_CallStaticMethodByName(env, NULL, "java/lang/Thread", "dumpStack", "()V");
   67.51 -    }
   67.52 -    if (!saved_error_handler) {
   67.53 -        return saved_error_handler(dpy, event);
   67.54 -    }
   67.55 -    return 0;
   67.56 -}
   67.57 -
   67.58 -/*
   67.59 - * Class:     sun_awt_X11_XToolkit
   67.60 - * Method:    setNoisyXErrorHandler
   67.61 - * Signature: ()V
   67.62 - */
   67.63 -JNIEXPORT void JNICALL Java_sun_awt_X11_XToolkit_setNoisyXErrorHandler
   67.64 -(JNIEnv *env , jclass clazz)
   67.65 -{
   67.66 -    (*env)->GetJavaVM(env, &jvm);
   67.67 -    saved_error_handler = XSetErrorHandler(NoisyXErrorHandler);
   67.68 -}
   67.69 -
   67.70 -
   67.71  Window get_xawt_root_shell(JNIEnv *env) {
   67.72    static jclass classXRootWindow = NULL;
   67.73    static jmethodID methodGetXRootWindow = NULL;
   67.74 @@ -943,3 +912,80 @@
   67.75          AWT_UNLOCK();
   67.76      }
   67.77  }
   67.78 +
   67.79 +
   67.80 +/*
   67.81 + * Class:     sun_awt_X11_XToolkit
   67.82 + * Method:    getNumberOfButtonsImpl
   67.83 + * Signature: ()I
   67.84 + */
   67.85 +JNIEXPORT jint JNICALL Java_sun_awt_X11_XToolkit_getNumberOfButtonsImpl
   67.86 +(JNIEnv * env, jobject cls){
   67.87 +    if (num_buttons == 0) {
   67.88 +        num_buttons = getNumButtons();
   67.89 +    }
   67.90 +    return num_buttons;
   67.91 +}
   67.92 +
   67.93 +int32_t getNumButtons() {
   67.94 +    int32_t major_opcode, first_event, first_error;
   67.95 +    int32_t xinputAvailable;
   67.96 +    int32_t numDevices, devIdx, clsIdx;
   67.97 +    XDeviceInfo* devices;
   67.98 +    XDeviceInfo* aDevice;
   67.99 +    XButtonInfo* bInfo;
  67.100 +    int32_t local_num_buttons = 0;
  67.101 +
  67.102 +    /* 4700242:
  67.103 +     * If XTest is asked to press a non-existant mouse button
  67.104 +     * (i.e. press Button3 on a system configured with a 2-button mouse),
  67.105 +     * then a crash may happen.  To avoid this, we use the XInput
  67.106 +     * extension to query for the number of buttons on the XPointer, and check
  67.107 +     * before calling XTestFakeButtonEvent().
  67.108 +     */
  67.109 +    xinputAvailable = XQueryExtension(awt_display, INAME, &major_opcode, &first_event, &first_error);
  67.110 +    DTRACE_PRINTLN3("RobotPeer: XQueryExtension(XINPUT) returns major_opcode = %d, first_event = %d, first_error = %d",
  67.111 +                    major_opcode, first_event, first_error);
  67.112 +    if (xinputAvailable) {
  67.113 +        devices = XListInputDevices(awt_display, &numDevices);
  67.114 +        for (devIdx = 0; devIdx < numDevices; devIdx++) {
  67.115 +            aDevice = &(devices[devIdx]);
  67.116 +#ifdef IsXExtensionPointer
  67.117 +            if (aDevice->use == IsXExtensionPointer) {
  67.118 +                for (clsIdx = 0; clsIdx < aDevice->num_classes; clsIdx++) {
  67.119 +                    if (aDevice->inputclassinfo[clsIdx].class == ButtonClass) {
  67.120 +                        bInfo = (XButtonInfo*)(&(aDevice->inputclassinfo[clsIdx]));
  67.121 +                        local_num_buttons = bInfo->num_buttons;
  67.122 +                        DTRACE_PRINTLN1("RobotPeer: XPointer has %d buttons", num_buttons);
  67.123 +                        break;
  67.124 +                    }
  67.125 +                }
  67.126 +                break;
  67.127 +            }
  67.128 +#endif
  67.129 +            if (local_num_buttons <= 0 ) {
  67.130 +                if (aDevice->use == IsXPointer) {
  67.131 +                    for (clsIdx = 0; clsIdx < aDevice->num_classes; clsIdx++) {
  67.132 +                        if (aDevice->inputclassinfo[clsIdx].class == ButtonClass) {
  67.133 +                            bInfo = (XButtonInfo*)(&(aDevice->inputclassinfo[clsIdx]));
  67.134 +                            local_num_buttons = bInfo->num_buttons;
  67.135 +                            DTRACE_PRINTLN1("RobotPeer: XPointer has %d buttons", num_buttons);
  67.136 +                            break;
  67.137 +                        }
  67.138 +                    }
  67.139 +                    break;
  67.140 +                }
  67.141 +            }
  67.142 +        }
  67.143 +
  67.144 +        XFreeDeviceList(devices);
  67.145 +    }
  67.146 +    else {
  67.147 +        DTRACE_PRINTLN1("RobotPeer: XINPUT extension is unavailable, assuming %d mouse buttons", num_buttons);
  67.148 +    }
  67.149 +    if (local_num_buttons == 0 ) {
  67.150 +        local_num_buttons = 3;
  67.151 +    }
  67.152 +
  67.153 +    return local_num_buttons;
  67.154 +}
    68.1 --- a/src/solaris/native/sun/xawt/XlibWrapper.c	Thu May 14 10:58:07 2009 -0700
    68.2 +++ b/src/solaris/native/sun/xawt/XlibWrapper.c	Mon Jun 01 01:05:22 2009 -0700
    68.3 @@ -1186,7 +1186,7 @@
    68.4  static int ToolkitErrorHandler(Display * dpy, XErrorEvent * event) {
    68.5      if (jvm != NULL) {
    68.6          JNIEnv * env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
    68.7 -        return JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XToolkit", "GlobalErrorHandler", "(JJ)I",
    68.8 +        return JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XToolkit", "globalErrorHandler", "(JJ)I",
    68.9                                            ptr_to_jlong(dpy), ptr_to_jlong(event)).i;
   68.10      } else {
   68.11          return 0;
   68.12 @@ -1229,6 +1229,28 @@
   68.13      return (*(XErrorHandler)jlong_to_ptr(handler))((Display*) jlong_to_ptr(display), (XErrorEvent*) jlong_to_ptr(event_ptr));
   68.14  }
   68.15  
   68.16 +/*
   68.17 + * Class:     sun_awt_X11_XlibWrapper
   68.18 + * Method:    PrintXErrorEvent
   68.19 + * Signature: (JJ)V
   68.20 + */
   68.21 +JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_PrintXErrorEvent
   68.22 +(JNIEnv *env, jclass clazz, jlong display, jlong event_ptr)
   68.23 +{
   68.24 +    char msg[128];
   68.25 +    char buf[128];
   68.26 +
   68.27 +    XErrorEvent* err = (XErrorEvent *)jlong_to_ptr(event_ptr);
   68.28 +
   68.29 +    XGetErrorText((Display *)jlong_to_ptr(display), err->error_code, msg, sizeof(msg));
   68.30 +    jio_fprintf(stderr, "Xerror %s, XID %x, ser# %d\n", msg, err->resourceid, err->serial);
   68.31 +    jio_snprintf(buf, sizeof(buf), "%d", err->request_code);
   68.32 +    XGetErrorDatabaseText((Display *)jlong_to_ptr(display), "XRequest", buf, "Unknown", msg, sizeof(msg));
   68.33 +    jio_fprintf(stderr, "Major opcode %d (%s)\n", err->request_code, msg);
   68.34 +    if (err->request_code > 128) {
   68.35 +        jio_fprintf(stderr, "Minor opcode %d\n", err->minor_code);
   68.36 +    }
   68.37 +}
   68.38  
   68.39  
   68.40  /*
    69.1 --- a/src/windows/classes/sun/awt/windows/TranslucentWindowPainter.java	Thu May 14 10:58:07 2009 -0700
    69.2 +++ b/src/windows/classes/sun/awt/windows/TranslucentWindowPainter.java	Mon Jun 01 01:05:22 2009 -0700
    69.3 @@ -105,9 +105,10 @@
    69.4      }
    69.5  
    69.6      /**
    69.7 -     * Creates (if needed), clears and returns the buffer for this painter.
    69.8 +     * Creates (if needed), clears (if requested) and returns the buffer
    69.9 +     * for this painter.
   69.10       */
   69.11 -    protected abstract Image getBackBuffer();
   69.12 +    protected abstract Image getBackBuffer(boolean clear);
   69.13  
   69.14      /**
   69.15       * Updates the the window associated with this painter with the contents
   69.16 @@ -123,31 +124,16 @@
   69.17      public abstract void flush();
   69.18  
   69.19      /**
   69.20 -     * Updates the window associated with the painter given the passed image.
   69.21 -     * If the passed image is null the painter will use its own buffer for
   69.22 -     * rendering the contents of the window into it and updating the window.
   69.23 +     * Updates the window associated with the painter.
   69.24       *
   69.25 -     * If the passed buffer has dimensions different from the window, it is
   69.26 -     * copied into the internal buffer first and the latter is used to update
   69.27 -     * the window.
   69.28 -     *
   69.29 -     * @param bb the image to update the non opaque window with, or null.
   69.30 -     * If not null, the image must be of ARGB_PRE type.
   69.31 +     * @param repaint indicates if the window should be completely repainted
   69.32 +     * to the back buffer using {@link java.awt.Window#paintAll} before update.
   69.33       */
   69.34 -    public void updateWindow(Image bb) {
   69.35 +    public void updateWindow(boolean repaint) {
   69.36          boolean done = false;
   69.37 -        if (bb != null && (window.getWidth()  != bb.getWidth(null) ||
   69.38 -                           window.getHeight() != bb.getHeight(null)))
   69.39 -        {
   69.40 -            Image ourBB = getBackBuffer();
   69.41 -            Graphics2D g = (Graphics2D)ourBB.getGraphics();
   69.42 -            g.drawImage(bb, 0, 0, null);
   69.43 -            g.dispose();
   69.44 -            bb = ourBB;
   69.45 -        }
   69.46 -        do {
   69.47 -            if (bb == null) {
   69.48 -                bb = getBackBuffer();
   69.49 +        Image bb = getBackBuffer(repaint);
   69.50 +        while (!done) {
   69.51 +            if (repaint) {
   69.52                  Graphics2D g = (Graphics2D)bb.getGraphics();
   69.53                  try {
   69.54                      window.paintAll(g);
   69.55 @@ -156,17 +142,12 @@
   69.56                  }
   69.57              }
   69.58  
   69.59 -            peer.paintAppletWarning((Graphics2D)bb.getGraphics(),
   69.60 -                                    bb.getWidth(null), bb.getHeight(null));
   69.61 -
   69.62              done = update(bb);
   69.63 -            // in case they passed us a lost VI, next time around we'll use our
   69.64 -            // own bb because we can not validate and restore the contents of
   69.65 -            // their VI
   69.66              if (!done) {
   69.67 -                bb = null;
   69.68 +                repaint = true;
   69.69 +                bb = getBackBuffer(true);
   69.70              }
   69.71 -        } while (!done);
   69.72 +        }
   69.73      }
   69.74  
   69.75      private static final Image clearImage(Image bb) {
   69.76 @@ -190,30 +171,24 @@
   69.77       * method (VI, BI, regular Images).
   69.78       */
   69.79      private static class BIWindowPainter extends TranslucentWindowPainter {
   69.80 -        private WeakReference<BufferedImage> biRef;
   69.81 +        private BufferedImage backBuffer;
   69.82  
   69.83          protected BIWindowPainter(WWindowPeer peer) {
   69.84              super(peer);
   69.85          }
   69.86  
   69.87 -        private BufferedImage getBIBackBuffer() {
   69.88 +        @Override
   69.89 +        protected Image getBackBuffer(boolean clear) {
   69.90              int w = window.getWidth();
   69.91              int h = window.getHeight();
   69.92 -            BufferedImage bb = biRef == null ? null : biRef.get();
   69.93 -            if (bb == null || bb.getWidth() != w || bb.getHeight() != h) {
   69.94 -                if (bb != null) {
   69.95 -                    bb.flush();
   69.96 -                    bb = null;
   69.97 -                }
   69.98 -                bb = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE);
   69.99 -                biRef = new WeakReference<BufferedImage>(bb);
  69.100 +            if (backBuffer == null ||
  69.101 +                backBuffer.getWidth() != w ||
  69.102 +                backBuffer.getHeight() != h)
  69.103 +            {
  69.104 +                flush();
  69.105 +                backBuffer = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE);
  69.106              }
  69.107 -            return (BufferedImage)clearImage(bb);
  69.108 -        }
  69.109 -
  69.110 -        @Override
  69.111 -        protected Image getBackBuffer() {
  69.112 -            return getBIBackBuffer();
  69.113 +            return clear ? (BufferedImage)clearImage(backBuffer) : backBuffer;
  69.114          }
  69.115  
  69.116          @Override
  69.117 @@ -246,10 +221,7 @@
  69.118              }
  69.119  
  69.120              // copy the passed image into our own buffer, then upload
  69.121 -            BufferedImage bi = getBIBackBuffer();
  69.122 -            Graphics2D g = (Graphics2D)bi.getGraphics();
  69.123 -            g.setComposite(AlphaComposite.Src);
  69.124 -            g.drawImage(bb, 0, 0, null);
  69.125 +            BufferedImage bi = (BufferedImage)clearImage(backBuffer);
  69.126  
  69.127              int data[] =
  69.128                  ((DataBufferInt)bi.getRaster().getDataBuffer()).getData();
  69.129 @@ -259,8 +231,9 @@
  69.130          }
  69.131  
  69.132          public void flush() {
  69.133 -            if (biRef != null) {
  69.134 -                biRef.clear();
  69.135 +            if (backBuffer != null) {
  69.136 +                backBuffer.flush();
  69.137 +                backBuffer = null;
  69.138              }
  69.139          }
  69.140      }
  69.141 @@ -271,27 +244,22 @@
  69.142       * Java heap-based buffer (which is then uploaded to the layered window)
  69.143       */
  69.144      private static class VIWindowPainter extends BIWindowPainter {
  69.145 -        private WeakReference<VolatileImage> viRef;
  69.146 +        private VolatileImage viBB;
  69.147  
  69.148          protected VIWindowPainter(WWindowPeer peer) {
  69.149              super(peer);
  69.150          }
  69.151  
  69.152          @Override
  69.153 -        protected Image getBackBuffer() {
  69.154 +        protected Image getBackBuffer(boolean clear) {
  69.155              int w = window.getWidth();
  69.156              int h = window.getHeight();
  69.157              GraphicsConfiguration gc = peer.getGraphicsConfiguration();
  69.158  
  69.159 -            VolatileImage viBB = viRef == null ? null : viRef.get();
  69.160 -
  69.161              if (viBB == null || viBB.getWidth() != w || viBB.getHeight() != h ||
  69.162                  viBB.validate(gc) == IMAGE_INCOMPATIBLE)
  69.163              {
  69.164 -                if (viBB != null) {
  69.165 -                    viBB.flush();
  69.166 -                    viBB = null;
  69.167 -                }
  69.168 +                flush();
  69.169  
  69.170                  if (gc instanceof AccelGraphicsConfig) {
  69.171                      AccelGraphicsConfig agc = ((AccelGraphicsConfig)gc);
  69.172 @@ -303,21 +271,16 @@
  69.173                      viBB = gc.createCompatibleVolatileImage(w, h, TRANSLUCENT);
  69.174                  }
  69.175                  viBB.validate(gc);
  69.176 -                viRef = new WeakReference<VolatileImage>(viBB);
  69.177              }
  69.178  
  69.179 -            return clearImage(viBB);
  69.180 +            return clear ? clearImage(viBB) : viBB;
  69.181          }
  69.182  
  69.183          @Override
  69.184          public void flush() {
  69.185 -            if (viRef != null) {
  69.186 -                VolatileImage viBB = viRef.get();
  69.187 -                if (viBB != null) {
  69.188 -                    viBB.flush();
  69.189 -                    viBB = null;
  69.190 -                }
  69.191 -                viRef.clear();
  69.192 +            if (viBB != null) {
  69.193 +                viBB.flush();
  69.194 +                viBB = null;
  69.195              }
  69.196          }
  69.197      }
    70.1 --- a/src/windows/classes/sun/awt/windows/WCanvasPeer.java	Thu May 14 10:58:07 2009 -0700
    70.2 +++ b/src/windows/classes/sun/awt/windows/WCanvasPeer.java	Mon Jun 01 01:05:22 2009 -0700
    70.3 @@ -78,25 +78,6 @@
    70.4          super.paint(g);
    70.5      }
    70.6  
    70.7 -    public void print(Graphics g) {
    70.8 -        if (!(target instanceof Window) ||
    70.9 -            AWTAccessor.getWindowAccessor().isOpaque((Window)target))
   70.10 -        {
   70.11 -            Dimension d = ((Component)target).getSize();
   70.12 -            if (g instanceof Graphics2D ||
   70.13 -                g instanceof sun.awt.Graphics2Delegate) {
   70.14 -                // background color is setup correctly, so just use clearRect
   70.15 -                g.clearRect(0, 0, d.width, d.height);
   70.16 -            } else {
   70.17 -                // emulate clearRect
   70.18 -                g.setColor(((Component)target).getBackground());
   70.19 -                g.fillRect(0, 0, d.width, d.height);
   70.20 -                g.setColor(((Component)target).getForeground());
   70.21 -            }
   70.22 -        }
   70.23 -        super.print(g);
   70.24 -    }
   70.25 -
   70.26      public boolean shouldClearRectBeforePaint() {
   70.27          return eraseBackground;
   70.28      }
    71.1 --- a/src/windows/classes/sun/awt/windows/WComponentPeer.java	Thu May 14 10:58:07 2009 -0700
    71.2 +++ b/src/windows/classes/sun/awt/windows/WComponentPeer.java	Mon Jun 01 01:05:22 2009 -0700
    71.3 @@ -239,7 +239,8 @@
    71.4  
    71.5      private static final double BANDING_DIVISOR = 4.0;
    71.6      private native int[] createPrintedPixels(int srcX, int srcY,
    71.7 -                                             int srcW, int srcH);
    71.8 +                                             int srcW, int srcH,
    71.9 +                                             int alpha);
   71.10      public void print(Graphics g) {
   71.11  
   71.12          Component comp = (Component)target;
   71.13 @@ -261,7 +262,9 @@
   71.14              }
   71.15              int h = endY - startY + 1;
   71.16  
   71.17 -            int[] pix = createPrintedPixels(0, startY, totalW, h);
   71.18 +            Color bgColor = comp.getBackground();
   71.19 +            int[] pix = createPrintedPixels(0, startY, totalW, h,
   71.20 +                                            bgColor == null ? 255 : bgColor.getAlpha());
   71.21              if (pix != null) {
   71.22                  BufferedImage bim = new BufferedImage(totalW, h,
   71.23                                                BufferedImage.TYPE_INT_ARGB);
   71.24 @@ -488,13 +491,14 @@
   71.25          }
   71.26      }
   71.27  
   71.28 -    public void updateGraphicsData(GraphicsConfiguration gc) {
   71.29 +    public boolean updateGraphicsData(GraphicsConfiguration gc) {
   71.30          winGraphicsConfig = (Win32GraphicsConfig)gc;
   71.31          try {
   71.32              replaceSurfaceData();
   71.33          } catch (InvalidPipeException e) {
   71.34              // REMIND : what do we do if our surface creation failed?
   71.35          }
   71.36 +        return false;
   71.37      }
   71.38  
   71.39      //This will return null for Components not yet added to a Container
    72.1 --- a/src/windows/classes/sun/awt/windows/WObjectPeer.java	Thu May 14 10:58:07 2009 -0700
    72.2 +++ b/src/windows/classes/sun/awt/windows/WObjectPeer.java	Mon Jun 01 01:05:22 2009 -0700
    72.3 @@ -42,6 +42,9 @@
    72.4      // set from JNI if any errors in creating the peer occur
    72.5      protected Error createError = null;
    72.6  
    72.7 +    // used to synchronize the state of this peer
    72.8 +    private final Object stateLock = new Object();
    72.9 +
   72.10      public static WObjectPeer getPeerForTarget(Object t) {
   72.11          WObjectPeer peer = (WObjectPeer) WToolkit.targetToPeer(t);
   72.12          return peer;
   72.13 @@ -55,6 +58,10 @@
   72.14          return target;
   72.15      }
   72.16  
   72.17 +    public final Object getStateLock() {
   72.18 +        return stateLock;
   72.19 +    }
   72.20 +
   72.21      /*
   72.22       * Subclasses should override disposeImpl() instead of dispose(). Client
   72.23       * code should always invoke dispose(), never disposeImpl().
    73.1 --- a/src/windows/classes/sun/awt/windows/WRobotPeer.java	Thu May 14 10:58:07 2009 -0700
    73.2 +++ b/src/windows/classes/sun/awt/windows/WRobotPeer.java	Mon Jun 01 01:05:22 2009 -0700
    73.3 @@ -60,8 +60,6 @@
    73.4      }
    73.5      public native int getRGBPixelImpl(int x, int y);
    73.6  
    73.7 -    public native int getNumberOfButtons();
    73.8 -
    73.9      public int [] getRGBPixels(Rectangle bounds) {
   73.10          int pixelArray[] = new int[bounds.width*bounds.height];
   73.11          getRGBPixels(bounds.x, bounds.y, bounds.width, bounds.height, pixelArray);
    74.1 --- a/src/windows/classes/sun/awt/windows/WToolkit.java	Thu May 14 10:58:07 2009 -0700
    74.2 +++ b/src/windows/classes/sun/awt/windows/WToolkit.java	Mon Jun 01 01:05:22 2009 -0700
    74.3 @@ -982,6 +982,16 @@
    74.4          return areExtraMouseButtonsEnabled;
    74.5      }
    74.6  
    74.7 +    private native synchronized int getNumberOfButtonsImpl();
    74.8 +
    74.9 +    @Override
   74.10 +    public int getNumberOfButtons(){
   74.11 +        if (numberOfButtons == 0) {
   74.12 +            numberOfButtons = getNumberOfButtonsImpl();
   74.13 +        }
   74.14 +        return (numberOfButtons > MAX_BUTTONS_SUPPORTED)? MAX_BUTTONS_SUPPORTED : numberOfButtons;
   74.15 +    }
   74.16 +
   74.17      @Override
   74.18      public boolean isWindowOpacitySupported() {
   74.19          // supported in Win2K and later
    75.1 --- a/src/windows/classes/sun/awt/windows/WWindowPeer.java	Thu May 14 10:58:07 2009 -0700
    75.2 +++ b/src/windows/classes/sun/awt/windows/WWindowPeer.java	Mon Jun 01 01:05:22 2009 -0700
    75.3 @@ -54,7 +54,7 @@
    75.4  
    75.5      private boolean isOpaque;
    75.6  
    75.7 -    private volatile TranslucentWindowPainter painter;
    75.8 +    private TranslucentWindowPainter painter;
    75.9  
   75.10      /*
   75.11       * A key used for storing a list of active windows in AppContext. The value
   75.12 @@ -106,11 +106,13 @@
   75.13          GraphicsConfiguration gc = getGraphicsConfiguration();
   75.14          ((Win32GraphicsDevice)gc.getDevice()).removeDisplayChangedListener(this);
   75.15  
   75.16 -        TranslucentWindowPainter currentPainter = painter;
   75.17 -        if (currentPainter != null) {
   75.18 -            currentPainter.flush();
   75.19 -            // don't set the current one to null here; reduces the chances of
   75.20 -            // MT issues (like NPEs)
   75.21 +        synchronized (getStateLock()) {
   75.22 +            TranslucentWindowPainter currentPainter = painter;
   75.23 +            if (currentPainter != null) {
   75.24 +                currentPainter.flush();
   75.25 +                // don't set the current one to null here; reduces the chances of
   75.26 +                // MT issues (like NPEs)
   75.27 +            }
   75.28          }
   75.29  
   75.30          super.disposeImpl();
   75.31 @@ -178,9 +180,23 @@
   75.32  
   75.33          updateIconImages();
   75.34  
   75.35 -        updateShape();
   75.36 -        updateOpacity();
   75.37 -        updateOpaque();
   75.38 +        Shape shape = ((Window)target).getShape();
   75.39 +        if (shape != null) {
   75.40 +            applyShape(Region.getInstance(shape, null));
   75.41 +        }
   75.42 +
   75.43 +        float opacity = ((Window)target).getOpacity();
   75.44 +        if (opacity < 1.0f) {
   75.45 +            setOpacity(opacity);
   75.46 +        }
   75.47 +
   75.48 +        synchronized (getStateLock()) {
   75.49 +            // default value of a boolean field is 'false', so set isOpaque to
   75.50 +            // true here explicitly
   75.51 +            this.isOpaque = true;
   75.52 +            Color bgColor = ((Window)target).getBackground();
   75.53 +            setOpaque((bgColor == null) || (bgColor.getAlpha() == 255));
   75.54 +        }
   75.55      }
   75.56  
   75.57      native void createAwtWindow(WComponentPeer parent);
   75.58 @@ -214,7 +230,11 @@
   75.59              setAlwaysOnTop(alwaysOnTop);
   75.60          }
   75.61  
   75.62 -        updateWindow(null);
   75.63 +        synchronized (getStateLock()) {
   75.64 +            if (!isOpaque) {
   75.65 +                updateWindow(true);
   75.66 +            }
   75.67 +        }
   75.68      }
   75.69  
   75.70      // Synchronize the insets members (here & in helper) with actual window
   75.71 @@ -334,29 +354,6 @@
   75.72          }
   75.73      }
   75.74  
   75.75 -    private void updateShape() {
   75.76 -        Shape shape = ((Window)target).getShape();
   75.77 -        if (shape != null) {
   75.78 -            applyShape(Region.getInstance(shape, null));
   75.79 -        }
   75.80 -    }
   75.81 -
   75.82 -    private void updateOpacity() {
   75.83 -        float opacity = ((Window)target).getOpacity();
   75.84 -        if (opacity < 1.0f) {
   75.85 -            setOpacity(opacity);
   75.86 -        }
   75.87 -    }
   75.88 -
   75.89 -    private void updateOpaque() {
   75.90 -        this.isOpaque = true;
   75.91 -        // boolean opaque = ((Window)target).isOpaque();
   75.92 -        boolean opaque = AWTAccessor.getWindowAccessor().isOpaque((Window)target);
   75.93 -        if (!opaque) {
   75.94 -            setOpaque(opaque);
   75.95 -        }
   75.96 -    }
   75.97 -
   75.98      native void setMinSize(int width, int height);
   75.99  
  75.100  /*
  75.101 @@ -579,6 +576,26 @@
  75.102          }
  75.103      }
  75.104  
  75.105 +    @Override
  75.106 +    public Graphics getGraphics() {
  75.107 +        synchronized (getStateLock()) {
  75.108 +            if (!isOpaque) {
  75.109 +                return painter.getBackBuffer(false).getGraphics();
  75.110 +            }
  75.111 +        }
  75.112 +        return super.getGraphics();
  75.113 +    }
  75.114 +
  75.115 +    @Override
  75.116 +    public void setBackground(Color c) {
  75.117 +        super.setBackground(c);
  75.118 +        synchronized (getStateLock()) {
  75.119 +            if (!isOpaque && ((Window)target).isVisible()) {
  75.120 +                updateWindow(true);
  75.121 +            }
  75.122 +        }
  75.123 +    }
  75.124 +
  75.125      private native void setOpacity(int iOpacity);
  75.126  
  75.127      public void setOpacity(float opacity) {
  75.128 @@ -600,12 +617,23 @@
  75.129          }
  75.130  
  75.131          setOpacity(iOpacity);
  75.132 -        updateWindow(null);
  75.133 +
  75.134 +        synchronized (getStateLock()) {
  75.135 +            if (!isOpaque && ((Window)target).isVisible()) {
  75.136 +                updateWindow(true);
  75.137 +            }
  75.138 +        }
  75.139      }
  75.140  
  75.141      private native void setOpaqueImpl(boolean isOpaque);
  75.142  
  75.143      public void setOpaque(boolean isOpaque) {
  75.144 +        synchronized (getStateLock()) {
  75.145 +            if (this.isOpaque == isOpaque) {
  75.146 +                return;
  75.147 +            }
  75.148 +        }
  75.149 +
  75.150          Window target = (Window)getTarget();
  75.151  
  75.152          if (!isOpaque) {
  75.153 @@ -617,20 +645,17 @@
  75.154              }
  75.155          }
  75.156  
  75.157 -        boolean opaqueChanged = this.isOpaque != isOpaque;
  75.158          boolean isVistaOS = Win32GraphicsEnvironment.isVistaOS();
  75.159  
  75.160 -        if (opaqueChanged && !isVistaOS){
  75.161 +        if (!isVistaOS) {
  75.162              // non-Vista OS: only replace the surface data if the opacity
  75.163              // status changed (see WComponentPeer.isAccelCapable() for more)
  75.164              replaceSurfaceDataRecursively(target);
  75.165          }
  75.166  
  75.167 -        this.isOpaque = isOpaque;
  75.168 -
  75.169 -        setOpaqueImpl(isOpaque);
  75.170 -
  75.171 -        if (opaqueChanged) {
  75.172 +        synchronized (getStateLock()) {
  75.173 +            this.isOpaque = isOpaque;
  75.174 +            setOpaqueImpl(isOpaque);
  75.175              if (isOpaque) {
  75.176                  TranslucentWindowPainter currentPainter = painter;
  75.177                  if (currentPainter != null) {
  75.178 @@ -642,7 +667,7 @@
  75.179              }
  75.180          }
  75.181  
  75.182 -        if (opaqueChanged && isVistaOS) {
  75.183 +        if (isVistaOS) {
  75.184              // On Vista: setting the window non-opaque makes the window look
  75.185              // rectangular, though still catching the mouse clicks within
  75.186              // its shape only. To restore the correct visual appearance
  75.187 @@ -654,42 +679,33 @@
  75.188              }
  75.189          }
  75.190  
  75.191 -        updateWindow(null);
  75.192 +        if (((Window)target).isVisible()) {
  75.193 +            updateWindow(true);
  75.194 +        }
  75.195      }
  75.196  
  75.197      public native void updateWindowImpl(int[] data, int width, int height);
  75.198  
  75.199 -    public void updateWindow(BufferedImage backBuffer) {
  75.200 -        if (isOpaque) {
  75.201 -            return;
  75.202 -        }
  75.203 -
  75.204 -        Component target = (Component)this.target;
  75.205 -        if (target.getWidth() <= 0 || target.getHeight() <= 0) {
  75.206 -            return;
  75.207 -        }
  75.208 -
  75.209 -        TranslucentWindowPainter currentPainter = painter;
  75.210 -        if (currentPainter != null) {
  75.211 -            currentPainter.updateWindow(backBuffer);
  75.212 -        } else if (log.isLoggable(Level.FINER)) {
  75.213 -            log.log(Level.FINER,
  75.214 -                    "Translucent window painter is null in updateWindow");
  75.215 -        }
  75.216 +    public void updateWindow() {
  75.217 +        updateWindow(false);
  75.218      }
  75.219  
  75.220 -    /**
  75.221 -     * Paints the Applet Warning into the passed Graphics2D. This method is
  75.222 -     * called by the TranslucentWindowPainter before updating the layered
  75.223 -     * window.
  75.224 -     *
  75.225 -     * @param g Graphics context to paint the warning to
  75.226 -     * @param w the width of the area
  75.227 -     * @param h the height of the area
  75.228 -     * @see TranslucentWindowPainter
  75.229 -     */
  75.230 -    public void paintAppletWarning(Graphics2D g, int w, int h) {
  75.231 -        // REMIND: the applet warning needs to be painted here
  75.232 +    private void updateWindow(boolean repaint) {
  75.233 +        Window w = (Window)target;
  75.234 +        synchronized (getStateLock()) {
  75.235 +            if (isOpaque || !w.isVisible() ||
  75.236 +                (w.getWidth() <= 0) || (w.getHeight() <= 0))
  75.237 +            {
  75.238 +                return;
  75.239 +            }
  75.240 +            TranslucentWindowPainter currentPainter = painter;
  75.241 +            if (currentPainter != null) {
  75.242 +                currentPainter.updateWindow(repaint);
  75.243 +            } else if (log.isLoggable(Level.FINER)) {
  75.244 +                log.log(Level.FINER,
  75.245 +                        "Translucent window painter is null in updateWindow");
  75.246 +            }
  75.247 +        }
  75.248      }
  75.249  
  75.250      /*
    76.1 --- a/src/windows/native/sun/windows/awt_Component.cpp	Thu May 14 10:58:07 2009 -0700
    76.2 +++ b/src/windows/native/sun/windows/awt_Component.cpp	Mon Jun 01 01:05:22 2009 -0700
    76.3 @@ -30,6 +30,7 @@
    76.4  
    76.5  #include "jlong.h"
    76.6  #include "awt_AWTEvent.h"
    76.7 +#include "awt_BitmapUtil.h"
    76.8  #include "awt_Component.h"
    76.9  #include "awt_Cursor.h"
   76.10  #include "awt_Dimension.h"
   76.11 @@ -127,6 +128,7 @@
   76.12      jobject component;
   76.13      int srcx, srcy;
   76.14      int srcw, srch;
   76.15 +    jint alpha;
   76.16  };
   76.17  // Struct for _SetRectangularShape() method
   76.18  struct SetRectangularShapeStruct {
   76.19 @@ -361,8 +363,8 @@
   76.20  AwtComponent* AwtComponent::GetComponentImpl(HWND hWnd) {
   76.21      AwtComponent *component =
   76.22          (AwtComponent *)::GetWindowLongPtr(hWnd, GWLP_USERDATA);
   76.23 -    DASSERT( !IsBadReadPtr(component, sizeof(AwtComponent)) );
   76.24 -    DASSERT( component->GetHWnd() == hWnd );
   76.25 +    DASSERT(!component || !IsBadReadPtr(component, sizeof(AwtComponent)) );
   76.26 +    DASSERT(!component || component->GetHWnd() == hWnd );
   76.27      return component;
   76.28  }
   76.29  
   76.30 @@ -1918,11 +1920,14 @@
   76.31            mr = mrConsume;
   76.32            break;
   76.33        }
   76.34 -      case WM_AWT_CREATE_PRINTED_PIXELS:
   76.35 -          retValue = (LRESULT)CreatePrintedPixels(*((SIZE *)wParam),
   76.36 -                                                  *((SIZE *)lParam));
   76.37 +      case WM_AWT_CREATE_PRINTED_PIXELS: {
   76.38 +          CreatePrintedPixelsStruct* cpps = (CreatePrintedPixelsStruct*)wParam;
   76.39 +          SIZE loc = { cpps->srcx, cpps->srcy };
   76.40 +          SIZE size = { cpps->srcw, cpps->srch };
   76.41 +          retValue = (LRESULT)CreatePrintedPixels(loc, size, cpps->alpha);
   76.42            mr = mrConsume;
   76.43            break;
   76.44 +      }
   76.45        case WM_UNDOCUMENTED_CLICKMENUBAR:
   76.46        {
   76.47            if (::IsWindow(AwtWindow::GetModalBlocker(GetHWnd()))) {
   76.48 @@ -4526,18 +4531,20 @@
   76.49  
   76.50  void AwtComponent::FillAlpha(void *bitmapBits, SIZE &size, BYTE alpha)
   76.51  {
   76.52 -    if (bitmapBits) {
   76.53 -        DWORD* dest = (DWORD*)bitmapBits;
   76.54 -        //XXX: might be optimized to use one loop (cy*cx -> 0).
   76.55 -        for (int i = 0; i < size.cy; i++ ) {
   76.56 -            for (int j = 0; j < size.cx; j++ ) {
   76.57 -                ((BYTE*)(dest++))[3] = alpha;
   76.58 -            }
   76.59 +    if (!bitmapBits) {
   76.60 +        return;
   76.61 +    }
   76.62 +
   76.63 +    DWORD* dest = (DWORD*)bitmapBits;
   76.64 +    //XXX: might be optimized to use one loop (cy*cx -> 0)
   76.65 +    for (int i = 0; i < size.cy; i++ ) {
   76.66 +        for (int j = 0; j < size.cx; j++ ) {
   76.67 +            ((BYTE*)(dest++))[3] = alpha;
   76.68          }
   76.69      }
   76.70  }
   76.71  
   76.72 -jintArray AwtComponent::CreatePrintedPixels(SIZE &loc, SIZE &size) {
   76.73 +jintArray AwtComponent::CreatePrintedPixels(SIZE &loc, SIZE &size, int alpha) {
   76.74      JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
   76.75  
   76.76      if (!::IsWindowVisible(GetHWnd())) {
   76.77 @@ -4549,12 +4556,12 @@
   76.78          return NULL;
   76.79      }
   76.80      HDC hMemoryDC = ::CreateCompatibleDC(hdc);
   76.81 -    HBITMAP hBitmap = ::CreateCompatibleBitmap(hdc, size.cx, size.cy);
   76.82 +    void *bitmapBits = NULL;
   76.83 +    HBITMAP hBitmap = BitmapUtil::CreateARGBBitmap(size.cx, size.cy, &bitmapBits);
   76.84      HBITMAP hOldBitmap = (HBITMAP)::SelectObject(hMemoryDC, hBitmap);
   76.85      SendMessage(WM_AWT_RELEASEDC, (WPARAM)hdc);
   76.86  
   76.87 -    RECT eraseR = { 0, 0, size.cx, size.cy };
   76.88 -    VERIFY(::FillRect(hMemoryDC, &eraseR, GetBackgroundBrush()));
   76.89 +    FillBackground(hMemoryDC, size);
   76.90  
   76.91      VERIFY(::SetWindowOrgEx(hMemoryDC, loc.cx, loc.cy, NULL));
   76.92  
   76.93 @@ -4562,6 +4569,14 @@
   76.94      // above.
   76.95      SendMessage(WM_PRINT, (WPARAM)hMemoryDC, PRF_CLIENT | PRF_NONCLIENT);
   76.96  
   76.97 +    // First make sure the system completed any drawing to the bitmap.
   76.98 +    ::GdiFlush();
   76.99 +
  76.100 +    // WM_PRINT does not fill the alpha-channel of the ARGB bitmap
  76.101 +    // leaving it equal to zero. Hence we need to fill it manually. Otherwise
  76.102 +    // the pixels will be considered transparent when interpreting the data.
  76.103 +    FillAlpha(bitmapBits, size, alpha);
  76.104 +
  76.105      ::SelectObject(hMemoryDC, hOldBitmap);
  76.106  
  76.107      BITMAPINFO bmi;
  76.108 @@ -5937,10 +5952,6 @@
  76.109  
  76.110      CreatePrintedPixelsStruct *cpps = (CreatePrintedPixelsStruct *)param;
  76.111      jobject self = cpps->component;
  76.112 -    jint srcx = cpps->srcx;
  76.113 -    jint srcy = cpps->srcy;
  76.114 -    jint srcw = cpps->srcw;
  76.115 -    jint srch = cpps->srch;
  76.116  
  76.117      jintArray result = NULL;
  76.118      AwtComponent *c = NULL;
  76.119 @@ -5950,12 +5961,7 @@
  76.120      c = (AwtComponent *)pData;
  76.121      if (::IsWindow(c->GetHWnd()))
  76.122      {
  76.123 -        SIZE loc = { srcx, srcy };
  76.124 -        SIZE size = { srcw, srch };
  76.125 -
  76.126 -        result = (jintArray)
  76.127 -            c->SendMessage(WM_AWT_CREATE_PRINTED_PIXELS, (WPARAM)&loc,
  76.128 -                          (LPARAM)&size);
  76.129 +        result = (jintArray)c->SendMessage(WM_AWT_CREATE_PRINTED_PIXELS, (WPARAM)cpps, 0);
  76.130      }
  76.131  ret:
  76.132      env->DeleteGlobalRef(self);
  76.133 @@ -6749,7 +6755,7 @@
  76.134   */
  76.135  JNIEXPORT jintArray JNICALL
  76.136  Java_sun_awt_windows_WComponentPeer_createPrintedPixels(JNIEnv* env,
  76.137 -    jobject self, jint srcX, jint srcY, jint srcW, jint srcH)
  76.138 +    jobject self, jint srcX, jint srcY, jint srcW, jint srcH, jint alpha)
  76.139  {
  76.140      TRY;
  76.141  
  76.142 @@ -6761,6 +6767,7 @@
  76.143      cpps->srcy = srcY;
  76.144      cpps->srcw = srcW;
  76.145      cpps->srch = srcH;
  76.146 +    cpps->alpha = alpha;
  76.147  
  76.148      jintArray globalRef = (jintArray)AwtToolkit::GetInstance().SyncCall(
  76.149          (void*(*)(void*))AwtComponent::_CreatePrintedPixels, cpps);
    77.1 --- a/src/windows/native/sun/windows/awt_Component.h	Thu May 14 10:58:07 2009 -0700
    77.2 +++ b/src/windows/native/sun/windows/awt_Component.h	Mon Jun 01 01:05:22 2009 -0700
    77.3 @@ -596,7 +596,7 @@
    77.4  
    77.5      void UpdateColorModel();
    77.6  
    77.7 -    jintArray CreatePrintedPixels(SIZE &loc, SIZE &size);
    77.8 +    jintArray CreatePrintedPixels(SIZE &loc, SIZE &size, int alpha);
    77.9  
   77.10      /*
   77.11       * HWND, AwtComponent and Java Peer interaction
   77.12 @@ -738,7 +738,6 @@
   77.13      virtual void SetDragCapture(UINT flags);
   77.14      virtual void ReleaseDragCapture(UINT flags);
   77.15  
   77.16 -    //These functions are overridden in AwtWindow to handle non-opaque windows.
   77.17      virtual void FillBackground(HDC hMemoryDC, SIZE &size);
   77.18      virtual void FillAlpha(void *bitmapBits, SIZE &size, BYTE alpha);
   77.19  
    78.1 --- a/src/windows/native/sun/windows/awt_Robot.cpp	Thu May 14 10:58:07 2009 -0700
    78.2 +++ b/src/windows/native/sun/windows/awt_Robot.cpp	Mon Jun 01 01:05:22 2009 -0700
    78.3 @@ -437,9 +437,3 @@
    78.4  
    78.5      CATCH_BAD_ALLOC;
    78.6  }
    78.7 -
    78.8 -JNIEXPORT jint JNICALL Java_sun_awt_windows_WRobotPeer_getNumberOfButtons(
    78.9 -  JNIEnv *, jobject self)
   78.10 -{
   78.11 -    return GetSystemMetrics(SM_CMOUSEBUTTONS);
   78.12 -}
    79.1 --- a/src/windows/native/sun/windows/awt_Toolkit.cpp	Thu May 14 10:58:07 2009 -0700
    79.2 +++ b/src/windows/native/sun/windows/awt_Toolkit.cpp	Mon Jun 01 01:05:22 2009 -0700
    79.3 @@ -2259,3 +2259,8 @@
    79.4  void AwtToolkit::setExtraMouseButtonsEnabled(BOOL enable) {
    79.5      m_areExtraMouseButtonsEnabled = enable;
    79.6  }
    79.7 +
    79.8 +JNIEXPORT jint JNICALL Java_sun_awt_windows_WToolkit_getNumberOfButtonsImpl
    79.9 +(JNIEnv *, jobject self) {
   79.10 +    return GetSystemMetrics(SM_CMOUSEBUTTONS);
   79.11 +}
    80.1 --- a/src/windows/native/sun/windows/awt_Window.cpp	Thu May 14 10:58:07 2009 -0700
    80.2 +++ b/src/windows/native/sun/windows/awt_Window.cpp	Mon Jun 01 01:05:22 2009 -0700
    80.3 @@ -464,7 +464,7 @@
    80.4          size_t length = env->GetStringLength(javaWarningString) + 1;
    80.5          warningString = new WCHAR[length];
    80.6          env->GetStringRegion(javaWarningString, 0,
    80.7 -                static_cast<jsize>(length - 1), warningString);
    80.8 +                static_cast<jsize>(length - 1), reinterpret_cast<jchar*>(warningString));
    80.9          warningString[length-1] = L'\0';
   80.10  
   80.11          env->DeleteLocalRef(javaWarningString);
   80.12 @@ -2651,20 +2651,6 @@
   80.13      ::LeaveCriticalSection(&contentBitmapCS);
   80.14  }
   80.15  
   80.16 -void AwtWindow::FillBackground(HDC hMemoryDC, SIZE &size)
   80.17 -{
   80.18 -    if (isOpaque()) {
   80.19 -        AwtCanvas::FillBackground(hMemoryDC, size);
   80.20 -    }
   80.21 -}
   80.22 -
   80.23 -void AwtWindow::FillAlpha(void *bitmapBits, SIZE &size, BYTE alpha)
   80.24 -{
   80.25 -    if (isOpaque()) {
   80.26 -        AwtCanvas::FillAlpha(bitmapBits, size, alpha);
   80.27 -    }
   80.28 -}
   80.29 -
   80.30  /*
   80.31   * Fixed 6353381: it's improved fix for 4792958
   80.32   * which was backed-out to avoid 5059656
    81.1 --- a/src/windows/native/sun/windows/awt_Window.h	Thu May 14 10:58:07 2009 -0700
    81.2 +++ b/src/windows/native/sun/windows/awt_Window.h	Mon Jun 01 01:05:22 2009 -0700
    81.3 @@ -343,11 +343,6 @@
    81.4      BOOL m_iconInherited;     /* TRUE if icon is inherited from the owner */
    81.5      BOOL m_filterFocusAndActivation; /* Used in the WH_CBT hook */
    81.6  
    81.7 -    //These are used in AwtComponent::CreatePrintedPixels. They are overridden
    81.8 -    //here to handle non-opaque windows.
    81.9 -    virtual void FillBackground(HDC hMemoryDC, SIZE &size);
   81.10 -    virtual void FillAlpha(void *bitmapBits, SIZE &size, BYTE alpha);
   81.11 -
   81.12      inline BOOL IsUntrusted() {
   81.13          return warningString != NULL;
   81.14      }
    82.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    82.2 +++ b/test/javax/swing/JComponent/6683775/bug6683775.java	Mon Jun 01 01:05:22 2009 -0700
    82.3 @@ -0,0 +1,82 @@
    82.4 +/* @test
    82.5 +   @bug 6683775 6794764
    82.6 +   @summary Painting artifacts is seen when panel is made setOpaque(false) for a translucent window
    82.7 +   @author Alexander Potochkin
    82.8 +   @run main bug6683775
    82.9 +*/
   82.10 +
   82.11 +import com.sun.awt.AWTUtilities;
   82.12 +import sun.awt.SunToolkit;
   82.13 +
   82.14 +import javax.swing.*;
   82.15 +import java.awt.*;
   82.16 +import java.awt.image.BufferedImage;
   82.17 +
   82.18 +public class bug6683775 {
   82.19 +    public static void main(String[] args) throws Exception {
   82.20 +        GraphicsConfiguration gc = getGC();
   82.21 +        if (!AWTUtilities.isTranslucencySupported(
   82.22 +                AWTUtilities.Translucency.PERPIXEL_TRANSLUCENT)
   82.23 +                || gc == null) {
   82.24 +            return;
   82.25 +        }
   82.26 +        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
   82.27 +        Robot robot = new Robot();
   82.28 +        final JFrame testFrame = new JFrame(gc);
   82.29 +
   82.30 +        SwingUtilities.invokeLater(new Runnable() {
   82.31 +            public void run() {
   82.32 +                JFrame backgroundFrame = new JFrame("Background frame");
   82.33 +                backgroundFrame.setUndecorated(true);
   82.34 +                JPanel panel = new JPanel();
   82.35 +                panel.setBackground(Color.RED);
   82.36 +                backgroundFrame.add(panel);
   82.37 +                backgroundFrame.setSize(200, 200);
   82.38 +                backgroundFrame.setVisible(true);
   82.39 +
   82.40 +                testFrame.setUndecorated(true);
   82.41 +                JPanel p = new JPanel();
   82.42 +                p.setOpaque(false);
   82.43 +                testFrame.add(p);
   82.44 +                AWTUtilities.setWindowOpaque(testFrame, false);
   82.45 +                testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   82.46 +                testFrame.setSize(400, 400);
   82.47 +                testFrame.setLocation(0, 0);
   82.48 +                testFrame.setVisible(true);
   82.49 +            }
   82.50 +        });
   82.51 +
   82.52 +        toolkit.realSync();
   82.53 +
   82.54 +        //robot.getPixelColor() didn't work right for some reason
   82.55 +        BufferedImage capture = robot.createScreenCapture(new Rectangle(100, 100));
   82.56 +
   82.57 +        int redRGB = Color.RED.getRGB();
   82.58 +        if (redRGB != capture.getRGB(10, 10)) {
   82.59 +            throw new RuntimeException("Transparent frame is not transparent!");
   82.60 +        }
   82.61 +    }
   82.62 +
   82.63 +    private static GraphicsConfiguration getGC() {
   82.64 +        GraphicsConfiguration transparencyCapableGC =
   82.65 +                GraphicsEnvironment.getLocalGraphicsEnvironment()
   82.66 +                        .getDefaultScreenDevice().getDefaultConfiguration();
   82.67 +        if (!AWTUtilities.isTranslucencyCapable(transparencyCapableGC)) {
   82.68 +            transparencyCapableGC = null;
   82.69 +
   82.70 +            GraphicsEnvironment env =
   82.71 +                    GraphicsEnvironment.getLocalGraphicsEnvironment();
   82.72 +            GraphicsDevice[] devices = env.getScreenDevices();
   82.73 +
   82.74 +            for (int i = 0; i < devices.length && transparencyCapableGC == null; i++) {
   82.75 +                GraphicsConfiguration[] configs = devices[i].getConfigurations();
   82.76 +                for (int j = 0; j < configs.length && transparencyCapableGC == null; j++) {
   82.77 +                    if (AWTUtilities.isTranslucencyCapable(configs[j])) {
   82.78 +                        transparencyCapableGC = configs[j];
   82.79 +                    }
   82.80 +                }
   82.81 +            }
   82.82 +        }
   82.83 +        return transparencyCapableGC;
   82.84 +    }
   82.85 +}
    83.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    83.2 +++ b/test/javax/swing/JInternalFrame/6726866/bug6726866.html	Mon Jun 01 01:05:22 2009 -0700
    83.3 @@ -0,0 +1,7 @@
    83.4 +<html>
    83.5 +<body>
    83.6 +<applet  code="bug6726866.class" width=400 height=100></applet>
    83.7 +Drag the internal frame inside the green undecorated window,
    83.8 +if you can drag it the test passes, otherwise fails.
    83.9 +</body>
   83.10 +</html>
    84.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    84.2 +++ b/test/javax/swing/JInternalFrame/6726866/bug6726866.java	Mon Jun 01 01:05:22 2009 -0700
    84.3 @@ -0,0 +1,44 @@
    84.4 +/* @test
    84.5 +   @bug 6726866
    84.6 +   @summary Repainting artifacts when resizing or dragging JInternalFrames in non-opaque toplevel
    84.7 +   @author Alexander Potochkin
    84.8 +   @run applet/manual=yesno bug6726866.html
    84.9 +*/
   84.10 +
   84.11 +import javax.swing.*;
   84.12 +import java.awt.*;
   84.13 +import java.lang.reflect.Method;
   84.14 +
   84.15 +public class bug6726866 extends JApplet {
   84.16 +
   84.17 +    public void init() {
   84.18 +        JFrame frame = new JFrame("bug6726866");
   84.19 +        frame.setUndecorated(true);
   84.20 +        setWindowNonOpaque(frame);
   84.21 +
   84.22 +        JDesktopPane desktop = new JDesktopPane();
   84.23 +        desktop.setBackground(Color.GREEN);
   84.24 +        JInternalFrame iFrame = new JInternalFrame("Test", true, true, true, true);
   84.25 +        iFrame.add(new JLabel("internal Frame"));
   84.26 +        iFrame.setBounds(10, 10, 300, 200);
   84.27 +        iFrame.setVisible(true);
   84.28 +        desktop.add(iFrame);
   84.29 +        frame.add(desktop);
   84.30 +
   84.31 +        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   84.32 +        frame.setSize(400, 400);
   84.33 +        frame.setVisible(true);
   84.34 +        frame.toFront();
   84.35 +    }
   84.36 +
   84.37 +    private void setWindowNonOpaque(Window w) {
   84.38 +        try {
   84.39 +            Class<?> c = Class.forName("com.sun.awt.AWTUtilities");
   84.40 +            Method m = c.getMethod("setWindowOpaque", Window.class, boolean.class);
   84.41 +            m.invoke(null, w, false);
   84.42 +        }
   84.43 +        catch (Exception e) {
   84.44 +            e.printStackTrace();
   84.45 +        }
   84.46 +    }
   84.47 +}