1 /***************************************************************************
2 **
3 ** Copyright (C) 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 #include "qqnxnativeinterface.h"
41
42 #if !defined(QT_NO_OPENGL)
43 #include "qqnxglcontext.h"
44 #endif
45
46 #include "qqnxscreen.h"
47 #include "qqnxwindow.h"
48 #if defined(QQNX_IMF)
49 #include "qqnxinputcontext_imf.h"
50 #endif
51
52 #include "qqnxintegration.h"
53
54 #if !defined(QT_NO_OPENGL)
55 #include <QtGui/QOpenGLContext>
56 #endif
57
58 #include <QtGui/QScreen>
59 #include <QtGui/QWindow>
60
61 QT_BEGIN_NAMESPACE
62
QQnxNativeInterface(QQnxIntegration * integration)63 QQnxNativeInterface::QQnxNativeInterface(QQnxIntegration *integration)
64 : m_integration(integration)
65 {
66 }
67
nativeResourceForWindow(const QByteArray & resource,QWindow * window)68 void *QQnxNativeInterface::nativeResourceForWindow(const QByteArray &resource, QWindow *window)
69 {
70 if (resource == "windowGroup" && window && window->screen()) {
71 QQnxScreen * const screen = static_cast<QQnxScreen *>(window->screen()->handle());
72 if (screen) {
73 screen_window_t screenWindow = reinterpret_cast<screen_window_t>(window->winId());
74 QQnxWindow *qnxWindow = screen->findWindow(screenWindow);
75 // We can't just call data() instead of constData() here, since that would detach
76 // and the lifetime of the char * would not be long enough. Therefore the const_cast.
77 return qnxWindow ? const_cast<char *>(qnxWindow->groupName().constData()) : 0;
78 }
79 }
80
81 return 0;
82 }
83
nativeResourceForScreen(const QByteArray & resource,QScreen * screen)84 void *QQnxNativeInterface::nativeResourceForScreen(const QByteArray &resource, QScreen *screen)
85 {
86 if (resource == "QObject*" && screen)
87 return static_cast<QObject*>(static_cast<QQnxScreen*>(screen->handle()));
88
89 return 0;
90 }
91
nativeResourceForIntegration(const QByteArray & resource)92 void *QQnxNativeInterface::nativeResourceForIntegration(const QByteArray &resource)
93 {
94 if (resource == "screenContext")
95 return m_integration->screenContext();
96
97 #if QT_CONFIG(opengl)
98 if (resource.toLower() == "egldisplay")
99 return m_integration->eglDisplay();
100 #endif
101
102 return 0;
103 }
104
105 #if !defined(QT_NO_OPENGL)
nativeResourceForContext(const QByteArray & resource,QOpenGLContext * context)106 void *QQnxNativeInterface::nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context)
107 {
108 if (resource == "eglcontext" && context)
109 return static_cast<QQnxGLContext*>(context->handle())->eglContext();
110
111 return 0;
112 }
113 #endif
114
setWindowProperty(QPlatformWindow * window,const QString & name,const QVariant & value)115 void QQnxNativeInterface::setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value)
116 {
117 QQnxWindow *qnxWindow = static_cast<QQnxWindow*>(window);
118
119 if (name == QLatin1String("mmRendererWindowName")) {
120 qnxWindow->setMMRendererWindowName(value.toString());
121 } else if (name == QLatin1String("qnxWindowGroup")) {
122 if (value.isNull())
123 qnxWindow->joinWindowGroup(QByteArray());
124 else if (value.canConvert<QByteArray>())
125 qnxWindow->joinWindowGroup(value.toByteArray());
126 }
127 }
128
nativeResourceFunctionForIntegration(const QByteArray & resource)129 QPlatformNativeInterface::NativeResourceForIntegrationFunction QQnxNativeInterface::nativeResourceFunctionForIntegration(const QByteArray &resource)
130 {
131 #if defined(QQNX_IMF)
132 if (resource == "blackberryIMFSetHighlightColor")
133 return reinterpret_cast<NativeResourceForIntegrationFunction>(QQnxInputContext::setHighlightColor);
134 if (resource == "blackberryIMFCheckSpelling")
135 return reinterpret_cast<NativeResourceForIntegrationFunction>(QQnxInputContext::checkSpelling);
136 #else
137 Q_UNUSED(resource)
138 #endif
139 return 0;
140 }
141
142 QT_END_NAMESPACE
143