1 /*************************************************************************** 2 ** 3 ** Copyright (C) 2011 - 2012 Research In Motion 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 QBBSCREEN_H 41 #define QBBSCREEN_H 42 43 #include <qpa/qplatformscreen.h> 44 45 #include "qqnxwindow.h" 46 47 #include <QtCore/QObject> 48 #include <QtCore/QScopedPointer> 49 50 #include <screen/screen.h> 51 52 #if !defined(_SCREEN_VERSION) 53 #define _SCREEN_MAKE_VERSION(major, minor, patch) (((major) * 10000) + ((minor) * 100) + (patch)) 54 #define _SCREEN_VERSION _SCREEN_MAKE_VERSION(0, 0, 0) 55 #endif 56 57 // For pre-1.0.0 screen, map some screen property names to the old 58 // names. 59 #if _SCREEN_VERSION < _SCREEN_MAKE_VERSION(1, 0, 0) 60 const int SCREEN_PROPERTY_FLAGS = SCREEN_PROPERTY_KEY_FLAGS; 61 const int SCREEN_PROPERTY_FOCUS = SCREEN_PROPERTY_KEYBOARD_FOCUS; 62 const int SCREEN_PROPERTY_MODIFIERS = SCREEN_PROPERTY_KEY_MODIFIERS; 63 const int SCREEN_PROPERTY_SCAN = SCREEN_PROPERTY_KEY_SCAN; 64 const int SCREEN_PROPERTY_SYM = SCREEN_PROPERTY_KEY_SYM; 65 #endif 66 67 QT_BEGIN_NAMESPACE 68 69 class QQnxWindow; 70 71 class QQnxScreen : public QObject, public QPlatformScreen 72 { 73 Q_OBJECT 74 public: 75 QQnxScreen(screen_context_t context, screen_display_t display, bool primaryScreen); 76 ~QQnxScreen(); 77 78 QPixmap grabWindow(WId window, int x, int y, int width, int height) const override; 79 geometry()80 QRect geometry() const override { return m_currentGeometry; } 81 QRect availableGeometry() const override; 82 int depth() const override; format()83 QImage::Format format() const override { return (depth() == 32) ? QImage::Format_RGB32 : QImage::Format_RGB16; } physicalSize()84 QSizeF physicalSize() const override { return m_currentPhysicalSize; } 85 86 qreal refreshRate() const override; 87 88 Qt::ScreenOrientation nativeOrientation() const override; 89 Qt::ScreenOrientation orientation() const override; 90 91 QWindow *topLevelAt(const QPoint &point) const override; 92 isPrimaryScreen()93 bool isPrimaryScreen() const { return m_primaryScreen; } 94 rotation()95 int rotation() const { return m_currentRotation; } 96 name()97 QString name() const override { return m_name; } 98 nativeFormat()99 int nativeFormat() const { return (depth() == 32) ? SCREEN_FORMAT_RGBA8888 : SCREEN_FORMAT_RGB565; } nativeDisplay()100 screen_display_t nativeDisplay() const { return m_display; } nativeContext()101 screen_context_t nativeContext() const { return m_screenContext; } windowGroupName()102 const char *windowGroupName() const { return m_rootWindow ? m_rootWindow->groupName().constData() : 0; } 103 104 QQnxWindow *findWindow(screen_window_t windowHandle) const; 105 106 /* Window hierarchy management */ 107 void addWindow(QQnxWindow *child); 108 void removeWindow(QQnxWindow *child); 109 void raiseWindow(QQnxWindow *window); 110 void lowerWindow(QQnxWindow *window); 111 void updateHierarchy(); 112 113 void adjustOrientation(); 114 115 QQnxWindow *rootWindow() const; 116 void setRootWindow(QQnxWindow*); 117 118 QPlatformCursor *cursor() const override; 119 120 Q_SIGNALS: 121 void foreignWindowCreated(void *window); 122 void foreignWindowClosed(void *window); 123 124 public Q_SLOTS: 125 void setRotation(int rotation); 126 void newWindowCreated(void *window); 127 void windowClosed(void *window); 128 void windowGroupStateChanged(const QByteArray &id, Qt::WindowState state); 129 void activateWindowGroup(const QByteArray &id); 130 void deactivateWindowGroup(const QByteArray &id); 131 132 private Q_SLOTS: 133 void keyboardHeightChanged(int height); 134 135 private: 136 void resizeNativeWidgetWindow(QQnxWindow *w, const QRect &previousScreenGeometry) const; 137 void resizeTopLevelWindow(QQnxWindow *w, const QRect &previousScreenGeometry) const; 138 void resizeWindows(const QRect &previousScreenGeometry); 139 void addOverlayWindow(screen_window_t window); 140 void addUnderlayWindow(screen_window_t window); 141 void addMultimediaWindow(const QByteArray &id, screen_window_t window); 142 void removeOverlayOrUnderlayWindow(screen_window_t window); 143 144 screen_context_t m_screenContext; 145 screen_display_t m_display; 146 QQnxWindow *m_rootWindow; 147 const bool m_primaryScreen; 148 149 int m_initialRotation; 150 int m_currentRotation; 151 int m_keyboardHeight; 152 QString m_name; 153 QSize m_initialPhysicalSize; 154 QSize m_currentPhysicalSize; 155 Qt::ScreenOrientation m_nativeOrientation; 156 QRect m_initialGeometry; 157 QRect m_currentGeometry; 158 159 QList<QQnxWindow *> m_childWindows; 160 QQnxWindow *m_coverWindow; 161 QList<screen_window_t> m_overlays; 162 QList<screen_window_t> m_underlays; 163 164 QPlatformCursor *m_cursor; 165 }; 166 167 QT_END_NAMESPACE 168 169 #endif // QBBSCREEN_H 170