Source

Target

Commits (10)
Showing with 230 additions and 82 deletions
......@@ -3,7 +3,7 @@
The Qt Toolkit is Copyright (C) 2015 The Qt Company Ltd.
Contact: http://www.qt.io/licensing/
You may use, distribute and copy the Qt GUI Toolkit under the terms of
You may use, distribute and copy the Qt Toolkit under the terms of
GNU Lesser General Public License version 3. That license references
the General Public License version 3, that is displayed below. Other
portions of the Qt Toolkit may be licensed directly under this license.
......
......@@ -3,7 +3,7 @@
The Qt Toolkit is Copyright (C) 2015 The Qt Company Ltd.
Contact: http://www.qt.io/licensing/
You may use, distribute and copy the Qt GUI Toolkit under the terms of
You may use, distribute and copy the Qt Toolkit under the terms of
GNU Lesser General Public License version 2.1, which is displayed below.
-------------------------------------------------------------------------
......
......@@ -3,7 +3,7 @@
The Qt Toolkit is Copyright (C) 2015 The Qt Company Ltd.
Contact: http://www.qt.io/licensing/
You may use, distribute and copy the Qt GUI Toolkit under the terms of
You may use, distribute and copy the Qt Toolkit under the terms of
GNU Lesser General Public License version 3, which is displayed below.
This license makes reference to the version 3 of the GNU General
Public License, which you can find in the LICENSE.GPLv3 file.
......
/****************************************************************************
**
** 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 <QtCore/QUrl>
#include <QtCore/QDebug>
#include <QtGui/QGuiApplication>
#include <QtQml/QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine appEngine(QUrl("qrc:///main.qml"));
return app.exec();
}
/****************************************************************************
**
** 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.6
import QtQuick.Window 2.2
import QtWayland.Compositor 1.0
WaylandCompositor {
id: wlcompositor
// The output defines the screen.
WaylandOutput {
compositor: wlcompositor
window: Window {
width: 1024
height: 768
visible: true
WaylandMouseTracker {
anchors.fill: parent
enableWSCursor: true
Rectangle {
id: surfaceArea
color: "#1337af"
anchors.fill: parent
}
}
}
}
// The chrome defines the window look and behavior.
// Here we use the built-in ShellSurfaceItem.
Component {
id: chromeComponent
ShellSurfaceItem {
onSurfaceDestroyed: destroy()
}
}
// Extensions are additions to the core Wayland
// protocol. We choose to support two different
// shells (window management protocols). When the
// client creates a new window, we instantiate a
// chromeComponent on the output.
extensions: [
WlShell {
onShellSurfaceCreated:
chromeComponent.createObject(surfaceArea, { "shellSurface": shellSurface } );
},
XdgShell {
onXdgSurfaceCreated:
chromeComponent.createObject(surfaceArea, { "shellSurface": xdgSurface } );
}
]
}
QT += gui qml
SOURCES += \
main.cpp
OTHER_FILES = \
main.qml
RESOURCES += minimal-qml.qrc
target.path = $$[QT_INSTALL_EXAMPLES]/wayland/minimal-qml
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS minimal-qml.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/wayland/minimal-qml
INSTALLS += target sources
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
</RCC>
......@@ -4,6 +4,7 @@ SUBDIRS += qwindow-compositor
SUBDIRS += minimal-cpp
qtHaveModule(quick) {
SUBDIRS += minimal-qml
SUBDIRS += pure-qml
SUBDIRS += multi-output
SUBDIRS += custom-extension
......
......@@ -69,8 +69,8 @@ public:
QString serverBufferIntegration();
protected:
void hardware_integration_client_backend(const QString &name);
void hardware_integration_server_backend(const QString &name);
void hardware_integration_client_backend(const QString &name) Q_DECL_OVERRIDE;
void hardware_integration_server_backend(const QString &name) Q_DECL_OVERRIDE;
private:
QString m_client_buffer;
......
......@@ -110,7 +110,10 @@ const QImage &QWaylandAbstractDecoration::contentImage()
if (d->m_isDirty) {
//Update the decoration backingstore
d->m_decorationContentImage = QImage(window()->frameGeometry().size(), QImage::Format_ARGB32_Premultiplied);
const int scale = waylandWindow()->scale();
const QSize imageSize = window()->frameGeometry().size() * scale;
d->m_decorationContentImage = QImage(imageSize, QImage::Format_ARGB32_Premultiplied);
d->m_decorationContentImage.setDevicePixelRatio(scale);
d->m_decorationContentImage.fill(Qt::transparent);
this->paint(&d->m_decorationContentImage);
......
......@@ -73,10 +73,10 @@ public:
QWaylandCursor(QWaylandScreen *screen);
~QWaylandCursor();
void changeCursor(QCursor *cursor, QWindow *window);
void pointerEvent(const QMouseEvent &event);
QPoint pos() const;
void setPos(const QPoint &pos);
void changeCursor(QCursor *cursor, QWindow *window) Q_DECL_OVERRIDE;
void pointerEvent(const QMouseEvent &event) Q_DECL_OVERRIDE;
QPoint pos() const Q_DECL_OVERRIDE;
void setPos(const QPoint &pos) Q_DECL_OVERRIDE;
struct wl_cursor_image *cursorImage(Qt::CursorShape shape);
QSharedPointer<QWaylandBuffer> cursorBitmapImage(const QCursor *cursor);
......
......@@ -156,31 +156,29 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
m_dragWindow = QWaylandWindow::fromWlSurface(surface)->window();
m_dragPoint = calculateDragPosition(x, y, m_dragWindow);
QDrag *drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->currentDrag();
QMimeData *dragData = Q_NULLPTR;
Qt::DropActions supportedActions;
m_dragOffer.reset(static_cast<QWaylandDataOffer *>(wl_data_offer_get_user_data(id)));
QDrag *drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->currentDrag();
if (drag) {
dragData = drag->mimeData();
supportedActions = drag->supportedActions();
} else {
m_dragOffer.reset(static_cast<QWaylandDataOffer *>(wl_data_offer_get_user_data(id)));
if (m_dragOffer) {
dragData = m_dragOffer->mimeData();
supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
}
} else if (m_dragOffer) {
dragData = m_dragOffer->mimeData();
supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
}
const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions);
if (drag) {
static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
}
if (response.isAccepted()) {
wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
} else {
if (response.isAccepted()) {
wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
} else {
wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, 0);
}
wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, 0);
}
}
......@@ -219,12 +217,12 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
if (drag) {
static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
}
if (response.isAccepted()) {
wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
} else {
if (response.isAccepted()) {
wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
} else {
wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, 0);
}
wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, 0);
}
}
......
......@@ -125,19 +125,8 @@ QWaylandWindowManagerIntegration *QWaylandDisplay::windowManagerIntegration() co
return mWindowManagerIntegration.data();
}
QWaylandInputDevice *QWaylandDisplay::lastKeyboardFocusInputDevice() const
{
return mLastKeyboardFocusInputDevice;
}
void QWaylandDisplay::setLastKeyboardFocusInputDevice(QWaylandInputDevice *device)
{
mLastKeyboardFocusInputDevice = device;
}
QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
: mWaylandIntegration(waylandIntegration)
, mLastKeyboardFocusInputDevice(0)
, mDndSelectionHandler(0)
, mWindowExtension(0)
, mSubCompositor(0)
......
......@@ -140,9 +140,6 @@ public:
QWaylandInputDevice *defaultInputDevice() const;
QWaylandInputDevice *currentInputDevice() const { return defaultInputDevice(); }
QWaylandInputDevice *lastKeyboardFocusInputDevice() const;
void setLastKeyboardFocusInputDevice(QWaylandInputDevice *device);
QWaylandDataDeviceManager *dndSelectionHandler() const { return mDndSelectionHandler.data(); }
QtWayland::qt_surface_extension *windowExtension() const { return mWindowExtension.data(); }
......@@ -200,7 +197,6 @@ private:
QList<QWaylandInputDevice *> mInputDevices;
QList<Listener> mRegistryListeners;
QWaylandIntegration *mWaylandIntegration;
QWaylandInputDevice *mLastKeyboardFocusInputDevice;
QScopedPointer<QWaylandDataDeviceManager> mDndSelectionHandler;
QScopedPointer<QtWayland::qt_surface_extension> mWindowExtension;
QScopedPointer<QtWayland::wl_subcompositor> mSubCompositor;
......
......@@ -656,7 +656,6 @@ void QWaylandInputDevice::Keyboard::focusCallback(void *data, struct wl_callback
self->mFocusCallback = 0;
}
self->mParent->mQDisplay->setLastKeyboardFocusInputDevice(self->mFocus ? self->mParent : 0);
QWindowSystemInterface::handleWindowActivated(self->mFocus ? self->mFocus->window() : 0);
}
......
......@@ -234,7 +234,7 @@ public:
void pointer_enter(uint32_t serial, struct wl_surface *surface,
wl_fixed_t sx, wl_fixed_t sy) Q_DECL_OVERRIDE;
void pointer_leave(uint32_t time, struct wl_surface *surface);
void pointer_leave(uint32_t time, struct wl_surface *surface) Q_DECL_OVERRIDE;
void pointer_motion(uint32_t time,
wl_fixed_t sx, wl_fixed_t sy) Q_DECL_OVERRIDE;
void pointer_button(uint32_t serial, uint32_t time,
......
......@@ -72,37 +72,37 @@ public:
QWaylandIntegration();
~QWaylandIntegration();
bool hasCapability(QPlatformIntegration::Capability cap) const;
QPlatformWindow *createPlatformWindow(QWindow *window) const;
bool hasCapability(QPlatformIntegration::Capability cap) const Q_DECL_OVERRIDE;
QPlatformWindow *createPlatformWindow(QWindow *window) const Q_DECL_OVERRIDE;
#ifndef QT_NO_OPENGL
QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const;
QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const Q_DECL_OVERRIDE;
#endif
QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const;
QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const Q_DECL_OVERRIDE;
QAbstractEventDispatcher *createEventDispatcher() const;
void initialize();
QAbstractEventDispatcher *createEventDispatcher() const Q_DECL_OVERRIDE;
void initialize() Q_DECL_OVERRIDE;
QPlatformFontDatabase *fontDatabase() const;
QPlatformFontDatabase *fontDatabase() const Q_DECL_OVERRIDE;
QPlatformNativeInterface *nativeInterface() const;
QPlatformNativeInterface *nativeInterface() const Q_DECL_OVERRIDE;
QPlatformClipboard *clipboard() const;
QPlatformClipboard *clipboard() const Q_DECL_OVERRIDE;
QPlatformDrag *drag() const;
QPlatformDrag *drag() const Q_DECL_OVERRIDE;
QPlatformInputContext *inputContext() const;
QPlatformInputContext *inputContext() const Q_DECL_OVERRIDE;
QVariant styleHint(StyleHint hint) const;
QVariant styleHint(StyleHint hint) const Q_DECL_OVERRIDE;
QPlatformAccessibility *accessibility() const;
QPlatformAccessibility *accessibility() const Q_DECL_OVERRIDE;
QPlatformServices *services() const;
QPlatformServices *services() const Q_DECL_OVERRIDE;
QWaylandDisplay *display() const;
QStringList themeNames() const;
QStringList themeNames() const Q_DECL_OVERRIDE;
QPlatformTheme *createPlatformTheme(const QString &name) const;
QPlatformTheme *createPlatformTheme(const QString &name) const Q_DECL_OVERRIDE;
QWaylandInputDevice *createInputDevice(QWaylandDisplay *display, int version, uint32_t id);
......
......@@ -67,17 +67,17 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandNativeInterface : public QPlatformNativeIn
{
public:
QWaylandNativeInterface(QWaylandIntegration *integration);
void *nativeResourceForIntegration(const QByteArray &resource);
void *nativeResourceForIntegration(const QByteArray &resource) Q_DECL_OVERRIDE;
void *nativeResourceForWindow(const QByteArray &resourceString,
QWindow *window);
QWindow *window) Q_DECL_OVERRIDE;
void *nativeResourceForScreen(const QByteArray &resourceString,
QScreen *screen);
void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context);
QScreen *screen) Q_DECL_OVERRIDE;
void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) Q_DECL_OVERRIDE;
QVariantMap windowProperties(QPlatformWindow *window) const;
QVariant windowProperty(QPlatformWindow *window, const QString &name) const;
QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const;
void setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value);
QVariantMap windowProperties(QPlatformWindow *window) const Q_DECL_OVERRIDE;
QVariant windowProperty(QPlatformWindow *window, const QString &name) const Q_DECL_OVERRIDE;
QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const Q_DECL_OVERRIDE;
void setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value) Q_DECL_OVERRIDE;
void emitWindowPropertyChanged(QPlatformWindow *window, const QString &name);
......
......@@ -72,25 +72,25 @@ public:
void init();
QWaylandDisplay *display() const;
QRect geometry() const;
int depth() const;
QImage::Format format() const;
QRect geometry() const Q_DECL_OVERRIDE;
int depth() const Q_DECL_OVERRIDE;
QImage::Format format() const Q_DECL_OVERRIDE;
QSizeF physicalSize() const Q_DECL_OVERRIDE;
QDpi logicalDpi() const Q_DECL_OVERRIDE;
QList<QPlatformScreen *> virtualSiblings() const Q_DECL_OVERRIDE;
void setOrientationUpdateMask(Qt::ScreenOrientations mask);
void setOrientationUpdateMask(Qt::ScreenOrientations mask) Q_DECL_OVERRIDE;
Qt::ScreenOrientation orientation() const;
Qt::ScreenOrientation orientation() const Q_DECL_OVERRIDE;
int scale() const;
qreal devicePixelRatio() const Q_DECL_OVERRIDE;
qreal refreshRate() const;
qreal refreshRate() const Q_DECL_OVERRIDE;
QString name() const { return mOutputName; }
QString name() const Q_DECL_OVERRIDE { return mOutputName; }
QPlatformCursor *cursor() const;
QPlatformCursor *cursor() const Q_DECL_OVERRIDE;
QWaylandCursor *waylandCursor() const { return mWaylandCursor; };
uint32_t outputId() const { return m_outputId; }
......
......@@ -72,7 +72,7 @@ public:
QWaylandShmBuffer(QWaylandDisplay *display,
const QSize &size, QImage::Format format, int scale = 1);
~QWaylandShmBuffer();
QSize size() const { return mImage.size(); }
QSize size() const Q_DECL_OVERRIDE { return mImage.size(); }
int scale() const Q_DECL_OVERRIDE { return int(mImage.devicePixelRatio()); }
QImage *image() { return &mImage; }
......@@ -91,11 +91,11 @@ public:
~QWaylandShmBackingStore();
QPaintDevice *paintDevice();
void flush(QWindow *window, const QRegion &region, const QPoint &offset);
void resize(const QSize &size, const QRegion &staticContents);
void flush(QWindow *window, const QRegion &region, const QPoint &offset) Q_DECL_OVERRIDE;
void resize(const QSize &size, const QRegion &staticContents) Q_DECL_OVERRIDE;
void resize(const QSize &size);
void beginPaint(const QRegion &);
void endPaint();
void beginPaint(const QRegion &) Q_DECL_OVERRIDE;
void endPaint() Q_DECL_OVERRIDE;
void hidden();
QWaylandAbstractDecoration *windowDecoration() const;
......