Merge
authorlana
Mon, 18 Oct 2010 21:44:47 -0700
changeset 6830 1fe56588acb1
parent 6818 feb638afc792 (current diff)
parent 6829 b348b1dcad94 (diff)
child 6844 cb9628ae9369
Merge
jdk/src/share/native/sun/awt/splashscreen/splashscreen_gif.c
--- a/jdk/src/share/classes/java/awt/AWTEvent.java	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/share/classes/java/awt/AWTEvent.java	Mon Oct 18 21:44:47 2010 -0700
@@ -101,6 +101,12 @@
     transient boolean isPosted;
 
     /**
+     * Indicates whether this AWTEvent was generated by the system as
+     * opposed to by user code.
+     */
+    private transient boolean isSystemGenerated;
+
+    /**
      * The event mask for selecting component events.
      */
     public final static long COMPONENT_EVENT_MASK = 0x01;
@@ -235,6 +241,12 @@
                 public void setPosted(AWTEvent ev) {
                     ev.isPosted = true;
                 }
+                public void setSystemGenerated(AWTEvent ev) {
+                    ev.isSystemGenerated = true;
+                }
+                public boolean isSystemGenerated(AWTEvent ev) {
+                    return ev.isSystemGenerated;
+                }
             });
     }
 
@@ -554,6 +566,7 @@
                 }
             }
         }
+        that.isSystemGenerated = this.isSystemGenerated;
     }
 
     void dispatched() {
--- a/jdk/src/share/classes/java/awt/Canvas.java	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/share/classes/java/awt/Canvas.java	Mon Oct 18 21:44:47 2010 -0700
@@ -71,12 +71,13 @@
 
     @Override
     void setGraphicsConfiguration(GraphicsConfiguration gc) {
-        CanvasPeer peer = (CanvasPeer)getPeer();
-        if (peer != null) {
-            gc = peer.getAppropriateGraphicsConfiguration(gc);
+        synchronized(getTreeLock()) {
+            CanvasPeer peer = (CanvasPeer)getPeer();
+            if (peer != null) {
+                gc = peer.getAppropriateGraphicsConfiguration(gc);
+            }
+            super.setGraphicsConfiguration(gc);
         }
-
-        super.setGraphicsConfiguration(gc);
     }
 
     /**
--- a/jdk/src/share/classes/java/awt/Container.java	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/share/classes/java/awt/Container.java	Mon Oct 18 21:44:47 2010 -0700
@@ -4187,7 +4187,7 @@
             return true;
         }
 
-        for (Container cont = getContainer();
+        for (Container cont = this;
                 cont != null && cont.isLightweight();
                 cont = cont.getContainer())
         {
--- a/jdk/src/share/classes/java/awt/SequencedEvent.java	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/share/classes/java/awt/SequencedEvent.java	Mon Oct 18 21:44:47 2010 -0700
@@ -64,6 +64,9 @@
     public SequencedEvent(AWTEvent nested) {
         super(nested.getSource(), ID);
         this.nested = nested;
+        // All AWTEvents that are wrapped in SequencedEvents are (at
+        // least currently) implicitly generated by the system
+        SunToolkit.setSystemGenerated(nested);
         synchronized (SequencedEvent.class) {
             list.add(this);
         }
--- a/jdk/src/share/classes/java/awt/SplashScreen.java	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/share/classes/java/awt/SplashScreen.java	Mon Oct 18 21:44:47 2010 -0700
@@ -318,6 +318,12 @@
             checkVisible();
             _close(splashPtr);
             image = null;
+            SplashScreen.markClosed();
+        }
+    }
+
+    static void markClosed() {
+        synchronized (SplashScreen.class) {
             wasClosed = true;
             theInstance = null;
         }
--- a/jdk/src/share/classes/java/awt/Window.java	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/share/classes/java/awt/Window.java	Mon Oct 18 21:44:47 2010 -0700
@@ -928,7 +928,10 @@
             return;
         }
         if (beforeFirstWindowShown.getAndSet(false)) {
+            // We don't use SplashScreen.getSplashScreen() to avoid instantiating
+            // the object if it hasn't been requested by user code explicitly
             SunToolkit.closeSplashScreen();
+            SplashScreen.markClosed();
         }
     }
 
--- a/jdk/src/share/classes/java/awt/event/InputEvent.java	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/share/classes/java/awt/event/InputEvent.java	Mon Oct 18 21:44:47 2010 -0700
@@ -29,8 +29,10 @@
 import java.awt.Component;
 import java.awt.GraphicsEnvironment;
 import java.awt.Toolkit;
+import java.util.Arrays;
+
+import sun.awt.AWTAccessor;
 import sun.util.logging.PlatformLogger;
-import java.util.Arrays;
 
 /**
  * The root event class for all component-level input events.
@@ -54,6 +56,7 @@
  * @since 1.1
  */
 public abstract class InputEvent extends ComponentEvent {
+
     private static final PlatformLogger logger = PlatformLogger.getLogger("java.awt.event.InputEvent");
 
     /**
@@ -288,6 +291,12 @@
         if (!GraphicsEnvironment.isHeadless()) {
             initIDs();
         }
+        AWTAccessor.setInputEventAccessor(
+            new AWTAccessor.InputEventAccessor() {
+                public int[] getButtonDownMasks() {
+                    return getButtonDownMasks();
+                }
+            });
     }
 
     /**
--- a/jdk/src/share/classes/sun/awt/AWTAccessor.java	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/share/classes/sun/awt/AWTAccessor.java	Mon Oct 18 21:44:47 2010 -0700
@@ -26,6 +26,7 @@
 package sun.awt;
 
 import java.awt.*;
+import java.awt.event.InputEvent;
 import java.awt.geom.Point2D;
 import java.awt.image.BufferedImage;
 
@@ -301,6 +302,24 @@
          * Marks the event as posted.
          */
         void setPosted(AWTEvent ev);
+
+        /**
+         * Sets the flag on this AWTEvent indicating that it was
+         * generated by the system.
+         */
+        void setSystemGenerated(AWTEvent ev);
+
+        /**
+         * Indicates whether this AWTEvent was generated by the system.
+         */
+        boolean isSystemGenerated(AWTEvent ev);
+    }
+
+    public interface InputEventAccessor {
+        /*
+         * Accessor for InputEvent.getButtonDownMasks()
+         */
+        int[] getButtonDownMasks();
     }
 
     /*
@@ -436,6 +455,11 @@
     private static AWTEventAccessor awtEventAccessor;
 
     /*
+     * The java.awt.event.InputEvent class accessor object.
+     */
+    private static InputEventAccessor inputEventAccessor;
+
+    /*
      * The java.awt.Frame class accessor object.
      */
     private static FrameAccessor frameAccessor;
@@ -518,6 +542,23 @@
     }
 
     /*
+     * Set an accessor object for the java.awt.event.InputEvent class.
+     */
+    public static void setInputEventAccessor(InputEventAccessor iea) {
+        inputEventAccessor = iea;
+    }
+
+    /*
+     * Retrieve the accessor object for the java.awt.event.InputEvent class.
+     */
+    public static InputEventAccessor getInputEventAccessor() {
+        if (inputEventAccessor == null) {
+            unsafe.ensureClassInitialized(InputEvent.class);
+        }
+        return inputEventAccessor;
+    }
+
+    /*
      * Set an accessor object for the java.awt.Frame class.
      */
     public static void setFrameAccessor(FrameAccessor fa) {
--- a/jdk/src/share/classes/sun/awt/SunToolkit.java	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/share/classes/sun/awt/SunToolkit.java	Mon Oct 18 21:44:47 2010 -0700
@@ -313,6 +313,11 @@
      */
     public static AppContext createNewAppContext() {
         ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
+        // Create appContext before initialization of EventQueue, so all
+        // the calls to AppContext.getAppContext() from EventQueue ctor
+        // return correct values
+        AppContext appContext = new AppContext(threadGroup);
+
         EventQueue eventQueue;
         String eqName = System.getProperty("AWT.EventQueueClass",
                                            "java.awt.EventQueue");
@@ -322,7 +327,6 @@
             System.err.println("Failed loading " + eqName + ": " + e);
             eventQueue = new EventQueue();
         }
-        AppContext appContext = new AppContext(threadGroup);
         appContext.put(AppContext.EVENT_QUEUE_KEY, eventQueue);
 
         PostEventQueue postEventQueue = new PostEventQueue(eventQueue);
@@ -587,6 +591,12 @@
         if (event == null) {
             throw new NullPointerException();
         }
+        // All events posted via this method are system-generated.
+        // Placing the following call here reduces considerably the
+        // number of places throughout the toolkit that would
+        // otherwise have to be modified to precisely identify
+        // system-generated events.
+        setSystemGenerated(event);
         AppContext eventContext = targetToAppContext(event.getSource());
         if (eventContext != null && !eventContext.equals(appContext)) {
             log.fine("Event posted on wrong app context : " + event);
@@ -2089,6 +2099,25 @@
         }
         return isInstanceOf(cls.getSuperclass(), type);
     }
+
+    ///////////////////////////////////////////////////////////////////////////
+    //
+    // The following methods help set and identify whether a particular
+    // AWTEvent object was produced by the system or by user code. As of this
+    // writing the only consumer is the Java Plug-In, although this information
+    // could be useful to more clients and probably should be formalized in
+    // the public API.
+    //
+    ///////////////////////////////////////////////////////////////////////////
+
+    public static void setSystemGenerated(AWTEvent e) {
+        AWTAccessor.getAWTEventAccessor().setSystemGenerated(e);
+    }
+
+    public static boolean isSystemGenerated(AWTEvent e) {
+        return AWTAccessor.getAWTEventAccessor().isSystemGenerated(e);
+    }
+
 } // class SunToolkit
 
 
--- a/jdk/src/share/native/sun/awt/libpng/pngrtran.c	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/share/native/sun/awt/libpng/pngrtran.c	Mon Oct 18 21:44:47 2010 -0700
@@ -3993,7 +3993,7 @@
 
 #ifdef PNG_FLOATING_POINT_SUPPORTED
 #if defined(PNG_READ_GAMMA_SUPPORTED)
-const static int png_gamma_shift[] =
+static PNG_CONST int png_gamma_shift[] =
    {0x10, 0x21, 0x42, 0x84, 0x110, 0x248, 0x550, 0xff0, 0x00};
 
 /* We build the 8- or 16-bit gamma tables here.  Note that for 16-bit
--- a/jdk/src/share/native/sun/awt/libpng/pngrutil.c	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/share/native/sun/awt/libpng/pngrutil.c	Mon Oct 18 21:44:47 2010 -0700
@@ -209,7 +209,7 @@
                               png_charp chunkdata, png_size_t chunklength,
                               png_size_t prefix_size, png_size_t *newlength)
 {
-   const static char msg[] = "Error decoding compressed text";
+   static PNG_CONST char msg[] = "Error decoding compressed text";
    png_charp text;
    png_size_t text_size;
 
--- a/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gif.c	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gif.c	Mon Oct 18 21:44:47 2010 -0700
@@ -51,7 +51,7 @@
 #define NSEXT_LOOP      0x01    // Loop Count field code
 
 // convert libungif samples to our ones
-#define MAKE_QUAD_GIF(c,a) MAKE_QUAD((c).Red, (c).Green, (c).Blue, (a))
+#define MAKE_QUAD_GIF(c,a) MAKE_QUAD((c).Red, (c).Green, (c).Blue, (unsigned)(a))
 
 /* stdio FILE* and memory input functions for libungif */
 int
@@ -165,7 +165,7 @@
                 {
                     int flag = pExtension[0];
 
-                    frameDelay = (pExtension[2] << 8) | pExtension[1];
+                    frameDelay = (((int)pExtension[2]) << 8) | pExtension[1];
                     if (frameDelay < 10)
                         frameDelay = 10;
                     if (flag & GIF_TRANSPARENT) {
@@ -191,7 +191,7 @@
                         iSubCode = pExtension[0] & 0x07;
                         if (iSubCode == NSEXT_LOOP) {
                             splash->loopCount =
-                                (pExtension[1] | (pExtension[2] << 8)) - 1;
+                                (pExtension[1] | (((int)pExtension[2]) << 8)) - 1;
                         }
                     }
                     break;
--- a/jdk/src/solaris/classes/sun/awt/X11/InfoWindow.java	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/InfoWindow.java	Mon Oct 18 21:44:47 2010 -0700
@@ -432,7 +432,7 @@
                     ActionEvent aev = new ActionEvent(target, ActionEvent.ACTION_PERFORMED,
                                                       liveArguments.getActionCommand(),
                                                       e.getWhen(), e.getModifiers());
-                    Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(aev);
+                    XToolkit.postEvent(XToolkit.targetToAppContext(aev.getSource()), aev);
                 }
             }
         }
--- a/jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java	Mon Oct 18 21:44:47 2010 -0700
@@ -87,11 +87,15 @@
     }
 
     void postInit(XCreateWindowParams params) {
+        // The size hints must be set BEFORE mapping the window (see 6895647)
+        updateSizeHints(dimensions);
+
+        // The super method maps the window if it's visible on the shared level
         super.postInit(params);
+
         // The lines that follow need to be in a postInit, so they
         // happen after the X window is created.
         initResizability();
-        updateSizeHints(dimensions);
         XWM.requestWMExtents(getWindow());
 
         content = XContentWindow.createContent(this);
--- a/jdk/src/solaris/classes/sun/awt/X11/XRobotPeer.java	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XRobotPeer.java	Mon Oct 18 21:44:47 2010 -0700
@@ -25,11 +25,15 @@
 package sun.awt.X11;
 
 import java.awt.*;
+import java.awt.event.InputEvent;
 import java.awt.peer.*;
+
+import sun.awt.AWTAccessor;
+import sun.awt.SunToolkit;
 import sun.awt.X11GraphicsConfig;
-import sun.awt.SunToolkit;
 
 class XRobotPeer implements RobotPeer {
+
     private X11GraphicsConfig   xgc = null;
     /*
      * native implementation uses some static shared data (pipes, processes)
@@ -40,7 +44,7 @@
     XRobotPeer(GraphicsConfiguration gc) {
         this.xgc = (X11GraphicsConfig)gc;
         SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
-        setup(tk.getNumberOfButtons());
+        setup(tk.getNumberOfButtons(), AWTAccessor.getInputEventAccessor().getButtonDownMasks());
     }
 
     public void dispose() {
@@ -83,7 +87,7 @@
         return pixelArray;
     }
 
-    private static native synchronized void setup(int numberOfButtons);
+    private static native synchronized void setup(int numberOfButtons, int[] buttonDownMasks);
 
     private static native synchronized void mouseMoveImpl(X11GraphicsConfig xgc, int x, int y);
     private static native synchronized void mousePressImpl(int buttons);
--- a/jdk/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java	Mon Oct 18 21:44:47 2010 -0700
@@ -61,6 +61,7 @@
 import java.awt.im.InputMethodRequests;
 import sun.awt.CausedFocusEvent;
 import sun.awt.AWTAccessor;
+import sun.awt.SunToolkit;
 
 
 class XTextAreaPeer extends XComponentPeer implements TextAreaPeer {
@@ -1318,13 +1319,18 @@
             Component source, Point point, MouseEvent template )
         {
             MouseEvent e = template;
-            return new MouseEvent(
+            MouseEvent nme = new MouseEvent(
                 source,
                 e.getID(), e.getWhen(),
                 e.getModifiersEx() | e.getModifiers(),
                 point.x, point.y,
                 e.getXOnScreen(), e.getYOnScreen(),
                 e.getClickCount(), e.isPopupTrigger(), e.getButton() );
+            // Because these MouseEvents are dispatched directly to
+            // their target, we need to mark them as being
+            // system-generated here
+            SunToolkit.setSystemGenerated(nme);
+            return nme;
         }
 
         private void setCursor() {
--- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java	Mon Oct 18 21:44:47 2010 -0700
@@ -377,22 +377,22 @@
             init();
             XWM.init();
             SunToolkit.setDataTransfererClassName(DATA_TRANSFERER_CLASS_NAME);
-            toolkitThread = new Thread(this, "AWT-XAWT");
-            toolkitThread.setPriority(Thread.NORM_PRIORITY + 1);
-            toolkitThread.setDaemon(true);
-            ThreadGroup mainTG = (ThreadGroup)AccessController.doPrivileged(
-                                                                            new PrivilegedAction() {
-                                                                                    public Object run() {
-                                                                                        ThreadGroup currentTG =
-                                                                                            Thread.currentThread().getThreadGroup();
-                                                                                        ThreadGroup parentTG = currentTG.getParent();
-                                                                                        while (parentTG != null) {
-                                                                                            currentTG = parentTG;
-                                                                                            parentTG = currentTG.getParent();
-                                                                                        }
-                                                                                        return currentTG;
-                                                                                    }
-                                                                                });
+
+            PrivilegedAction<Thread> action = new PrivilegedAction() {
+                public Thread run() {
+                    ThreadGroup currentTG = Thread.currentThread().getThreadGroup();
+                    ThreadGroup parentTG = currentTG.getParent();
+                    while (parentTG != null) {
+                        currentTG = parentTG;
+                        parentTG = currentTG.getParent();
+                    }
+                    Thread thread = new Thread(currentTG, XToolkit.this, "AWT-XAWT");
+                    thread.setPriority(Thread.NORM_PRIORITY + 1);
+                    thread.setDaemon(true);
+                    return thread;
+                }
+            };
+            toolkitThread = AccessController.doPrivileged(action);
             toolkitThread.start();
         }
     }
--- a/jdk/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java	Mon Oct 18 21:44:47 2010 -0700
@@ -454,7 +454,7 @@
                 ActionEvent aev = new ActionEvent(xtiPeer.target, ActionEvent.ACTION_PERFORMED,
                                                   xtiPeer.target.getActionCommand(), e.getWhen(),
                                                   e.getModifiers());
-                Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(aev);
+                XToolkit.postEvent(XToolkit.targetToAppContext(aev.getSource()), aev);
             }
             if (xtiPeer.balloon.isVisible()) {
                 xtiPeer.balloon.hide();
--- a/jdk/src/solaris/classes/sun/awt/X11/XWindow.java	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XWindow.java	Mon Oct 18 21:44:47 2010 -0700
@@ -401,6 +401,8 @@
         if (isPostedField == null) {
             isPostedField = SunToolkit.getField(AWTEvent.class, "isPosted");
         }
+        // The uses of this method imply that the incoming event is system-generated
+        SunToolkit.setSystemGenerated(e);
         PeerEvent pe = new PeerEvent(Toolkit.getDefaultToolkit(), new Runnable() {
                 public void run() {
                     try {
@@ -779,7 +781,7 @@
                                                           xbe.get_x_root(),
                                                           xbe.get_y_root(),
                                                           1,false,MouseWheelEvent.WHEEL_UNIT_SCROLL,
-                                                          3,button==4 ?  -1*clickCount : 1*clickCount);
+                                                          3,button==4 ?  -1 : 1);
                 postEventToEventQueue(mwe);
             }
         }
--- a/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java	Mon Oct 18 21:44:47 2010 -0700
@@ -604,7 +604,9 @@
     public void handleWindowFocusIn_Dispatch() {
         if (EventQueue.isDispatchThread()) {
             XKeyboardFocusManagerPeer.setCurrentNativeFocusedWindow((Window) target);
-            target.dispatchEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_GAINED_FOCUS));
+            WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_GAINED_FOCUS);
+            SunToolkit.setSystemGenerated(we);
+            target.dispatchEvent(we);
         }
     }
 
--- a/jdk/src/solaris/native/sun/awt/awt.h	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/solaris/native/sun/awt/awt.h	Mon Oct 18 21:44:47 2010 -0700
@@ -159,20 +159,8 @@
 #endif /* DEBUG_AWT_LOCK && !XAWT */
 
 #ifndef HEADLESS
-extern Display         *awt_display;            /* awt_GraphicsEnv.c */
-extern XtAppContext     awt_appContext;         /* awt_MToolkit.c */
-extern Widget           awt_root_shell;
-extern Pixel            awt_defaultBg;
-extern Pixel            awt_defaultFg;
-extern int              awt_multiclick_time;    /* awt_MToolkit.c */
-extern int              awt_multiclick_smudge;  /* canvas.c */
-extern unsigned int     awt_MetaMask;           /* awt_MToolkit.c */
-extern unsigned int     awt_AltMask;
-extern unsigned int     awt_NumLockMask;
-extern unsigned int     awt_ModeSwitchMask;
-extern Cursor           awt_scrollCursor;       /* awt_MToolkit.c */
-extern Boolean          awt_ModLockIsShiftLock;
-
+extern Display         *awt_display; /* awt_GraphicsEnv.c */
+extern Boolean          awt_ModLockIsShiftLock; /* XToolkit.c */
 #endif /* !HEADLESS */
 
 #endif /* ! _AWT_ */
--- a/jdk/src/solaris/native/sun/awt/awt_DrawingSurface.c	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/solaris/native/sun/awt/awt_DrawingSurface.c	Mon Oct 18 21:44:47 2010 -0700
@@ -264,7 +264,7 @@
 #ifndef XAWT
     px->drawable = XtWindow(cdata->widget);
 #else
-    px->drawable = JNU_GetLongFieldAsPtr(env, peer, windowID);
+    px->drawable = (*env)->GetLongField(env, peer, windowID);
 #endif
     px->display = awt_display;
 
--- a/jdk/src/solaris/native/sun/awt/awt_InputMethod.c	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/solaris/native/sun/awt/awt_InputMethod.c	Mon Oct 18 21:44:47 2010 -0700
@@ -46,8 +46,6 @@
 #ifdef XAWT
 #include <sun_awt_X11_XComponentPeer.h>
 #include <sun_awt_X11_XInputMethod.h>
-
-#define XtWindow(w)     (w)
 #else /* !XAWT */
 #include <sun_awt_motif_MComponentPeer.h>
 #include <sun_awt_motif_MInputMethod.h>
@@ -670,7 +668,8 @@
     int  mccr = 0;
     char *dsr;
     Pixel bg, fg, light, dim;
-    int x, y, w, h, bw, depth, off_x, off_y, xx, yy;
+    int x, y, off_x, off_y, xx, yy;
+    unsigned int w, h, bw, depth;
     XGCValues values;
     unsigned long valuemask = 0;  /*ignore XGCvalue and use defaults*/
     int screen = 0;
@@ -709,7 +708,7 @@
     light = adata->AwtColorMatch(195, 195, 195, adata);
     dim   = adata->AwtColorMatch(128, 128, 128, adata);
 
-    XGetWindowAttributes(dpy, XtWindow(parent), &xwa);
+    XGetWindowAttributes(dpy, parent, &xwa);
     bw = 2; /*xwa.border_width does not have the correct value*/
 
     /*compare the size difference between parent container
@@ -717,7 +716,7 @@
       and title bar height (?)*/
 
     XQueryTree( dpy,
-                XtWindow(parent),
+                parent,
                 &rootWindow,
                 &containerWindow,
                 &ignoreWindowPtr,
@@ -731,7 +730,7 @@
     XGetWindowAttributes(dpy, rootWindow, &xxwa);
 
     XTranslateCoordinates(dpy,
-                          XtWindow(parent), xwa.root,
+                          parent, xwa.root,
                           xwa.x, xwa.y,
                           &x, &y,
                           &child);
@@ -833,9 +832,9 @@
     if (statusWindow->parent != parent){
         statusWindow->parent = parent;
     }
-    XGetWindowAttributes(dpy, XtWindow(parent), &xwa);
+    XGetWindowAttributes(dpy, parent, &xwa);
     XTranslateCoordinates(dpy,
-                          XtWindow(parent), xwa.root,
+                          parent, xwa.root,
                           xwa.x, xwa.y,
                           &x, &y,
                           &child);
@@ -966,9 +965,9 @@
         XWindowAttributes xwa;
         int x, y;
         Window child;
-        XGetWindowAttributes(dpy, XtWindow(shell), &xwa);
+        XGetWindowAttributes(dpy, shell, &xwa);
         XTranslateCoordinates(dpy,
-                              XtWindow(shell), xwa.root,
+                              shell, xwa.root,
                               xwa.x, xwa.y,
                               &x, &y,
                               &child);
@@ -1033,7 +1032,7 @@
         return False;
     }
 #ifdef XAWT
-    if (w == NULL) {
+    if (!w) {
         return False;
     }
 #else /* !XAWT */
@@ -1148,8 +1147,8 @@
                 goto err;
             pX11IMData->statusWindow = createStatusWindow(w);
             pX11IMData->ic_active = XCreateIC(X11im,
-                                              XNClientWindow, XtWindow(w),
-                                              XNFocusWindow, XtWindow(w),
+                                              XNClientWindow, w,
+                                              XNFocusWindow, w,
                                               XNInputStyle, active_styles,
                                               XNPreeditAttributes, preedit,
                                               XNStatusAttributes, status,
@@ -1166,8 +1165,8 @@
                 goto err;
             pX11IMData->statusWidget = awt_util_getXICStatusAreaWindow(w);
             pX11IMData->ic_active = XCreateIC(X11im,
-                                              XNClientWindow, XtWindow(pX11IMData->statusWidget),
-                                              XNFocusWindow, XtWindow(w),
+                                              XNClientWindow, pX11IMData->statusWidget,
+                                              XNFocusWindow, w,
                                               XNInputStyle, active_styles,
                                               XNPreeditAttributes, preedit,
                                               XNStatusAttributes, status,
@@ -1176,8 +1175,8 @@
         } else {
 #endif /* XAWT */
             pX11IMData->ic_active = XCreateIC(X11im,
-                                              XNClientWindow, XtWindow(w),
-                                              XNFocusWindow, XtWindow(w),
+                                              XNClientWindow, w,
+                                              XNFocusWindow, w,
                                               XNInputStyle, active_styles,
                                               XNPreeditAttributes, preedit,
                                               NULL);
@@ -1187,15 +1186,15 @@
         XFree((void *)preedit);
 #endif /* __linux__ */
         pX11IMData->ic_passive = XCreateIC(X11im,
-                                           XNClientWindow, XtWindow(w),
-                                           XNFocusWindow, XtWindow(w),
+                                           XNClientWindow, w,
+                                           XNFocusWindow, w,
                                            XNInputStyle, passive_styles,
                                            NULL);
 
     } else {
         pX11IMData->ic_active = XCreateIC(X11im,
-                                          XNClientWindow, XtWindow(w),
-                                          XNFocusWindow, XtWindow(w),
+                                          XNClientWindow, w,
+                                          XNFocusWindow, w,
                                           XNInputStyle, active_styles,
                                           NULL);
         pX11IMData->ic_passive = pX11IMData->ic_active;
@@ -1213,7 +1212,7 @@
     {
         XIMCallback cb;
         cb.client_data = (XPointer) pX11IMData->x11inputmethod;
-        cb.callback = CommitStringCallback;
+        cb.callback = (XIMProc) CommitStringCallback;
         XSetICValues (pX11IMData->ic_active, XNCommitStringCallback, &cb, NULL);
         if (pX11IMData->ic_active != pX11IMData->ic_passive) {
             XSetICValues (pX11IMData->ic_passive, XNCommitStringCallback, &cb, NULL);
@@ -1510,7 +1509,7 @@
     AWT_LOCK();
 
 #ifdef XAWT
-    dpy = (Display *)display;
+    dpy = (Display *)jlong_to_ptr(display);
 #else
     dpy = awt_display;
 #endif
@@ -1520,7 +1519,7 @@
 */
 #ifdef __linux__
     registered = XRegisterIMInstantiateCallback(dpy, NULL, NULL,
-                     NULL, (XIMProc)OpenXIMCallback, NULL);
+                     NULL, (XIDProc)OpenXIMCallback, NULL);
     if (!registered) {
         /* directly call openXIM callback */
 #endif
@@ -1555,7 +1554,7 @@
     AWT_LOCK();
 
 #ifdef XAWT
-    if (window == NULL) {
+    if (!window) {
 #else /* !XAWT */
     if (JNU_IsNull(env, comp)) {
 #endif /* XAWT */
@@ -1664,7 +1663,7 @@
              * On Solaris2.6, setXICWindowFocus() has to be invoked
              * before setting focus.
              */
-            setXICWindowFocus(pX11IMData->current_ic, XtWindow(cdata->widget));
+            setXICWindowFocus(pX11IMData->current_ic, cdata->widget);
             setXICFocus(pX11IMData->current_ic, True);
         } else {
             destroyX11InputMethodData((JNIEnv *) NULL, pX11IMData);
@@ -1705,7 +1704,7 @@
 
     if (req) {
 #ifdef XAWT
-        if (w == NULL) {
+        if (!w) {
             AWT_UNLOCK();
             return;
         }
@@ -1738,10 +1737,10 @@
 #ifndef XAWT
         w = cdata->widget;
 #endif /* XAWT */
-        setXICWindowFocus(pX11IMData->current_ic, XtWindow(w));
+        setXICWindowFocus(pX11IMData->current_ic, w);
         setXICFocus(pX11IMData->current_ic, req);
         currentX11InputMethodInstance = pX11IMData->x11inputmethod;
-        currentFocusWindow =  XtWindow(w);
+        currentFocusWindow =  w;
 #ifdef __linux__
         if (active && pX11IMData->statusWindow && pX11IMData->statusWindow->on)
             onoffStatusWindow(pX11IMData, w, True);
--- a/jdk/src/solaris/native/sun/awt/awt_Robot.c	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/solaris/native/sun/awt/awt_Robot.c	Mon Oct 18 21:44:47 2010 -0700
@@ -165,41 +165,34 @@
 
 // this should be called from XRobotPeer constructor
 JNIEXPORT void JNICALL
-Java_sun_awt_X11_XRobotPeer_setup (JNIEnv * env, jclass cls, jint numberOfButtons) {
+Java_sun_awt_X11_XRobotPeer_setup (JNIEnv * env, jclass cls, jint numberOfButtons, jintArray buttonDownMasks)
+{
     int32_t xtestAvailable;
+    jint *tmp;
+    int i;
 
     DTRACE_PRINTLN("RobotPeer: setup()");
 
     num_buttons = numberOfButtons;
-
-    jclass inputEventClazz = (*env)->FindClass(env, "java/awt/event/InputEvent");
-    jmethodID getButtonDownMasksID = (*env)->GetStaticMethodID(env, inputEventClazz, "getButtonDownMasks", "()[I");
-    jintArray obj = (jintArray)(*env)->CallStaticObjectMethod(env, inputEventClazz, getButtonDownMasksID);
-    jint * tmp = (*env)->GetIntArrayElements(env, obj, JNI_FALSE);
-
-    masks  = (jint *)malloc(sizeof(jint) * num_buttons);
+    tmp = (*env)->GetIntArrayElements(env, buttonDownMasks, JNI_FALSE);
+    masks = (jint *)malloc(sizeof(jint) * num_buttons);
     if (masks == (jint *) NULL) {
         JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), NULL);
-        goto finally;
+        (*env)->ReleaseIntArrayElements(env, buttonDownMasks, tmp, 0);
+        return;
     }
-
-    int i;
     for (i = 0; i < num_buttons; i++) {
         masks[i] = tmp[i];
     }
-    (*env)->ReleaseIntArrayElements(env, obj, tmp, 0);
-    (*env)->DeleteLocalRef(env, obj);
+    (*env)->ReleaseIntArrayElements(env, buttonDownMasks, tmp, 0);
 
     AWT_LOCK();
     xtestAvailable = isXTestAvailable();
     DTRACE_PRINTLN1("RobotPeer: XTest available = %d", xtestAvailable);
     if (!xtestAvailable) {
         JNU_ThrowByName(env, "java/awt/AWTException", "java.awt.Robot requires your X server support the XTEST extension version 2.2");
-        AWT_UNLOCK();
-        return;
     }
 
-    finally:
     AWT_UNLOCK();
 }
 
--- a/jdk/src/solaris/native/sun/awt/awt_UNIXToolkit.c	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/solaris/native/sun/awt/awt_UNIXToolkit.c	Mon Oct 18 21:44:47 2010 -0700
@@ -112,7 +112,7 @@
         /* Copy the data array into a Java structure so we can pass it back. */
         jbyteArray data = (*env)->NewByteArray(env, (row_stride * height));
         (*env)->SetByteArrayRegion(env, data, 0, (row_stride * height),
-                                   pixbuf_data);
+                                   (jbyte *)pixbuf_data);
 
         /* Release the pixbuf. */
         (*fp_g_object_unref)(pixbuf);
--- a/jdk/src/solaris/native/sun/xawt/XlibWrapper.c	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/solaris/native/sun/xawt/XlibWrapper.c	Mon Oct 18 21:44:47 2010 -0700
@@ -484,8 +484,8 @@
 (JNIEnv *env, jclass clazz, jlong lib_major_in_out, jlong lib_minor_in_out)
 {
     AWT_CHECK_HAVE_LOCK();
-    *((int *)lib_major_in_out) =  XkbMajorVersion;
-    *((int *)lib_minor_in_out) =  XkbMinorVersion;
+    *((int *)jlong_to_ptr(lib_major_in_out)) =  XkbMajorVersion;
+    *((int *)jlong_to_ptr(lib_minor_in_out)) =  XkbMinorVersion;
     return  XkbLibraryVersion((int *)jlong_to_ptr(lib_major_in_out), (int *)jlong_to_ptr(lib_minor_in_out));
 }
 
@@ -1229,7 +1229,6 @@
 (JNIEnv *env, jclass clazz, jlong display)
 {
     int xx;
-    AWT_CHECK_HAVE_LOCK();
     static jboolean result = JNI_FALSE;
 
     int32_t minKeyCode, maxKeyCode, keySymsPerKeyCode;
@@ -1237,6 +1236,8 @@
     int32_t i;
     int32_t kanaCount = 0;
 
+    AWT_CHECK_HAVE_LOCK();
+
     // There's no direct way to determine whether the keyboard has
     // a kana lock key. From available keyboard mapping tables, it looks
     // like only keyboards with the kana lock key can produce keysyms
@@ -1337,12 +1338,14 @@
 JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XInternAtoms
 (JNIEnv *env, jclass clazz, jlong display, jobjectArray names_arr, jboolean only_if_exists, jlong atoms)
 {
-
     int length = (*env)->GetArrayLength(env, names_arr);
     char ** names = (char**)malloc(length*sizeof(char*));
     jboolean copy;
     int index, name_index = 0;
     int status;
+
+    AWT_CHECK_HAVE_LOCK();
+
     for (index = 0; index < length; index++) {
         jstring str = (*env)->GetObjectArrayElement(env, names_arr, index);
         if (!JNU_IsNull(env, str)) {
@@ -1352,7 +1355,6 @@
             (*env)->DeleteLocalRef(env, str);
         }
     }
-    AWT_CHECK_HAVE_LOCK();
     status = XInternAtoms((Display*)jlong_to_ptr(display), names, name_index, only_if_exists, (Atom*) jlong_to_ptr(atoms));
     for (index = 0; index < length; index++) {
         free(names[index]);
@@ -2186,12 +2188,12 @@
 Java_sun_awt_X11_XlibWrapper_SetZOrder
 (JNIEnv *env, jclass clazz, jlong display, jlong window, jlong above)
 {
-    AWT_CHECK_HAVE_LOCK();
+    unsigned int value_mask = CWStackMode;
 
     XWindowChanges wc;
     wc.sibling = (Window)jlong_to_ptr(above);
 
-    unsigned int value_mask = CWStackMode;
+    AWT_CHECK_HAVE_LOCK();
 
     if (above == 0) {
         wc.stack_mode = Above;
@@ -2219,6 +2221,7 @@
     jboolean isCopy = JNI_FALSE;
     size_t worstBufferSize = (size_t)((width / 2 + 1) * height);
     RECT_T * pRect;
+    int numrects;
 
     AWT_CHECK_HAVE_LOCK();
 
@@ -2237,7 +2240,7 @@
     /* Note: the values[0] and values[1] are supposed to contain the width
      * and height (see XIconInfo.getIntData() for details). So, we do +2.
      */
-    int numrects = BitmapToYXBandedRectangles(32, (int)width, (int)height,
+    numrects = BitmapToYXBandedRectangles(32, (int)width, (int)height,
             (unsigned char *)(values + 2), pRect);
 
     XShapeCombineRectangles((Display *)jlong_to_ptr(display), (Window)jlong_to_ptr(window),
--- a/jdk/src/solaris/native/sun/xawt/awt_Desktop.c	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/solaris/native/sun/xawt/awt_Desktop.c	Mon Oct 18 21:44:47 2010 -0700
@@ -28,12 +28,15 @@
 
 typedef int gboolean;
 
-gboolean (*gnome_url_show) (const char *url, void **error);
+typedef gboolean (GNOME_URL_SHOW_TYPE)(const char *, void **);
+typedef gboolean (GNOME_VFS_INIT_TYPE)(void);
+
+GNOME_URL_SHOW_TYPE *gnome_url_show;
+GNOME_VFS_INIT_TYPE *gnome_vfs_init;
 
 int init(){
     void *vfs_handle;
     void *gnome_handle;
-    gboolean (*gnome_vfs_init) (void);
     const char *errmsg;
 
     vfs_handle = dlopen("libgnomevfs-2.so.0", RTLD_LAZY);
@@ -44,7 +47,7 @@
         return 0;
     }
     dlerror(); /* Clear errors */
-    gnome_vfs_init = dlsym(vfs_handle, "gnome_vfs_init");
+    gnome_vfs_init = (GNOME_VFS_INIT_TYPE*)dlsym(vfs_handle, "gnome_vfs_init");
     if ((errmsg = dlerror()) != NULL) {
 #ifdef INTERNAL_BUILD
         fprintf(stderr, "can not find symble gnome_vfs_init\n");
@@ -62,7 +65,7 @@
         return 0;
     }
     dlerror(); /* Clear errors */
-    gnome_url_show = dlsym(gnome_handle, "gnome_url_show");
+    gnome_url_show = (GNOME_URL_SHOW_TYPE*)dlsym(gnome_handle, "gnome_url_show");
     if ((errmsg = dlerror()) != NULL) {
 #ifdef INTERNAL_BUILD
         fprintf(stderr, "can not find symble gnome_url_show\n");
@@ -94,14 +97,15 @@
   (JNIEnv *env, jobject obj, jbyteArray url_j)
 {
     gboolean success;
-
-    const char* url_c = (*env)->GetByteArrayElements(env, url_j, NULL);
+    const char* url_c;
 
-    if (gnome_url_show == NULL) return JNI_FALSE;
+    if (gnome_url_show == NULL) {
+        return JNI_FALSE;
+    }
 
+    url_c = (char*)(*env)->GetByteArrayElements(env, url_j, NULL);
     // call gnome_url_show(const char* , GError**)
     success = (*gnome_url_show)(url_c, NULL);
-
     (*env)->ReleaseByteArrayElements(env, url_j, (signed char*)url_c, 0);
 
     return success ? JNI_TRUE : JNI_FALSE;
--- a/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java	Mon Oct 18 21:44:47 2010 -0700
@@ -487,13 +487,8 @@
             newDev.addDisplayChangedListener(this);
         }
 
-        SunToolkit.executeOnEventHandlerThread((Component)target,
-                new Runnable() {
-                    public void run() {
-                        AWTAccessor.getComponentAccessor().
+        AWTAccessor.getComponentAccessor().
             setGraphicsConfiguration((Component)target, winGraphicsConfig);
-                    }
-                });
     }
 
     /**
--- a/jdk/src/windows/native/sun/windows/WPrinterJob.cpp	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/windows/native/sun/windows/WPrinterJob.cpp	Mon Oct 18 21:44:47 2010 -0700
@@ -639,7 +639,7 @@
     if( ::ExtEscape( hDC, GETTECHNOLOGY, 0, NULL, MAX_PATH,
                      (LPSTR)szTechnology ) <= 0 )
         return FALSE;
-    strupr( szTechnology );
+    _strupr_s(szTechnology, MAX_PATH);
     if(!strstr( szTechnology, "POSTSCRIPT" ) == NULL )
         return TRUE;
 
--- a/jdk/src/windows/native/sun/windows/awt_BitmapUtil.cpp	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_BitmapUtil.cpp	Mon Oct 18 21:44:47 2010 -0700
@@ -246,7 +246,7 @@
     UINT height = abs(bi.bmiHeader.biHeight);
 
     BYTE * buf = (BYTE*)safe_Malloc(bi.bmiHeader.biSizeImage);
-    bi.bmiHeader.biHeight = -height;
+    bi.bmiHeader.biHeight = -(INT)height;
     ::GetDIBits(hdc, hBitmap, 0, height, buf,
             reinterpret_cast<BITMAPINFO*>(&bi), DIB_RGB_COLORS);
 
@@ -305,7 +305,7 @@
     UINT height = abs(bi.bmiHeader.biHeight);
 
     BYTE * buf = (BYTE*)safe_Malloc(bi.bmiHeader.biSizeImage);
-    bi.bmiHeader.biHeight = -height;
+    bi.bmiHeader.biHeight = -(INT)height;
     ::GetDIBits(hdc, hSrcBitmap, 0, height, buf,
             reinterpret_cast<BITMAPINFO*>(&bi), DIB_RGB_COLORS);
 
--- a/jdk/src/windows/native/sun/windows/awt_DesktopProperties.cpp	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_DesktopProperties.cpp	Mon Oct 18 21:44:47 2010 -0700
@@ -238,7 +238,7 @@
     // when running on XP. However this can't be referenced at compile time
     // with the older SDK, so there use 'lfMessageFont' plus its size.
     if (!IS_WINVISTA) {
-#if defined(_MSC_VER) && (_MSC_VER >= 1600) {
+#if defined(_MSC_VER) && (_MSC_VER >= 1600)
         ncmetrics.cbSize = offsetof(NONCLIENTMETRICS, iPaddedBorderWidth);
 #else
         ncmetrics.cbSize = offsetof(NONCLIENTMETRICS,lfMessageFont) + sizeof(LOGFONT);
--- a/jdk/src/windows/native/sun/windows/awt_Dialog.cpp	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Dialog.cpp	Mon Oct 18 21:44:47 2010 -0700
@@ -304,7 +304,15 @@
     UINT flags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE;
 
     if (isBlocked) {
-        ::SetWindowPos(dialog, blocker, 0, 0, 0, 0, flags);
+        // Fix for 6829546: if blocker is a top-most window, but window isn't, then
+        // calling ::SetWindowPos(dialog, blocker, ...) makes window top-most as well
+        BOOL isBlockerTopmost = (::GetWindowLong(blocker, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0;
+        BOOL isDialogTopmost = (::GetWindowLong(dialog, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0;
+        if (!isBlockerTopmost || isDialogTopmost) {
+            ::SetWindowPos(dialog, blocker, 0, 0, 0, 0, flags);
+        } else {
+            ::SetWindowPos(dialog, HWND_TOP, 0, 0, 0, 0, flags);
+        }
     } else {
         ::SetWindowPos(dialog, HWND_TOP, 0, 0, 0, 0, flags);
         // no beep/flash if the mouse was clicked in the taskbar menu
--- a/jdk/src/windows/native/sun/windows/awt_DrawingSurface.h	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_DrawingSurface.h	Mon Oct 18 21:44:47 2010 -0700
@@ -159,7 +159,8 @@
     void JNICALL DSUnlockAWT(JNIEnv* env);
 
     _JNI_IMPORT_OR_EXPORT_
-    jobject JNICALL DSGetComponent(JNIEnv* env, void* platformInfo);
+    jobject JNICALL DSGetComponent(
+        JNIEnv* env, void* platformInfo);
 
 #ifdef __cplusplus
 } /* extern "C" */
--- a/jdk/src/windows/native/sun/windows/awt_Font.cpp	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Font.cpp	Mon Oct 18 21:44:47 2010 -0700
@@ -1189,7 +1189,7 @@
 
 AwtFontCache::Item::Item(const WCHAR* s, HFONT f, AwtFontCache::Item* n )
 {
-    name = wcsdup(s);
+    name = _wcsdup(s);
     font = f;
     next = n;
     refCount = 1;
@@ -1237,7 +1237,7 @@
         free(m_lpszFontName);
         m_lpszFontName = NULL;
     }
-    m_lpszFontName = wcsdup(name);
+    m_lpszFontName = _wcsdup(name);
     DASSERT(m_lpszFontName);
 }
 
--- a/jdk/src/windows/native/sun/windows/awt_PrintJob.cpp	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_PrintJob.cpp	Mon Oct 18 21:44:47 2010 -0700
@@ -1050,7 +1050,7 @@
     return NULL;
   }
 
-  LPTSTR port = wcsdup(info2->pPortName);
+  LPTSTR port = _wcsdup(info2->pPortName);
   ::GlobalFree(info2);
   return port;
 }
--- a/jdk/src/windows/native/sun/windows/awt_Toolkit.cpp	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Toolkit.cpp	Mon Oct 18 21:44:47 2010 -0700
@@ -23,16 +23,12 @@
  * questions.
  */
 
+#define _JNI_IMPLEMENTATION_
+
 #include "awt.h"
 #include <signal.h>
 #include <windowsx.h>
 
-//#if defined(_DEBUG) && defined(_MSC_VER) && _MSC_VER >= 1000
-//#include <crtdbg.h>
-//#endif
-
-#define _JNI_IMPLEMENTATION_
-
 #include "awt_DrawingSurface.h"
 #include "awt_AWTEvent.h"
 #include "awt_Component.h"
@@ -2224,21 +2220,21 @@
     WCHAR szVer[128];
 
     DWORD version = ::GetVersion();
-    swprintf(szVer, L"0x%x = %ld", version, version);
+    swprintf(szVer, 128, L"0x%x = %ld", version, version);
     int l = lstrlen(szVer);
 
     if (IS_WIN2000) {
         if (IS_WINXP) {
             if (IS_WINVISTA) {
-                swprintf(szVer + l, L" (Windows Vista)");
+                swprintf(szVer + l, 128, L" (Windows Vista)");
             } else {
-                swprintf(szVer + l, L" (Windows XP)");
+                swprintf(szVer + l, 128, L" (Windows XP)");
             }
         } else {
-            swprintf(szVer + l, L" (Windows 2000)");
+            swprintf(szVer + l, 128, L" (Windows 2000)");
         }
     } else {
-        swprintf(szVer + l, L" (Unknown)");
+        swprintf(szVer + l, 128, L" (Unknown)");
     }
 
     return JNU_NewStringPlatform(env, szVer);
--- a/jdk/src/windows/native/sun/windows/awt_Win32GraphicsEnv.cpp	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Win32GraphicsEnv.cpp	Mon Oct 18 21:44:47 2010 -0700
@@ -269,7 +269,7 @@
         //if the fontPath includes %SystemRoot%
         LPWSTR systemRoot = _wgetenv(L"SystemRoot");
         if (systemRoot != NULL
-            && swprintf(tmpPath, L"%s%s", systemRoot, fontPath + 12) != -1) {
+            && swprintf(tmpPath, MAX_PATH, L"%s%s", systemRoot, fontPath + 12) != -1) {
             fontPath = tmpPath;
         }
         else {
@@ -279,7 +279,7 @@
         //else to see if it only inludes "EUDC.TTE"
         WCHAR systemRoot[MAX_PATH + 1];
         if (GetWindowsDirectory(systemRoot, MAX_PATH + 1) != 0) {
-            swprintf(tmpPath, L"%s\\FONTS\\EUDC.TTE", systemRoot);
+            swprintf(tmpPath, MAX_PATH, L"%s\\FONTS\\EUDC.TTE", systemRoot);
             fontPath = tmpPath;
         }
         else {
--- a/jdk/src/windows/native/sun/windows/awt_Window.cpp	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Window.cpp	Mon Oct 18 21:44:47 2010 -0700
@@ -219,7 +219,7 @@
 
     ::InitializeCriticalSection(&contentBitmapCS);
 
-    m_windowType = Type::NORMAL;
+    m_windowType = NORMAL;
     m_alwaysOnTop = false;
 }
 
@@ -1016,9 +1016,9 @@
     }
 
     if (strcmp(valueNative, "UTILITY") == 0) {
-        m_windowType = Type::UTILITY;
+        m_windowType = UTILITY;
     } else if (strcmp(valueNative, "POPUP") == 0) {
-        m_windowType = Type::POPUP;
+        m_windowType = POPUP;
     }
 
     env->ReleaseStringUTFChars(value, valueNative);
@@ -1029,10 +1029,10 @@
 void AwtWindow::TweakStyle(DWORD & style, DWORD & exStyle)
 {
     switch (GetType()) {
-        case Type::UTILITY:
+        case UTILITY:
             exStyle |= WS_EX_TOOLWINDOW;
             break;
-        case Type::POPUP:
+        case POPUP:
             style &= ~WS_OVERLAPPED;
             style |= WS_POPUP;
             break;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Dialog/MakeWindowAlwaysOnTop/MakeWindowAlwaysOnTop.java	Mon Oct 18 21:44:47 2010 -0700
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  @test
+  @bug 6829546
+  @summary tests that an always-on-top modal dialog doesn't make any windows always-on-top
+  @author artem.ananiev: area=awt.modal
+  @library ../../regtesthelpers
+  @build Util
+  @run main MakeWindowAlwaysOnTop
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+
+import test.java.awt.regtesthelpers.Util;
+
+public class MakeWindowAlwaysOnTop
+{
+    private static Frame f;
+    private static Dialog d;
+
+    public static void main(String[] args) throws Exception
+    {
+        Robot r = Util.createRobot();
+        Util.waitForIdle(r);
+
+        // Frame
+        f = new Frame("Test frame");
+        f.setBounds(100, 100, 400, 300);
+        f.setBackground(Color.RED);
+        f.setVisible(true);
+        r.delay(100);
+        Util.waitForIdle(r);
+
+        // Dialog
+        d = new Dialog(null, "Modal dialog", Dialog.ModalityType.APPLICATION_MODAL);
+        d.setBounds(500, 500, 160, 160);
+        d.setAlwaysOnTop(true);
+        EventQueue.invokeLater(new Runnable()
+        {
+            public void run()
+            {
+                d.setVisible(true);
+            }
+        });
+        // Wait until the dialog is shown
+        EventQueue.invokeAndWait(new Runnable()
+        {
+            public void run()
+            {
+                // Empty
+            }
+        });
+        r.delay(100);
+        Util.waitForIdle(r);
+
+        // Click on the frame to trigger modality
+        Point p = f.getLocationOnScreen();
+        r.mouseMove(p.x + f.getWidth() / 2, p.y + f.getHeight() / 2);
+        Util.waitForIdle(r);
+        r.mousePress(InputEvent.BUTTON1_MASK);
+        Util.waitForIdle(r);
+        r.mouseRelease(InputEvent.BUTTON1_MASK);
+        Util.waitForIdle(r);
+
+        r.delay(100);
+        Util.waitForIdle(r);
+
+        // Dispose dialog
+        d.dispose();
+        r.delay(100);
+        Util.waitForIdle(r);
+
+        // Show another frame at the same location
+        Frame t = new Frame("Check");
+        t.setBounds(100, 100, 400, 300);
+        t.setBackground(Color.BLUE);
+        t.setVisible(true);
+        r.delay(100);
+        Util.waitForIdle(r);
+
+        // Bring it above the first frame
+        t.toFront();
+        r.delay(100);
+        Util.waitForIdle(r);
+
+        Color c = r.getPixelColor(p.x + f.getWidth() / 2, p.y + f.getHeight() / 2);
+        System.out.println("Color = " + c);
+        System.out.flush();
+        // If the color is RED, then the first frame is now always-on-top
+        if (Color.RED.equals(c))
+        {
+            throw new RuntimeException("Test FAILED: the frame is always-on-top");
+        }
+        else if (!Color.BLUE.equals(c))
+        {
+            throw new RuntimeException("Test FAILED: unknown window is on top of the frame");
+        }
+        else
+        {
+            System.out.println("Test PASSED");
+            System.out.flush();
+        }
+
+        // Dispose all the windows
+        t.dispose();
+        f.dispose();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Frame/FrameLocation/FrameLocation.java	Mon Oct 18 21:44:47 2010 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  @test
+  @bug 6895647
+  @summary X11 Frame locations should be what we set them to
+  @author anthony.petrov@oracle.com: area=awt.toplevel
+  @run main FrameLocation
+ */
+
+import java.awt.*;
+
+public class FrameLocation {
+    private static final int X = 250;
+    private static final int Y = 250;
+
+    public static void main(String[] args) {
+        Frame f = new Frame("test");
+        f.setBounds(X, Y, 250, 250); // the size doesn't matter
+        f.setVisible(true);
+
+        for (int i = 0; i < 10; i++) {
+            // 2 seconds must be enough for the WM to show the window
+            try {
+                Thread.sleep(2000);
+            } catch (InterruptedException ex) {
+            }
+
+            // Check the location
+            int x = f.getX();
+            int y = f.getY();
+
+            if (x != X || y != Y) {
+                throw new RuntimeException("The frame location is wrong! Current: " + x + ", " + y + ";  expected: " + X + ", " + Y);
+            }
+
+            // Emulate what happens when setGraphicsConfiguration() is called
+            synchronized (f.getTreeLock()) {
+                f.removeNotify();
+                f.addNotify();
+            }
+        }
+
+        f.dispose();
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Multiscreen/TranslucencyThrowsExceptionWhenFullScreen/TranslucencyThrowsExceptionWhenFullScreen.java	Mon Oct 18 21:44:47 2010 -0700
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  @test
+  @bug 6838089
+  @summary Translucent windows should throw exception in FS mode
+  @author dmitry.cherepanov@oracle.com: area=awt-multiscreen
+  @run main TranslucencyThrowsExceptionWhenFullScreen
+*/
+
+import java.awt.*;
+import java.lang.reflect.InvocationTargetException;
+
+public class TranslucencyThrowsExceptionWhenFullScreen
+{
+    public static void main(String[] args)
+        throws InvocationTargetException, InterruptedException
+    {
+        EventQueue.invokeAndWait(
+            new Runnable(){
+                public void run() {
+                    Frame frame = new Frame();
+                    frame.setBounds(100,100,100,100);
+                    frame.setVisible(true);
+
+                    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+                    GraphicsDevice[] devices = ge.getScreenDevices();
+                    for (GraphicsDevice device : devices) {
+                        testGraphicsDevice(device, frame);
+                    }
+
+                    frame.dispose();
+                }
+            }
+        );
+    }
+
+    private static void testGraphicsDevice(GraphicsDevice device, Frame frame) {
+        device.setFullScreenWindow(frame);
+        try {
+            frame.setOpacity(0.5f);
+            throw new RuntimeException("Test fails, there's no exception for device="+device);
+        } catch(IllegalComponentStateException e) {
+            device.setFullScreenWindow(null);
+        }
+    }
+}
--- a/jdk/test/javax/swing/system/6799345/TestShutdown.java	Mon Oct 18 12:43:39 2010 -0700
+++ b/jdk/test/javax/swing/system/6799345/TestShutdown.java	Mon Oct 18 21:44:47 2010 -0700
@@ -59,7 +59,7 @@
 
         while (!appcontextInitDone)
         {
-            Thread.sleep(500);
+            Thread.sleep(1000);
         }
 
         targetAppContext.dispose();
@@ -146,7 +146,6 @@
                     startGUI();
                 }
             });
-            stk.realSync();
 
             // start multiple SwingWorkers
             while (!Thread.interrupted())