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>
This commit is contained in:
parent
ccbff3fce5
commit
f5fd534603
@ -783,7 +783,7 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
|
|||||||
d->m_creationContext->obtainedGeometry.moveTo(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
d->m_creationContext->obtainedGeometry.moveTo(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
||||||
return true;
|
return true;
|
||||||
case QtWindows::CalculateSize:
|
case QtWindows::CalculateSize:
|
||||||
return false;
|
return QWindowsGeometryHint::handleCalculateSize(d->m_creationContext->customMargins, msg, result);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -818,12 +818,7 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
|
|||||||
platformWindow->getSizeHints(reinterpret_cast<MINMAXINFO *>(lParam));
|
platformWindow->getSizeHints(reinterpret_cast<MINMAXINFO *>(lParam));
|
||||||
return true;// maybe available on some SDKs revisit WM_NCCALCSIZE
|
return true;// maybe available on some SDKs revisit WM_NCCALCSIZE
|
||||||
case QtWindows::CalculateSize:
|
case QtWindows::CalculateSize:
|
||||||
// NCCALCSIZE_PARAMS structure if wParam==TRUE
|
return QWindowsGeometryHint::handleCalculateSize(platformWindow->customMargins(), msg, result);
|
||||||
if (wParam && QWindowsContext::verboseWindows) {
|
|
||||||
const NCCALCSIZE_PARAMS *ncp = reinterpret_cast<NCCALCSIZE_PARAMS *>(lParam);
|
|
||||||
qDebug() << platformWindow->window() << *ncp;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
case QtWindows::ExposeEvent:
|
case QtWindows::ExposeEvent:
|
||||||
return platformWindow->handleWmPaint(hwnd, message, wParam, lParam);
|
return platformWindow->handleWmPaint(hwnd, message, wParam, lParam);
|
||||||
|
@ -75,6 +75,7 @@
|
|||||||
|
|
||||||
#include <QtCore/private/qeventdispatcher_win_p.h>
|
#include <QtCore/private/qeventdispatcher_win_p.h>
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
|
#include <QtCore/QVariant>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@ -109,6 +110,11 @@ public:
|
|||||||
void *eventProc) const;
|
void *eventProc) const;
|
||||||
bool asyncExpose() const;
|
bool asyncExpose() const;
|
||||||
void setAsyncExpose(bool value);
|
void setAsyncExpose(bool value);
|
||||||
|
|
||||||
|
QVariantMap windowProperties(QPlatformWindow *window) const;
|
||||||
|
QVariant windowProperty(QPlatformWindow *window, const QString &name) const;
|
||||||
|
QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const;
|
||||||
|
void setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value);
|
||||||
};
|
};
|
||||||
|
|
||||||
void *QWindowsNativeInterface::nativeResourceForWindow(const QByteArray &resource, QWindow *window)
|
void *QWindowsNativeInterface::nativeResourceForWindow(const QByteArray &resource, QWindow *window)
|
||||||
@ -145,6 +151,37 @@ void *QWindowsNativeInterface::nativeResourceForBackingStore(const QByteArray &r
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char customMarginPropertyC[] = "WindowsCustomMargins";
|
||||||
|
|
||||||
|
QVariant QWindowsNativeInterface::windowProperty(QPlatformWindow *window, const QString &name) const
|
||||||
|
{
|
||||||
|
QWindowsWindow *platformWindow = static_cast<QWindowsWindow *>(window);
|
||||||
|
if (name == QLatin1String(customMarginPropertyC))
|
||||||
|
return qVariantFromValue(platformWindow->customMargins());
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant QWindowsNativeInterface::windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const
|
||||||
|
{
|
||||||
|
const QVariant result = windowProperty(window, name);
|
||||||
|
return result.isValid() ? result : defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QWindowsNativeInterface::setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value)
|
||||||
|
{
|
||||||
|
QWindowsWindow *platformWindow = static_cast<QWindowsWindow *>(window);
|
||||||
|
if (name == QLatin1String(customMarginPropertyC))
|
||||||
|
platformWindow->setCustomMargins(qvariant_cast<QMargins>(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantMap QWindowsNativeInterface::windowProperties(QPlatformWindow *window) const
|
||||||
|
{
|
||||||
|
QVariantMap result;
|
||||||
|
const QString customMarginProperty = QLatin1String(customMarginPropertyC);
|
||||||
|
result.insert(customMarginProperty, windowProperty(window, customMarginProperty));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_OPENGL
|
#ifndef QT_NO_OPENGL
|
||||||
void *QWindowsNativeInterface::nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context)
|
void *QWindowsNativeInterface::nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context)
|
||||||
{
|
{
|
||||||
@ -356,6 +393,11 @@ QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) cons
|
|||||||
QWindowsWindow::WindowData requested;
|
QWindowsWindow::WindowData requested;
|
||||||
requested.flags = window->flags();
|
requested.flags = window->flags();
|
||||||
requested.geometry = window->geometry();
|
requested.geometry = window->geometry();
|
||||||
|
// Apply custom margins (see QWindowsWindow::setCustomMargins())).
|
||||||
|
const QVariant customMarginsV = window->property("_q_windowsCustomMargins");
|
||||||
|
if (customMarginsV.isValid())
|
||||||
|
requested.customMargins = qvariant_cast<QMargins>(customMarginsV);
|
||||||
|
|
||||||
const QWindowsWindow::WindowData obtained
|
const QWindowsWindow::WindowData obtained
|
||||||
= QWindowsWindow::WindowData::create(window, requested, window->title());
|
= QWindowsWindow::WindowData::create(window, requested, window->title());
|
||||||
if (QWindowsContext::verboseIntegration || QWindowsContext::verboseWindows)
|
if (QWindowsContext::verboseIntegration || QWindowsContext::verboseWindows)
|
||||||
|
@ -274,7 +274,7 @@ struct WindowCreationData
|
|||||||
tool(false), embedded(false) {}
|
tool(false), embedded(false) {}
|
||||||
|
|
||||||
void fromWindow(const QWindow *w, const Qt::WindowFlags flags, unsigned creationFlags = 0);
|
void fromWindow(const QWindow *w, const Qt::WindowFlags flags, unsigned creationFlags = 0);
|
||||||
inline WindowData create(const QWindow *w, const QRect &geometry, QString title) const;
|
inline WindowData create(const QWindow *w, const WindowData &data, QString title) const;
|
||||||
inline void applyWindowFlags(HWND hwnd) const;
|
inline void applyWindowFlags(HWND hwnd) const;
|
||||||
void initialize(HWND h, bool frameChange, qreal opacityLevel) const;
|
void initialize(HWND h, bool frameChange, qreal opacityLevel) const;
|
||||||
|
|
||||||
@ -416,7 +416,7 @@ void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flag
|
|||||||
}
|
}
|
||||||
|
|
||||||
QWindowsWindow::WindowData
|
QWindowsWindow::WindowData
|
||||||
WindowCreationData::create(const QWindow *w, const QRect &geometry, QString title) const
|
WindowCreationData::create(const QWindow *w, const WindowData &data, QString title) const
|
||||||
{
|
{
|
||||||
typedef QSharedPointer<QWindowCreationContext> QWindowCreationContextPtr;
|
typedef QSharedPointer<QWindowCreationContext> QWindowCreationContextPtr;
|
||||||
|
|
||||||
@ -442,24 +442,25 @@ QWindowsWindow::WindowData
|
|||||||
const wchar_t *titleUtf16 = reinterpret_cast<const wchar_t *>(title.utf16());
|
const wchar_t *titleUtf16 = reinterpret_cast<const wchar_t *>(title.utf16());
|
||||||
const wchar_t *classNameUtf16 = reinterpret_cast<const wchar_t *>(windowClassName.utf16());
|
const wchar_t *classNameUtf16 = reinterpret_cast<const wchar_t *>(windowClassName.utf16());
|
||||||
|
|
||||||
// Capture events before CreateWindowEx() returns.
|
// Capture events before CreateWindowEx() returns. The context is cleared in
|
||||||
const QWindowCreationContextPtr context(new QWindowCreationContext(w, geometry, style, exStyle));
|
// the QWindowsWindow constructor.
|
||||||
|
const QWindowCreationContextPtr context(new QWindowCreationContext(w, data.geometry, data.customMargins, style, exStyle));
|
||||||
QWindowsContext::instance()->setWindowCreationContext(context);
|
QWindowsContext::instance()->setWindowCreationContext(context);
|
||||||
|
|
||||||
if (QWindowsContext::verboseWindows)
|
if (QWindowsContext::verboseWindows)
|
||||||
qDebug().nospace()
|
qDebug().nospace()
|
||||||
<< "CreateWindowEx: " << w << *this
|
<< "CreateWindowEx: " << w << *this
|
||||||
<< " class=" <<windowClassName << " title=" << title
|
<< " class=" <<windowClassName << " title=" << title
|
||||||
<< "\nrequested: " << geometry << ": "
|
<< "\nrequested: " << data.geometry << ": "
|
||||||
<< context->frameWidth << 'x' << context->frameHeight
|
<< context->frameWidth << 'x' << context->frameHeight
|
||||||
<< '+' << context->frameX << '+' << context->frameY;
|
<< '+' << context->frameX << '+' << context->frameY
|
||||||
|
<< " custom margins: " << context->customMargins;
|
||||||
|
|
||||||
result.hwnd = CreateWindowEx(exStyle, classNameUtf16, titleUtf16,
|
result.hwnd = CreateWindowEx(exStyle, classNameUtf16, titleUtf16,
|
||||||
style,
|
style,
|
||||||
context->frameX, context->frameY,
|
context->frameX, context->frameY,
|
||||||
context->frameWidth, context->frameHeight,
|
context->frameWidth, context->frameHeight,
|
||||||
parentHandle, NULL, appinst, NULL);
|
parentHandle, NULL, appinst, NULL);
|
||||||
QWindowsContext::instance()->setWindowCreationContext(QWindowCreationContextPtr());
|
|
||||||
if (QWindowsContext::verboseWindows)
|
if (QWindowsContext::verboseWindows)
|
||||||
qDebug().nospace()
|
qDebug().nospace()
|
||||||
<< "CreateWindowEx: returns " << w << ' ' << result.hwnd << " obtained geometry: "
|
<< "CreateWindowEx: returns " << w << ' ' << result.hwnd << " obtained geometry: "
|
||||||
@ -473,6 +474,7 @@ QWindowsWindow::WindowData
|
|||||||
result.geometry = context->obtainedGeometry;
|
result.geometry = context->obtainedGeometry;
|
||||||
result.frame = context->margins;
|
result.frame = context->margins;
|
||||||
result.embedded = embedded;
|
result.embedded = embedded;
|
||||||
|
result.customMargins = context->customMargins;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -511,6 +513,8 @@ void WindowCreationData::initialize(HWND hwnd, bool frameChange, qreal opacityLe
|
|||||||
qWarning() << "QWidget: Incompatible window flags: the window can't be on top and on bottom at the same time";
|
qWarning() << "QWidget: Incompatible window flags: the window can't be on top and on bottom at the same time";
|
||||||
} else if (flags & Qt::WindowStaysOnBottomHint) {
|
} else if (flags & Qt::WindowStaysOnBottomHint) {
|
||||||
SetWindowPos(hwnd, HWND_BOTTOM, 0, 0, 0, 0, swpFlags);
|
SetWindowPos(hwnd, HWND_BOTTOM, 0, 0, 0, 0, swpFlags);
|
||||||
|
} else if (frameChange) { // Force WM_NCCALCSIZE with wParam=1 in case of custom margins.
|
||||||
|
SetWindowPos(hwnd, 0, 0, 0, 0, 0, swpFlags);
|
||||||
}
|
}
|
||||||
if (flags & (Qt::CustomizeWindowHint|Qt::WindowTitleHint)) {
|
if (flags & (Qt::CustomizeWindowHint|Qt::WindowTitleHint)) {
|
||||||
HMENU systemMenu = GetSystemMenu(hwnd, FALSE);
|
HMENU systemMenu = GetSystemMenu(hwnd, FALSE);
|
||||||
@ -571,6 +575,33 @@ QMargins QWindowsGeometryHint::frame(DWORD style, DWORD exStyle)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QWindowsGeometryHint::handleCalculateSize(const QMargins &customMargins, const MSG &msg, LRESULT *result)
|
||||||
|
{
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// NCCALCSIZE_PARAMS structure if wParam==TRUE
|
||||||
|
if (!msg.wParam || customMargins.isNull())
|
||||||
|
return false;
|
||||||
|
*result = DefWindowProc(msg.hwnd, msg.message, msg.wParam, msg.lParam);
|
||||||
|
NCCALCSIZE_PARAMS *ncp = reinterpret_cast<NCCALCSIZE_PARAMS *>(msg.lParam);
|
||||||
|
const RECT oldClientArea = ncp->rgrc[0];
|
||||||
|
ncp->rgrc[0].left += customMargins.left();
|
||||||
|
ncp->rgrc[0].top += customMargins.top();
|
||||||
|
ncp->rgrc[0].right -= customMargins.right();
|
||||||
|
ncp->rgrc[0].bottom -= customMargins.bottom();
|
||||||
|
result = 0;
|
||||||
|
if (QWindowsContext::verboseWindows)
|
||||||
|
qDebug() << __FUNCTION__ << oldClientArea << '+' << customMargins << "-->"
|
||||||
|
<< ncp->rgrc[0] << ' ' << ncp->rgrc[1] << ' ' << ncp->rgrc[2]
|
||||||
|
<< ' ' << ncp->lppos->cx << ',' << ncp->lppos->cy;
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
Q_UNUSED(customMargins)
|
||||||
|
Q_UNUSED(msg)
|
||||||
|
Q_UNUSED(result)
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef Q_OS_WINCE
|
#ifndef Q_OS_WINCE
|
||||||
void QWindowsGeometryHint::applyToMinMaxInfo(HWND hwnd, MINMAXINFO *mmi) const
|
void QWindowsGeometryHint::applyToMinMaxInfo(HWND hwnd, MINMAXINFO *mmi) const
|
||||||
{
|
{
|
||||||
@ -637,10 +668,11 @@ bool QWindowsGeometryHint::positionIncludesFrame(const QWindow *w)
|
|||||||
|
|
||||||
QWindowCreationContext::QWindowCreationContext(const QWindow *w,
|
QWindowCreationContext::QWindowCreationContext(const QWindow *w,
|
||||||
const QRect &geometry,
|
const QRect &geometry,
|
||||||
|
const QMargins &cm,
|
||||||
DWORD style_, DWORD exStyle_) :
|
DWORD style_, DWORD exStyle_) :
|
||||||
geometryHint(w), style(style_), exStyle(exStyle_),
|
geometryHint(w), style(style_), exStyle(exStyle_),
|
||||||
requestedGeometry(geometry), obtainedGeometry(geometry),
|
requestedGeometry(geometry), obtainedGeometry(geometry),
|
||||||
margins(QWindowsGeometryHint::frame(style, exStyle)),
|
margins(QWindowsGeometryHint::frame(style, exStyle)), customMargins(cm),
|
||||||
frameX(CW_USEDEFAULT), frameY(CW_USEDEFAULT),
|
frameX(CW_USEDEFAULT), frameY(CW_USEDEFAULT),
|
||||||
frameWidth(CW_USEDEFAULT), frameHeight(CW_USEDEFAULT)
|
frameWidth(CW_USEDEFAULT), frameHeight(CW_USEDEFAULT)
|
||||||
{
|
{
|
||||||
@ -651,14 +683,16 @@ QWindowCreationContext::QWindowCreationContext(const QWindow *w,
|
|||||||
if (geometry.isValid()) {
|
if (geometry.isValid()) {
|
||||||
frameX = geometry.x();
|
frameX = geometry.x();
|
||||||
frameY = geometry.y();
|
frameY = geometry.y();
|
||||||
frameWidth = margins.left() + geometry.width() + margins.right();
|
const QMargins effectiveMargins = margins + customMargins;
|
||||||
frameHeight = margins.top() + geometry.height() + margins.bottom();
|
frameWidth = effectiveMargins.left() + geometry.width() + effectiveMargins.right();
|
||||||
|
frameHeight = effectiveMargins.top() + geometry.height() + effectiveMargins.bottom();
|
||||||
const bool isDefaultPosition = !frameX && !frameY && w->isTopLevel();
|
const bool isDefaultPosition = !frameX && !frameY && w->isTopLevel();
|
||||||
if (!QWindowsGeometryHint::positionIncludesFrame(w) && !isDefaultPosition) {
|
if (!QWindowsGeometryHint::positionIncludesFrame(w) && !isDefaultPosition) {
|
||||||
frameX -= margins.left();
|
frameX -= effectiveMargins.left();
|
||||||
frameY -= margins.top();
|
frameY -= effectiveMargins.top();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QWindowsContext::verboseWindows)
|
if (QWindowsContext::verboseWindows)
|
||||||
qDebug().nospace()
|
qDebug().nospace()
|
||||||
<< __FUNCTION__ << ' ' << w << geometry
|
<< __FUNCTION__ << ' ' << w << geometry
|
||||||
@ -666,7 +700,8 @@ QWindowCreationContext::QWindowCreationContext(const QWindow *w,
|
|||||||
<< " frame: " << frameWidth << 'x' << frameHeight << '+'
|
<< " frame: " << frameWidth << 'x' << frameHeight << '+'
|
||||||
<< frameX << '+' << frameY
|
<< frameX << '+' << frameY
|
||||||
<< " min" << geometryHint.minimumSize
|
<< " min" << geometryHint.minimumSize
|
||||||
<< " max" << geometryHint.maximumSize;
|
<< " max" << geometryHint.maximumSize
|
||||||
|
<< " custom margins " << customMargins;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -713,6 +748,8 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const WindowData &data) :
|
|||||||
{
|
{
|
||||||
if (aWindow->surfaceType() == QWindow::OpenGLSurface)
|
if (aWindow->surfaceType() == QWindow::OpenGLSurface)
|
||||||
setFlag(OpenGLSurface);
|
setFlag(OpenGLSurface);
|
||||||
|
// Clear the creation context as the window can be found in QWindowsContext's map.
|
||||||
|
QWindowsContext::instance()->setWindowCreationContext(QSharedPointer<QWindowCreationContext>());
|
||||||
QWindowsContext::instance()->addWindow(m_data.hwnd, this);
|
QWindowsContext::instance()->addWindow(m_data.hwnd, this);
|
||||||
if (aWindow->isTopLevel()) {
|
if (aWindow->isTopLevel()) {
|
||||||
switch (aWindow->type()) {
|
switch (aWindow->type()) {
|
||||||
@ -826,8 +863,9 @@ QWindowsWindow::WindowData
|
|||||||
{
|
{
|
||||||
WindowCreationData creationData;
|
WindowCreationData creationData;
|
||||||
creationData.fromWindow(w, parameters.flags);
|
creationData.fromWindow(w, parameters.flags);
|
||||||
WindowData result = creationData.create(w, parameters.geometry, title);
|
WindowData result = creationData.create(w, parameters, title);
|
||||||
creationData.initialize(result.hwnd, false, 1);
|
// Force WM_NCCALCSIZE (with wParam=1) via SWP_FRAMECHANGED for custom margin.
|
||||||
|
creationData.initialize(result.hwnd, !parameters.customMargins.isNull(), 1);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1452,7 +1490,7 @@ QMargins QWindowsWindow::frameMargins() const
|
|||||||
m_data.frame = QWindowsGeometryHint::frame(style(), exStyle());
|
m_data.frame = QWindowsGeometryHint::frame(style(), exStyle());
|
||||||
clearFlag(FrameDirty);
|
clearFlag(FrameDirty);
|
||||||
}
|
}
|
||||||
return m_data.frame;
|
return m_data.frame + m_data.customMargins;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWindowsWindow::setOpacity(qreal level)
|
void QWindowsWindow::setOpacity(qreal level)
|
||||||
@ -1808,4 +1846,32 @@ void QWindowsWindow::setWindowIcon(const QIcon &icon)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Sets custom margins to be added to the default margins determined by
|
||||||
|
the windows style in the handling of the WM_NCCALCSIZE message.
|
||||||
|
|
||||||
|
This is currently used to give the Aero-style QWizard a smaller top margin.
|
||||||
|
The property can be set using QPlatformNativeInterface::setWindowProperty() or,
|
||||||
|
before platform window creation, by setting a dynamic property
|
||||||
|
on the QWindow (see QWindowsIntegration::createPlatformWindow()).
|
||||||
|
*/
|
||||||
|
|
||||||
|
void QWindowsWindow::setCustomMargins(const QMargins &newCustomMargins)
|
||||||
|
{
|
||||||
|
if (newCustomMargins != m_data.customMargins) {
|
||||||
|
const QMargins oldCustomMargins = m_data.customMargins;
|
||||||
|
m_data.customMargins = newCustomMargins;
|
||||||
|
// Re-trigger WM_NCALCSIZE with wParam=1 by passing SWP_FRAMECHANGED
|
||||||
|
const QRect currentFrameGeometry = frameGeometry_sys();
|
||||||
|
const QPoint topLeft = currentFrameGeometry.topLeft();
|
||||||
|
QRect newFrame = currentFrameGeometry.marginsRemoved(oldCustomMargins) + m_data.customMargins;
|
||||||
|
newFrame.moveTo(topLeft);
|
||||||
|
setFlag(FrameDirty);
|
||||||
|
if (QWindowsContext::verboseWindows)
|
||||||
|
qDebug() << __FUNCTION__ << oldCustomMargins << "->" << newCustomMargins
|
||||||
|
<< currentFrameGeometry << "->" << newFrame;
|
||||||
|
SetWindowPos(m_data.hwnd, 0, newFrame.x(), newFrame.y(), newFrame.width(), newFrame.height(), SWP_NOZORDER | SWP_FRAMECHANGED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -69,6 +69,7 @@ struct QWindowsGeometryHint
|
|||||||
QWindowsGeometryHint() {}
|
QWindowsGeometryHint() {}
|
||||||
explicit QWindowsGeometryHint(const QWindow *w);
|
explicit QWindowsGeometryHint(const QWindow *w);
|
||||||
static QMargins frame(DWORD style, DWORD exStyle);
|
static QMargins frame(DWORD style, DWORD exStyle);
|
||||||
|
static bool handleCalculateSize(const QMargins &customMargins, const MSG &msg, LRESULT *result);
|
||||||
#ifndef Q_OS_WINCE //MinMax maybe define struct if not available
|
#ifndef Q_OS_WINCE //MinMax maybe define struct if not available
|
||||||
void applyToMinMaxInfo(DWORD style, DWORD exStyle, MINMAXINFO *mmi) const;
|
void applyToMinMaxInfo(DWORD style, DWORD exStyle, MINMAXINFO *mmi) const;
|
||||||
void applyToMinMaxInfo(HWND hwnd, MINMAXINFO *mmi) const;
|
void applyToMinMaxInfo(HWND hwnd, MINMAXINFO *mmi) const;
|
||||||
@ -89,6 +90,7 @@ struct QWindowsGeometryHint
|
|||||||
struct QWindowCreationContext
|
struct QWindowCreationContext
|
||||||
{
|
{
|
||||||
QWindowCreationContext(const QWindow *w, const QRect &r,
|
QWindowCreationContext(const QWindow *w, const QRect &r,
|
||||||
|
const QMargins &customMargins,
|
||||||
DWORD style, DWORD exStyle);
|
DWORD style, DWORD exStyle);
|
||||||
#ifndef Q_OS_WINCE //MinMax maybe define struct if not available
|
#ifndef Q_OS_WINCE //MinMax maybe define struct if not available
|
||||||
void applyToMinMaxInfo(MINMAXINFO *mmi) const
|
void applyToMinMaxInfo(MINMAXINFO *mmi) const
|
||||||
@ -101,6 +103,7 @@ struct QWindowCreationContext
|
|||||||
QRect requestedGeometry;
|
QRect requestedGeometry;
|
||||||
QRect obtainedGeometry;
|
QRect obtainedGeometry;
|
||||||
QMargins margins;
|
QMargins margins;
|
||||||
|
QMargins customMargins; // User-defined, additional frame for WM_NCCALCSIZE
|
||||||
int frameX; // Passed on to CreateWindowEx(), including frame.
|
int frameX; // Passed on to CreateWindowEx(), including frame.
|
||||||
int frameY;
|
int frameY;
|
||||||
int frameWidth;
|
int frameWidth;
|
||||||
@ -137,6 +140,7 @@ public:
|
|||||||
Qt::WindowFlags flags;
|
Qt::WindowFlags flags;
|
||||||
QRect geometry;
|
QRect geometry;
|
||||||
QMargins frame; // Do not use directly for windows, see FrameDirty.
|
QMargins frame; // Do not use directly for windows, see FrameDirty.
|
||||||
|
QMargins customMargins; // User-defined, additional frame for NCCALCSIZE
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
bool embedded;
|
bool embedded;
|
||||||
|
|
||||||
@ -190,6 +194,9 @@ public:
|
|||||||
void setFrameStrutEventsEnabled(bool enabled);
|
void setFrameStrutEventsEnabled(bool enabled);
|
||||||
bool frameStrutEventsEnabled() const { return testFlag(FrameStrutEventsEnabled); }
|
bool frameStrutEventsEnabled() const { return testFlag(FrameStrutEventsEnabled); }
|
||||||
|
|
||||||
|
QMargins customMargins() const { return m_data.customMargins; }
|
||||||
|
void setCustomMargins(const QMargins &m);
|
||||||
|
|
||||||
#ifdef QT_OPENGL_ES_2
|
#ifdef QT_OPENGL_ES_2
|
||||||
EGLSurface eglSurfaceHandle() const { return m_eglSurface;}
|
EGLSurface eglSurfaceHandle() const { return m_eglSurface;}
|
||||||
EGLSurface ensureEglSurfaceHandle(const QWindowsEGLStaticContextPtr &staticContext, EGLConfig config);
|
EGLSurface ensureEglSurfaceHandle(const QWindowsEGLStaticContextPtr &staticContext, EGLConfig config);
|
||||||
@ -353,4 +360,6 @@ inline void QWindowsWindow::destroyIcon()
|
|||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(QMargins)
|
||||||
|
|
||||||
#endif // QWINDOWSWINDOW_H
|
#endif // QWINDOWSWINDOW_H
|
||||||
|
@ -1557,7 +1557,7 @@ void QWizardPrivate::handleAeroStyleChange()
|
|||||||
_q_updateButtonStates();
|
_q_updateButtonStates();
|
||||||
|
|
||||||
if (q->isVisible())
|
if (q->isVisible())
|
||||||
vistaHelper->setWindowPosHack();
|
vistaHelper->updateCustomMargins();
|
||||||
|
|
||||||
inHandleAeroStyleChange = false;
|
inHandleAeroStyleChange = false;
|
||||||
}
|
}
|
||||||
@ -2922,6 +2922,10 @@ QWidget *QWizard::sideWidget() const
|
|||||||
void QWizard::setVisible(bool visible)
|
void QWizard::setVisible(bool visible)
|
||||||
{
|
{
|
||||||
Q_D(QWizard);
|
Q_D(QWizard);
|
||||||
|
#if !defined(QT_NO_STYLE_WINDOWSVISTA)
|
||||||
|
if (visible)
|
||||||
|
d->vistaHelper->updateCustomMargins();
|
||||||
|
#endif
|
||||||
if (visible) {
|
if (visible) {
|
||||||
if (d->current == -1)
|
if (d->current == -1)
|
||||||
restart();
|
restart();
|
||||||
|
@ -49,7 +49,9 @@
|
|||||||
#include "qwizard.h"
|
#include "qwizard.h"
|
||||||
#include "qpaintengine.h"
|
#include "qpaintengine.h"
|
||||||
#include "qapplication.h"
|
#include "qapplication.h"
|
||||||
|
#include <QtCore/QVariant>
|
||||||
#include <QtGui/QMouseEvent>
|
#include <QtGui/QMouseEvent>
|
||||||
|
#include <QtGui/QWindow>
|
||||||
#include <QtWidgets/QDesktopWidget>
|
#include <QtWidgets/QDesktopWidget>
|
||||||
|
|
||||||
// Note, these tests are duplicates in qwindowsxpstyle_p.h.
|
// Note, these tests are duplicates in qwindowsxpstyle_p.h.
|
||||||
@ -66,6 +68,8 @@
|
|||||||
|
|
||||||
#include <uxtheme.h>
|
#include <uxtheme.h>
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(QMargins)
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
//DWM related
|
//DWM related
|
||||||
@ -265,6 +269,24 @@ QVistaHelper::~QVistaHelper()
|
|||||||
--instanceCount;
|
--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 QVistaHelper::isCompositionEnabled()
|
||||||
{
|
{
|
||||||
bool value = is_vista;
|
bool value = is_vista;
|
||||||
@ -402,13 +424,6 @@ bool QVistaHelper::winEvent(MSG* msg, long* result)
|
|||||||
}
|
}
|
||||||
break;
|
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:
|
default:
|
||||||
LRESULT lResult;
|
LRESULT lResult;
|
||||||
// Pass to DWM to handle
|
// 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)
|
bool QVistaHelper::handleWinEvent(MSG *message, long *result)
|
||||||
{
|
{
|
||||||
if (message->message == WIZ_WM_THEMECHANGED || message->message == WIZ_WM_DWMCOMPOSITIONCHANGED)
|
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;
|
bool status = false;
|
||||||
if (wizard->wizardStyle() == QWizard::AeroStyle && vistaState() == VistaAero) {
|
if (wizard->wizardStyle() == QWizard::AeroStyle && vistaState() == VistaAero) {
|
||||||
status = winEvent(message, result);
|
status = winEvent(message, result);
|
||||||
if (message->message == WM_NCCALCSIZE) {
|
if (message->message == WM_NCPAINT)
|
||||||
// if (status) #fixme
|
|
||||||
// collapseTopFrameStrut();
|
|
||||||
} else if (message->message == WM_NCPAINT) {
|
|
||||||
wizard->update();
|
wizard->update();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -87,6 +87,7 @@ public:
|
|||||||
QVistaHelper(QWizard *wizard);
|
QVistaHelper(QWizard *wizard);
|
||||||
~QVistaHelper();
|
~QVistaHelper();
|
||||||
enum TitleBarChangeType { NormalTitleBar, ExtendedTitleBar };
|
enum TitleBarChangeType { NormalTitleBar, ExtendedTitleBar };
|
||||||
|
void updateCustomMargins();
|
||||||
bool setDWMTitleBar(TitleBarChangeType type);
|
bool setDWMTitleBar(TitleBarChangeType type);
|
||||||
void setTitleBarIconAndCaptionVisible(bool visible);
|
void setTitleBarIconAndCaptionVisible(bool visible);
|
||||||
void mouseEvent(QEvent *event);
|
void mouseEvent(QEvent *event);
|
||||||
@ -96,7 +97,6 @@ public:
|
|||||||
QVistaBackButton *backButton() const { return backButton_; }
|
QVistaBackButton *backButton() const { return backButton_; }
|
||||||
void disconnectBackButton() { if (backButton_) backButton_->disconnect(); }
|
void disconnectBackButton() { if (backButton_) backButton_->disconnect(); }
|
||||||
void hideBackButton() { if (backButton_) backButton_->hide(); }
|
void hideBackButton() { if (backButton_) backButton_->hide(); }
|
||||||
void setWindowPosHack();
|
|
||||||
QColor basicWindowFrameColor();
|
QColor basicWindowFrameColor();
|
||||||
enum VistaState { VistaAero, VistaBasic, Classic, Dirty };
|
enum VistaState { VistaAero, VistaBasic, Classic, Dirty };
|
||||||
static VistaState vistaState();
|
static VistaState vistaState();
|
||||||
|
Loading…
Reference in New Issue
Block a user