changeset 198:f9fa5c538031

6708392: Provide internal API to create OverrideRedirect windows, XToolkit Summary: SunToolkit.setOverrideRedirect() method is introduced Reviewed-by: mlapshin, yan
author art
date Thu, 14 Aug 2008 12:58:51 +0400
parents 735527f2e9dc
children b394cbe9501e c4fb21cf8696
files src/share/classes/javax/swing/Popup.java src/share/classes/sun/awt/SunToolkit.java src/solaris/classes/sun/awt/X11/XToolkit.java src/solaris/classes/sun/awt/X11/XWindowPeer.java
diffstat 4 files changed, 39 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/javax/swing/Popup.java	Fri Sep 11 10:54:55 2009 -0700
+++ b/src/share/classes/javax/swing/Popup.java	Thu Aug 14 12:58:51 2008 +0400
@@ -26,7 +26,9 @@
 package javax.swing;
 
 import java.awt.*;
+
 import sun.awt.ModalExclude;
+import sun.awt.SunToolkit;
 
 /**
  * Popups are used to display a <code>Component</code> to the user, typically
@@ -225,7 +227,12 @@
         HeavyWeightWindow(Window parent) {
             super(parent);
             setFocusableWindowState(false);
-            setName("###overrideRedirect###");
+            Toolkit tk = Toolkit.getDefaultToolkit();
+            if (tk instanceof SunToolkit) {
+                // all the short-lived windows like Popups should be
+                // OverrideRedirect on X11 platforms
+                ((SunToolkit)tk).setOverrideRedirect(this);
+            }
             // Popups are typically transient and most likely won't benefit
             // from true double buffering.  Turn it off here.
             getRootPane().setUseTrueDoubleBuffering(false);
--- a/src/share/classes/sun/awt/SunToolkit.java	Fri Sep 11 10:54:55 2009 -0700
+++ b/src/share/classes/sun/awt/SunToolkit.java	Thu Aug 14 12:58:51 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -853,6 +853,15 @@
         return AccessController.doPrivileged(new GetBooleanAction("sun.awt.erasebackgroundonresize"));
     }
 
+
+    /**
+     * Makes the window OverrideRedirect, on X11 platforms. See
+     * ICCCM specification for more details about OverrideRedirect
+     * windows. Implemented in XToolkit, no-op in WToolkit.
+     */
+    public void setOverrideRedirect(Window target) {
+    }
+
     static SoftCache imgCache = new SoftCache();
 
     static synchronized Image getImageFromHash(Toolkit tk, URL url) {
--- a/src/solaris/classes/sun/awt/X11/XToolkit.java	Fri Sep 11 10:54:55 2009 -0700
+++ b/src/solaris/classes/sun/awt/X11/XToolkit.java	Thu Aug 14 12:58:51 2008 +0400
@@ -93,6 +93,11 @@
     static int awt_multiclick_time;
     static boolean securityWarningEnabled;
 
+    // WeakSet should be used here, but there is no such class
+    // in JDK (at least in JDK6 and earlier versions)
+    private WeakHashMap<Window, Boolean> overrideRedirectWindows =
+        new WeakHashMap<Window, Boolean>();
+
     private static int screenWidth = -1, screenHeight = -1; // Dimensions of default screen
     static long awt_defaultFg; // Pixel
     private static XMouseInfoPeer xPeer;
@@ -1096,7 +1101,7 @@
         awtLock();
         try {
             XlibWrapper.XBell(getDisplay(), 0);
-	    XlibWrapper.XFlush(getDisplay());
+            XlibWrapper.XFlush(getDisplay());
         } finally {
             awtUnlock();
         }
@@ -1239,6 +1244,19 @@
         }
     }
 
+    @Override
+    public void setOverrideRedirect(Window target) {
+        synchronized (overrideRedirectWindows) {
+            overrideRedirectWindows.put(target, true);
+        }
+    }
+
+    public boolean isOverrideRedirect(Window target) {
+        synchronized (overrideRedirectWindows) {
+            return overrideRedirectWindows.containsKey(target);
+        }
+    }
+
     static void dumpPeers() {
         if (log.isLoggable(Level.FINE)) {
             log.fine("Mapped windows:");
--- a/src/solaris/classes/sun/awt/X11/XWindowPeer.java	Fri Sep 11 10:54:55 2009 -0700
+++ b/src/solaris/classes/sun/awt/X11/XWindowPeer.java	Thu Aug 14 12:58:51 2008 +0400
@@ -133,6 +133,7 @@
     private static final int MAXIMUM_BUFFER_LENGTH_NET_WM_ICON = (2<<15) - 1;
 
     void preInit(XCreateWindowParams params) {
+        target = (Component)params.get(TARGET);
         params.put(REPARENTED,
                    Boolean.valueOf(isOverrideRedirect() || isSimpleWindow()));
         super.preInit(params);
@@ -1122,6 +1123,7 @@
 
     boolean isOverrideRedirect() {
         return (XWM.getWMID() == XWM.OPENLOOK_WM ? true : false) ||
+            ((XToolkit)Toolkit.getDefaultToolkit()).isOverrideRedirect((Window)target) ||
             XTrayIconPeer.isTrayIconStuffWindow((Window)target);
     }