1 /***************************************************************************
2 **
3 ** Copyright (C) 2011 - 2013 BlackBerry Limited. All rights reserved.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the plugins of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #ifndef QQNXWINDOW_H
41 #define QQNXWINDOW_H
42 
43 #include <qpa/qplatformwindow.h>
44 #include "qqnxabstractcover.h"
45 
46 #include <QtCore/QScopedPointer>
47 
48 #if !defined(QT_NO_OPENGL)
49 #include <EGL/egl.h>
50 #endif
51 
52 #include <screen/screen.h>
53 
54 QT_BEGIN_NAMESPACE
55 
56 // all surfaces double buffered
57 #define MAX_BUFFER_COUNT    2
58 
59 class QQnxScreen;
60 
61 class QSurfaceFormat;
62 
63 class QQnxWindow : public QPlatformWindow
64 {
65 friend class QQnxScreen;
66 public:
67     explicit QQnxWindow(QWindow *window, screen_context_t context, bool needRootWindow);
68     explicit QQnxWindow(QWindow *window, screen_context_t context, screen_window_t screenWindow);
69     virtual ~QQnxWindow();
70 
71     void setGeometry(const QRect &rect) override;
72     void setVisible(bool visible) override;
73     void setOpacity(qreal level) override;
74 
75     bool isExposed() const override;
76 
winId()77     WId winId() const override { return window()->type() == Qt::Desktop ? -1 : (WId)m_window; }
nativeHandle()78     screen_window_t nativeHandle() const { return m_window; }
79 
80     void setBufferSize(const QSize &size);
bufferSize()81     QSize bufferSize() const { return m_bufferSize; }
82 
83     void setScreen(QQnxScreen *platformScreen);
84 
85     void setParent(const QPlatformWindow *window) override;
86     void raise() override;
87     void lower() override;
88     void requestActivateWindow() override;
89     void setWindowState(Qt::WindowStates state) override;
90     void setExposed(bool exposed);
91 
92     void propagateSizeHints() override;
93 
94     void setMMRendererWindowName(const QString &name);
95     void setMMRendererWindow(screen_window_t handle);
96     void clearMMRendererWindow();
97 
98     QPlatformScreen *screen() const override;
children()99     const QList<QQnxWindow*>& children() const { return m_childWindows; }
100 
101     QQnxWindow *findWindow(screen_window_t windowHandle);
102 
103     void minimize();
104 
mmRendererWindowName()105     QString mmRendererWindowName() const { return m_mmRendererWindowName; }
106 
mmRendererWindow()107     screen_window_t mmRendererWindow() const { return m_mmRendererWindow; }
108 
109     void setRotation(int rotation);
110 
groupName()111     QByteArray groupName() const { return m_windowGroupName; }
112     void joinWindowGroup(const QByteArray &groupName);
113 
114     bool shouldMakeFullScreen() const;
115 
116     void windowPosted();
117     void handleActivationEvent();
118 
119 protected:
120     virtual int pixelFormat() const = 0;
121     virtual void resetBuffers() = 0;
122 
123     void initWindow();
124 
125     screen_context_t m_screenContext;
126 
127 private:
128     void collectWindowGroup();
129     void createWindowGroup();
130     void setGeometryHelper(const QRect &rect);
131     void removeFromParent();
132     void updateVisibility(bool parentVisible);
133     void updateZorder(int &topZorder);
134     void updateZorder(screen_window_t window, int &zOrder);
135     void applyWindowState();
136     void setFocus(screen_window_t newFocusWindow);
137     bool showWithoutActivating() const;
138     bool focusable() const;
139 
140     void addContextPermission();
141     void removeContextPermission();
142 
143     screen_window_t m_window;
144     QSize m_bufferSize;
145 
146     QQnxScreen *m_screen;
147     QQnxWindow *m_parentWindow;
148     QList<QQnxWindow*> m_childWindows;
149     QScopedPointer<QQnxAbstractCover> m_cover;
150     bool m_visible;
151     bool m_exposed;
152     bool m_foreign;
153     QRect m_unmaximizedGeometry;
154     Qt::WindowStates m_windowState;
155     QString m_mmRendererWindowName;
156     screen_window_t m_mmRendererWindow;
157 
158     // Group name of window group headed by this window
159     QByteArray m_windowGroupName;
160     // Group name that we have joined or "" if we've not joined any group.
161     QByteArray m_parentGroupName;
162 
163     bool m_isTopLevel;
164     bool m_firstActivateHandled;
165 };
166 
167 QT_END_NAMESPACE
168 
169 #endif // QQNXWINDOW_H
170