提交 153216b5 编写于 作者: A art

6708392: Provide internal API to create OverrideRedirect windows, XToolkit

Summary: SunToolkit.setOverrideRedirect() method is introduced
Reviewed-by: mlapshin, yan
上级 783b25f7
...@@ -26,7 +26,9 @@ ...@@ -26,7 +26,9 @@
package javax.swing; package javax.swing;
import java.awt.*; import java.awt.*;
import sun.awt.ModalExclude; import sun.awt.ModalExclude;
import sun.awt.SunToolkit;
/** /**
* Popups are used to display a <code>Component</code> to the user, typically * Popups are used to display a <code>Component</code> to the user, typically
...@@ -225,7 +227,12 @@ public class Popup { ...@@ -225,7 +227,12 @@ public class Popup {
HeavyWeightWindow(Window parent) { HeavyWeightWindow(Window parent) {
super(parent); super(parent);
setFocusableWindowState(false); 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 // Popups are typically transient and most likely won't benefit
// from true double buffering. Turn it off here. // from true double buffering. Turn it off here.
getRootPane().setUseTrueDoubleBuffering(false); getRootPane().setUseTrueDoubleBuffering(false);
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -852,6 +852,15 @@ public abstract class SunToolkit extends Toolkit ...@@ -852,6 +852,15 @@ public abstract class SunToolkit extends Toolkit
return AccessController.doPrivileged(new GetBooleanAction("sun.awt.erasebackgroundonresize")); 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 SoftCache imgCache = new SoftCache();
static synchronized Image getImageFromHash(Toolkit tk, URL url) { static synchronized Image getImageFromHash(Toolkit tk, URL url) {
......
...@@ -97,6 +97,11 @@ public final class XToolkit extends UNIXToolkit implements Runnable { ...@@ -97,6 +97,11 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
static int awt_multiclick_time; static int awt_multiclick_time;
static boolean securityWarningEnabled; 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 private static int screenWidth = -1, screenHeight = -1; // Dimensions of default screen
static long awt_defaultFg; // Pixel static long awt_defaultFg; // Pixel
private static XMouseInfoPeer xPeer; private static XMouseInfoPeer xPeer;
...@@ -1248,6 +1253,19 @@ public final class XToolkit extends UNIXToolkit implements Runnable { ...@@ -1248,6 +1253,19 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
} }
} }
@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() { static void dumpPeers() {
if (log.isLoggable(Level.FINE)) { if (log.isLoggable(Level.FINE)) {
log.fine("Mapped windows:"); log.fine("Mapped windows:");
......
...@@ -129,6 +129,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, ...@@ -129,6 +129,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
private static final int MAXIMUM_BUFFER_LENGTH_NET_WM_ICON = (2<<15) - 1; private static final int MAXIMUM_BUFFER_LENGTH_NET_WM_ICON = (2<<15) - 1;
void preInit(XCreateWindowParams params) { void preInit(XCreateWindowParams params) {
target = (Component)params.get(TARGET);
params.put(REPARENTED, params.put(REPARENTED,
Boolean.valueOf(isOverrideRedirect() || isSimpleWindow())); Boolean.valueOf(isOverrideRedirect() || isSimpleWindow()));
super.preInit(params); super.preInit(params);
...@@ -1117,6 +1118,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, ...@@ -1117,6 +1118,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
boolean isOverrideRedirect() { boolean isOverrideRedirect() {
return (XWM.getWMID() == XWM.OPENLOOK_WM ? true : false) || return (XWM.getWMID() == XWM.OPENLOOK_WM ? true : false) ||
((XToolkit)Toolkit.getDefaultToolkit()).isOverrideRedirect((Window)target) ||
XTrayIconPeer.isTrayIconStuffWindow((Window)target); XTrayIconPeer.isTrayIconStuffWindow((Window)target);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册