QPlatformWindow: change API for QPlatformWindow::setWindowFlags

The current implementation requests the platform window to set
as many of the flags it can, and return the same flags with the
unsupported flags removed.

The problem with this approach is that the platform window is created
as late as possible, so a call to QWindow::setWindowFlags would in
many (most?) cases never be forwarded to the platform window (instead,
the platform window is responsible to check the current window flags
upon creation). As such, the filtering would never be done.
Looking at the current set of plugins, most of them also seems to
ignore this protocol, returning the flags unfiltered.

This patch suggests removing the return value from
QPlatformWindow::setWindowFlags. This will at least be consistent, so
that setting/getting flags would produce the same result independent of
delayed window creation. If needed, we can later add new API to
QPlatformIntegration or QPlatformWindow for querying supported window
flags.

Change-Id: I9c759b5f9fab5ebed764a982f77fe19881118875
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
This commit is contained in:
Richard Moe Gustavsen 2012-10-09 10:52:44 +02:00 committed by The Qt Project
parent 6343a46bc5
commit 58add50eb0
13 changed files with 17 additions and 25 deletions

View File

@ -142,17 +142,16 @@ void QPlatformWindow::setVisible(bool visible)
QWindowSystemInterface::handleExposeEvent(window(), rect);
QWindowSystemInterface::flushWindowSystemEvents();
}
/*!
Requests setting the window flags of this surface
to \a type. Returns the actual flags set.
to \a flags.
*/
Qt::WindowFlags QPlatformWindow::setWindowFlags(Qt::WindowFlags flags)
void QPlatformWindow::setWindowFlags(Qt::WindowFlags flags)
{
return flags;
Q_UNUSED(flags);
}
/*!
Returns if this window is exposed in the windowing system.

View File

@ -90,7 +90,7 @@ public:
virtual QMargins frameMargins() const;
virtual void setVisible(bool visible);
virtual Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags);
virtual void setWindowFlags(Qt::WindowFlags flags);
virtual Qt::WindowState setWindowState(Qt::WindowState state);
virtual WId winId() const;

View File

@ -514,9 +514,8 @@ void QWindow::setWindowFlags(Qt::WindowFlags flags)
{
Q_D(QWindow);
if (d->platformWindow)
d->windowFlags = d->platformWindow->setWindowFlags(flags);
else
d->windowFlags = flags;
d->platformWindow->setWindowFlags(flags);
d->windowFlags = flags;
}
/*!

View File

@ -76,11 +76,10 @@ void QFbWindow::setGeometry(const QRect &rect)
QPlatformWindow::setGeometry(rect);
}
Qt::WindowFlags QFbWindow::setWindowFlags(Qt::WindowFlags flags)
void QFbWindow::setWindowFlags(Qt::WindowFlags flags)
{
mWindowFlags = flags;
platformScreen()->invalidateRectCache();
return mWindowFlags;
}
Qt::WindowFlags QFbWindow::windowFlags() const

View File

@ -60,7 +60,7 @@ public:
void setGeometry(const QRect &rect);
virtual Qt::WindowFlags setWindowFlags(Qt::WindowFlags type);
virtual void setWindowFlags(Qt::WindowFlags type);
virtual Qt::WindowFlags windowFlags() const;
WId winId() const { return mWindowId; }

View File

@ -98,7 +98,7 @@ public:
void setGeometry(const QRect &rect);
void setCocoaGeometry(const QRect &rect);
void setVisible(bool visible);
Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags);
void setWindowFlags(Qt::WindowFlags flags);
Qt::WindowState setWindowState(Qt::WindowState state);
void setWindowTitle(const QString &title);
void setWindowFilePath(const QString &filePath);

View File

@ -387,7 +387,7 @@ void QCocoaWindow::setWindowShadow(Qt::WindowFlags flags)
[m_nsWindow setHasShadow:(keepShadow ? YES : NO)];
}
Qt::WindowFlags QCocoaWindow::setWindowFlags(Qt::WindowFlags flags)
void QCocoaWindow::setWindowFlags(Qt::WindowFlags flags)
{
if (m_nsWindow) {
NSUInteger styleMask = windowStyleMask(flags);
@ -398,7 +398,6 @@ Qt::WindowFlags QCocoaWindow::setWindowFlags(Qt::WindowFlags flags)
}
m_windowFlags = flags;
return m_windowFlags;
}
Qt::WindowState QCocoaWindow::setWindowState(Qt::WindowState state)

View File

@ -140,7 +140,7 @@ void QDirectFbWindow::setVisible(bool visible)
QWindowSystemInterface::handleExposeEvent(window(), window()->geometry());
}
Qt::WindowFlags QDirectFbWindow::setWindowFlags(Qt::WindowFlags flags)
void QDirectFbWindow::setWindowFlags(Qt::WindowFlags flags)
{
switch (flags & Qt::WindowType_Mask) {
case Qt::ToolTip: {
@ -154,7 +154,6 @@ Qt::WindowFlags QDirectFbWindow::setWindowFlags(Qt::WindowFlags flags)
}
m_dfbWindow->SetStackingClass(m_dfbWindow.data(), flags & Qt::WindowStaysOnTopHint ? DWSC_UPPER : DWSC_MIDDLE);
return flags;
}
void QDirectFbWindow::raise()

View File

@ -60,7 +60,7 @@ public:
void setVisible(bool visible);
Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags);
void setWindowFlags(Qt::WindowFlags flags);
bool setKeyboardGrabEnabled(bool grab);
bool setMouseGrabEnabled(bool grab);
void raise();

View File

@ -1178,7 +1178,7 @@ void QWindowsWindow::setWindowTitle(const QString &title)
SetWindowText(m_data.hwnd, (const wchar_t*)title.utf16());
}
Qt::WindowFlags QWindowsWindow::setWindowFlags(Qt::WindowFlags flags)
void QWindowsWindow::setWindowFlags(Qt::WindowFlags flags)
{
if (QWindowsContext::verboseWindows)
qDebug() << '>' << __FUNCTION__ << this << window() << "\n from: "
@ -1202,7 +1202,6 @@ Qt::WindowFlags QWindowsWindow::setWindowFlags(Qt::WindowFlags flags)
qDebug() << '<' << __FUNCTION__ << "\n returns: "
<< QWindowsWindow::debugWindowFlags(m_data.flags)
<< " geometry " << oldGeometry << "->" << newGeometry;
return m_data.flags;
}
QWindowsWindow::WindowData QWindowsWindow::setWindowFlags_sys(Qt::WindowFlags wt,

View File

@ -159,7 +159,7 @@ public:
virtual QPoint mapToGlobal(const QPoint &pos) const;
virtual QPoint mapFromGlobal(const QPoint &pos) const;
virtual Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags);
virtual void setWindowFlags(Qt::WindowFlags flags);
virtual Qt::WindowState setWindowState(Qt::WindowState state);
HWND handle() const { return m_data.hwnd; }

View File

@ -740,7 +740,7 @@ void QXcbWindow::setNetWmStates(NetWmStates states)
xcb_flush(xcb_connection());
}
Qt::WindowFlags QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
{
Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
@ -763,8 +763,6 @@ Qt::WindowFlags QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
return flags;
}
void QXcbWindow::setMotifWindowFlags(Qt::WindowFlags flags)

View File

@ -81,7 +81,7 @@ public:
QMargins frameMargins() const;
void setVisible(bool visible);
Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags);
void setWindowFlags(Qt::WindowFlags flags);
Qt::WindowState setWindowState(Qt::WindowState state);
WId winId() const;
void setParent(const QPlatformWindow *window);