在平铺模式下打开JavaFX子窗口(i3wm)

时间:2018-03-24 18:46:18

标签: java javafx kotlin tornadofx

我尝试编写一个可以打开多个子窗口的JavaFX应用程序(TornadoFX,因为我使用kotlin)。每个窗口都应在i3wm中以平铺模式显示。在其他非平铺窗口管理器上,它应该开始最大化。但目前它总是以浮动模式打开。我认为这可以通过最大化窗口来存档。所以我在两个变体中尝试了以下onDock()方法。但这两种变体都没有效果。

class FileMapFragment : Fragment() {

    val file:Path by param()

    final override val root =
            borderpane {
                ...
            }

    override fun onDock() {
        //Variant 1
        val screen = Screen.getPrimary()
        val bounds = screen.visualBounds

        currentStage?.x = bounds.minX
        currentStage?.y = bounds.minY
        currentStage?.width = bounds.width
        currentStage?.height = bounds.height

        //Variant 2
        currentStage?.isMaximized = true
        currentStage?.isIconified = true
    }
}

此片段通过以下代码打开

find<FileMapFragment>(
    mapOf(
        FileMapFragment::file to file
    )
).openWindow()

使用Variant 1时,它处于伪全屏模式,但不处于平铺模式。有人知道解决方案吗? (我认为这是一个普遍的JavaFX问题,并没有特别与kotlin / TornadoFX相关)

1 个答案:

答案 0 :(得分:1)

i3用于处理具有父窗口作为浮动窗口的窗口。要在平铺模式下启动窗口(或允许在其他窗口管理器中最小化/最大化),您必须将父窗口设置为null。在此示例中,以下内容将起作用:

find<FileMapFragment>(
    mapOf(
        FileMapFragment::file to file
    )
).openWindow(owner = null)
相关问题