summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/qnx
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/qnx')
-rw-r--r--src/plugins/platforms/qnx/qqnxglcontext.cpp10
-rw-r--r--src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp12
-rw-r--r--src/plugins/platforms/qnx/qqnxinputcontext_imf.h6
-rw-r--r--src/plugins/platforms/qnx/qqnxinputcontext_noimf.cpp18
-rw-r--r--src/plugins/platforms/qnx/qqnxinputcontext_noimf.h6
-rw-r--r--src/plugins/platforms/qnx/qqnxintegration.cpp15
-rw-r--r--src/plugins/platforms/qnx/qqnxrootwindow.cpp2
-rw-r--r--src/plugins/platforms/qnx/qqnxrootwindow.h4
-rw-r--r--src/plugins/platforms/qnx/qqnxscreen.cpp30
-rw-r--r--src/plugins/platforms/qnx/qqnxscreen.h8
-rw-r--r--src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp16
11 files changed, 92 insertions, 35 deletions
diff --git a/src/plugins/platforms/qnx/qqnxglcontext.cpp b/src/plugins/platforms/qnx/qqnxglcontext.cpp
index aa748fc852..1c2ec23fa9 100644
--- a/src/plugins/platforms/qnx/qqnxglcontext.cpp
+++ b/src/plugins/platforms/qnx/qqnxglcontext.cpp
@@ -150,13 +150,13 @@ QQnxGLContext::QQnxGLContext(QOpenGLContext *glContext)
// Select EGL config based on requested window format
m_eglConfig = q_configFromGLFormat(ms_eglDisplay, format);
if (m_eglConfig == 0) {
- qFatal("QQNXQBBWindow: failed to find EGL config");
+ qFatal("QQnxGLContext: failed to find EGL config");
}
m_eglContext = eglCreateContext(ms_eglDisplay, m_eglConfig, EGL_NO_CONTEXT, contextAttrs());
if (m_eglContext == EGL_NO_CONTEXT) {
checkEGLError("eglCreateContext");
- qFatal("QQNXQBBWindow: failed to create EGL context, err=%d", eglGetError());
+ qFatal("QQnxGLContext: failed to create EGL context, err=%d", eglGetError());
}
// Query/cache window format of selected EGL config
@@ -184,13 +184,13 @@ void QQnxGLContext::initialize()
ms_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (ms_eglDisplay == EGL_NO_DISPLAY) {
checkEGLError("eglGetDisplay");
- qFatal("QQNXQBBWindow: failed to obtain EGL display");
+ qFatal("QQnxGLContext: failed to obtain EGL display");
}
EGLBoolean eglResult = eglInitialize(ms_eglDisplay, 0, 0);
if (eglResult != EGL_TRUE) {
checkEGLError("eglInitialize");
- qFatal("QQNXQBBWindow: failed to initialize EGL display, err=%d", eglGetError());
+ qFatal("QQnxGLContext: failed to initialize EGL display, err=%d", eglGetError());
}
}
@@ -217,7 +217,7 @@ bool QQnxGLContext::makeCurrent(QPlatformSurface *surface)
// Set current rendering API
EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API);
if (eglResult != EGL_TRUE) {
- qFatal("QQNXQBBWindow: failed to set EGL API, err=%d", eglGetError());
+ qFatal("QQnxGLContext: failed to set EGL API, err=%d", eglGetError());
}
if (m_newSurfaceRequested.testAndSetOrdered(true, false)) {
diff --git a/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp b/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp
index 30ca8a5c48..0d8f430c73 100644
--- a/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp
+++ b/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp
@@ -42,6 +42,8 @@
#include "qqnxinputcontext_imf.h"
#include "qqnxeventthread.h"
#include "qqnxabstractvirtualkeyboard.h"
+#include "qqnxintegration.h"
+#include "qqnxscreen.h"
#include <QtGui/QGuiApplication>
#include <QtGui/QInputMethodEvent>
@@ -645,12 +647,13 @@ static bool imfAvailable()
QT_BEGIN_NAMESPACE
-QQnxInputContext::QQnxInputContext(QQnxAbstractVirtualKeyboard &keyboard):
+QQnxInputContext::QQnxInputContext(QQnxIntegration *integration, QQnxAbstractVirtualKeyboard &keyboard) :
QPlatformInputContext(),
m_lastCaretPos(0),
m_isComposing(false),
m_inputPanelVisible(false),
m_inputPanelLocale(QLocale::c()),
+ m_integration(integration),
m_virtualKeyboad(keyboard)
{
qInputContextDebug() << Q_FUNC_INFO;
@@ -857,6 +860,13 @@ bool QQnxInputContext::filterEvent( const QEvent *event )
}
}
+QRectF QQnxInputContext::keyboardRect() const
+{
+ QRect screenGeometry = m_integration->primaryDisplay()->geometry();
+ return QRectF(screenGeometry.x(), screenGeometry.height() - m_virtualKeyboard.height(),
+ screenGeometry.width(), m_virtualKeyboard.height());
+}
+
void QQnxInputContext::reset()
{
qInputContextDebug() << Q_FUNC_INFO;
diff --git a/src/plugins/platforms/qnx/qqnxinputcontext_imf.h b/src/plugins/platforms/qnx/qqnxinputcontext_imf.h
index 72c52300bb..1980a99ed9 100644
--- a/src/plugins/platforms/qnx/qqnxinputcontext_imf.h
+++ b/src/plugins/platforms/qnx/qqnxinputcontext_imf.h
@@ -54,21 +54,24 @@
QT_BEGIN_NAMESPACE
class QQnxAbstractVirtualKeyboard;
+class QQnxIntegration;
class QQnxInputContext : public QPlatformInputContext
{
Q_OBJECT
public:
- explicit QQnxInputContext(QQnxAbstractVirtualKeyboard &keyboard);
+ explicit QQnxInputContext(QQnxIntegration *integration, QQnxAbstractVirtualKeyboard &keyboard);
~QQnxInputContext();
bool isValid() const;
bool filterEvent(const QEvent *event);
+ QRectF keyboardRect() const;
void reset();
void update(Qt::InputMethodQueries);
bool handleKeyboardEvent(int flags, int sym, int mod, int scan, int cap);
+
void showInputPanel();
void hideInputPanel();
bool isInputPanelVisible() const;
@@ -125,6 +128,7 @@ private:
QString m_composingText;
bool m_inputPanelVisible;
QLocale m_inputPanelLocale;
+ QQnxIntegration *m_integration;
QQnxAbstractVirtualKeyboard &m_virtualKeyboad;
};
diff --git a/src/plugins/platforms/qnx/qqnxinputcontext_noimf.cpp b/src/plugins/platforms/qnx/qqnxinputcontext_noimf.cpp
index 23d1f75539..71b925357a 100644
--- a/src/plugins/platforms/qnx/qqnxinputcontext_noimf.cpp
+++ b/src/plugins/platforms/qnx/qqnxinputcontext_noimf.cpp
@@ -41,6 +41,8 @@
#include "qqnxinputcontext_noimf.h"
#include "qqnxabstractvirtualkeyboard.h"
+#include "qqnxintegration.h"
+#include "qqnxscreen.h"
#include <QtCore/QDebug>
#include <QtGui/QGuiApplication>
@@ -53,12 +55,14 @@
QT_BEGIN_NAMESPACE
-QQnxInputContext::QQnxInputContext(QQnxAbstractVirtualKeyboard &keyboard) :
+QQnxInputContext::QQnxInputContext(QQnxIntegration *integration, QQnxAbstractVirtualKeyboard &keyboard) :
QPlatformInputContext(),
m_inputPanelVisible(false),
m_inputPanelLocale(QLocale::c()),
+ m_integration(integration),
m_virtualKeyboard(keyboard)
{
+ connect(&keyboard, SIGNAL(heightChanged(int)), this, SLOT(keyboardHeightChanged()));
connect(&keyboard, SIGNAL(visibilityChanged(bool)), this, SLOT(keyboardVisibilityChanged(bool)));
connect(&keyboard, SIGNAL(localeChanged(QLocale)), this, SLOT(keyboardLocaleChanged(QLocale)));
keyboardVisibilityChanged(keyboard.isVisible());
@@ -105,6 +109,13 @@ bool QQnxInputContext::filterEvent( const QEvent *event )
}
+QRectF QQnxInputContext::keyboardRect() const
+{
+ QRect screenGeometry = m_integration->primaryDisplay()->geometry();
+ return QRectF(screenGeometry.x(), screenGeometry.height() - m_virtualKeyboard.height(),
+ screenGeometry.width(), m_virtualKeyboard.height());
+}
+
bool QQnxInputContext::handleKeyboardEvent(int flags, int sym, int mod, int scan, int cap)
{
Q_UNUSED(flags);
@@ -137,6 +148,11 @@ QLocale QQnxInputContext::locale() const
return m_inputPanelLocale;
}
+void QQnxInputContext::keyboardHeightChanged()
+{
+ emitKeyboardRectChanged();
+}
+
void QQnxInputContext::keyboardVisibilityChanged(bool visible)
{
qInputContextDebug() << Q_FUNC_INFO << "visible=" << visible;
diff --git a/src/plugins/platforms/qnx/qqnxinputcontext_noimf.h b/src/plugins/platforms/qnx/qqnxinputcontext_noimf.h
index c037b6afd0..1ecf7cc94e 100644
--- a/src/plugins/platforms/qnx/qqnxinputcontext_noimf.h
+++ b/src/plugins/platforms/qnx/qqnxinputcontext_noimf.h
@@ -49,18 +49,20 @@
QT_BEGIN_NAMESPACE
class QQnxAbstractVirtualKeyboard;
+class QQnxIntegration;
class QQnxInputContext : public QPlatformInputContext
{
Q_OBJECT
public:
- explicit QQnxInputContext(QQnxAbstractVirtualKeyboard &keyboard);
+ explicit QQnxInputContext(QQnxIntegration *integration, QQnxAbstractVirtualKeyboard &keyboard);
~QQnxInputContext();
bool isValid() const;
void reset();
bool filterEvent( const QEvent *event );
+ QRectF keyboardRect() const;
bool handleKeyboardEvent(int flags, int sym, int mod, int scan, int cap);
void showInputPanel();
@@ -71,6 +73,7 @@ public:
void setFocusObject(QObject *object);
private Q_SLOTS:
+ void keyboardHeightChanged();
void keyboardVisibilityChanged(bool visible);
void keyboardLocaleChanged(const QLocale &locale);
@@ -79,6 +82,7 @@ private:
bool m_inputPanelVisible;
QLocale m_inputPanelLocale;
+ QQnxIntegration *m_integration;
QQnxAbstractVirtualKeyboard &m_virtualKeyboard;
};
diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp
index bff4dbdc2a..f3cfdab9c6 100644
--- a/src/plugins/platforms/qnx/qqnxintegration.cpp
+++ b/src/plugins/platforms/qnx/qqnxintegration.cpp
@@ -214,7 +214,7 @@ QQnxIntegration::QQnxIntegration()
#if defined(QQNX_PPS)
// Set up the input context
- m_inputContext = new QQnxInputContext(*m_virtualKeyboard);
+ m_inputContext = new QQnxInputContext(this, *m_virtualKeyboard);
#endif
}
@@ -446,6 +446,11 @@ void QQnxIntegration::createDisplays()
qFatal("QQnxIntegration: failed to query display count, errno=%d", errno);
}
+ if (displayCount < 1) {
+ // Never happens, even if there's no display, libscreen returns 1
+ qFatal("QQnxIntegration: displayCount=%d", displayCount);
+ }
+
// Get all displays
errno = 0;
screen_display_t *displays = (screen_display_t *)alloca(sizeof(screen_display_t) * displayCount);
@@ -454,7 +459,11 @@ void QQnxIntegration::createDisplays()
qFatal("QQnxIntegration: failed to query displays, errno=%d", errno);
}
- for (int i=0; i<displayCount; i++) {
+ // If it's primary, we create a QScreen for it even if it's not attached
+ // since Qt will dereference QGuiApplication::primaryScreen()
+ createDisplay(displays[0], /*isPrimary=*/true);
+
+ for (int i=1; i<displayCount; i++) {
int isAttached = 0;
result = screen_get_display_property_iv(displays[i], SCREEN_PROPERTY_ATTACHED, &isAttached);
if (result != 0) {
@@ -468,7 +477,7 @@ void QQnxIntegration::createDisplays()
}
qIntegrationDebug() << Q_FUNC_INFO << "Creating screen for display" << i;
- createDisplay(displays[i], i==0);
+ createDisplay(displays[i], /*isPrimary=*/false);
} // of displays iteration
}
diff --git a/src/plugins/platforms/qnx/qqnxrootwindow.cpp b/src/plugins/platforms/qnx/qqnxrootwindow.cpp
index ee05e00394..b01d468647 100644
--- a/src/plugins/platforms/qnx/qqnxrootwindow.cpp
+++ b/src/plugins/platforms/qnx/qqnxrootwindow.cpp
@@ -57,7 +57,7 @@
static const int MAGIC_ZORDER_FOR_NO_NAV = 10;
-QQnxRootWindow::QQnxRootWindow(QQnxScreen *screen)
+QQnxRootWindow::QQnxRootWindow(const QQnxScreen *screen)
: m_screen(screen),
m_window(0),
m_windowGroupName()
diff --git a/src/plugins/platforms/qnx/qqnxrootwindow.h b/src/plugins/platforms/qnx/qqnxrootwindow.h
index f9f1dc0810..aae1563c95 100644
--- a/src/plugins/platforms/qnx/qqnxrootwindow.h
+++ b/src/plugins/platforms/qnx/qqnxrootwindow.h
@@ -54,7 +54,7 @@ class QQnxScreen;
class QQnxRootWindow
{
public:
- QQnxRootWindow(QQnxScreen *screen);
+ QQnxRootWindow(const QQnxScreen *screen);
~QQnxRootWindow();
screen_window_t nativeHandle() const { return m_window; }
@@ -71,7 +71,7 @@ public:
private:
void createWindowGroup();
- QQnxScreen *m_screen;
+ const QQnxScreen *m_screen;
screen_window_t m_window;
QByteArray m_windowGroupName;
};
diff --git a/src/plugins/platforms/qnx/qqnxscreen.cpp b/src/plugins/platforms/qnx/qqnxscreen.cpp
index 5450f086e9..fc8b3bb167 100644
--- a/src/plugins/platforms/qnx/qqnxscreen.cpp
+++ b/src/plugins/platforms/qnx/qqnxscreen.cpp
@@ -107,7 +107,6 @@ static QSize determineScreenSize(screen_display_t display, bool primaryScreen) {
QQnxScreen::QQnxScreen(screen_context_t screenContext, screen_display_t display, bool primaryScreen)
: m_screenContext(screenContext),
m_display(display),
- m_rootWindow(),
m_primaryScreen(primaryScreen),
m_posted(false),
m_keyboardHeight(0),
@@ -147,10 +146,6 @@ QQnxScreen::QQnxScreen(screen_context_t screenContext, screen_display_t display,
m_currentPhysicalSize = m_initialPhysicalSize = screenSize;
else
m_currentPhysicalSize = m_initialPhysicalSize = screenSize.transposed();
-
- // We only create the root window if we are the primary display.
- if (primaryScreen)
- m_rootWindow = QSharedPointer<QQnxRootWindow>(new QQnxRootWindow(this));
}
QQnxScreen::~QQnxScreen()
@@ -252,8 +247,8 @@ void QQnxScreen::setRotation(int rotation)
// Check if rotation changed
if (m_currentRotation != rotation) {
// Update rotation of root window
- if (m_rootWindow)
- m_rootWindow->setRotation(rotation);
+ if (rootWindow())
+ rootWindow()->setRotation(rotation);
const QRect previousScreenGeometry = geometry();
@@ -269,16 +264,16 @@ void QQnxScreen::setRotation(int rotation)
// Resize root window if we've rotated 90 or 270 from previous orientation
if (isOrthogonal(m_currentRotation, rotation)) {
qScreenDebug() << Q_FUNC_INFO << "resize, size =" << m_currentGeometry.size();
- if (m_rootWindow)
- m_rootWindow->resize(m_currentGeometry.size());
+ if (rootWindow())
+ rootWindow()->resize(m_currentGeometry.size());
if (m_primaryScreen)
resizeWindows(previousScreenGeometry);
} else {
// TODO: Find one global place to flush display updates
// Force immediate display update if no geometry changes required
- if (m_rootWindow)
- m_rootWindow->flush();
+ if (rootWindow())
+ rootWindow()->flush();
}
// Save new rotation
@@ -495,8 +490,8 @@ void QQnxScreen::onWindowPost(QQnxWindow *window)
// post app window (so navigator will show it) after first child window
// has posted; this only needs to happen once as the app window's content
// never changes
- if (!m_posted && m_rootWindow) {
- m_rootWindow->post();
+ if (!m_posted && rootWindow()) {
+ rootWindow()->post();
m_posted = true;
}
}
@@ -582,4 +577,13 @@ void QQnxScreen::deactivateWindowGroup(const QByteArray &id)
QWindowSystemInterface::handleWindowActivated(0);
}
+QSharedPointer<QQnxRootWindow> QQnxScreen::rootWindow() const
+{
+ // We only create the root window if we are the primary display.
+ if (m_primaryScreen && !m_rootWindow)
+ m_rootWindow = QSharedPointer<QQnxRootWindow>(new QQnxRootWindow(this));
+
+ return m_rootWindow;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/qnx/qqnxscreen.h b/src/plugins/platforms/qnx/qqnxscreen.h
index 682f681cd3..39cd4159d1 100644
--- a/src/plugins/platforms/qnx/qqnxscreen.h
+++ b/src/plugins/platforms/qnx/qqnxscreen.h
@@ -80,7 +80,7 @@ public:
int nativeFormat() const { return (depth() == 32) ? SCREEN_FORMAT_RGBA8888 : SCREEN_FORMAT_RGB565; }
screen_display_t nativeDisplay() const { return m_display; }
screen_context_t nativeContext() const { return m_screenContext; }
- const char *windowGroupName() const { return m_rootWindow->groupName().constData(); }
+ const char *windowGroupName() const { return rootWindow()->groupName().constData(); }
QQnxWindow *findWindow(screen_window_t windowHandle);
@@ -93,7 +93,7 @@ public:
void onWindowPost(QQnxWindow *window);
- QSharedPointer<QQnxRootWindow> rootWindow() const { return m_rootWindow; }
+ QSharedPointer<QQnxRootWindow> rootWindow() const;
QPlatformCursor *cursor() const;
@@ -116,8 +116,8 @@ private:
screen_context_t m_screenContext;
screen_display_t m_display;
- QSharedPointer<QQnxRootWindow> m_rootWindow;
- bool m_primaryScreen;
+ mutable QSharedPointer<QQnxRootWindow> m_rootWindow;
+ const bool m_primaryScreen;
bool m_posted;
int m_initialRotation;
diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
index 4b1cc4fdac..2d3c7608bf 100644
--- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
+++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
@@ -42,6 +42,7 @@
#include "qqnxscreeneventhandler.h"
#include "qqnxintegration.h"
#include "qqnxkeytranslator.h"
+#include "qqnxscreen.h"
#include <QDebug>
#include <QGuiApplication>
@@ -489,9 +490,18 @@ void QQnxScreenEventHandler::handleDisplayEvent(screen_event_t event)
m_qnxIntegration->createDisplay(nativeDisplay, false /* not primary, we assume */);
}
} else if (!isAttached) {
- // libscreen display is deactivated, let's remove the QQnxScreen / QScreen
- qScreenEventDebug() << "removing display";
- m_qnxIntegration->removeDisplay(screen);
+ // We never remove the primary display, the qpa plugin doesn't support that and it crashes.
+ // To support it, this would be needed:
+ // - Adjust all qnx qpa code which uses screens
+ // - Make QWidgetBackingStore not dereference a null paint device
+ // - Create platform resources ( QQnxWindow ) for all QWindow because they would be deleted
+ // when you delete the screen
+
+ if (!screen->isPrimaryScreen()) {
+ // libscreen display is deactivated, let's remove the QQnxScreen / QScreen
+ qScreenEventDebug() << "removing display";
+ m_qnxIntegration->removeDisplay(screen);
+ }
}
}