이 페이지에서

멀티 스크린

Multi Screen은 여러 화면을 지원하는 데스크톱 스타일의 Wayland 컴포지터입니다.

소개

멀티 스크린은 여러 화면을 위한 데스크톱 스타일의 Wayland 컴포지터 예제입니다.

여러 컴포지터 창을 하나의 통합된 화면으로 결합

Qt를 사용하여 Qt Wayland Compositor 에 대한 소개는 Minimal Qml 예제를 참조하십시오.

다중 화면 지원

이 예제는 시스템에서 사용 가능한 각 화면마다 WaylandOutput 의 하위 클래스인 CompositorScreen 를 생성합니다. 사용 가능한 물리적 화면이 하나뿐인 경우, 이 예제는 더미 데이터를 사용하여 세 개의 화면을 에뮬레이트합니다.

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와 같은 표준 설정과 마찬가지로, 클라이언트 콘텐츠를 담는 데 사용됩니다. 각 Window는 서로 격리되어 있으므로, Window 항목 간에 Qt Quick 항목을 공유할 수 없습니다. 따라서 클라이언트가 연결되어 ShellSurface 가 생성되면, 각 화면에 하나씩 ShellSurfaceItem 가 생성됩니다.

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;

클라이언트 콘텐츠는 한 번에 한두 개의 화면에서만 표시됩니다. 화면 항목( ShellSurfaceItem )의 위치는 동기화되어 있어, 창이 한 화면으로 들어오면 동시에 다른 화면에서 빠져나갑니다. 이를 통해 화면 사이를 매끄럽게 이동하는 단일 항목처럼 보입니다. 클라이언트의 전체적인 위치는 공유된 ` moveItem `에 저장되며, 각 화면의 ` ShellSurfaceItem `의 상대적 위치는 이를 기반으로 계산됩니다. 만약 ` moveItem `가 현재 한 화면의 경계 밖에 있다면, 그 좌표는 이를 반영하게 되며 해당 화면에서는 보이지 않게 됩니다.

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

마지막으로, 적절한 시점에 ` WaylandQuickItem::setPrimary()`가 호출되어 ` ShellSurface`의 주 뷰(primary view)를 설정하며, 이는 클라이언트가 최대화 또는 전체 화면 모드를 요청할 때 사용됩니다. 주 ` ShellSurfaceItem `는 현재 표시된 영역의 비율에 따라 선택됩니다.

참고: 동일한 컴포지터에서 여러 Wayland 출력을지원하려면 , QGuiApplication 객체가 생성되기 전에 Qt::AA_ShareOpenGLContexts 속성을 설정해야 합니다. 이 예제에서는 main() 함수의 맨 처음에 이 작업을 수행합니다.

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

예제 프로젝트 @ code.qt.io

‘다중 출력’항목도 참조하십시오 .

© 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.