From 0da4451b783b02d6df464fba9f0c34828df1ac06 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 25 Jan 2012 12:43:20 +0100 Subject: [PATCH] Introduce QGuiApplicationPrivate::windowForWidget. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change getHWNDForWidget() to take a const QWidget *. Change-Id: I6b0d0bce70487304dfcd4e7a6a039fe8c7ca4aae Reviewed-by: Samuel Rødal --- src/widgets/kernel/qapplication_p.h | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index 30d5e4400db..0da36f92625 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -350,11 +350,23 @@ public: QWidget *native, QWidget **buttonDown, QPointer &lastMouseReceiver, bool spontaneous = true); void sendSyntheticEnterLeave(QWidget *widget); -#ifdef Q_OS_WIN - static HWND getHWNDForWidget(QWidget *widget) + + static QWindow *windowForWidget(const QWidget *widget) { - QWindow *window = widget->windowHandle(); - return static_cast (QGuiApplication::platformNativeInterface()->nativeResourceForWindow("handle", window)); + if (QWindow *window = widget->windowHandle()) + return window; + if (const QWidget *nativeParent = widget->nativeParentWidget()) + return nativeParent->windowHandle(); + return 0; + } + +#ifdef Q_OS_WIN + static HWND getHWNDForWidget(const QWidget *widget) + { + if (QWindow *window = windowForWidget(widget)) + return static_cast (QGuiApplication::platformNativeInterface()-> + nativeResourceForWindow(QByteArrayLiteral("handle"), window)); + return 0; } #endif