summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-07-02 09:12:27 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-07-07 09:29:06 +0200
commit322b28f183d20850326ebc229d2658586c8cc5b6 (patch)
treede569089a39446913037f8a3a70bb8b8dd79f3a1 /examples
parentc114e173ce2f47f8df2fb0ea35af0ede04354751 (diff)
downloadqtwayland-322b28f183d20850326ebc229d2658586c8cc5b6.tar.gz
Remove deprecated code
XdgShellv5 and XdgShellv6 have been deprecated in the compositor since 5.15, and wl-scaler since 5.13. These are now removed. Since the qwindow-compositor has not been updated for a long time, it depends on the outdated protocols. This change removes it, since it no longer represents best practices. This means we will be missing a proper C++-based compositor for now, so we will have to create a new one later. Change-Id: Icc6ef97c17e553f266c4145abeef26ddd631d6bf Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/wayland/.prev_CMakeLists.txt1
-rw-r--r--examples/wayland/CMakeLists.txt1
-rw-r--r--examples/wayland/hwlayer-compositor/main.qml1
-rw-r--r--examples/wayland/minimal-cpp/README3
-rw-r--r--examples/wayland/minimal-qml/main.qml4
-rw-r--r--examples/wayland/multi-screen/qml/main.qml4
-rw-r--r--examples/wayland/pure-qml/qml/main.qml5
-rw-r--r--examples/wayland/qwindow-compositor/.prev_CMakeLists.txt59
-rw-r--r--examples/wayland/qwindow-compositor/CMakeLists.txt59
-rw-r--r--examples/wayland/qwindow-compositor/compositor.cpp550
-rw-r--r--examples/wayland/qwindow-compositor/compositor.h195
-rw-r--r--examples/wayland/qwindow-compositor/doc/src/qwindow-compositor.qdoc36
-rw-r--r--examples/wayland/qwindow-compositor/main.cpp66
-rw-r--r--examples/wayland/qwindow-compositor/qwindow-compositor.pro20
-rw-r--r--examples/wayland/qwindow-compositor/qwindow-compositor.qrc5
-rw-r--r--examples/wayland/qwindow-compositor/window.cpp282
-rw-r--r--examples/wayland/qwindow-compositor/window.h114
-rw-r--r--examples/wayland/texture-sharing/custom-compositor/qml/main.qml4
-rw-r--r--examples/wayland/texture-sharing/minimal-compositor.qml4
-rw-r--r--examples/wayland/wayland.pro1
20 files changed, 0 insertions, 1414 deletions
diff --git a/examples/wayland/.prev_CMakeLists.txt b/examples/wayland/.prev_CMakeLists.txt
index 435734b7..490035a9 100644
--- a/examples/wayland/.prev_CMakeLists.txt
+++ b/examples/wayland/.prev_CMakeLists.txt
@@ -1,7 +1,6 @@
# Generated from wayland.pro.
if(QT_FEATURE_opengl)
- add_subdirectory(qwindow-compositor)
add_subdirectory(minimal-cpp)
endif()
if(TARGET Qt::Quick)
diff --git a/examples/wayland/CMakeLists.txt b/examples/wayland/CMakeLists.txt
index 9470d3a1..1275ca2e 100644
--- a/examples/wayland/CMakeLists.txt
+++ b/examples/wayland/CMakeLists.txt
@@ -2,7 +2,6 @@
if(QT_FEATURE_wayland_server) # special case
if(QT_FEATURE_opengl)
- add_subdirectory(qwindow-compositor)
add_subdirectory(minimal-cpp)
endif()
if(TARGET Qt::Quick)
diff --git a/examples/wayland/hwlayer-compositor/main.qml b/examples/wayland/hwlayer-compositor/main.qml
index b4f088c9..ae4720f3 100644
--- a/examples/wayland/hwlayer-compositor/main.qml
+++ b/examples/wayland/hwlayer-compositor/main.qml
@@ -156,6 +156,5 @@ WaylandCompositor {
shellSurfaces.append({shSurface: shellSurface, animatePosition: false, animateOpacity: false, level: 0});
}
XdgShell { onToplevelCreated: addShellSurface(xdgSurface) }
- XdgShellV6 { onToplevelCreated: addShellSurface(xdgSurface) }
WlShell { onWlShellSurfaceCreated: addShellSurface(shellSurface) }
}
diff --git a/examples/wayland/minimal-cpp/README b/examples/wayland/minimal-cpp/README
index 87c389c3..2a4a51f3 100644
--- a/examples/wayland/minimal-cpp/README
+++ b/examples/wayland/minimal-cpp/README
@@ -3,6 +3,3 @@ and running. Input events are not delivered to clients, to avoid the logic
for finding the correct window and map the coordinates. This example uses the
IVI-application shell protocol, positioning windows based on the ivi_id.
-See the qwindow-compositor example for information on how to implement
-support for key and mouse events, and everything else a proper desktop
-compositor needs.
diff --git a/examples/wayland/minimal-qml/main.qml b/examples/wayland/minimal-qml/main.qml
index 61cb6c9e..55ec9c03 100644
--- a/examples/wayland/minimal-qml/main.qml
+++ b/examples/wayland/minimal-qml/main.qml
@@ -82,10 +82,6 @@ WaylandCompositor {
onWlShellSurfaceCreated:
shellSurfaces.append({shellSurface: shellSurface});
}
- XdgShellV6 {
- onToplevelCreated:
- shellSurfaces.append({shellSurface: xdgSurface});
- }
XdgShell {
onToplevelCreated:
shellSurfaces.append({shellSurface: xdgSurface});
diff --git a/examples/wayland/multi-screen/qml/main.qml b/examples/wayland/multi-screen/qml/main.qml
index ecd32739..2925d7e0 100644
--- a/examples/wayland/multi-screen/qml/main.qml
+++ b/examples/wayland/multi-screen/qml/main.qml
@@ -100,10 +100,6 @@ WaylandCompositor {
onWlShellSurfaceCreated: handleShellSurfaceCreated(shellSurface)
}
- XdgShellV6 {
- onToplevelCreated: handleShellSurfaceCreated(xdgSurface)
- }
-
XdgShell {
onToplevelCreated: handleShellSurfaceCreated(xdgSurface)
}
diff --git a/examples/wayland/pure-qml/qml/main.qml b/examples/wayland/pure-qml/qml/main.qml
index 391dbed4..83d7b2a1 100644
--- a/examples/wayland/pure-qml/qml/main.qml
+++ b/examples/wayland/pure-qml/qml/main.qml
@@ -62,11 +62,6 @@ WaylandCompositor {
onToplevelCreated: screen.handleShellSurface(xdgSurface)
}
- // Unstable version of xdg-shell still used by some clients
- XdgShellV6 {
- onToplevelCreated: screen.handleShellSurface(xdgSurface)
- }
-
// Deprecated shell extension, still used by some clients
WlShell {
onWlShellSurfaceCreated: screen.handleShellSurface(shellSurface)
diff --git a/examples/wayland/qwindow-compositor/.prev_CMakeLists.txt b/examples/wayland/qwindow-compositor/.prev_CMakeLists.txt
deleted file mode 100644
index 0207bb1c..00000000
--- a/examples/wayland/qwindow-compositor/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,59 +0,0 @@
-# Generated from qwindow-compositor.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(qwindow-compositor LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/wayland/qwindow-compositor")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS WaylandCompositor)
-
-add_qt_gui_executable(qwindow-compositor
- compositor.cpp compositor.h
- main.cpp
- window.cpp window.h
-)
-target_include_directories(qwindow-compositor PUBLIC
- ../../include
-)
-
-target_link_libraries(qwindow-compositor PUBLIC
- # Remove: L
- ../../lib
- Qt::Core
- Qt::Gui
- Qt::WaylandCompositor
-)
-
-
-# Resources:
-set_source_files_properties("../pure-qml/images/background.jpg"
- PROPERTIES QT_RESOURCE_ALIAS "background.jpg"
-)
-set(qwindow-compositor_resource_files
- "../pure-qml/images/background.jpg"
-)
-
-qt6_add_resources(qwindow-compositor "qwindow-compositor"
- PREFIX
- "/"
- FILES
- ${qwindow-compositor_resource_files}
-)
-
-install(TARGETS qwindow-compositor
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/wayland/qwindow-compositor/CMakeLists.txt b/examples/wayland/qwindow-compositor/CMakeLists.txt
deleted file mode 100644
index 6894f18f..00000000
--- a/examples/wayland/qwindow-compositor/CMakeLists.txt
+++ /dev/null
@@ -1,59 +0,0 @@
-# Generated from qwindow-compositor.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(qwindow-compositor LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/wayland/qwindow-compositor")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS WaylandCompositor)
-
-add_qt_gui_executable(qwindow-compositor
- compositor.cpp compositor.h
- main.cpp
- window.cpp window.h
-)
-target_include_directories(qwindow-compositor PUBLIC
- ../../include
-)
-
-target_link_libraries(qwindow-compositor PUBLIC
- # Remove: L
- #../../lib # special case
- Qt::Core
- Qt::Gui
- Qt::WaylandCompositor
-)
-
-
-# Resources:
-set_source_files_properties("../pure-qml/images/background.jpg"
- PROPERTIES QT_RESOURCE_ALIAS "background.jpg"
-)
-set(qwindow-compositor_resource_files
- "../pure-qml/images/background.jpg"
-)
-
-qt6_add_resources(qwindow-compositor "qwindow-compositor"
- PREFIX
- "/"
- FILES
- ${qwindow-compositor_resource_files}
-)
-
-install(TARGETS qwindow-compositor
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/wayland/qwindow-compositor/compositor.cpp b/examples/wayland/qwindow-compositor/compositor.cpp
deleted file mode 100644
index 72f23ce6..00000000
--- a/examples/wayland/qwindow-compositor/compositor.cpp
+++ /dev/null
@@ -1,550 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Wayland module
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "compositor.h"
-
-#include <QMouseEvent>
-#include <QKeyEvent>
-#include <QTouchEvent>
-
-#include <QtWaylandCompositor/QWaylandXdgShellV5>
-#include <QtWaylandCompositor/QWaylandWlShellSurface>
-#include <QtWaylandCompositor/qwaylandseat.h>
-#include <QtWaylandCompositor/qwaylanddrag.h>
-
-#include <QDebug>
-#include <QOpenGLContext>
-
-#ifndef GL_TEXTURE_EXTERNAL_OES
-#define GL_TEXTURE_EXTERNAL_OES 0x8D65
-#endif
-
-View::View(Compositor *compositor)
- : m_compositor(compositor)
-{}
-
-QOpenGLTexture *View::getTexture()
-{
- bool newContent = advance();
- QWaylandBufferRef buf = currentBuffer();
- if (!buf.hasContent())
- m_texture = nullptr;
- if (newContent) {
- m_texture = buf.toOpenGLTexture();
- if (surface()) {
- m_size = surface()->destinationSize();
- m_origin = buf.origin() == QWaylandSurface::OriginTopLeft
- ? QOpenGLTextureBlitter::OriginTopLeft
- : QOpenGLTextureBlitter::OriginBottomLeft;
- }
- }
-
- return m_texture;
-}
-
-QOpenGLTextureBlitter::Origin View::textureOrigin() const
-{
- return m_origin;
-}
-
-QSize View::size() const
-{
- return surface() ? surface()->destinationSize() : m_size;
-}
-
-bool View::isCursor() const
-{
- return surface() && surface()->isCursorSurface();
-}
-
-
-void View::onXdgSetMaximized()
-{
- m_xdgSurface->sendMaximized(output()->geometry().size());
-
- // An improvement here, would have been to wait for the commit after the ack_configure for the
- // request above before moving the window. This would have prevented the window from being
- // moved until the contents of the window had actually updated. This improvement is left as an
- // exercise for the reader.
- setPosition(QPoint(0, 0));
-}
-
-void View::onXdgUnsetMaximized()
-{
- m_xdgSurface->sendUnmaximized();
-}
-
-void View::onXdgSetFullscreen(QWaylandOutput* clientPreferredOutput)
-{
- QWaylandOutput *outputToFullscreen = clientPreferredOutput
- ? clientPreferredOutput
- : output();
-
- m_xdgSurface->sendFullscreen(outputToFullscreen->geometry().size());
-
- // An improvement here, would have been to wait for the commit after the ack_configure for the
- // request above before moving the window. This would have prevented the window from being
- // moved until the contents of the window had actually updated. This improvement is left as an
- // exercise for the reader.
- setPosition(outputToFullscreen->position());
-}
-
-void View::onOffsetForNextFrame(const QPoint &offset)
-{
- m_offset = offset;
- setPosition(position() + offset);
-}
-
-
-void View::timerEvent(QTimerEvent *event)
-{
- if (event->timerId() != m_animationTimer.timerId())
- return;
-
- m_compositor->triggerRender();
-
- if (m_animationCountUp) {
- m_animationFactor += .08;
- if (m_animationFactor > 1.0) {
- m_animationFactor = 1.0;
- m_animationTimer.stop();
- emit animationDone();
- }
- } else {
- m_animationFactor -= .08;
- if (m_animationFactor < 0.01) {
- m_animationFactor = 0.01;
- m_animationTimer.stop();
- emit animationDone();
- }
- }
-}
-
-void View::startAnimation(bool countUp)
-{
- m_animationCountUp = countUp;
- m_animationFactor = countUp ? .1 : 1.0;
- m_animationTimer.start(20, this);
-}
-
-void View::cancelAnimation()
-{
- m_animationFactor = 1.0;
- m_animationTimer.stop();
-}
-
-void View::onXdgUnsetFullscreen()
-{
- onXdgUnsetMaximized();
-}
-
-Compositor::Compositor(QWindow *window)
- : m_window(window)
- , m_wlShell(new QWaylandWlShell(this))
- , m_xdgShell(new QWaylandXdgShellV5(this))
-{
- connect(m_wlShell, &QWaylandWlShell::wlShellSurfaceCreated, this, &Compositor::onWlShellSurfaceCreated);
- connect(m_xdgShell, &QWaylandXdgShellV5::xdgSurfaceCreated, this, &Compositor::onXdgSurfaceCreated);
- connect(m_xdgShell, &QWaylandXdgShellV5::xdgPopupRequested, this, &Compositor::onXdgPopupRequested);
-}
-
-Compositor::~Compositor()
-{
-}
-
-void Compositor::create()
-{
- QWaylandOutput *output = new QWaylandOutput(this, m_window);
- QWaylandOutputMode mode(QSize(800, 600), 60000);
- output->addMode(mode, true);
- QWaylandCompositor::create();
- output->setCurrentMode(mode);
-
- connect(this, &QWaylandCompositor::surfaceCreated, this, &Compositor::onSurfaceCreated);
- connect(defaultSeat(), &QWaylandSeat::cursorSurfaceRequest, this, &Compositor::adjustCursorSurface);
- connect(defaultSeat()->drag(), &QWaylandDrag::dragStarted, this, &Compositor::startDrag);
-
- connect(this, &QWaylandCompositor::subsurfaceChanged, this, &Compositor::onSubsurfaceChanged);
-}
-
-void Compositor::onSurfaceCreated(QWaylandSurface *surface)
-{
- connect(surface, &QWaylandSurface::surfaceDestroyed, this, &Compositor::surfaceDestroyed);
- connect(surface, &QWaylandSurface::hasContentChanged, this, &Compositor::surfaceHasContentChanged);
- connect(surface, &QWaylandSurface::redraw, this, &Compositor::triggerRender);
-
- connect(surface, &QWaylandSurface::subsurfacePositionChanged, this, &Compositor::onSubsurfacePositionChanged);
- View *view = new View(this);
- view->setSurface(surface);
- view->setOutput(outputFor(m_window));
- m_views << view;
- connect(view, &QWaylandView::surfaceDestroyed, this, &Compositor::viewSurfaceDestroyed);
- connect(surface, &QWaylandSurface::offsetForNextFrame, view, &View::onOffsetForNextFrame);
-}
-
-void Compositor::surfaceHasContentChanged()
-{
- QWaylandSurface *surface = qobject_cast<QWaylandSurface *>(sender());
- if (surface->hasContent()) {
- if (surface->role() == QWaylandWlShellSurface::role()
- || surface->role() == QWaylandXdgSurfaceV5::role()
- || surface->role() == QWaylandXdgPopupV5::role()) {
- defaultSeat()->setKeyboardFocus(surface);
- }
- }
- triggerRender();
-}
-
-void Compositor::surfaceDestroyed()
-{
- triggerRender();
-}
-
-void Compositor::viewSurfaceDestroyed()
-{
- View *view = qobject_cast<View*>(sender());
- view->setBufferLocked(true);
- view->startAnimation(false);
- connect(view, &View::animationDone, this, &Compositor::viewAnimationDone);
-}
-
-
-void Compositor::viewAnimationDone()
-{
- View *view = qobject_cast<View*>(sender());
- m_views.removeAll(view);
- delete view;
-}
-
-
-View * Compositor::findView(const QWaylandSurface *s) const
-{
- for (View* view : m_views) {
- if (view->surface() == s)
- return view;
- }
- return nullptr;
-}
-
-void Compositor::onWlShellSurfaceCreated(QWaylandWlShellSurface *wlShellSurface)
-{
- connect(wlShellSurface, &QWaylandWlShellSurface::startMove, this, &Compositor::onStartMove);
- connect(wlShellSurface, &QWaylandWlShellSurface::startResize, this, &Compositor::onWlStartResize);
- connect(wlShellSurface, &QWaylandWlShellSurface::setTransient, this, &Compositor::onSetTransient);
- connect(wlShellSurface, &QWaylandWlShellSurface::setPopup, this, &Compositor::onSetPopup);
-
- View *view = findView(wlShellSurface->surface());
- Q_ASSERT(view);
- view->m_wlShellSurface = wlShellSurface;
- view->startAnimation(true);
-}
-
-void Compositor::onXdgSurfaceCreated(QWaylandXdgSurfaceV5 *xdgSurface)
-{
- connect(xdgSurface, &QWaylandXdgSurfaceV5::startMove, this, &Compositor::onStartMove);
- connect(xdgSurface, &QWaylandXdgSurfaceV5::startResize, this, &Compositor::onXdgStartResize);
-
- View *view = findView(xdgSurface->surface());
- Q_ASSERT(view);
- view->m_xdgSurface = xdgSurface;
-
- connect(xdgSurface, &QWaylandXdgSurfaceV5::setMaximized, view, &View::onXdgSetMaximized);
- connect(xdgSurface, &QWaylandXdgSurfaceV5::setFullscreen, view, &View::onXdgSetFullscreen);
- connect(xdgSurface, &QWaylandXdgSurfaceV5::unsetMaximized, view, &View::onXdgUnsetMaximized);
- connect(xdgSurface, &QWaylandXdgSurfaceV5::unsetFullscreen, view, &View::onXdgUnsetFullscreen);
- view->startAnimation(true);
-}
-
-void Compositor::onXdgPopupRequested(QWaylandSurface *surface, QWaylandSurface *parent,
- QWaylandSeat *seat, const QPoint &position,
- const QWaylandResource &resource)
-{
- Q_UNUSED(seat);
-
- QWaylandXdgPopupV5 *xdgPopup = new QWaylandXdgPopupV5(m_xdgShell, surface, parent, position, resource);
-
- View *view = findView(surface);
- Q_ASSERT(view);
-
- View *parentView = findView(parent);
- Q_ASSERT(parentView);
-
- view->setPosition(parentView->position() + position);
- view->m_xdgPopup = xdgPopup;
-}
-
-void Compositor::onStartMove()
-{
- closePopups();
- emit startMove();
-}
-
-void Compositor::onWlStartResize(QWaylandSeat *, QWaylandWlShellSurface::ResizeEdge edges)
-{
- closePopups();
- emit startResize(int(edges), false);
-}
-
-void Compositor::onXdgStartResize(QWaylandSeat *seat,
- QWaylandXdgSurfaceV5::ResizeEdge edges)
-{
- Q_UNUSED(seat);
- emit startResize(int(edges), true);
-}
-
-void Compositor::onSetTransient(QWaylandSurface *parent, const QPoint &relativeToParent, bool inactive)
-{
- Q_UNUSED(inactive);
-
- QWaylandWlShellSurface *wlShellSurface = qobject_cast<QWaylandWlShellSurface*>(sender());
- View *view = findView(wlShellSurface->surface());
-
- if (view) {
- raise(view);
- View *parentView = findView(parent);
- if (parentView)
- view->setPosition(parentView->position() + relativeToParent);
- }
-}
-
-void Compositor::onSetPopup(QWaylandSeat *seat, QWaylandSurface *parent, const QPoint &relativeToParent)
-{
- Q_UNUSED(seat);
- QWaylandWlShellSurface *surface = qobject_cast<QWaylandWlShellSurface*>(sender());
- View *view = findView(surface->surface());
- if (view) {
- raise(view);
- View *parentView = findView(parent);
- if (parentView)
- view->setPosition(parentView->position() + relativeToParent);
- view->cancelAnimation();
- }
-}
-
-void Compositor::onSubsurfaceChanged(QWaylandSurface *child, QWaylandSurface *parent)
-{
- View *view = findView(child);
- View *parentView = findView(parent);
- view->setParentView(parentView);
-}
-
-void Compositor::onSubsurfacePositionChanged(const QPoint &position)
-{
- QWaylandSurface *surface = qobject_cast<QWaylandSurface*>(sender());
- if (!surface)
- return;
- View *view = findView(surface);
- view->setPosition(position);
- triggerRender();
-}
-
-void Compositor::triggerRender()
-{
- m_window->requestUpdate();
-}
-
-void Compositor::startRender()
-{
- QWaylandOutput *out = defaultOutput();
- if (out)
- out->frameStarted();
-}
-
-void Compositor::endRender()
-{
- QWaylandOutput *out = defaultOutput();
- if (out)
- out->sendFrameCallbacks();
-}
-
-void Compositor::updateCursor()
-{
- m_cursorView.advance();
- QImage image = m_cursorView.currentBuffer().image();
- if (!image.isNull())
- m_window->setCursor(QCursor(QPixmap::fromImage(image), m_cursorHotspotX, m_cursorHotspotY));
-}
-
-void Compositor::adjustCursorSurface(QWaylandSurface *surface, int hotspotX, int hotspotY)
-{
- if ((m_cursorView.surface() != surface)) {
- if (m_cursorView.surface())
- disconnect(m_cursorView.surface(), &QWaylandSurface::redraw, this, &Compositor::updateCursor);
- if (surface)
- connect(surface, &QWaylandSurface::redraw, this, &Compositor::updateCursor);
- }
-
- m_cursorView.setSurface(surface);
- m_cursorHotspotX = hotspotX;
- m_cursorHotspotY = hotspotY;
-
- if (surface && surface->hasContent())
- updateCursor();
-}
-
-void Compositor::closePopups()
-{
- m_wlShell->closeAllPopups();
- m_xdgShell->closeAllPopups();
-}
-
-void Compositor::handleMouseEvent(QWaylandView *target, QMouseEvent *me)
-{
- auto popClient = popupClient();
- if (target && me->type() == QEvent::MouseButtonPress
- && popClient && popClient != target->surface()->client()) {
- closePopups();
- }
-
- QWaylandSeat *seat = defaultSeat();
- QWaylandSurface *surface = target ? target->surface() : nullptr;
- switch (me->type()) {
- case QEvent::MouseButtonPress:
- seat->sendMousePressEvent(me->button());
- if (surface != seat->keyboardFocus()) {
- if (surface == nullptr
- || surface->role() == QWaylandWlShellSurface::role()
- || surface->role() == QWaylandXdgSurfaceV5::role()
- || surface->role() == QWaylandXdgPopupV5::role()) {
- seat->setKeyboardFocus(surface);
- }
- }
- break;
- case QEvent::MouseButtonRelease:
- seat->sendMouseReleaseEvent(me->button());
- break;
- case QEvent::MouseMove:
- seat->sendMouseMoveEvent(target, me->position(), me->globalPosition());
- default:
- break;
- }
-}
-
-void Compositor::handleResize(View *target, const QSize &initialSize, const QPoint &delta, int edge)
-{
- QWaylandWlShellSurface *wlShellSurface = target->m_wlShellSurface;
- if (wlShellSurface) {
- QWaylandWlShellSurface::ResizeEdge edges = QWaylandWlShellSurface::ResizeEdge(edge);
- QSize newSize = wlShellSurface->sizeForResize(initialSize, delta, edges);
- wlShellSurface->sendConfigure(newSize, edges);
- }
-
- QWaylandXdgSurfaceV5 *xdgSurface = target->m_xdgSurface;
- if (xdgSurface) {
- QWaylandXdgSurfaceV5::ResizeEdge edges = static_cast<QWaylandXdgSurfaceV5::ResizeEdge>(edge);
- QSize newSize = xdgSurface->sizeForResize(initialSize, delta, edges);
- xdgSurface->sendResizing(newSize);
- }
-}
-
-void Compositor::startDrag()
-{
- QWaylandDrag *currentDrag = defaultSeat()->drag();
- Q_ASSERT(currentDrag);
- View *iconView = findView(currentDrag->icon());
- iconView->setPosition(m_window->mapFromGlobal(QCursor::pos()));
-
- emit dragStarted(iconView);
-}
-
-void Compositor::handleDrag(View *target, QMouseEvent *me)
-{
- QPointF pos = me->position();
- QWaylandSurface *surface = nullptr;
- if (target) {
- pos -= target->position();
- surface = target->surface();
- }
- QWaylandDrag *currentDrag = defaultSeat()->drag();
- currentDrag->dragMove(surface, pos);
- if (me->buttons() == Qt::NoButton) {
- m_views.removeOne(findView(currentDrag->icon()));
- currentDrag->drop();
- }
-}
-
-QWaylandClient *Compositor::popupClient() const
-{
- auto client = m_wlShell->popupClient();
- return client ? client : m_xdgShell->popupClient();
-}
-
-// We only have a flat list of views, plus pointers from child to parent,
-// so maintaining a stacking order gets a bit complex. A better data
-// structure is left as an exercise for the reader.
-
-static int findEndOfChildTree(const QList<View*> &list, int index)
-{
- int n = list.count();
- View *parent = list.at(index);
- while (index + 1 < n) {
- if (list.at(index+1)->parentView() != parent)
- break;
- index = findEndOfChildTree(list, index + 1);
- }
- return index;
-}
-
-void Compositor::raise(View *view)
-{
- int startPos = m_views.indexOf(view);
- int endPos = findEndOfChildTree(m_views, startPos);
-
- int n = m_views.count();
- int tail = n - endPos - 1;
-
- //bubble sort: move the child tree to the end of the list
- for (int i = 0; i < tail; i++) {
- int source = endPos + 1 + i;
- int dest = startPos + i;
- for (int j = source; j > dest; j--)
- m_views.swapItemsAt(j, j-1);
- }
-}
diff --git a/examples/wayland/qwindow-compositor/compositor.h b/examples/wayland/qwindow-compositor/compositor.h
deleted file mode 100644
index 8f18dc53..00000000
--- a/examples/wayland/qwindow-compositor/compositor.h
+++ /dev/null
@@ -1,195 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Wayland module
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef WINDOWCOMPOSITOR_H
-#define WINDOWCOMPOSITOR_H
-
-#include <QtWaylandCompositor/QWaylandCompositor>
-#include <QtWaylandCompositor/QWaylandSurface>
-#include <QtWaylandCompositor/QWaylandView>
-#include <QtWaylandCompositor/QWaylandWlShellSurface>
-#include <QtWaylandCompositor/QWaylandXdgSurfaceV5>
-#include <QTimer>
-#include <QOpenGLTextureBlitter>
-
-QT_BEGIN_NAMESPACE
-
-class QWaylandWlShell;
-class QWaylandWlShellSurface;
-class QWaylandXdgShellV5;
-class QOpenGLTexture;
-class Compositor;
-
-class View : public QWaylandView
-{
- Q_OBJECT
-public:
- View(Compositor *compositor);
- QOpenGLTexture *getTexture();
- QOpenGLTextureBlitter::Origin textureOrigin() const;
- QPointF position() const { return m_position; }
- void setPosition(const QPointF &pos) { m_position = pos; }
- QSize size() const;
- bool isCursor() const;
- bool hasShell() const { return m_wlShellSurface; }
- void setParentView(View *parent) { m_parentView = parent; }
- View *parentView() const { return m_parentView; }
- QPointF parentPosition() const { return m_parentView ? (m_parentView->position() + m_parentView->parentPosition()) : QPointF(); }
- QSize windowSize() { return m_xdgSurface ? m_xdgSurface->windowGeometry().size() : surface() ? surface()->destinationSize() : m_size; }
- QPoint offset() const { return m_offset; }
-
- qreal animationFactor() const {return m_animationFactor; }
- void setAnimationFactor(qreal f) {m_animationFactor = f; }
-
-signals:
- void animationDone();
-
-protected:
- void timerEvent(QTimerEvent *event) override;
-
-private:
- friend class Compositor;
- Compositor *m_compositor = nullptr;
- GLenum m_textureTarget = GL_TEXTURE_2D;
- QOpenGLTexture *m_texture = nullptr;
- QOpenGLTextureBlitter::Origin m_origin;
- QPointF m_position;
- QSize m_size;
- QWaylandWlShellSurface *m_wlShellSurface = nullptr;
- QWaylandXdgSurfaceV5 *m_xdgSurface = nullptr;
- QWaylandXdgPopupV5 *m_xdgPopup = nullptr;
- View *m_parentView = nullptr;
- QPoint m_offset;
- qreal m_animationFactor = 1.0;
- QBasicTimer m_animationTimer;
- bool m_animationCountUp;
-
-public slots:
- void onXdgSetMaximized();
- void onXdgUnsetMaximized();
- void onXdgSetFullscreen(QWaylandOutput *output);
- void onXdgUnsetFullscreen();
- void onOffsetForNextFrame(const QPoint &offset);
-
- void startAnimation(bool countUp);
- void cancelAnimation();
-};
-
-class Compositor : public QWaylandCompositor
-{
- Q_OBJECT
-public:
- Compositor(QWindow *window);
- ~Compositor() override;
- void create() override;
-
- void startRender();
- void endRender();
-
- QList<View*> views() const { return m_views; }
- void raise(View *view);
-
- void handleMouseEvent(QWaylandView *target, QMouseEvent *me);
- void handleResize(View *target, const QSize &initialSize, const QPoint &delta, int edge);
- void handleDrag(View *target, QMouseEvent *me);
-
- QWaylandClient *popupClient() const;
- void closePopups();
-protected:
- void adjustCursorSurface(QWaylandSurface *surface, int hotspotX, int hotspotY);
-
-signals:
- void startMove();
- void startResize(int edge, bool anchored);
- void dragStarted(View *dragIcon);
- void frameOffset(const QPoint &offset);
-
-public slots:
- void triggerRender();
-
-private slots:
- void surfaceHasContentChanged();
- void surfaceDestroyed();
- void viewSurfaceDestroyed();
- void onStartMove();
- void onWlStartResize(QWaylandSeat *seat, QWaylandWlShellSurface::ResizeEdge edges);
- void onXdgStartResize(QWaylandSeat *seat, QWaylandXdgSurfaceV5::ResizeEdge edges);
-
- void startDrag();
-
-
- void onSurfaceCreated(QWaylandSurface *surface);
- void onWlShellSurfaceCreated(QWaylandWlShellSurface *wlShellSurface);
- void onXdgSurfaceCreated(QWaylandXdgSurfaceV5 *xdgSurface);
- void onXdgPopupRequested(QWaylandSurface *surface, QWaylandSurface *parent, QWaylandSeat *seat,
- const QPoint &position, const QWaylandResource &resource);
- void onSetTransient(QWaylandSurface *parentSurface, const QPoint &relativeToParent, bool inactive);
- void onSetPopup(QWaylandSeat *seat, QWaylandSurface *parent, const QPoint &relativeToParent);
-
- void onSubsurfaceChanged(QWaylandSurface *child, QWaylandSurface *parent);
- void onSubsurfacePositionChanged(const QPoint &position);
-
- void updateCursor();
- void viewAnimationDone();
-private:
- View *findView(const QWaylandSurface *s) const;
- QWindow *m_window = nullptr;
- QList<View*> m_views;
- QWaylandWlShell *m_wlShell = nullptr;
- QWaylandXdgShellV5 *m_xdgShell = nullptr;
- QWaylandView m_cursorView;
- int m_cursorHotspotX;
- int m_cursorHotspotY;
-};
-
-
-QT_END_NAMESPACE
-
-#endif // WINDOWCOMPOSITOR_H
diff --git a/examples/wayland/qwindow-compositor/doc/src/qwindow-compositor.qdoc b/examples/wayland/qwindow-compositor/doc/src/qwindow-compositor.qdoc
deleted file mode 100644
index c4f408c5..00000000
--- a/examples/wayland/qwindow-compositor/doc/src/qwindow-compositor.qdoc
+++ /dev/null
@@ -1,36 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \title Qt Wayland Compositor Examples - QWindow Compositor
- \example qwindow-compositor
- \brief QWindow Compositor is an example that demonstrates how to write a Wayland compositor in C++.
- \ingroup qtwaylandcompositor-examples
-
- QWindow Compositor is a desktop-style Wayland compositor example that demonstrates the power
- of the Qt Wayland Compositor C++ APIs.
-*/
diff --git a/examples/wayland/qwindow-compositor/main.cpp b/examples/wayland/qwindow-compositor/main.cpp
deleted file mode 100644
index 9d8c1f78..00000000
--- a/examples/wayland/qwindow-compositor/main.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Wayland module
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QGuiApplication>
-#include "window.h"
-#include "compositor.h"
-
-int main(int argc, char *argv[])
-{
- QGuiApplication app(argc, argv);
-
- Window window;
- Compositor compositor(&window);
- window.setCompositor(&compositor);
- window.resize(800,600);
- window.show();
-
- return app.exec();
-}
diff --git a/examples/wayland/qwindow-compositor/qwindow-compositor.pro b/examples/wayland/qwindow-compositor/qwindow-compositor.pro
deleted file mode 100644
index b9261e77..00000000
--- a/examples/wayland/qwindow-compositor/qwindow-compositor.pro
+++ /dev/null
@@ -1,20 +0,0 @@
-QT += gui waylandcompositor
-
-LIBS += -L ../../lib
-
-HEADERS += \
- window.h \
- compositor.h
-
-SOURCES += main.cpp \
- window.cpp \
- compositor.cpp
-
-# to make QtWaylandCompositor/... style includes working without installing
-INCLUDEPATH += $$PWD/../../include
-
-
-RESOURCES += qwindow-compositor.qrc
-
-target.path = $$[QT_INSTALL_EXAMPLES]/wayland/qwindow-compositor
-INSTALLS += target
diff --git a/examples/wayland/qwindow-compositor/qwindow-compositor.qrc b/examples/wayland/qwindow-compositor/qwindow-compositor.qrc
deleted file mode 100644
index 688dd900..00000000
--- a/examples/wayland/qwindow-compositor/qwindow-compositor.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file alias="background.jpg">../pure-qml/images/background.jpg</file>
- </qresource>
-</RCC>
diff --git a/examples/wayland/qwindow-compositor/window.cpp b/examples/wayland/qwindow-compositor/window.cpp
deleted file mode 100644
index 34066f42..00000000
--- a/examples/wayland/qwindow-compositor/window.cpp
+++ /dev/null
@@ -1,282 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Wayland module
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "window.h"
-
-#include <QMouseEvent>
-#include <QOpenGLWindow>
-#include <QOpenGLTexture>
-#include <QOpenGLFunctions>
-#include <QMatrix4x4>
-
-#include "compositor.h"
-#include <QtWaylandCompositor/qwaylandseat.h>
-
-Window::Window()
-{
-}
-
-void Window::setCompositor(Compositor *comp) {
- m_compositor = comp;
- connect(m_compositor, &Compositor::startMove, this, &Window::startMove);
- connect(m_compositor, &Compositor::startResize, this, &Window::startResize);
- connect(m_compositor, &Compositor::dragStarted, this, &Window::startDrag);
-}
-
-void Window::initializeGL()
-{
- QImage backgroundImage = QImage(QLatin1String(":/background.jpg")).rgbSwapped();
- backgroundImage.invertPixels();
- m_backgroundTexture = new QOpenGLTexture(backgroundImage, QOpenGLTexture::DontGenerateMipMaps);
- m_backgroundTexture->setMinificationFilter(QOpenGLTexture::Nearest);
- m_backgroundImageSize = backgroundImage.size();
- m_textureBlitter.create();
- m_compositor->create(); // the compositor's hardware integration may depend on GL
-}
-
-void Window::drawBackground()
-{
- for (int y = 0; y < height(); y += m_backgroundImageSize.height()) {
- for (int x = 0; x < width(); x += m_backgroundImageSize.width()) {
- QMatrix4x4 targetTransform = QOpenGLTextureBlitter::targetTransform(QRect(QPoint(x,y), m_backgroundImageSize), QRect(QPoint(0,0), size()));
- m_textureBlitter.blit(m_backgroundTexture->textureId(),
- targetTransform,
- QOpenGLTextureBlitter::OriginTopLeft);
- }
- }
-}
-
-QPointF Window::getAnchorPosition(const QPointF &position, int resizeEdge, const QSize &windowSize)
-{
- float y = position.y();
- if (resizeEdge & QWaylandXdgSurfaceV5::ResizeEdge::TopEdge)
- y += windowSize.height();
-
- float x = position.x();
- if (resizeEdge & QWaylandXdgSurfaceV5::ResizeEdge::LeftEdge)
- x += windowSize.width();
-
- return QPointF(x, y);
-}
-
-QPointF Window::getAnchoredPosition(const QPointF &anchorPosition, int resizeEdge, const QSize &windowSize)
-{
- return anchorPosition - getAnchorPosition(QPointF(), resizeEdge, windowSize);
-}
-
-void Window::paintGL()
-{
- m_compositor->startRender();
- QOpenGLFunctions *functions = context()->functions();
- functions->glClearColor(1.f, .6f, .0f, 0.5f);
- functions->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- m_textureBlitter.bind();
- drawBackground();
-
- functions->glEnable(GL_BLEND);
- functions->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- GLenum currentTarget = GL_TEXTURE_2D;
- const auto views = m_compositor->views();
- for (View *view : views) {
- if (view->isCursor())
- continue;
- auto texture = view->getTexture();
- if (!texture)
- continue;
- if (texture->target() != currentTarget) {
- currentTarget = texture->target();
- m_textureBlitter.bind(currentTarget);
- }
- QWaylandSurface *surface = view->surface();
- if ((surface && surface->hasContent()) || view->isBufferLocked()) {
- QSize s = view->size();
- if (!s.isEmpty()) {
- if (m_mouseView == view && m_grabState == ResizeGrab && m_resizeAnchored)
- view->setPosition(getAnchoredPosition(m_resizeAnchorPosition, m_resizeEdge, s));
- QPointF pos = view->position() + view->parentPosition();
- QRectF surfaceGeometry(pos, s);
- auto surfaceOrigin = view->textureOrigin();
- auto sf = view->animationFactor();
- QRectF targetRect(surfaceGeometry.topLeft() * sf, surfaceGeometry.size() * sf);
- QMatrix4x4 targetTransform = QOpenGLTextureBlitter::targetTransform(targetRect, QRect(QPoint(), size()));
- m_textureBlitter.blit(texture->textureId(), targetTransform, surfaceOrigin);
- }
- }
- }
- functions->glDisable(GL_BLEND);
-
- m_textureBlitter.release();
- m_compositor->endRender();
-}
-
-View *Window::viewAt(const QPointF &point)
-{
- View *ret = nullptr;
- const auto views = m_compositor->views();
- for (View *view : views) {
- if (view == m_dragIconView)
- continue;
- QRectF geom(view->position(), view->size());
- if (geom.contains(point))
- ret = view;
- }
- return ret;
-}
-
-void Window::startMove()
-{
- m_grabState = MoveGrab;
-}
-
-void Window::startResize(int edge, bool anchored)
-{
- m_initialSize = m_mouseView->windowSize();
- m_grabState = ResizeGrab;
- m_resizeEdge = edge;
- m_resizeAnchored = anchored;
- m_resizeAnchorPosition = getAnchorPosition(m_mouseView->position(), edge, m_mouseView->surface()->destinationSize());
-}
-
-void Window::startDrag(View *dragIcon)
-{
- m_grabState = DragGrab;
- m_dragIconView = dragIcon;
- m_compositor->raise(dragIcon);
-}
-
-void Window::mousePressEvent(QMouseEvent *e)
-{
- if (mouseGrab())
- return;
- if (m_mouseView.isNull()) {
- m_mouseView = viewAt(e->position());
- if (!m_mouseView) {
- m_compositor->closePopups();
- return;
- }
- if (e->modifiers() == Qt::AltModifier || e->modifiers() == Qt::MetaModifier)
- m_grabState = MoveGrab; //start move
- else
- m_compositor->raise(m_mouseView);
- m_initialMousePos = e->position();
- m_mouseOffset = e->position() - m_mouseView->position();
-
- QMouseEvent moveEvent(QEvent::MouseMove, e->position(), e->globalPosition(), Qt::NoButton, Qt::NoButton, e->modifiers());
- sendMouseEvent(&moveEvent, m_mouseView);
- }
- sendMouseEvent(e, m_mouseView);
-}
-
-void Window::mouseReleaseEvent(QMouseEvent *e)
-{
- if (!mouseGrab())
- sendMouseEvent(e, m_mouseView);
- if (e->buttons() == Qt::NoButton) {
- if (m_grabState == DragGrab) {
- View *view = viewAt(e->position());
- m_compositor->handleDrag(view, e);
- }
- m_mouseView = nullptr;
- m_grabState = NoGrab;
- }
-}
-
-void Window::mouseMoveEvent(QMouseEvent *e)
-{
- switch (m_grabState) {
- case NoGrab: {
- View *view = m_mouseView ? m_mouseView.data() : viewAt(e->position());
- sendMouseEvent(e, view);
- if (!view)
- setCursor(Qt::ArrowCursor);
- }
- break;
- case MoveGrab: {
- m_mouseView->setPosition(e->position() - m_mouseOffset);
- update();
- }
- break;
- case ResizeGrab: {
- QPoint delta = (e->position() - m_initialMousePos).toPoint();
- m_compositor->handleResize(m_mouseView, m_initialSize, delta, m_resizeEdge);
- }
- break;
- case DragGrab: {
- View *view = viewAt(e->position());
- m_compositor->handleDrag(view, e);
- if (m_dragIconView) {
- m_dragIconView->setPosition(e->position() + m_dragIconView->offset());
- update();
- }
- }
- break;
- }
-}
-
-void Window::sendMouseEvent(QMouseEvent *e, View *target)
-{
- QPointF mappedPos = e->position();
- if (target)
- mappedPos -= target->position();
- QMouseEvent viewEvent(e->type(), mappedPos, e->position(), e->button(), e->buttons(), e->modifiers());
- m_compositor->handleMouseEvent(target, &viewEvent);
-}
-
-void Window::keyPressEvent(QKeyEvent *e)
-{
- m_compositor->defaultSeat()->sendKeyPressEvent(e->nativeScanCode());
-}
-
-void Window::keyReleaseEvent(QKeyEvent *e)
-{
- m_compositor->defaultSeat()->sendKeyReleaseEvent(e->nativeScanCode());
-}
diff --git a/examples/wayland/qwindow-compositor/window.h b/examples/wayland/qwindow-compositor/window.h
deleted file mode 100644
index c16e726b..00000000
--- a/examples/wayland/qwindow-compositor/window.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Wayland module
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef COMPOSITORWINDOW_H
-#define COMPOSITORWINDOW_H
-
-#include <QOpenGLWindow>
-#include <QPointer>
-#include <QOpenGLTextureBlitter>
-
-QT_BEGIN_NAMESPACE
-
-class Compositor;
-class View;
-class QOpenGLTexture;
-
-class Window : public QOpenGLWindow
-{
-public:
- Window();
-
- void setCompositor(Compositor *comp);
-
-protected:
- void initializeGL() override;
- void paintGL() override;
-
- void mousePressEvent(QMouseEvent *e) override;
- void mouseReleaseEvent(QMouseEvent *e) override;
- void mouseMoveEvent(QMouseEvent *e) override;
-
- void keyPressEvent(QKeyEvent *e) override;
- void keyReleaseEvent(QKeyEvent *e) override;
-
-private slots:
- void startMove();
- void startResize(int edge, bool anchored);
- void startDrag(View *dragIcon);
-
-private:
- enum GrabState { NoGrab, MoveGrab, ResizeGrab, DragGrab };
-
- View *viewAt(const QPointF &point);
- bool mouseGrab() const { return m_grabState != NoGrab ;}
- void drawBackground();
- void sendMouseEvent(QMouseEvent *e, View *target);
- static QPointF getAnchoredPosition(const QPointF &anchorPosition, int resizeEdge, const QSize &windowSize);
- static QPointF getAnchorPosition(const QPointF &position, int resizeEdge, const QSize &windowSize);
-
- QOpenGLTextureBlitter m_textureBlitter;
- QSize m_backgroundImageSize;
- QOpenGLTexture *m_backgroundTexture = nullptr;
- Compositor *m_compositor = nullptr;
- QPointer<View> m_mouseView;
- GrabState m_grabState = NoGrab;
- QSize m_initialSize;
- int m_resizeEdge;
- bool m_resizeAnchored;
- QPointF m_resizeAnchorPosition;
- QPointF m_mouseOffset;
- QPointF m_initialMousePos;
- View *m_dragIconView = nullptr;
-};
-
-QT_END_NAMESPACE
-
-#endif // COMPOSITORWINDOW_H
diff --git a/examples/wayland/texture-sharing/custom-compositor/qml/main.qml b/examples/wayland/texture-sharing/custom-compositor/qml/main.qml
index 6a0b90c8..fc6befd9 100644
--- a/examples/wayland/texture-sharing/custom-compositor/qml/main.qml
+++ b/examples/wayland/texture-sharing/custom-compositor/qml/main.qml
@@ -105,10 +105,6 @@ WaylandCompositor {
onWlShellSurfaceCreated:
shellSurfaces.append({shellSurface: shellSurface});
}
- XdgShellV6 {
- onToplevelCreated:
- shellSurfaces.append({shellSurface: xdgSurface});
- }
XdgShell {
onToplevelCreated:
shellSurfaces.append({shellSurface: xdgSurface});
diff --git a/examples/wayland/texture-sharing/minimal-compositor.qml b/examples/wayland/texture-sharing/minimal-compositor.qml
index 226da429..84756047 100644
--- a/examples/wayland/texture-sharing/minimal-compositor.qml
+++ b/examples/wayland/texture-sharing/minimal-compositor.qml
@@ -75,10 +75,6 @@ WaylandCompositor {
onWlShellSurfaceCreated:
shellSurfaces.append({shellSurface: shellSurface});
}
- XdgShellV6 {
- onToplevelCreated:
- shellSurfaces.append({shellSurface: xdgSurface});
- }
XdgShell {
onToplevelCreated:
shellSurfaces.append({shellSurface: xdgSurface});
diff --git a/examples/wayland/wayland.pro b/examples/wayland/wayland.pro
index f9287481..e7ff0a16 100644
--- a/examples/wayland/wayland.pro
+++ b/examples/wayland/wayland.pro
@@ -5,7 +5,6 @@ TEMPLATE=subdirs
qtConfig(opengl) {
SUBDIRS += \
- qwindow-compositor \
minimal-cpp
}