提交 47a08914 编写于 作者: T tdv

6748082: remove platform-specific code from SwingUtilities2.isDisplayLocal

Reviewed-by: prr, tdv
Contributed-by: rkennke@kennke.org
上级 1709d153
......@@ -1272,6 +1272,13 @@ public abstract class SunGraphicsEnvironment extends GraphicsEnvironment
displayChanger.notifyPaletteChanged();
}
/**
* Returns true when the display is local, false for remote displays.
*
* @return true when the display is local, false for remote displays
*/
public abstract boolean isDisplayLocal();
/*
* ----DISPLAY CHANGE SUPPORT----
*/
......
......@@ -55,6 +55,7 @@ import java.io.*;
import java.util.*;
import sun.font.FontDesignMetrics;
import sun.font.FontManager;
import sun.java2d.SunGraphicsEnvironment;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
......@@ -1482,22 +1483,14 @@ public class SwingUtilities2 {
* appear capable of performing gamma correction needed for LCD text.
*/
public static boolean isLocalDisplay() {
try {
// On Windows just return true. Permission to read os.name
// is granted to all code but wrapped in try to be safe.
if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS) {
return true;
}
// Else probably Solaris or Linux in which case may be remote X11
Class x11Class = Class.forName("sun.awt.X11GraphicsEnvironment");
Method isDisplayLocalMethod = x11Class.getMethod(
"isDisplayLocal", new Class[0]);
return (Boolean)isDisplayLocalMethod.invoke(null, (Object[])null);
} catch (Throwable t) {
}
// If we get here we're most likely being run on some other O/S
// or we didn't properly detect Windows.
return true;
boolean isLocal;
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
if (ge instanceof SunGraphicsEnvironment) {
isLocal = ((SunGraphicsEnvironment) ge).isDisplayLocal();
} else {
isLocal = true;
}
return isLocal;
}
/**
......
......@@ -209,7 +209,7 @@ public class X11GraphicsEnvironment
private static native int checkShmExt();
private static native String getDisplayString();
private static Boolean isDisplayLocal;
private Boolean isDisplayLocal;
/**
* This should only be called from the static initializer, so no need for
......@@ -234,7 +234,8 @@ public class X11GraphicsEnvironment
return getScreenDevices()[getDefaultScreenNum()];
}
public static boolean isDisplayLocal() {
@Override
public boolean isDisplayLocal() {
if (isDisplayLocal == null) {
SunToolkit.awtLock();
try {
......
......@@ -156,7 +156,7 @@ jboolean isDisplayLocal(JNIEnv *env) {
isLocal = JNU_CallStaticMethodByName(env, NULL,
"sun/awt/X11GraphicsEnvironment",
"isDisplayLocal",
"_isDisplayLocal",
"()Z").z;
isLocalSet = True;
return isLocal;
......
......@@ -393,4 +393,9 @@ public class Win32GraphicsEnvironment
private static void dwmCompositionChanged(boolean enabled) {
isDWMCompositionEnabled = enabled;
}
@Override
public boolean isDisplayLocal() {
return true;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册