java - javaFX误报屏幕设备的数量
问题描述
我在 Red Hat 6.8 x64 上使用 java 8u162 和 NVidia GPU(及其最新驱动程序)在 Linux 上开发了一个 javaFX 应用程序,带有 2 个全高清屏幕。
我在检索物理屏幕数量时遇到问题:
- 当X服务器处于扩展桌面模式时(2个物理屏幕,但是一个0到3840像素的逻辑屏幕),Screen.getScreens()返回2个屏幕(这是正常的)
- 当 X 服务器处于单独的桌面模式(2 个物理屏幕和 2 个逻辑屏幕,从 0 到 1920 像素)时,Screen.getScreens() 返回 1 个屏幕 ==> 这是正常的还是错误的?
我将 JavaFX API 与 AWT API 进行了比较:
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gdev = env.getScreenDevices();
AWT 在两种配置模式下都返回 2 个屏幕设备。
我还使用 ubuntu x64 机器检查了 java 9 和 java 10,并在 JavaFX 上遇到了同样的问题。
我尝试对此进行调试,似乎问题出在本机代码中的 libglass.so 中。
你怎么看待这件事 ?我错过了什么吗?
这是重现该问题的代码:
public class ScreenTest extends Application {
private static final int SIZE = 1600;
private final AnchorPane root = new AnchorPane();
@Override
public void start(Stage primaryStage) throws Exception {
root.backgroundProperty().set(new Background(new BackgroundFill(Color.BEIGE, null, null)));
Scene scene = new Scene(root, SIZE, SIZE);
primaryStage.show();
Screen.getScreens().forEach(screen -> System.out.println("JAVAFX :"+ screen));
GraphicsEnvironment env =GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gdev = env.getScreenDevices();
for (GraphicsDevice d : gdev) {
System.out.println("AWT:" + d);
}
}
public static void main(String... strings) {
launch(strings);
}
}
这是我的 xorg.conf X11 配置:
Section "ServerLayout"
Identifier "Layout0"
Screen 0 "Screen0" 0 0
Screen 1 "Screen1" RightOf "Screen0"
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "Mouse0" "CorePointer"
Option "Xinerama" "0"
EndSection
Section "Files"
EndSection
Section "InputDevice"
# generated from default
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/psaux"
Option "Emulate3Buttons" "no"
Option "ZAxisMapping" "4 5"
EndSection
Section "InputDevice"
# generated from default
Identifier "Keyboard0"
Driver "kbd"
EndSection
Section "Monitor"
Identifier "Monitor0"
VendorName "Unknown"
ModelName "CMN"
HorizSync 53.0 - 66.0
VertRefresh 48.0 - 60.0
Option "DPMS"
EndSection
Section "Monitor"
Identifier "Monitor1"
VendorName "Unknown"
ModelName "DELL C7017T"
HorizSync 30.0 - 83.0
VertRefresh 56.0 - 76.0
EndSection
Section "Device"
Identifier "Device0"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BoardName "Quadro K3100M"
BusID "PCI:1:0:0"
Screen 0
EndSection
Section "Device"
Identifier "Device1"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BoardName "Quadro K3100M"
BusID "PCI:1:0:0"
Screen 1
EndSection
解决方案
推荐阅读
- javascript - Vue如何查看表单中的所有字段是否填写
- javascript - 带有外部 js 文件的 getElementbyID,为一个特定的 id 返回 null hust
- c# - C# 进程“持久性”
- javascript - 为什么使用 Promise.finally 会导致未捕获的异常?
- python - Python:从 json 获取特定键的所有值
- c# - 如何找出我的 RabbitMQ 连接失败的原因?
- python - 使用类并将其作为模块导入时出错
- html - 打印样式在 macOS Safari 打印预览中未正确显示
- python - 如何有效地将值“向上移动”到 3d 数组中的 NaN 位置?
- python - 如何在字符串中的元素周围移动元素