diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2011-10-18 15:33:19 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-18 15:47:49 +0200 |
commit | b419e567c028a6cbc2e0c30906426d12f4abc99c (patch) | |
tree | 96e657ab4b2a97b3ea15625937733407c9c9dff3 /src/plugins/platforms/windows/qwindowswindow.cpp | |
parent | 87274e272d2a854563066489e20d019b4e6320de (diff) |
Windows platform: Improve Open GL.
- Pass on version to ARB.
- Query obtained ARB format more fine-grained depending on version,
indicate failures
- Fix GDI contexts and introduce gl=gdi to activate the GDI
functionality
- Adapt window flags after setParent if top level state changes
- Remove unused OpenGL flag from integration/context
Change-Id: I59ca74ee1fa727bd2bcfd605b3907bc82cca18fa
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowswindow.cpp')
-rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.cpp | 54 |
1 files changed, 38 insertions, 16 deletions
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index fc59be640b..095b22c1be 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -57,7 +57,6 @@ QT_BEGIN_NAMESPACE static QByteArray debugWinStyle(DWORD style) { - QByteArray rc = "0x"; rc += QByteArray::number(qulonglong(style), 16); if (style & WS_POPUP) @@ -83,6 +82,19 @@ static QByteArray debugWinStyle(DWORD style) return rc; } +static QByteArray debugWinExStyle(DWORD exStyle) +{ + QByteArray rc = "0x"; + rc += QByteArray::number(qulonglong(exStyle), 16); + if (exStyle & WS_EX_TOOLWINDOW) + rc += " WS_EX_TOOLWINDOW"; + if (exStyle & WS_EX_CONTEXTHELP) + rc += " WS_EX_CONTEXTHELP"; + if (exStyle & WS_EX_LAYERED) + rc += " WS_EX_LAYERED"; + return rc; +} + static QByteArray debugWindowStates(Qt::WindowStates s) { @@ -194,12 +206,13 @@ static bool shouldShowMaximizeButton(Qt::WindowFlags flags) struct WindowCreationData { typedef QWindowsWindow::WindowData WindowData; + enum Flags { ForceChild = 0x1 }; WindowCreationData() : parentHandle(0), type(Qt::Widget), style(0), exStyle(0), topLevel(false), popup(false), dialog(false), desktop(false), tool(false) {} - void fromWindow(const QWindow *w, const Qt::WindowFlags flags, bool isGL); + 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 void applyWindowFlags(HWND hwnd) const; void initialize(HWND h, bool frameChange) const; @@ -220,20 +233,20 @@ struct WindowCreationData QDebug operator<<(QDebug debug, const WindowCreationData &d) { debug.nospace() << QWindowsWindow::debugWindowFlags(d.flags) - << " gs=" << d.isGL << " topLevel=" << d.topLevel << " popup=" + << " GL=" << d.isGL << " topLevel=" << d.topLevel << " popup=" << d.popup << " dialog=" << d.dialog << " desktop=" << d.desktop << " tool=" << d.tool << " style=" << debugWinStyle(d.style) - << " exStyle=0x" << QString::number(d.exStyle, 16) + << " exStyle=" << debugWinExStyle(d.exStyle) << " parent=" << d.parentHandle; return debug; } void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flagsIn, - bool isGLin) + unsigned creationFlags) { - isGL = isGLin; + isGL = w->surfaceType() == QWindow::OpenGLSurface; flags = flagsIn; - topLevel = w->isTopLevel(); + topLevel = (creationFlags & ForceChild) ? false : w->isTopLevel(); if (topLevel && flags == 1) { qWarning("Remove me: fixing toplevel window flags"); @@ -397,9 +410,9 @@ void WindowCreationData::applyWindowFlags(HWND hwnd) const if (QWindowsContext::verboseWindows) qDebug().nospace() << __FUNCTION__ << hwnd << *this << "\n Style from " << debugWinStyle(oldStyle) << "\n to " - << debugWinStyle(newStyle) << "\n ExStyle from 0x" - << QByteArray::number(qulonglong(oldExStyle), 16) << " to 0x" - << QByteArray::number(qulonglong(newExStyle), 16); + << debugWinStyle(newStyle) << "\n ExStyle from " + << debugWinExStyle(oldExStyle) << " to " + << debugWinExStyle(newExStyle); } void WindowCreationData::initialize(HWND hwnd, bool frameChange) const @@ -651,12 +664,11 @@ QWindow *QWindowsWindow::topLevelOf(QWindow *w) QWindowsWindow::WindowData QWindowsWindow::WindowData::create(const QWindow *w, - const WindowData ¶meters, - const QString &title, - bool isGL) + const WindowData ¶meters, + const QString &title) { WindowCreationData creationData; - creationData.fromWindow(w, parameters.flags, isGL); + creationData.fromWindow(w, parameters.flags); WindowData result = creationData.create(w, parameters.geometry, title); creationData.initialize(result.hwnd, false); return result; @@ -748,8 +760,17 @@ void QWindowsWindow::setParent_sys(const QPlatformWindow *parent) const if (parent) { const QWindowsWindow *parentW = static_cast<const QWindowsWindow *>(parent); parentHWND = parentW->handle(); + } + const bool wasTopLevel = window()->isTopLevel(); + const bool isTopLevel = parentHWND == 0; SetParent(m_data.hwnd, parentHWND); + // WS_CHILD/WS_POPUP must be manually set/cleared in addition + // to dialog frames, etc (see SetParent() ) if the top level state changes. + if (wasTopLevel != isTopLevel) { + const unsigned flags = isTopLevel ? unsigned(0) : unsigned(WindowCreationData::ForceChild); + setWindowFlags_sys(window()->windowFlags(), flags); + } } void QWindowsWindow::handleShown() @@ -934,11 +955,12 @@ Qt::WindowFlags QWindowsWindow::setWindowFlags(Qt::WindowFlags flags) return m_data.flags; } -QWindowsWindow::WindowData QWindowsWindow::setWindowFlags_sys(Qt::WindowFlags wt) const +QWindowsWindow::WindowData QWindowsWindow::setWindowFlags_sys(Qt::WindowFlags wt, + unsigned flags) const { // Geometry changes have not been observed here. Frames change, though. WindowCreationData creationData; - creationData.fromWindow(window(), wt, window()->surfaceType() == QWindow::OpenGLSurface); + creationData.fromWindow(window(), wt, flags); creationData.applyWindowFlags(m_data.hwnd); creationData.initialize(m_data.hwnd, true); WindowData result = m_data; |