summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-01-19 15:00:05 +0100
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-01-20 19:59:23 +0100
commit0b62cd8da7d8ee078b799b95088a63626099caa4 (patch)
tree11961286788da1012e8df89e4b15c95a9ee912c6 /src/plugins
parent8c5b3c6d912709d4db9624bb999b3166a27ee189 (diff)
Windows: Fix coordinate offset when positioning the taskbar on the left.
For windows that do not have WS_EX_TOOLWINDOW set, the WINDOWPLACEMENT API uses workspace/available aera coordinates. Introduce a helper function to return the offset and use that. Task-number: QTBUG-43872 Change-Id: I329c640f180524699b45b855b4583f447c4a0987 Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.cpp9
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.h2
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp34
3 files changed, 40 insertions, 5 deletions
diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp
index fd57d9ee61..ae8020a53e 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.cpp
+++ b/src/plugins/platforms/windows/qwindowsscreen.cpp
@@ -497,4 +497,13 @@ bool QWindowsScreenManager::handleScreenChanges()
return true;
}
+const QWindowsScreen *QWindowsScreenManager::screenAtDp(const QPoint &p) const
+{
+ foreach (QWindowsScreen *scr, m_screens) {
+ if (scr->geometryDp().contains(p))
+ return scr;
+ }
+ return Q_NULLPTR;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowsscreen.h b/src/plugins/platforms/windows/qwindowsscreen.h
index aa1408358b..28256f3000 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.h
+++ b/src/plugins/platforms/windows/qwindowsscreen.h
@@ -137,6 +137,8 @@ public:
bool handleDisplayChange(WPARAM wParam, LPARAM lParam);
const WindowsScreenList &screens() const { return m_screens; }
+ const QWindowsScreen *screenAtDp(const QPoint &p) const;
+
private:
void removeScreen(int index);
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 1d8645f5f4..fbb61a1aff 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -169,6 +169,25 @@ QDebug operator<<(QDebug d, const NCCALCSIZE_PARAMS &p)
}
#endif // !Q_OS_WINCE
+// QTBUG-43872, for windows that do not have WS_EX_TOOLWINDOW set, WINDOWPLACEMENT
+// is in workspace/available area coordinates.
+static QPoint windowPlacementOffset(HWND hwnd, const QPoint &point)
+{
+#ifndef Q_OS_WINCE
+ if (GetWindowLongPtr(hwnd, GWL_EXSTYLE) & WS_EX_TOOLWINDOW)
+ return QPoint(0, 0);
+ const QWindowsScreenManager &screenManager = QWindowsContext::instance()->screenManager();
+ const QWindowsScreen *screen = screenManager.screens().size() == 1
+ ? screenManager.screens().first() : screenManager.screenAtDp(point);
+ if (screen)
+ return screen->availableGeometryDp().topLeft() - screen->geometryDp().topLeft();
+#else
+ Q_UNUSED(hwnd)
+ Q_UNUSED(point)
+#endif
+ return QPoint(0, 0);
+}
+
// Return the frame geometry relative to the parent
// if there is one.
static inline QRect frameGeometry(HWND hwnd, bool topLevel)
@@ -179,8 +198,10 @@ static inline QRect frameGeometry(HWND hwnd, bool topLevel)
WINDOWPLACEMENT windowPlacement;
windowPlacement.length = sizeof(WINDOWPLACEMENT);
GetWindowPlacement(hwnd, &windowPlacement);
- if (windowPlacement.showCmd == SW_SHOWMINIMIZED)
- return qrectFromRECT(windowPlacement.rcNormalPosition);
+ if (windowPlacement.showCmd == SW_SHOWMINIMIZED) {
+ const QRect result = qrectFromRECT(windowPlacement.rcNormalPosition);
+ return result.translated(windowPlacementOffset(hwnd, result.topLeft()));
+ }
}
#endif // !Q_OS_WINCE
GetWindowRect(hwnd, &rect); // Screen coordinates.
@@ -1297,8 +1318,10 @@ static QRect normalFrameGeometry(HWND hwnd)
#ifndef Q_OS_WINCE
WINDOWPLACEMENT wp;
wp.length = sizeof(WINDOWPLACEMENT);
- if (GetWindowPlacement(hwnd, &wp))
- return qrectFromRECT(wp.rcNormalPosition);
+ if (GetWindowPlacement(hwnd, &wp)) {
+ const QRect result = qrectFromRECT(wp.rcNormalPosition);
+ return result.translated(windowPlacementOffset(hwnd, result.topLeft()));
+ }
#else
Q_UNUSED(hwnd)
#endif
@@ -1427,7 +1450,8 @@ void QWindowsWindow::setGeometry_sys(const QRect &rect) const
// window, set the normal position of the window.
if ((windowPlacement.showCmd == SW_MAXIMIZE && !IsWindowVisible(m_data.hwnd))
|| windowPlacement.showCmd == SW_SHOWMINIMIZED) {
- windowPlacement.rcNormalPosition = RECTfromQRect(frameGeometry);
+ windowPlacement.rcNormalPosition =
+ RECTfromQRect(frameGeometry.translated(-windowPlacementOffset(m_data.hwnd, frameGeometry.topLeft())));
windowPlacement.showCmd = windowPlacement.showCmd == SW_SHOWMINIMIZED ? SW_SHOWMINIMIZED : SW_HIDE;
result = SetWindowPlacement(m_data.hwnd, &windowPlacement);
} else