6708392: Provide internal API to create OverrideRedirect windows, XToolkit
Summary: SunToolkit.setOverrideRedirect() method is introduced
Reviewed-by: mlapshin, yan
--- a/jdk/src/share/classes/javax/swing/Popup.java Tue Aug 12 12:00:46 2008 +0400
+++ b/jdk/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/jdk/src/share/classes/sun/awt/SunToolkit.java Tue Aug 12 12:00:46 2008 +0400
+++ b/jdk/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
@@ -852,6 +852,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/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java Tue Aug 12 12:00:46 2008 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java Thu Aug 14 12:58:51 2008 +0400
@@ -97,6 +97,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;
@@ -1248,6 +1253,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/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java Tue Aug 12 12:00:46 2008 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java Thu Aug 14 12:58:51 2008 +0400
@@ -129,6 +129,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);
@@ -1117,6 +1118,7 @@
boolean isOverrideRedirect() {
return (XWM.getWMID() == XWM.OPENLOOK_WM ? true : false) ||
+ ((XToolkit)Toolkit.getDefaultToolkit()).isOverrideRedirect((Window)target) ||
XTrayIconPeer.isTrayIconStuffWindow((Window)target);
}