summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2011-01-25 09:01:56 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2011-03-24 15:38:49 (GMT)
commitfe0e71ae0bc13464ecbcc39b6db9300fc6200779 (patch)
tree9b99ac3b0bbd29b1dd4510d52826394688c46396
parentf1a7f339109ee72059aa135381defeaf6f564977 (diff)
downloadQt-fe0e71ae0bc13464ecbcc39b6db9300fc6200779.zip
Qt-fe0e71ae0bc13464ecbcc39b6db9300fc6200779.tar.gz
Qt-fe0e71ae0bc13464ecbcc39b6db9300fc6200779.tar.bz2
Improved performance of mapFromGlobal/mapToGlobal on X11
We don't call XTranslateCoordinates anymore, but use the toplevel window offset that we already store to convert between screen coordinates and widget coordinates. Reviewed-by: João Abecasis
-rw-r--r--src/gui/kernel/qwidget_x11.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp
index c6753fc..4f39443 100644
--- a/src/gui/kernel/qwidget_x11.cpp
+++ b/src/gui/kernel/qwidget_x11.cpp
@@ -1333,12 +1333,40 @@ QPoint QWidgetPrivate::mapFromGlobal(const QPoint &pos) const
QPoint QWidget::mapToGlobal(const QPoint &pos) const
{
Q_D(const QWidget);
+ QPoint offset = data->crect.topLeft();
+ const QWidget *w = this;
+ const QWidget *p = w->parentWidget();
+ while (!w->isWindow() && p) {
+ w = p;
+ p = p->parentWidget();
+ offset += w->data->crect.topLeft();
+ }
+
+ const QWidgetPrivate *wd = w->d_func();
+ QTLWExtra *tlw = wd->topData();
+ if (!tlw->embedded)
+ return pos + offset;
+
return d->mapToGlobal(pos);
}
QPoint QWidget::mapFromGlobal(const QPoint &pos) const
{
Q_D(const QWidget);
+ QPoint offset = data->crect.topLeft();
+ const QWidget *w = this;
+ const QWidget *p = w->parentWidget();
+ while (!w->isWindow() && p) {
+ w = p;
+ p = p->parentWidget();
+ offset += w->data->crect.topLeft();
+ }
+
+ const QWidgetPrivate *wd = w->d_func();
+ QTLWExtra *tlw = wd->topData();
+ if (!tlw->embedded)
+ return pos - offset;
+
return d->mapFromGlobal(pos);
}