QPlatformWindow: change API for QPlatformWindow::setWindowFlags
authorRichard Moe Gustavsen <richard.gustavsen@digia.com>
Tue, 9 Oct 2012 08:52:44 +0000 (10:52 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Mon, 15 Oct 2012 08:18:31 +0000 (10:18 +0200)
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>
13 files changed:
src/gui/kernel/qplatformwindow.cpp
src/gui/kernel/qplatformwindow.h
src/gui/kernel/qwindow.cpp
src/platformsupport/fbconvenience/qfbwindow.cpp
src/platformsupport/fbconvenience/qfbwindow_p.h
src/plugins/platforms/cocoa/qcocoawindow.h
src/plugins/platforms/cocoa/qcocoawindow.mm
src/plugins/platforms/directfb/qdirectfbwindow.cpp
src/plugins/platforms/directfb/qdirectfbwindow.h
src/plugins/platforms/windows/qwindowswindow.cpp
src/plugins/platforms/windows/qwindowswindow.h
src/plugins/platforms/xcb/qxcbwindow.cpp
src/plugins/platforms/xcb/qxcbwindow.h

index 755fd8a..27dfd7c 100644 (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.
 
index 7ea17d0..2b2d227 100644 (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;
index 79927cb..27e1571 100644 (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;
 }
 
 /*!
index fd89e1b..598e968 100644 (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
index 67b2ef8..e440e04 100644 (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; }
index 4a14676..014db37 100644 (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);
index 26161b1..f4a4936 100644 (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)
index 8b108ee..630e4fd 100644 (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()
index cedd140..3edee7c 100644 (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();
index 2335870..f3830eb 100644 (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,
index 4b17928..3b7666c 100644 (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; }
index 64cb9af..cefe1a7 100644 (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)
index ab18b50..e2f6240 100644 (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);