Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqnxnativeinterface.cpp
Go to the documentation of this file.
1// Copyright (C) 2012 Research In Motion
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
6#if !defined(QT_NO_OPENGL)
8#endif
9
10#if QT_CONFIG(vulkan)
11#include "qqnxvulkanwindow.h"
12#endif
13
14#include "qqnxscreen.h"
15#include "qqnxwindow.h"
16#if defined(QQNX_IMF)
17#include "qqnxinputcontext_imf.h"
18#endif
19
21
22#if !defined(QT_NO_OPENGL)
23#include <QtGui/QOpenGLContext>
24#endif
25
26#include <QtGui/QScreen>
27#include <QtGui/QWindow>
28
30
31using namespace Qt::StringLiterals;
32
34 : m_integration(integration)
35{
36}
37
38void *QQnxNativeInterface::nativeResourceForWindow(const QByteArray &resource, QWindow *window)
39{
40#if QT_CONFIG(vulkan)
41 if (resource == "vkSurface") {
42 if (window && window->surfaceType() == QSurface::VulkanSurface && window->handle())
43 return static_cast<QQnxVulkanWindow *>(window->handle())->surface();
44 return nullptr;
45 }
46#endif
47
48 if (resource == "windowGroup" && window && window->screen()) {
49 QQnxScreen * const screen = static_cast<QQnxScreen *>(window->screen()->handle());
50 if (screen) {
51 screen_window_t screenWindow = reinterpret_cast<screen_window_t>(window->winId());
52 QQnxWindow *qnxWindow = screen->findWindow(screenWindow);
53 // We can't just call data() instead of constData() here, since that would detach
54 // and the lifetime of the char * would not be long enough. Therefore the const_cast.
55 return qnxWindow ? const_cast<char *>(qnxWindow->groupName().constData()) : 0;
56 }
57 }
58
59 return 0;
60}
61
62void *QQnxNativeInterface::nativeResourceForScreen(const QByteArray &resource, QScreen *screen)
63{
64 if (resource == "QObject*" && screen)
65 return static_cast<QObject*>(static_cast<QQnxScreen*>(screen->handle()));
66
67 return 0;
68}
69
70void *QQnxNativeInterface::nativeResourceForIntegration(const QByteArray &resource)
71{
72 if (resource == "screenContext")
73 return m_integration->screenContext();
74
75#if QT_CONFIG(opengl)
76 if (resource.toLower() == "egldisplay")
77 return m_integration->eglDisplay();
78#endif
79
80 return 0;
81}
82
83#if !defined(QT_NO_OPENGL)
84void *QQnxNativeInterface::nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context)
85{
86 if (resource == "eglcontext" && context)
87 return static_cast<QQnxGLContext*>(context->handle())->eglContext();
88
89 return 0;
90}
91#endif
92
93void QQnxNativeInterface::setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value)
94{
95 QQnxWindow *qnxWindow = static_cast<QQnxWindow*>(window);
96
97 if (name == "qnxWindowGroup"_L1) {
98 if (value.isNull())
99 qnxWindow->joinWindowGroup(QByteArray());
100 else if (value.canConvert<QByteArray>())
101 qnxWindow->joinWindowGroup(value.toByteArray());
102 }
103}
104
106{
107#if defined(QQNX_IMF)
108 if (resource == "blackberryIMFSetHighlightColor")
109 return reinterpret_cast<NativeResourceForIntegrationFunction>(QQnxInputContext::setHighlightColor);
110 if (resource == "blackberryIMFCheckSpelling")
111 return reinterpret_cast<NativeResourceForIntegrationFunction>(QQnxInputContext::checkSpelling);
112#else
113 Q_UNUSED(resource);
114#endif
115 return 0;
116}
117
118QT_END_NAMESPACE
void * nativeResourceForScreen(const QByteArray &resource, QScreen *screen) override
void * nativeResourceForWindow(const QByteArray &resource, QWindow *window) override
void * nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) override
QQnxNativeInterface(QQnxIntegration *integration)
void * nativeResourceForIntegration(const QByteArray &resource) override
NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource) override
void setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value) override
Sets a window property with name to value.
The QQnxWindow is the base class of the various classes used as instances of QPlatformWindow in the Q...
Definition qqnxwindow.h:31
Combined button and popup list for selecting options.