マルチスクリーン

Multi Screen はマルチスクリーン用のデスクトップ型 Wayland コンポジターです。

はじめに

Multi-screenはマルチスクリーン用のデスクトップ型Waylandコンポジターのサンプルです。

Qtを使った Qt Wayland CompositorをQtで作成する基本な原理については、Minimal QML exampleを参照してください。

マルチスクリーンのサポート

システム上で利用可能な各画面に対して、このサンプルはWaylandOutput のサブクラスであるCompositorScreen を作成します。 物理的に利用可能な画面が1つしかない場合、このサンプルはダミーデータで3つの画面をエミュレートします。

Instantiator {
    id: screens
    model: emulated ? emulatedScreens : Qt.application.screens

    delegate: CompositorScreen {
        surfaceArea.color: "lightsteelblue"
        text: name
        compositor: comp
        screen: emulated ? Qt.application.screens[0] : modelData
        Component.onCompleted: if (!comp.defaultOutput) comp.defaultOutput = this
        position: Qt.point(virtualX, virtualY)
        windowed: emulated
    }
}

それぞれのWaylandOutput にはWindowが含まれ、これはクライアント・コンテンツを含むために使用されます。 Qt Wayland Compositor.各ウィンドウは他のウィンドウから分離されているので、Qt Quick アイテムを共有することはできません。したがって、クライアントが接続してShellSurface が作成されると、各スクリーンにShellSurfaceItem が1つずつ作成されます。

for (var i = 0; i < screens.count; ++i)
    createShellSurfaceItem(shellSurface, moveItem, screens.objectAt(i));

これらのアイテムは、同じクライアントコンテンツのビューとして機能します。クライアントのサーフェス自体は一度だけ作成され、サーフェスアイテムによって共有されます。

トップレベルのサーフェスアイテムは、各出力の背景Rectangle の子として作成される。これらのビューは後のために保存され、クライアントが子ウィンドウを生成する場合、それらはトップレベル・ウィンドウのアイテムの親になります。

var parentSurfaceItem = output.viewsBySurface[shellSurface.parentSurface];
var parent = parentSurfaceItem || output.surfaceArea;

クライアントのコンテンツは、一度に1つまたは2つのスクリーンのみに表示されます。ShellSurfaceItem 位置が同期されているので、ウィンドウが1つのスクリーンに入ると、同時に別のスクリーンから移動されます。これにより、画面間をシームレスに移動する1つのアイテムのように見えます。クライアントのグローバルな位置は共有のmoveItem に保存され、各画面のShellSurfaceItem の相対的な位置はこれに基づいて計算されます。現在moveItem があるスクリーンの境界の外にある場合、その座標はこれを反映し、そのスクリーンには表示されません。

x: surfaceItem.moveItem.x - surfaceItem.output.geometry.x
y: surfaceItem.moveItem.y - surfaceItem.output.geometry.y

最後に、WaylandQuickItem::setPrimary() が適切なタイミングで呼び出され、ShellSurface のプライマリ・ビューが設定されます。これは、クライアントが最大化またはフルスクリーンを要求したときに使用されます。プライマリ・ビューShellSurfaceItem は、現在どの程度表示されているかに基づいて選択される。

注意: 同じコンポジターで複数のWayland出力をサポートするためには、QGuiApplication オブジェクトを構築する前にQt::AA_ShareOpenGLContexts 属性を設定する必要があります。この例では、main() 関数の先頭でこれを行います。

QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true);

プロジェクト例 @ code.qt.io

マルチ出力」も参照してください

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.