summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qwidget.cpp
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-06-12 00:28:39 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-06-12 00:28:39 (GMT)
commita653056f806a3410b4aa76df78fae736d4f93791 (patch)
treeaafc9a816ce6a55e4ad6ba999d2a6d2d8e4be1f1 /src/gui/kernel/qwidget.cpp
parent497da277770ccf37e05a7b519afd5206601a7cf1 (diff)
parentcde3f39cb75ba69185cca8176ea7126f8441f042 (diff)
downloadQt-a653056f806a3410b4aa76df78fae736d4f93791.zip
Qt-a653056f806a3410b4aa76df78fae736d4f93791.tar.gz
Qt-a653056f806a3410b4aa76df78fae736d4f93791.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2: (31 commits) Fixed an on-exit crash for apps using GL. QMetaType: do not crash when registering builtin stream operator Fix another potential strstr() crash for EGL based GL apps. Fixed an on-exit application crash for GL apps using EGL. Compile fix. QWidget::childAt for masked child widgets doesn't work properly Optimized 90-, 180-, and 270- rotated blits in raster paint engine. Rename QLocale::isWrittenRightToLeft() to textDirection() Fixed some bugs in detection of keyboard directionality Add a isWrittenRightToLeft() method to QLocale. consistent handling of directionality in QTextLayout For an empty line edit the cursor position is depending on input language correctly initialize the bidi level in the text engine Use the textDirection() of blocks correctly. Add QTextBlock::textDirection() Make sure LayoutDirectionAuto is the default text direction LayoutDirectionAuto is the default layout direction for QPainter Correct BiDi behavior of QLineEdit The default text direction for QTextOption is Qt::LayoutDirectionAuto Handle setting the layoutDirection to Qt::LayoutDirectionAuto ...
Diffstat (limited to 'src/gui/kernel/qwidget.cpp')
-rw-r--r--src/gui/kernel/qwidget.cpp80
1 files changed, 49 insertions, 31 deletions
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 895c85d..492954a 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -67,6 +67,7 @@
# include "qt_mac_p.h"
# include "qt_cocoa_helpers_mac_p.h"
# include "qmainwindow.h"
+# include "qtoolbar.h"
#endif
#if defined(Q_WS_QWS)
# include "qwsdisplay_qws.h"
@@ -4828,6 +4829,11 @@ void QWidget::setLayoutDirection(Qt::LayoutDirection direction)
{
Q_D(QWidget);
+ if (direction == Qt::LayoutDirectionAuto) {
+ unsetLayoutDirection();
+ return;
+ }
+
setAttribute(Qt::WA_SetLayoutDirection);
d->setLayoutDirection_helper(direction);
}
@@ -9711,46 +9717,58 @@ QWidget *QWidget::childAt(const QPoint &p) const
QWidget *QWidgetPrivate::childAt_helper(const QPoint &p, bool ignoreChildrenInDestructor) const
{
- Q_Q(const QWidget);
+ if (children.isEmpty())
+ return 0;
+
#ifdef Q_WS_MAC
+ Q_Q(const QWidget);
+ // Unified tool bars on the Mac require special handling since they live outside
+ // QMainWindow's geometry(). See commit: 35667fd45ada49269a5987c235fdedfc43e92bb8
bool includeFrame = q->isWindow() && qobject_cast<const QMainWindow *>(q)
&& static_cast<const QMainWindow *>(q)->unifiedTitleAndToolBarOnMac();
+ if (includeFrame)
+ return childAtRecursiveHelper(p, ignoreChildrenInDestructor, includeFrame);
#endif
- if (
-#ifdef Q_WS_MAC
- !includeFrame &&
-#endif
- !q->rect().contains(p))
+ if (!pointInsideRectAndMask(p))
return 0;
+ return childAtRecursiveHelper(p, ignoreChildrenInDestructor);
+}
- for (int i = children.size(); i > 0 ;) {
- --i;
- QWidget *w = qobject_cast<QWidget *>(children.at(i));
- if (w && !w->isWindow() && !w->isHidden()
- && (w->geometry().contains(p)
-#ifdef Q_WS_MAC
- || (includeFrame && w->geometry().contains(qt_mac_nativeMapFromParent(w, p)))
+QWidget *QWidgetPrivate::childAtRecursiveHelper(const QPoint &p, bool ignoreChildrenInDestructor, bool includeFrame) const
+{
+#ifndef Q_WS_MAC
+ Q_UNUSED(includeFrame);
#endif
- )) {
- if (ignoreChildrenInDestructor && w->data->in_destructor)
- continue;
- if (w->testAttribute(Qt::WA_TransparentForMouseEvents))
- continue;
- QPoint childPoint = w->mapFromParent(p);
-#ifdef Q_WS_MAC
- if (includeFrame && !w->geometry().contains(p))
- childPoint = qt_mac_nativeMapFromParent(w, p);
-#endif
- if (QWidget *t = w->d_func()->childAt_helper(childPoint, ignoreChildrenInDestructor))
- return t;
- // if WMouseNoMask is set the widget mask is ignored, if
- // the widget has no mask then the WMouseNoMask flag has no
- // effect
- if (w->testAttribute(Qt::WA_MouseNoMask) || w->mask().contains(childPoint)
- || w->mask().isEmpty())
- return w;
+ for (int i = children.size() - 1; i >= 0; --i) {
+ QWidget *child = qobject_cast<QWidget *>(children.at(i));
+ if (!child || child->isWindow() || child->isHidden() || child->testAttribute(Qt::WA_TransparentForMouseEvents)
+ || (ignoreChildrenInDestructor && child->data->in_destructor)) {
+ continue;
}
+
+ // Map the point 'p' from parent coordinates to child coordinates.
+ QPoint childPoint = p;
+#ifdef Q_WS_MAC
+ // 'includeFrame' is true if the child's parent is a top-level QMainWindow with an unified tool bar.
+ // An unified tool bar on the Mac lives outside QMainWindow's geometry(), so a normal
+ // QWidget::mapFromParent won't do the trick.
+ if (includeFrame && qobject_cast<QToolBar *>(child))
+ childPoint = qt_mac_nativeMapFromParent(child, p);
+ else
+#endif
+ childPoint -= child->data->crect.topLeft();
+
+ // Check if the point hits the child.
+ if (!child->d_func()->pointInsideRectAndMask(childPoint))
+ continue;
+
+ // Do the same for the child's descendants.
+ if (QWidget *w = child->d_func()->childAtRecursiveHelper(childPoint, ignoreChildrenInDestructor))
+ return w;
+
+ // We have found our target; namely the child at position 'p'.
+ return child;
}
return 0;
}