멀티 스크린
멀티 스크린은 여러 개의 스크린을 위한 데스크톱 스타일의 Wayland 컴포지터입니다.
소개
멀티 스크린은 여러 화면을 위한 데스크톱 스타일의 Wayland 컴포지터 예제입니다.
Qt로 멀티 스크린을 만드는 기본 원리에 대한 소개는 Qt Wayland Compositor 를 만드는 기본 원리에 대한 소개는 Minimal Qt 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 에는 클라이언트 콘텐츠를 포함하는 데 사용되는 창이 포함되며, 표준 설정과 마찬가지로 Qt Wayland Compositor. 각 창은 다른 창과 격리되어 있으므로 창 간에 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 에 대한 기본 보기를 설정합니다. 기본 ShellSurfaceItem 은 현재 얼마나 많이 표시되는지에 따라 선택됩니다.
참고: 동일한 컴포저에서 여러 웨이랜드 출력을 지원하려면 QGuiApplication 객체를 구성하기 전에 Qt::AA_ShareOpenGLContexts 속성을 설정해야 합니다. 이 예제에서는 main()
함수의 맨 처음에 이 작업을 수행합니다.
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true);
다중 출력도참조하세요 .
© 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.