diff options
Diffstat (limited to 'src/quick/items/qquickwindow.cpp')
-rw-r--r-- | src/quick/items/qquickwindow.cpp | 100 |
1 files changed, 84 insertions, 16 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 26d83cfdf5..10e439182d 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtQuick module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:LGPL$ ** 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. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 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-3.0.html. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -46,6 +52,7 @@ #include <private/qsgrenderloop_p.h> #include <private/qquickrendercontrol_p.h> #include <private/qquickanimatorcontroller_p.h> +#include <private/qquickprofiler_p.h> #include <private/qguiapplication_p.h> #include <QtGui/QInputMethod> @@ -65,6 +72,8 @@ #include <QtQuick/private/qquickpixmapcache_p.h> #include <private/qqmlmemoryprofiler_p.h> +#include <private/qqmldebugserviceinterfaces_p.h> +#include <private/qqmldebugconnector_p.h> #include <private/qopenglvertexarrayobject_p.h> @@ -89,6 +98,7 @@ void QQuickWindowPrivate::updateFocusItemTransform() QQuickItemPrivate *focusPrivate = QQuickItemPrivate::get(focus); QGuiApplication::inputMethod()->setInputItemTransform(focusPrivate->itemToWindowTransform()); QGuiApplication::inputMethod()->setInputItemRectangle(QRectF(0, 0, focusPrivate->width, focusPrivate->height)); + focus->updateInputMethod(Qt::ImInputItemClipRectangle); } #endif } @@ -247,6 +257,26 @@ void QQuickWindow::focusInEvent(QFocusEvent *ev) d->updateFocusItemTransform(); } +#ifndef QT_NO_IM +static bool transformDirtyOnItemOrAncestor(const QQuickItem *item) +{ + while (item) { + if (QQuickItemPrivate::get(item)->dirtyAttributes & ( + QQuickItemPrivate::TransformOrigin | + QQuickItemPrivate::Transform | + QQuickItemPrivate::BasicTransform | + QQuickItemPrivate::Position | + QQuickItemPrivate::Size | + QQuickItemPrivate::ParentChanged | + QQuickItemPrivate::Clip)) { + return true; + } + item = item->parentItem(); + } + return false; +} +#endif + void QQuickWindowPrivate::polishItems() { // An item can trigger polish on another item, or itself for that matter, @@ -266,7 +296,17 @@ void QQuickWindowPrivate::polishItems() if (recursionSafeguard == 0) qWarning("QQuickWindow: possible QQuickItem::polish() loop"); - updateFocusItemTransform(); +#ifndef QT_NO_IM + if (QQuickItem *focusItem = q_func()->activeFocusItem()) { + // If the current focus item, or any of its anchestors, has changed location + // inside the window, we need inform IM about it. This to ensure that overlays + // such as selection handles will be updated. + const bool isActiveFocusItem = (focusItem == QGuiApplication::focusObject()); + const bool hasImEnabled = focusItem->inputMethodQuery(Qt::ImEnabled).toBool(); + if (isActiveFocusItem && hasImEnabled && transformDirtyOnItemOrAncestor(focusItem)) + updateFocusItemTransform(); + } +#endif } /*! @@ -467,6 +507,8 @@ QQuickWindowPrivate::QQuickWindowPrivate() QQuickWindowPrivate::~QQuickWindowPrivate() { delete customRenderStage; + if (QQmlInspectorService *service = QQmlDebugConnector::service<QQmlInspectorService>()) + service->removeWindow(q_func()); } void QQuickWindowPrivate::init(QQuickWindow *c, QQuickRenderControl *control) @@ -520,6 +562,9 @@ void QQuickWindowPrivate::init(QQuickWindow *c, QQuickRenderControl *control) QObject::connect(q, SIGNAL(screenChanged(QScreen*)), q, SLOT(handleScreenChanged(QScreen*))); QObject::connect(q, SIGNAL(frameSwapped()), q, SLOT(runJobsAfterSwap()), Qt::DirectConnection); + + if (QQmlInspectorService *service = QQmlDebugConnector::service<QQmlInspectorService>()) + service->addWindow(q); } /*! @@ -1505,6 +1550,8 @@ bool QQuickWindow::event(QEvent *e) void QQuickWindow::keyPressEvent(QKeyEvent *e) { Q_D(QQuickWindow); + Q_QUICK_INPUT_PROFILE(QQuickProfiler::Key, QQuickProfiler::InputKeyPress, e->key(), + e->modifiers()); d->deliverKeyEvent(e); } @@ -1512,6 +1559,8 @@ void QQuickWindow::keyPressEvent(QKeyEvent *e) void QQuickWindow::keyReleaseEvent(QKeyEvent *e) { Q_D(QQuickWindow); + Q_QUICK_INPUT_PROFILE(QQuickProfiler::Key, QQuickProfiler::InputKeyRelease, e->key(), + e->modifiers()); d->deliverKeyEvent(e); } @@ -1615,6 +1664,8 @@ bool QQuickWindowPrivate::deliverMouseEvent(QMouseEvent *event) void QQuickWindow::mousePressEvent(QMouseEvent *event) { Q_D(QQuickWindow); + Q_QUICK_INPUT_PROFILE(QQuickProfiler::Mouse, QQuickProfiler::InputMousePress, event->button(), + event->buttons()); if (event->source() == Qt::MouseEventSynthesizedBySystem) { event->accept(); @@ -1629,6 +1680,8 @@ void QQuickWindow::mousePressEvent(QMouseEvent *event) void QQuickWindow::mouseReleaseEvent(QMouseEvent *event) { Q_D(QQuickWindow); + Q_QUICK_INPUT_PROFILE(QQuickProfiler::Mouse, QQuickProfiler::InputMouseRelease, event->button(), + event->buttons()); if (event->source() == Qt::MouseEventSynthesizedBySystem) { event->accept(); @@ -1651,6 +1704,8 @@ void QQuickWindow::mouseReleaseEvent(QMouseEvent *event) void QQuickWindow::mouseDoubleClickEvent(QMouseEvent *event) { Q_D(QQuickWindow); + Q_QUICK_INPUT_PROFILE(QQuickProfiler::Mouse, QQuickProfiler::InputMouseDoubleClick, + event->button(), event->buttons()); if (event->source() == Qt::MouseEventSynthesizedBySystem) { event->accept(); @@ -1697,6 +1752,8 @@ bool QQuickWindowPrivate::sendHoverEvent(QEvent::Type type, QQuickItem *item, void QQuickWindow::mouseMoveEvent(QMouseEvent *event) { Q_D(QQuickWindow); + Q_QUICK_INPUT_PROFILE(QQuickProfiler::Mouse, QQuickProfiler::InputMouseMove, + event->localPos().x(), event->localPos().y()); if (event->source() == Qt::MouseEventSynthesizedBySystem) { event->accept(); @@ -1826,7 +1883,7 @@ bool QQuickWindowPrivate::deliverWheelEvent(QQuickItem *item, QWheelEvent *event if (item->contains(p)) { QWheelEvent wheel(p, p, event->pixelDelta(), event->angleDelta(), event->delta(), - event->orientation(), event->buttons(), event->modifiers(), event->phase(), event->source()); + event->orientation(), event->buttons(), event->modifiers(), event->phase(), event->source(), event->inverted()); wheel.accept(); q->sendEvent(item, &wheel); if (wheel.isAccepted()) { @@ -1842,6 +1899,9 @@ bool QQuickWindowPrivate::deliverWheelEvent(QQuickItem *item, QWheelEvent *event void QQuickWindow::wheelEvent(QWheelEvent *event) { Q_D(QQuickWindow); + Q_QUICK_INPUT_PROFILE(QQuickProfiler::Mouse, QQuickProfiler::InputMouseWheel, + event->angleDelta().x(), event->angleDelta().y()); + qCDebug(DBG_MOUSE) << "QQuickWindow::wheelEvent()" << event->pixelDelta() << event->angleDelta() << event->phase(); //if the actual wheel event was accepted, accept the compatibility wheel event and return early @@ -3916,6 +3976,14 @@ void QQuickWindow::resetOpenGLState() */ /*! + \qmlattachedproperty Window Window::window + \since 5.7 + + This attached property holds the item's window. + The Window attached property can be attached to any Item. +*/ + +/*! \qmlattachedproperty int Window::width \qmlattachedproperty int Window::height \since 5.5 |