summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2011-01-25 09:45:41 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2011-01-25 10:19:50 (GMT)
commit7332dd762a406bb94d37e53a0bdd16045760d956 (patch)
tree26c190bada49d44c3d9bbf34148d0750ed38ad31
parenta0e0a9378d10db9c8ab3ba4d59f5c576ee4cbc40 (diff)
downloadQt-7332dd762a406bb94d37e53a0bdd16045760d956.zip
Qt-7332dd762a406bb94d37e53a0bdd16045760d956.tar.gz
Qt-7332dd762a406bb94d37e53a0bdd16045760d956.tar.bz2
Moved the implementation of mapFromGlobal/mapToGlobal to QWidgetPrivate
Reviewed-by: João Abecasis
-rw-r--r--src/gui/kernel/qwidget_p.h2
-rw-r--r--src/gui/kernel/qwidget_x11.cpp50
2 files changed, 32 insertions, 20 deletions
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index 693984a..3759dd1 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -767,6 +767,8 @@ public:
void x11UpdateIsOpaque();
bool isBackgroundInherited() const;
void updateX11AcceptFocus();
+ QPoint mapToGlobal(const QPoint &pos) const;
+ QPoint mapFromGlobal(const QPoint &pos) const;
#elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN
uint noPaintOnScreen : 1; // see qwidget_win.cpp ::paintEngine()
#ifndef QT_NO_GESTURES
diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp
index a93c545..4b59bfc 100644
--- a/src/gui/kernel/qwidget_x11.cpp
+++ b/src/gui/kernel/qwidget_x11.cpp
@@ -1280,39 +1280,49 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
#endif
}
-
-QPoint QWidget::mapToGlobal(const QPoint &pos) const
+QPoint QWidgetPrivate::mapToGlobal(const QPoint &pos) const
{
- Q_D(const QWidget);
- if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) {
- QPoint p = pos + data->crect.topLeft();
+ Q_Q(const QWidget);
+ if (!q->testAttribute(Qt::WA_WState_Created) || !q->internalWinId()) {
+ QPoint p = pos + q->data->crect.topLeft();
//cannot trust that !isWindow() implies parentWidget() before create
- return (isWindow() || !parentWidget()) ? p : parentWidget()->mapToGlobal(p);
+ return (q->isWindow() || !q->parentWidget()) ? p : q->parentWidget()->d_func()->mapToGlobal(p);
}
- int x, y;
+ int x, y;
Window child;
- QPoint p = d->mapToWS(pos);
- XTranslateCoordinates(X11->display, internalWinId(),
- QApplication::desktop()->screen(d->xinfo.screen())->internalWinId(),
+ QPoint p = mapToWS(pos);
+ XTranslateCoordinates(X11->display, q->internalWinId(),
+ QApplication::desktop()->screen(xinfo.screen())->internalWinId(),
p.x(), p.y(), &x, &y, &child);
return QPoint(x, y);
}
-
-QPoint QWidget::mapFromGlobal(const QPoint &pos) const
+QPoint QWidgetPrivate::mapFromGlobal(const QPoint &pos) const
{
- Q_D(const QWidget);
- if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) {
+ Q_Q(const QWidget);
+ if (!q->testAttribute(Qt::WA_WState_Created) || !q->internalWinId()) {
//cannot trust that !isWindow() implies parentWidget() before create
- QPoint p = (isWindow() || !parentWidget()) ? pos : parentWidget()->mapFromGlobal(pos);
- return p - data->crect.topLeft();
+ QPoint p = (q->isWindow() || !q->parentWidget()) ? pos : q->parentWidget()->d_func()->mapFromGlobal(pos);
+ return p - q->data->crect.topLeft();
}
- int x, y;
+ int x, y;
Window child;
XTranslateCoordinates(X11->display,
- QApplication::desktop()->screen(d->xinfo.screen())->internalWinId(),
- internalWinId(), pos.x(), pos.y(), &x, &y, &child);
- return d->mapFromWS(QPoint(x, y));
+ QApplication::desktop()->screen(xinfo.screen())->internalWinId(),
+ q->internalWinId(), pos.x(), pos.y(), &x, &y, &child);
+ return mapFromWS(QPoint(x, y));
+}
+
+QPoint QWidget::mapToGlobal(const QPoint &pos) const
+{
+ Q_D(const QWidget);
+ return d->mapToGlobal(pos);
+}
+
+QPoint QWidget::mapFromGlobal(const QPoint &pos) const
+{
+ Q_D(const QWidget);
+ return d->mapFromGlobal(pos);
}
void QWidgetPrivate::updateSystemBackground()