Implement QApplication::topLevelAt() using QGuiApplication::topLevelAt().

Reducing code duplication, preparing for High-DPI support.

Task-number: QTBUG-38858
Change-Id: Id0ed12db4b5cadd0eef79afd0ac62f58a7b01901
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
bb10
Friedemann Kleint 2014-07-18 09:09:16 +02:00
parent fe099b6383
commit f547381806
1 changed files with 3 additions and 10 deletions

View File

@ -377,16 +377,9 @@ void QApplicationPrivate::createEventDispatcher()
*/
QWidget *QApplication::topLevelAt(const QPoint &pos)
{
QList<QScreen *> screens = QGuiApplication::screens();
QList<QScreen *>::const_iterator screen = screens.constBegin();
QList<QScreen *>::const_iterator end = screens.constEnd();
while (screen != end) {
if ((*screen)->geometry().contains(pos)) {
QWidgetWindow *w = qobject_cast<QWidgetWindow *>((*screen)->handle()->topLevelAt(pos));
return w ? w->widget() : 0;
}
++screen;
if (const QWindow *window = QGuiApplication::topLevelAt(pos)) {
if (const QWidgetWindow *widgetWindow = qobject_cast<const QWidgetWindow *>(window))
return widgetWindow->widget();
}
return 0;
}