diff options
author | Oliver Wolff <oliver.wolff@nokia.com> | 2011-11-03 13:08:51 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-11-03 18:43:52 +0100 |
commit | e84b8a34758a1f23a7f2b61820b72b3edb6c4472 (patch) | |
tree | 68db30b4c4a99eb03fae4a86782b355022bc8c83 /src | |
parent | faa6113c41b81368c5bbc2a764c2ae9bbc42e415 (diff) |
Fixed returned geometry of toplevel child widgets
If a widget has got a parent widget but also is a toplevel widget it
should not return its geometry relative to its parent.
In addition to that, child widgets which are not toplevel should not
change their left and top values according to their parent but also
keep their width and height intact.
Change-Id: I5e641abf5ddc0b8d056ba023f8de52af1d2ccc9f
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 21d02ab664..f61e15dded 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -158,16 +158,20 @@ QDebug operator<<(QDebug d, const NCCALCSIZE_PARAMS &p) // Return the frame geometry relative to the parent // if there is one. -// Note: This has been observed to return invalid sizes for child windows. -static inline QRect frameGeometry(HWND hwnd) +static inline QRect frameGeometry(HWND hwnd, bool topLevel) { RECT rect = { 0, 0, 0, 0 }; GetWindowRect(hwnd, &rect); // Screen coordinates. - if (const HWND parent = GetParent(hwnd)) { + const HWND parent = GetParent(hwnd); + if (parent && !topLevel) { + const int width = rect.right - rect.left; + const int height = rect.bottom - rect.top; POINT leftTop = { rect.left, rect.top }; ScreenToClient(parent, &leftTop); rect.left = leftTop.x; rect.top = leftTop.y; + rect.right = leftTop.x + width; + rect.bottom = leftTop.y + height; } return qrectFromRECT(rect); } @@ -363,7 +367,7 @@ QWindowsWindow::WindowData if (desktop) { // desktop widget. No frame, hopefully? result.hwnd = GetDesktopWindow(); - result.geometry = frameGeometry(result.hwnd); + result.geometry = frameGeometry(result.hwnd, true); if (QWindowsContext::verboseWindows) qDebug().nospace() << "Created desktop window " << w << result.hwnd; return result; @@ -903,13 +907,7 @@ void QWindowsWindow::setGeometry_sys(const QRect &rect) const QRect QWindowsWindow::geometry_sys() const { // Warning: Returns bogus values when minimized. - // Note: Using frameGeometry (based on GetWindowRect) - // has been observed to return a size based on a standard top level - // frame for WS_CHILD windows (whose frame is zero), thus, use the real - // client size instead. - QRect result = frameGeometry(m_data.hwnd) - frameMargins(); - if (result.isValid() && !window()->isTopLevel()) - result.setSize(clientSize(m_data.hwnd)); + QRect result = frameGeometry(m_data.hwnd, window()->isTopLevel()) - frameMargins(); return result; } |