summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/qnx/qqnxvirtualkeyboard.cpp
diff options
context:
space:
mode:
authorKevin Krammer <kevin.krammer.qnx@kdab.com>2012-03-23 12:50:22 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-28 19:34:42 +0200
commit5d117fd427e3e727df5d3f417a2b91366f2a31c1 (patch)
tree7ab2f4bffabd8af212e481c3563c2b8ecb48d12a /src/plugins/platforms/qnx/qqnxvirtualkeyboard.cpp
parenta80a2c6da241dac77f533bc702a1c7d94349a812 (diff)
Refactoring virtual keyboard class into non-singleton
Getting rid of the singleton gives us better control over when the virtual keyboard handling class is instantiated and configured. Also notify screens about keyboard height changes and let them notify through QWindowSystemInterface instead of "guessing" the screen in QQnxVirtualKeyboard. Change-Id: I71a7f6b5e9d5455563404f6abe7a0daec567a12d Reviewed-by: Sean Harmer <sh@theharmers.co.uk> Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Diffstat (limited to 'src/plugins/platforms/qnx/qqnxvirtualkeyboard.cpp')
-rw-r--r--src/plugins/platforms/qnx/qqnxvirtualkeyboard.cpp59
1 files changed, 16 insertions, 43 deletions
diff --git a/src/plugins/platforms/qnx/qqnxvirtualkeyboard.cpp b/src/plugins/platforms/qnx/qqnxvirtualkeyboard.cpp
index 20c89d3e32..afdd7715db 100644
--- a/src/plugins/platforms/qnx/qqnxvirtualkeyboard.cpp
+++ b/src/plugins/platforms/qnx/qqnxvirtualkeyboard.cpp
@@ -42,9 +42,6 @@
#include "qqnxvirtualkeyboard.h"
#include "qqnxscreen.h"
-#include <QtGui/QPlatformScreen>
-#include <QtGui/QPlatformWindow>
-
#include <QtCore/QDebug>
#include <QtCore/QSocketNotifier>
#include <QtCore/private/qcore_unix_p.h>
@@ -59,11 +56,11 @@
#include <sys/types.h>
#include <unistd.h>
+QT_BEGIN_NAMESPACE
+
const char *QQnxVirtualKeyboard::ms_PPSPath = "/pps/services/input/control?wait";
const size_t QQnxVirtualKeyboard::ms_bufferSize = 2048;
-static QQnxVirtualKeyboard *s_instance = 0;
-
// Huge hack for keyboard shadow (see QNX PR 88400). Should be removed ASAP.
#define KEYBOARD_SHADOW_HEIGHT 8
@@ -85,20 +82,6 @@ QQnxVirtualKeyboard::~QQnxVirtualKeyboard()
close();
}
-/* static */
-QQnxVirtualKeyboard& QQnxVirtualKeyboard::instance()
-{
- if (!s_instance) {
- s_instance = new QQnxVirtualKeyboard();
-
- // delay invocation of start() to the time the event loop is up and running
- // needed to have the QThread internals of the main thread properly initialized
- QMetaObject::invokeMethod(s_instance, "start", Qt::QueuedConnection);
- }
-
- return *s_instance;
-}
-
void QQnxVirtualKeyboard::start()
{
#ifdef QQNXVIRTUALKEYBOARD_DEBUG
@@ -108,15 +91,6 @@ void QQnxVirtualKeyboard::start()
return;
}
-/* static */
-void QQnxVirtualKeyboard::destroy()
-{
- if (s_instance) {
- delete s_instance;
- s_instance = 0;
- }
-}
-
void QQnxVirtualKeyboard::close()
{
delete m_readNotifier;
@@ -292,7 +266,8 @@ void QQnxVirtualKeyboard::handleKeyboardInfoMessage()
if (newHeight != m_height) {
m_height = newHeight;
- updateAvailableScreenGeometry();
+ if (m_visible)
+ emit heightChanged(m_height);
}
const QLocale locale = QLocale(languageId + QLatin1Char('_') + countryId);
@@ -312,7 +287,8 @@ void QQnxVirtualKeyboard::handleKeyboardStateChangeMessage(bool visible)
#ifdef QQNXVIRTUALKEYBOARD_DEBUG
qDebug() << "QQNX: handleKeyboardStateChangeMessage " << visible;
#endif
- updateAvailableScreenGeometry();
+ if (visible != m_visible)
+ emit heightChanged(height());
if (visible)
showKeyboard();
@@ -320,19 +296,6 @@ void QQnxVirtualKeyboard::handleKeyboardStateChangeMessage(bool visible)
hideKeyboard();
}
-void QQnxVirtualKeyboard::updateAvailableScreenGeometry()
-{
-#ifdef QQNXVIRTUALKEYBOARD_DEBUG
- qDebug() << "QQNX: updateAvailableScreenGeometry: keyboard visible=" << m_visible << ", keyboard height=" << m_height;
-#endif
-
- // TODO: What screen index should be used? I assume primaryScreen here because it works, and
- // we do it for handleScreenGeometryChange elsewhere but since we have support
- // for more than one screen, that's not going to always work.
- QQnxScreen *platformScreen = QQnxScreen::primaryDisplay();
- QWindowSystemInterface::handleScreenAvailableGeometryChange(platformScreen->screen(), platformScreen->availableGeometry());
-}
-
bool QQnxVirtualKeyboard::showKeyboard()
{
#ifdef QQNXVIRTUALKEYBOARD_DEBUG
@@ -347,6 +310,9 @@ bool QQnxVirtualKeyboard::showKeyboard()
// hiding the keyboard wipes the setting.
applyKeyboardModeOptions();
+ if (m_visible)
+ return true;
+
pps_encoder_reset(m_encoder);
// Send the show message.
@@ -398,7 +364,12 @@ bool QQnxVirtualKeyboard::hideKeyboard()
void QQnxVirtualKeyboard::setKeyboardMode(KeyboardMode mode)
{
+ if (m_keyboardMode == mode)
+ return;
+
m_keyboardMode = mode;
+ if (m_visible)
+ applyKeyboardModeOptions();
}
void QQnxVirtualKeyboard::applyKeyboardModeOptions()
@@ -495,3 +466,5 @@ void QQnxVirtualKeyboard::addSymbolModeOptions()
pps_encoder_add_string(m_encoder, "enter", "enter.default");
pps_encoder_add_string(m_encoder, "type", "symbol");
}
+
+QT_END_NAMESPACE