6708392: Provide internal API to create OverrideRedirect windows, XToolkit
SunToolkit.setOverrideRedirect() method is introduced Reviewed-by: mlapshin, yan
This commit is contained in:
parent
18c2b3a604
commit
f5cc909878
@ -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 @@ public class Popup {
|
||||
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);
|
||||
|
@ -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 @@ public abstract class SunToolkit extends Toolkit
|
||||
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) {
|
||||
|
@ -97,6 +97,11 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
|
||||
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 @@ 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() {
|
||||
if (log.isLoggable(Level.FINE)) {
|
||||
log.fine("Mapped windows:");
|
||||
|
@ -129,6 +129,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
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 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
|
||||
boolean isOverrideRedirect() {
|
||||
return (XWM.getWMID() == XWM.OPENLOOK_WM ? true : false) ||
|
||||
((XToolkit)Toolkit.getDefaultToolkit()).isOverrideRedirect((Window)target) ||
|
||||
XTrayIconPeer.isTrayIconStuffWindow((Window)target);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user