summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Katz <jeremy.katz@nokia.com>2009-11-19 11:43:20 +0100
committerJeremy Katz <jeremy.katz@nokia.com>2009-11-19 11:43:20 +0100
commitc357ab6fbb673f75e9f2ccb2da5d3a938eaadf1f (patch)
tree7cd48b67a8452bb35d25cde2f63321358189b037
parent8fc2eec5b3282665f76f1e0313a03608bf4e7bc1 (diff)
added QGraphicsSystemScreen::topLevelAt(): find the window at a global position
This is used to determine which widget to send a pointer event to, and to implement QApplication::widgetAt().
-rw-r--r--src/gui/kernel/qapplication_lite.cpp23
-rw-r--r--src/gui/painting/qgraphicssystem.cpp13
-rw-r--r--src/gui/painting/qgraphicssystem_p.h1
-rw-r--r--src/gui/painting/qgraphicssystemcursor.cpp3
-rw-r--r--src/plugins/graphicssystems/fb_base/fb_base.cpp2
-rw-r--r--src/plugins/graphicssystems/fb_base/fb_base.h2
6 files changed, 26 insertions, 18 deletions
diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp
index 061ac5bf08..b0f50749bc 100644
--- a/src/gui/kernel/qapplication_lite.cpp
+++ b/src/gui/kernel/qapplication_lite.cpp
@@ -56,7 +56,7 @@
#include <qdesktopwidget.h>
#include <qinputcontext.h>
-
+#include "private/qgraphicssystem_p.h"
#include <qdebug.h>
@@ -354,19 +354,14 @@ void QApplication::restoreOverrideCursor()
QWidget *QApplication::topLevelAt(const QPoint &pos)
{
-//### We have to implement a windowsystem-aware way to do this
-
- //fallback implementation assuming widgets are in stacking order
-
- QWidgetList list = topLevelWidgets();
- for (int i = list.size()-1; i >= 0; --i) {
- QWidget *w = list[i];
- //### mask is ignored
- if (w != QApplication::desktop() && w->isVisible() && w->geometry().contains(pos))
- return w;
- }
-
- return 0;
+ QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem();
+ if (!gs)
+ return 0;
+ QGraphicsSystemScreen *screen = gs->screens().first();
+ if (!screen)
+ return 0;
+ QWidget *w = screen->topLevelAt(pos);
+ return w;
}
void QApplication::beep()
diff --git a/src/gui/painting/qgraphicssystem.cpp b/src/gui/painting/qgraphicssystem.cpp
index 2071127fcb..948223d3b3 100644
--- a/src/gui/painting/qgraphicssystem.cpp
+++ b/src/gui/painting/qgraphicssystem.cpp
@@ -85,6 +85,19 @@ QPixmapData *QGraphicsSystem::createDefaultPixmapData(QPixmapData::PixelType typ
}
#ifdef Q_WS_LITE
+QWidget *QGraphicsSystemScreen::topLevelAt(const QPoint & pos) const
+{
+ QWidgetList list = QApplication::topLevelWidgets();
+ for (int i = list.size()-1; i >= 0; --i) {
+ QWidget *w = list[i];
+ //### mask is ignored
+ if (w != QApplication::desktop() && w->isVisible() && w->geometry().contains(pos))
+ return w;
+ }
+
+ return 0;
+}
+
QList<QGraphicsSystemScreen *> QGraphicsSystem::screens() const
{
return QList<QGraphicsSystemScreen *>();
diff --git a/src/gui/painting/qgraphicssystem_p.h b/src/gui/painting/qgraphicssystem_p.h
index ddba22d149..1bfca584bb 100644
--- a/src/gui/painting/qgraphicssystem_p.h
+++ b/src/gui/painting/qgraphicssystem_p.h
@@ -75,6 +75,7 @@ public:
virtual QSize physicalSize() const = 0;
virtual void setDirty(QRect) { }
virtual void pointerEvent(QMouseEvent &) { }
+ virtual QWidget *topLevelAt(const QPoint &point) const;
};
#endif // Q_WS_LITE
diff --git a/src/gui/painting/qgraphicssystemcursor.cpp b/src/gui/painting/qgraphicssystemcursor.cpp
index 08dcbbe505..b919d0a085 100644
--- a/src/gui/painting/qgraphicssystemcursor.cpp
+++ b/src/gui/painting/qgraphicssystemcursor.cpp
@@ -57,8 +57,7 @@ QGraphicsSystemCursor::QGraphicsSystemCursor(QGraphicsSystemScreen *scr )
{
graphic = new QGraphicsSystemCursorImage(0, 0, 0, 0, 0, 0);
instance = this;
- QWidget * widget = QApplication::widgetAt(QCursor::pos());
- changeCursor(widget);
+ setCursor(Qt::ArrowCursor);
}
QGraphicsSystemCursor::~QGraphicsSystemCursor()
diff --git a/src/plugins/graphicssystems/fb_base/fb_base.cpp b/src/plugins/graphicssystems/fb_base/fb_base.cpp
index a091f731b4..d8725932a5 100644
--- a/src/plugins/graphicssystems/fb_base/fb_base.cpp
+++ b/src/plugins/graphicssystems/fb_base/fb_base.cpp
@@ -144,7 +144,7 @@ void QGraphicsSystemFbScreen::pointerEvent(QMouseEvent & me)
QApplicationPrivate::handleMouseEvent(widget, e);
}
-QWidget * QGraphicsSystemFbScreen::topLevelAt(QPoint p)
+QWidget * QGraphicsSystemFbScreen::topLevelAt(const QPoint & p) const
{
for(int i = 0; i < windowStack.size(); i++) {
if (windowStack[i]->geometry().contains(p, false) &&
diff --git a/src/plugins/graphicssystems/fb_base/fb_base.h b/src/plugins/graphicssystems/fb_base/fb_base.h
index 18519ec3f9..8c1bb5629e 100644
--- a/src/plugins/graphicssystems/fb_base/fb_base.h
+++ b/src/plugins/graphicssystems/fb_base/fb_base.h
@@ -66,7 +66,7 @@ public:
virtual void addWindowSurface(QGraphicsSystemFbWindowSurface * surface) { windowStack.prepend(surface); }
virtual void raise(QWindowSurface * surface);
virtual void lower(QWindowSurface * surface);
- virtual QWidget * topLevelAt(QPoint p);
+ virtual QWidget * topLevelAt(const QPoint & p) const;
virtual void pointerEvent(QMouseEvent & me);