Windows: Take custom margins into account for size constraints.
Fix a warning unearthed by the task's code example. The minimum size of the window would be too big since it did not take the negative custom top margin into account. Task-number: QTBUG-29904 Change-Id: I8b71a39f0724bdd1b9359676ce1d86ef5384d685 Reviewed-by: Oliver Wolff <oliver.wolff@digia.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
This commit is contained in:
parent
f2dc9f1dc2
commit
f4933eba54
@ -575,9 +575,10 @@ void WindowCreationData::initialize(HWND hwnd, bool frameChange, qreal opacityLe
|
|||||||
|
|
||||||
#define QWINDOWSIZE_MAX ((1<<24)-1)
|
#define QWINDOWSIZE_MAX ((1<<24)-1)
|
||||||
|
|
||||||
QWindowsGeometryHint::QWindowsGeometryHint(const QWindow *w) :
|
QWindowsGeometryHint::QWindowsGeometryHint(const QWindow *w, const QMargins &cm) :
|
||||||
minimumSize(w->minimumSize()),
|
minimumSize(w->minimumSize()),
|
||||||
maximumSize(w->maximumSize())
|
maximumSize(w->maximumSize()),
|
||||||
|
customMargins(cm)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -650,8 +651,8 @@ void QWindowsGeometryHint::applyToMinMaxInfo(DWORD style, DWORD exStyle, MINMAXI
|
|||||||
<< " in " << *mmi;
|
<< " in " << *mmi;
|
||||||
|
|
||||||
const QMargins margins = QWindowsGeometryHint::frame(style, exStyle);
|
const QMargins margins = QWindowsGeometryHint::frame(style, exStyle);
|
||||||
const int frameWidth = margins.left() + margins.right();
|
const int frameWidth = margins.left() + margins.right() + customMargins.left() + customMargins.right();
|
||||||
const int frameHeight = margins.top() + margins.bottom();
|
const int frameHeight = margins.top() + margins.bottom() + customMargins.top() + customMargins.bottom();
|
||||||
if (minimumSize.width() > 0)
|
if (minimumSize.width() > 0)
|
||||||
mmi->ptMinTrackSize.x = minimumSize.width() + frameWidth;
|
mmi->ptMinTrackSize.x = minimumSize.width() + frameWidth;
|
||||||
if (minimumSize.height() > 0)
|
if (minimumSize.height() > 0)
|
||||||
@ -702,7 +703,7 @@ QWindowCreationContext::QWindowCreationContext(const QWindow *w,
|
|||||||
const QRect &geometry,
|
const QRect &geometry,
|
||||||
const QMargins &cm,
|
const QMargins &cm,
|
||||||
DWORD style_, DWORD exStyle_) :
|
DWORD style_, DWORD exStyle_) :
|
||||||
geometryHint(w), style(style_), exStyle(exStyle_),
|
geometryHint(w, cm), style(style_), exStyle(exStyle_),
|
||||||
requestedGeometry(geometry), obtainedGeometry(geometry),
|
requestedGeometry(geometry), obtainedGeometry(geometry),
|
||||||
margins(QWindowsGeometryHint::frame(style, exStyle)), customMargins(cm),
|
margins(QWindowsGeometryHint::frame(style, exStyle)), customMargins(cm),
|
||||||
frameX(CW_USEDEFAULT), frameY(CW_USEDEFAULT),
|
frameX(CW_USEDEFAULT), frameY(CW_USEDEFAULT),
|
||||||
@ -1095,7 +1096,7 @@ void QWindowsWindow::setGeometry(const QRect &rectIn)
|
|||||||
const QSize newSize = rect.size();
|
const QSize newSize = rect.size();
|
||||||
// Check on hint.
|
// Check on hint.
|
||||||
if (newSize != oldSize) {
|
if (newSize != oldSize) {
|
||||||
const QWindowsGeometryHint hint(window());
|
const QWindowsGeometryHint hint(window(), m_data.customMargins);
|
||||||
if (!hint.validSize(newSize)) {
|
if (!hint.validSize(newSize)) {
|
||||||
qWarning("%s: Attempt to set a size (%dx%d) violating the constraints"
|
qWarning("%s: Attempt to set a size (%dx%d) violating the constraints"
|
||||||
"(%dx%d - %dx%d) on window '%s'.", __FUNCTION__,
|
"(%dx%d - %dx%d) on window '%s'.", __FUNCTION__,
|
||||||
@ -1683,7 +1684,7 @@ void QWindowsWindow::setFrameStrutEventsEnabled(bool enabled)
|
|||||||
#ifndef Q_OS_WINCE // maybe available on some SDKs revisit WM_GETMINMAXINFO
|
#ifndef Q_OS_WINCE // maybe available on some SDKs revisit WM_GETMINMAXINFO
|
||||||
void QWindowsWindow::getSizeHints(MINMAXINFO *mmi) const
|
void QWindowsWindow::getSizeHints(MINMAXINFO *mmi) const
|
||||||
{
|
{
|
||||||
const QWindowsGeometryHint hint(window());
|
const QWindowsGeometryHint hint(window(), m_data.customMargins);
|
||||||
hint.applyToMinMaxInfo(m_data.hwnd, mmi);
|
hint.applyToMinMaxInfo(m_data.hwnd, mmi);
|
||||||
if (QWindowsContext::verboseWindows)
|
if (QWindowsContext::verboseWindows)
|
||||||
qDebug() << __FUNCTION__ << window() << *mmi;
|
qDebug() << __FUNCTION__ << window() << *mmi;
|
||||||
|
@ -67,7 +67,7 @@ class QWindowsEGLStaticContext;
|
|||||||
struct QWindowsGeometryHint
|
struct QWindowsGeometryHint
|
||||||
{
|
{
|
||||||
QWindowsGeometryHint() {}
|
QWindowsGeometryHint() {}
|
||||||
explicit QWindowsGeometryHint(const QWindow *w);
|
explicit QWindowsGeometryHint(const QWindow *w, const QMargins &customMargins);
|
||||||
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);
|
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
|
||||||
@ -85,6 +85,7 @@ struct QWindowsGeometryHint
|
|||||||
|
|
||||||
QSize minimumSize;
|
QSize minimumSize;
|
||||||
QSize maximumSize;
|
QSize maximumSize;
|
||||||
|
QMargins customMargins;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct QWindowCreationContext
|
struct QWindowCreationContext
|
||||||
|
Loading…
Reference in New Issue
Block a user