summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-05-20 13:46:21 +0200
committerOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2016-05-23 21:09:46 +0200
commit56d6e000f7487c59172330ebd23a718268c508f1 (patch)
tree1494432583b1569816075091a8075b31d795f77c /src/widgets/kernel
parent9fd407fc6a29c94b4568dd042a05c208255179e0 (diff)
parentc276aa51303b7c6f8e4cd854aadf8344a906e50f (diff)
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts: mkspecs/wince80colibri-armv7-msvc2012/qmake.conf qmake/generators/win32/msvc_vcproj.cpp src/corelib/global/qnamespace.h src/corelib/global/qnamespace.qdoc src/corelib/io/qfsfileengine_win.cpp src/corelib/tools/tools.pri src/network/ssl/qsslconfiguration_p.h src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp src/plugins/platforms/windows/windows.pri src/src.pro src/tools/bootstrap/bootstrap.pro src/tools/uic/cpp/cppwriteinitialization.cpp src/widgets/dialogs/qfilesystemmodel.cpp tests/auto/testlib/selftests/expected_cmptest.teamcity tests/auto/testlib/selftests/expected_cmptest.txt Change-Id: I4d2ac78f0dcc97f008186bbbc769c6fe588ab0e5
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r--src/widgets/kernel/qapplication.cpp8
-rw-r--r--src/widgets/kernel/qgesturemanager.cpp2
-rw-r--r--src/widgets/kernel/qwidget.cpp99
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp27
-rw-r--r--src/widgets/kernel/qwidgetwindow_p.h2
5 files changed, 75 insertions, 63 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 4ff466e04b..5007969c96 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -2213,10 +2213,10 @@ void QApplicationPrivate::notifyActiveWindowChange(QWindow *previous)
QApplication::setActiveWindow(tlw);
// QTBUG-37126, Active X controls may set the focus on native child widgets.
if (wnd && tlw && wnd != tlw->windowHandle()) {
- if (QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(wnd)) {
- if (widgetWindow->widget()->inherits("QAxHostWidget"))
- widgetWindow->widget()->setFocus(Qt::ActiveWindowFocusReason);
- }
+ if (QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(wnd))
+ if (QWidget *widget = widgetWindow->widget())
+ if (widget->inherits("QAxHostWidget"))
+ widget->setFocus(Qt::ActiveWindowFocusReason);
}
}
diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp
index 777be8525e..c901285d1a 100644
--- a/src/widgets/kernel/qgesturemanager.cpp
+++ b/src/widgets/kernel/qgesturemanager.cpp
@@ -552,7 +552,7 @@ bool QGestureManager::filterEvent(QObject *receiver, QEvent *event)
// filter method.
QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(receiver);
- if (widgetWindow)
+ if (widgetWindow && widgetWindow->widget())
return filterEvent(widgetWindow->widget(), event);
QGesture *state = qobject_cast<QGesture *>(receiver);
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 495af34c60..6fa74b7cc6 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -12374,6 +12374,53 @@ static inline bool canMapPosition(QWindow *window)
return window->handle() && !qt_window_private(window)->resizeEventPending;
}
+#ifndef QT_NO_GRAPHICSVIEW
+static inline QGraphicsProxyWidget *graphicsProxyWidget(const QWidget *w)
+{
+ QGraphicsProxyWidget *result = Q_NULLPTR;
+ const QWidgetPrivate *d = qt_widget_private(const_cast<QWidget *>(w));
+ if (d->extra)
+ result = d->extra->proxyWidget;
+ return result;
+}
+#endif // !QT_NO_GRAPHICSVIEW
+
+struct MapToGlobalTransformResult {
+ QTransform transform;
+ QWindow *window;
+};
+
+static MapToGlobalTransformResult mapToGlobalTransform(const QWidget *w)
+{
+ MapToGlobalTransformResult result;
+ result.window = Q_NULLPTR;
+ for ( ; w ; w = w->parentWidget()) {
+#ifndef QT_NO_GRAPHICSVIEW
+ if (QGraphicsProxyWidget *qgpw = graphicsProxyWidget(w)) {
+ if (const QGraphicsScene *scene = qgpw->scene()) {
+ const QList <QGraphicsView *> views = scene->views();
+ if (!views.isEmpty()) {
+ result.transform *= qgpw->sceneTransform();
+ result.transform *= views.first()->viewportTransform();
+ w = views.first()->viewport();
+ }
+ }
+ }
+#endif // !QT_NO_GRAPHICSVIEW
+ QWindow *window = w->windowHandle();
+ if (window && canMapPosition(window)) {
+ result.window = window;
+ break;
+ }
+
+ const QPoint topLeft = w->geometry().topLeft();
+ result.transform.translate(topLeft.x(), topLeft.y());
+ if (w->isWindow())
+ break;
+ }
+ return result;
+}
+
/*!
\fn QPoint QWidget::mapToGlobal(const QPoint &pos) const
@@ -12385,29 +12432,9 @@ static inline bool canMapPosition(QWindow *window)
*/
QPoint QWidget::mapToGlobal(const QPoint &pos) const
{
-#ifndef QT_NO_GRAPHICSVIEW
- Q_D(const QWidget);
- if (d->extra && d->extra->proxyWidget && d->extra->proxyWidget->scene()) {
- const QList <QGraphicsView *> views = d->extra->proxyWidget->scene()->views();
- if (!views.isEmpty()) {
- const QPointF scenePos = d->extra->proxyWidget->mapToScene(pos);
- const QPoint viewPortPos = views.first()->mapFromScene(scenePos);
- return views.first()->viewport()->mapToGlobal(viewPortPos);
- }
- }
-#endif // !QT_NO_GRAPHICSVIEW
- int x = pos.x(), y = pos.y();
- const QWidget *w = this;
- while (w) {
- QWindow *window = w->windowHandle();
- if (window && canMapPosition(window))
- return window->mapToGlobal(QPoint(x, y));
-
- x += w->data->crect.x();
- y += w->data->crect.y();
- w = w->isWindow() ? 0 : w->parentWidget();
- }
- return QPoint(x, y);
+ const MapToGlobalTransformResult t = mapToGlobalTransform(this);
+ const QPoint g = t.transform.map(pos);
+ return t.window ? t.window->mapToGlobal(g) : g;
}
/*!
@@ -12420,29 +12447,9 @@ QPoint QWidget::mapToGlobal(const QPoint &pos) const
*/
QPoint QWidget::mapFromGlobal(const QPoint &pos) const
{
-#ifndef QT_NO_GRAPHICSVIEW
- Q_D(const QWidget);
- if (d->extra && d->extra->proxyWidget && d->extra->proxyWidget->scene()) {
- const QList <QGraphicsView *> views = d->extra->proxyWidget->scene()->views();
- if (!views.isEmpty()) {
- const QPoint viewPortPos = views.first()->viewport()->mapFromGlobal(pos);
- const QPointF scenePos = views.first()->mapToScene(viewPortPos);
- return d->extra->proxyWidget->mapFromScene(scenePos).toPoint();
- }
- }
-#endif // !QT_NO_GRAPHICSVIEW
- int x = pos.x(), y = pos.y();
- const QWidget *w = this;
- while (w) {
- QWindow *window = w->windowHandle();
- if (window && canMapPosition(window))
- return window->mapFromGlobal(QPoint(x, y));
-
- x -= w->data->crect.x();
- y -= w->data->crect.y();
- w = w->isWindow() ? 0 : w->parentWidget();
- }
- return QPoint(x, y);
+ const MapToGlobalTransformResult t = mapToGlobalTransform(this);
+ const QPoint windowLocal = t.window ? t.window->mapFromGlobal(pos) : pos;
+ return t.transform.inverted().map(windowLocal);
}
QWidget *qt_pressGrab = 0;
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index 843b89b6e4..675d54f6b4 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -93,7 +93,7 @@ QRectF QWidgetWindowPrivate::closestAcceptableGeometry(const QRectF &rect) const
{
Q_Q(const QWidgetWindow);
const QWidget *widget = q->widget();
- if (!widget->isWindow() || !widget->hasHeightForWidth())
+ if (!widget || !widget->isWindow() || !widget->hasHeightForWidth())
return QRect();
const QSize oldSize = rect.size().toSize();
const QSize newSize = QLayout::closestAcceptableSize(widget, oldSize);
@@ -129,7 +129,7 @@ QWidgetWindow::QWidgetWindow(QWidget *widget)
&& !QApplication::testAttribute(Qt::AA_ForceRasterWidgets)) {
setSurfaceType(QSurface::RasterGLSurface);
}
- connect(m_widget, &QObject::objectNameChanged, this, &QWidgetWindow::updateObjectName);
+ connect(widget, &QObject::objectNameChanged, this, &QWidgetWindow::updateObjectName);
connect(this, SIGNAL(screenChanged(QScreen*)), this, SLOT(handleScreenChange()));
}
@@ -148,16 +148,18 @@ QAccessibleInterface *QWidgetWindow::accessibleRoot() const
QObject *QWidgetWindow::focusObject() const
{
- QWidget *widget = m_widget->focusWidget();
+ QWidget *windowWidget = m_widget;
+ if (!windowWidget)
+ return Q_NULLPTR;
+
+ QWidget *widget = windowWidget->focusWidget();
if (!widget)
- widget = m_widget;
+ widget = windowWidget;
- if (widget) {
- QObject *focusObj = QWidgetPrivate::get(widget)->focusObject();
- if (focusObj)
- return focusObj;
- }
+ QObject *focusObj = QWidgetPrivate::get(widget)->focusObject();
+ if (focusObj)
+ return focusObj;
return widget;
}
@@ -180,6 +182,9 @@ static inline bool shouldBePropagatedToWidget(QEvent *event)
bool QWidgetWindow::event(QEvent *event)
{
+ if (!m_widget)
+ return QWindow::event(event);
+
if (m_widget->testAttribute(Qt::WA_DontShowOnScreen)) {
// \a event is uninteresting for QWidgetWindow, the event was probably
// generated before WA_DontShowOnScreen was set
@@ -207,7 +212,7 @@ bool QWidgetWindow::event(QEvent *event)
#ifndef QT_NO_ACCESSIBILITY
QAccessible::State state;
state.active = true;
- QAccessibleStateChangeEvent ev(widget(), state);
+ QAccessibleStateChangeEvent ev(m_widget, state);
QAccessible::updateAccessibility(&ev);
#endif
return false; }
@@ -381,7 +386,7 @@ void QWidgetWindow::handleEnterLeaveEvent(QEvent *event)
} else {
const QEnterEvent *ee = static_cast<QEnterEvent *>(event);
QWidget *child = m_widget->childAt(ee->pos());
- QWidget *receiver = child ? child : m_widget;
+ QWidget *receiver = child ? child : m_widget.data();
QApplicationPrivate::dispatchEnterLeave(receiver, 0, ee->screenPos());
qt_last_mouse_receiver = receiver;
}
diff --git a/src/widgets/kernel/qwidgetwindow_p.h b/src/widgets/kernel/qwidgetwindow_p.h
index d20e7cb15e..a0d79b2b72 100644
--- a/src/widgets/kernel/qwidgetwindow_p.h
+++ b/src/widgets/kernel/qwidgetwindow_p.h
@@ -125,7 +125,7 @@ private:
};
QWidget *getFocusWidget(FocusWidgets fw);
- QWidget *m_widget;
+ QPointer<QWidget> m_widget;
QPointer<QWidget> m_implicit_mouse_grabber;
#ifndef QT_NO_DRAGANDDROP
QPointer<QWidget> m_dragTarget;