summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowswindow.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/windows/qwindowswindow.h')
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.h153
1 files changed, 111 insertions, 42 deletions
diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h
index 6fffa1e6e9..df7d2295a9 100644
--- a/src/plugins/platforms/windows/qwindowswindow.h
+++ b/src/plugins/platforms/windows/qwindowswindow.h
@@ -1,31 +1,37 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
@@ -112,7 +118,78 @@ struct QWindowsWindowData
const QString &title);
};
-class QWindowsWindow : public QPlatformWindow
+class QWindowsBaseWindow : public QPlatformWindow
+{
+public:
+ explicit QWindowsBaseWindow(QWindow *window) : QPlatformWindow(window) {}
+
+ WId winId() const Q_DECL_OVERRIDE { return WId(handle()); }
+ QRect geometry() const Q_DECL_OVERRIDE { return geometry_sys(); }
+ QMargins frameMargins() const Q_DECL_OVERRIDE { return frameMargins_sys(); }
+ QPoint mapToGlobal(const QPoint &pos) const Q_DECL_OVERRIDE;
+ QPoint mapFromGlobal(const QPoint &pos) const Q_DECL_OVERRIDE;
+
+ using QPlatformWindow::screenForGeometry;
+
+ virtual HWND handle() const = 0;
+ virtual bool isTopLevel() const { return isTopLevel_sys(); }
+
+ unsigned style() const { return GetWindowLongPtr(handle(), GWL_STYLE); }
+ unsigned exStyle() const { return GetWindowLongPtr(handle(), GWL_EXSTYLE); }
+
+ static QWindowsBaseWindow *baseWindowOf(const QWindow *w);
+ static HWND handleOf(const QWindow *w);
+
+protected:
+ HWND parentHwnd() const { return GetAncestor(handle(), GA_PARENT); }
+ bool isTopLevel_sys() const;
+ QRect frameGeometry_sys() const;
+ QRect geometry_sys() const;
+ void setGeometry_sys(const QRect &rect) const;
+ QMargins frameMargins_sys() const;
+ void hide_sys();
+ void raise_sys();
+ void lower_sys();
+ void setWindowTitle_sys(const QString &title);
+};
+
+class QWindowsDesktopWindow : public QWindowsBaseWindow
+{
+public:
+ explicit QWindowsDesktopWindow(QWindow *window)
+ : QWindowsBaseWindow(window), m_hwnd(GetDesktopWindow()) {}
+
+ QMargins frameMargins() const Q_DECL_OVERRIDE { return QMargins(); }
+ bool isTopLevel() const Q_DECL_OVERRIDE { return true; }
+
+protected:
+ HWND handle() const Q_DECL_OVERRIDE { return m_hwnd; }
+
+private:
+ const HWND m_hwnd;
+};
+
+class QWindowsForeignWindow : public QWindowsBaseWindow
+{
+public:
+ explicit QWindowsForeignWindow(QWindow *window, HWND hwnd);
+
+ void setParent(const QPlatformWindow *window) Q_DECL_OVERRIDE;
+ void setGeometry(const QRect &rect) Q_DECL_OVERRIDE { setGeometry_sys(rect); }
+ void setVisible(bool visible) Q_DECL_OVERRIDE;
+ void raise() Q_DECL_OVERRIDE { raise_sys(); }
+ void lower() Q_DECL_OVERRIDE { lower_sys(); }
+ void setWindowTitle(const QString &title) Q_DECL_OVERRIDE { setWindowTitle_sys(title); }
+
+protected:
+ HWND handle() const Q_DECL_OVERRIDE { return m_hwnd; }
+
+private:
+ const HWND m_hwnd;
+ DWORD m_topLevelStyle;
+};
+
+class QWindowsWindow : public QWindowsBaseWindow
{
public:
enum Flags
@@ -162,14 +239,11 @@ public:
void setWindowFlags(Qt::WindowFlags flags) Q_DECL_OVERRIDE;
void setWindowState(Qt::WindowState state) Q_DECL_OVERRIDE;
- HWND handle() const { return m_data.hwnd; }
-
- WId winId() const Q_DECL_OVERRIDE { return WId(m_data.hwnd); }
void setParent(const QPlatformWindow *window) Q_DECL_OVERRIDE;
void setWindowTitle(const QString &title) Q_DECL_OVERRIDE;
- void raise() Q_DECL_OVERRIDE;
- void lower() Q_DECL_OVERRIDE;
+ void raise() Q_DECL_OVERRIDE { raise_sys(); }
+ void lower() Q_DECL_OVERRIDE { lower_sys(); }
void windowEvent(QEvent *event) Q_DECL_OVERRIDE;
@@ -192,14 +266,14 @@ public:
void setFrameStrutEventsEnabled(bool enabled) Q_DECL_OVERRIDE;
bool frameStrutEventsEnabled() const Q_DECL_OVERRIDE { return testFlag(FrameStrutEventsEnabled); }
+ // QWindowsBaseWindow overrides
+ HWND handle() const Q_DECL_OVERRIDE { return m_data.hwnd; }
+ bool isTopLevel() const Q_DECL_OVERRIDE;
+
QMargins customMargins() const { return m_data.customMargins; }
void setCustomMargins(const QMargins &m);
- inline unsigned style() const
- { return GetWindowLongPtr(m_data.hwnd, GWL_STYLE); }
void setStyle(unsigned s) const;
- inline unsigned exStyle() const
- { return GetWindowLongPtr(m_data.hwnd, GWL_EXSTYLE); }
void setExStyle(unsigned s) const;
bool handleWmPaint(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
@@ -209,8 +283,7 @@ public:
void handleHidden();
void handleCompositionSettingsChanged();
- static inline HWND handleOf(const QWindow *w);
- static inline QWindowsWindow *baseWindowOf(const QWindow *w);
+ static QWindowsWindow *windowsWindowOf(const QWindow *w);
static QWindow *topLevelOf(QWindow *w);
static inline void *userDataOf(HWND hwnd);
static inline void setUserDataOf(HWND hwnd, void *ud);
@@ -254,12 +327,10 @@ public:
void registerTouchWindow(QWindowsWindowFunctions::TouchWindowTouchTypes touchTypes = QWindowsWindowFunctions::NormalTouch);
static void setHasBorderInFullScreenStatic(QWindow *window, bool border);
void setHasBorderInFullScreen(bool border);
+ static QString formatWindowTitle(const QString &title);
+
private:
inline void show_sys() const;
- inline void hide_sys() const;
- inline void setGeometry_sys(const QRect &rect) const;
- inline QRect frameGeometry_sys() const;
- inline QRect geometry_sys() const;
inline QWindowsWindowData setWindowFlags_sys(Qt::WindowFlags wt, unsigned flags = 0) const;
inline bool isFullScreen_sys() const;
inline void setWindowState_sys(Qt::WindowState newState);
@@ -328,19 +399,17 @@ QPoint QWindowsGeometryHint::mapFromGlobal(const QWindow *w, const QPoint &p)
// ---------- QWindowsBaseWindow inline functions.
-QWindowsWindow *QWindowsWindow::baseWindowOf(const QWindow *w)
+inline QWindowsWindow *QWindowsWindow::windowsWindowOf(const QWindow *w)
{
- if (w)
- if (QPlatformWindow *pw = w->handle())
- return static_cast<QWindowsWindow *>(pw);
- return 0;
-}
-
-HWND QWindowsWindow::handleOf(const QWindow *w)
-{
- if (const QWindowsWindow *bw = QWindowsWindow::baseWindowOf(w))
- return bw->handle();
- return 0;
+ QWindowsWindow *result = Q_NULLPTR;
+ if (w) {
+ const Qt::WindowType type = w->type();
+ if (type != Qt::Desktop && type != Qt::ForeignWindow) {
+ if (QPlatformWindow *pw = w->handle())
+ result = static_cast<QWindowsWindow *>(pw);
+ }
+ }
+ return result;
}
void *QWindowsWindow::userDataOf(HWND hwnd)