diff options
author | Jørgen Lind <jorgen.lind@theqtcompany.com> | 2015-07-30 14:53:35 +0200 |
---|---|---|
committer | Jørgen Lind <jorgen.lind@theqtcompany.com> | 2015-08-28 13:09:42 +0200 |
commit | ce58545b220a49354533a27ef79cdbc8d50186cd (patch) | |
tree | 660232f61bc971d68c29b37acfa9c709f617c697 /src/compositor | |
parent | 5edaac978e01ead8648aad91f0d050748f7a8915 (diff) |
Rework how we manage extensions
Change-Id: If2cbf096e7419bc1bda007d5167ce39d1a5d50ae
Diffstat (limited to 'src/compositor')
52 files changed, 740 insertions, 911 deletions
diff --git a/src/compositor/compositor.pro b/src/compositor/compositor.pro index cf6300c06..90efd1fec 100644 --- a/src/compositor/compositor.pro +++ b/src/compositor/compositor.pro @@ -25,6 +25,6 @@ include ($$PWD/global/global.pri) include ($$PWD/wayland_wrapper/wayland_wrapper.pri) include ($$PWD/hardware_integration/hardware_integration.pri) include ($$PWD/compositor_api/compositor_api.pri) -include ($$PWD/windowmanagerprotocol/windowmanagerprotocol.pri) +include ($$PWD/extensions/extensions.pri) diff --git a/src/compositor/compositor_api/compositor_api.pri b/src/compositor/compositor_api/compositor_api.pri index 656f2e0c5..0cb5392dc 100644 --- a/src/compositor/compositor_api/compositor_api.pri +++ b/src/compositor/compositor_api/compositor_api.pri @@ -12,8 +12,6 @@ HEADERS += \ compositor_api/qwaylandbufferref.h \ compositor_api/qwaylandsurfaceview.h \ compositor_api/qwaylandsurfaceview_p.h \ - compositor_api/qwaylandglobalinterface.h \ - compositor_api/qwaylandsurfaceinterface.h \ compositor_api/qwaylandoutputspace.h \ compositor_api/qwaylandoutputspace_p.h @@ -27,8 +25,6 @@ SOURCES += \ compositor_api/qwaylanddrag.cpp \ compositor_api/qwaylandbufferref.cpp \ compositor_api/qwaylandsurfaceview.cpp \ - compositor_api/qwaylandglobalinterface.cpp \ - compositor_api/qwaylandsurfaceinterface.cpp \ compositor_api/qwaylandoutputspace.cpp QT += core-private diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp index 0c7342329..cc1826fc7 100644 --- a/src/compositor/compositor_api/qwaylandcompositor.cpp +++ b/src/compositor/compositor_api/qwaylandcompositor.cpp @@ -40,7 +40,6 @@ #include "qwaylandclient.h" #include "qwaylandinput.h" #include "qwaylandoutput.h" -#include "qwaylandglobalinterface.h" #include "qwaylandsurfaceview.h" #include "qwaylandclient.h" @@ -48,8 +47,9 @@ #include "wayland_wrapper/qwldatadevice_p.h" #include "wayland_wrapper/qwlsurface_p.h" #include "wayland_wrapper/qwlinputdevice_p.h" -#include "wayland_wrapper/qwlinputpanel_p.h" -#include "wayland_wrapper/qwlshellsurface_p.h" + +#include "extensions/qwlinputpanel_p.h" +#include "extensions/qwlshellsurface_p.h" #include <QtCore/QCoreApplication> #include <QtCore/QStringList> @@ -69,7 +69,6 @@ QWaylandCompositor::QWaylandCompositor(QObject *parent) QWaylandCompositor::~QWaylandCompositor() { - qDeleteAll(m_compositor->m_globals); delete m_compositor; } @@ -111,17 +110,6 @@ QWaylandCompositor::ExtensionFlags QWaylandCompositor::extensionFlags() const return m_compositor->extensions(); } -void QWaylandCompositor::addGlobalInterface(QWaylandGlobalInterface *interface) -{ - wl_global_create(m_compositor->wl_display(), interface->interface(), interface->version(), interface, QtWayland::Compositor::bindGlobal); - m_compositor->m_globals << interface; -} - -void QWaylandCompositor::addDefaultShell() -{ - addGlobalInterface(new QtWayland::Shell); -} - struct wl_display *QWaylandCompositor::waylandDisplay() const { return m_compositor->wl_display(); @@ -311,11 +299,6 @@ QWaylandInputDevice *QWaylandCompositor::defaultInputDevice() const return m_compositor->defaultInputDevice()->handle(); } -QWaylandInputPanel *QWaylandCompositor::inputPanel() const -{ - return m_compositor->inputPanel()->handle(); -} - QWaylandDrag *QWaylandCompositor::drag() const { return m_compositor->defaultInputDevice()->dragHandle(); @@ -346,12 +329,6 @@ void QWaylandCompositor::setCursorSurface(QWaylandSurface *surface, int hotspotX } #endif -void QWaylandCompositor::configureTouchExtension(TouchExtensionFlags flags) -{ - m_compositor->configureTouchExtension(flags); -} - - QWaylandSurfaceView *QWaylandCompositor::createSurfaceView(QWaylandSurface *surface) { QWaylandSurfaceView *view = createView(); diff --git a/src/compositor/compositor_api/qwaylandcompositor.h b/src/compositor/compositor_api/qwaylandcompositor.h index 462f381c6..984624383 100644 --- a/src/compositor/compositor_api/qwaylandcompositor.h +++ b/src/compositor/compositor_api/qwaylandcompositor.h @@ -38,6 +38,7 @@ #define QWAYLANDCOMPOSITOR_H #include <QtCompositor/qwaylandexport.h> +#include <QtCompositor/qwaylandextension.h> #include <QObject> #include <QImage> @@ -55,7 +56,6 @@ class QOpenGLContext; class QWaylandClient; class QWaylandSurface; class QWaylandInputDevice; -class QWaylandInputPanel; class QWaylandDrag; class QWaylandGlobalInterface; class QWaylandSurfaceView; @@ -67,7 +67,7 @@ namespace QtWayland class Compositor; } -class Q_COMPOSITOR_EXPORT QWaylandCompositor : public QObject +class Q_COMPOSITOR_EXPORT QWaylandCompositor : public QObject, public QWaylandExtensionContainer { Q_OBJECT Q_PROPERTY(QByteArray socketName READ socketName WRITE setSocketName) @@ -85,6 +85,7 @@ public: SubSurfaceExtension = 0x10, TextInputExtension = 0x20, HardwareIntegrationExtension = 0x40, + DefaultShellExtension = 0x80, DefaultExtensions = WindowManagerExtension | SurfaceExtension | QtKeyExtension | TouchExtension | HardwareIntegrationExtension }; @@ -102,9 +103,6 @@ public: void setExtensionFlags(ExtensionFlags flags); ExtensionFlags extensionFlags() const; - void addGlobalInterface(QWaylandGlobalInterface *interface); - void addDefaultShell(); - ::wl_display *waylandDisplay() const; Q_INVOKABLE void destroyClientForSurface(QWaylandSurface *surface); @@ -143,7 +141,6 @@ public: QWaylandInputDevice *defaultInputDevice() const; - QWaylandInputPanel *inputPanel() const; QWaylandDrag *drag() const; bool isDragging() const; @@ -156,12 +153,6 @@ public: void cleanupGraphicsResources(); - enum TouchExtensionFlag { - TouchExtMouseFromTouch = 0x01 - }; - Q_DECLARE_FLAGS(TouchExtensionFlags, TouchExtensionFlag) - void configureTouchExtension(TouchExtensionFlags flags); - QWaylandSurfaceView *createSurfaceView(QWaylandSurface *surface); QWaylandInputDevice *inputDeviceFor(QInputEvent *inputEvent); @@ -192,7 +183,6 @@ protected: }; Q_DECLARE_OPERATORS_FOR_FLAGS(QWaylandCompositor::ExtensionFlags) -Q_DECLARE_OPERATORS_FOR_FLAGS(QWaylandCompositor::TouchExtensionFlags) QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandglobalinterface.cpp b/src/compositor/compositor_api/qwaylandglobalinterface.cpp deleted file mode 100644 index 48f374eb8..000000000 --- a/src/compositor/compositor_api/qwaylandglobalinterface.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandglobalinterface.h" - -#include <wayland-server.h> - -QT_BEGIN_NAMESPACE - -QWaylandGlobalInterface::QWaylandGlobalInterface() -{ - -} - -QWaylandGlobalInterface::~QWaylandGlobalInterface() -{ - -} - -quint32 QWaylandGlobalInterface::version() const -{ - return interface()->version; -} - -QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandinputpanel.cpp b/src/compositor/compositor_api/qwaylandinputpanel.cpp index 8a2330220..a7fa8214d 100644 --- a/src/compositor/compositor_api/qwaylandinputpanel.cpp +++ b/src/compositor/compositor_api/qwaylandinputpanel.cpp @@ -36,6 +36,8 @@ #include "qwaylandinputpanel.h" +#include <QtCompositor/QWaylandCompositor> + #include <private/qobject_p.h> #include "qwlinputpanel_p.h" @@ -43,35 +45,16 @@ QT_BEGIN_NAMESPACE -class QWaylandInputPanelPrivate : public QObjectPrivate -{ -public: - QWaylandInputPanelPrivate(QtWayland::InputPanel *panel) - : inputPanel(panel) - { - } - - QtWayland::InputPanel *inputPanel; -}; - - -QWaylandInputPanel::QWaylandInputPanel(QtWayland::InputPanel *inputPanel) - : QObject(*new QWaylandInputPanelPrivate(inputPanel)) -{ -} - -QtWayland::InputPanel *QWaylandInputPanel::handle() const +QWaylandInputPanel::QWaylandInputPanel(QWaylandCompositor *compositor) + : QWaylandExtensionTemplate(*new QWaylandInputPanelPrivate(compositor->handle())) { - Q_D(const QWaylandInputPanel); - - return d->inputPanel; } QWaylandSurface *QWaylandInputPanel::focus() const { - Q_D(const QWaylandInputPanel); + Q_D(const QWaylandInputPanel); - QtWayland::Surface *surface = d->inputPanel->focus(); + QtWayland::Surface *surface = d->focus(); if (surface) return surface->waylandSurface(); return 0; @@ -81,14 +64,19 @@ bool QWaylandInputPanel::visible() const { Q_D(const QWaylandInputPanel); - return d->inputPanel->inputPanelVisible(); + return d->inputPanelVisible(); } QRect QWaylandInputPanel::cursorRectangle() const { Q_D(const QWaylandInputPanel); - return d->inputPanel->cursorRectangle(); + return d->cursorRectangle(); +} + +QWaylandInputPanel *QWaylandInputPanel::get(QWaylandExtensionContainer *container) +{ + return static_cast<QWaylandInputPanel *>(container->extension(QtWaylandServer::wl_input_panel::name())); } QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandinputpanel.h b/src/compositor/compositor_api/qwaylandinputpanel.h index a4a710fbb..9336b7cad 100644 --- a/src/compositor/compositor_api/qwaylandinputpanel.h +++ b/src/compositor/compositor_api/qwaylandinputpanel.h @@ -38,6 +38,7 @@ #define QWAYLANDINPUTPANEL_H #include <QtCompositor/qwaylandexport.h> +#include <QtCompositor/qwaylandextension.h> #include <QObject> #include <QRect> @@ -52,7 +53,7 @@ namespace QtWayland { class InputPanel; } -class Q_COMPOSITOR_EXPORT QWaylandInputPanel : public QObject +class Q_COMPOSITOR_EXPORT QWaylandInputPanel : public QWaylandExtensionTemplate { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandInputPanel) @@ -62,14 +63,13 @@ class Q_COMPOSITOR_EXPORT QWaylandInputPanel : public QObject Q_PROPERTY(QRect cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged) public: - explicit QWaylandInputPanel(QtWayland::InputPanel *inputPanel); - - QtWayland::InputPanel *handle() const; + explicit QWaylandInputPanel(QWaylandCompositor *compositor); QWaylandSurface *focus() const; bool visible() const; QRect cursorRectangle() const; + static QWaylandInputPanel *get(QWaylandExtensionContainer *container); Q_SIGNALS: void focusChanged(); void visibleChanged(); diff --git a/src/compositor/compositor_api/qwaylandquickcompositor.cpp b/src/compositor/compositor_api/qwaylandquickcompositor.cpp index 39dae9461..75027299b 100644 --- a/src/compositor/compositor_api/qwaylandquickcompositor.cpp +++ b/src/compositor/compositor_api/qwaylandquickcompositor.cpp @@ -60,6 +60,11 @@ void QWaylandQuickCompositor::create() if (m_initializeLegazyQmlNames) registerLegacyQmlNames(); + if (m_exposeDefaultShell) + setExtensionFlags(extensionFlags() | QWaylandCompositor::DefaultShellExtension); + else + setExtensionFlags(extensionFlags() & !QWaylandCompositor::DefaultShellExtension); + QWaylandCompositor::create(); } @@ -133,8 +138,8 @@ void QWaylandQuickCompositor::classBegin() void QWaylandQuickCompositor::componentComplete() { - if (m_exposeDefaultShell) - addDefaultShell(); + //if (m_exposeDefaultShell) + //addDefaultShell(); } diff --git a/src/compositor/compositor_api/qwaylandquicksurface.cpp b/src/compositor/compositor_api/qwaylandquicksurface.cpp index 96e9ca484..ffa8f437f 100644 --- a/src/compositor/compositor_api/qwaylandquicksurface.cpp +++ b/src/compositor/compositor_api/qwaylandquicksurface.cpp @@ -38,7 +38,6 @@ #include <QOpenGLTexture> #include <QQuickWindow> #include <QDebug> -#include <QQmlPropertyMap> #include "qwaylandquicksurface.h" #include "qwaylandquickcompositor.h" @@ -47,6 +46,9 @@ #include <QtCompositor/qwaylandbufferref.h> #include <QtCompositor/private/qwaylandsurface_p.h> +#include <QtCompositor/private/qwayland-server-surface-extension.h> +#include <QtCompositor/private/qwlextendedsurface_p.h> + QT_BEGIN_NAMESPACE class QWaylandQuickSurfacePrivate : public QWaylandSurfacePrivate @@ -56,14 +58,12 @@ public: : QWaylandSurfacePrivate(client, id, version, c, surf) , compositor(c) , useTextureAlpha(true) - , windowPropertyMap(new QQmlPropertyMap) , clientRenderingEnabled(true) { } ~QWaylandQuickSurfacePrivate() { - windowPropertyMap->deleteLater(); } void surface_commit(Resource *resource) Q_DECL_OVERRIDE @@ -78,18 +78,13 @@ public: QWaylandQuickCompositor *compositor; bool useTextureAlpha; - QQmlPropertyMap *windowPropertyMap; bool clientRenderingEnabled; }; QWaylandQuickSurface::QWaylandQuickSurface(wl_client *client, quint32 id, int version, QWaylandQuickCompositor *compositor) : QWaylandSurface(new QWaylandQuickSurfacePrivate(client, id, version, compositor, this)) { - Q_D(QWaylandQuickSurface); - connect(this, &QWaylandSurface::shellViewCreated, this, &QWaylandQuickSurface::shellViewCreated); connect(this, &QWaylandSurface::primaryOutputChanged, this, &QWaylandQuickSurface::primaryOutputWindowChanged); - connect(this, &QWaylandSurface::windowPropertyChanged, d->windowPropertyMap, &QQmlPropertyMap::insert); - connect(d->windowPropertyMap, &QQmlPropertyMap::valueChanged, this, &QWaylandSurface::setWindowProperty); connect(this, &QWaylandSurface::windowPropertyChanged, d->windowPropertyMap, &QQmlPropertyMap::insert); connect(d->windowPropertyMap, &QQmlPropertyMap::valueChanged, this, &QWaylandSurface::setWindowProperty); @@ -117,17 +112,6 @@ void QWaylandQuickSurface::setUseTextureAlpha(bool useTextureAlpha) } } -QObject *QWaylandQuickSurface::windowPropertyMap() const -{ - Q_D(const QWaylandQuickSurface); - return d->windowPropertyMap; -} - -QWaylandSurfaceItem *QWaylandQuickSurface::shellView() const -{ - return static_cast<QWaylandSurfaceItem *>(QWaylandSurface::shellView()); -} - QWindow *QWaylandQuickSurface::primaryOutputWindow() const { return primaryOutput() ? primaryOutput()->window() : Q_NULLPTR; @@ -185,8 +169,8 @@ void QWaylandQuickSurface::setClientRenderingEnabled(bool enabled) if (d->clientRenderingEnabled != enabled) { d->clientRenderingEnabled = enabled; - sendOnScreenVisibilityChange(enabled); - + if (QWaylandExtension *extension = this->extension(QtWaylandServer::qt_extended_surface::name())) + static_cast<QtWayland::ExtendedSurface*>(extension)->setVisibility(enabled ? QWindow::AutomaticVisibility : QWindow::Hidden); emit clientRenderingEnabledChanged(); } } diff --git a/src/compositor/compositor_api/qwaylandquicksurface.h b/src/compositor/compositor_api/qwaylandquicksurface.h index 7e079471d..03d889e72 100644 --- a/src/compositor/compositor_api/qwaylandquicksurface.h +++ b/src/compositor/compositor_api/qwaylandquicksurface.h @@ -53,8 +53,6 @@ class Q_COMPOSITOR_EXPORT QWaylandQuickSurface : public QWaylandSurface Q_DECLARE_PRIVATE(QWaylandQuickSurface) Q_PROPERTY(bool useTextureAlpha READ useTextureAlpha WRITE setUseTextureAlpha NOTIFY useTextureAlphaChanged) Q_PROPERTY(bool clientRenderingEnabled READ clientRenderingEnabled WRITE setClientRenderingEnabled NOTIFY clientRenderingEnabledChanged) - Q_PROPERTY(QObject *windowProperties READ windowPropertyMap CONSTANT) - Q_PROPERTY(QWaylandSurfaceItem *shellView READ shellView NOTIFY shellViewCreated) Q_PROPERTY(QWindow *primaryOutputWindow READ primaryOutputWindow NOTIFY primaryOutputWindowChanged) public: QWaylandQuickSurface(wl_client *client, quint32 id, int version, QWaylandQuickCompositor *compositor); @@ -66,18 +64,13 @@ public: bool clientRenderingEnabled() const; void setClientRenderingEnabled(bool enabled); - QObject *windowPropertyMap() const; - - QWaylandSurfaceItem *shellView() const; -private: - bool event(QEvent *event) Q_DECL_OVERRIDE; - QWindow *primaryOutputWindow() const; +protected: + bool event(QEvent *event) Q_DECL_OVERRIDE; Q_SIGNALS: void useTextureAlphaChanged(); void clientRenderingEnabledChanged(); - void shellViewCreated(); void primaryOutputWindowChanged(); }; diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp index 0f722f334..cc463d08a 100644 --- a/src/compositor/compositor_api/qwaylandsurface.cpp +++ b/src/compositor/compositor_api/qwaylandsurface.cpp @@ -40,19 +40,18 @@ #include <private/qobject_p.h> #include "wayland_wrapper/qwlsurface_p.h" -#include "wayland_wrapper/qwlextendedsurface_p.h" -#include "wayland_wrapper/qwlsubsurface_p.h" #include "wayland_wrapper/qwlcompositor_p.h" -#include "wayland_wrapper/qwlshellsurface_p.h" #include "wayland_wrapper/qwlinputdevice_p.h" #include "wayland_wrapper/qwldatadevice_p.h" #include "wayland_wrapper/qwldatadevicemanager_p.h" +#include "extensions/qwlextendedsurface_p.h" +#include "extensions/qwlsubsurface_p.h" + #include "qwaylandcompositor.h" #include "qwaylandclient.h" #include "qwaylandsurface_p.h" #include "qwaylandbufferref.h" -#include "qwaylandsurfaceinterface.h" #include "qwaylandoutput.h" #include <QtGui/QGuiApplication> @@ -136,14 +135,13 @@ QWaylandSurface::QWaylandSurface(wl_client *client, quint32 id, int version, QWa } QWaylandSurface::QWaylandSurface(QWaylandSurfacePrivate *dptr) - : QObject(*dptr) + : QObject(*dptr) { } QWaylandSurface::~QWaylandSurface() { Q_D(QWaylandSurface); - qDeleteAll(d->interfaces); d->m_compositor->unregisterSurface(this); d->notifyViewsAboutDestruction(); } @@ -160,7 +158,7 @@ QWaylandSurface *QWaylandSurface::parentSurface() const { Q_D(const QWaylandSurface); if (d->subSurface() && d->subSurface()->parent()) { - return d->subSurface()->parent()->waylandSurface(); + return d->subSurface()->parent()->surface(); } return 0; } @@ -174,18 +172,6 @@ QLinkedList<QWaylandSurface *> QWaylandSurface::subSurfaces() const return QLinkedList<QWaylandSurface *>(); } -void QWaylandSurface::addInterface(QWaylandSurfaceInterface *iface) -{ - Q_D(QWaylandSurface); - d->interfaces.prepend(iface); -} - -void QWaylandSurface::removeInterface(QWaylandSurfaceInterface *iface) -{ - Q_D(QWaylandSurface); - d->interfaces.removeOne(iface); -} - bool QWaylandSurface::visible() const { return isMapped(); @@ -203,44 +189,12 @@ QSize QWaylandSurface::size() const return d->size(); } -void QWaylandSurface::requestSize(const QSize &size) -{ - Q_D(QWaylandSurface); - QWaylandSurfaceResizeOp op(size); - if (!sendInterfaceOp(op)) { - int id = wl_resource_get_id(d->resource()->handle); - qWarning("No surface interface forwarded the resize request for this surface (wl_surface@%d).", id); - } -} - -Qt::ScreenOrientations QWaylandSurface::orientationUpdateMask() const -{ - Q_D(const QWaylandSurface); - if (!d->extendedSurface()) - return Qt::PrimaryOrientation; - return d->extendedSurface()->contentOrientationMask(); -} - Qt::ScreenOrientation QWaylandSurface::contentOrientation() const { Q_D(const QWaylandSurface); return d->contentOrientation(); } -QWaylandSurface::WindowFlags QWaylandSurface::windowFlags() const -{ - Q_D(const QWaylandSurface); - if (!d->extendedSurface()) - return QWaylandSurface::WindowFlags(0); - return d->extendedSurface()->windowFlags(); -} - -QWaylandSurface::WindowType QWaylandSurface::windowType() const -{ - Q_D(const QWaylandSurface); - return d->windowType; -} - QWaylandSurface::Origin QWaylandSurface::origin() const { Q_D(const QWaylandSurface); @@ -265,24 +219,6 @@ QtWayland::Surface * QWaylandSurface::handle() return d; } -QVariantMap QWaylandSurface::windowProperties() const -{ - Q_D(const QWaylandSurface); - if (!d->extendedSurface()) - return QVariantMap(); - - return d->extendedSurface()->windowProperties(); -} - -void QWaylandSurface::setWindowProperty(const QString &name, const QVariant &value) -{ - Q_D(QWaylandSurface); - if (!d->extendedSurface()) - return; - - d->extendedSurface()->setWindowProperty(name, value); -} - QWaylandCompositor *QWaylandSurface::compositor() const { Q_D(const QWaylandSurface); @@ -303,63 +239,12 @@ void QWaylandSurface::setPrimaryOutput(QWaylandOutput *output) d->setPrimaryOutput(output->handle()); } -QWindow::Visibility QWaylandSurface::visibility() const -{ - Q_D(const QWaylandSurface); - return d->m_visibility; -} - -void QWaylandSurface::setVisibility(QWindow::Visibility v) -{ - Q_D(QWaylandSurface); - if (v == visibility()) - return; - - d->m_visibility = v; - QWaylandSurfaceSetVisibilityOp op(v); - sendInterfaceOp(op); - - emit visibilityChanged(); -} - -QWaylandSurfaceView *QWaylandSurface::shellView() const -{ - Q_D(const QWaylandSurface); - return d->shellSurface() ? d->shellSurface()->view() : Q_NULLPTR; -} - -bool QWaylandSurface::sendInterfaceOp(QWaylandSurfaceOp &op) -{ - Q_D(QWaylandSurface); - foreach (QWaylandSurfaceInterface *iface, d->interfaces) { - if (iface->runOperation(&op)) - return true; - } - return false; -} - -void QWaylandSurface::ping() -{ - Q_D(QWaylandSurface); - uint32_t serial = wl_display_next_serial(compositor()->waylandDisplay()); - QWaylandSurfacePingOp op(serial); - if (!sendInterfaceOp(op)) { - int id = wl_resource_get_id(d->resource()->handle); - qWarning("No surface interface forwarded the ping for this surface (wl_surface@%d).", id); - } -} - void QWaylandSurface::sendFrameCallbacks() { Q_D(QWaylandSurface); d->sendFrameCallback(); } -void QWaylandSurface::sendOnScreenVisibilityChange(bool visible) -{ - setVisibility(visible ? QWindow::AutomaticVisibility : QWindow::Hidden); -} - QString QWaylandSurface::className() const { Q_D(const QWaylandSurface); @@ -399,13 +284,6 @@ void QWaylandSurface::destroy() deref(); } -void QWaylandSurface::destroySurface() -{ - QWaylandSurfaceOp op(QWaylandSurfaceOp::Close); - if (!sendInterfaceOp(op)) - emit surfaceDestroyed(); -} - void QWaylandSurface::enter(QWaylandOutput *output) { Q_D(QWaylandSurface); @@ -465,12 +343,6 @@ QList<QWaylandSurfaceView *> QWaylandSurface::views() const return d->views; } -QList<QWaylandSurfaceInterface *> QWaylandSurface::interfaces() const -{ - Q_D(const QWaylandSurface); - return d->interfaces; -} - QWaylandSurface *QWaylandSurface::fromResource(::wl_resource *res) { QtWayland::Surface *s = QtWayland::Surface::fromResource(res); @@ -502,15 +374,6 @@ void QWaylandSurfacePrivate::setClassName(const QString &className) } } -void QWaylandSurfacePrivate::setType(QWaylandSurface::WindowType type) -{ - Q_Q(QWaylandSurface); - if (windowType != type) { - windowType = type; - emit q->windowTypeChanged(type); - } -} - void QWaylandSurfacePrivate::refView(QWaylandSurfaceView *view) { if (views.contains(view)) diff --git a/src/compositor/compositor_api/qwaylandsurface.h b/src/compositor/compositor_api/qwaylandsurface.h index 30005e3f7..96be55f7d 100644 --- a/src/compositor/compositor_api/qwaylandsurface.h +++ b/src/compositor/compositor_api/qwaylandsurface.h @@ -39,6 +39,7 @@ #define QWAYLANDSURFACE_H #include <QtCompositor/qwaylandexport.h> +#include <QtCompositor/qwaylandextension.h> #include <QtCore/QScopedPointer> #include <QtGui/QImage> @@ -56,7 +57,6 @@ class QWaylandSurfacePrivate; class QWaylandCompositor; class QWaylandBufferRef; class QWaylandSurfaceView; -class QWaylandSurfaceInterface; class QWaylandSurfaceOp; class QWaylandOutput; @@ -98,42 +98,21 @@ private: QWaylandSurfaceLeaveEventPrivate *d; }; -class Q_COMPOSITOR_EXPORT QWaylandSurface : public QObject +class Q_COMPOSITOR_EXPORT QWaylandSurface : public QObject, public QWaylandExtensionContainer { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandSurface) Q_PROPERTY(QWaylandClient *client READ client CONSTANT) Q_PROPERTY(QSize size READ size NOTIFY sizeChanged) - Q_PROPERTY(QWaylandSurface::WindowFlags windowFlags READ windowFlags NOTIFY windowFlagsChanged) - Q_PROPERTY(QWaylandSurface::WindowType windowType READ windowType NOTIFY windowTypeChanged) Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation NOTIFY contentOrientationChanged) Q_PROPERTY(QString className READ className NOTIFY classNameChanged) Q_PROPERTY(QString title READ title NOTIFY titleChanged) - Q_PROPERTY(Qt::ScreenOrientations orientationUpdateMask READ orientationUpdateMask NOTIFY orientationUpdateMaskChanged) - Q_PROPERTY(QWindow::Visibility visibility READ visibility WRITE setVisibility NOTIFY visibilityChanged) Q_PROPERTY(QWaylandSurface *transientParent READ transientParent) Q_PROPERTY(QPointF transientOffset READ transientOffset) Q_PROPERTY(QWaylandOutput *primaryOutput READ primaryOutput WRITE setPrimaryOutput NOTIFY primaryOutputChanged) Q_PROPERTY(QWaylandSurface::Origin origin READ origin NOTIFY originChanged); - Q_ENUMS(WindowFlag WindowType) - Q_FLAGS(WindowFlag WindowFlags) - public: - enum WindowFlag { - OverridesSystemGestures = 0x0001, - StaysOnTop = 0x0002, - BypassWindowManager = 0x0004 - }; - Q_DECLARE_FLAGS(WindowFlags, WindowFlag) - - enum WindowType { - None, - Toplevel, - Transient, - Popup - }; - enum Origin { OriginTopLeft, OriginBottomLeft @@ -146,27 +125,16 @@ public: QWaylandSurface *parentSurface() const; QLinkedList<QWaylandSurface *> subSurfaces() const; - void addInterface(QWaylandSurfaceInterface *interface); - void removeInterface(QWaylandSurfaceInterface *interface); bool visible() const; bool isMapped() const; QSize size() const; - Q_INVOKABLE void requestSize(const QSize &size); - Qt::ScreenOrientations orientationUpdateMask() const; Qt::ScreenOrientation contentOrientation() const; - WindowFlags windowFlags() const; - - WindowType windowType() const; Origin origin() const; - QWindow::Visibility visibility() const; - void setVisibility(QWindow::Visibility visibility); - Q_INVOKABLE void sendOnScreenVisibilityChange(bool visible); // Compat - QWaylandSurface *transientParent() const; QPointF transientOffset() const; @@ -174,8 +142,6 @@ public: QtWayland::Surface *handle(); QByteArray authenticationToken() const; - QVariantMap windowProperties() const; - void setWindowProperty(const QString &name, const QVariant &value); QWaylandCompositor *compositor() const; @@ -193,8 +159,6 @@ public: bool inputRegionContains(const QPoint &p) const; Q_INVOKABLE void destroy(); - Q_INVOKABLE void destroySurface(); - Q_INVOKABLE void ping(); Q_INVOKABLE void sendFrameCallbacks(); @@ -203,11 +167,6 @@ public: void setMapped(bool mapped); QList<QWaylandSurfaceView *> views() const; - QList<QWaylandSurfaceInterface *> interfaces() const; - - QWaylandSurfaceView *shellView() const; - - bool sendInterfaceOp(QWaylandSurfaceOp &op); static QWaylandSurface *fromResource(::wl_resource *resource); @@ -227,27 +186,20 @@ Q_SIGNALS: void parentChanged(QWaylandSurface *newParent, QWaylandSurface *oldParent); void sizeChanged(); void offsetForNextFrame(const QPoint &offset); - void windowPropertyChanged(const QString &name, const QVariant &value); - void windowFlagsChanged(WindowFlags flags); - void windowTypeChanged(WindowType type); void contentOrientationChanged(); - void orientationUpdateMaskChanged(); void extendedSurfaceReady(); void classNameChanged(); void titleChanged(); void raiseRequested(); void lowerRequested(); - void visibilityChanged(); void pong(); void surfaceDestroyed(); - void shellViewCreated(); void primaryOutputChanged(QWaylandOutput *newOutput, QWaylandOutput *oldOutput); void originChanged(); void configure(bool hasBuffer); void redraw(); - friend class QWaylandSurfaceInterface; friend class QtWayland::Surface; }; diff --git a/src/compositor/compositor_api/qwaylandsurface_p.h b/src/compositor/compositor_api/qwaylandsurface_p.h index bef6a49e0..683c50654 100644 --- a/src/compositor/compositor_api/qwaylandsurface_p.h +++ b/src/compositor/compositor_api/qwaylandsurface_p.h @@ -56,7 +56,6 @@ class Q_COMPOSITOR_EXPORT QWaylandSurfacePrivate : public QObjectPrivate, public public: static QWaylandSurfacePrivate *get(QWaylandSurface *surface); QWaylandSurfacePrivate(wl_client *wlClient, quint32 id, int version, QWaylandCompositor *compositor, QWaylandSurface *surface); - void setType(QWaylandSurface::WindowType type); void setTitle(const QString &title); void setClassName(const QString &className); void refView(QWaylandSurfaceView *view); @@ -67,9 +66,7 @@ public: QWaylandClient *client; - QWaylandSurface::WindowType windowType; QList<QWaylandSurfaceView *> views; - QList<QWaylandSurfaceInterface *> interfaces; }; QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandsurfaceinterface.cpp b/src/compositor/compositor_api/qwaylandsurfaceinterface.cpp deleted file mode 100644 index b20d70613..000000000 --- a/src/compositor/compositor_api/qwaylandsurfaceinterface.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <wayland-server.h> - -#include "qwaylandsurfaceinterface.h" -#include "qwaylandsurface.h" -#include "qwaylandsurface_p.h" - -class QWaylandSurfaceInterface::Private -{ -public: - QWaylandSurface *surface; -}; - -QWaylandSurfaceInterface::QWaylandSurfaceInterface(QWaylandSurface *surface) - : d(new Private) -{ - d->surface = surface; - surface->addInterface(this); -} - -QWaylandSurfaceInterface::~QWaylandSurfaceInterface() -{ - d->surface->removeInterface(this); - delete d; -} - -QWaylandSurface *QWaylandSurfaceInterface::surface() const -{ - return d->surface; -} - -void QWaylandSurfaceInterface::setSurfaceType(QWaylandSurface::WindowType type) -{ - surface()->d_func()->setType(type); -} - -void QWaylandSurfaceInterface::setSurfaceClassName(const QString &name) -{ - surface()->d_func()->setClassName(name); -} - -void QWaylandSurfaceInterface::setSurfaceTitle(const QString &title) -{ - surface()->d_func()->setTitle(title); -} - - - -class QWaylandSurfaceOp::Private -{ -public: - int type; -}; - -QWaylandSurfaceOp::QWaylandSurfaceOp(int t) - : d(new Private) -{ - d->type = t; -} - -QWaylandSurfaceOp::~QWaylandSurfaceOp() -{ - delete d; -} - -int QWaylandSurfaceOp::type() const -{ - return d->type; -} - - - -QWaylandSurfaceSetVisibilityOp::QWaylandSurfaceSetVisibilityOp(QWindow::Visibility visibility) - : QWaylandSurfaceOp(QWaylandSurfaceOp::SetVisibility) - , m_visibility(visibility) -{ -} - -QWindow::Visibility QWaylandSurfaceSetVisibilityOp::visibility() const -{ - return m_visibility; -} - -QWaylandSurfaceResizeOp::QWaylandSurfaceResizeOp(const QSize &size) - : QWaylandSurfaceOp(QWaylandSurfaceOp::Resize) - , m_size(size) -{ -} - -QSize QWaylandSurfaceResizeOp::size() const -{ - return m_size; -} - -QWaylandSurfacePingOp::QWaylandSurfacePingOp(uint32_t serial) - : QWaylandSurfaceOp(QWaylandSurfaceOp::Ping) - , m_serial(serial) -{ -} - -uint32_t QWaylandSurfacePingOp::serial() const -{ - return m_serial; -} diff --git a/src/compositor/compositor_api/qwaylandsurfaceitem.cpp b/src/compositor/compositor_api/qwaylandsurfaceitem.cpp index c690521ba..3b0ec3a3e 100644 --- a/src/compositor/compositor_api/qwaylandsurfaceitem.cpp +++ b/src/compositor/compositor_api/qwaylandsurfaceitem.cpp @@ -408,16 +408,6 @@ void QWaylandSurfaceItem::updateSize() } } -void QWaylandSurfaceItem::geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry) -{ - QQuickItem::geometryChanged(newGeometry, oldGeometry); - - if (surface() && m_resizeSurfaceToItem) { - surface()->requestSize(newGeometry.size().toSize()); - } -} - void QWaylandSurfaceItem::setRequestedPosition(const QPointF &pos) { bool xChanged = pos.x() != requestedPosition().x(); diff --git a/src/compositor/compositor_api/qwaylandsurfaceitem.h b/src/compositor/compositor_api/qwaylandsurfaceitem.h index c8eea8973..a06f4534c 100644 --- a/src/compositor/compositor_api/qwaylandsurfaceitem.h +++ b/src/compositor/compositor_api/qwaylandsurfaceitem.h @@ -123,8 +123,6 @@ protected: void waylandSurfaceChanged(QWaylandSurface *newSurface, QWaylandSurface *oldSurface) Q_DECL_OVERRIDE; void waylandSurfaceDestroyed() Q_DECL_OVERRIDE; - void geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry) Q_DECL_OVERRIDE; public Q_SLOTS: virtual void takeFocus(QWaylandInputDevice *device = 0); void setPaintEnabled(bool paintEnabled); diff --git a/src/compositor/extensions/extensions.pri b/src/compositor/extensions/extensions.pri new file mode 100644 index 000000000..070c319c2 --- /dev/null +++ b/src/compositor/extensions/extensions.pri @@ -0,0 +1,33 @@ +CONFIG += wayland-scanner +WAYLANDSERVERSOURCES += \ + ../extensions/sub-surface-extension.xml \ + ../extensions/surface-extension.xml \ + ../extensions/touch-extension.xml \ + ../extensions/qtkey-extension.xml \ + ../extensions/windowmanager.xml \ + +HEADERS += \ + extensions/qwlextendedsurface_p.h \ + extensions/qwlsubsurface_p.h \ + extensions/qwlqttouch_p.h \ + extensions/qwlqtkey_p.h \ + extensions/qwlshellsurface_p.h \ + extensions/qwaylandwindowmanagerextension.h \ + extensions/qwltextinput_p.h \ + extensions/qwltextinputmanager_p.h \ + extensions/qwlinputpanel_p.h \ + extensions/qwlinputpanelsurface_p.h \ + +SOURCES += \ + extensions/qwlextendedsurface.cpp \ + extensions/qwlsubsurface.cpp \ + extensions/qwlqttouch.cpp \ + extensions/qwlqtkey.cpp \ + extensions/qwlshellsurface.cpp \ + extensions/qwaylandwindowmanagerextension.cpp \ + extensions/qwltextinput.cpp \ + extensions/qwltextinputmanager.cpp \ + extensions/qwlinputpanel.cpp \ + extensions/qwlinputpanelsurface.cpp \ + +INCLUDEPATH += extensions diff --git a/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp b/src/compositor/extensions/qwaylandwindowmanagerextension.cpp index bb3c9fc37..160fb690f 100644 --- a/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp +++ b/src/compositor/extensions/qwaylandwindowmanagerextension.cpp @@ -34,7 +34,7 @@ ** ****************************************************************************/ -#include <windowmanagerprotocol/waylandwindowmanagerintegration_p.h> +#include "qwaylandwindowmanagerextension.h" #include <wayland_wrapper/qwldisplay_p.h> #include <wayland_wrapper/qwlcompositor_p.h> @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE WindowManagerServerIntegration::WindowManagerServerIntegration(QWaylandCompositor *compositor, QObject *parent) - : QObject(parent) + : QWaylandExtension(compositor) , QtWaylandServer::qt_windowmanager() , m_showIsFullScreen(false) , m_compositor(compositor) diff --git a/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration_p.h b/src/compositor/extensions/qwaylandwindowmanagerextension.h index d6acee9cb..5cd64e06d 100644 --- a/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration_p.h +++ b/src/compositor/extensions/qwaylandwindowmanagerextension.h @@ -40,7 +40,7 @@ #include <QtCompositor/qwaylandexport.h> #include <QtCompositor/private/qwayland-server-windowmanager.h> -#include <QObject> +#include <QtCompositor/QWaylandExtension> #include <QMap> QT_BEGIN_NAMESPACE @@ -51,7 +51,7 @@ namespace QtWayland { class QWaylandCompositor; -class Q_COMPOSITOR_EXPORT WindowManagerServerIntegration : public QObject, public QtWaylandServer::qt_windowmanager +class Q_COMPOSITOR_EXPORT WindowManagerServerIntegration : public QWaylandExtension, public QtWaylandServer::qt_windowmanager { Q_OBJECT public: @@ -63,6 +63,7 @@ public: void setShowIsFullScreen(bool value); void sendQuitMessage(wl_client *client); + const wl_interface *interface() const Q_DECL_OVERRIDE { return QtWaylandServer::qt_windowmanager::interface(); } protected: void windowmanager_bind_resource(Resource *resource) Q_DECL_OVERRIDE; void windowmanager_destroy_resource(Resource *resource) Q_DECL_OVERRIDE; diff --git a/src/compositor/wayland_wrapper/qwlextendedsurface.cpp b/src/compositor/extensions/qwlextendedsurface.cpp index 8b06cb182..42c100531 100644 --- a/src/compositor/wayland_wrapper/qwlextendedsurface.cpp +++ b/src/compositor/extensions/qwlextendedsurface.cpp @@ -44,7 +44,8 @@ QT_BEGIN_NAMESPACE namespace QtWayland { SurfaceExtensionGlobal::SurfaceExtensionGlobal(Compositor *compositor) - : QtWaylandServer::qt_surface_extension(compositor->wl_display(), 1) + : QWaylandExtension(compositor->waylandCompositor()) + , QtWaylandServer::qt_surface_extension(compositor->wl_display(), 1) { } @@ -56,20 +57,21 @@ void SurfaceExtensionGlobal::surface_extension_get_extended_surface(Resource *re new ExtendedSurface(resource->client(),id, wl_resource_get_version(resource->handle), surface); } +ExtendedSurface *ExtendedSurface::get(QWaylandSurface *surface) +{ + return static_cast<ExtendedSurface *>(surface->extension(qt_extended_surface::name())); +} + ExtendedSurface::ExtendedSurface(struct wl_client *client, uint32_t id, int version, Surface *surface) - : QWaylandSurfaceInterface(surface->waylandSurface()) + : QWaylandExtension(surface->waylandSurface()) , QtWaylandServer::qt_extended_surface(client, id, version) , m_surface(surface) , m_windowFlags(0) { - Q_ASSERT(surface->extendedSurface() == 0); - surface->setExtendedSurface(this); } ExtendedSurface::~ExtendedSurface() { - if (m_surface) - m_surface->setExtendedSurface(0); } void ExtendedSurface::sendGenericProperty(const QString &name, const QVariant &variant) @@ -81,9 +83,13 @@ void ExtendedSurface::sendGenericProperty(const QString &name, const QVariant &v } +void ExtendedSurface::sendOnScreenVisibilityChange(bool onScreen) +{ + setVisibility(onScreen ? QWindow::AutomaticVisibility : QWindow::Hidden); +} + void ExtendedSurface::setVisibility(QWindow::Visibility visibility) { - // If this change came from the client, we shouldn't update it send_onscreen_visibility(visibility); } @@ -92,21 +98,6 @@ void ExtendedSurface::setParentSurface(Surface *surface) m_surface = surface; } -bool ExtendedSurface::runOperation(QWaylandSurfaceOp *op) -{ - switch (op->type()) { - case QWaylandSurfaceOp::Close: - send_close(); - return true; - case QWaylandSurfaceOp::SetVisibility: - setVisibility(static_cast<QWaylandSurfaceSetVisibilityOp *>(op)->visibility()); - return true; - default: - break; - } - return false; -} - void ExtendedSurface::extended_surface_update_generic_property(Resource *resource, const QString &name, struct wl_array *value) @@ -116,7 +107,7 @@ void ExtendedSurface::extended_surface_update_generic_property(Resource *resourc QByteArray byteValue((const char*)value->data, value->size); QDataStream ds(&byteValue, QIODevice::ReadOnly); ds >> variantValue; - setWindowProperty(name,variantValue,false); + setWindowPropertyImpl(name,variantValue); } Qt::ScreenOrientations ExtendedSurface::contentOrientationMask() const @@ -142,8 +133,8 @@ void ExtendedSurface::extended_surface_set_content_orientation_mask(Resource *re Qt::ScreenOrientations oldMask = m_contentOrientationMask; m_contentOrientationMask = mask; - if (m_surface && mask != oldMask) - emit m_surface->waylandSurface()->orientationUpdateMaskChanged(); + if (mask != oldMask) + emit contentOrientationMaskChanged(); } QVariantMap ExtendedSurface::windowProperties() const @@ -157,22 +148,26 @@ QVariant ExtendedSurface::windowProperty(const QString &propertyName) const return props.value(propertyName); } -void ExtendedSurface::setWindowProperty(const QString &name, const QVariant &value, bool writeUpdateToClient) +void ExtendedSurface::setWindowProperty(const QString &name, const QVariant &value) +{ + setWindowPropertyImpl(name,value); + sendGenericProperty(name, value); +} + +void ExtendedSurface::setWindowPropertyImpl(const QString &name, const QVariant &value) { m_windowProperties.insert(name, value); - m_surface->waylandSurface()->windowPropertyChanged(name,value); - if (writeUpdateToClient) - sendGenericProperty(name, value); + emit windowPropertyChanged(name,value); } void ExtendedSurface::extended_surface_set_window_flags(Resource *resource, int32_t flags) { Q_UNUSED(resource); - QWaylandSurface::WindowFlags windowFlags(flags); - if (!m_surface || windowFlags == m_windowFlags) + WindowFlags windowFlags(flags); + if (windowFlags == m_windowFlags) return; m_windowFlags = windowFlags; - emit m_surface->waylandSurface()->windowFlagsChanged(windowFlags); + emit windowFlagsChanged(); } void ExtendedSurface::extended_surface_destroy_resource(Resource *) diff --git a/src/compositor/wayland_wrapper/qwlextendedsurface_p.h b/src/compositor/extensions/qwlextendedsurface_p.h index 524a4d6e8..f0953b499 100644 --- a/src/compositor/wayland_wrapper/qwlextendedsurface_p.h +++ b/src/compositor/extensions/qwlextendedsurface_p.h @@ -42,7 +42,7 @@ #include <QtCompositor/private/qwayland-server-surface-extension.h> #include <private/qwlsurface_p.h> #include <QtCompositor/qwaylandsurface.h> -#include <QtCompositor/qwaylandsurfaceinterface.h> +#include <QtCompositor/qwaylandextension.h> #include <QtCore/QVariant> #include <QtCore/QLinkedList> @@ -56,11 +56,13 @@ namespace QtWayland { class Compositor; -class SurfaceExtensionGlobal : public QtWaylandServer::qt_surface_extension +class SurfaceExtensionGlobal : public QWaylandExtension, public QtWaylandServer::qt_surface_extension { public: SurfaceExtensionGlobal(Compositor *compositor); + const wl_interface *interface() const Q_DECL_OVERRIDE { return QtWaylandServer::qt_surface_extension::interface(); } + private: void surface_extension_get_extended_surface(Resource *resource, uint32_t id, @@ -68,14 +70,28 @@ private: }; -class ExtendedSurface : public QWaylandSurfaceInterface, public QtWaylandServer::qt_extended_surface +class Q_COMPOSITOR_EXPORT ExtendedSurface : public QWaylandExtension, public QtWaylandServer::qt_extended_surface { + Q_OBJECT + Q_PROPERTY(Qt::ScreenOrientations contentOrientationMask READ contentOrientationMask NOTIFY contentOrientationMaskChanged) + Q_PROPERTY(WindowFlags windowFlags READ windowFlags NOTIFY windowFlagsChanged) + Q_FLAGS(WindowFlag WindowFlags) public: + enum WindowFlag { + OverridesSystemGestures = 0x0001, + StaysOnTop = 0x0002, + BypassWindowManager = 0x0004 + }; + Q_DECLARE_FLAGS(WindowFlags, WindowFlag) + + static ExtendedSurface *get(QWaylandSurface *surface); + ExtendedSurface(struct wl_client *client, uint32_t id, int version, Surface *surface); ~ExtendedSurface(); void sendGenericProperty(const QString &name, const QVariant &variant); + void sendOnScreenVisibilityChange(bool onScreen); void setVisibility(QWindow::Visibility visibility); void setSubSurface(ExtendedSurface *subSurface,int x, int y); @@ -87,21 +103,27 @@ public: Qt::ScreenOrientations contentOrientationMask() const; - QWaylandSurface::WindowFlags windowFlags() const { return m_windowFlags; } + WindowFlags windowFlags() const { return m_windowFlags; } QVariantMap windowProperties() const; QVariant windowProperty(const QString &propertyName) const; - void setWindowProperty(const QString &name, const QVariant &value, bool writeUpdateToClient = true); + void setWindowProperty(const QString &name, const QVariant &value); -protected: - bool runOperation(QWaylandSurfaceOp *op) Q_DECL_OVERRIDE; + const wl_interface *interface() const Q_DECL_OVERRIDE { return QtWaylandServer::qt_extended_surface::interface(); } + +signals: + void contentOrientationMaskChanged(); + void windowFlagsChanged(); + void windowPropertyChanged(const QString &name, const QVariant &value); private: + void setWindowPropertyImpl(const QString &name, const QVariant &value); + Surface *m_surface; Qt::ScreenOrientations m_contentOrientationMask; - QWaylandSurface::WindowFlags m_windowFlags; + WindowFlags m_windowFlags; QByteArray m_authenticationToken; QVariantMap m_windowProperties; diff --git a/src/compositor/wayland_wrapper/qwlinputpanel.cpp b/src/compositor/extensions/qwlinputpanel.cpp index 65befd41c..d1c6ab825 100644 --- a/src/compositor/wayland_wrapper/qwlinputpanel.cpp +++ b/src/compositor/extensions/qwlinputpanel.cpp @@ -47,77 +47,90 @@ QT_BEGIN_NAMESPACE -namespace QtWayland { - -InputPanel::InputPanel(Compositor *compositor) - : QtWaylandServer::wl_input_panel(compositor->wl_display(), 1) +QWaylandInputPanelPrivate::QWaylandInputPanelPrivate(QtWayland::Compositor *compositor) + : QWaylandExtensionTemplatePrivateImpl(compositor->waylandCompositor()) , m_compositor(compositor) - , m_handle(new QWaylandInputPanel(this)) , m_focus() , m_inputPanelVisible(false) , m_cursorRectangle() { + init(compositor->wl_display(), 1); } -InputPanel::~InputPanel() +QWaylandInputPanelPrivate::~QWaylandInputPanelPrivate() { } -QWaylandInputPanel *InputPanel::handle() const +QWaylandInputPanel *QWaylandInputPanelPrivate::waylandInputPanel() const { - return m_handle.data(); + QWaylandInputPanel *panel = const_cast<QWaylandInputPanel *>(q_func()); + return panel; } -Surface *InputPanel::focus() const +QtWayland::Surface *QWaylandInputPanelPrivate::focus() const { return m_focus; } -void InputPanel::setFocus(Surface *focus) +void QWaylandInputPanelPrivate::setFocus(QtWayland::Surface *focus) { + Q_Q(QWaylandInputPanel); if (m_focus == focus) return; m_focus = focus; - Q_EMIT handle()->focusChanged(); + Q_EMIT q->focusChanged(); } -bool InputPanel::inputPanelVisible() const +bool QWaylandInputPanelPrivate::inputPanelVisible() const { return m_inputPanelVisible; } -void InputPanel::setInputPanelVisible(bool inputPanelVisible) +void QWaylandInputPanelPrivate::setInputPanelVisible(bool inputPanelVisible) { + Q_Q(QWaylandInputPanel); if (m_inputPanelVisible == inputPanelVisible) return; m_inputPanelVisible = inputPanelVisible; - Q_EMIT handle()->visibleChanged(); + q->visibleChanged(); } -QRect InputPanel::cursorRectangle() const +QRect QWaylandInputPanelPrivate::cursorRectangle() const { return m_cursorRectangle; } -void InputPanel::setCursorRectangle(const QRect &cursorRectangle) +void QWaylandInputPanelPrivate::setCursorRectangle(const QRect &cursorRectangle) { + Q_Q(QWaylandInputPanel); if (m_cursorRectangle == cursorRectangle) return; m_cursorRectangle = cursorRectangle; - Q_EMIT handle()->cursorRectangleChanged(); + Q_EMIT q->cursorRectangleChanged(); +} + +QWaylandInputPanelPrivate *QWaylandInputPanelPrivate::get(QWaylandExtensionContainer *container) +{ + QWaylandInputPanel *panel = static_cast<QWaylandInputPanel *>(container->extension(wl_input_panel::name())); + if (panel) + return panel->d_func(); + return Q_NULLPTR; } -void InputPanel::input_panel_get_input_panel_surface(Resource *resource, uint32_t id, wl_resource *surface) +QWaylandInputPanelPrivate *QWaylandInputPanelPrivate::get(QWaylandInputPanel *panel) { - new InputPanelSurface(resource->client(), id, Surface::fromResource(surface)); + return panel->d_func(); } -} // namespace QtWayland +void QWaylandInputPanelPrivate::input_panel_get_input_panel_surface(Resource *resource, uint32_t id, wl_resource *surface) +{ + new QtWayland::InputPanelSurface(resource->client(), id, QtWayland::Surface::fromResource(surface)); +} QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwlinputpanel_p.h b/src/compositor/extensions/qwlinputpanel_p.h index f9dc49370..49a14e792 100644 --- a/src/compositor/wayland_wrapper/qwlinputpanel_p.h +++ b/src/compositor/extensions/qwlinputpanel_p.h @@ -38,7 +38,9 @@ #define QTWAYLAND_QWLINPUTPANEL_P_H #include <QtCompositor/qwaylandexport.h> +#include <QtCompositor/qwaylandinputpanel.h> +#include <QtCompositor/private/qwaylandextension_p.h> #include <QtCompositor/private/qwayland-server-input-method.h> #include <QRect> @@ -46,24 +48,24 @@ QT_BEGIN_NAMESPACE -class QWaylandInputPanel; - namespace QtWayland { - class Compositor; class Surface; class TextInput; +} -class Q_COMPOSITOR_EXPORT InputPanel : public QtWaylandServer::wl_input_panel + +class Q_COMPOSITOR_EXPORT QWaylandInputPanelPrivate : public QWaylandExtensionTemplatePrivateImpl<QtWaylandServer::wl_input_panel> { + Q_DECLARE_PUBLIC(QWaylandInputPanel) public: - InputPanel(Compositor *compositor); - ~InputPanel(); + QWaylandInputPanelPrivate(QtWayland::Compositor *compositor); + ~QWaylandInputPanelPrivate(); - QWaylandInputPanel *handle() const; + QWaylandInputPanel *waylandInputPanel() const; - Surface *focus() const; - void setFocus(Surface *focus); + QtWayland::Surface *focus() const; + void setFocus(QtWayland::Surface *focus); bool inputPanelVisible() const; void setInputPanelVisible(bool inputPanelVisible); @@ -71,20 +73,19 @@ public: QRect cursorRectangle() const; void setCursorRectangle(const QRect &cursorRectangle); + static QWaylandInputPanelPrivate *get(QWaylandExtensionContainer *container); + static QWaylandInputPanelPrivate *get(QWaylandInputPanel *panel); protected: void input_panel_get_input_panel_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface) Q_DECL_OVERRIDE; private: - Compositor *m_compositor; - QScopedPointer<QWaylandInputPanel> m_handle; + QtWayland::Compositor *m_compositor; - Surface *m_focus; + QtWayland::Surface *m_focus; bool m_inputPanelVisible; QRect m_cursorRectangle; }; -} // namespace QtWayland - QT_END_NAMESPACE #endif // QTWAYLAND_QWLINPUTPANEL_P_H diff --git a/src/compositor/wayland_wrapper/qwlinputpanelsurface.cpp b/src/compositor/extensions/qwlinputpanelsurface.cpp index a72afa2b3..a72afa2b3 100644 --- a/src/compositor/wayland_wrapper/qwlinputpanelsurface.cpp +++ b/src/compositor/extensions/qwlinputpanelsurface.cpp diff --git a/src/compositor/wayland_wrapper/qwlinputpanelsurface_p.h b/src/compositor/extensions/qwlinputpanelsurface_p.h index 0591832fb..0591832fb 100644 --- a/src/compositor/wayland_wrapper/qwlinputpanelsurface_p.h +++ b/src/compositor/extensions/qwlinputpanelsurface_p.h diff --git a/src/compositor/wayland_wrapper/qwlqtkey.cpp b/src/compositor/extensions/qwlqtkey.cpp index 34506e6fb..b7d567a0a 100644 --- a/src/compositor/wayland_wrapper/qwlqtkey.cpp +++ b/src/compositor/extensions/qwlqtkey.cpp @@ -44,7 +44,8 @@ QT_BEGIN_NAMESPACE namespace QtWayland { QtKeyExtensionGlobal::QtKeyExtensionGlobal(Compositor *compositor) - : QtWaylandServer::qt_key_extension(compositor->wl_display(), 2) + : QWaylandExtension(compositor->waylandCompositor()) + , QtWaylandServer::qt_key_extension(compositor->wl_display(), 2) , m_compositor(compositor) { } @@ -72,6 +73,11 @@ bool QtKeyExtensionGlobal::postQtKeyEvent(QKeyEvent *event, Surface *surface) return false; } +QtKeyExtensionGlobal *QtKeyExtensionGlobal::get(QWaylandExtensionContainer *container) +{ + return static_cast<QtKeyExtensionGlobal *>(container->extension(qt_key_extension::name())); +} + } QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwlqtkey_p.h b/src/compositor/extensions/qwlqtkey_p.h index 76cf6c310..542f6eae2 100644 --- a/src/compositor/wayland_wrapper/qwlqtkey_p.h +++ b/src/compositor/extensions/qwlqtkey_p.h @@ -51,13 +51,17 @@ class QKeyEvent; namespace QtWayland { -class QtKeyExtensionGlobal : public QtWaylandServer::qt_key_extension +class QtKeyExtensionGlobal : public QWaylandExtension, public QtWaylandServer::qt_key_extension { + Q_OBJECT public: QtKeyExtensionGlobal(Compositor *compositor); bool postQtKeyEvent(QKeyEvent *event, Surface *surface); + const struct wl_interface *interface() const Q_DECL_OVERRIDE { return qt_key_extension::interface(); } + + static QtKeyExtensionGlobal *get(QWaylandExtensionContainer *container); private: Compositor *m_compositor; }; diff --git a/src/compositor/wayland_wrapper/qwlqttouch.cpp b/src/compositor/extensions/qwlqttouch.cpp index b99ff776b..872bbdcb5 100644 --- a/src/compositor/wayland_wrapper/qwlqttouch.cpp +++ b/src/compositor/extensions/qwlqttouch.cpp @@ -47,7 +47,8 @@ namespace QtWayland { static const int maxRawPos = 24; TouchExtensionGlobal::TouchExtensionGlobal(Compositor *compositor) - : QtWaylandServer::qt_touch_extension(compositor->wl_display(), 1) + : QWaylandExtension(compositor->waylandCompositor()) + , QtWaylandServer::qt_touch_extension(compositor->wl_display(), 1) , m_compositor(compositor) , m_flags(0) , m_resources() @@ -141,6 +142,20 @@ bool TouchExtensionGlobal::postTouchEvent(QTouchEvent *event, QWaylandSurfaceVie return false; } +void TouchExtensionGlobal::setBehviorFlags(BehaviorFlags flags) +{ + if (m_flags == flags) + return; + + m_flags = flags; + behaviorFlagsChanged(); +} + +TouchExtensionGlobal *TouchExtensionGlobal::get(QWaylandExtensionContainer *container) +{ + return static_cast<TouchExtensionGlobal *>(container->extension(qt_touch_extension::name())); +} + void TouchExtensionGlobal::touch_extension_bind_resource(Resource *resource) { m_resources.append(resource); diff --git a/src/compositor/wayland_wrapper/qwlqttouch_p.h b/src/compositor/extensions/qwlqttouch_p.h index e9d42f7e3..2c108f069 100644 --- a/src/compositor/wayland_wrapper/qwlqttouch_p.h +++ b/src/compositor/extensions/qwlqttouch_p.h @@ -50,15 +50,31 @@ class QWaylandSurfaceView; namespace QtWayland { -class TouchExtensionGlobal : public QtWaylandServer::qt_touch_extension +class TouchExtensionGlobal : public QWaylandExtension, public QtWaylandServer::qt_touch_extension { + Q_OBJECT + Q_PROPERTY(BehaviorFlags behaviorFlags READ behaviorFlags WRITE setBehviorFlags NOTIFY behaviorFlagsChanged) public: + + enum BehaviorFlag{ + None = 0x00, + MouseFromTouch = 0x01 + }; + Q_DECLARE_FLAGS(BehaviorFlags, BehaviorFlag) + TouchExtensionGlobal(Compositor *compositor); ~TouchExtensionGlobal(); bool postTouchEvent(QTouchEvent *event, QWaylandSurfaceView *view); - void setFlags(int flags) { m_flags = flags; } + void setBehviorFlags(BehaviorFlags flags); + BehaviorFlags behaviorFlags() const { return m_flags; } + + const struct wl_interface *interface() const Q_DECL_OVERRIDE { return QtWaylandServer::qt_touch_extension::interface(); } + + static TouchExtensionGlobal *get(QWaylandExtensionContainer *container); +signals: + void behaviorFlagsChanged(); protected: void touch_extension_bind_resource(Resource *resource) Q_DECL_OVERRIDE; @@ -66,11 +82,13 @@ protected: private: Compositor *m_compositor; - int m_flags; + BehaviorFlags m_flags; QList<Resource *> m_resources; QVector<float> m_posData; }; +Q_DECLARE_OPERATORS_FOR_FLAGS(TouchExtensionGlobal::BehaviorFlags) + } QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwlshellsurface.cpp b/src/compositor/extensions/qwlshellsurface.cpp index 09316358b..de53f60eb 100644 --- a/src/compositor/wayland_wrapper/qwlshellsurface.cpp +++ b/src/compositor/extensions/qwlshellsurface.cpp @@ -55,7 +55,9 @@ QT_BEGIN_NAMESPACE namespace QtWayland { -Shell::Shell() +Shell::Shell(QWaylandCompositor *compositor) + : QWaylandExtension(compositor) + , wl_shell(compositor->waylandDisplay(), 1) { } @@ -64,11 +66,6 @@ const wl_interface *Shell::interface() const return &wl_shell_interface; } -void Shell::bind(struct wl_client *client, uint32_t version, uint32_t id) -{ - add(client, id, version); -} - ShellSurfacePopupGrabber *Shell::getPopupGrabber(InputDevice *input) { if (!m_popupGrabber.contains(input)) @@ -84,9 +81,13 @@ void Shell::shell_get_shell_surface(Resource *resource, uint32_t id, struct ::wl } +ShellSurface *ShellSurface::get(QWaylandSurface *surface) +{ + return static_cast<ShellSurface *>(surface->extension(wl_shell_surface::name())); +} ShellSurface::ShellSurface(Shell *shell, wl_client *client, uint32_t id, Surface *surface) - : QWaylandSurfaceInterface(surface->waylandSurface()) + : QWaylandExtension(surface->waylandSurface()) , wl_shell_surface(client, id, 1) , m_shell(shell) , m_surface(surface) @@ -94,13 +95,13 @@ ShellSurface::ShellSurface(Shell *shell, wl_client *client, uint32_t id, Surface , m_moveGrabber(0) , m_popupGrabber(0) , m_popupSerial() + , m_surfaceType(None) { m_view = surface->compositor()->waylandCompositor()->createSurfaceView(surface->waylandSurface()); m_view->setOutput(surface->waylandSurface()->primaryOutput()); connect(surface->waylandSurface(), &QWaylandSurface::configure, this, &ShellSurface::configure); connect(surface->waylandSurface(), &QWaylandSurface::mapped, this, &ShellSurface::mapped); connect(surface->waylandSurface(), &QWaylandSurface::offsetForNextFrame, this, &ShellSurface::adjustOffset); - surface->setShellSurface(this); } ShellSurface::~ShellSurface() @@ -113,12 +114,32 @@ void ShellSurface::sendConfigure(uint32_t edges, int32_t width, int32_t height) send_configure(edges, width, height); } +void ShellSurface::ping() +{ + uint32_t serial = wl_display_next_serial(m_surface->compositor()->wl_display()); + ping(serial); +} + void ShellSurface::ping(uint32_t serial) { m_pings.insert(serial); send_ping(serial); } +void ShellSurface::setSurfaceType(SurfaceType type) +{ + if (m_surfaceType == type) + return; + + m_surfaceType = type; + emit surfaceTypeChanged(); +} + +ShellSurface::SurfaceType ShellSurface::surfaceType() const +{ + return m_surfaceType; +} + void ShellSurface::adjustPosInResize() { if (m_surface->transientParent()) @@ -158,24 +179,9 @@ void ShellSurface::configure(bool hasBuffer) m_surface->setMapped(hasBuffer); } -bool ShellSurface::runOperation(QWaylandSurfaceOp *op) -{ - switch (op->type()) { - case QWaylandSurfaceOp::Ping: - ping(static_cast<QWaylandSurfacePingOp *>(op)->serial()); - return true; - case QWaylandSurfaceOp::Resize: - requestSize(static_cast<QWaylandSurfaceResizeOp *>(op)->size()); - return true; - default: - break; - } - return false; -} - void ShellSurface::mapped() { - if (m_surface->waylandSurface()->windowType() == QWaylandSurface::Popup) { + if (m_surfaceType == Popup) { if (m_surface->mapped() && m_popupGrabber->grabSerial() == m_popupSerial) { m_popupGrabber->addPopup(this); } else { @@ -290,7 +296,6 @@ void ShellSurface::shell_surface_set_fullscreen(Resource *resource, Q_UNUSED(resource); Q_UNUSED(method); Q_UNUSED(framerate); - QWaylandOutput *output = output_resource ? QWaylandOutput::fromResource(output_resource) : Q_NULLPTR; diff --git a/src/compositor/wayland_wrapper/qwlshellsurface_p.h b/src/compositor/extensions/qwlshellsurface_p.h index 033a8f971..804ee2cff 100644 --- a/src/compositor/wayland_wrapper/qwlshellsurface_p.h +++ b/src/compositor/extensions/qwlshellsurface_p.h @@ -39,8 +39,7 @@ #include <QtCompositor/qwaylandexport.h> #include <QtCompositor/qwaylandsurface.h> -#include <QtCompositor/qwaylandglobalinterface.h> -#include <QtCompositor/qwaylandsurfaceinterface.h> +#include <QtCompositor/qwaylandextension.h> #include <wayland-server.h> #include <QHash> @@ -63,15 +62,14 @@ class ShellSurfaceResizeGrabber; class ShellSurfaceMoveGrabber; class ShellSurfacePopupGrabber; -class Shell : public QWaylandGlobalInterface, public QtWaylandServer::wl_shell +class Shell : public QWaylandExtension, public QtWaylandServer::wl_shell { + Q_OBJECT public: - Shell(); + Shell(QWaylandCompositor *compositor); const wl_interface *interface() const Q_DECL_OVERRIDE; - void bind(struct wl_client *client, uint32_t version, uint32_t id) Q_DECL_OVERRIDE; - ShellSurfacePopupGrabber* getPopupGrabber(InputDevice *input); private: @@ -80,9 +78,20 @@ private: QHash<InputDevice*, ShellSurfacePopupGrabber*> m_popupGrabber; }; -class Q_COMPOSITOR_EXPORT ShellSurface : public QObject, public QWaylandSurfaceInterface, public QtWaylandServer::wl_shell_surface +class Q_COMPOSITOR_EXPORT ShellSurface : public QWaylandExtension, public QtWaylandServer::wl_shell_surface { + Q_OBJECT + Q_PROPERTY(SurfaceType surfaceType READ surfaceType WRITE setSurfaceType NOTIFY surfaceTypeChanged) public: + enum SurfaceType { + None, + Toplevel, + Transient, + Popup + }; + + static ShellSurface *get(QWaylandSurface *surface); + ShellSurface(Shell *shell, struct wl_client *client, uint32_t id, Surface *surface); ~ShellSurface(); void sendConfigure(uint32_t edges, int32_t width, int32_t height); @@ -96,11 +105,19 @@ public: void configure(bool hasBuffer); void requestSize(const QSize &size); + + Q_INVOKABLE void ping(); void ping(uint32_t serial); QWaylandSurfaceView *view() { return m_view; } -protected: - bool runOperation(QWaylandSurfaceOp *op) Q_DECL_OVERRIDE; + + const struct wl_interface *interface() const Q_DECL_OVERRIDE { return QtWaylandServer::wl_shell_surface::interface(); } + + void setSurfaceType(SurfaceType type); + SurfaceType surfaceType() const; + +signals: + void surfaceTypeChanged(); private Q_SLOTS: void mapped(); @@ -119,6 +136,8 @@ private: QSet<uint32_t> m_pings; + SurfaceType m_surfaceType; + void shell_surface_destroy_resource(Resource *resource) Q_DECL_OVERRIDE; void shell_surface_move(Resource *resource, diff --git a/src/compositor/extensions/qwlsubsurface.cpp b/src/compositor/extensions/qwlsubsurface.cpp new file mode 100644 index 000000000..fb99fbe81 --- /dev/null +++ b/src/compositor/extensions/qwlsubsurface.cpp @@ -0,0 +1,161 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWaylandCompositor module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwlsubsurface_p.h" + +#include "qwlcompositor_p.h" +#include "qwaylandsurface.h" +#include "qwaylandsurfaceview.h" + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +SubSurfaceExtensionGlobal::SubSurfaceExtensionGlobal(QWaylandCompositor *compositor) + : QWaylandExtension(compositor) + , qt_sub_surface_extension(compositor->waylandDisplay(), 1) + , m_compositor(compositor) +{ +} + +void SubSurfaceExtensionGlobal::sub_surface_extension_get_sub_surface_aware_surface(Resource *resource, + uint32_t id, + struct ::wl_resource *surface) +{ + QWaylandSurface *waylandsurface = QWaylandSurface::fromResource(surface); + new SubSurface(resource->client(),id,waylandsurface); +} + +SubSurface::SubSurface(wl_client *client, uint32_t id, QWaylandSurface *surface) + : QWaylandExtension(surface) + , qt_sub_surface(client, id, 1) + , m_surface(surface) + , m_parent(0) +{ +} + +SubSurface::~SubSurface() +{ + if (m_parent) { + m_parent->removeSubSurface(this); + } + QLinkedList<QWaylandSurface *>::iterator it; + for (it = m_sub_surfaces.begin(); it != m_sub_surfaces.end(); ++it) { + (*it)->handle()->subSurface()->parentDestroyed(); + } +} + +void SubSurface::setSubSurface(SubSurface *subSurface, int x, int y) +{ + if (!m_sub_surfaces.contains(subSurface->m_surface)) { + m_sub_surfaces.append(subSurface->m_surface); + subSurface->setParent(this); + } + foreach (QWaylandSurfaceView *view, subSurface->m_surface->views()) + view->setRequestedPosition(QPointF(x,y)); +} + +void SubSurface::removeSubSurface(SubSurface *subSurfaces) +{ + Q_ASSERT(m_sub_surfaces.contains(subSurfaces->m_surface)); + m_sub_surfaces.removeOne(subSurfaces->m_surface); +} + +SubSurface *SubSurface::parent() const +{ + return m_parent; +} + +void SubSurface::setParent(SubSurface *parent) +{ + if (m_parent == parent) + return; + + SubSurface *oldParent = 0; + SubSurface *newParent = 0; + + if (m_parent) { + oldParent = m_parent; + m_parent->removeSubSurface(this); + } + if (parent) { + newParent = parent; + } + m_parent = parent; + + parentChanged(newParent,oldParent); +} + +QLinkedList<QWaylandSurface *> SubSurface::subSurfaces() const +{ + return m_sub_surfaces; +} + +void SubSurface::parentDestroyed() +{ + m_parent = 0; +} + +void SubSurface::sub_surface_attach_sub_surface(Resource *resource, struct ::wl_resource *sub_surface, int32_t x, int32_t y) +{ + Q_UNUSED(resource); + SubSurface *child_sub_surface = static_cast<SubSurface *>(Resource::fromResource(sub_surface)->sub_surface_object); + setSubSurface(child_sub_surface,x,y); +} + +void SubSurface::sub_surface_move_sub_surface(Resource *resource, struct ::wl_resource *sub_surface, int32_t x, int32_t y) +{ + Q_UNUSED(resource); + Q_UNUSED(sub_surface); + Q_UNUSED(x); + Q_UNUSED(y); +} + +void SubSurface::sub_surface_raise(Resource *resource, struct ::wl_resource *sub_surface) +{ + Q_UNUSED(resource); + Q_UNUSED(sub_surface); +} + +void SubSurface::sub_surface_lower(Resource *resource, struct ::wl_resource *sub_surface) +{ + Q_UNUSED(resource); + Q_UNUSED(sub_surface); +} + +} + +QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwlsubsurface_p.h b/src/compositor/extensions/qwlsubsurface_p.h index 27c2bc172..66eff6dc9 100644 --- a/src/compositor/wayland_wrapper/qwlsubsurface_p.h +++ b/src/compositor/extensions/qwlsubsurface_p.h @@ -39,7 +39,7 @@ #include <private/qwlsurface_p.h> -#include <QtCompositor/private/wayland-sub-surface-extension-server-protocol.h> +#include <QtCompositor/private/qwayland-server-sub-surface-extension.h> #include <QtCore/QLinkedList> @@ -50,28 +50,25 @@ class QWaylandSurface; namespace QtWayland { -class SubSurfaceExtensionGlobal +class SubSurfaceExtensionGlobal : public QWaylandExtension, public QtWaylandServer::qt_sub_surface_extension { + Q_OBJECT public: - SubSurfaceExtensionGlobal(Compositor *compositor); + SubSurfaceExtensionGlobal(QWaylandCompositor *compositor); + const struct wl_interface *interface() const { return qt_sub_surface_extension::interface(); } private: - Compositor *m_compositor; + QWaylandCompositor *m_compositor; - static void bind_func(struct wl_client *client, void *data, - uint32_t version, uint32_t id); - static void get_sub_surface_aware_surface(struct wl_client *client, - struct wl_resource *sub_surface_extension_resource, - uint32_t id, - struct wl_resource *surface_resource); - - static const struct qt_sub_surface_extension_interface sub_surface_extension_interface; + void sub_surface_extension_get_sub_surface_aware_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface) Q_DECL_OVERRIDE; }; -class SubSurface +class SubSurface : public QWaylandExtension, public QtWaylandServer::qt_sub_surface { + Q_OBJECT + Q_PROPERTY(SubSurface *parent READ parent WRITE setParent NOTIFY parentChanged) public: - SubSurface(struct wl_client *client, uint32_t id, Surface *surface); + SubSurface(struct wl_client *client, uint32_t id, QWaylandSurface *surface); ~SubSurface(); void setSubSurface(SubSurface *subSurface, int x, int y); @@ -82,46 +79,34 @@ public: QLinkedList<QWaylandSurface *> subSurfaces() const; - Surface *surface() const; - QWaylandSurface *waylandSurface() const; + QWaylandSurface *surface() const; + + const struct wl_interface *interface() const { return qt_sub_surface::interface(); } + +signals: + void parentChanged(SubSurface *newParent, SubSurface *oldParent); + +protected: + void sub_surface_attach_sub_surface(Resource *resource, struct ::wl_resource *sub_surface, int32_t x, int32_t y) Q_DECL_OVERRIDE; + void sub_surface_move_sub_surface(Resource *resource, struct ::wl_resource *sub_surface, int32_t x, int32_t y) Q_DECL_OVERRIDE; + void sub_surface_raise(Resource *resource, struct ::wl_resource *sub_surface) Q_DECL_OVERRIDE; + void sub_surface_lower(Resource *resource, struct ::wl_resource *sub_surface) Q_DECL_OVERRIDE; private: void parentDestroyed(); struct wl_resource *m_sub_surface_resource; - Surface *m_surface; + QWaylandSurface *m_surface; SubSurface *m_parent; QLinkedList<QWaylandSurface *> m_sub_surfaces; - static void attach_sub_surface(struct wl_client *client, - struct wl_resource *sub_surface_parent_resource, - struct wl_resource *sub_surface_child_resource, - int32_t x, - int32_t y); - static void move_sub_surface(struct wl_client *client, - struct wl_resource *sub_surface_parent_resource, - struct wl_resource *sub_surface_child_resource, - int32_t x, - int32_t y); - static void raise(struct wl_client *client, - struct wl_resource *sub_surface_parent_resource, - struct wl_resource *sub_surface_child_resource); - static void lower(struct wl_client *client, - struct wl_resource *sub_surface_parent_resource, - struct wl_resource *sub_surface_child_resource); - static const struct qt_sub_surface_interface sub_surface_interface; }; -inline Surface *SubSurface::surface() const +inline QWaylandSurface *SubSurface::surface() const { return m_surface; } -inline QWaylandSurface *SubSurface::waylandSurface() const -{ - return m_surface->waylandSurface(); -} - } QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwltextinput.cpp b/src/compositor/extensions/qwltextinput.cpp index af5771d7a..af1b73cb6 100644 --- a/src/compositor/wayland_wrapper/qwltextinput.cpp +++ b/src/compositor/extensions/qwltextinput.cpp @@ -49,8 +49,9 @@ QT_BEGIN_NAMESPACE namespace QtWayland { -TextInput::TextInput(Compositor *compositor, struct ::wl_client *client, int id) - : wl_text_input(client, id, 1) +TextInput::TextInput(QWaylandExtensionContainer *container, Compositor *compositor, struct ::wl_client *client, int id) + : QWaylandExtension(container) + , wl_text_input(client, id, 1) , m_compositor(compositor) , m_focus() , m_inputPanelVisible() @@ -128,24 +129,33 @@ void TextInput::text_input_show_input_panel(Resource *) { m_inputPanelVisible = true; - if (std::find_if(m_activeInputMethods.cbegin(), m_activeInputMethods.cend(), isInputMethodBound) != m_activeInputMethods.cend()) - m_compositor->inputPanel()->setInputPanelVisible(true); + if (std::find_if(m_activeInputMethods.cbegin(), m_activeInputMethods.cend(), isInputMethodBound) != m_activeInputMethods.cend()){ + QWaylandInputPanelPrivate *panel = QWaylandInputPanelPrivate::get(m_compositor->waylandCompositor()); + if (panel) + panel->setInputPanelVisible(true); + } } void TextInput::text_input_hide_input_panel(Resource *) { m_inputPanelVisible = false; - if (std::find_if(m_activeInputMethods.cbegin(), m_activeInputMethods.cend(), isInputMethodBound) != m_activeInputMethods.cend()) - m_compositor->inputPanel()->setInputPanelVisible(false); + if (std::find_if(m_activeInputMethods.cbegin(), m_activeInputMethods.cend(), isInputMethodBound) != m_activeInputMethods.cend()) { + QWaylandInputPanelPrivate *panel = QWaylandInputPanelPrivate::get(m_compositor->waylandCompositor()); + if (panel) + panel->setInputPanelVisible(false); + } } void TextInput::text_input_set_cursor_rectangle(Resource *, int32_t x, int32_t y, int32_t width, int32_t height) { m_cursorRectangle = QRect(x, y, width, height); - if (!m_activeInputMethods.isEmpty()) - m_compositor->inputPanel()->setCursorRectangle(m_cursorRectangle); + if (!m_activeInputMethods.isEmpty()) { + QWaylandInputPanelPrivate *panel = QWaylandInputPanelPrivate::get(m_compositor->waylandCompositor()); + if (panel) + panel->setCursorRectangle(m_cursorRectangle); + } } void TextInput::text_input_reset(Resource *) diff --git a/src/compositor/wayland_wrapper/qwltextinput_p.h b/src/compositor/extensions/qwltextinput_p.h index 9d6f75247..60485d32d 100644 --- a/src/compositor/wayland_wrapper/qwltextinput_p.h +++ b/src/compositor/extensions/qwltextinput_p.h @@ -37,6 +37,7 @@ #ifndef QTWAYLAND_QWLTEXTINPUT_P_H #define QTWAYLAND_QWLTEXTINPUT_P_H +#include <QtCompositor/QWaylandExtension> #include <QtCompositor/private/qwayland-server-text.h> #include <QRect> @@ -49,10 +50,10 @@ class Compositor; class InputMethod; class Surface; -class TextInput : public QtWaylandServer::wl_text_input +class TextInput : public QWaylandExtension, public QtWaylandServer::wl_text_input { public: - explicit TextInput(Compositor *compositor, struct ::wl_client *client, int id); + explicit TextInput(QWaylandExtensionContainer *container, Compositor *compositor, struct ::wl_client *client, int id); Surface *focus() const; @@ -61,6 +62,7 @@ public: void deactivate(InputMethod *inputMethod); + const struct wl_interface *interface() const Q_DECL_OVERRIDE { return wl_text_input::interface(); } protected: void text_input_destroy_resource(Resource *resource) Q_DECL_OVERRIDE; diff --git a/src/compositor/wayland_wrapper/qwltextinputmanager.cpp b/src/compositor/extensions/qwltextinputmanager.cpp index 1daa8cb7b..738680151 100644 --- a/src/compositor/wayland_wrapper/qwltextinputmanager.cpp +++ b/src/compositor/extensions/qwltextinputmanager.cpp @@ -44,7 +44,8 @@ QT_BEGIN_NAMESPACE namespace QtWayland { TextInputManager::TextInputManager(Compositor *compositor) - : QtWaylandServer::wl_text_input_manager(compositor->wl_display(), 1) + : QWaylandExtension(compositor->waylandCompositor()) + , QtWaylandServer::wl_text_input_manager(compositor->wl_display(), 1) , m_compositor(compositor) { } @@ -55,7 +56,7 @@ TextInputManager::~TextInputManager() void TextInputManager::text_input_manager_create_text_input(Resource *resource, uint32_t id) { - new TextInput(m_compositor, resource->client(), id); + new TextInput(this, m_compositor, resource->client(), id); } } // namespace QtWayland diff --git a/src/compositor/wayland_wrapper/qwltextinputmanager_p.h b/src/compositor/extensions/qwltextinputmanager_p.h index ae883af50..b9f3a0ae5 100644 --- a/src/compositor/wayland_wrapper/qwltextinputmanager_p.h +++ b/src/compositor/extensions/qwltextinputmanager_p.h @@ -37,6 +37,7 @@ #ifndef QTWAYLAND_QWLTEXTINPUTMANAGER_P_H #define QTWAYLAND_QWLTEXTINPUTMANAGER_P_H +#include <QtCompositor/QWaylandExtension> #include <QtCompositor/private/qwayland-server-text.h> QT_BEGIN_NAMESPACE @@ -45,12 +46,14 @@ namespace QtWayland { class Compositor; -class TextInputManager : public QtWaylandServer::wl_text_input_manager +class TextInputManager : public QWaylandExtension, public QtWaylandServer::wl_text_input_manager, public QWaylandExtensionContainer { + Q_OBJECT public: TextInputManager(Compositor *compositor); ~TextInputManager(); + const struct wl_interface *interface() const Q_DECL_OVERRIDE { return wl_text_input_manager::interface(); } protected: void text_input_manager_create_text_input(Resource *resource, uint32_t id) Q_DECL_OVERRIDE; diff --git a/src/compositor/global/global.pri b/src/compositor/global/global.pri index fdb2049cd..68b385e92 100644 --- a/src/compositor/global/global.pri +++ b/src/compositor/global/global.pri @@ -1,5 +1,10 @@ INCLUDEPATH += global/ HEADERS += \ - global/qwaylandexport.h + global/qwaylandexport.h \ + global/qwaylandextension.h \ + global/qwaylandextension_p.h + +SOURCES += \ + global/qwaylandextension.cpp diff --git a/src/compositor/global/qwaylandextension.cpp b/src/compositor/global/qwaylandextension.cpp new file mode 100644 index 000000000..55fd994ee --- /dev/null +++ b/src/compositor/global/qwaylandextension.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWaylandCompositor module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include "qwaylandextension.h" +#include "qwaylandextension_p.h" + +#include <wayland-server.h> + +QT_BEGIN_NAMESPACE + +QWaylandExtension::QWaylandExtension(QWaylandExtensionContainer *container, QObject *parent) + : QObject(*new QWaylandExtensionPrivate(container), parent) +{ + container->addExtension(this); +} + +QWaylandExtension::QWaylandExtension(QWaylandExtensionPrivate &dd, QObject *parent) + : QObject(dd,parent) +{ + d_func()->extension_container->addExtension(this); +} + +QWaylandExtension::~QWaylandExtension() +{ + Q_D(QWaylandExtension); + d->extension_container->removeExtension(this); +} + +QWaylandExtensionContainer::~QWaylandExtensionContainer() +{ + foreach (QWaylandExtension *extension, extension_vector) { + delete extension; + } +} + +QWaylandExtension *QWaylandExtensionContainer::extension(const QByteArray &name) +{ + for (int i = 0; i < extension_vector.size(); i++) { + if (extension_vector.at(i)->name() == name) + return extension_vector.at(i); + } + return Q_NULLPTR; +} + +QWaylandExtension *QWaylandExtensionContainer::extension(const wl_interface *interface) +{ + for (int i = 0; i < extension_vector.size(); i++) { + if (extension_vector.at(i)->interface() == interface) + return extension_vector.at(i); + } + return Q_NULLPTR; +} + +QVector<QWaylandExtension *> QWaylandExtensionContainer::extensions() const +{ + return extension_vector; +} + +void QWaylandExtensionContainer::addExtension(QWaylandExtension *extension) +{ + Q_ASSERT(!extension_vector.contains(extension)); + extension_vector.append(extension); +} + +void QWaylandExtensionContainer::removeExtension(QWaylandExtension *extension) +{ + extension_vector.removeOne(extension); +} + +QWaylandExtensionTemplate::QWaylandExtensionTemplate(QWaylandExtensionContainer *container, QObject *parent) + : QWaylandExtension(container, parent) +{ } + +QWaylandExtensionTemplate::QWaylandExtensionTemplate(QWaylandExtensionTemplatePrivate &dd, QObject *parent) + : QWaylandExtension(dd, parent) +{ } + +const struct wl_interface *QWaylandExtensionTemplate::interface() const +{ + Q_D(const QWaylandExtensionTemplate); + return d->interface(); +} + +QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandsurfaceinterface.h b/src/compositor/global/qwaylandextension.h index 89d5772b6..c051e366f 100644 --- a/src/compositor/compositor_api/qwaylandsurfaceinterface.h +++ b/src/compositor/global/qwaylandextension.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtWaylandCompositor module of the Qt Toolkit. @@ -34,88 +34,65 @@ ** ****************************************************************************/ -#ifndef QWAYLANDSURFACEINTERFACE_H -#define QWAYLANDSURFACEINTERFACE_H +#ifndef QWAYLANDEXTENSION_H +#define QWAYLANDEXTENSION_H -#include <QWindow> - -#include <QtCompositor/qwaylandsurface.h> #include <QtCompositor/qwaylandexport.h> +#include <wayland-server.h> + +#include <QtCore/QObject> +#include <QtCore/QVector> QT_BEGIN_NAMESPACE -class QWaylandSurface; +class QWaylandCompositor; +class QWaylandExtensionContainer; +class QWaylandExtensionPrivate; -class Q_COMPOSITOR_EXPORT QWaylandSurfaceOp +class Q_COMPOSITOR_EXPORT QWaylandExtension : public QObject { + Q_OBJECT + Q_DECLARE_PRIVATE(QWaylandExtension) public: - enum Type { - Close, - SetVisibility, - Resize, - Ping, - UserType = 1000 - }; - - QWaylandSurfaceOp(int t); - virtual ~QWaylandSurfaceOp(); - - int type() const; - -private: - class Private; - Private *const d; -}; + QWaylandExtension(QWaylandExtensionContainer *container, QObject *parent = 0); + virtual ~QWaylandExtension(); -class Q_COMPOSITOR_EXPORT QWaylandSurfaceSetVisibilityOp : public QWaylandSurfaceOp -{ -public: - QWaylandSurfaceSetVisibilityOp(QWindow::Visibility visibility); - QWindow::Visibility visibility() const; - -private: - QWindow::Visibility m_visibility; -}; + virtual const struct wl_interface *interface() const = 0; -class Q_COMPOSITOR_EXPORT QWaylandSurfaceResizeOp : public QWaylandSurfaceOp -{ -public: - QWaylandSurfaceResizeOp(const QSize &size); - QSize size() const; + const QByteArray name() const { return interface()->name; } + quint32 version() const { return interface()->version; } -private: - QSize m_size; +protected: + QWaylandExtension(QWaylandExtensionPrivate &dd, QObject *parent = 0); }; -class Q_COMPOSITOR_EXPORT QWaylandSurfacePingOp : public QWaylandSurfaceOp +class Q_COMPOSITOR_EXPORT QWaylandExtensionContainer { public: - QWaylandSurfacePingOp(quint32 serial); - quint32 serial() const; + virtual ~QWaylandExtensionContainer(); + + QWaylandExtension *extension(const QByteArray &name); + QWaylandExtension *extension(const wl_interface *interface); + QVector<QWaylandExtension *> extensions() const; + void addExtension(QWaylandExtension *extension); + void removeExtension(QWaylandExtension *extension); -private: - quint32 m_serial; +protected: + QVector<QWaylandExtension *> extension_vector; }; -class Q_COMPOSITOR_EXPORT QWaylandSurfaceInterface +class QWaylandExtensionTemplatePrivate; +class Q_COMPOSITOR_EXPORT QWaylandExtensionTemplate : public QWaylandExtension { + Q_OBJECT + Q_DECLARE_PRIVATE(QWaylandExtensionTemplate) public: - QWaylandSurfaceInterface(QWaylandSurface *surf); - virtual ~QWaylandSurfaceInterface(); + QWaylandExtensionTemplate(QWaylandExtensionContainer *container, QObject *parent = 0); - QWaylandSurface *surface() const; + const struct wl_interface *interface() const Q_DECL_OVERRIDE; protected: - virtual bool runOperation(QWaylandSurfaceOp *op) = 0; - - void setSurfaceType(QWaylandSurface::WindowType type); - void setSurfaceClassName(const QString &name); - void setSurfaceTitle(const QString &title); - -private: - class Private; - Private *const d; - friend class QWaylandSurface; + QWaylandExtensionTemplate(QWaylandExtensionTemplatePrivate &dd, QObject *parent = 0); }; QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandglobalinterface.h b/src/compositor/global/qwaylandextension_p.h index e17b1671e..b86943650 100644 --- a/src/compositor/compositor_api/qwaylandglobalinterface.h +++ b/src/compositor/global/qwaylandextension_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtWaylandCompositor module of the Qt Toolkit. @@ -34,35 +34,47 @@ ** ****************************************************************************/ -#ifndef QWAYLANDGLOBALINTERFACE_H -#define QWAYLANDGLOBALINTERFACE_H +#ifndef QWAYLANDEXTENSION_P_H +#define QWAYLANDEXTENSION_P_H -#include <QtCompositor/qwaylandexport.h> +#include "qwaylandextension.h" +#include <QtCore/private/qobject_p.h> -struct wl_interface; -struct wl_client; +class Q_COMPOSITOR_EXPORT QWaylandExtensionPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QWaylandExtension) -QT_BEGIN_NAMESPACE +public: + QWaylandExtensionPrivate(QWaylandExtensionContainer *container) + : QObjectPrivate() + , extension_container(container) + { + } -namespace QtWayland { -class Compositor; -} + QWaylandExtensionContainer *extension_container; +}; -class Q_COMPOSITOR_EXPORT QWaylandGlobalInterface +class Q_COMPOSITOR_EXPORT QWaylandExtensionTemplatePrivate : public QWaylandExtensionPrivate { + Q_DECLARE_PUBLIC(QWaylandExtension) + public: - QWaylandGlobalInterface(); - virtual ~QWaylandGlobalInterface(); + QWaylandExtensionTemplatePrivate(QWaylandExtensionContainer *container) + : QWaylandExtensionPrivate(container) + {} - virtual const wl_interface *interface() const = 0; - virtual quint32 version() const; + virtual const struct wl_interface *interface() const = 0; +}; -protected: - virtual void bind(wl_client *client, quint32 version, quint32 id) = 0; +template <typename T> +class Q_COMPOSITOR_EXPORT QWaylandExtensionTemplatePrivateImpl : public QWaylandExtensionTemplatePrivate, public T +{ +public: + QWaylandExtensionTemplatePrivateImpl(QWaylandExtensionContainer *container) + : QWaylandExtensionTemplatePrivate(container) + { } - friend class QtWayland::Compositor; + const struct wl_interface *interface() const Q_DECL_OVERRIDE { return T::interface(); } }; -QT_END_NAMESPACE - -#endif +#endif /*QWAYLANDEXTENSION_P_H*/ diff --git a/src/compositor/wayland_wrapper/qwlcompositor.cpp b/src/compositor/wayland_wrapper/qwlcompositor.cpp index e58c6e999..2de42fc2d 100644 --- a/src/compositor/wayland_wrapper/qwlcompositor.cpp +++ b/src/compositor/wayland_wrapper/qwlcompositor.cpp @@ -51,11 +51,10 @@ #include "qwlqttouch_p.h" #include "qwlqtkey_p.h" #include "qwlinputdevice_p.h" -#include "qwlinputpanel_p.h" #include "qwlregion_p.h" #include "qwlpointer_p.h" #include "qwltextinputmanager_p.h" -#include "qwaylandglobalinterface.h" +#include <QtCompositor/QWaylandInputPanel> #include "qwaylandsurfaceview.h" #include "qwaylandshmformathelper.h" #include "qwaylandoutput.h" @@ -90,7 +89,7 @@ #include "hardware_integration/qwlclientbufferintegration_p.h" #include "hardware_integration/qwlserverbufferintegration_p.h" #endif -#include "windowmanagerprotocol/waylandwindowmanagerintegration_p.h" +#include "extensions/qwaylandwindowmanagerextension.h" #include "hardware_integration/qwlclientbufferintegrationfactory_p.h" #include "hardware_integration/qwlserverbufferintegrationfactory_p.h" @@ -167,13 +166,6 @@ Compositor::Compositor(QWaylandCompositor *qt_compositor) , m_client_buffer_integration(0) , m_server_buffer_integration(0) #endif - , m_windowManagerIntegration(0) - , m_surfaceExtension(0) - , m_subSurfaceExtension(0) - , m_touchExtension(0) - , m_qtkeyExtension(0) - , m_textInputManager() - , m_inputPanel() , m_eventHandler(new WindowSystemEventHandler(this)) , m_retainSelection(false) , m_initialized(false) @@ -240,11 +232,6 @@ Compositor::~Compositor() qDeleteAll(m_outputSpaces); - delete m_surfaceExtension; - delete m_subSurfaceExtension; - delete m_touchExtension; - delete m_qtkeyExtension; - removeInputDevice(m_default_wayland_input_device); delete m_default_wayland_input_device; delete m_data_device_manager; @@ -361,8 +348,9 @@ void Compositor::destroyClient(QWaylandClient *client) if (!client) return; - if (m_windowManagerIntegration) - m_windowManagerIntegration->sendQuitMessage(client->client()); + WindowManagerServerIntegration *wmExtension = static_cast<WindowManagerServerIntegration *>(waylandCompositor()->extension(QtWaylandServer::qt_windowmanager::name())); + if (wmExtension) + wmExtension->sendQuitMessage(client->client()); wl_client_destroy(client->client()); } @@ -404,20 +392,23 @@ void Compositor::initializeHardwareIntegration() void Compositor::initializeExtensions() { if (m_extensions & QWaylandCompositor::SurfaceExtension) - m_surfaceExtension = new SurfaceExtensionGlobal(this); + new SurfaceExtensionGlobal(this); if (m_extensions & QWaylandCompositor::SubSurfaceExtension) - m_subSurfaceExtension = new SubSurfaceExtensionGlobal(this); + new SubSurfaceExtensionGlobal(waylandCompositor()); if (m_extensions & QWaylandCompositor::TouchExtension) - m_touchExtension = new TouchExtensionGlobal(this); + new TouchExtensionGlobal(this); if (m_extensions & QWaylandCompositor::QtKeyExtension) - m_qtkeyExtension = new QtKeyExtensionGlobal(this); + new QtKeyExtensionGlobal(this); if (m_extensions & QWaylandCompositor::TextInputExtension) { - m_textInputManager.reset(new TextInputManager(this)); - m_inputPanel.reset(new InputPanel(this)); + new TextInputManager(this); + new QWaylandInputPanel(waylandCompositor()); } if (m_extensions & QWaylandCompositor::WindowManagerExtension) { - m_windowManagerIntegration = new WindowManagerServerIntegration(m_qt_compositor, this); - m_windowManagerIntegration->initialize(m_display); + WindowManagerServerIntegration *wmint = new WindowManagerServerIntegration(m_qt_compositor, this); + wmint->initialize(m_display); + } + if (m_extensions & QWaylandCompositor::DefaultShellExtension) { + new Shell(waylandCompositor()); } } @@ -434,8 +425,9 @@ QList<QWaylandClient *> Compositor::clients() const void Compositor::setClientFullScreenHint(bool value) { - if (m_windowManagerIntegration) - m_windowManagerIntegration->setShowIsFullScreen(value); + WindowManagerServerIntegration *wmExtension = static_cast<WindowManagerServerIntegration *>(waylandCompositor()->extension(QtWaylandServer::qt_windowmanager::name())); + if (wmExtension) + wmExtension->setShowIsFullScreen(value); } QWaylandCompositor::ExtensionFlags Compositor::extensions() const @@ -449,17 +441,6 @@ InputDevice* Compositor::defaultInputDevice() return m_inputDevices.last()->handle(); } -void Compositor::configureTouchExtension(int flags) -{ - if (m_touchExtension) - m_touchExtension->setFlags(flags); -} - -InputPanel *Compositor::inputPanel() const -{ - return m_inputPanel.data(); -} - DataDeviceManager *Compositor::dataDeviceManager() const { return m_data_device_manager; @@ -505,12 +486,6 @@ void Compositor::sendDragEndEvent() // Drag::instance()->dragEnd(); } -void Compositor::bindGlobal(wl_client *client, void *data, uint32_t version, uint32_t id) -{ - QWaylandGlobalInterface *iface = static_cast<QWaylandGlobalInterface *>(data); - iface->bind(client, qMin(iface->version(), version), id); -}; - void Compositor::loadClientBufferIntegration() { #ifdef QT_COMPOSITOR_WAYLAND_GL diff --git a/src/compositor/wayland_wrapper/qwlcompositor_p.h b/src/compositor/wayland_wrapper/qwlcompositor_p.h index 304cb94f7..0862477e4 100644 --- a/src/compositor/wayland_wrapper/qwlcompositor_p.h +++ b/src/compositor/wayland_wrapper/qwlcompositor_p.h @@ -71,7 +71,6 @@ class SurfaceBuffer; class InputDevice; class DataDeviceManager; class SurfaceExtensionGlobal; -class SubSurfaceExtensionGlobal; class TouchExtensionGlobal; class QtKeyExtensionGlobal; class TextInputManager; @@ -129,17 +128,10 @@ public: QList<QWaylandClient *> clients() const; - WindowManagerServerIntegration *windowManagerIntegration() const { return m_windowManagerIntegration; } - void setClientFullScreenHint(bool value); QWaylandCompositor::ExtensionFlags extensions() const; - TouchExtensionGlobal *touchExtension() { return m_touchExtension; } - void configureTouchExtension(int flags); - - QtKeyExtensionGlobal *qtkeyExtension() { return m_qtkeyExtension; } - InputPanel *inputPanel() const; DataDeviceManager *dataDeviceManager() const; @@ -153,7 +145,6 @@ public: void overrideSelection(const QMimeData *data); void feedRetainedSelectionData(QMimeData *data); - static void bindGlobal(wl_client *client, void *data, uint32_t version, uint32_t id); void resetInputDevice(Surface *surface); void unregisterSurface(QWaylandSurface *surface); @@ -207,16 +198,6 @@ protected: QScopedPointer<ServerBufferIntegration> m_server_buffer_integration; #endif - //extensions - WindowManagerServerIntegration *m_windowManagerIntegration; - - SurfaceExtensionGlobal *m_surfaceExtension; - SubSurfaceExtensionGlobal *m_subSurfaceExtension; - TouchExtensionGlobal *m_touchExtension; - QtKeyExtensionGlobal *m_qtkeyExtension; - QScopedPointer<TextInputManager> m_textInputManager; - QScopedPointer<InputPanel> m_inputPanel; - QList<QWaylandGlobalInterface *> m_globals; QScopedPointer<QWindowSystemEventHandler> m_eventHandler; static void bind_func(struct wl_client *client, void *data, diff --git a/src/compositor/wayland_wrapper/qwlinputdevice.cpp b/src/compositor/wayland_wrapper/qwlinputdevice.cpp index a4af463f7..2e1720a9f 100644 --- a/src/compositor/wayland_wrapper/qwlinputdevice.cpp +++ b/src/compositor/wayland_wrapper/qwlinputdevice.cpp @@ -247,7 +247,7 @@ void InputDevice::sendFullKeyEvent(QKeyEvent *event) return; } - QtKeyExtensionGlobal *ext = m_compositor->qtkeyExtension(); + QtKeyExtensionGlobal *ext = QtKeyExtensionGlobal::get(m_compositor->waylandCompositor()); if (ext && ext->postQtKeyEvent(event, keyboardFocus())) return; @@ -261,7 +261,7 @@ void InputDevice::sendFullKeyEvent(QKeyEvent *event) void InputDevice::sendFullKeyEvent(Surface *surface, QKeyEvent *event) { - QtKeyExtensionGlobal *ext = m_compositor->qtkeyExtension(); + QtKeyExtensionGlobal *ext = QtKeyExtensionGlobal::get(m_compositor->waylandCompositor()); if (ext) ext->postQtKeyEvent(event, surface); } @@ -278,7 +278,7 @@ void InputDevice::sendFullTouchEvent(QTouchEvent *event) return; } - TouchExtensionGlobal *ext = m_compositor->touchExtension(); + TouchExtensionGlobal *ext = TouchExtensionGlobal::get(m_compositor->waylandCompositor()); if (ext && ext->postTouchEvent(event, mouseFocus())) return; diff --git a/src/compositor/wayland_wrapper/qwlinputmethod.cpp b/src/compositor/wayland_wrapper/qwlinputmethod.cpp index f17008f65..187c4e13d 100644 --- a/src/compositor/wayland_wrapper/qwlinputmethod.cpp +++ b/src/compositor/wayland_wrapper/qwlinputmethod.cpp @@ -78,9 +78,12 @@ void InputMethod::activate(TextInput *textInput) send_activate(m_resource->handle, m_context->resource()->handle); - m_compositor->inputPanel()->setFocus(textInput->focus()); - m_compositor->inputPanel()->setCursorRectangle(textInput->cursorRectangle()); - m_compositor->inputPanel()->setInputPanelVisible(textInput->inputPanelVisible()); + QWaylandInputPanelPrivate *panel = QWaylandInputPanelPrivate::get(m_compositor->waylandCompositor()); + if (panel) { + panel->setFocus(textInput->focus()); + panel->setCursorRectangle(textInput->cursorRectangle()); + panel->setInputPanelVisible(textInput->inputPanelVisible()); + } } void InputMethod::deactivate() @@ -94,9 +97,12 @@ void InputMethod::deactivate() m_textInput = 0; m_context = 0; - m_compositor->inputPanel()->setFocus(0); - m_compositor->inputPanel()->setCursorRectangle(QRect()); - m_compositor->inputPanel()->setInputPanelVisible(false); + QWaylandInputPanelPrivate *panel = QWaylandInputPanelPrivate::get(m_compositor->waylandCompositor()); + if (panel) { + panel->setFocus(0); + panel->setCursorRectangle(QRect()); + panel->setInputPanelVisible(false); + } } void InputMethod::focusChanged(Surface *surface) diff --git a/src/compositor/wayland_wrapper/qwloutput.cpp b/src/compositor/wayland_wrapper/qwloutput.cpp index 76acfb2b5..813e6e0d8 100644 --- a/src/compositor/wayland_wrapper/qwloutput.cpp +++ b/src/compositor/wayland_wrapper/qwloutput.cpp @@ -36,7 +36,6 @@ ****************************************************************************/ #include "qwloutput_p.h" - #include "qwlcompositor_p.h" #include "qwlsurface_p.h" diff --git a/src/compositor/wayland_wrapper/qwloutput_p.h b/src/compositor/wayland_wrapper/qwloutput_p.h index 917240c1f..974f5a789 100644 --- a/src/compositor/wayland_wrapper/qwloutput_p.h +++ b/src/compositor/wayland_wrapper/qwloutput_p.h @@ -68,9 +68,9 @@ struct SurfaceViewMapper QVector<QWaylandSurfaceView *> views; }; -struct OutputResource : public QtWaylandServer::wl_output::Resource +//Just for naming convenience +class OutputResource : public QtWaylandServer::wl_output::Resource { - OutputResource() {} }; class Output : public QtWaylandServer::wl_output diff --git a/src/compositor/wayland_wrapper/qwlpointer.cpp b/src/compositor/wayland_wrapper/qwlpointer.cpp index fe67bd1f0..389964fa2 100644 --- a/src/compositor/wayland_wrapper/qwlpointer.cpp +++ b/src/compositor/wayland_wrapper/qwlpointer.cpp @@ -327,9 +327,6 @@ void Pointer::button(uint32_t time, Qt::MouseButton button, uint32_t state) static void requestCursorSurface(QWaylandCompositor *compositor, QWaylandSurface *surface, int32_t hotspot_x, int hotspot_y) { -#if QT_DEPRECATED_SINCE(5, 5) - compositor->setCursorSurface(surface, hotspot_x, hotspot_y); -#endif compositor->currentCurserSurfaceRequest(surface, hotspot_x, hotspot_y); } diff --git a/src/compositor/wayland_wrapper/qwlsurface.cpp b/src/compositor/wayland_wrapper/qwlsurface.cpp index 375a0f054..498d9f23a 100644 --- a/src/compositor/wayland_wrapper/qwlsurface.cpp +++ b/src/compositor/wayland_wrapper/qwlsurface.cpp @@ -119,8 +119,6 @@ Surface::Surface(struct wl_client *client, uint32_t id, int version, QWaylandCom , m_primaryOutput(0) , m_buffer(0) , m_surfaceMapped(false) - , m_shellSurface(0) - , m_extendedSurface(0) , m_subSurface(0) , m_inputPanelSurface(0) , m_inputRegion(infiniteRegion()) @@ -233,30 +231,6 @@ QPoint Surface::lastMousePos() const return m_lastLocalMousePos; } -void Surface::setShellSurface(ShellSurface *shellSurface) -{ - m_shellSurface = shellSurface; - if (m_shellSurface) - emit m_waylandSurface->shellViewCreated(); -} - -ShellSurface *Surface::shellSurface() const -{ - return m_shellSurface; -} - -void Surface::setExtendedSurface(ExtendedSurface *extendedSurface) -{ - m_extendedSurface = extendedSurface; - if (m_extendedSurface) - emit m_waylandSurface->extendedSurfaceReady(); -} - -ExtendedSurface *Surface::extendedSurface() const -{ - return m_extendedSurface; -} - void Surface::setSubSurface(SubSurface *subSurface) { m_subSurface = subSurface; @@ -394,11 +368,6 @@ void Surface::notifyViewsAboutDestruction() void Surface::surface_destroy_resource(Resource *) { - if (m_extendedSurface) { - m_extendedSurface->setParentSurface(Q_NULLPTR); - m_extendedSurface = 0; - } - notifyViewsAboutDestruction(); m_destroyed = true; diff --git a/src/compositor/wayland_wrapper/qwlsurface_p.h b/src/compositor/wayland_wrapper/qwlsurface_p.h index b7299d2b4..e896c48a9 100644 --- a/src/compositor/wayland_wrapper/qwlsurface_p.h +++ b/src/compositor/wayland_wrapper/qwlsurface_p.h @@ -106,12 +106,6 @@ public: QPoint lastMousePos() const; - void setShellSurface(ShellSurface *shellSurface); - ShellSurface *shellSurface() const; - - void setExtendedSurface(ExtendedSurface *extendedSurface); - ExtendedSurface *extendedSurface() const; - void setSubSurface(SubSurface *subSurface); SubSurface *subSurface() const; @@ -200,8 +194,6 @@ protected: QList<FrameCallback *> m_pendingFrameCallbacks; QList<FrameCallback *> m_frameCallbacks; - ShellSurface *m_shellSurface; - ExtendedSurface *m_extendedSurface; SubSurface *m_subSurface; InputPanelSurface *m_inputPanelSurface; diff --git a/src/compositor/wayland_wrapper/wayland_wrapper.pri b/src/compositor/wayland_wrapper/wayland_wrapper.pri index eb66f6949..f7a630bd4 100644 --- a/src/compositor/wayland_wrapper/wayland_wrapper.pri +++ b/src/compositor/wayland_wrapper/wayland_wrapper.pri @@ -1,10 +1,5 @@ CONFIG += wayland-scanner WAYLANDSERVERSOURCES += \ - ../extensions/surface-extension.xml \ - ../extensions/sub-surface-extension.xml \ - ../extensions/touch-extension.xml \ - ../extensions/qtkey-extension.xml \ - ../extensions/windowmanager.xml \ ../3rdparty/protocol/wayland.xml \ ../3rdparty/protocol/input-method.xml \ ../3rdparty/protocol/text.xml @@ -16,24 +11,15 @@ HEADERS += \ wayland_wrapper/qwldataoffer_p.h \ wayland_wrapper/qwldatasource_p.h \ wayland_wrapper/qwldisplay_p.h \ - wayland_wrapper/qwlextendedsurface_p.h \ wayland_wrapper/qwlinputdevice_p.h \ wayland_wrapper/qwlinputmethod_p.h \ wayland_wrapper/qwlinputmethodcontext_p.h \ - wayland_wrapper/qwlinputpanel_p.h \ - wayland_wrapper/qwlinputpanelsurface_p.h \ wayland_wrapper/qwlkeyboard_p.h \ wayland_wrapper/qwloutput_p.h \ wayland_wrapper/qwlpointer_p.h \ - wayland_wrapper/qwlqtkey_p.h \ - wayland_wrapper/qwlqttouch_p.h \ wayland_wrapper/qwlregion_p.h \ - wayland_wrapper/qwlshellsurface_p.h \ - wayland_wrapper/qwlsubsurface_p.h \ wayland_wrapper/qwlsurface_p.h \ wayland_wrapper/qwlsurfacebuffer_p.h \ - wayland_wrapper/qwltextinput_p.h \ - wayland_wrapper/qwltextinputmanager_p.h \ wayland_wrapper/qwltouch_p.h \ wayland_wrapper/qwllistener_p.h \ ../shared/qwaylandxkb.h \ @@ -45,24 +31,15 @@ SOURCES += \ wayland_wrapper/qwldataoffer.cpp \ wayland_wrapper/qwldatasource.cpp \ wayland_wrapper/qwldisplay.cpp \ - wayland_wrapper/qwlextendedsurface.cpp \ wayland_wrapper/qwlinputdevice.cpp \ wayland_wrapper/qwlinputmethod.cpp \ wayland_wrapper/qwlinputmethodcontext.cpp \ - wayland_wrapper/qwlinputpanel.cpp \ - wayland_wrapper/qwlinputpanelsurface.cpp \ wayland_wrapper/qwlkeyboard.cpp \ wayland_wrapper/qwloutput.cpp \ wayland_wrapper/qwlpointer.cpp \ - wayland_wrapper/qwlqtkey.cpp \ - wayland_wrapper/qwlqttouch.cpp \ wayland_wrapper/qwlregion.cpp \ - wayland_wrapper/qwlshellsurface.cpp \ - wayland_wrapper/qwlsubsurface.cpp \ wayland_wrapper/qwlsurface.cpp \ wayland_wrapper/qwlsurfacebuffer.cpp \ - wayland_wrapper/qwltextinput.cpp \ - wayland_wrapper/qwltextinputmanager.cpp \ wayland_wrapper/qwltouch.cpp \ wayland_wrapper/qwllistener.cpp \ ../shared/qwaylandxkb.cpp \ diff --git a/src/compositor/windowmanagerprotocol/windowmanagerprotocol.pri b/src/compositor/windowmanagerprotocol/windowmanagerprotocol.pri deleted file mode 100644 index da3f2529c..000000000 --- a/src/compositor/windowmanagerprotocol/windowmanagerprotocol.pri +++ /dev/null @@ -1,9 +0,0 @@ -INCLUDEPATH += $$PWD - -HEADERS += \ - windowmanagerprotocol/waylandwindowmanagerintegration_p.h - -SOURCES += \ - windowmanagerprotocol/waylandwindowmanagerintegration.cpp - - |