画面のまたがり
「Spanning Screens」は、Waylandクライアントが複数のディスプレイにまたがって表示される仕組みを示す例です。
はじめに
「Spanning Screens」は、Wayland コンポジターのサンプルであり、クライアントを上下のスクリーンにまたがって最大化するものです。

Qt を使用した Wayland コンポジターの作成に関する基本原則の概要については、 Qt Wayland Compositor については、「Minimal Qml」サンプルを参照してください。
複数スクリーンのサポート
この Qt Wayland Compositor 画面はWaylandOutput で表され、Windowは Qt Quick クライアントとコンポジターの UI の両方を表すシーンを格納するために使用されます。
この例では、プライマリ画面上に 2 つのウィンドウを作成することでマルチスクリーン環境をエミュレートしていますが、コードを少し変更するだけで、複数の物理画面に対応させることができます。
// Enable the following to make the output target an actual screen,
// for example when running on eglfs in a multi-display embedded system.
// screen: Qt.application.screens[0]各Windowは独立した Qt Quick シーンを表しているため、両方のウィンドウ内に同じクライアントコンテンツを表示させるには工夫が必要です。これを実現する方法は Qt Wayland Compositor 、同じクライアントコンテンツのビューを2つ作成することです。1つは「上」のウィンドウ用、もう1つは「下」のウィンドウ用です。これらのビューは、基盤となる同じグラフィックスバッファへの参照を共有します。これにより、クライアントのサーフェスの異なる領域をそれぞれのウィンドウにコピーすることが可能になります。
const topItem = chromeComponent.createObject(topSurfaceArea, {
shellSurface
});
const bottomItem = chromeComponent.createObject(bottomSurfaceArea, {
shellSurface,
y: Qt.binding(function() { return -topSurfaceArea.height;})
});クライアントがシェル拡張機能 XdgShell に接続すると、サーフェスへの参照を2つ作成します。そのうちの1つは「上」の出力に、もう1つは「下」の出力に追加されます。 「bottom」出力上のアイテムには、「top」出力の高さに相当するオフセットも付与されます。これにより、「bottom」出力に表示されるクライアントサーフェスの部分が、「top」出力の終了位置から始まるようになります。
const height = topSurfaceArea.pixelHeight + bottomSurfaceArea.pixelHeight;
const width = Math.max(bottomSurfaceArea.pixelWidth, topSurfaceArea.pixelWidth);
const size = Qt.size(width, height);
toplevel.sendFullscreen(size);さらに、クライアントに対して、上部と下部の両方のウィンドウを埋め尽くすようにサーフェスのサイズを変更するよう指示します。その結果、クライアントは2つのウィンドウ、つまり「画面」にまたがる形になります。
複数のアイテムから同じクライアントサーフェスを参照する手法は、さまざまな用途に活用できます。ウィンドウを画面間で移動できるデスクトップスタイルのコンポジターのデモについては、「Multi Screen」の例をご覧ください。
「Multi Output」の例では、クライアントサーフェスを、サイズやその他のプロパティが異なる複数の出力に表示する方法を示しています。
注: 同じコンポジターで複数のWayland出力をサポートするには 、QGuiApplication オブジェクトの生成前に、Qt::AA_ShareOpenGLContexts 属性を設定する必要があります。
© 2026 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.