@@ -28,8 +28,14 @@ MirSurfaceItem::MirSurfaceItem(const QString& name,
28 , m_type(type)
28 , m_type(type)
29 , m_state(state)
29 , m_state(state)
30 , m_img(screenshot.isLocalFile() ? screenshot.toLocalFile() : screenshot.toString())
30 , m_img(screenshot.isLocalFile() ? screenshot.toLocalFile() : screenshot.toString())
31+ , m_haveInputMethod(false)
33+ // The virtual keyboard (input method) has a big transparent area so that
34+ // content behind it show through
32− setFillColor(Qt::white);
35+ setFillColor(Qt::transparent);
37+ connect(this, &QQuickItem::focusChanged,
38+ this, &MirSurfaceItem::onFocusChanged);
35void MirSurfaceItem::paint(QPainter * painter)
41void MirSurfaceItem::paint(QPainter * painter)
@@ -38,3 +44,27 @@ void MirSurfaceItem::paint(QPainter * painter)
38 painter->drawImage(contentsBoundingRect(), m_img, QRect(QPoint(0,0), m_img.size()));
44 painter->drawImage(contentsBoundingRect(), m_img, QRect(QPoint(0,0), m_img.size()));
48+void MirSurfaceItem::touchEvent(QTouchEvent * event)
50+ if (event->type() == QEvent::TouchBegin && hasFocus()) {
51+ Q_EMIT inputMethodRequested();
52+ m_haveInputMethod = true;
56+void MirSurfaceItem::onFocusChanged()
58+ if (!hasFocus() && m_haveInputMethod) {
59+ Q_EMIT inputMethodDismissed();
60+ m_haveInputMethod = false;
64+void MirSurfaceItem::setState(MirSurfaceItem::State newState)
66+ if (newState != m_state) {
68+ Q_EMIT stateChanged(newState);