Check for 0 and use primary screen as default.
Change-Id: Ib4d0d3f507e7fb17687f5e126b49f98cfdbead6c
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-on: http://codereview.qt.nokia.com/2166
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
#include "QtGui/private/qwindow_p.h"
#include <QtGui/QPlatformCursor>
+#include <QtGui/QGuiApplication>
+#include <QtGui/QScreen>
QT_BEGIN_NAMESPACE
{
Q_D(const QWidget);
- QPlatformScreen *screen = QPlatformScreen::platformScreenForWindow(windowHandle());
+ QPlatformScreen *screen = 0;
+ if (QWidget *topLevel = window())
+ if (QWindow *topLevelWindow = topLevel->windowHandle())
+ screen = QPlatformScreen::platformScreenForWindow(topLevelWindow);
+ if (!screen && QGuiApplication::primaryScreen())
+ screen = QGuiApplication::primaryScreen()->handle();
+
if (!screen) {
if (m == PdmDpiX || m == PdmDpiY)
return 72;