From acb37c995a93b208540d73dc9035d924db3d646d Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Mon, 11 Apr 2016 12:01:27 +0200 Subject: Add a multi-screen compositor example This example shows how shell surfaces can move across outputs in order to create traditional multi-monitor desktop functionality. Change-Id: Ie7c0aa1dc47c0c1a944dffcce5237dee92785396 Reviewed-by: Paul Olav Tvete Reviewed-by: Pier Luigi Fiorini --- examples/wayland/multi-screen/main.cpp | 55 +++++++++++ examples/wayland/multi-screen/multi-screen.pro | 18 ++++ examples/wayland/multi-screen/multi-screen.qrc | 7 ++ examples/wayland/multi-screen/qml/Chrome.qml | 77 +++++++++++++++ examples/wayland/multi-screen/qml/Screen.qml | 82 ++++++++++++++++ examples/wayland/multi-screen/qml/main.qml | 127 +++++++++++++++++++++++++ examples/wayland/wayland.pro | 1 + 7 files changed, 367 insertions(+) create mode 100644 examples/wayland/multi-screen/main.cpp create mode 100644 examples/wayland/multi-screen/multi-screen.pro create mode 100644 examples/wayland/multi-screen/multi-screen.qrc create mode 100644 examples/wayland/multi-screen/qml/Chrome.qml create mode 100644 examples/wayland/multi-screen/qml/Screen.qml create mode 100644 examples/wayland/multi-screen/qml/main.qml diff --git a/examples/wayland/multi-screen/main.cpp b/examples/wayland/multi-screen/main.cpp new file mode 100644 index 000000000..81adbc13d --- /dev/null +++ b/examples/wayland/multi-screen/main.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include + +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine appEngine(QUrl("qrc:///qml/main.qml")); + + return app.exec(); +} diff --git a/examples/wayland/multi-screen/multi-screen.pro b/examples/wayland/multi-screen/multi-screen.pro new file mode 100644 index 000000000..29e1479da --- /dev/null +++ b/examples/wayland/multi-screen/multi-screen.pro @@ -0,0 +1,18 @@ +QT += gui qml + +SOURCES += \ + main.cpp + +OTHER_FILES = \ + qml/main.qml \ + +RESOURCES += multi-screen.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/wayland/multi-screen +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS multi-screen.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/wayland/multi-screen +INSTALLS += target sources + +DISTFILES += \ + qml/Screen.qml \ + qml/Chrome.qml diff --git a/examples/wayland/multi-screen/multi-screen.qrc b/examples/wayland/multi-screen/multi-screen.qrc new file mode 100644 index 000000000..57fcd3cf6 --- /dev/null +++ b/examples/wayland/multi-screen/multi-screen.qrc @@ -0,0 +1,7 @@ + + + qml/main.qml + qml/Screen.qml + qml/Chrome.qml + + diff --git a/examples/wayland/multi-screen/qml/Chrome.qml b/examples/wayland/multi-screen/qml/Chrome.qml new file mode 100644 index 000000000..d91a93043 --- /dev/null +++ b/examples/wayland/multi-screen/qml/Chrome.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2016 Pier Luigi Fiorini +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtWayland.Compositor 1.0 + +Item { + id: chrome + property alias shellSurface: surfaceItem.shellSurface + property alias surfaceItem: surfaceItem + property alias moveItem: surfaceItem.moveItem + + x: surfaceItem.moveItem.x - surfaceItem.output.geometry.x + y: surfaceItem.moveItem.y - surfaceItem.output.geometry.y + + ShellSurfaceItem { + id: surfaceItem + onSurfaceDestroyed: chrome.destroy(); + } + + onXChanged: updatePrimary() + onYChanged: updatePrimary() + function updatePrimary() { + var w = surfaceItem.width + var h = surfaceItem.height + var area = w * h; + var screenW = surfaceItem.output.geometry.width; + var screenH = surfaceItem.output.geometry.height; + var x1 = Math.max(0, x); + var y1 = Math.max(0, y); + var x2 = Math.min(x + w, screenW); + var y2 = Math.min(y + h, screenH); + var w1 = Math.max(0, x2 - x1); + var h1 = Math.max(0, y2 - y1); + if (w1 * h1 * 2 > area) { + surfaceItem.setPrimary(); + } + } +} diff --git a/examples/wayland/multi-screen/qml/Screen.qml b/examples/wayland/multi-screen/qml/Screen.qml new file mode 100644 index 000000000..7e2eb01dc --- /dev/null +++ b/examples/wayland/multi-screen/qml/Screen.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtWayland.Compositor 1.0 +import QtQuick.Window 2.2 + +WaylandOutput { + id: screen + property variant viewsBySurface: ({}) + property alias surfaceArea: background + property alias text: t.text + sizeFollowsWindow: true + + window: Window { + width: 1024 + height: 760 + visible: true + + WaylandMouseTracker { + id: mouseTracker + anchors.fill: parent + windowSystemCursorEnabled: false + + Rectangle { + anchors.fill: parent + id: background + + Text { + id: t + anchors.centerIn: parent + font.pointSize: 72 + } + } + + WaylandCursorItem { + inputEventsEnabled: false + x: mouseTracker.mouseX + y: mouseTracker.mouseY + seat: comp.defaultSeat + visible: mouseTracker.containsMouse + } + } + } +} diff --git a/examples/wayland/multi-screen/qml/main.qml b/examples/wayland/multi-screen/qml/main.qml new file mode 100644 index 000000000..37350289e --- /dev/null +++ b/examples/wayland/multi-screen/qml/main.qml @@ -0,0 +1,127 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2016 Pier Luigi Fiorini +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtWayland.Compositor 1.0 + +WaylandCompositor { + id: comp + defaultOutput: middleScreen + + Screen { + id: leftScreen + position.x: -leftScreen.surfaceArea.width + position.y: 0 + surfaceArea.color: "#f00" + text: "Left" + compositor: comp + } + + Screen { + id: middleScreen + position.x: leftScreen.position.x + leftScreen.surfaceArea.width + position.y: 0 + text: "Middle" + surfaceArea.color: "#0f0" + compositor: comp + } + + Screen { + id: rightScreen + position.x: middleScreen.position.x + middleScreen.surfaceArea.width + position.y: 0 + surfaceArea.color: "#00f" + text: "Right" + compositor: comp + } + + Component { + id: chromeComponent + Chrome {} + } + + Component { + id: moveItemComponent + Item {} + } + + Item { + id: rootItem + x: leftScreen.position.x + y: leftScreen.position.y + width: leftScreen.surfaceArea.width + middleScreen.surfaceArea.width + rightScreen.surfaceArea.width + height: Math.max(leftScreen.surfaceArea.height, middleScreen.surfaceArea.height, rightScreen.surfaceArea.height) + } + + WlShell { + onWlShellSurfaceCreated: handleShellSurfaceCreated(shellSurface) + } + + XdgShellV5 { + onXdgSurfaceCreated: handleShellSurfaceCreated(xdgSurface) + onXdgPopupCreated: handleShellSurfaceCreated(xdgPopup) + } + + function createShellSurfaceItem(shellSurface, moveItem, output) { + var parentSurfaceItem = output.viewsBySurface[shellSurface.parentSurface]; + var parent = parentSurfaceItem || output.surfaceArea; + var item = chromeComponent.createObject(parent, { + "shellSurface": shellSurface, + "moveItem": moveItem, + "output": output + }); + if (parentSurfaceItem) { + item.x += output.position.x; + item.y += output.position.y; + } + output.viewsBySurface[shellSurface.surface] = item; + } + + function handleShellSurfaceCreated(shellSurface) { + var moveItem = moveItemComponent.createObject(rootItem, { + "width": Qt.binding(function() { return shellSurface.surface.width; }), + "height": Qt.binding(function() { return shellSurface.surface.height; }) + }); + createShellSurfaceItem(shellSurface, moveItem, middleScreen); + createShellSurfaceItem(shellSurface, moveItem, leftScreen); + createShellSurfaceItem(shellSurface, moveItem, rightScreen); + } +} diff --git a/examples/wayland/wayland.pro b/examples/wayland/wayland.pro index f36bf69e8..2a5395004 100644 --- a/examples/wayland/wayland.pro +++ b/examples/wayland/wayland.pro @@ -10,6 +10,7 @@ contains(QT_CONFIG, opengl):qtHaveModule(quick) { SUBDIRS += spanning-screens SUBDIRS += pure-qml SUBDIRS += multi-output + SUBDIRS += multi-screen SUBDIRS += custom-extension SUBDIRS += server-buffer SUBDIRS += ivi-compositor -- cgit v1.2.3 From e3cc20df4290ef0364206e930ed43ae06bd6ed58 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Mon, 10 Oct 2016 18:01:43 +0200 Subject: Clients tests: Don't send leave events for destroyed surfaces Change-Id: Ia7dd13f629439b116f494ff8b7432020a65ea1df Reviewed-by: Paul Olav Tvete --- tests/auto/client/client/mockcompositor.cpp | 6 ++---- tests/auto/client/client/mockinput.cpp | 16 ++++++++++++++++ tests/auto/client/client/mockinput.h | 2 ++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/tests/auto/client/client/mockcompositor.cpp b/tests/auto/client/client/mockcompositor.cpp index 45a35ea7d..2c5f2541f 100644 --- a/tests/auto/client/client/mockcompositor.cpp +++ b/tests/auto/client/client/mockcompositor.cpp @@ -362,10 +362,8 @@ void Compositor::addSurface(Surface *surface) void Compositor::removeSurface(Surface *surface) { m_surfaces.removeOne(surface); - if (m_keyboard->focus() == surface) - m_keyboard->setFocus(0); - if (m_pointer->focus() == surface) - m_pointer->setFocus(0, QPoint()); + m_keyboard->handleSurfaceDestroyed(surface); + m_pointer->handleSurfaceDestroyed(surface); } } diff --git a/tests/auto/client/client/mockinput.cpp b/tests/auto/client/client/mockinput.cpp index fe06bf79b..99acdd43a 100644 --- a/tests/auto/client/client/mockinput.cpp +++ b/tests/auto/client/client/mockinput.cpp @@ -267,6 +267,14 @@ void Keyboard::setFocus(Surface *surface) m_focus = surface; } +void Keyboard::handleSurfaceDestroyed(Surface *surface) +{ + if (surface == m_focus) { + m_focusResource = nullptr; + m_focus = nullptr; + } +} + void Keyboard::sendKey(uint32_t key, uint32_t state) { if (m_focusResource) { @@ -314,6 +322,14 @@ void Pointer::setFocus(Surface *surface, const QPoint &pos) m_focus = surface; } +void Pointer::handleSurfaceDestroyed(Surface *surface) +{ + if (m_focus == surface) { + m_focus = nullptr; + m_focusResource = nullptr; + } +} + void Pointer::sendMotion(const QPoint &pos) { if (m_focusResource) diff --git a/tests/auto/client/client/mockinput.h b/tests/auto/client/client/mockinput.h index 031be2a4a..7e88ffb0f 100644 --- a/tests/auto/client/client/mockinput.h +++ b/tests/auto/client/client/mockinput.h @@ -75,6 +75,7 @@ public: Surface *focus() const { return m_focus; } void setFocus(Surface *surface); + void handleSurfaceDestroyed(Surface *surface); void sendKey(uint32_t key, uint32_t state); @@ -97,6 +98,7 @@ public: Surface *focus() const { return m_focus; } void setFocus(Surface *surface, const QPoint &pos); + void handleSurfaceDestroyed(Surface *surface); void sendMotion(const QPoint &pos); void sendButton(uint32_t button, uint32_t state); -- cgit v1.2.3 From 0049240a2b7d8691f09224e1542919ddbbb0d864 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Mon, 10 Oct 2016 17:52:15 +0200 Subject: Client: Remove windows from keyboard focus list when destroyed This fixes the undefined behavior in tst_WaylandClient::touchDrag and mouseDrag Note: The test still fails if run twice in a row, but it appears to be deterministic. Task-number: QTBUG-56187 Change-Id: Ib45d82224f004d1324f2ce4d6b7df05ee36c04f5 Reviewed-by: Paul Olav Tvete --- src/client/qwaylanddisplay.cpp | 6 ++++++ src/client/qwaylanddisplay_p.h | 3 ++- src/client/qwaylandwindow.cpp | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp index d94afcab5..3fd2aa565 100644 --- a/src/client/qwaylanddisplay.cpp +++ b/src/client/qwaylanddisplay.cpp @@ -422,6 +422,12 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic mLastKeyboardFocus = keyboardFocus; } +void QWaylandDisplay::handleWindowDestroyed(QWaylandWindow *window) +{ + if (mActiveWindows.contains(window)) + handleWindowDeactivated(window); +} + void QWaylandDisplay::handleWaylandSync() { // This callback is used to set the window activation because we may get an activate/deactivate diff --git a/src/client/qwaylanddisplay_p.h b/src/client/qwaylanddisplay_p.h index f4fb3fa56..2864b357d 100644 --- a/src/client/qwaylanddisplay_p.h +++ b/src/client/qwaylanddisplay_p.h @@ -176,6 +176,7 @@ public: void handleWindowActivated(QWaylandWindow *window); void handleWindowDeactivated(QWaylandWindow *window); void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice); + void handleWindowDestroyed(QWaylandWindow *window); public slots: void blockingReadEvents(); @@ -217,7 +218,7 @@ private: uint32_t mLastInputSerial; QWaylandInputDevice *mLastInputDevice; QPointer mLastInputWindow; - QWaylandWindow *mLastKeyboardFocus; + QPointer mLastKeyboardFocus; QVector mActiveWindows; struct wl_callback *mSyncCallback; static const wl_callback_listener syncCallbackListener; diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index 59c446bb3..2b7d81f88 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -102,6 +102,8 @@ QWaylandWindow::QWaylandWindow(QWindow *window) QWaylandWindow::~QWaylandWindow() { + mDisplay->handleWindowDestroyed(this); + delete mWindowDecoration; if (isInitialized()) -- cgit v1.2.3 From 582c6a379f6a45648352c538a7df4d675c9d0a65 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 11 Oct 2016 11:35:14 +0200 Subject: Don't try to deliver event to destroyed window Change-Id: If1c57250e2dc9e0d55767bbdfb15c3e3f5d9b333 Reviewed-by: Johan Helsing --- src/client/qwaylanddatadevice.cpp | 3 ++- src/client/qwaylanddatadevice_p.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/client/qwaylanddatadevice.cpp b/src/client/qwaylanddatadevice.cpp index 0ff1f1979..d04c20bf4 100644 --- a/src/client/qwaylanddatadevice.cpp +++ b/src/client/qwaylanddatadevice.cpp @@ -183,7 +183,8 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface, void QWaylandDataDevice::data_device_leave() { - QWindowSystemInterface::handleDrag(m_dragWindow, 0, QPoint(), Qt::IgnoreAction); + if (m_dragWindow) + QWindowSystemInterface::handleDrag(m_dragWindow, 0, QPoint(), Qt::IgnoreAction); QDrag *drag = static_cast(QGuiApplicationPrivate::platformIntegration()->drag())->currentDrag(); if (!drag) { diff --git a/src/client/qwaylanddatadevice_p.h b/src/client/qwaylanddatadevice_p.h index 579cb3c7c..7daa9f0d3 100644 --- a/src/client/qwaylanddatadevice_p.h +++ b/src/client/qwaylanddatadevice_p.h @@ -53,6 +53,7 @@ // #include +#include #include #include @@ -106,7 +107,7 @@ private: QWaylandDisplay *m_display; QWaylandInputDevice *m_inputDevice; uint32_t m_enterSerial; - QWindow *m_dragWindow; + QPointer m_dragWindow; QPoint m_dragPoint; QScopedPointer m_dragOffer; QScopedPointer m_selectionOffer; -- cgit v1.2.3 From 3443483c9efdcfbfe049f96c83f83a5bf1d81e61 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 29 Sep 2016 15:59:36 +0200 Subject: use modularized platformsupport modules Change-Id: I7883470e22deb089240d86df7dc2d625a107a53e Reviewed-by: Lars Knoll --- src/client/client.pro | 9 +++++++-- src/client/qwaylandintegration.cpp | 6 +++--- src/client/qwaylandwindowmanagerintegration_p.h | 2 +- .../client/brcm-egl/qwaylandbrcmeglwindow.cpp | 2 +- .../client/brcm-egl/qwaylandbrcmglcontext.cpp | 2 +- src/hardwareintegration/client/wayland-egl/qwaylandeglinclude.h | 2 +- src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp | 2 +- src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp | 2 +- src/hardwareintegration/client/wayland-egl/wayland-egl.pri | 2 +- .../qwaylandxcompositeeglclientbufferintegration.cpp | 2 +- .../client/xcomposite-egl/qwaylandxcompositeeglcontext.cpp | 2 +- .../client/xcomposite-egl/qwaylandxcompositeeglcontext.h | 2 +- .../client/xcomposite-egl/qwaylandxcompositeeglwindow.cpp | 4 ++-- src/hardwareintegration/client/xcomposite-egl/xcomposite-egl.pri | 2 +- .../client/xcomposite-glx/qwaylandxcompositeglxcontext.h | 2 +- src/hardwareintegration/client/xcomposite-glx/xcomposite-glx.pri | 2 +- src/hardwareintegration/compositor/wayland-egl/wayland-egl.pri | 1 + .../compositor/wayland-egl/waylandeglclientbufferintegration.cpp | 2 +- .../hardwareintegration/compositor/wayland-egl/wayland-egl.pro | 2 +- 19 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/client/client.pro b/src/client/client.pro index fa2036745..34955dfbb 100644 --- a/src/client/client.pro +++ b/src/client/client.pro @@ -2,13 +2,18 @@ TARGET = QtWaylandClient MODULE = waylandclient QT += core-private gui-private -QT_FOR_PRIVATE += platformsupport-private +QT_FOR_PRIVATE += service_support-private +QT_PRIVATE += fontdatabase_support-private eventdispatcher_support-private theme_support-private # We have a bunch of C code with casts, so we can't have this option QMAKE_CXXFLAGS_WARN_ON -= -Wcast-qual +# Prevent gold linker from crashing. +# This started happening when QtPlatformSupport was modularized. +use_gold_linker: CONFIG += no_linker_version_script + CONFIG -= precompile_header -CONFIG += link_pkgconfig qpa/genericunixfontdatabase wayland-scanner +CONFIG += link_pkgconfig wayland-scanner contains(QT_CONFIG, opengl) { DEFINES += QT_WAYLAND_GL_SUPPORT diff --git a/src/client/qwaylandintegration.cpp b/src/client/qwaylandintegration.cpp index 0e9eb44d6..48517fce1 100644 --- a/src/client/qwaylandintegration.cpp +++ b/src/client/qwaylandintegration.cpp @@ -50,9 +50,9 @@ #include "qwaylandwindowmanagerintegration_p.h" #include "qwaylandscreen_p.h" -#include "QtPlatformSupport/private/qgenericunixfontdatabase_p.h" -#include -#include +#include +#include +#include #include diff --git a/src/client/qwaylandwindowmanagerintegration_p.h b/src/client/qwaylandwindowmanagerintegration_p.h index 0e5f67ac1..09a79d48d 100644 --- a/src/client/qwaylandwindowmanagerintegration_p.h +++ b/src/client/qwaylandwindowmanagerintegration_p.h @@ -55,7 +55,7 @@ #include #include -#include +#include #include #include diff --git a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.cpp b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.cpp index fe7e17e86..4d56d66e6 100644 --- a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.cpp +++ b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.cpp @@ -43,7 +43,7 @@ #include #include "qwaylandbrcmglcontext.h" -#include +#include #include #include diff --git a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.cpp b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.cpp index a14f6b024..f5480b0ed 100644 --- a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.cpp +++ b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.cpp @@ -43,7 +43,7 @@ #include #include "qwaylandbrcmeglwindow.h" -#include +#include #include #include diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglinclude.h b/src/hardwareintegration/client/wayland-egl/qwaylandeglinclude.h index 024809ff6..233ce78bd 100644 --- a/src/hardwareintegration/client/wayland-egl/qwaylandeglinclude.h +++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglinclude.h @@ -46,6 +46,6 @@ #include #define EGL_EGLEXT_PROTOTYPES -#include +#include #endif // QWAYLANDEGLINCLUDE_H diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp index 417fc75bd..236218e7f 100644 --- a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp +++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp @@ -42,7 +42,7 @@ #include #include "qwaylandglcontext.h" -#include +#include #include #include diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp index 72e7b0e6a..f70c75a33 100644 --- a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp +++ b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp @@ -47,7 +47,7 @@ #include "qwaylandeglwindow.h" #include -#include +#include #include #include #include diff --git a/src/hardwareintegration/client/wayland-egl/wayland-egl.pri b/src/hardwareintegration/client/wayland-egl/wayland-egl.pri index 520c1eb0f..276b7b54f 100644 --- a/src/hardwareintegration/client/wayland-egl/wayland-egl.pri +++ b/src/hardwareintegration/client/wayland-egl/wayland-egl.pri @@ -8,7 +8,7 @@ INCLUDEPATH += $$PWD DEFINES += QT_EGL_WAYLAND CONFIG += egl -QT += platformsupport-private +QT += egl_support-private SOURCES += $$PWD/qwaylandeglclientbufferintegration.cpp \ $$PWD/qwaylandglcontext.cpp \ diff --git a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglclientbufferintegration.cpp b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglclientbufferintegration.cpp index 5fca5610a..2a7de6b72 100644 --- a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglclientbufferintegration.cpp +++ b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglclientbufferintegration.cpp @@ -42,7 +42,7 @@ #include "qwaylandxcompositeeglwindow.h" #include -#include +#include #include diff --git a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglcontext.cpp b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglcontext.cpp index 0194878a3..e2e2f5519 100644 --- a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglcontext.cpp +++ b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglcontext.cpp @@ -44,7 +44,7 @@ #include #include -#include +#include QT_BEGIN_NAMESPACE diff --git a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglcontext.h b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglcontext.h index f655dee21..83a643757 100644 --- a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglcontext.h +++ b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglcontext.h @@ -44,7 +44,7 @@ #include "qwaylandxcompositeeglclientbufferintegration.h" -#include +#include QT_BEGIN_NAMESPACE diff --git a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglwindow.cpp b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglwindow.cpp index f9b6fc1de..cfc0cda10 100644 --- a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglwindow.cpp +++ b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglwindow.cpp @@ -40,8 +40,8 @@ #include "qwaylandxcompositeeglwindow.h" #include "qwaylandxcompositebuffer.h" -#include -#include +#include +#include #include "wayland-xcomposite-client-protocol.h" diff --git a/src/hardwareintegration/client/xcomposite-egl/xcomposite-egl.pri b/src/hardwareintegration/client/xcomposite-egl/xcomposite-egl.pri index 52653c4ae..3a5fcb543 100644 --- a/src/hardwareintegration/client/xcomposite-egl/xcomposite-egl.pri +++ b/src/hardwareintegration/client/xcomposite-egl/xcomposite-egl.pri @@ -8,7 +8,7 @@ include($$PWD/../xcomposite_share/xcomposite_share.pri) LIBS += -lXcomposite -lX11 } -QT += platformsupport-private +QT += egl_support-private CONFIG += egl SOURCES += \ diff --git a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxcontext.h b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxcontext.h index 862ed928b..5847ea976 100644 --- a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxcontext.h +++ b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxcontext.h @@ -43,7 +43,7 @@ #include #include "qwaylandxcompositeglxintegration.h" -#include +#include QT_BEGIN_NAMESPACE diff --git a/src/hardwareintegration/client/xcomposite-glx/xcomposite-glx.pri b/src/hardwareintegration/client/xcomposite-glx/xcomposite-glx.pri index 11c051728..bc072bf05 100644 --- a/src/hardwareintegration/client/xcomposite-glx/xcomposite-glx.pri +++ b/src/hardwareintegration/client/xcomposite-glx/xcomposite-glx.pri @@ -8,7 +8,7 @@ include ($$PWD/../xcomposite_share/xcomposite_share.pri) LIBS += -lXcomposite -lGL -lX11 } -QT += platformsupport-private +QT += glx_support-private SOURCES += \ $$PWD/qwaylandxcompositeglxcontext.cpp \ diff --git a/src/hardwareintegration/compositor/wayland-egl/wayland-egl.pri b/src/hardwareintegration/compositor/wayland-egl/wayland-egl.pri index 8dacc130b..f36474890 100644 --- a/src/hardwareintegration/compositor/wayland-egl/wayland-egl.pri +++ b/src/hardwareintegration/compositor/wayland-egl/wayland-egl.pri @@ -8,6 +8,7 @@ INCLUDEPATH += $$PWD } CONFIG += egl +QT += egl_support-private SOURCES += \ $$PWD/waylandeglclientbufferintegration.cpp diff --git a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp index 3814442c4..8b87db971 100644 --- a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp +++ b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp @@ -49,7 +49,7 @@ #include #include #include -#include +#include #ifndef GL_TEXTURE_EXTERNAL_OES #define GL_TEXTURE_EXTERNAL_OES 0x8D65 diff --git a/src/plugins/hardwareintegration/compositor/wayland-egl/wayland-egl.pro b/src/plugins/hardwareintegration/compositor/wayland-egl/wayland-egl.pro index 7374a5982..9ddd961c7 100644 --- a/src/plugins/hardwareintegration/compositor/wayland-egl/wayland-egl.pro +++ b/src/plugins/hardwareintegration/compositor/wayland-egl/wayland-egl.pro @@ -1,4 +1,4 @@ -QT = waylandcompositor waylandcompositor-private core-private gui-private platformsupport-private +QT = waylandcompositor waylandcompositor-private core-private gui-private OTHER_FILES += wayland-egl.json -- cgit v1.2.3 From c4ad427523313c2ad9d773501fdc43bffe240f08 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Tue, 1 Nov 2016 10:42:21 +0100 Subject: Compositor: Switch keyboard focus on touch input When touchEventsEnabled is set to true on ShellSurfaceItem, touching a client did not switch the keyboard focus to that client. Consequently, touching inside a TextField would not switch the focus to that client, causing keyboard and virtual keyboard input to be delivered to the wrong client. Task-number: QTBUG-56836 Change-Id: I47134dfeb80d25e995baf91e51977dacb7087bb7 Reviewed-by: Paul Olav Tvete --- src/compositor/compositor_api/qwaylandquickitem.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp index f0454b72c..e6cfce343 100644 --- a/src/compositor/compositor_api/qwaylandquickitem.cpp +++ b/src/compositor/compositor_api/qwaylandquickitem.cpp @@ -653,6 +653,9 @@ void QWaylandQuickItem::touchEvent(QTouchEvent *event) seat->sendMouseMoveEvent(d->view.data(), pointPos, mapToScene(pointPos)); } seat->sendFullTouchEvent(surface(), event); + + if (event->type() == QEvent::TouchBegin && d->focusOnClick) + takeFocus(seat); } else { event->ignore(); } @@ -921,7 +924,7 @@ void QWaylandQuickItem::updateSize() * \qmlproperty bool QtWaylandCompositor::WaylandQuickItem::focusOnClick * * This property specifies whether the WaylandQuickItem should take focus when - * it is clicked. + * it is clicked or touched. * * The default is \c true. */ @@ -930,7 +933,7 @@ void QWaylandQuickItem::updateSize() * \property QWaylandQuickItem::focusOnClick * * This property specifies whether the QWaylandQuickItem should take focus when - * it is clicked. + * it is clicked or touched. * * The default is \c true. */ -- cgit v1.2.3 From 5f264935a42ed56f46b6d0a38f30700429396ac9 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Tue, 1 Nov 2016 13:04:07 +0100 Subject: QML Compositors: Switch touch events on by default Previously sending multi-touch to clients would only be possible after setting touchEventsEnabled on ShellSurffaceItem. Change-Id: I53b9d024ceee0abfe35d9761a5ddbec2b91a37db Reviewed-by: Paul Olav Tvete Reviewed-by: Pier Luigi Fiorini --- src/compositor/compositor_api/qwaylandquickitem_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compositor/compositor_api/qwaylandquickitem_p.h b/src/compositor/compositor_api/qwaylandquickitem_p.h index c30829926..5eba99572 100644 --- a/src/compositor/compositor_api/qwaylandquickitem_p.h +++ b/src/compositor/compositor_api/qwaylandquickitem_p.h @@ -110,7 +110,7 @@ public: , oldSurface(Q_NULLPTR) , provider(Q_NULLPTR) , paintEnabled(true) - , touchEventsEnabled(false) + , touchEventsEnabled(true) , inputEventsEnabled(true) , isDragging(false) , newTexture(false) -- cgit v1.2.3 From e05f6c01d2ac4b807c07a682927f75d70292595b Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Mon, 10 Oct 2016 16:26:24 +0200 Subject: Fix memory leaks Several fields in QWaylandIntegration were never deleted, so use QScopedPointer to handle that. Also use QScopedPointer for all the heap allocated fields of the class. Change-Id: I4c33be4157a6e17abfa1610f84ef9a88afe5f38a Reviewed-by: Pier Luigi Fiorini Reviewed-by: Johan Helsing --- src/client/qwaylandintegration.cpp | 65 ++++++++++++++++---------------------- src/client/qwaylandintegration_p.h | 22 +++++++------ 2 files changed, 40 insertions(+), 47 deletions(-) diff --git a/src/client/qwaylandintegration.cpp b/src/client/qwaylandintegration.cpp index 48517fce1..3e2630610 100644 --- a/src/client/qwaylandintegration.cpp +++ b/src/client/qwaylandintegration.cpp @@ -119,7 +119,6 @@ public: QWaylandIntegration::QWaylandIntegration() : mClientBufferIntegration(0) - , mShellIntegration(Q_NULLPTR) , mInputDeviceIntegration(Q_NULLPTR) , mFontDb(new QGenericUnixFontDatabase()) , mNativeInterface(new QWaylandNativeInterface(this)) @@ -131,16 +130,16 @@ QWaylandIntegration::QWaylandIntegration() , mShellIntegrationInitialized(false) { initializeInputDeviceIntegration(); - mDisplay = new QWaylandDisplay(this); - mClipboard = new QWaylandClipboard(mDisplay); - mDrag = new QWaylandDrag(mDisplay); + mDisplay.reset(new QWaylandDisplay(this)); + mClipboard.reset(new QWaylandClipboard(mDisplay.data())); + mDrag.reset(new QWaylandDrag(mDisplay.data())); QString icStr = QPlatformInputContextFactory::requested(); if (!icStr.isNull()) { mInputContext.reset(QPlatformInputContextFactory::create(icStr)); } else { //try to use the input context using the wl_text_input interface - QPlatformInputContext *ctx = new QWaylandInputContext(mDisplay); + QPlatformInputContext *ctx = new QWaylandInputContext(mDisplay.data()); mInputContext.reset(ctx); //use the traditional way for on screen keyboards for now @@ -153,18 +152,11 @@ QWaylandIntegration::QWaylandIntegration() QWaylandIntegration::~QWaylandIntegration() { - delete mDrag; - delete mClipboard; -#ifndef QT_NO_ACCESSIBILITY - delete mAccessibility; -#endif - delete mNativeInterface; - delete mDisplay; } QPlatformNativeInterface * QWaylandIntegration::nativeInterface() const { - return mNativeInterface; + return mNativeInterface.data(); } bool QWaylandIntegration::hasCapability(QPlatformIntegration::Capability cap) const @@ -217,27 +209,27 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const void QWaylandIntegration::initialize() { QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher; - QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay, SLOT(flushRequests())); - QObject::connect(dispatcher, SIGNAL(awake()), mDisplay, SLOT(flushRequests())); + QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests())); + QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests())); int fd = wl_display_get_fd(mDisplay->wl_display()); - QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay); - QObject::connect(sn, SIGNAL(activated(int)), mDisplay, SLOT(flushRequests())); + QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data()); + QObject::connect(sn, SIGNAL(activated(int)), mDisplay.data(), SLOT(flushRequests())); } QPlatformFontDatabase *QWaylandIntegration::fontDatabase() const { - return mFontDb; + return mFontDb.data(); } QPlatformClipboard *QWaylandIntegration::clipboard() const { - return mClipboard; + return mClipboard.data(); } QPlatformDrag *QWaylandIntegration::drag() const { - return mDrag; + return mDrag.data(); } QPlatformInputContext *QWaylandIntegration::inputContext() const @@ -263,7 +255,7 @@ QVariant QWaylandIntegration::styleHint(StyleHint hint) const #ifndef QT_NO_ACCESSIBILITY QPlatformAccessibility *QWaylandIntegration::accessibility() const { - return mAccessibility; + return mAccessibility.data(); } #endif @@ -274,7 +266,7 @@ QPlatformServices *QWaylandIntegration::services() const QWaylandDisplay *QWaylandIntegration::display() const { - return mDisplay; + return mDisplay.data(); } QStringList QWaylandIntegration::themeNames() const @@ -292,7 +284,7 @@ QWaylandClientBufferIntegration *QWaylandIntegration::clientBufferIntegration() if (!mClientBufferIntegrationInitialized) const_cast(this)->initializeClientBufferIntegration(); - return mClientBufferIntegration && mClientBufferIntegration->isValid() ? mClientBufferIntegration : 0; + return mClientBufferIntegration && mClientBufferIntegration->isValid() ? mClientBufferIntegration.data() : nullptr; } QWaylandServerBufferIntegration *QWaylandIntegration::serverBufferIntegration() const @@ -300,7 +292,7 @@ QWaylandServerBufferIntegration *QWaylandIntegration::serverBufferIntegration() if (!mServerBufferIntegrationInitialized) const_cast(this)->initializeServerBufferIntegration(); - return mServerBufferIntegration; + return mServerBufferIntegration.data(); } QWaylandShellIntegration *QWaylandIntegration::shellIntegration() const @@ -308,7 +300,7 @@ QWaylandShellIntegration *QWaylandIntegration::shellIntegration() const if (!mShellIntegrationInitialized) const_cast(this)->initializeShellIntegration(); - return mShellIntegration; + return mShellIntegration.data(); } void QWaylandIntegration::initializeClientBufferIntegration() @@ -334,10 +326,10 @@ void QWaylandIntegration::initializeClientBufferIntegration() QStringList keys = QWaylandClientBufferIntegrationFactory::keys(); if (keys.contains(targetKey)) { - mClientBufferIntegration = QWaylandClientBufferIntegrationFactory::create(targetKey, QStringList()); + mClientBufferIntegration.reset(QWaylandClientBufferIntegrationFactory::create(targetKey, QStringList())); } if (mClientBufferIntegration) - mClientBufferIntegration->initialize(mDisplay); + mClientBufferIntegration->initialize(mDisplay.data()); else qWarning("Failed to load client buffer integration: %s\n", qPrintable(targetKey)); } @@ -364,10 +356,10 @@ void QWaylandIntegration::initializeServerBufferIntegration() QStringList keys = QWaylandServerBufferIntegrationFactory::keys(); if (keys.contains(targetKey)) { - mServerBufferIntegration = QWaylandServerBufferIntegrationFactory::create(targetKey, QStringList()); + mServerBufferIntegration.reset(QWaylandServerBufferIntegrationFactory::create(targetKey, QStringList())); } if (mServerBufferIntegration) - mServerBufferIntegration->initialize(mDisplay); + mServerBufferIntegration->initialize(mDisplay.data()); else qWarning("Failed to load server buffer integration %s\n", qPrintable(targetKey)); } @@ -383,7 +375,7 @@ void QWaylandIntegration::initializeShellIntegration() QStringList keys = QWaylandShellIntegrationFactory::keys(); if (keys.contains(targetKey)) { qDebug("Using the '%s' shell integration", qPrintable(targetKey)); - mShellIntegration = QWaylandShellIntegrationFactory::create(targetKey, QStringList()); + mShellIntegration.reset(QWaylandShellIntegrationFactory::create(targetKey, QStringList())); } } else { QStringList preferredShells; @@ -393,15 +385,14 @@ void QWaylandIntegration::initializeShellIntegration() Q_FOREACH (QString preferredShell, preferredShells) { if (mDisplay->hasRegistryGlobal(preferredShell)) { - mShellIntegration = createShellIntegration(preferredShell); + mShellIntegration.reset(createShellIntegration(preferredShell)); break; } } } - if (!mShellIntegration || !mShellIntegration->initialize(mDisplay)) { - delete mShellIntegration; - mShellIntegration = Q_NULLPTR; + if (!mShellIntegration || !mShellIntegration->initialize(mDisplay.data())) { + mShellIntegration.reset(); qWarning("Failed to load shell integration %s", qPrintable(targetKey)); } } @@ -425,7 +416,7 @@ void QWaylandIntegration::initializeInputDeviceIntegration() QStringList keys = QWaylandInputDeviceIntegrationFactory::keys(); if (keys.contains(targetKey)) { - mInputDeviceIntegration = QWaylandInputDeviceIntegrationFactory::create(targetKey, QStringList()); + mInputDeviceIntegration.reset(QWaylandInputDeviceIntegrationFactory::create(targetKey, QStringList())); qDebug("Using the '%s' input device integration", qPrintable(targetKey)); } else { qWarning("Wayland inputdevice integration '%s' not found, using default", qPrintable(targetKey)); @@ -435,9 +426,9 @@ void QWaylandIntegration::initializeInputDeviceIntegration() QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &interfaceName) { if (interfaceName == QLatin1Literal("wl_shell")) { - return new QWaylandWlShellIntegration(mDisplay); + return new QWaylandWlShellIntegration(mDisplay.data()); } else if (interfaceName == QLatin1Literal("xdg_shell")) { - return new QWaylandXdgShellIntegration(mDisplay); + return new QWaylandXdgShellIntegration(mDisplay.data()); } else { return Q_NULLPTR; } diff --git a/src/client/qwaylandintegration_p.h b/src/client/qwaylandintegration_p.h index 9a4990229..bd66f55a7 100644 --- a/src/client/qwaylandintegration_p.h +++ b/src/client/qwaylandintegration_p.h @@ -54,6 +54,8 @@ #include #include +#include + QT_BEGIN_NAMESPACE namespace QtWaylandClient { @@ -113,10 +115,10 @@ public: virtual QWaylandShellIntegration *shellIntegration() const; protected: - QWaylandClientBufferIntegration *mClientBufferIntegration; - QWaylandServerBufferIntegration *mServerBufferIntegration; - QWaylandShellIntegration *mShellIntegration; - QWaylandInputDeviceIntegration *mInputDeviceIntegration; + QScopedPointer mClientBufferIntegration; + QScopedPointer mServerBufferIntegration; + QScopedPointer mShellIntegration; + QScopedPointer mInputDeviceIntegration; private: void initializeClientBufferIntegration(); @@ -125,14 +127,14 @@ private: void initializeInputDeviceIntegration(); QWaylandShellIntegration *createShellIntegration(const QString& interfaceName); - QPlatformFontDatabase *mFontDb; - QPlatformClipboard *mClipboard; - QPlatformDrag *mDrag; - QWaylandDisplay *mDisplay; - QPlatformNativeInterface *mNativeInterface; + QScopedPointer mFontDb; + QScopedPointer mClipboard; + QScopedPointer mDrag; + QScopedPointer mDisplay; + QScopedPointer mNativeInterface; QScopedPointer mInputContext; #ifndef QT_NO_ACCESSIBILITY - QPlatformAccessibility *mAccessibility; + QScopedPointer mAccessibility; #endif bool mClientBufferIntegrationInitialized; bool mServerBufferIntegrationInitialized; -- cgit v1.2.3