diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2017-01-31 13:29:14 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2017-02-09 14:10:17 +0000 |
commit | a57f2128b15d363b88c063325eac1d36c2ff1578 (patch) | |
tree | 8cfd5c6ded2a9e4adc1766905114342addb94751 /src/plugins/platforms/windows | |
parent | ee8b61bcf56e03aae0f8e346e70330276e221843 (diff) |
Add QPlatformWindow::isForeignWindow()
Simplifies code at call sites and allows for refactoring how to decide
if a window is foreign or not at a later point.
Change-Id: Icc51a83bac187f4975535366b53b4990832b6c82
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows')
-rw-r--r-- | src/plugins/platforms/windows/qwindowsmousehandler.cpp | 2 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.cpp | 2 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.h | 17 |
3 files changed, 10 insertions, 11 deletions
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index 81abf24131..34c34fd28e 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -414,7 +414,7 @@ static bool isValidWheelReceiver(QWindow *candidate) { if (candidate) { const QWindow *toplevel = QWindowsWindow::topLevelOf(candidate); - if (toplevel->type() == Qt::ForeignWindow) + if (toplevel->handle() && toplevel->handle()->isForeignWindow()) return true; if (const QWindowsWindow *ww = QWindowsWindow::windowsWindowOf(toplevel)) return !ww->testFlag(QWindowsWindow::BlockedByModal); diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 04db975360..68d69f3765 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1122,7 +1122,7 @@ void QWindowsWindow::updateDropSite(bool topLevel) // if the parent window is a foreign window wrapped via QWindow::fromWinId, we need to enable the drop site // on the first child window const QWindow *parent = window()->parent(); - if (parent && (parent->type() == Qt::ForeignWindow)) + if (parent && parent->handle() && parent->handle()->isForeignWindow()) parentIsEmbedded = true; } diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index 22ba49b0a5..8179280bb3 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -385,15 +385,14 @@ QPoint QWindowsGeometryHint::mapFromGlobal(const QWindow *w, const QPoint &p) inline QWindowsWindow *QWindowsWindow::windowsWindowOf(const QWindow *w) { - QWindowsWindow *result = Q_NULLPTR; - if (w) { - const Qt::WindowType type = w->type(); - if (type != Qt::Desktop && type != Qt::ForeignWindow) { - if (QPlatformWindow *pw = w->handle()) - result = static_cast<QWindowsWindow *>(pw); - } - } - return result; + if (!w || !w->handle()) + return nullptr; + + const Qt::WindowType type = w->type(); + if (type == Qt::Desktop || w->handle()->isForeignWindow()) + return nullptr; + + return static_cast<QWindowsWindow *>(w->handle()); } void *QWindowsWindow::userDataOf(HWND hwnd) |