Make QQnxIntegration a singleton
Turn all the static members and functions into regular members and functions. Change-Id: Ib37d9bdd1a84e512013af7d334e04cd2b1da640e Reviewed-by: Dan Cape <dcape@qnx.com> Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
This commit is contained in:
parent
d133b02a3b
commit
b14527f529
@ -45,9 +45,9 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
void qScreenCheckError(int rc, const char *funcInfo, const char *message, bool critical)
|
void qScreenCheckError(int rc, const char *funcInfo, const char *message, bool critical)
|
||||||
{
|
{
|
||||||
if (!rc && (QQnxIntegration::options() & QQnxIntegration::AlwaysFlushScreenContext)
|
if (!rc && (QQnxIntegration::instance()->options() & QQnxIntegration::AlwaysFlushScreenContext)
|
||||||
&& QQnxIntegration::screenContext() != 0) {
|
&& QQnxIntegration::instance()->screenContext() != 0) {
|
||||||
rc = screen_flush_context(QQnxIntegration::screenContext(), 0);
|
rc = screen_flush_context(QQnxIntegration::instance()->screenContext(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Q_UNLIKELY(rc)) {
|
if (Q_UNLIKELY(rc)) {
|
||||||
|
@ -99,8 +99,7 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
QQnxWindowMapper QQnxIntegration::ms_windowMapper;
|
QQnxIntegration *QQnxIntegration::ms_instance;
|
||||||
QMutex QQnxIntegration::ms_windowMapperMutex;
|
|
||||||
|
|
||||||
static inline QQnxIntegration::Options parseOptions(const QStringList ¶mList)
|
static inline QQnxIntegration::Options parseOptions(const QStringList ¶mList)
|
||||||
{
|
{
|
||||||
@ -159,11 +158,12 @@ QQnxIntegration::QQnxIntegration(const QStringList ¶mList)
|
|||||||
, m_drag(new QSimpleDrag())
|
, m_drag(new QSimpleDrag())
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
ms_options = parseOptions(paramList);
|
ms_instance = this;
|
||||||
|
m_options = parseOptions(paramList);
|
||||||
qIntegrationDebug();
|
qIntegrationDebug();
|
||||||
|
|
||||||
// Open connection to QNX composition manager
|
// Open connection to QNX composition manager
|
||||||
if (screen_create_context(&ms_screenContext, getContextCapabilities(paramList))) {
|
if (screen_create_context(&m_screenContext, getContextCapabilities(paramList))) {
|
||||||
qFatal("%s - Screen: Failed to create screen context - Error: %s (%i)",
|
qFatal("%s - Screen: Failed to create screen context - Error: %s (%i)",
|
||||||
Q_FUNC_INFO, strerror(errno), errno);
|
Q_FUNC_INFO, strerror(errno), errno);
|
||||||
}
|
}
|
||||||
@ -183,7 +183,7 @@ QQnxIntegration::QQnxIntegration(const QStringList ¶mList)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Create/start event thread
|
// Create/start event thread
|
||||||
m_screenEventThread = new QQnxScreenEventThread(ms_screenContext);
|
m_screenEventThread = new QQnxScreenEventThread(m_screenContext);
|
||||||
m_screenEventHandler->setScreenEventThread(m_screenEventThread);
|
m_screenEventHandler->setScreenEventThread(m_screenEventThread);
|
||||||
m_screenEventThread->start();
|
m_screenEventThread->start();
|
||||||
|
|
||||||
@ -260,7 +260,7 @@ QQnxIntegration::~QQnxIntegration()
|
|||||||
destroyDisplays();
|
destroyDisplays();
|
||||||
|
|
||||||
// Close connection to QNX composition manager
|
// Close connection to QNX composition manager
|
||||||
screen_destroy_context(ms_screenContext);
|
screen_destroy_context(m_screenContext);
|
||||||
|
|
||||||
#if !defined(QT_NO_OPENGL)
|
#if !defined(QT_NO_OPENGL)
|
||||||
// Cleanup global OpenGL resources
|
// Cleanup global OpenGL resources
|
||||||
@ -284,6 +284,8 @@ QQnxIntegration::~QQnxIntegration()
|
|||||||
// Destroy navigator interface
|
// Destroy navigator interface
|
||||||
delete m_navigator;
|
delete m_navigator;
|
||||||
|
|
||||||
|
ms_instance = nullptr;
|
||||||
|
|
||||||
qIntegrationDebug("platform plugin shutdown end");
|
qIntegrationDebug("platform plugin shutdown end");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,10 +314,10 @@ QPlatformWindow *QQnxIntegration::createPlatformWindow(QWindow *window) const
|
|||||||
const bool needRootWindow = options() & RootWindow;
|
const bool needRootWindow = options() & RootWindow;
|
||||||
switch (surfaceType) {
|
switch (surfaceType) {
|
||||||
case QSurface::RasterSurface:
|
case QSurface::RasterSurface:
|
||||||
return new QQnxRasterWindow(window, ms_screenContext, needRootWindow);
|
return new QQnxRasterWindow(window, m_screenContext, needRootWindow);
|
||||||
#if !defined(QT_NO_OPENGL)
|
#if !defined(QT_NO_OPENGL)
|
||||||
case QSurface::OpenGLSurface:
|
case QSurface::OpenGLSurface:
|
||||||
return new QQnxEglWindow(window, ms_screenContext, needRootWindow);
|
return new QQnxEglWindow(window, m_screenContext, needRootWindow);
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
qFatal("QQnxWindow: unsupported window API");
|
qFatal("QQnxWindow: unsupported window API");
|
||||||
@ -449,7 +451,7 @@ QPlatformDrag *QQnxIntegration::drag() const
|
|||||||
QVariant QQnxIntegration::styleHint(QPlatformIntegration::StyleHint hint) const
|
QVariant QQnxIntegration::styleHint(QPlatformIntegration::StyleHint hint) const
|
||||||
{
|
{
|
||||||
qIntegrationDebug();
|
qIntegrationDebug();
|
||||||
if ((hint == ShowIsFullScreen) && (ms_options & FullScreenApplication))
|
if ((hint == ShowIsFullScreen) && (m_options & FullScreenApplication))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return QPlatformIntegration::styleHint(hint);
|
return QPlatformIntegration::styleHint(hint);
|
||||||
@ -463,25 +465,25 @@ QPlatformServices * QQnxIntegration::services() const
|
|||||||
QWindow *QQnxIntegration::window(screen_window_t qnxWindow)
|
QWindow *QQnxIntegration::window(screen_window_t qnxWindow)
|
||||||
{
|
{
|
||||||
qIntegrationDebug();
|
qIntegrationDebug();
|
||||||
QMutexLocker locker(&ms_windowMapperMutex);
|
QMutexLocker locker(&m_windowMapperMutex);
|
||||||
Q_UNUSED(locker);
|
Q_UNUSED(locker);
|
||||||
return ms_windowMapper.value(qnxWindow, 0);
|
return m_windowMapper.value(qnxWindow, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QQnxIntegration::addWindow(screen_window_t qnxWindow, QWindow *window)
|
void QQnxIntegration::addWindow(screen_window_t qnxWindow, QWindow *window)
|
||||||
{
|
{
|
||||||
qIntegrationDebug();
|
qIntegrationDebug();
|
||||||
QMutexLocker locker(&ms_windowMapperMutex);
|
QMutexLocker locker(&m_windowMapperMutex);
|
||||||
Q_UNUSED(locker);
|
Q_UNUSED(locker);
|
||||||
ms_windowMapper.insert(qnxWindow, window);
|
m_windowMapper.insert(qnxWindow, window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QQnxIntegration::removeWindow(screen_window_t qnxWindow)
|
void QQnxIntegration::removeWindow(screen_window_t qnxWindow)
|
||||||
{
|
{
|
||||||
qIntegrationDebug();
|
qIntegrationDebug();
|
||||||
QMutexLocker locker(&ms_windowMapperMutex);
|
QMutexLocker locker(&m_windowMapperMutex);
|
||||||
Q_UNUSED(locker);
|
Q_UNUSED(locker);
|
||||||
ms_windowMapper.remove(qnxWindow);
|
m_windowMapper.remove(qnxWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QQnxIntegration::createDisplays()
|
void QQnxIntegration::createDisplays()
|
||||||
@ -489,7 +491,7 @@ void QQnxIntegration::createDisplays()
|
|||||||
qIntegrationDebug();
|
qIntegrationDebug();
|
||||||
// Query number of displays
|
// Query number of displays
|
||||||
int displayCount = 0;
|
int displayCount = 0;
|
||||||
int result = screen_get_context_property_iv(ms_screenContext, SCREEN_PROPERTY_DISPLAY_COUNT,
|
int result = screen_get_context_property_iv(m_screenContext, SCREEN_PROPERTY_DISPLAY_COUNT,
|
||||||
&displayCount);
|
&displayCount);
|
||||||
Q_SCREEN_CRITICALERROR(result, "Failed to query display count");
|
Q_SCREEN_CRITICALERROR(result, "Failed to query display count");
|
||||||
|
|
||||||
@ -500,7 +502,7 @@ void QQnxIntegration::createDisplays()
|
|||||||
|
|
||||||
// Get all displays
|
// Get all displays
|
||||||
screen_display_t *displays = (screen_display_t *)alloca(sizeof(screen_display_t) * displayCount);
|
screen_display_t *displays = (screen_display_t *)alloca(sizeof(screen_display_t) * displayCount);
|
||||||
result = screen_get_context_property_pv(ms_screenContext, SCREEN_PROPERTY_DISPLAYS,
|
result = screen_get_context_property_pv(m_screenContext, SCREEN_PROPERTY_DISPLAYS,
|
||||||
(void **)displays);
|
(void **)displays);
|
||||||
Q_SCREEN_CRITICALERROR(result, "Failed to query displays");
|
Q_SCREEN_CRITICALERROR(result, "Failed to query displays");
|
||||||
|
|
||||||
@ -526,7 +528,7 @@ void QQnxIntegration::createDisplays()
|
|||||||
|
|
||||||
void QQnxIntegration::createDisplay(screen_display_t display, bool isPrimary)
|
void QQnxIntegration::createDisplay(screen_display_t display, bool isPrimary)
|
||||||
{
|
{
|
||||||
QQnxScreen *screen = new QQnxScreen(ms_screenContext, display, isPrimary);
|
QQnxScreen *screen = new QQnxScreen(m_screenContext, display, isPrimary);
|
||||||
m_screens.append(screen);
|
m_screens.append(screen);
|
||||||
screenAdded(screen);
|
screenAdded(screen);
|
||||||
screen->adjustOrientation();
|
screen->adjustOrientation();
|
||||||
@ -575,14 +577,14 @@ QQnxScreen *QQnxIntegration::primaryDisplay() const
|
|||||||
return m_screens.first();
|
return m_screens.first();
|
||||||
}
|
}
|
||||||
|
|
||||||
QQnxIntegration::Options QQnxIntegration::options()
|
QQnxIntegration::Options QQnxIntegration::options() const
|
||||||
{
|
{
|
||||||
return ms_options;
|
return m_options;
|
||||||
}
|
}
|
||||||
|
|
||||||
screen_context_t QQnxIntegration::screenContext()
|
screen_context_t QQnxIntegration::screenContext()
|
||||||
{
|
{
|
||||||
return ms_screenContext;
|
return m_screenContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
QQnxNavigatorEventHandler *QQnxIntegration::navigatorEventHandler()
|
QQnxNavigatorEventHandler *QQnxIntegration::navigatorEventHandler()
|
||||||
@ -590,10 +592,6 @@ QQnxNavigatorEventHandler *QQnxIntegration::navigatorEventHandler()
|
|||||||
return m_navigatorEventHandler;
|
return m_navigatorEventHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
screen_context_t QQnxIntegration::ms_screenContext = 0;
|
|
||||||
|
|
||||||
QQnxIntegration::Options QQnxIntegration::ms_options = 0;
|
|
||||||
|
|
||||||
bool QQnxIntegration::supportsNavigatorEvents() const
|
bool QQnxIntegration::supportsNavigatorEvents() const
|
||||||
{
|
{
|
||||||
// If QQNX_PPS is defined then we have navigator
|
// If QQNX_PPS is defined then we have navigator
|
||||||
|
@ -87,6 +87,8 @@ public:
|
|||||||
explicit QQnxIntegration(const QStringList ¶mList);
|
explicit QQnxIntegration(const QStringList ¶mList);
|
||||||
~QQnxIntegration();
|
~QQnxIntegration();
|
||||||
|
|
||||||
|
static QQnxIntegration *instance() { return ms_instance; }
|
||||||
|
|
||||||
bool hasCapability(QPlatformIntegration::Capability cap) const override;
|
bool hasCapability(QPlatformIntegration::Capability cap) const override;
|
||||||
|
|
||||||
QPlatformWindow *createPlatformWindow(QWindow *window) const override;
|
QPlatformWindow *createPlatformWindow(QWindow *window) const override;
|
||||||
@ -120,15 +122,15 @@ public:
|
|||||||
|
|
||||||
QPlatformServices *services() const override;
|
QPlatformServices *services() const override;
|
||||||
|
|
||||||
static QWindow *window(screen_window_t qnxWindow);
|
QWindow *window(screen_window_t qnxWindow);
|
||||||
|
|
||||||
QQnxScreen *screenForNative(screen_display_t qnxScreen) const;
|
QQnxScreen *screenForNative(screen_display_t qnxScreen) const;
|
||||||
|
|
||||||
void createDisplay(screen_display_t display, bool isPrimary);
|
void createDisplay(screen_display_t display, bool isPrimary);
|
||||||
void removeDisplay(QQnxScreen *screen);
|
void removeDisplay(QQnxScreen *screen);
|
||||||
QQnxScreen *primaryDisplay() const;
|
QQnxScreen *primaryDisplay() const;
|
||||||
static Options options();
|
Options options() const;
|
||||||
static screen_context_t screenContext();
|
screen_context_t screenContext();
|
||||||
|
|
||||||
QQnxNavigatorEventHandler *navigatorEventHandler();
|
QQnxNavigatorEventHandler *navigatorEventHandler();
|
||||||
|
|
||||||
@ -136,10 +138,10 @@ private:
|
|||||||
void createDisplays();
|
void createDisplays();
|
||||||
void destroyDisplays();
|
void destroyDisplays();
|
||||||
|
|
||||||
static void addWindow(screen_window_t qnxWindow, QWindow *window);
|
void addWindow(screen_window_t qnxWindow, QWindow *window);
|
||||||
static void removeWindow(screen_window_t qnxWindow);
|
void removeWindow(screen_window_t qnxWindow);
|
||||||
|
|
||||||
static screen_context_t ms_screenContext;
|
screen_context_t m_screenContext;
|
||||||
QQnxScreenEventThread *m_screenEventThread;
|
QQnxScreenEventThread *m_screenEventThread;
|
||||||
QQnxNavigatorEventHandler *m_navigatorEventHandler;
|
QQnxNavigatorEventHandler *m_navigatorEventHandler;
|
||||||
QQnxAbstractVirtualKeyboard *m_virtualKeyboard;
|
QQnxAbstractVirtualKeyboard *m_virtualKeyboard;
|
||||||
@ -161,10 +163,12 @@ private:
|
|||||||
#if QT_CONFIG(draganddrop)
|
#if QT_CONFIG(draganddrop)
|
||||||
QSimpleDrag *m_drag;
|
QSimpleDrag *m_drag;
|
||||||
#endif
|
#endif
|
||||||
static QQnxWindowMapper ms_windowMapper;
|
QQnxWindowMapper m_windowMapper;
|
||||||
static QMutex ms_windowMapperMutex;
|
QMutex m_windowMapperMutex;
|
||||||
|
|
||||||
static Options ms_options;
|
Options m_options;
|
||||||
|
|
||||||
|
static QQnxIntegration *ms_instance;
|
||||||
|
|
||||||
friend class QQnxWindow;
|
friend class QQnxWindow;
|
||||||
};
|
};
|
||||||
|
@ -326,11 +326,11 @@ void QQnxScreenEventHandler::handlePointerEvent(screen_event_t event)
|
|||||||
"Failed to query event wheel delta");
|
"Failed to query event wheel delta");
|
||||||
|
|
||||||
// Map window handle to top-level QWindow
|
// Map window handle to top-level QWindow
|
||||||
QWindow *w = QQnxIntegration::window(qnxWindow);
|
QWindow *w = QQnxIntegration::instance()->window(qnxWindow);
|
||||||
|
|
||||||
// Generate enter and leave events as needed.
|
// Generate enter and leave events as needed.
|
||||||
if (qnxWindow != m_lastMouseWindow) {
|
if (qnxWindow != m_lastMouseWindow) {
|
||||||
QWindow *wOld = QQnxIntegration::window(m_lastMouseWindow);
|
QWindow *wOld = QQnxIntegration::instance()->window(m_lastMouseWindow);
|
||||||
|
|
||||||
if (wOld) {
|
if (wOld) {
|
||||||
QWindowSystemInterface::handleLeaveEvent(wOld);
|
QWindowSystemInterface::handleLeaveEvent(wOld);
|
||||||
@ -438,11 +438,11 @@ void QQnxScreenEventHandler::handleTouchEvent(screen_event_t event, int qnxType)
|
|||||||
if (touchId < MaximumTouchPoints) {
|
if (touchId < MaximumTouchPoints) {
|
||||||
|
|
||||||
// Map window handle to top-level QWindow
|
// Map window handle to top-level QWindow
|
||||||
QWindow *w = QQnxIntegration::window(qnxWindow);
|
QWindow *w = QQnxIntegration::instance()->window(qnxWindow);
|
||||||
|
|
||||||
// Generate enter and leave events as needed.
|
// Generate enter and leave events as needed.
|
||||||
if (qnxWindow != m_lastMouseWindow) {
|
if (qnxWindow != m_lastMouseWindow) {
|
||||||
QWindow *wOld = QQnxIntegration::window(m_lastMouseWindow);
|
QWindow *wOld = QQnxIntegration::instance()->window(m_lastMouseWindow);
|
||||||
|
|
||||||
if (wOld) {
|
if (wOld) {
|
||||||
QWindowSystemInterface::handleLeaveEvent(wOld);
|
QWindowSystemInterface::handleLeaveEvent(wOld);
|
||||||
@ -532,7 +532,7 @@ void QQnxScreenEventHandler::handleCloseEvent(screen_event_t event)
|
|||||||
Q_EMIT windowClosed(window);
|
Q_EMIT windowClosed(window);
|
||||||
|
|
||||||
// Map window handle to top-level QWindow
|
// Map window handle to top-level QWindow
|
||||||
QWindow *w = QQnxIntegration::window(window);
|
QWindow *w = QQnxIntegration::instance()->window(window);
|
||||||
if (w != 0)
|
if (w != 0)
|
||||||
QWindowSystemInterface::handleCloseEvent(w);
|
QWindowSystemInterface::handleCloseEvent(w);
|
||||||
}
|
}
|
||||||
@ -632,7 +632,7 @@ void QQnxScreenEventHandler::handleKeyboardFocusPropertyEvent(screen_window_t wi
|
|||||||
if (Q_UNLIKELY(window && screen_get_window_property_iv(window, SCREEN_PROPERTY_FOCUS, &focus) != 0))
|
if (Q_UNLIKELY(window && screen_get_window_property_iv(window, SCREEN_PROPERTY_FOCUS, &focus) != 0))
|
||||||
qFatal("QQnx: failed to query keyboard focus property, errno=%d", errno);
|
qFatal("QQnx: failed to query keyboard focus property, errno=%d", errno);
|
||||||
|
|
||||||
QWindow *focusWindow = QQnxIntegration::window(window);
|
QWindow *focusWindow = QQnxIntegration::instance()->window(window);
|
||||||
|
|
||||||
if (m_focusLostTimer != -1) {
|
if (m_focusLostTimer != -1) {
|
||||||
killTimer(m_focusLostTimer);
|
killTimer(m_focusLostTimer);
|
||||||
@ -658,7 +658,7 @@ void QQnxScreenEventHandler::handleGeometryPropertyEvent(screen_window_t window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QRect rect(pos[0], pos[1], size[0], size[1]);
|
QRect rect(pos[0], pos[1], size[0], size[1]);
|
||||||
QWindow *qtWindow = QQnxIntegration::window(window);
|
QWindow *qtWindow = QQnxIntegration::instance()->window(window);
|
||||||
if (qtWindow) {
|
if (qtWindow) {
|
||||||
qtWindow->setGeometry(rect);
|
qtWindow->setGeometry(rect);
|
||||||
QWindowSystemInterface::handleGeometryChange(qtWindow, rect);
|
QWindowSystemInterface::handleGeometryChange(qtWindow, rect);
|
||||||
|
@ -271,7 +271,7 @@ QQnxWindow::~QQnxWindow()
|
|||||||
Q_ASSERT(m_childWindows.size() == 0);
|
Q_ASSERT(m_childWindows.size() == 0);
|
||||||
|
|
||||||
// Remove from plugin's window mapper
|
// Remove from plugin's window mapper
|
||||||
QQnxIntegration::removeWindow(m_window);
|
QQnxIntegration::instance()->removeWindow(m_window);
|
||||||
|
|
||||||
// Remove from parent's Hierarchy.
|
// Remove from parent's Hierarchy.
|
||||||
removeFromParent();
|
removeFromParent();
|
||||||
@ -480,7 +480,7 @@ void QQnxWindow::setScreen(QQnxScreen *platformScreen)
|
|||||||
qWindowDebug("Moving window to different screen");
|
qWindowDebug("Moving window to different screen");
|
||||||
m_screen->removeWindow(this);
|
m_screen->removeWindow(this);
|
||||||
|
|
||||||
if ((QQnxIntegration::options() & QQnxIntegration::RootWindow)) {
|
if ((QQnxIntegration::instance()->options() & QQnxIntegration::RootWindow)) {
|
||||||
screen_leave_window_group(m_window);
|
screen_leave_window_group(m_window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -735,7 +735,7 @@ void QQnxWindow::initWindow()
|
|||||||
m_exposed = false;
|
m_exposed = false;
|
||||||
|
|
||||||
// Add window to plugin's window mapper
|
// Add window to plugin's window mapper
|
||||||
QQnxIntegration::addWindow(m_window, window());
|
QQnxIntegration::instance()->addWindow(m_window, window());
|
||||||
|
|
||||||
// Qt never calls these setters after creating the window, so we need to do that ourselves here
|
// Qt never calls these setters after creating the window, so we need to do that ourselves here
|
||||||
setWindowState(window()->windowState());
|
setWindowState(window()->windowState());
|
||||||
@ -832,7 +832,7 @@ void QQnxWindow::windowPosted()
|
|||||||
bool QQnxWindow::shouldMakeFullScreen() const
|
bool QQnxWindow::shouldMakeFullScreen() const
|
||||||
{
|
{
|
||||||
return ((static_cast<QQnxScreen *>(screen())->rootWindow() == this)
|
return ((static_cast<QQnxScreen *>(screen())->rootWindow() == this)
|
||||||
&& (QQnxIntegration::options() & QQnxIntegration::FullScreenApplication));
|
&& (QQnxIntegration::instance()->options() & QQnxIntegration::FullScreenApplication));
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user