javaFX误报了屏幕设备的数量

时间:2018-05-04 06:49:12

标签: java javafx graphics x11 nvidia

我使用java 8u162和NVidia GPU(以及最新的驱动程序)在Red Hat 6.8 x64上使用2个全高清屏幕在Linux上开发javaFX应用程序。

我在检索物理屏幕数量方面遇到了问题:

  • 当X服务器处于扩展桌面模式时(2个物理屏幕,但是 从0到3840像素的单个逻辑1),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

0 个答案:

没有答案