summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs/qwizard_win.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2012-12-17 09:41:36 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-09 20:53:57 +0100
commitf5fd53460387411a3ed192595562fc2cfd92a2b6 (patch)
tree4d5a7aab3a7a74eae44602680cb179da3e25fa08 /src/widgets/dialogs/qwizard_win.cpp
parentccbff3fce504bd2ee99fe22f6e275c7033a3f9f7 (diff)
Fix frame of Aero-Style wizards.
Add custom frames which are added to the system frame to the platform plugin. Make them settable when creating a platform window using dynamic properties and per window properties of the platform native interface. Use this in favor of the native event handling changing the frame in wizard_win.cpp since that caused the frame/backing store sizes of the QWindow to be wrong. Task-number: QTBUG-28099 Change-Id: Idd6416cf1b0eb629f56663088b0ce17162e1739d Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'src/widgets/dialogs/qwizard_win.cpp')
-rw-r--r--src/widgets/dialogs/qwizard_win.cpp67
1 files changed, 23 insertions, 44 deletions
diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp
index c78202e866..e328a5f498 100644
--- a/src/widgets/dialogs/qwizard_win.cpp
+++ b/src/widgets/dialogs/qwizard_win.cpp
@@ -49,7 +49,9 @@
#include "qwizard.h"
#include "qpaintengine.h"
#include "qapplication.h"
+#include <QtCore/QVariant>
#include <QtGui/QMouseEvent>
+#include <QtGui/QWindow>
#include <QtWidgets/QDesktopWidget>
// Note, these tests are duplicates in qwindowsxpstyle_p.h.
@@ -66,6 +68,8 @@
#include <uxtheme.h>
+Q_DECLARE_METATYPE(QMargins)
+
QT_BEGIN_NAMESPACE
//DWM related
@@ -265,6 +269,24 @@ QVistaHelper::~QVistaHelper()
--instanceCount;
}
+void QVistaHelper::updateCustomMargins()
+{
+ if (QWindow *window = wizard->windowHandle()) {
+ // Reduce top frame to zero since we paint it ourselves.
+ const QMargins customMargins = vistaState() == VistaAero ?
+ QMargins(0, -titleBarSize(), 0, 0) : QMargins();
+ const QVariant customMarginsV = qVariantFromValue(customMargins);
+ // The dynamic property takes effect when creating the platform window.
+ window->setProperty("_q_windowsCustomMargins", customMarginsV);
+ // If a platform window exists, change via native interface.
+ if (QPlatformWindow *platformWindow = window->handle()) {
+ QGuiApplication::platformNativeInterface()->
+ setWindowProperty(platformWindow, QStringLiteral("WindowsCustomMargins"),
+ customMarginsV);
+ }
+ }
+}
+
bool QVistaHelper::isCompositionEnabled()
{
bool value = is_vista;
@@ -402,13 +424,6 @@ bool QVistaHelper::winEvent(MSG* msg, long* result)
}
break;
}
-// case WM_NCCALCSIZE: { #fixme: If the frame size is changed, it needs to be communicated to the QWindow.
-// NCCALCSIZE_PARAMS* lpncsp = (NCCALCSIZE_PARAMS*)msg->lParam;
-// *result = DefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam);
-// lpncsp->rgrc[0].top -= (vistaState() == VistaAero ? titleBarSize() : 0);
-//
-// break;
-// }
default:
LRESULT lResult;
// Pass to DWM to handle
@@ -449,38 +464,6 @@ void QVistaHelper::mouseEvent(QEvent *event)
}
}
-// The following hack ensures that the titlebar is updated correctly
-// when the wizard style changes to and from AeroStyle. Specifically,
-// this function causes a Windows message of type WM_NCCALCSIZE to
-// be triggered.
-void QVistaHelper::setWindowPosHack()
-{
- const int x = wizard->geometry().x(); // ignored by SWP_NOMOVE
- const int y = wizard->geometry().y(); // ignored by SWP_NOMOVE
- const int w = wizard->width();
- const int h = wizard->height();
- HWND handle = QApplicationPrivate::getHWNDForWidget(wizard);
- SetWindowPos(handle, 0, x, y, w, h, SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED);
-}
-
-// The following hack allows any QWidget subclass to access
-// QWidgetPrivate::topData() without being declared as a
-// friend by QWidget.
-class QHackWidget : public QWidget
-{
-public:
- Q_DECLARE_PRIVATE(QWidget)
- QTLWExtra* topData() { return d_func()->topData(); }
-};
-
-void QVistaHelper::collapseTopFrameStrut()
-{
- QTLWExtra *top = ((QHackWidget *)wizard)->d_func()->topData();
- int x1, y1, x2, y2;
- top->frameStrut.getCoords(&x1, &y1, &x2, &y2);
- top->frameStrut.setCoords(x1, 0, x2, y2);
-}
-
bool QVistaHelper::handleWinEvent(MSG *message, long *result)
{
if (message->message == WIZ_WM_THEMECHANGED || message->message == WIZ_WM_DWMCOMPOSITIONCHANGED)
@@ -489,12 +472,8 @@ bool QVistaHelper::handleWinEvent(MSG *message, long *result)
bool status = false;
if (wizard->wizardStyle() == QWizard::AeroStyle && vistaState() == VistaAero) {
status = winEvent(message, result);
- if (message->message == WM_NCCALCSIZE) {
-// if (status) #fixme
-// collapseTopFrameStrut();
- } else if (message->message == WM_NCPAINT) {
+ if (message->message == WM_NCPAINT)
wizard->update();
- }
}
return status;
}