diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2016-11-25 15:02:55 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2017-01-05 12:07:35 +0000 |
commit | 2ac50ac15621e303adbf6c35cbc2456f7ae5dd2f (patch) | |
tree | 1eb44c0eff603841208c6254c9f4621fb51f2cb3 /src/plugins | |
parent | c5282fc185caee86a3e35499763006c224118185 (diff) |
Split QPlatformWindow::isEmbedded into isAncestorOf to separate concerns
The function was doing two things, both checking window ancestry and
whether or the window was a direct child of non-Qt window. The former
has now been split of in a QPlatformWindow::isAncestorOf(), which
simplifies the code in e.g. QApplicationPrivate::isWindowBlocked().
Change-Id: I259a190e03ef8def23356005474eeeee74c9ae89
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.cpp | 16 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.h | 3 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.cpp | 7 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.h | 2 |
4 files changed, 11 insertions, 17 deletions
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index bb5f3a8d75..5edf40b886 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1243,18 +1243,14 @@ bool QWindowsWindow::isActive() const return false; } -bool QWindowsWindow::isEmbedded(const QPlatformWindow *parentWindow) const +bool QWindowsWindow::isAncestorOf(const QPlatformWindow *child) const { - if (parentWindow) { - const QWindowsWindow *ww = static_cast<const QWindowsWindow *>(parentWindow); - const HWND hwnd = ww->handle(); - if (!IsChild(hwnd, m_data.hwnd)) - return false; - } - - if (!m_data.embedded && parent()) - return parent()->isEmbedded(); + const QWindowsWindow *childWindow = static_cast<const QWindowsWindow *>(child); + return IsChild(m_data.hwnd, childWindow->handle()); +} +bool QWindowsWindow::isEmbedded() const +{ return m_data.embedded; } diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index 54c9900771..22ba49b0a5 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -222,7 +222,8 @@ public: bool isVisible() const; bool isExposed() const override { return testFlag(Exposed); } bool isActive() const override; - bool isEmbedded(const QPlatformWindow *parentWindow = 0) const override; + bool isAncestorOf(const QPlatformWindow *child) const override; + bool isEmbedded() const override; QPoint mapToGlobal(const QPoint &pos) const override; QPoint mapFromGlobal(const QPoint &pos) const override; diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index ff01fa019e..0275cf5630 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -2154,12 +2154,9 @@ bool QXcbWindow::isExposed() const return m_mapped; } -bool QXcbWindow::isEmbedded(const QPlatformWindow *parentWindow) const +bool QXcbWindow::isEmbedded() const { - if (!m_embedded) - return false; - - return parentWindow ? (parentWindow == parent()) : true; + return m_embedded; } QPoint QXcbWindow::mapToGlobal(const QPoint &pos) const diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index 089df8f3f6..41befbf66f 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -87,7 +87,7 @@ public: void setParent(const QPlatformWindow *window) override; bool isExposed() const override; - bool isEmbedded(const QPlatformWindow *parentWindow = 0) const override; + bool isEmbedded() const override; QPoint mapToGlobal(const QPoint &pos) const override; QPoint mapFromGlobal(const QPoint &pos) const override; |