From ce58545b220a49354533a27ef79cdbc8d50186cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 30 Jul 2015 14:53:35 +0200 Subject: Rework how we manage extensions Change-Id: If2cbf096e7419bc1bda007d5167ce39d1a5d50ae --- src/compositor/compositor.pro | 2 +- src/compositor/compositor_api/compositor_api.pri | 4 - .../compositor_api/qwaylandcompositor.cpp | 29 +- src/compositor/compositor_api/qwaylandcompositor.h | 16 +- .../compositor_api/qwaylandglobalinterface.cpp | 58 --- .../compositor_api/qwaylandglobalinterface.h | 68 --- .../compositor_api/qwaylandinputpanel.cpp | 38 +- src/compositor/compositor_api/qwaylandinputpanel.h | 8 +- .../compositor_api/qwaylandquickcompositor.cpp | 9 +- .../compositor_api/qwaylandquicksurface.cpp | 26 +- .../compositor_api/qwaylandquicksurface.h | 11 +- src/compositor/compositor_api/qwaylandsurface.cpp | 147 +----- src/compositor/compositor_api/qwaylandsurface.h | 52 +- src/compositor/compositor_api/qwaylandsurface_p.h | 3 - .../compositor_api/qwaylandsurfaceinterface.cpp | 139 ----- .../compositor_api/qwaylandsurfaceinterface.h | 123 ----- .../compositor_api/qwaylandsurfaceitem.cpp | 10 - .../compositor_api/qwaylandsurfaceitem.h | 2 - src/compositor/extensions/extensions.pri | 33 ++ .../extensions/qwaylandwindowmanagerextension.cpp | 108 ++++ .../extensions/qwaylandwindowmanagerextension.h | 80 +++ src/compositor/extensions/qwlextendedsurface.cpp | 192 +++++++ src/compositor/extensions/qwlextendedsurface_p.h | 150 ++++++ src/compositor/extensions/qwlinputpanel.cpp | 136 +++++ src/compositor/extensions/qwlinputpanel_p.h | 91 ++++ src/compositor/extensions/qwlinputpanelsurface.cpp | 87 ++++ src/compositor/extensions/qwlinputpanelsurface_p.h | 83 +++ src/compositor/extensions/qwlqtkey.cpp | 83 +++ src/compositor/extensions/qwlqtkey_p.h | 73 +++ src/compositor/extensions/qwlqttouch.cpp | 172 +++++++ src/compositor/extensions/qwlqttouch_p.h | 96 ++++ src/compositor/extensions/qwlshellsurface.cpp | 567 +++++++++++++++++++++ src/compositor/extensions/qwlshellsurface_p.h | 244 +++++++++ src/compositor/extensions/qwlsubsurface.cpp | 161 ++++++ src/compositor/extensions/qwlsubsurface_p.h | 114 +++++ src/compositor/extensions/qwltextinput.cpp | 211 ++++++++ src/compositor/extensions/qwltextinput_p.h | 95 ++++ src/compositor/extensions/qwltextinputmanager.cpp | 64 +++ src/compositor/extensions/qwltextinputmanager_p.h | 68 +++ src/compositor/global/global.pri | 7 +- src/compositor/global/qwaylandextension.cpp | 118 +++++ src/compositor/global/qwaylandextension.h | 100 ++++ src/compositor/global/qwaylandextension_p.h | 80 +++ src/compositor/wayland_wrapper/qwlcompositor.cpp | 63 +-- src/compositor/wayland_wrapper/qwlcompositor_p.h | 19 - .../wayland_wrapper/qwlextendedsurface.cpp | 197 ------- .../wayland_wrapper/qwlextendedsurface_p.h | 128 ----- src/compositor/wayland_wrapper/qwlinputdevice.cpp | 6 +- src/compositor/wayland_wrapper/qwlinputmethod.cpp | 18 +- src/compositor/wayland_wrapper/qwlinputpanel.cpp | 123 ----- src/compositor/wayland_wrapper/qwlinputpanel_p.h | 90 ---- .../wayland_wrapper/qwlinputpanelsurface.cpp | 87 ---- .../wayland_wrapper/qwlinputpanelsurface_p.h | 83 --- src/compositor/wayland_wrapper/qwloutput.cpp | 1 - src/compositor/wayland_wrapper/qwloutput_p.h | 4 +- src/compositor/wayland_wrapper/qwlpointer.cpp | 3 - src/compositor/wayland_wrapper/qwlqtkey.cpp | 77 --- src/compositor/wayland_wrapper/qwlqtkey_p.h | 69 --- src/compositor/wayland_wrapper/qwlqttouch.cpp | 157 ------ src/compositor/wayland_wrapper/qwlqttouch_p.h | 78 --- src/compositor/wayland_wrapper/qwlshellsurface.cpp | 562 -------------------- src/compositor/wayland_wrapper/qwlshellsurface_p.h | 225 -------- src/compositor/wayland_wrapper/qwlsubsurface_p.h | 129 ----- src/compositor/wayland_wrapper/qwlsurface.cpp | 31 -- src/compositor/wayland_wrapper/qwlsurface_p.h | 8 - src/compositor/wayland_wrapper/qwltextinput.cpp | 201 -------- src/compositor/wayland_wrapper/qwltextinput_p.h | 93 ---- .../wayland_wrapper/qwltextinputmanager.cpp | 63 --- .../wayland_wrapper/qwltextinputmanager_p.h | 65 --- src/compositor/wayland_wrapper/wayland_wrapper.pri | 23 - .../waylandwindowmanagerintegration.cpp | 108 ---- .../waylandwindowmanagerintegration_p.h | 79 --- .../windowmanagerprotocol.pri | 9 - 73 files changed, 3293 insertions(+), 3464 deletions(-) delete mode 100644 src/compositor/compositor_api/qwaylandglobalinterface.cpp delete mode 100644 src/compositor/compositor_api/qwaylandglobalinterface.h delete mode 100644 src/compositor/compositor_api/qwaylandsurfaceinterface.cpp delete mode 100644 src/compositor/compositor_api/qwaylandsurfaceinterface.h create mode 100644 src/compositor/extensions/extensions.pri create mode 100644 src/compositor/extensions/qwaylandwindowmanagerextension.cpp create mode 100644 src/compositor/extensions/qwaylandwindowmanagerextension.h create mode 100644 src/compositor/extensions/qwlextendedsurface.cpp create mode 100644 src/compositor/extensions/qwlextendedsurface_p.h create mode 100644 src/compositor/extensions/qwlinputpanel.cpp create mode 100644 src/compositor/extensions/qwlinputpanel_p.h create mode 100644 src/compositor/extensions/qwlinputpanelsurface.cpp create mode 100644 src/compositor/extensions/qwlinputpanelsurface_p.h create mode 100644 src/compositor/extensions/qwlqtkey.cpp create mode 100644 src/compositor/extensions/qwlqtkey_p.h create mode 100644 src/compositor/extensions/qwlqttouch.cpp create mode 100644 src/compositor/extensions/qwlqttouch_p.h create mode 100644 src/compositor/extensions/qwlshellsurface.cpp create mode 100644 src/compositor/extensions/qwlshellsurface_p.h create mode 100644 src/compositor/extensions/qwlsubsurface.cpp create mode 100644 src/compositor/extensions/qwlsubsurface_p.h create mode 100644 src/compositor/extensions/qwltextinput.cpp create mode 100644 src/compositor/extensions/qwltextinput_p.h create mode 100644 src/compositor/extensions/qwltextinputmanager.cpp create mode 100644 src/compositor/extensions/qwltextinputmanager_p.h create mode 100644 src/compositor/global/qwaylandextension.cpp create mode 100644 src/compositor/global/qwaylandextension.h create mode 100644 src/compositor/global/qwaylandextension_p.h delete mode 100644 src/compositor/wayland_wrapper/qwlextendedsurface.cpp delete mode 100644 src/compositor/wayland_wrapper/qwlextendedsurface_p.h delete mode 100644 src/compositor/wayland_wrapper/qwlinputpanel.cpp delete mode 100644 src/compositor/wayland_wrapper/qwlinputpanel_p.h delete mode 100644 src/compositor/wayland_wrapper/qwlinputpanelsurface.cpp delete mode 100644 src/compositor/wayland_wrapper/qwlinputpanelsurface_p.h delete mode 100644 src/compositor/wayland_wrapper/qwlqtkey.cpp delete mode 100644 src/compositor/wayland_wrapper/qwlqtkey_p.h delete mode 100644 src/compositor/wayland_wrapper/qwlqttouch.cpp delete mode 100644 src/compositor/wayland_wrapper/qwlqttouch_p.h delete mode 100644 src/compositor/wayland_wrapper/qwlshellsurface.cpp delete mode 100644 src/compositor/wayland_wrapper/qwlshellsurface_p.h delete mode 100644 src/compositor/wayland_wrapper/qwlsubsurface_p.h delete mode 100644 src/compositor/wayland_wrapper/qwltextinput.cpp delete mode 100644 src/compositor/wayland_wrapper/qwltextinput_p.h delete mode 100644 src/compositor/wayland_wrapper/qwltextinputmanager.cpp delete mode 100644 src/compositor/wayland_wrapper/qwltextinputmanager_p.h delete mode 100644 src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp delete mode 100644 src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration_p.h delete mode 100644 src/compositor/windowmanagerprotocol/windowmanagerprotocol.pri (limited to 'src/compositor') 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 #include @@ -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 +#include #include #include @@ -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: -** 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 - -QT_BEGIN_NAMESPACE - -QWaylandGlobalInterface::QWaylandGlobalInterface() -{ - -} - -QWaylandGlobalInterface::~QWaylandGlobalInterface() -{ - -} - -quint32 QWaylandGlobalInterface::version() const -{ - return interface()->version; -} - -QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandglobalinterface.h b/src/compositor/compositor_api/qwaylandglobalinterface.h deleted file mode 100644 index e17b1671e..000000000 --- a/src/compositor/compositor_api/qwaylandglobalinterface.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Jolla Ltd, author: -** 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$ -** -****************************************************************************/ - -#ifndef QWAYLANDGLOBALINTERFACE_H -#define QWAYLANDGLOBALINTERFACE_H - -#include - -struct wl_interface; -struct wl_client; - -QT_BEGIN_NAMESPACE - -namespace QtWayland { -class Compositor; -} - -class Q_COMPOSITOR_EXPORT QWaylandGlobalInterface -{ -public: - QWaylandGlobalInterface(); - virtual ~QWaylandGlobalInterface(); - - virtual const wl_interface *interface() const = 0; - virtual quint32 version() const; - -protected: - virtual void bind(wl_client *client, quint32 version, quint32 id) = 0; - - friend class QtWayland::Compositor; -}; - -QT_END_NAMESPACE - -#endif 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 + #include #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(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 +#include #include #include @@ -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 #include #include -#include #include "qwaylandquicksurface.h" #include "qwaylandquickcompositor.h" @@ -47,6 +46,9 @@ #include #include +#include +#include + 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(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(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 #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 @@ -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::subSurfaces() const return QLinkedList(); } -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 QWaylandSurface::views() const return d->views; } -QList 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 +#include #include #include @@ -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 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 views() const; - QList 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 views; - QList 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: -** 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 - -#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/qwaylandsurfaceinterface.h b/src/compositor/compositor_api/qwaylandsurfaceinterface.h deleted file mode 100644 index 89d5772b6..000000000 --- a/src/compositor/compositor_api/qwaylandsurfaceinterface.h +++ /dev/null @@ -1,123 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Jolla Ltd, author: -** 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$ -** -****************************************************************************/ - -#ifndef QWAYLANDSURFACEINTERFACE_H -#define QWAYLANDSURFACEINTERFACE_H - -#include - -#include -#include - -QT_BEGIN_NAMESPACE - -class QWaylandSurface; - -class Q_COMPOSITOR_EXPORT QWaylandSurfaceOp -{ -public: - enum Type { - Close, - SetVisibility, - Resize, - Ping, - UserType = 1000 - }; - - QWaylandSurfaceOp(int t); - virtual ~QWaylandSurfaceOp(); - - int type() const; - -private: - class Private; - Private *const d; -}; - -class Q_COMPOSITOR_EXPORT QWaylandSurfaceSetVisibilityOp : public QWaylandSurfaceOp -{ -public: - QWaylandSurfaceSetVisibilityOp(QWindow::Visibility visibility); - QWindow::Visibility visibility() const; - -private: - QWindow::Visibility m_visibility; -}; - -class Q_COMPOSITOR_EXPORT QWaylandSurfaceResizeOp : public QWaylandSurfaceOp -{ -public: - QWaylandSurfaceResizeOp(const QSize &size); - QSize size() const; - -private: - QSize m_size; -}; - -class Q_COMPOSITOR_EXPORT QWaylandSurfacePingOp : public QWaylandSurfaceOp -{ -public: - QWaylandSurfacePingOp(quint32 serial); - quint32 serial() const; - -private: - quint32 m_serial; -}; - -class Q_COMPOSITOR_EXPORT QWaylandSurfaceInterface -{ -public: - QWaylandSurfaceInterface(QWaylandSurface *surf); - virtual ~QWaylandSurfaceInterface(); - - QWaylandSurface *surface() const; - -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; -}; - -QT_END_NAMESPACE - -#endif 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/extensions/qwaylandwindowmanagerextension.cpp b/src/compositor/extensions/qwaylandwindowmanagerextension.cpp new file mode 100644 index 000000000..160fb690f --- /dev/null +++ b/src/compositor/extensions/qwaylandwindowmanagerextension.cpp @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** 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 "qwaylandwindowmanagerextension.h" + +#include +#include + +#include +#include + +#include + +#include + +QT_BEGIN_NAMESPACE + +WindowManagerServerIntegration::WindowManagerServerIntegration(QWaylandCompositor *compositor, QObject *parent) + : QWaylandExtension(compositor) + , QtWaylandServer::qt_windowmanager() + , m_showIsFullScreen(false) + , m_compositor(compositor) +{ +} + +WindowManagerServerIntegration::~WindowManagerServerIntegration() +{ +} + +void WindowManagerServerIntegration::initialize(QtWayland::Display *waylandDisplay) +{ + init(waylandDisplay->handle(), 1); +} + +void WindowManagerServerIntegration::setShowIsFullScreen(bool value) +{ + m_showIsFullScreen = value; + Q_FOREACH (Resource *resource, resourceMap().values()) { + send_hints(resource->handle, static_cast(m_showIsFullScreen)); + } +} + +void WindowManagerServerIntegration::sendQuitMessage(wl_client *client) +{ + Resource *resource = resourceMap().value(client); + + if (resource) + send_quit(resource->handle); +} + +void WindowManagerServerIntegration::windowmanager_bind_resource(Resource *resource) +{ + send_hints(resource->handle, static_cast(m_showIsFullScreen)); +} + +void WindowManagerServerIntegration::windowmanager_destroy_resource(Resource *resource) +{ + m_urls.remove(resource); +} + +void WindowManagerServerIntegration::windowmanager_open_url(Resource *resource, uint32_t remaining, const QString &newUrl) +{ + QString url = m_urls.value(resource, QString()); + + url.append(newUrl); + + if (remaining) + m_urls.insert(resource, url); + else { + m_urls.remove(resource); + m_compositor->openUrl(QWaylandClient::fromWlClient(resource->client()), QUrl(url)); + } +} + +QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandwindowmanagerextension.h b/src/compositor/extensions/qwaylandwindowmanagerextension.h new file mode 100644 index 000000000..5cd64e06d --- /dev/null +++ b/src/compositor/extensions/qwaylandwindowmanagerextension.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** 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$ +** +****************************************************************************/ + +#ifndef WAYLANDWINDOWMANAGERINTEGRATION_H +#define WAYLANDWINDOWMANAGERINTEGRATION_H + +#include +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + class Display; +} + +class QWaylandCompositor; + +class Q_COMPOSITOR_EXPORT WindowManagerServerIntegration : public QWaylandExtension, public QtWaylandServer::qt_windowmanager +{ + Q_OBJECT +public: + explicit WindowManagerServerIntegration(QWaylandCompositor *compositor, QObject *parent = 0); + ~WindowManagerServerIntegration(); + + void initialize(QtWayland::Display *waylandDisplay); + + 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; + void windowmanager_open_url(Resource *resource, uint32_t remaining, const QString &url) Q_DECL_OVERRIDE; + +private: + bool m_showIsFullScreen; + QWaylandCompositor *m_compositor; + QMap m_urls; +}; + +QT_END_NAMESPACE + +#endif // WAYLANDWINDOWMANAGERINTEGRATION_H diff --git a/src/compositor/extensions/qwlextendedsurface.cpp b/src/compositor/extensions/qwlextendedsurface.cpp new file mode 100644 index 000000000..42c100531 --- /dev/null +++ b/src/compositor/extensions/qwlextendedsurface.cpp @@ -0,0 +1,192 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** 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 "qwlextendedsurface_p.h" + +#include "qwlcompositor_p.h" +#include "qwlsurface_p.h" + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +SurfaceExtensionGlobal::SurfaceExtensionGlobal(Compositor *compositor) + : QWaylandExtension(compositor->waylandCompositor()) + , QtWaylandServer::qt_surface_extension(compositor->wl_display(), 1) +{ +} + +void SurfaceExtensionGlobal::surface_extension_get_extended_surface(Resource *resource, + uint32_t id, + struct wl_resource *surface_resource) +{ + Surface *surface = Surface::fromResource(surface_resource); + new ExtendedSurface(resource->client(),id, wl_resource_get_version(resource->handle), surface); +} + +ExtendedSurface *ExtendedSurface::get(QWaylandSurface *surface) +{ + return static_cast(surface->extension(qt_extended_surface::name())); +} + +ExtendedSurface::ExtendedSurface(struct wl_client *client, uint32_t id, int version, Surface *surface) + : QWaylandExtension(surface->waylandSurface()) + , QtWaylandServer::qt_extended_surface(client, id, version) + , m_surface(surface) + , m_windowFlags(0) +{ +} + +ExtendedSurface::~ExtendedSurface() +{ +} + +void ExtendedSurface::sendGenericProperty(const QString &name, const QVariant &variant) +{ + QByteArray byteValue; + QDataStream ds(&byteValue, QIODevice::WriteOnly); + ds << variant; + send_set_generic_property(name, byteValue); + +} + +void ExtendedSurface::sendOnScreenVisibilityChange(bool onScreen) +{ + setVisibility(onScreen ? QWindow::AutomaticVisibility : QWindow::Hidden); +} + +void ExtendedSurface::setVisibility(QWindow::Visibility visibility) +{ + send_onscreen_visibility(visibility); +} + +void ExtendedSurface::setParentSurface(Surface *surface) +{ + m_surface = surface; +} + +void ExtendedSurface::extended_surface_update_generic_property(Resource *resource, + const QString &name, + struct wl_array *value) +{ + Q_UNUSED(resource); + QVariant variantValue; + QByteArray byteValue((const char*)value->data, value->size); + QDataStream ds(&byteValue, QIODevice::ReadOnly); + ds >> variantValue; + setWindowPropertyImpl(name,variantValue); +} + +Qt::ScreenOrientations ExtendedSurface::contentOrientationMask() const +{ + return m_contentOrientationMask; +} + +void ExtendedSurface::extended_surface_set_content_orientation_mask(Resource *resource, int32_t orientation) +{ + Q_UNUSED(resource); + Qt::ScreenOrientations mask = 0; + if (orientation & QT_EXTENDED_SURFACE_ORIENTATION_PORTRAITORIENTATION) + mask |= Qt::PortraitOrientation; + if (orientation & QT_EXTENDED_SURFACE_ORIENTATION_LANDSCAPEORIENTATION) + mask |= Qt::LandscapeOrientation; + if (orientation & QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDPORTRAITORIENTATION) + mask |= Qt::InvertedPortraitOrientation; + if (orientation & QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDLANDSCAPEORIENTATION) + mask |= Qt::InvertedLandscapeOrientation; + if (orientation & QT_EXTENDED_SURFACE_ORIENTATION_PRIMARYORIENTATION) + mask |= Qt::PrimaryOrientation; + + Qt::ScreenOrientations oldMask = m_contentOrientationMask; + m_contentOrientationMask = mask; + + if (mask != oldMask) + emit contentOrientationMaskChanged(); +} + +QVariantMap ExtendedSurface::windowProperties() const +{ + return m_windowProperties; +} + +QVariant ExtendedSurface::windowProperty(const QString &propertyName) const +{ + QVariantMap props = m_windowProperties; + return props.value(propertyName); +} + +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); + emit windowPropertyChanged(name,value); +} + +void ExtendedSurface::extended_surface_set_window_flags(Resource *resource, int32_t flags) +{ + Q_UNUSED(resource); + WindowFlags windowFlags(flags); + if (windowFlags == m_windowFlags) + return; + m_windowFlags = windowFlags; + emit windowFlagsChanged(); +} + +void ExtendedSurface::extended_surface_destroy_resource(Resource *) +{ + delete this; +} + +void ExtendedSurface::extended_surface_raise(Resource *) +{ + if (m_surface) + emit m_surface->waylandSurface()->raiseRequested(); +} + +void ExtendedSurface::extended_surface_lower(Resource *) +{ + if (m_surface) + emit m_surface->waylandSurface()->lowerRequested(); +} + +} + +QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwlextendedsurface_p.h b/src/compositor/extensions/qwlextendedsurface_p.h new file mode 100644 index 000000000..f0953b499 --- /dev/null +++ b/src/compositor/extensions/qwlextendedsurface_p.h @@ -0,0 +1,150 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** 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$ +** +****************************************************************************/ + +#ifndef WLEXTENDEDSURFACE_H +#define WLEXTENDEDSURFACE_H + +#include + +#include +#include +#include +#include + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QWaylandSurface; + +namespace QtWayland { + +class Compositor; + +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, + struct wl_resource *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); + void removeSubSurface(ExtendedSurface *subSurfaces); + ExtendedSurface *parent() const; + void setParent(ExtendedSurface *parent); + QLinkedList subSurfaces() const; + void setParentSurface(Surface *s); + + Qt::ScreenOrientations contentOrientationMask() const; + + WindowFlags windowFlags() const { return m_windowFlags; } + + QVariantMap windowProperties() const; + QVariant windowProperty(const QString &propertyName) const; + void setWindowProperty(const QString &name, const QVariant &value); + + 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; + + WindowFlags m_windowFlags; + + QByteArray m_authenticationToken; + QVariantMap m_windowProperties; + + void extended_surface_update_generic_property(Resource *resource, + const QString &name, + struct wl_array *value) Q_DECL_OVERRIDE; + + void extended_surface_set_content_orientation_mask(Resource *resource, + int32_t orientation) Q_DECL_OVERRIDE; + + void extended_surface_set_window_flags(Resource *resource, + int32_t flags) Q_DECL_OVERRIDE; + + void extended_surface_destroy_resource(Resource *) Q_DECL_OVERRIDE; + void extended_surface_raise(Resource *) Q_DECL_OVERRIDE; + void extended_surface_lower(Resource *) Q_DECL_OVERRIDE; +}; + +} + +QT_END_NAMESPACE + +#endif // WLEXTENDEDSURFACE_H diff --git a/src/compositor/extensions/qwlinputpanel.cpp b/src/compositor/extensions/qwlinputpanel.cpp new file mode 100644 index 000000000..d1c6ab825 --- /dev/null +++ b/src/compositor/extensions/qwlinputpanel.cpp @@ -0,0 +1,136 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB). +** 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 "qwlinputpanel_p.h" + +#include + +#include "qwlcompositor_p.h" +#include "qwlinputdevice_p.h" +#include "qwlinputmethod_p.h" +#include "qwlinputpanelsurface_p.h" +#include "qwlsurface_p.h" +#include "qwltextinput_p.h" + +QT_BEGIN_NAMESPACE + +QWaylandInputPanelPrivate::QWaylandInputPanelPrivate(QtWayland::Compositor *compositor) + : QWaylandExtensionTemplatePrivateImpl(compositor->waylandCompositor()) + , m_compositor(compositor) + , m_focus() + , m_inputPanelVisible(false) + , m_cursorRectangle() +{ + init(compositor->wl_display(), 1); +} + +QWaylandInputPanelPrivate::~QWaylandInputPanelPrivate() +{ +} + +QWaylandInputPanel *QWaylandInputPanelPrivate::waylandInputPanel() const +{ + QWaylandInputPanel *panel = const_cast(q_func()); + return panel; +} + +QtWayland::Surface *QWaylandInputPanelPrivate::focus() const +{ + return m_focus; +} + +void QWaylandInputPanelPrivate::setFocus(QtWayland::Surface *focus) +{ + Q_Q(QWaylandInputPanel); + if (m_focus == focus) + return; + + m_focus = focus; + + Q_EMIT q->focusChanged(); +} + +bool QWaylandInputPanelPrivate::inputPanelVisible() const +{ + return m_inputPanelVisible; +} + +void QWaylandInputPanelPrivate::setInputPanelVisible(bool inputPanelVisible) +{ + Q_Q(QWaylandInputPanel); + if (m_inputPanelVisible == inputPanelVisible) + return; + + m_inputPanelVisible = inputPanelVisible; + + q->visibleChanged(); +} + +QRect QWaylandInputPanelPrivate::cursorRectangle() const +{ + return m_cursorRectangle; +} + +void QWaylandInputPanelPrivate::setCursorRectangle(const QRect &cursorRectangle) +{ + Q_Q(QWaylandInputPanel); + if (m_cursorRectangle == cursorRectangle) + return; + + m_cursorRectangle = cursorRectangle; + + Q_EMIT q->cursorRectangleChanged(); +} + +QWaylandInputPanelPrivate *QWaylandInputPanelPrivate::get(QWaylandExtensionContainer *container) +{ + QWaylandInputPanel *panel = static_cast(container->extension(wl_input_panel::name())); + if (panel) + return panel->d_func(); + return Q_NULLPTR; +} + +QWaylandInputPanelPrivate *QWaylandInputPanelPrivate::get(QWaylandInputPanel *panel) +{ + return panel->d_func(); +} + +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/extensions/qwlinputpanel_p.h b/src/compositor/extensions/qwlinputpanel_p.h new file mode 100644 index 000000000..49a14e792 --- /dev/null +++ b/src/compositor/extensions/qwlinputpanel_p.h @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB). +** 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$ +** +****************************************************************************/ + +#ifndef QTWAYLAND_QWLINPUTPANEL_P_H +#define QTWAYLAND_QWLINPUTPANEL_P_H + +#include +#include + +#include +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { +class Compositor; +class Surface; +class TextInput; +} + + +class Q_COMPOSITOR_EXPORT QWaylandInputPanelPrivate : public QWaylandExtensionTemplatePrivateImpl +{ + Q_DECLARE_PUBLIC(QWaylandInputPanel) +public: + QWaylandInputPanelPrivate(QtWayland::Compositor *compositor); + ~QWaylandInputPanelPrivate(); + + QWaylandInputPanel *waylandInputPanel() const; + + QtWayland::Surface *focus() const; + void setFocus(QtWayland::Surface *focus); + + bool inputPanelVisible() const; + void setInputPanelVisible(bool inputPanelVisible); + + 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: + QtWayland::Compositor *m_compositor; + + QtWayland::Surface *m_focus; + bool m_inputPanelVisible; + QRect m_cursorRectangle; +}; + +QT_END_NAMESPACE + +#endif // QTWAYLAND_QWLINPUTPANEL_P_H diff --git a/src/compositor/extensions/qwlinputpanelsurface.cpp b/src/compositor/extensions/qwlinputpanelsurface.cpp new file mode 100644 index 000000000..a72afa2b3 --- /dev/null +++ b/src/compositor/extensions/qwlinputpanelsurface.cpp @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Pier Luigi Fiorini +** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB). +** 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 "qwlinputpanelsurface_p.h" + +#include "qwloutput_p.h" +#include "qwlsurface_p.h" + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +InputPanelSurface::InputPanelSurface(wl_client *client, int id, Surface *surface) + : QtWaylandServer::wl_input_panel_surface(client, id, 1) + , m_surface(surface) + , m_type(Invalid) + , m_output(0) + , m_position() +{ + surface->setInputPanelSurface(this); +} + +InputPanelSurface::Type InputPanelSurface::type() const +{ + return m_type; +} + +Output *InputPanelSurface::output() const +{ + return m_output; +} + +QtWaylandServer::wl_input_panel_surface::position InputPanelSurface::position() const +{ + return m_position; +} + +void InputPanelSurface::input_panel_surface_set_overlay_panel(Resource *) +{ + m_type = OverlayPanel; +} + +void InputPanelSurface::input_panel_surface_set_toplevel(Resource *, wl_resource *output_resource, uint32_t position) +{ + m_type = Toplevel; + OutputResource *output = static_cast(Output::Resource::fromResource(output_resource)); + m_output = static_cast(output->output_object); + m_position = static_cast(position); +} + +QT_END_NAMESPACE + +} // namespace QtWayland diff --git a/src/compositor/extensions/qwlinputpanelsurface_p.h b/src/compositor/extensions/qwlinputpanelsurface_p.h new file mode 100644 index 000000000..0591832fb --- /dev/null +++ b/src/compositor/extensions/qwlinputpanelsurface_p.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Pier Luigi Fiorini +** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB). +** 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$ +** +****************************************************************************/ + +#ifndef QTWAYLAND_QWLINPUTPANELSURFACE_P_H +#define QTWAYLAND_QWLINPUTPANELSURFACE_P_H + +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +class Output; +class Surface; + +class InputPanelSurface : public QtWaylandServer::wl_input_panel_surface +{ +public: + enum Type { + Invalid, + Toplevel, + OverlayPanel + }; + + InputPanelSurface(struct ::wl_client *client, int id, Surface *surface); + + Type type() const; + + Output *output() const; + wl_input_panel_surface::position position() const; + +protected: + void input_panel_surface_set_overlay_panel(Resource *resource) Q_DECL_OVERRIDE; + void input_panel_surface_set_toplevel(Resource *resource, wl_resource *output_resource, uint32_t position) Q_DECL_OVERRIDE; + +private: + Surface *m_surface; + + Type m_type; + + Output *m_output; + wl_input_panel_surface::position m_position; +}; + +} // namespace QtWayland + +QT_END_NAMESPACE + +#endif // QTWAYLAND_QWLINPUTPANELSURFACE_P_H diff --git a/src/compositor/extensions/qwlqtkey.cpp b/src/compositor/extensions/qwlqtkey.cpp new file mode 100644 index 000000000..b7d567a0a --- /dev/null +++ b/src/compositor/extensions/qwlqtkey.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** 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 "qwlqtkey_p.h" +#include "qwlsurface_p.h" +#include +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +QtKeyExtensionGlobal::QtKeyExtensionGlobal(Compositor *compositor) + : QWaylandExtension(compositor->waylandCompositor()) + , QtWaylandServer::qt_key_extension(compositor->wl_display(), 2) + , m_compositor(compositor) +{ +} + +bool QtKeyExtensionGlobal::postQtKeyEvent(QKeyEvent *event, Surface *surface) +{ + uint32_t time = m_compositor->currentTimeMsecs(); + + Resource *target = surface ? resourceMap().value(surface->resource()->client()) : 0; + + if (target) { + send_qtkey(target->handle, + surface ? surface->resource()->handle : 0, + time, event->type(), event->key(), event->modifiers(), + event->nativeScanCode(), + event->nativeVirtualKey(), + event->nativeModifiers(), + event->text(), + event->isAutoRepeat(), + event->count()); + + return true; + } + + return false; +} + +QtKeyExtensionGlobal *QtKeyExtensionGlobal::get(QWaylandExtensionContainer *container) +{ + return static_cast(container->extension(qt_key_extension::name())); +} + +} + +QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwlqtkey_p.h b/src/compositor/extensions/qwlqtkey_p.h new file mode 100644 index 000000000..542f6eae2 --- /dev/null +++ b/src/compositor/extensions/qwlqtkey_p.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** 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$ +** +****************************************************************************/ + +#ifndef WLQTKEY_H +#define WLQTKEY_H + +#include + +#include "wayland-util.h" + +#include + +QT_BEGIN_NAMESPACE + +class Compositor; +class Surface; +class QKeyEvent; + +namespace QtWayland { + +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; +}; + +} + +QT_END_NAMESPACE + +#endif // WLQTKEY_H diff --git a/src/compositor/extensions/qwlqttouch.cpp b/src/compositor/extensions/qwlqttouch.cpp new file mode 100644 index 000000000..872bbdcb5 --- /dev/null +++ b/src/compositor/extensions/qwlqttouch.cpp @@ -0,0 +1,172 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** 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 "qwlqttouch_p.h" +#include "qwlsurface_p.h" +#include "qwaylandsurfaceview.h" +#include +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +static const int maxRawPos = 24; + +TouchExtensionGlobal::TouchExtensionGlobal(Compositor *compositor) + : QWaylandExtension(compositor->waylandCompositor()) + , QtWaylandServer::qt_touch_extension(compositor->wl_display(), 1) + , m_compositor(compositor) + , m_flags(0) + , m_resources() + , m_posData(maxRawPos * 2) +{ +} + +TouchExtensionGlobal::~TouchExtensionGlobal() +{ +} + +static inline int toFixed(qreal f) +{ + return int(f * 10000); +} + +bool TouchExtensionGlobal::postTouchEvent(QTouchEvent *event, QWaylandSurfaceView *view) +{ + const QList points = event->touchPoints(); + const int pointCount = points.count(); + if (!pointCount) + return false; + + QPointF surfacePos = view->requestedPosition(); + wl_client *surfaceClient = view->surface()->handle()->resource()->client(); + uint32_t time = m_compositor->currentTimeMsecs(); + const int rescount = m_resources.count(); + + for (int res = 0; res < rescount; ++res) { + Resource *target = m_resources.at(res); + if (target->client() != surfaceClient) + continue; + + // We will use no touch_frame type of event, to reduce the number of + // events flowing through the wire. Instead, the number of points sent is + // included in the touch point events. + int sentPointCount = 0; + for (int i = 0; i < pointCount; ++i) { + if (points.at(i).state() != Qt::TouchPointStationary) + ++sentPointCount; + } + + for (int i = 0; i < pointCount; ++i) { + const QTouchEvent::TouchPoint &tp(points.at(i)); + // Stationary points are never sent. They are cached on client side. + if (tp.state() == Qt::TouchPointStationary) + continue; + + uint32_t id = tp.id(); + uint32_t state = (tp.state() & 0xFFFF) | (sentPointCount << 16); + uint32_t flags = (tp.flags() & 0xFFFF) | (int(event->device()->capabilities()) << 16); + + QPointF p = tp.pos() - surfacePos; // surface-relative + int x = toFixed(p.x()); + int y = toFixed(p.y()); + int nx = toFixed(tp.normalizedPos().x()); + int ny = toFixed(tp.normalizedPos().y()); + int w = toFixed(tp.rect().width()); + int h = toFixed(tp.rect().height()); + int vx = toFixed(tp.velocity().x()); + int vy = toFixed(tp.velocity().y()); + uint32_t pressure = uint32_t(tp.pressure() * 255); + + QByteArray rawData; + QVector rawPosList = tp.rawScreenPositions(); + int rawPosCount = rawPosList.count(); + if (rawPosCount) { + rawPosCount = qMin(maxRawPos, rawPosCount); + QVector::iterator iter = m_posData.begin(); + for (int rpi = 0; rpi < rawPosCount; ++rpi) { + const QPointF &rawPos(rawPosList.at(rpi)); + // This will stay in screen coordinates for performance + // reasons, clients using this data will presumably know + // what they are doing. + *iter++ = static_cast(rawPos.x()); + *iter++ = static_cast(rawPos.y()); + } + rawData = QByteArray::fromRawData(reinterpret_cast(m_posData.constData()), sizeof(float) * rawPosCount * 2); + } + + send_touch(target->handle, + time, id, state, + x, y, nx, ny, w, h, + pressure, vx, vy, + flags, rawData); + } + + return true; + } + + return false; +} + +void TouchExtensionGlobal::setBehviorFlags(BehaviorFlags flags) +{ + if (m_flags == flags) + return; + + m_flags = flags; + behaviorFlagsChanged(); +} + +TouchExtensionGlobal *TouchExtensionGlobal::get(QWaylandExtensionContainer *container) +{ + return static_cast(container->extension(qt_touch_extension::name())); +} + +void TouchExtensionGlobal::touch_extension_bind_resource(Resource *resource) +{ + m_resources.append(resource); + send_configure(resource->handle, m_flags); +} + +void TouchExtensionGlobal::touch_extension_destroy_resource(Resource *resource) +{ + m_resources.removeOne(resource); +} + +} + +QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwlqttouch_p.h b/src/compositor/extensions/qwlqttouch_p.h new file mode 100644 index 000000000..2c108f069 --- /dev/null +++ b/src/compositor/extensions/qwlqttouch_p.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** 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$ +** +****************************************************************************/ + +#ifndef WLTOUCH_H +#define WLTOUCH_H + +#include +#include +#include "wayland-util.h" + +QT_BEGIN_NAMESPACE + +class Compositor; +class Surface; +class QTouchEvent; +class QWaylandSurfaceView; + +namespace QtWayland { + +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 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; + void touch_extension_destroy_resource(Resource *resource) Q_DECL_OVERRIDE; + +private: + Compositor *m_compositor; + BehaviorFlags m_flags; + QList m_resources; + QVector m_posData; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(TouchExtensionGlobal::BehaviorFlags) + +} + +QT_END_NAMESPACE + +#endif // WLTOUCH_H diff --git a/src/compositor/extensions/qwlshellsurface.cpp b/src/compositor/extensions/qwlshellsurface.cpp new file mode 100644 index 000000000..de53f60eb --- /dev/null +++ b/src/compositor/extensions/qwlshellsurface.cpp @@ -0,0 +1,567 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Pier Luigi Fiorini +** Copyright (C) 2015 The Qt Company Ltd. +** 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 "qwlshellsurface_p.h" + +#include "qwlcompositor_p.h" +#include "qwlsurface_p.h" +#include "qwloutput_p.h" +#include "qwlinputdevice_p.h" +#include "qwlsubsurface_p.h" +#include "qwlpointer_p.h" +#include "qwlextendedsurface_p.h" + +#include "qwaylandoutput.h" +#include "qwaylandsurfaceview.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +Shell::Shell(QWaylandCompositor *compositor) + : QWaylandExtension(compositor) + , wl_shell(compositor->waylandDisplay(), 1) +{ +} + +const wl_interface *Shell::interface() const +{ + return &wl_shell_interface; +} + +ShellSurfacePopupGrabber *Shell::getPopupGrabber(InputDevice *input) +{ + if (!m_popupGrabber.contains(input)) + m_popupGrabber.insert(input, new ShellSurfacePopupGrabber(input)); + + return m_popupGrabber.value(input); +} + +void Shell::shell_get_shell_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface_res) +{ + Surface *surface = Surface::fromResource(surface_res); + new ShellSurface(this, resource->client(), id, surface); +} + + +ShellSurface *ShellSurface::get(QWaylandSurface *surface) +{ + return static_cast(surface->extension(wl_shell_surface::name())); +} + +ShellSurface::ShellSurface(Shell *shell, wl_client *client, uint32_t id, Surface *surface) + : QWaylandExtension(surface->waylandSurface()) + , wl_shell_surface(client, id, 1) + , m_shell(shell) + , m_surface(surface) + , m_resizeGrabber(0) + , 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); +} + +ShellSurface::~ShellSurface() +{ + delete m_view; +} + +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()) + return; + if (!m_resizeGrabber || !(m_resizeGrabber->resize_edges & WL_SHELL_SURFACE_RESIZE_TOP_LEFT)) + return; + + int bottomLeftX = m_resizeGrabber->point.x() + m_resizeGrabber->width; + int bottomLeftY = m_resizeGrabber->point.y() + m_resizeGrabber->height; + qreal x = m_view->requestedPosition().x(); + qreal y = m_view->requestedPosition().y(); + if (m_resizeGrabber->resize_edges & WL_SHELL_SURFACE_RESIZE_TOP) + y = bottomLeftY - m_view->surface()->size().height(); + if (m_resizeGrabber->resize_edges & WL_SHELL_SURFACE_RESIZE_LEFT) + x = bottomLeftX - m_view->surface()->size().width(); + QPointF newPos(x,y); + m_view->setRequestedPosition(newPos); +} + +void ShellSurface::resetResizeGrabber() +{ + m_resizeGrabber = 0; +} + +void ShellSurface::resetMoveGrabber() +{ + m_moveGrabber = 0; +} + +void ShellSurface::setOffset(const QPointF &offset) +{ + m_surface->setTransientOffset(offset.x(), offset.y()); +} + +void ShellSurface::configure(bool hasBuffer) +{ + m_surface->setMapped(hasBuffer); +} + +void ShellSurface::mapped() +{ + if (m_surfaceType == Popup) { + if (m_surface->mapped() && m_popupGrabber->grabSerial() == m_popupSerial) { + m_popupGrabber->addPopup(this); + } else { + send_popup_done(); + m_popupGrabber->setClient(0); + } + } +} + +void ShellSurface::adjustOffset(const QPoint &p) +{ + QPointF offset(p); + QPointF pos = m_view->requestedPosition(); + m_view->setRequestedPosition(pos + offset); +} + +void ShellSurface::requestSize(const QSize &size) +{ + send_configure(WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT, size.width(), size.height()); +} + +void ShellSurface::shell_surface_destroy_resource(Resource *) +{ + if (m_popupGrabber) + m_popupGrabber->removePopup(this); + + delete this; +} + +void ShellSurface::shell_surface_move(Resource *resource, + struct wl_resource *input_device_super, + uint32_t time) +{ + Q_UNUSED(resource); + Q_UNUSED(time); + + if (m_resizeGrabber || m_moveGrabber) { + qDebug() << "invalid state"; + return; + } + + InputDevice *input_device = InputDevice::fromSeatResource(input_device_super); + Pointer *pointer = input_device->pointerDevice(); + + m_moveGrabber = new ShellSurfaceMoveGrabber(this, pointer->position() - m_view->requestedPosition()); + + pointer->startGrab(m_moveGrabber); +} + +void ShellSurface::shell_surface_resize(Resource *resource, + struct wl_resource *input_device_super, + uint32_t time, + uint32_t edges) +{ + Q_UNUSED(resource); + Q_UNUSED(time); + + if (m_moveGrabber || m_resizeGrabber) { + qDebug() << "invalid state2"; + return; + } + + m_resizeGrabber = new ShellSurfaceResizeGrabber(this); + + InputDevice *input_device = InputDevice::fromSeatResource(input_device_super); + Pointer *pointer = input_device->pointerDevice(); + + m_resizeGrabber->point = pointer->position(); + m_resizeGrabber->resize_edges = static_cast(edges); + m_resizeGrabber->width = m_view->surface()->size().width(); + m_resizeGrabber->height = m_view->surface()->size().height(); + + pointer->startGrab(m_resizeGrabber); +} + +void ShellSurface::shell_surface_set_toplevel(Resource *resource) +{ + Q_UNUSED(resource); + m_surface->setTransientParent(0); + m_surface->setTransientOffset(0, 0); + + setSurfaceType(QWaylandSurface::Toplevel); + + m_surface->setVisibility(QWindow::Windowed); +} + +void ShellSurface::shell_surface_set_transient(Resource *resource, + struct wl_resource *parent_surface_resource, + int x, + int y, + uint32_t flags) +{ + + Q_UNUSED(resource); + Q_UNUSED(flags); + Surface *parent_surface = Surface::fromResource(parent_surface_resource); + m_surface->setTransientParent(parent_surface); + m_surface->setTransientOffset(x, y); + if (flags & WL_SHELL_SURFACE_TRANSIENT_INACTIVE) + m_surface->setTransientInactive(true); + + setSurfaceType(QWaylandSurface::Transient); + + m_surface->setVisibility(QWindow::AutomaticVisibility); +} + +void ShellSurface::shell_surface_set_fullscreen(Resource *resource, + uint32_t method, + uint32_t framerate, + struct wl_resource *output_resource) +{ + Q_UNUSED(resource); + Q_UNUSED(method); + Q_UNUSED(framerate); + QWaylandOutput *output = output_resource + ? QWaylandOutput::fromResource(output_resource) + : Q_NULLPTR; + if (!output) { + // Look for an output that can contain this surface + Q_FOREACH (QWaylandOutput *curOutput, m_surface->compositor()->primaryOutputSpace()->outputs()) { + if (curOutput->geometry().size().width() >= m_surface->size().width() && + curOutput->geometry().size().height() >= m_surface->size().height()) { + output = curOutput; + break; + } + } + } + if (!output) { + qWarning() << "Unable to resize surface full screen, cannot determine output"; + return; + } + QSize outputSize = output->geometry().size(); + + m_view->setRequestedPosition(output->geometry().topLeft()); + send_configure(resize_bottom_right, outputSize.width(), outputSize.height()); + + m_surface->setVisibility(QWindow::FullScreen); +} + +void ShellSurface::shell_surface_set_popup(Resource *resource, wl_resource *input_device, uint32_t serial, wl_resource *parent, int32_t x, int32_t y, uint32_t flags) +{ + Q_UNUSED(resource); + Q_UNUSED(input_device); + Q_UNUSED(flags); + + InputDevice *input = InputDevice::fromSeatResource(input_device); + m_popupGrabber = m_shell->getPopupGrabber(input); + + m_popupSerial = serial; + m_surface->setTransientParent(Surface::fromResource(parent)); + m_surface->setTransientOffset(x, y); + + setSurfaceType(QWaylandSurface::Popup); + + m_surface->setVisibility(QWindow::AutomaticVisibility); +} + +void ShellSurface::shell_surface_set_maximized(Resource *resource, + struct wl_resource *output_resource) +{ + Q_UNUSED(resource); + + QWaylandOutput *output = output_resource + ? QWaylandOutput::fromResource(output_resource) + : Q_NULLPTR; + if (!output) { + // Look for an output that can contain this surface + Q_FOREACH (QWaylandOutput *curOutput, m_surface->compositor()->primaryOutputSpace()->outputs()) { + if (curOutput->geometry().size().width() >= m_surface->size().width() && + curOutput->geometry().size().height() >= m_surface->size().height()) { + output = curOutput; + break; + } + } + } + if (!output) { + qWarning() << "Unable to maximize surface, cannot determine output"; + return; + } + QSize outputSize = output->availableGeometry().size(); + + m_view->setRequestedPosition(output->availableGeometry().topLeft()); + send_configure(resize_bottom_right, outputSize.width(), outputSize.height()); + + m_surface->setVisibility(QWindow::Maximized); +} + +void ShellSurface::shell_surface_pong(Resource *resource, + uint32_t serial) +{ + Q_UNUSED(resource); + if (m_pings.remove(serial)) + emit m_surface->waylandSurface()->pong(); + else + qWarning("Received an unexpected pong!"); +} + +void ShellSurface::shell_surface_set_title(Resource *resource, + const QString &title) +{ + Q_UNUSED(resource); + m_surface->setTitle(title); +} + +void ShellSurface::shell_surface_set_class(Resource *resource, + const QString &className) +{ + Q_UNUSED(resource); + m_surface->setClassName(className); +} + +ShellSurfaceGrabber::ShellSurfaceGrabber(ShellSurface *shellSurface) + : PointerGrabber() + , shell_surface(shellSurface) +{ +} + +ShellSurfaceGrabber::~ShellSurfaceGrabber() +{ +} + +ShellSurfaceResizeGrabber::ShellSurfaceResizeGrabber(ShellSurface *shellSurface) + : ShellSurfaceGrabber(shellSurface) +{ +} + +void ShellSurfaceResizeGrabber::focus() +{ +} + +void ShellSurfaceResizeGrabber::motion(uint32_t time) +{ + Q_UNUSED(time); + + int width_delta = point.x() - m_pointer->position().x(); + int height_delta = point.y() - m_pointer->position().y(); + + int new_height = height; + if (resize_edges & WL_SHELL_SURFACE_RESIZE_TOP) + new_height = qMax(new_height + height_delta, 1); + else if (resize_edges & WL_SHELL_SURFACE_RESIZE_BOTTOM) + new_height = qMax(new_height - height_delta, 1); + + int new_width = width; + if (resize_edges & WL_SHELL_SURFACE_RESIZE_LEFT) + new_width = qMax(new_width + width_delta, 1); + else if (resize_edges & WL_SHELL_SURFACE_RESIZE_RIGHT) + new_width = qMax(new_width - width_delta, 1); + + shell_surface->sendConfigure(resize_edges, new_width, new_height); +} + +void ShellSurfaceResizeGrabber::button(uint32_t time, Qt::MouseButton button, uint32_t state) +{ + Q_UNUSED(time) + + if (button == Qt::LeftButton && !state) { + m_pointer->endGrab(); + shell_surface->resetResizeGrabber(); + delete this; + } +} + +ShellSurfaceMoveGrabber::ShellSurfaceMoveGrabber(ShellSurface *shellSurface, const QPointF &offset) + : ShellSurfaceGrabber(shellSurface) + , m_offset(offset) +{ +} + +void ShellSurfaceMoveGrabber::focus() +{ +} + +void ShellSurfaceMoveGrabber::motion(uint32_t time) +{ + Q_UNUSED(time); + + QPointF pos(m_pointer->position() - m_offset); + shell_surface->m_view->setRequestedPosition(pos); + if (shell_surface->m_surface->transientParent()) { + QWaylandSurfaceView *view = shell_surface->m_surface->transientParent()->waylandSurface()->views().first(); + if (view) + shell_surface->setOffset(pos - view->requestedPosition()); + } + +} + +void ShellSurfaceMoveGrabber::button(uint32_t time, Qt::MouseButton button, uint32_t state) +{ + Q_UNUSED(time) + + if (button == Qt::LeftButton && !state) { + m_pointer->setFocus(0, QPointF()); + m_pointer->endGrab(); + shell_surface->resetMoveGrabber(); + delete this; + } +} + +ShellSurfacePopupGrabber::ShellSurfacePopupGrabber(InputDevice *inputDevice) + : PointerGrabber() + , m_inputDevice(inputDevice) + , m_client(0) + , m_surfaces() + , m_initialUp(false) +{ +} + +uint32_t ShellSurfacePopupGrabber::grabSerial() const +{ + return m_inputDevice->pointerDevice()->grabSerial(); +} + +struct ::wl_client *ShellSurfacePopupGrabber::client() const +{ + return m_client; +} + +void ShellSurfacePopupGrabber::setClient(struct ::wl_client *client) +{ + m_client = client; +} + +void ShellSurfacePopupGrabber::addPopup(ShellSurface *surface) +{ + if (m_surfaces.isEmpty()) { + m_client = surface->resource()->client(); + + if (m_inputDevice->pointerDevice()->buttonPressed()) + m_initialUp = false; + + m_surfaces.append(surface); + m_inputDevice->pointerDevice()->startGrab(this); + } else { + m_surfaces.append(surface); + } +} + +void ShellSurfacePopupGrabber::removePopup(ShellSurface *surface) +{ + if (m_surfaces.isEmpty()) + return; + + m_surfaces.removeOne(surface); + if (m_surfaces.isEmpty()) + m_inputDevice->pointerDevice()->endGrab(); +} + +void ShellSurfacePopupGrabber::focus() +{ + if (m_pointer->current() && m_pointer->current()->surface()->handle()->resource()->client() == m_client) + m_pointer->setFocus(m_pointer->current(), m_pointer->currentPosition()); + else + m_pointer->setFocus(0, QPointF()); +} + +void ShellSurfacePopupGrabber::motion(uint32_t time) +{ + m_pointer->motion(time); +} + +void ShellSurfacePopupGrabber::button(uint32_t time, Qt::MouseButton button, uint32_t state) +{ + if (m_pointer->focusResource()) { + m_pointer->sendButton(time, button, state); + } else if (state == QtWaylandServer::wl_pointer::button_state_pressed && + (m_initialUp || time - m_pointer->grabTime() > 500) && + m_pointer->currentGrab() == this) { + m_pointer->endGrab(); + Q_FOREACH (ShellSurface *surface, m_surfaces) { + surface->send_popup_done(); + } + m_surfaces.clear(); + } + + if (state == QtWaylandServer::wl_pointer::button_state_released) + m_initialUp = true; +} + + +} + +QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwlshellsurface_p.h b/src/compositor/extensions/qwlshellsurface_p.h new file mode 100644 index 000000000..804ee2cff --- /dev/null +++ b/src/compositor/extensions/qwlshellsurface_p.h @@ -0,0 +1,244 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** 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$ +** +****************************************************************************/ + +#ifndef WLSHELLSURFACE_H +#define WLSHELLSURFACE_H + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +class QWaylandSurfaceView; + +namespace QtWayland { + +class Compositor; +class Surface; +class ShellSurface; +class ShellSurfaceResizeGrabber; +class ShellSurfaceMoveGrabber; +class ShellSurfacePopupGrabber; + +class Shell : public QWaylandExtension, public QtWaylandServer::wl_shell +{ + Q_OBJECT +public: + Shell(QWaylandCompositor *compositor); + + const wl_interface *interface() const Q_DECL_OVERRIDE; + + ShellSurfacePopupGrabber* getPopupGrabber(InputDevice *input); + +private: + void shell_get_shell_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface) Q_DECL_OVERRIDE; + + QHash m_popupGrabber; +}; + +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); + + void adjustPosInResize(); + void resetResizeGrabber(); + void resetMoveGrabber(); + + void setOffset(const QPointF &offset); + + void configure(bool hasBuffer); + + void requestSize(const QSize &size); + + Q_INVOKABLE void ping(); + void ping(uint32_t serial); + + QWaylandSurfaceView *view() { return m_view; } + + 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(); + void adjustOffset(const QPoint &p); + +private: + Shell *m_shell; + Surface *m_surface; + QWaylandSurfaceView *m_view; + + ShellSurfaceResizeGrabber *m_resizeGrabber; + ShellSurfaceMoveGrabber *m_moveGrabber; + ShellSurfacePopupGrabber *m_popupGrabber; + + uint32_t m_popupSerial; + + QSet m_pings; + + SurfaceType m_surfaceType; + + void shell_surface_destroy_resource(Resource *resource) Q_DECL_OVERRIDE; + + void shell_surface_move(Resource *resource, + struct wl_resource *input_device_super, + uint32_t time) Q_DECL_OVERRIDE; + void shell_surface_resize(Resource *resource, + struct wl_resource *input_device, + uint32_t time, + uint32_t edges) Q_DECL_OVERRIDE; + void shell_surface_set_toplevel(Resource *resource) Q_DECL_OVERRIDE; + void shell_surface_set_transient(Resource *resource, + struct wl_resource *parent_surface_resource, + int x, + int y, + uint32_t flags) Q_DECL_OVERRIDE; + void shell_surface_set_fullscreen(Resource *resource, + uint32_t method, + uint32_t framerate, + struct wl_resource *output_resource) Q_DECL_OVERRIDE; + void shell_surface_set_popup(Resource *resource, + struct wl_resource *input_device, + uint32_t time, + struct wl_resource *parent, + int32_t x, + int32_t y, + uint32_t flags) Q_DECL_OVERRIDE; + void shell_surface_set_maximized(Resource *resource, + struct wl_resource *output_resource) Q_DECL_OVERRIDE; + void shell_surface_pong(Resource *resource, + uint32_t serial) Q_DECL_OVERRIDE; + void shell_surface_set_title(Resource *resource, + const QString &title) Q_DECL_OVERRIDE; + void shell_surface_set_class(Resource *resource, + const QString &class_) Q_DECL_OVERRIDE; + + friend class ShellSurfaceMoveGrabber; +}; + +class ShellSurfaceGrabber : public PointerGrabber +{ +public: + ShellSurfaceGrabber(ShellSurface *shellSurface); + ~ShellSurfaceGrabber(); + + ShellSurface *shell_surface; +}; + +class ShellSurfaceResizeGrabber : public ShellSurfaceGrabber +{ +public: + ShellSurfaceResizeGrabber(ShellSurface *shellSurface); + + QPointF point; + enum wl_shell_surface_resize resize_edges; + int32_t width; + int32_t height; + + void focus() Q_DECL_OVERRIDE; + void motion(uint32_t time) Q_DECL_OVERRIDE; + void button(uint32_t time, Qt::MouseButton button, uint32_t state) Q_DECL_OVERRIDE; +}; + +class ShellSurfaceMoveGrabber : public ShellSurfaceGrabber +{ +public: + ShellSurfaceMoveGrabber(ShellSurface *shellSurface, const QPointF &offset); + + void focus() Q_DECL_OVERRIDE; + void motion(uint32_t time) Q_DECL_OVERRIDE; + void button(uint32_t time, Qt::MouseButton button, uint32_t state) Q_DECL_OVERRIDE; + +private: + QPointF m_offset; +}; + +class ShellSurfacePopupGrabber : public PointerGrabber +{ +public: + ShellSurfacePopupGrabber(InputDevice *inputDevice); + + uint32_t grabSerial() const; + + struct ::wl_client *client() const; + void setClient(struct ::wl_client *client); + + void addPopup(ShellSurface *surface); + void removePopup(ShellSurface *surface); + + void focus() Q_DECL_OVERRIDE; + void motion(uint32_t time) Q_DECL_OVERRIDE; + void button(uint32_t time, Qt::MouseButton button, uint32_t state) Q_DECL_OVERRIDE; + +private: + InputDevice *m_inputDevice; + struct ::wl_client *m_client; + QList m_surfaces; + bool m_initialUp; +}; + +} + +QT_END_NAMESPACE + +#endif // WLSHELLSURFACE_H 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::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 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(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/extensions/qwlsubsurface_p.h b/src/compositor/extensions/qwlsubsurface_p.h new file mode 100644 index 000000000..66eff6dc9 --- /dev/null +++ b/src/compositor/extensions/qwlsubsurface_p.h @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** 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$ +** +****************************************************************************/ + +#ifndef WLSUBSURFACE_H +#define WLSUBSURFACE_H + +#include + +#include + +#include + +QT_BEGIN_NAMESPACE + +class Compositor; +class QWaylandSurface; + +namespace QtWayland { + +class SubSurfaceExtensionGlobal : public QWaylandExtension, public QtWaylandServer::qt_sub_surface_extension +{ + Q_OBJECT +public: + SubSurfaceExtensionGlobal(QWaylandCompositor *compositor); + + const struct wl_interface *interface() const { return qt_sub_surface_extension::interface(); } +private: + QWaylandCompositor *m_compositor; + + void sub_surface_extension_get_sub_surface_aware_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface) Q_DECL_OVERRIDE; +}; + +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, QWaylandSurface *surface); + ~SubSurface(); + + void setSubSurface(SubSurface *subSurface, int x, int y); + void removeSubSurface(SubSurface *subSurfaces); + + SubSurface *parent() const; + void setParent(SubSurface *parent); + + QLinkedList subSurfaces() 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; + QWaylandSurface *m_surface; + + SubSurface *m_parent; + QLinkedList m_sub_surfaces; + +}; + +inline QWaylandSurface *SubSurface::surface() const +{ + return m_surface; +} + +} + +QT_END_NAMESPACE + +#endif // WLSUBSURFACE_H diff --git a/src/compositor/extensions/qwltextinput.cpp b/src/compositor/extensions/qwltextinput.cpp new file mode 100644 index 000000000..af1b73cb6 --- /dev/null +++ b/src/compositor/extensions/qwltextinput.cpp @@ -0,0 +1,211 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB). +** 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 "qwltextinput_p.h" + +#include "qwlcompositor_p.h" +#include "qwlinputdevice_p.h" +#include "qwlinputmethod_p.h" +#include "qwlinputmethodcontext_p.h" +#include "qwlinputpanel_p.h" +#include "qwlsurface_p.h" + +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +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() + , m_cursorRectangle() +{ +} + +Surface *TextInput::focus() const +{ + return m_focus; +} + +bool TextInput::inputPanelVisible() const +{ + return m_inputPanelVisible; +} + +QRect TextInput::cursorRectangle() const +{ + return m_cursorRectangle; +} + +void TextInput::deactivate(InputMethod *inputMethod) +{ + if (m_activeInputMethods.removeOne(inputMethod)) + inputMethod->deactivate(); + + if (m_activeInputMethods.isEmpty()) + send_leave(); +} + +void TextInput::text_input_destroy_resource(Resource *) +{ + Q_FOREACH (InputMethod *inputMethod, m_activeInputMethods) { + deactivate(inputMethod); + } + + delete this; +} + +void TextInput::text_input_activate(Resource *, wl_resource *seat, wl_resource *surface) +{ + Surface *oldSurface = m_focus; + m_focus = Surface::fromResource(surface); + + if (oldSurface != m_focus) + send_leave(); + + bool wasEmpty = m_activeInputMethods.isEmpty(); + + InputMethod *inputMethod = InputDevice::fromSeatResource(seat)->inputMethod(); + + if (!m_activeInputMethods.contains(inputMethod)) { + m_activeInputMethods.append(inputMethod); + inputMethod->activate(this); + } + + if (wasEmpty || oldSurface != m_focus) + send_enter(surface); +} + +void TextInput::text_input_deactivate(Resource *, wl_resource *seat) +{ + InputMethod *inputMethod = InputDevice::fromSeatResource(seat)->inputMethod(); + + deactivate(inputMethod); +} + +static bool isInputMethodBound(InputMethod *inputMethod) +{ + return inputMethod->isBound(); +} + +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()){ + 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()) { + 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()) { + QWaylandInputPanelPrivate *panel = QWaylandInputPanelPrivate::get(m_compositor->waylandCompositor()); + if (panel) + panel->setCursorRectangle(m_cursorRectangle); + } +} + +void TextInput::text_input_reset(Resource *) +{ + Q_FOREACH (InputMethod *inputMethod, m_activeInputMethods) { + if (inputMethod->context()) + inputMethod->context()->send_reset(); + } +} + +void TextInput::text_input_commit_state(Resource *, uint32_t serial) +{ + Q_FOREACH (InputMethod *inputMethod, m_activeInputMethods) { + if (inputMethod->context()) + inputMethod->context()->send_commit_state(serial); + } +} + +void TextInput::text_input_set_content_type(Resource *, uint32_t hint, uint32_t purpose) +{ + Q_FOREACH (InputMethod *inputMethod, m_activeInputMethods) { + if (inputMethod->context()) + inputMethod->context()->send_content_type(hint, purpose); + } +} + +void TextInput::text_input_set_preferred_language(Resource *, const QString &language) +{ + Q_FOREACH (InputMethod *inputMethod, m_activeInputMethods) { + if (inputMethod->context()) + inputMethod->context()->send_preferred_language(language); + } +} + +void TextInput::text_input_set_surrounding_text(Resource *, const QString &text, uint32_t cursor, uint32_t anchor) +{ + Q_FOREACH (InputMethod *inputMethod, m_activeInputMethods) { + if (inputMethod->context()) + inputMethod->context()->send_surrounding_text(text, cursor, anchor); + } +} + +void TextInput::text_input_invoke_action(Resource *, uint32_t button, uint32_t index) +{ + Q_FOREACH (InputMethod *inputMethod, m_activeInputMethods) { + if (inputMethod->context()) + inputMethod->context()->send_invoke_action(button, index); + } +} + +} // namespace QtWayland + +QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwltextinput_p.h b/src/compositor/extensions/qwltextinput_p.h new file mode 100644 index 000000000..60485d32d --- /dev/null +++ b/src/compositor/extensions/qwltextinput_p.h @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB). +** 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$ +** +****************************************************************************/ + +#ifndef QTWAYLAND_QWLTEXTINPUT_P_H +#define QTWAYLAND_QWLTEXTINPUT_P_H + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +class Compositor; +class InputMethod; +class Surface; + +class TextInput : public QWaylandExtension, public QtWaylandServer::wl_text_input +{ +public: + explicit TextInput(QWaylandExtensionContainer *container, Compositor *compositor, struct ::wl_client *client, int id); + + Surface *focus() const; + + bool inputPanelVisible() const; + QRect cursorRectangle() const; + + 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; + + void text_input_activate(Resource *resource, wl_resource *seat, wl_resource *surface) Q_DECL_OVERRIDE; + void text_input_deactivate(Resource *resource, wl_resource *seat) Q_DECL_OVERRIDE; + void text_input_show_input_panel(Resource *resource) Q_DECL_OVERRIDE; + void text_input_hide_input_panel(Resource *resource) Q_DECL_OVERRIDE; + void text_input_reset(Resource *resource) Q_DECL_OVERRIDE; + void text_input_commit_state(Resource *resource, uint32_t serial) Q_DECL_OVERRIDE; + void text_input_set_content_type(Resource *resource, uint32_t hint, uint32_t purpose) Q_DECL_OVERRIDE; + void text_input_set_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) Q_DECL_OVERRIDE; + void text_input_set_preferred_language(Resource *resource, const QString &language) Q_DECL_OVERRIDE; + void text_input_set_surrounding_text(Resource *resource, const QString &text, uint32_t cursor, uint32_t anchor) Q_DECL_OVERRIDE; + void text_input_invoke_action(Resource *resource, uint32_t button, uint32_t index) Q_DECL_OVERRIDE; + +private: + Compositor *m_compositor; + QList m_activeInputMethods; + Surface *m_focus; + + bool m_inputPanelVisible; + QRect m_cursorRectangle; + +}; + +} // namespace QtWayland + +QT_END_NAMESPACE + +#endif // QTWAYLAND_QWLTEXTINPUT_P_H diff --git a/src/compositor/extensions/qwltextinputmanager.cpp b/src/compositor/extensions/qwltextinputmanager.cpp new file mode 100644 index 000000000..738680151 --- /dev/null +++ b/src/compositor/extensions/qwltextinputmanager.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB). +** 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 "qwltextinputmanager_p.h" + +#include "qwlcompositor_p.h" +#include "qwltextinput_p.h" + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +TextInputManager::TextInputManager(Compositor *compositor) + : QWaylandExtension(compositor->waylandCompositor()) + , QtWaylandServer::wl_text_input_manager(compositor->wl_display(), 1) + , m_compositor(compositor) +{ +} + +TextInputManager::~TextInputManager() +{ +} + +void TextInputManager::text_input_manager_create_text_input(Resource *resource, uint32_t id) +{ + new TextInput(this, m_compositor, resource->client(), id); +} + +} // namespace QtWayland + +QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwltextinputmanager_p.h b/src/compositor/extensions/qwltextinputmanager_p.h new file mode 100644 index 000000000..b9f3a0ae5 --- /dev/null +++ b/src/compositor/extensions/qwltextinputmanager_p.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB). +** 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$ +** +****************************************************************************/ + +#ifndef QTWAYLAND_QWLTEXTINPUTMANAGER_P_H +#define QTWAYLAND_QWLTEXTINPUTMANAGER_P_H + +#include +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +class Compositor; + +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; + +private: + Compositor *m_compositor; +}; + +} // namespace QtWayland + +QT_END_NAMESPACE + +#endif // QTWAYLAND_QWLTEXTINPUTMANAGER_P_H 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 + +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 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/global/qwaylandextension.h b/src/compositor/global/qwaylandextension.h new file mode 100644 index 000000000..c051e366f --- /dev/null +++ b/src/compositor/global/qwaylandextension.h @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#ifndef QWAYLANDEXTENSION_H +#define QWAYLANDEXTENSION_H + +#include +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +class QWaylandCompositor; +class QWaylandExtensionContainer; +class QWaylandExtensionPrivate; + +class Q_COMPOSITOR_EXPORT QWaylandExtension : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QWaylandExtension) +public: + QWaylandExtension(QWaylandExtensionContainer *container, QObject *parent = 0); + virtual ~QWaylandExtension(); + + virtual const struct wl_interface *interface() const = 0; + + const QByteArray name() const { return interface()->name; } + quint32 version() const { return interface()->version; } + +protected: + QWaylandExtension(QWaylandExtensionPrivate &dd, QObject *parent = 0); +}; + +class Q_COMPOSITOR_EXPORT QWaylandExtensionContainer +{ +public: + virtual ~QWaylandExtensionContainer(); + + QWaylandExtension *extension(const QByteArray &name); + QWaylandExtension *extension(const wl_interface *interface); + QVector extensions() const; + void addExtension(QWaylandExtension *extension); + void removeExtension(QWaylandExtension *extension); + +protected: + QVector extension_vector; +}; + +class QWaylandExtensionTemplatePrivate; +class Q_COMPOSITOR_EXPORT QWaylandExtensionTemplate : public QWaylandExtension +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QWaylandExtensionTemplate) +public: + QWaylandExtensionTemplate(QWaylandExtensionContainer *container, QObject *parent = 0); + + const struct wl_interface *interface() const Q_DECL_OVERRIDE; + +protected: + QWaylandExtensionTemplate(QWaylandExtensionTemplatePrivate &dd, QObject *parent = 0); +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/compositor/global/qwaylandextension_p.h b/src/compositor/global/qwaylandextension_p.h new file mode 100644 index 000000000..b86943650 --- /dev/null +++ b/src/compositor/global/qwaylandextension_p.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#ifndef QWAYLANDEXTENSION_P_H +#define QWAYLANDEXTENSION_P_H + +#include "qwaylandextension.h" +#include + +class Q_COMPOSITOR_EXPORT QWaylandExtensionPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QWaylandExtension) + +public: + QWaylandExtensionPrivate(QWaylandExtensionContainer *container) + : QObjectPrivate() + , extension_container(container) + { + } + + QWaylandExtensionContainer *extension_container; +}; + +class Q_COMPOSITOR_EXPORT QWaylandExtensionTemplatePrivate : public QWaylandExtensionPrivate +{ + Q_DECLARE_PUBLIC(QWaylandExtension) + +public: + QWaylandExtensionTemplatePrivate(QWaylandExtensionContainer *container) + : QWaylandExtensionPrivate(container) + {} + + virtual const struct wl_interface *interface() const = 0; +}; + +template +class Q_COMPOSITOR_EXPORT QWaylandExtensionTemplatePrivateImpl : public QWaylandExtensionTemplatePrivate, public T +{ +public: + QWaylandExtensionTemplatePrivateImpl(QWaylandExtensionContainer *container) + : QWaylandExtensionTemplatePrivate(container) + { } + + const struct wl_interface *interface() const Q_DECL_OVERRIDE { return T::interface(); } +}; + +#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 #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(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 Compositor::clients() const void Compositor::setClientFullScreenHint(bool value) { - if (m_windowManagerIntegration) - m_windowManagerIntegration->setShowIsFullScreen(value); + WindowManagerServerIntegration *wmExtension = static_cast(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(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 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 m_server_buffer_integration; #endif - //extensions - WindowManagerServerIntegration *m_windowManagerIntegration; - - SurfaceExtensionGlobal *m_surfaceExtension; - SubSurfaceExtensionGlobal *m_subSurfaceExtension; - TouchExtensionGlobal *m_touchExtension; - QtKeyExtensionGlobal *m_qtkeyExtension; - QScopedPointer m_textInputManager; - QScopedPointer m_inputPanel; - QList m_globals; QScopedPointer m_eventHandler; static void bind_func(struct wl_client *client, void *data, diff --git a/src/compositor/wayland_wrapper/qwlextendedsurface.cpp b/src/compositor/wayland_wrapper/qwlextendedsurface.cpp deleted file mode 100644 index 8b06cb182..000000000 --- a/src/compositor/wayland_wrapper/qwlextendedsurface.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** 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 "qwlextendedsurface_p.h" - -#include "qwlcompositor_p.h" -#include "qwlsurface_p.h" - -QT_BEGIN_NAMESPACE - -namespace QtWayland { - -SurfaceExtensionGlobal::SurfaceExtensionGlobal(Compositor *compositor) - : QtWaylandServer::qt_surface_extension(compositor->wl_display(), 1) -{ -} - -void SurfaceExtensionGlobal::surface_extension_get_extended_surface(Resource *resource, - uint32_t id, - struct wl_resource *surface_resource) -{ - Surface *surface = Surface::fromResource(surface_resource); - new ExtendedSurface(resource->client(),id, wl_resource_get_version(resource->handle), surface); -} - -ExtendedSurface::ExtendedSurface(struct wl_client *client, uint32_t id, int version, Surface *surface) - : QWaylandSurfaceInterface(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) -{ - QByteArray byteValue; - QDataStream ds(&byteValue, QIODevice::WriteOnly); - ds << variant; - send_set_generic_property(name, byteValue); - -} - -void ExtendedSurface::setVisibility(QWindow::Visibility visibility) -{ - // If this change came from the client, we shouldn't update it - send_onscreen_visibility(visibility); -} - -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(op)->visibility()); - return true; - default: - break; - } - return false; -} - -void ExtendedSurface::extended_surface_update_generic_property(Resource *resource, - const QString &name, - struct wl_array *value) -{ - Q_UNUSED(resource); - QVariant variantValue; - QByteArray byteValue((const char*)value->data, value->size); - QDataStream ds(&byteValue, QIODevice::ReadOnly); - ds >> variantValue; - setWindowProperty(name,variantValue,false); -} - -Qt::ScreenOrientations ExtendedSurface::contentOrientationMask() const -{ - return m_contentOrientationMask; -} - -void ExtendedSurface::extended_surface_set_content_orientation_mask(Resource *resource, int32_t orientation) -{ - Q_UNUSED(resource); - Qt::ScreenOrientations mask = 0; - if (orientation & QT_EXTENDED_SURFACE_ORIENTATION_PORTRAITORIENTATION) - mask |= Qt::PortraitOrientation; - if (orientation & QT_EXTENDED_SURFACE_ORIENTATION_LANDSCAPEORIENTATION) - mask |= Qt::LandscapeOrientation; - if (orientation & QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDPORTRAITORIENTATION) - mask |= Qt::InvertedPortraitOrientation; - if (orientation & QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDLANDSCAPEORIENTATION) - mask |= Qt::InvertedLandscapeOrientation; - if (orientation & QT_EXTENDED_SURFACE_ORIENTATION_PRIMARYORIENTATION) - mask |= Qt::PrimaryOrientation; - - Qt::ScreenOrientations oldMask = m_contentOrientationMask; - m_contentOrientationMask = mask; - - if (m_surface && mask != oldMask) - emit m_surface->waylandSurface()->orientationUpdateMaskChanged(); -} - -QVariantMap ExtendedSurface::windowProperties() const -{ - return m_windowProperties; -} - -QVariant ExtendedSurface::windowProperty(const QString &propertyName) const -{ - QVariantMap props = m_windowProperties; - return props.value(propertyName); -} - -void ExtendedSurface::setWindowProperty(const QString &name, const QVariant &value, bool writeUpdateToClient) -{ - m_windowProperties.insert(name, value); - m_surface->waylandSurface()->windowPropertyChanged(name,value); - if (writeUpdateToClient) - sendGenericProperty(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) - return; - m_windowFlags = windowFlags; - emit m_surface->waylandSurface()->windowFlagsChanged(windowFlags); -} - -void ExtendedSurface::extended_surface_destroy_resource(Resource *) -{ - delete this; -} - -void ExtendedSurface::extended_surface_raise(Resource *) -{ - if (m_surface) - emit m_surface->waylandSurface()->raiseRequested(); -} - -void ExtendedSurface::extended_surface_lower(Resource *) -{ - if (m_surface) - emit m_surface->waylandSurface()->lowerRequested(); -} - -} - -QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwlextendedsurface_p.h b/src/compositor/wayland_wrapper/qwlextendedsurface_p.h deleted file mode 100644 index 524a4d6e8..000000000 --- a/src/compositor/wayland_wrapper/qwlextendedsurface_p.h +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** 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$ -** -****************************************************************************/ - -#ifndef WLEXTENDEDSURFACE_H -#define WLEXTENDEDSURFACE_H - -#include - -#include -#include -#include -#include - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QWaylandSurface; - -namespace QtWayland { - -class Compositor; - -class SurfaceExtensionGlobal : public QtWaylandServer::qt_surface_extension -{ -public: - SurfaceExtensionGlobal(Compositor *compositor); - -private: - void surface_extension_get_extended_surface(Resource *resource, - uint32_t id, - struct wl_resource *surface); - -}; - -class ExtendedSurface : public QWaylandSurfaceInterface, public QtWaylandServer::qt_extended_surface -{ -public: - ExtendedSurface(struct wl_client *client, uint32_t id, int version, Surface *surface); - ~ExtendedSurface(); - - void sendGenericProperty(const QString &name, const QVariant &variant); - - void setVisibility(QWindow::Visibility visibility); - - void setSubSurface(ExtendedSurface *subSurface,int x, int y); - void removeSubSurface(ExtendedSurface *subSurfaces); - ExtendedSurface *parent() const; - void setParent(ExtendedSurface *parent); - QLinkedList subSurfaces() const; - void setParentSurface(Surface *s); - - Qt::ScreenOrientations contentOrientationMask() const; - - QWaylandSurface::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); - -protected: - bool runOperation(QWaylandSurfaceOp *op) Q_DECL_OVERRIDE; - -private: - Surface *m_surface; - - Qt::ScreenOrientations m_contentOrientationMask; - - QWaylandSurface::WindowFlags m_windowFlags; - - QByteArray m_authenticationToken; - QVariantMap m_windowProperties; - - void extended_surface_update_generic_property(Resource *resource, - const QString &name, - struct wl_array *value) Q_DECL_OVERRIDE; - - void extended_surface_set_content_orientation_mask(Resource *resource, - int32_t orientation) Q_DECL_OVERRIDE; - - void extended_surface_set_window_flags(Resource *resource, - int32_t flags) Q_DECL_OVERRIDE; - - void extended_surface_destroy_resource(Resource *) Q_DECL_OVERRIDE; - void extended_surface_raise(Resource *) Q_DECL_OVERRIDE; - void extended_surface_lower(Resource *) Q_DECL_OVERRIDE; -}; - -} - -QT_END_NAMESPACE - -#endif // WLEXTENDEDSURFACE_H 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/qwlinputpanel.cpp b/src/compositor/wayland_wrapper/qwlinputpanel.cpp deleted file mode 100644 index 65befd41c..000000000 --- a/src/compositor/wayland_wrapper/qwlinputpanel.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB). -** 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 "qwlinputpanel_p.h" - -#include - -#include "qwlcompositor_p.h" -#include "qwlinputdevice_p.h" -#include "qwlinputmethod_p.h" -#include "qwlinputpanelsurface_p.h" -#include "qwlsurface_p.h" -#include "qwltextinput_p.h" - -QT_BEGIN_NAMESPACE - -namespace QtWayland { - -InputPanel::InputPanel(Compositor *compositor) - : QtWaylandServer::wl_input_panel(compositor->wl_display(), 1) - , m_compositor(compositor) - , m_handle(new QWaylandInputPanel(this)) - , m_focus() - , m_inputPanelVisible(false) - , m_cursorRectangle() -{ -} - -InputPanel::~InputPanel() -{ -} - -QWaylandInputPanel *InputPanel::handle() const -{ - return m_handle.data(); -} - -Surface *InputPanel::focus() const -{ - return m_focus; -} - -void InputPanel::setFocus(Surface *focus) -{ - if (m_focus == focus) - return; - - m_focus = focus; - - Q_EMIT handle()->focusChanged(); -} - -bool InputPanel::inputPanelVisible() const -{ - return m_inputPanelVisible; -} - -void InputPanel::setInputPanelVisible(bool inputPanelVisible) -{ - if (m_inputPanelVisible == inputPanelVisible) - return; - - m_inputPanelVisible = inputPanelVisible; - - Q_EMIT handle()->visibleChanged(); -} - -QRect InputPanel::cursorRectangle() const -{ - return m_cursorRectangle; -} - -void InputPanel::setCursorRectangle(const QRect &cursorRectangle) -{ - if (m_cursorRectangle == cursorRectangle) - return; - - m_cursorRectangle = cursorRectangle; - - Q_EMIT handle()->cursorRectangleChanged(); -} - -void InputPanel::input_panel_get_input_panel_surface(Resource *resource, uint32_t id, wl_resource *surface) -{ - new InputPanelSurface(resource->client(), id, Surface::fromResource(surface)); -} - -} // namespace QtWayland - -QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwlinputpanel_p.h b/src/compositor/wayland_wrapper/qwlinputpanel_p.h deleted file mode 100644 index f9dc49370..000000000 --- a/src/compositor/wayland_wrapper/qwlinputpanel_p.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB). -** 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$ -** -****************************************************************************/ - -#ifndef QTWAYLAND_QWLINPUTPANEL_P_H -#define QTWAYLAND_QWLINPUTPANEL_P_H - -#include - -#include - -#include -#include - -QT_BEGIN_NAMESPACE - -class QWaylandInputPanel; - -namespace QtWayland { - -class Compositor; -class Surface; -class TextInput; - -class Q_COMPOSITOR_EXPORT InputPanel : public QtWaylandServer::wl_input_panel -{ -public: - InputPanel(Compositor *compositor); - ~InputPanel(); - - QWaylandInputPanel *handle() const; - - Surface *focus() const; - void setFocus(Surface *focus); - - bool inputPanelVisible() const; - void setInputPanelVisible(bool inputPanelVisible); - - QRect cursorRectangle() const; - void setCursorRectangle(const QRect &cursorRectangle); - -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 m_handle; - - 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/wayland_wrapper/qwlinputpanelsurface.cpp deleted file mode 100644 index a72afa2b3..000000000 --- a/src/compositor/wayland_wrapper/qwlinputpanelsurface.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Pier Luigi Fiorini -** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB). -** 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 "qwlinputpanelsurface_p.h" - -#include "qwloutput_p.h" -#include "qwlsurface_p.h" - -QT_BEGIN_NAMESPACE - -namespace QtWayland { - -InputPanelSurface::InputPanelSurface(wl_client *client, int id, Surface *surface) - : QtWaylandServer::wl_input_panel_surface(client, id, 1) - , m_surface(surface) - , m_type(Invalid) - , m_output(0) - , m_position() -{ - surface->setInputPanelSurface(this); -} - -InputPanelSurface::Type InputPanelSurface::type() const -{ - return m_type; -} - -Output *InputPanelSurface::output() const -{ - return m_output; -} - -QtWaylandServer::wl_input_panel_surface::position InputPanelSurface::position() const -{ - return m_position; -} - -void InputPanelSurface::input_panel_surface_set_overlay_panel(Resource *) -{ - m_type = OverlayPanel; -} - -void InputPanelSurface::input_panel_surface_set_toplevel(Resource *, wl_resource *output_resource, uint32_t position) -{ - m_type = Toplevel; - OutputResource *output = static_cast(Output::Resource::fromResource(output_resource)); - m_output = static_cast(output->output_object); - m_position = static_cast(position); -} - -QT_END_NAMESPACE - -} // namespace QtWayland diff --git a/src/compositor/wayland_wrapper/qwlinputpanelsurface_p.h b/src/compositor/wayland_wrapper/qwlinputpanelsurface_p.h deleted file mode 100644 index 0591832fb..000000000 --- a/src/compositor/wayland_wrapper/qwlinputpanelsurface_p.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Pier Luigi Fiorini -** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB). -** 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$ -** -****************************************************************************/ - -#ifndef QTWAYLAND_QWLINPUTPANELSURFACE_P_H -#define QTWAYLAND_QWLINPUTPANELSURFACE_P_H - -#include - -QT_BEGIN_NAMESPACE - -namespace QtWayland { - -class Output; -class Surface; - -class InputPanelSurface : public QtWaylandServer::wl_input_panel_surface -{ -public: - enum Type { - Invalid, - Toplevel, - OverlayPanel - }; - - InputPanelSurface(struct ::wl_client *client, int id, Surface *surface); - - Type type() const; - - Output *output() const; - wl_input_panel_surface::position position() const; - -protected: - void input_panel_surface_set_overlay_panel(Resource *resource) Q_DECL_OVERRIDE; - void input_panel_surface_set_toplevel(Resource *resource, wl_resource *output_resource, uint32_t position) Q_DECL_OVERRIDE; - -private: - Surface *m_surface; - - Type m_type; - - Output *m_output; - wl_input_panel_surface::position m_position; -}; - -} // namespace QtWayland - -QT_END_NAMESPACE - -#endif // QTWAYLAND_QWLINPUTPANELSURFACE_P_H 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 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/qwlqtkey.cpp b/src/compositor/wayland_wrapper/qwlqtkey.cpp deleted file mode 100644 index 34506e6fb..000000000 --- a/src/compositor/wayland_wrapper/qwlqtkey.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** 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 "qwlqtkey_p.h" -#include "qwlsurface_p.h" -#include -#include - -QT_BEGIN_NAMESPACE - -namespace QtWayland { - -QtKeyExtensionGlobal::QtKeyExtensionGlobal(Compositor *compositor) - : QtWaylandServer::qt_key_extension(compositor->wl_display(), 2) - , m_compositor(compositor) -{ -} - -bool QtKeyExtensionGlobal::postQtKeyEvent(QKeyEvent *event, Surface *surface) -{ - uint32_t time = m_compositor->currentTimeMsecs(); - - Resource *target = surface ? resourceMap().value(surface->resource()->client()) : 0; - - if (target) { - send_qtkey(target->handle, - surface ? surface->resource()->handle : 0, - time, event->type(), event->key(), event->modifiers(), - event->nativeScanCode(), - event->nativeVirtualKey(), - event->nativeModifiers(), - event->text(), - event->isAutoRepeat(), - event->count()); - - return true; - } - - return false; -} - -} - -QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwlqtkey_p.h b/src/compositor/wayland_wrapper/qwlqtkey_p.h deleted file mode 100644 index 76cf6c310..000000000 --- a/src/compositor/wayland_wrapper/qwlqtkey_p.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** 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$ -** -****************************************************************************/ - -#ifndef WLQTKEY_H -#define WLQTKEY_H - -#include - -#include "wayland-util.h" - -#include - -QT_BEGIN_NAMESPACE - -class Compositor; -class Surface; -class QKeyEvent; - -namespace QtWayland { - -class QtKeyExtensionGlobal : public QtWaylandServer::qt_key_extension -{ -public: - QtKeyExtensionGlobal(Compositor *compositor); - - bool postQtKeyEvent(QKeyEvent *event, Surface *surface); - -private: - Compositor *m_compositor; -}; - -} - -QT_END_NAMESPACE - -#endif // WLQTKEY_H diff --git a/src/compositor/wayland_wrapper/qwlqttouch.cpp b/src/compositor/wayland_wrapper/qwlqttouch.cpp deleted file mode 100644 index b99ff776b..000000000 --- a/src/compositor/wayland_wrapper/qwlqttouch.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** 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 "qwlqttouch_p.h" -#include "qwlsurface_p.h" -#include "qwaylandsurfaceview.h" -#include -#include - -QT_BEGIN_NAMESPACE - -namespace QtWayland { - -static const int maxRawPos = 24; - -TouchExtensionGlobal::TouchExtensionGlobal(Compositor *compositor) - : QtWaylandServer::qt_touch_extension(compositor->wl_display(), 1) - , m_compositor(compositor) - , m_flags(0) - , m_resources() - , m_posData(maxRawPos * 2) -{ -} - -TouchExtensionGlobal::~TouchExtensionGlobal() -{ -} - -static inline int toFixed(qreal f) -{ - return int(f * 10000); -} - -bool TouchExtensionGlobal::postTouchEvent(QTouchEvent *event, QWaylandSurfaceView *view) -{ - const QList points = event->touchPoints(); - const int pointCount = points.count(); - if (!pointCount) - return false; - - QPointF surfacePos = view->requestedPosition(); - wl_client *surfaceClient = view->surface()->handle()->resource()->client(); - uint32_t time = m_compositor->currentTimeMsecs(); - const int rescount = m_resources.count(); - - for (int res = 0; res < rescount; ++res) { - Resource *target = m_resources.at(res); - if (target->client() != surfaceClient) - continue; - - // We will use no touch_frame type of event, to reduce the number of - // events flowing through the wire. Instead, the number of points sent is - // included in the touch point events. - int sentPointCount = 0; - for (int i = 0; i < pointCount; ++i) { - if (points.at(i).state() != Qt::TouchPointStationary) - ++sentPointCount; - } - - for (int i = 0; i < pointCount; ++i) { - const QTouchEvent::TouchPoint &tp(points.at(i)); - // Stationary points are never sent. They are cached on client side. - if (tp.state() == Qt::TouchPointStationary) - continue; - - uint32_t id = tp.id(); - uint32_t state = (tp.state() & 0xFFFF) | (sentPointCount << 16); - uint32_t flags = (tp.flags() & 0xFFFF) | (int(event->device()->capabilities()) << 16); - - QPointF p = tp.pos() - surfacePos; // surface-relative - int x = toFixed(p.x()); - int y = toFixed(p.y()); - int nx = toFixed(tp.normalizedPos().x()); - int ny = toFixed(tp.normalizedPos().y()); - int w = toFixed(tp.rect().width()); - int h = toFixed(tp.rect().height()); - int vx = toFixed(tp.velocity().x()); - int vy = toFixed(tp.velocity().y()); - uint32_t pressure = uint32_t(tp.pressure() * 255); - - QByteArray rawData; - QVector rawPosList = tp.rawScreenPositions(); - int rawPosCount = rawPosList.count(); - if (rawPosCount) { - rawPosCount = qMin(maxRawPos, rawPosCount); - QVector::iterator iter = m_posData.begin(); - for (int rpi = 0; rpi < rawPosCount; ++rpi) { - const QPointF &rawPos(rawPosList.at(rpi)); - // This will stay in screen coordinates for performance - // reasons, clients using this data will presumably know - // what they are doing. - *iter++ = static_cast(rawPos.x()); - *iter++ = static_cast(rawPos.y()); - } - rawData = QByteArray::fromRawData(reinterpret_cast(m_posData.constData()), sizeof(float) * rawPosCount * 2); - } - - send_touch(target->handle, - time, id, state, - x, y, nx, ny, w, h, - pressure, vx, vy, - flags, rawData); - } - - return true; - } - - return false; -} - -void TouchExtensionGlobal::touch_extension_bind_resource(Resource *resource) -{ - m_resources.append(resource); - send_configure(resource->handle, m_flags); -} - -void TouchExtensionGlobal::touch_extension_destroy_resource(Resource *resource) -{ - m_resources.removeOne(resource); -} - -} - -QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwlqttouch_p.h b/src/compositor/wayland_wrapper/qwlqttouch_p.h deleted file mode 100644 index e9d42f7e3..000000000 --- a/src/compositor/wayland_wrapper/qwlqttouch_p.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** 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$ -** -****************************************************************************/ - -#ifndef WLTOUCH_H -#define WLTOUCH_H - -#include -#include -#include "wayland-util.h" - -QT_BEGIN_NAMESPACE - -class Compositor; -class Surface; -class QTouchEvent; -class QWaylandSurfaceView; - -namespace QtWayland { - -class TouchExtensionGlobal : public QtWaylandServer::qt_touch_extension -{ -public: - TouchExtensionGlobal(Compositor *compositor); - ~TouchExtensionGlobal(); - - bool postTouchEvent(QTouchEvent *event, QWaylandSurfaceView *view); - - void setFlags(int flags) { m_flags = flags; } - -protected: - void touch_extension_bind_resource(Resource *resource) Q_DECL_OVERRIDE; - void touch_extension_destroy_resource(Resource *resource) Q_DECL_OVERRIDE; - -private: - Compositor *m_compositor; - int m_flags; - QList m_resources; - QVector m_posData; -}; - -} - -QT_END_NAMESPACE - -#endif // WLTOUCH_H diff --git a/src/compositor/wayland_wrapper/qwlshellsurface.cpp b/src/compositor/wayland_wrapper/qwlshellsurface.cpp deleted file mode 100644 index 09316358b..000000000 --- a/src/compositor/wayland_wrapper/qwlshellsurface.cpp +++ /dev/null @@ -1,562 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Pier Luigi Fiorini -** Copyright (C) 2015 The Qt Company Ltd. -** 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 "qwlshellsurface_p.h" - -#include "qwlcompositor_p.h" -#include "qwlsurface_p.h" -#include "qwloutput_p.h" -#include "qwlinputdevice_p.h" -#include "qwlsubsurface_p.h" -#include "qwlpointer_p.h" -#include "qwlextendedsurface_p.h" - -#include "qwaylandoutput.h" -#include "qwaylandsurfaceview.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -namespace QtWayland { - -Shell::Shell() -{ -} - -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)) - m_popupGrabber.insert(input, new ShellSurfacePopupGrabber(input)); - - return m_popupGrabber.value(input); -} - -void Shell::shell_get_shell_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface_res) -{ - Surface *surface = Surface::fromResource(surface_res); - new ShellSurface(this, resource->client(), id, surface); -} - - - -ShellSurface::ShellSurface(Shell *shell, wl_client *client, uint32_t id, Surface *surface) - : QWaylandSurfaceInterface(surface->waylandSurface()) - , wl_shell_surface(client, id, 1) - , m_shell(shell) - , m_surface(surface) - , m_resizeGrabber(0) - , m_moveGrabber(0) - , m_popupGrabber(0) - , m_popupSerial() -{ - 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() -{ - delete m_view; -} - -void ShellSurface::sendConfigure(uint32_t edges, int32_t width, int32_t height) -{ - send_configure(edges, width, height); -} - -void ShellSurface::ping(uint32_t serial) -{ - m_pings.insert(serial); - send_ping(serial); -} - -void ShellSurface::adjustPosInResize() -{ - if (m_surface->transientParent()) - return; - if (!m_resizeGrabber || !(m_resizeGrabber->resize_edges & WL_SHELL_SURFACE_RESIZE_TOP_LEFT)) - return; - - int bottomLeftX = m_resizeGrabber->point.x() + m_resizeGrabber->width; - int bottomLeftY = m_resizeGrabber->point.y() + m_resizeGrabber->height; - qreal x = m_view->requestedPosition().x(); - qreal y = m_view->requestedPosition().y(); - if (m_resizeGrabber->resize_edges & WL_SHELL_SURFACE_RESIZE_TOP) - y = bottomLeftY - m_view->surface()->size().height(); - if (m_resizeGrabber->resize_edges & WL_SHELL_SURFACE_RESIZE_LEFT) - x = bottomLeftX - m_view->surface()->size().width(); - QPointF newPos(x,y); - m_view->setRequestedPosition(newPos); -} - -void ShellSurface::resetResizeGrabber() -{ - m_resizeGrabber = 0; -} - -void ShellSurface::resetMoveGrabber() -{ - m_moveGrabber = 0; -} - -void ShellSurface::setOffset(const QPointF &offset) -{ - m_surface->setTransientOffset(offset.x(), offset.y()); -} - -void ShellSurface::configure(bool hasBuffer) -{ - m_surface->setMapped(hasBuffer); -} - -bool ShellSurface::runOperation(QWaylandSurfaceOp *op) -{ - switch (op->type()) { - case QWaylandSurfaceOp::Ping: - ping(static_cast(op)->serial()); - return true; - case QWaylandSurfaceOp::Resize: - requestSize(static_cast(op)->size()); - return true; - default: - break; - } - return false; -} - -void ShellSurface::mapped() -{ - if (m_surface->waylandSurface()->windowType() == QWaylandSurface::Popup) { - if (m_surface->mapped() && m_popupGrabber->grabSerial() == m_popupSerial) { - m_popupGrabber->addPopup(this); - } else { - send_popup_done(); - m_popupGrabber->setClient(0); - } - } -} - -void ShellSurface::adjustOffset(const QPoint &p) -{ - QPointF offset(p); - QPointF pos = m_view->requestedPosition(); - m_view->setRequestedPosition(pos + offset); -} - -void ShellSurface::requestSize(const QSize &size) -{ - send_configure(WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT, size.width(), size.height()); -} - -void ShellSurface::shell_surface_destroy_resource(Resource *) -{ - if (m_popupGrabber) - m_popupGrabber->removePopup(this); - - delete this; -} - -void ShellSurface::shell_surface_move(Resource *resource, - struct wl_resource *input_device_super, - uint32_t time) -{ - Q_UNUSED(resource); - Q_UNUSED(time); - - if (m_resizeGrabber || m_moveGrabber) { - qDebug() << "invalid state"; - return; - } - - InputDevice *input_device = InputDevice::fromSeatResource(input_device_super); - Pointer *pointer = input_device->pointerDevice(); - - m_moveGrabber = new ShellSurfaceMoveGrabber(this, pointer->position() - m_view->requestedPosition()); - - pointer->startGrab(m_moveGrabber); -} - -void ShellSurface::shell_surface_resize(Resource *resource, - struct wl_resource *input_device_super, - uint32_t time, - uint32_t edges) -{ - Q_UNUSED(resource); - Q_UNUSED(time); - - if (m_moveGrabber || m_resizeGrabber) { - qDebug() << "invalid state2"; - return; - } - - m_resizeGrabber = new ShellSurfaceResizeGrabber(this); - - InputDevice *input_device = InputDevice::fromSeatResource(input_device_super); - Pointer *pointer = input_device->pointerDevice(); - - m_resizeGrabber->point = pointer->position(); - m_resizeGrabber->resize_edges = static_cast(edges); - m_resizeGrabber->width = m_view->surface()->size().width(); - m_resizeGrabber->height = m_view->surface()->size().height(); - - pointer->startGrab(m_resizeGrabber); -} - -void ShellSurface::shell_surface_set_toplevel(Resource *resource) -{ - Q_UNUSED(resource); - m_surface->setTransientParent(0); - m_surface->setTransientOffset(0, 0); - - setSurfaceType(QWaylandSurface::Toplevel); - - m_surface->setVisibility(QWindow::Windowed); -} - -void ShellSurface::shell_surface_set_transient(Resource *resource, - struct wl_resource *parent_surface_resource, - int x, - int y, - uint32_t flags) -{ - - Q_UNUSED(resource); - Q_UNUSED(flags); - Surface *parent_surface = Surface::fromResource(parent_surface_resource); - m_surface->setTransientParent(parent_surface); - m_surface->setTransientOffset(x, y); - if (flags & WL_SHELL_SURFACE_TRANSIENT_INACTIVE) - m_surface->setTransientInactive(true); - - setSurfaceType(QWaylandSurface::Transient); - - m_surface->setVisibility(QWindow::AutomaticVisibility); -} - -void ShellSurface::shell_surface_set_fullscreen(Resource *resource, - uint32_t method, - uint32_t framerate, - struct wl_resource *output_resource) -{ - Q_UNUSED(resource); - Q_UNUSED(method); - Q_UNUSED(framerate); - - QWaylandOutput *output = output_resource - ? QWaylandOutput::fromResource(output_resource) - : Q_NULLPTR; - if (!output) { - // Look for an output that can contain this surface - Q_FOREACH (QWaylandOutput *curOutput, m_surface->compositor()->primaryOutputSpace()->outputs()) { - if (curOutput->geometry().size().width() >= m_surface->size().width() && - curOutput->geometry().size().height() >= m_surface->size().height()) { - output = curOutput; - break; - } - } - } - if (!output) { - qWarning() << "Unable to resize surface full screen, cannot determine output"; - return; - } - QSize outputSize = output->geometry().size(); - - m_view->setRequestedPosition(output->geometry().topLeft()); - send_configure(resize_bottom_right, outputSize.width(), outputSize.height()); - - m_surface->setVisibility(QWindow::FullScreen); -} - -void ShellSurface::shell_surface_set_popup(Resource *resource, wl_resource *input_device, uint32_t serial, wl_resource *parent, int32_t x, int32_t y, uint32_t flags) -{ - Q_UNUSED(resource); - Q_UNUSED(input_device); - Q_UNUSED(flags); - - InputDevice *input = InputDevice::fromSeatResource(input_device); - m_popupGrabber = m_shell->getPopupGrabber(input); - - m_popupSerial = serial; - m_surface->setTransientParent(Surface::fromResource(parent)); - m_surface->setTransientOffset(x, y); - - setSurfaceType(QWaylandSurface::Popup); - - m_surface->setVisibility(QWindow::AutomaticVisibility); -} - -void ShellSurface::shell_surface_set_maximized(Resource *resource, - struct wl_resource *output_resource) -{ - Q_UNUSED(resource); - - QWaylandOutput *output = output_resource - ? QWaylandOutput::fromResource(output_resource) - : Q_NULLPTR; - if (!output) { - // Look for an output that can contain this surface - Q_FOREACH (QWaylandOutput *curOutput, m_surface->compositor()->primaryOutputSpace()->outputs()) { - if (curOutput->geometry().size().width() >= m_surface->size().width() && - curOutput->geometry().size().height() >= m_surface->size().height()) { - output = curOutput; - break; - } - } - } - if (!output) { - qWarning() << "Unable to maximize surface, cannot determine output"; - return; - } - QSize outputSize = output->availableGeometry().size(); - - m_view->setRequestedPosition(output->availableGeometry().topLeft()); - send_configure(resize_bottom_right, outputSize.width(), outputSize.height()); - - m_surface->setVisibility(QWindow::Maximized); -} - -void ShellSurface::shell_surface_pong(Resource *resource, - uint32_t serial) -{ - Q_UNUSED(resource); - if (m_pings.remove(serial)) - emit m_surface->waylandSurface()->pong(); - else - qWarning("Received an unexpected pong!"); -} - -void ShellSurface::shell_surface_set_title(Resource *resource, - const QString &title) -{ - Q_UNUSED(resource); - m_surface->setTitle(title); -} - -void ShellSurface::shell_surface_set_class(Resource *resource, - const QString &className) -{ - Q_UNUSED(resource); - m_surface->setClassName(className); -} - -ShellSurfaceGrabber::ShellSurfaceGrabber(ShellSurface *shellSurface) - : PointerGrabber() - , shell_surface(shellSurface) -{ -} - -ShellSurfaceGrabber::~ShellSurfaceGrabber() -{ -} - -ShellSurfaceResizeGrabber::ShellSurfaceResizeGrabber(ShellSurface *shellSurface) - : ShellSurfaceGrabber(shellSurface) -{ -} - -void ShellSurfaceResizeGrabber::focus() -{ -} - -void ShellSurfaceResizeGrabber::motion(uint32_t time) -{ - Q_UNUSED(time); - - int width_delta = point.x() - m_pointer->position().x(); - int height_delta = point.y() - m_pointer->position().y(); - - int new_height = height; - if (resize_edges & WL_SHELL_SURFACE_RESIZE_TOP) - new_height = qMax(new_height + height_delta, 1); - else if (resize_edges & WL_SHELL_SURFACE_RESIZE_BOTTOM) - new_height = qMax(new_height - height_delta, 1); - - int new_width = width; - if (resize_edges & WL_SHELL_SURFACE_RESIZE_LEFT) - new_width = qMax(new_width + width_delta, 1); - else if (resize_edges & WL_SHELL_SURFACE_RESIZE_RIGHT) - new_width = qMax(new_width - width_delta, 1); - - shell_surface->sendConfigure(resize_edges, new_width, new_height); -} - -void ShellSurfaceResizeGrabber::button(uint32_t time, Qt::MouseButton button, uint32_t state) -{ - Q_UNUSED(time) - - if (button == Qt::LeftButton && !state) { - m_pointer->endGrab(); - shell_surface->resetResizeGrabber(); - delete this; - } -} - -ShellSurfaceMoveGrabber::ShellSurfaceMoveGrabber(ShellSurface *shellSurface, const QPointF &offset) - : ShellSurfaceGrabber(shellSurface) - , m_offset(offset) -{ -} - -void ShellSurfaceMoveGrabber::focus() -{ -} - -void ShellSurfaceMoveGrabber::motion(uint32_t time) -{ - Q_UNUSED(time); - - QPointF pos(m_pointer->position() - m_offset); - shell_surface->m_view->setRequestedPosition(pos); - if (shell_surface->m_surface->transientParent()) { - QWaylandSurfaceView *view = shell_surface->m_surface->transientParent()->waylandSurface()->views().first(); - if (view) - shell_surface->setOffset(pos - view->requestedPosition()); - } - -} - -void ShellSurfaceMoveGrabber::button(uint32_t time, Qt::MouseButton button, uint32_t state) -{ - Q_UNUSED(time) - - if (button == Qt::LeftButton && !state) { - m_pointer->setFocus(0, QPointF()); - m_pointer->endGrab(); - shell_surface->resetMoveGrabber(); - delete this; - } -} - -ShellSurfacePopupGrabber::ShellSurfacePopupGrabber(InputDevice *inputDevice) - : PointerGrabber() - , m_inputDevice(inputDevice) - , m_client(0) - , m_surfaces() - , m_initialUp(false) -{ -} - -uint32_t ShellSurfacePopupGrabber::grabSerial() const -{ - return m_inputDevice->pointerDevice()->grabSerial(); -} - -struct ::wl_client *ShellSurfacePopupGrabber::client() const -{ - return m_client; -} - -void ShellSurfacePopupGrabber::setClient(struct ::wl_client *client) -{ - m_client = client; -} - -void ShellSurfacePopupGrabber::addPopup(ShellSurface *surface) -{ - if (m_surfaces.isEmpty()) { - m_client = surface->resource()->client(); - - if (m_inputDevice->pointerDevice()->buttonPressed()) - m_initialUp = false; - - m_surfaces.append(surface); - m_inputDevice->pointerDevice()->startGrab(this); - } else { - m_surfaces.append(surface); - } -} - -void ShellSurfacePopupGrabber::removePopup(ShellSurface *surface) -{ - if (m_surfaces.isEmpty()) - return; - - m_surfaces.removeOne(surface); - if (m_surfaces.isEmpty()) - m_inputDevice->pointerDevice()->endGrab(); -} - -void ShellSurfacePopupGrabber::focus() -{ - if (m_pointer->current() && m_pointer->current()->surface()->handle()->resource()->client() == m_client) - m_pointer->setFocus(m_pointer->current(), m_pointer->currentPosition()); - else - m_pointer->setFocus(0, QPointF()); -} - -void ShellSurfacePopupGrabber::motion(uint32_t time) -{ - m_pointer->motion(time); -} - -void ShellSurfacePopupGrabber::button(uint32_t time, Qt::MouseButton button, uint32_t state) -{ - if (m_pointer->focusResource()) { - m_pointer->sendButton(time, button, state); - } else if (state == QtWaylandServer::wl_pointer::button_state_pressed && - (m_initialUp || time - m_pointer->grabTime() > 500) && - m_pointer->currentGrab() == this) { - m_pointer->endGrab(); - Q_FOREACH (ShellSurface *surface, m_surfaces) { - surface->send_popup_done(); - } - m_surfaces.clear(); - } - - if (state == QtWaylandServer::wl_pointer::button_state_released) - m_initialUp = true; -} - - -} - -QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwlshellsurface_p.h b/src/compositor/wayland_wrapper/qwlshellsurface_p.h deleted file mode 100644 index 033a8f971..000000000 --- a/src/compositor/wayland_wrapper/qwlshellsurface_p.h +++ /dev/null @@ -1,225 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** 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$ -** -****************************************************************************/ - -#ifndef WLSHELLSURFACE_H -#define WLSHELLSURFACE_H - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -class QWaylandSurfaceView; - -namespace QtWayland { - -class Compositor; -class Surface; -class ShellSurface; -class ShellSurfaceResizeGrabber; -class ShellSurfaceMoveGrabber; -class ShellSurfacePopupGrabber; - -class Shell : public QWaylandGlobalInterface, public QtWaylandServer::wl_shell -{ -public: - Shell(); - - 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: - void shell_get_shell_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface) Q_DECL_OVERRIDE; - - QHash m_popupGrabber; -}; - -class Q_COMPOSITOR_EXPORT ShellSurface : public QObject, public QWaylandSurfaceInterface, public QtWaylandServer::wl_shell_surface -{ -public: - ShellSurface(Shell *shell, struct wl_client *client, uint32_t id, Surface *surface); - ~ShellSurface(); - void sendConfigure(uint32_t edges, int32_t width, int32_t height); - - void adjustPosInResize(); - void resetResizeGrabber(); - void resetMoveGrabber(); - - void setOffset(const QPointF &offset); - - void configure(bool hasBuffer); - - void requestSize(const QSize &size); - void ping(uint32_t serial); - - QWaylandSurfaceView *view() { return m_view; } -protected: - bool runOperation(QWaylandSurfaceOp *op) Q_DECL_OVERRIDE; - -private Q_SLOTS: - void mapped(); - void adjustOffset(const QPoint &p); - -private: - Shell *m_shell; - Surface *m_surface; - QWaylandSurfaceView *m_view; - - ShellSurfaceResizeGrabber *m_resizeGrabber; - ShellSurfaceMoveGrabber *m_moveGrabber; - ShellSurfacePopupGrabber *m_popupGrabber; - - uint32_t m_popupSerial; - - QSet m_pings; - - void shell_surface_destroy_resource(Resource *resource) Q_DECL_OVERRIDE; - - void shell_surface_move(Resource *resource, - struct wl_resource *input_device_super, - uint32_t time) Q_DECL_OVERRIDE; - void shell_surface_resize(Resource *resource, - struct wl_resource *input_device, - uint32_t time, - uint32_t edges) Q_DECL_OVERRIDE; - void shell_surface_set_toplevel(Resource *resource) Q_DECL_OVERRIDE; - void shell_surface_set_transient(Resource *resource, - struct wl_resource *parent_surface_resource, - int x, - int y, - uint32_t flags) Q_DECL_OVERRIDE; - void shell_surface_set_fullscreen(Resource *resource, - uint32_t method, - uint32_t framerate, - struct wl_resource *output_resource) Q_DECL_OVERRIDE; - void shell_surface_set_popup(Resource *resource, - struct wl_resource *input_device, - uint32_t time, - struct wl_resource *parent, - int32_t x, - int32_t y, - uint32_t flags) Q_DECL_OVERRIDE; - void shell_surface_set_maximized(Resource *resource, - struct wl_resource *output_resource) Q_DECL_OVERRIDE; - void shell_surface_pong(Resource *resource, - uint32_t serial) Q_DECL_OVERRIDE; - void shell_surface_set_title(Resource *resource, - const QString &title) Q_DECL_OVERRIDE; - void shell_surface_set_class(Resource *resource, - const QString &class_) Q_DECL_OVERRIDE; - - friend class ShellSurfaceMoveGrabber; -}; - -class ShellSurfaceGrabber : public PointerGrabber -{ -public: - ShellSurfaceGrabber(ShellSurface *shellSurface); - ~ShellSurfaceGrabber(); - - ShellSurface *shell_surface; -}; - -class ShellSurfaceResizeGrabber : public ShellSurfaceGrabber -{ -public: - ShellSurfaceResizeGrabber(ShellSurface *shellSurface); - - QPointF point; - enum wl_shell_surface_resize resize_edges; - int32_t width; - int32_t height; - - void focus() Q_DECL_OVERRIDE; - void motion(uint32_t time) Q_DECL_OVERRIDE; - void button(uint32_t time, Qt::MouseButton button, uint32_t state) Q_DECL_OVERRIDE; -}; - -class ShellSurfaceMoveGrabber : public ShellSurfaceGrabber -{ -public: - ShellSurfaceMoveGrabber(ShellSurface *shellSurface, const QPointF &offset); - - void focus() Q_DECL_OVERRIDE; - void motion(uint32_t time) Q_DECL_OVERRIDE; - void button(uint32_t time, Qt::MouseButton button, uint32_t state) Q_DECL_OVERRIDE; - -private: - QPointF m_offset; -}; - -class ShellSurfacePopupGrabber : public PointerGrabber -{ -public: - ShellSurfacePopupGrabber(InputDevice *inputDevice); - - uint32_t grabSerial() const; - - struct ::wl_client *client() const; - void setClient(struct ::wl_client *client); - - void addPopup(ShellSurface *surface); - void removePopup(ShellSurface *surface); - - void focus() Q_DECL_OVERRIDE; - void motion(uint32_t time) Q_DECL_OVERRIDE; - void button(uint32_t time, Qt::MouseButton button, uint32_t state) Q_DECL_OVERRIDE; - -private: - InputDevice *m_inputDevice; - struct ::wl_client *m_client; - QList m_surfaces; - bool m_initialUp; -}; - -} - -QT_END_NAMESPACE - -#endif // WLSHELLSURFACE_H diff --git a/src/compositor/wayland_wrapper/qwlsubsurface_p.h b/src/compositor/wayland_wrapper/qwlsubsurface_p.h deleted file mode 100644 index 27c2bc172..000000000 --- a/src/compositor/wayland_wrapper/qwlsubsurface_p.h +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** 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$ -** -****************************************************************************/ - -#ifndef WLSUBSURFACE_H -#define WLSUBSURFACE_H - -#include - -#include - -#include - -QT_BEGIN_NAMESPACE - -class Compositor; -class QWaylandSurface; - -namespace QtWayland { - -class SubSurfaceExtensionGlobal -{ -public: - SubSurfaceExtensionGlobal(Compositor *compositor); - -private: - Compositor *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; -}; - -class SubSurface -{ -public: - SubSurface(struct wl_client *client, uint32_t id, Surface *surface); - ~SubSurface(); - - void setSubSurface(SubSurface *subSurface, int x, int y); - void removeSubSurface(SubSurface *subSurfaces); - - SubSurface *parent() const; - void setParent(SubSurface *parent); - - QLinkedList subSurfaces() const; - - Surface *surface() const; - QWaylandSurface *waylandSurface() const; - -private: - void parentDestroyed(); - struct wl_resource *m_sub_surface_resource; - Surface *m_surface; - - SubSurface *m_parent; - QLinkedList 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 -{ - return m_surface; -} - -inline QWaylandSurface *SubSurface::waylandSurface() const -{ - return m_surface->waylandSurface(); -} - -} - -QT_END_NAMESPACE - -#endif // WLSUBSURFACE_H 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 m_pendingFrameCallbacks; QList m_frameCallbacks; - ShellSurface *m_shellSurface; - ExtendedSurface *m_extendedSurface; SubSurface *m_subSurface; InputPanelSurface *m_inputPanelSurface; diff --git a/src/compositor/wayland_wrapper/qwltextinput.cpp b/src/compositor/wayland_wrapper/qwltextinput.cpp deleted file mode 100644 index af5771d7a..000000000 --- a/src/compositor/wayland_wrapper/qwltextinput.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB). -** 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 "qwltextinput_p.h" - -#include "qwlcompositor_p.h" -#include "qwlinputdevice_p.h" -#include "qwlinputmethod_p.h" -#include "qwlinputmethodcontext_p.h" -#include "qwlinputpanel_p.h" -#include "qwlsurface_p.h" - -#include - -QT_BEGIN_NAMESPACE - -namespace QtWayland { - -TextInput::TextInput(Compositor *compositor, struct ::wl_client *client, int id) - : wl_text_input(client, id, 1) - , m_compositor(compositor) - , m_focus() - , m_inputPanelVisible() - , m_cursorRectangle() -{ -} - -Surface *TextInput::focus() const -{ - return m_focus; -} - -bool TextInput::inputPanelVisible() const -{ - return m_inputPanelVisible; -} - -QRect TextInput::cursorRectangle() const -{ - return m_cursorRectangle; -} - -void TextInput::deactivate(InputMethod *inputMethod) -{ - if (m_activeInputMethods.removeOne(inputMethod)) - inputMethod->deactivate(); - - if (m_activeInputMethods.isEmpty()) - send_leave(); -} - -void TextInput::text_input_destroy_resource(Resource *) -{ - Q_FOREACH (InputMethod *inputMethod, m_activeInputMethods) { - deactivate(inputMethod); - } - - delete this; -} - -void TextInput::text_input_activate(Resource *, wl_resource *seat, wl_resource *surface) -{ - Surface *oldSurface = m_focus; - m_focus = Surface::fromResource(surface); - - if (oldSurface != m_focus) - send_leave(); - - bool wasEmpty = m_activeInputMethods.isEmpty(); - - InputMethod *inputMethod = InputDevice::fromSeatResource(seat)->inputMethod(); - - if (!m_activeInputMethods.contains(inputMethod)) { - m_activeInputMethods.append(inputMethod); - inputMethod->activate(this); - } - - if (wasEmpty || oldSurface != m_focus) - send_enter(surface); -} - -void TextInput::text_input_deactivate(Resource *, wl_resource *seat) -{ - InputMethod *inputMethod = InputDevice::fromSeatResource(seat)->inputMethod(); - - deactivate(inputMethod); -} - -static bool isInputMethodBound(InputMethod *inputMethod) -{ - return inputMethod->isBound(); -} - -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); -} - -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); -} - -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); -} - -void TextInput::text_input_reset(Resource *) -{ - Q_FOREACH (InputMethod *inputMethod, m_activeInputMethods) { - if (inputMethod->context()) - inputMethod->context()->send_reset(); - } -} - -void TextInput::text_input_commit_state(Resource *, uint32_t serial) -{ - Q_FOREACH (InputMethod *inputMethod, m_activeInputMethods) { - if (inputMethod->context()) - inputMethod->context()->send_commit_state(serial); - } -} - -void TextInput::text_input_set_content_type(Resource *, uint32_t hint, uint32_t purpose) -{ - Q_FOREACH (InputMethod *inputMethod, m_activeInputMethods) { - if (inputMethod->context()) - inputMethod->context()->send_content_type(hint, purpose); - } -} - -void TextInput::text_input_set_preferred_language(Resource *, const QString &language) -{ - Q_FOREACH (InputMethod *inputMethod, m_activeInputMethods) { - if (inputMethod->context()) - inputMethod->context()->send_preferred_language(language); - } -} - -void TextInput::text_input_set_surrounding_text(Resource *, const QString &text, uint32_t cursor, uint32_t anchor) -{ - Q_FOREACH (InputMethod *inputMethod, m_activeInputMethods) { - if (inputMethod->context()) - inputMethod->context()->send_surrounding_text(text, cursor, anchor); - } -} - -void TextInput::text_input_invoke_action(Resource *, uint32_t button, uint32_t index) -{ - Q_FOREACH (InputMethod *inputMethod, m_activeInputMethods) { - if (inputMethod->context()) - inputMethod->context()->send_invoke_action(button, index); - } -} - -} // namespace QtWayland - -QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwltextinput_p.h b/src/compositor/wayland_wrapper/qwltextinput_p.h deleted file mode 100644 index 9d6f75247..000000000 --- a/src/compositor/wayland_wrapper/qwltextinput_p.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB). -** 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$ -** -****************************************************************************/ - -#ifndef QTWAYLAND_QWLTEXTINPUT_P_H -#define QTWAYLAND_QWLTEXTINPUT_P_H - -#include - -#include - -QT_BEGIN_NAMESPACE - -namespace QtWayland { - -class Compositor; -class InputMethod; -class Surface; - -class TextInput : public QtWaylandServer::wl_text_input -{ -public: - explicit TextInput(Compositor *compositor, struct ::wl_client *client, int id); - - Surface *focus() const; - - bool inputPanelVisible() const; - QRect cursorRectangle() const; - - void deactivate(InputMethod *inputMethod); - -protected: - void text_input_destroy_resource(Resource *resource) Q_DECL_OVERRIDE; - - void text_input_activate(Resource *resource, wl_resource *seat, wl_resource *surface) Q_DECL_OVERRIDE; - void text_input_deactivate(Resource *resource, wl_resource *seat) Q_DECL_OVERRIDE; - void text_input_show_input_panel(Resource *resource) Q_DECL_OVERRIDE; - void text_input_hide_input_panel(Resource *resource) Q_DECL_OVERRIDE; - void text_input_reset(Resource *resource) Q_DECL_OVERRIDE; - void text_input_commit_state(Resource *resource, uint32_t serial) Q_DECL_OVERRIDE; - void text_input_set_content_type(Resource *resource, uint32_t hint, uint32_t purpose) Q_DECL_OVERRIDE; - void text_input_set_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) Q_DECL_OVERRIDE; - void text_input_set_preferred_language(Resource *resource, const QString &language) Q_DECL_OVERRIDE; - void text_input_set_surrounding_text(Resource *resource, const QString &text, uint32_t cursor, uint32_t anchor) Q_DECL_OVERRIDE; - void text_input_invoke_action(Resource *resource, uint32_t button, uint32_t index) Q_DECL_OVERRIDE; - -private: - Compositor *m_compositor; - QList m_activeInputMethods; - Surface *m_focus; - - bool m_inputPanelVisible; - QRect m_cursorRectangle; - -}; - -} // namespace QtWayland - -QT_END_NAMESPACE - -#endif // QTWAYLAND_QWLTEXTINPUT_P_H diff --git a/src/compositor/wayland_wrapper/qwltextinputmanager.cpp b/src/compositor/wayland_wrapper/qwltextinputmanager.cpp deleted file mode 100644 index 1daa8cb7b..000000000 --- a/src/compositor/wayland_wrapper/qwltextinputmanager.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB). -** 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 "qwltextinputmanager_p.h" - -#include "qwlcompositor_p.h" -#include "qwltextinput_p.h" - -QT_BEGIN_NAMESPACE - -namespace QtWayland { - -TextInputManager::TextInputManager(Compositor *compositor) - : QtWaylandServer::wl_text_input_manager(compositor->wl_display(), 1) - , m_compositor(compositor) -{ -} - -TextInputManager::~TextInputManager() -{ -} - -void TextInputManager::text_input_manager_create_text_input(Resource *resource, uint32_t id) -{ - new TextInput(m_compositor, resource->client(), id); -} - -} // namespace QtWayland - -QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwltextinputmanager_p.h b/src/compositor/wayland_wrapper/qwltextinputmanager_p.h deleted file mode 100644 index ae883af50..000000000 --- a/src/compositor/wayland_wrapper/qwltextinputmanager_p.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB). -** 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$ -** -****************************************************************************/ - -#ifndef QTWAYLAND_QWLTEXTINPUTMANAGER_P_H -#define QTWAYLAND_QWLTEXTINPUTMANAGER_P_H - -#include - -QT_BEGIN_NAMESPACE - -namespace QtWayland { - -class Compositor; - -class TextInputManager : public QtWaylandServer::wl_text_input_manager -{ -public: - TextInputManager(Compositor *compositor); - ~TextInputManager(); - -protected: - void text_input_manager_create_text_input(Resource *resource, uint32_t id) Q_DECL_OVERRIDE; - -private: - Compositor *m_compositor; -}; - -} // namespace QtWayland - -QT_END_NAMESPACE - -#endif // QTWAYLAND_QWLTEXTINPUTMANAGER_P_H 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/waylandwindowmanagerintegration.cpp b/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp deleted file mode 100644 index bb3c9fc37..000000000 --- a/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** 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 - -#include -#include - -#include -#include - -#include - -#include - -QT_BEGIN_NAMESPACE - -WindowManagerServerIntegration::WindowManagerServerIntegration(QWaylandCompositor *compositor, QObject *parent) - : QObject(parent) - , QtWaylandServer::qt_windowmanager() - , m_showIsFullScreen(false) - , m_compositor(compositor) -{ -} - -WindowManagerServerIntegration::~WindowManagerServerIntegration() -{ -} - -void WindowManagerServerIntegration::initialize(QtWayland::Display *waylandDisplay) -{ - init(waylandDisplay->handle(), 1); -} - -void WindowManagerServerIntegration::setShowIsFullScreen(bool value) -{ - m_showIsFullScreen = value; - Q_FOREACH (Resource *resource, resourceMap().values()) { - send_hints(resource->handle, static_cast(m_showIsFullScreen)); - } -} - -void WindowManagerServerIntegration::sendQuitMessage(wl_client *client) -{ - Resource *resource = resourceMap().value(client); - - if (resource) - send_quit(resource->handle); -} - -void WindowManagerServerIntegration::windowmanager_bind_resource(Resource *resource) -{ - send_hints(resource->handle, static_cast(m_showIsFullScreen)); -} - -void WindowManagerServerIntegration::windowmanager_destroy_resource(Resource *resource) -{ - m_urls.remove(resource); -} - -void WindowManagerServerIntegration::windowmanager_open_url(Resource *resource, uint32_t remaining, const QString &newUrl) -{ - QString url = m_urls.value(resource, QString()); - - url.append(newUrl); - - if (remaining) - m_urls.insert(resource, url); - else { - m_urls.remove(resource); - m_compositor->openUrl(QWaylandClient::fromWlClient(resource->client()), QUrl(url)); - } -} - -QT_END_NAMESPACE diff --git a/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration_p.h b/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration_p.h deleted file mode 100644 index d6acee9cb..000000000 --- a/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration_p.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** 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$ -** -****************************************************************************/ - -#ifndef WAYLANDWINDOWMANAGERINTEGRATION_H -#define WAYLANDWINDOWMANAGERINTEGRATION_H - -#include -#include - -#include -#include - -QT_BEGIN_NAMESPACE - -namespace QtWayland { - class Display; -} - -class QWaylandCompositor; - -class Q_COMPOSITOR_EXPORT WindowManagerServerIntegration : public QObject, public QtWaylandServer::qt_windowmanager -{ - Q_OBJECT -public: - explicit WindowManagerServerIntegration(QWaylandCompositor *compositor, QObject *parent = 0); - ~WindowManagerServerIntegration(); - - void initialize(QtWayland::Display *waylandDisplay); - - void setShowIsFullScreen(bool value); - void sendQuitMessage(wl_client *client); - -protected: - void windowmanager_bind_resource(Resource *resource) Q_DECL_OVERRIDE; - void windowmanager_destroy_resource(Resource *resource) Q_DECL_OVERRIDE; - void windowmanager_open_url(Resource *resource, uint32_t remaining, const QString &url) Q_DECL_OVERRIDE; - -private: - bool m_showIsFullScreen; - QWaylandCompositor *m_compositor; - QMap m_urls; -}; - -QT_END_NAMESPACE - -#endif // WAYLANDWINDOWMANAGERINTEGRATION_H 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 - - -- cgit v1.2.3