summaryrefslogtreecommitdiffstats
path: root/src/compositor
diff options
context:
space:
mode:
Diffstat (limited to 'src/compositor')
-rw-r--r--src/compositor/compositor.pro4
-rw-r--r--src/compositor/compositor_api/compositor_api.pri5
-rw-r--r--src/compositor/compositor_api/qwaylandcompositor.cpp2
-rw-r--r--src/compositor/compositor_api/qwaylandcompositor.h3
-rw-r--r--src/compositor/compositor_api/qwaylandinput.cpp13
-rw-r--r--src/compositor/compositor_api/qwaylandinputmethodcontrol.cpp162
-rw-r--r--src/compositor/compositor_api/qwaylandinputmethodcontrol.h (renamed from src/compositor/compositor_api/qwaylandinputpanel.cpp)67
-rw-r--r--src/compositor/compositor_api/qwaylandinputmethodcontrol_p.h (renamed from src/compositor/compositor_api/qwaylandinputpanel.h)52
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem.cpp60
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem.h12
-rw-r--r--src/compositor/compositor_api/qwaylandsurface.cpp20
-rw-r--r--src/compositor/compositor_api/qwaylandsurface.h5
-rw-r--r--src/compositor/compositor_api/qwaylandsurface_p.h7
-rw-r--r--src/compositor/extensions/extensions.pri21
-rw-r--r--src/compositor/extensions/qwaylandtextinput.cpp591
-rw-r--r--src/compositor/extensions/qwaylandtextinput.h (renamed from src/compositor/extensions/qwlinputpanelsurface_p.h)73
-rw-r--r--src/compositor/extensions/qwaylandtextinput_p.h135
-rw-r--r--src/compositor/extensions/qwaylandtextinputmanager.cpp98
-rw-r--r--src/compositor/extensions/qwaylandtextinputmanager.h (renamed from src/compositor/extensions/qwltextinputmanager.cpp)38
-rw-r--r--src/compositor/extensions/qwaylandtextinputmanager_p.h (renamed from src/compositor/extensions/qwltextinputmanager_p.h)31
-rw-r--r--src/compositor/extensions/qwlinputmethod.cpp152
-rw-r--r--src/compositor/extensions/qwlinputmethod_p.h105
-rw-r--r--src/compositor/extensions/qwlinputmethodcontext.cpp135
-rw-r--r--src/compositor/extensions/qwlinputmethodcontext_p.h90
-rw-r--r--src/compositor/extensions/qwlinputpanel.cpp130
-rw-r--r--src/compositor/extensions/qwlinputpanel_p.h99
-rw-r--r--src/compositor/extensions/qwlinputpanelsurface.cpp86
-rw-r--r--src/compositor/extensions/qwltextinput.cpp212
-rw-r--r--src/compositor/extensions/qwltextinput_p.h106
29 files changed, 1223 insertions, 1291 deletions
diff --git a/src/compositor/compositor.pro b/src/compositor/compositor.pro
index 67c735f98..37f670964 100644
--- a/src/compositor/compositor.pro
+++ b/src/compositor/compositor.pro
@@ -20,8 +20,8 @@ QMAKE_DOCS = $$PWD/doc/qtwaylandcompositor.qdocconf
}
INCLUDEPATH += ../shared
-HEADERS += ../shared/qwaylandmimehelper.h
-SOURCES += ../shared/qwaylandmimehelper.cpp
+HEADERS += ../shared/qwaylandmimehelper.h ../shared/qwaylandinputmethodeventbuilder.h
+SOURCES += ../shared/qwaylandmimehelper.cpp ../shared/qwaylandinputmethodeventbuilder.cpp
include ($$PWD/global/global.pri)
include ($$PWD/wayland_wrapper/wayland_wrapper.pri)
diff --git a/src/compositor/compositor_api/compositor_api.pri b/src/compositor/compositor_api/compositor_api.pri
index 1140efe34..1724ec965 100644
--- a/src/compositor/compositor_api/compositor_api.pri
+++ b/src/compositor/compositor_api/compositor_api.pri
@@ -14,7 +14,6 @@ HEADERS += \
compositor_api/qwaylandpointer_p.h \
compositor_api/qwaylandtouch.h \
compositor_api/qwaylandtouch_p.h \
- compositor_api/qwaylandinputpanel.h \
compositor_api/qwaylandoutput.h \
compositor_api/qwaylanddrag.h \
compositor_api/qwaylandbufferref.h \
@@ -24,6 +23,8 @@ HEADERS += \
compositor_api/qwaylandview_p.h \
compositor_api/qwaylandresource.h \
compositor_api/qwaylandsurfacegrabber.h \
+ compositor_api/qwaylandinputmethodcontrol.h \
+ compositor_api/qwaylandinputmethodcontrol_p.h
SOURCES += \
compositor_api/qwaylandcompositor.cpp \
@@ -33,7 +34,6 @@ SOURCES += \
compositor_api/qwaylandkeyboard.cpp \
compositor_api/qwaylandpointer.cpp \
compositor_api/qwaylandtouch.cpp \
- compositor_api/qwaylandinputpanel.cpp \
compositor_api/qwaylandoutput.cpp \
compositor_api/qwaylanddrag.cpp \
compositor_api/qwaylandbufferref.cpp \
@@ -41,6 +41,7 @@ SOURCES += \
compositor_api/qwaylandview.cpp \
compositor_api/qwaylandresource.cpp \
compositor_api/qwaylandsurfacegrabber.cpp \
+ compositor_api/qwaylandinputmethodcontrol.cpp
QT += core-private
diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp
index 17b089dcf..9bc4f582b 100644
--- a/src/compositor/compositor_api/qwaylandcompositor.cpp
+++ b/src/compositor/compositor_api/qwaylandcompositor.cpp
@@ -85,6 +85,8 @@
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(qLcCompositorInputMethods, "qt.compositor.input.methods")
+
namespace QtWayland {
class WindowSystemEventHandler : public QWindowSystemEventHandler
diff --git a/src/compositor/compositor_api/qwaylandcompositor.h b/src/compositor/compositor_api/qwaylandcompositor.h
index a30786eb2..c03bcc5d1 100644
--- a/src/compositor/compositor_api/qwaylandcompositor.h
+++ b/src/compositor/compositor_api/qwaylandcompositor.h
@@ -44,6 +44,7 @@
#include <QObject>
#include <QImage>
#include <QRect>
+#include <QLoggingCategory>
struct wl_display;
@@ -66,6 +67,8 @@ class QWaylandTouch;
class QWaylandSurfaceGrabber;
class QWaylandBufferRef;
+Q_DECLARE_LOGGING_CATEGORY(qLcCompositorInputMethods)
+
class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandCompositor : public QWaylandObject
{
Q_OBJECT
diff --git a/src/compositor/compositor_api/qwaylandinput.cpp b/src/compositor/compositor_api/qwaylandinput.cpp
index ed1a9c786..ad6cb2369 100644
--- a/src/compositor/compositor_api/qwaylandinput.cpp
+++ b/src/compositor/compositor_api/qwaylandinput.cpp
@@ -38,17 +38,18 @@
#include "qwaylandinput_p.h"
#include "qwaylandcompositor.h"
+#include "qwaylandinputmethodcontrol.h"
#include "qwaylandview.h"
#include <QtWaylandCompositor/QWaylandDrag>
#include <QtWaylandCompositor/QWaylandTouch>
#include <QtWaylandCompositor/QWaylandPointer>
#include <QtWaylandCompositor/QWaylandWlShellSurface>
-#include <QtWaylandCompositor/private/qwlinputmethod_p.h>
#include <QtWaylandCompositor/private/qwaylandinput_p.h>
#include <QtWaylandCompositor/private/qwaylandcompositor_p.h>
#include <QtWaylandCompositor/private/qwldatadevice_p.h>
#include "extensions/qwlqtkey_p.h"
+#include "extensions/qwaylandtextinput.h"
QT_BEGIN_NAMESPACE
@@ -295,11 +296,21 @@ void QWaylandInputDevice::sendFullTouchEvent(QTouchEvent *event)
void QWaylandInputDevice::sendFullKeyEvent(QKeyEvent *event)
{
Q_D(QWaylandInputDevice);
+
if (!keyboardFocus()) {
qWarning("Cannot send key event, no keyboard focus, fix the compositor");
return;
}
+ if (keyboardFocus()->inputMethodControl()->enabled()
+ && event->nativeScanCode() == 0) {
+ QWaylandTextInput *textInput = QWaylandTextInput::findIn(this);
+ if (textInput) {
+ textInput->sendKeyEvent(event);
+ return;
+ }
+ }
+
QtWayland::QtKeyExtensionGlobal *ext = QtWayland::QtKeyExtensionGlobal::findIn(d->compositor);
if (ext && ext->postQtKeyEvent(event, keyboardFocus()))
return;
diff --git a/src/compositor/compositor_api/qwaylandinputmethodcontrol.cpp b/src/compositor/compositor_api/qwaylandinputmethodcontrol.cpp
new file mode 100644
index 000000000..a82990f3d
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylandinputmethodcontrol.cpp
@@ -0,0 +1,162 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandinputmethodcontrol.h"
+#include "qwaylandinputmethodcontrol_p.h"
+
+#include "qwaylandcompositor.h"
+#include "qwaylandinput.h"
+#include "qwaylandsurface.h"
+#include "qwaylandview.h"
+#include "qwaylandtextinput.h"
+
+#include <QtGui/QInputMethodEvent>
+
+QWaylandInputMethodControl::QWaylandInputMethodControl(QWaylandSurface *surface)
+ : QObject(*new QWaylandInputMethodControlPrivate(surface), surface)
+{
+ connect(d_func()->compositor, &QWaylandCompositor::defaultInputDeviceChanged,
+ this, &QWaylandInputMethodControl::defaultInputDeviceChanged);
+ connect(d_func()->textInput(), &QWaylandTextInput::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled);
+ connect(d_func()->textInput(), &QWaylandTextInput::surfaceDisabled, this, &QWaylandInputMethodControl::surfaceDisabled);
+#ifndef QT_NO_IM
+ connect(d_func()->textInput(), &QWaylandTextInput::updateInputMethod, this, &QWaylandInputMethodControl::updateInputMethod);
+#endif
+}
+
+QVariant QWaylandInputMethodControl::inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const
+{
+ Q_D(const QWaylandInputMethodControl);
+
+ QWaylandTextInput *textInput = d->textInput();
+
+ if (textInput && textInput->focus() == d->surface) {
+ return textInput->inputMethodQuery(query, argument);
+ }
+
+ return QVariant();
+}
+
+void QWaylandInputMethodControl::inputMethodEvent(QInputMethodEvent *event)
+{
+ Q_D(QWaylandInputMethodControl);
+
+ QWaylandTextInput *textInput = d->textInput();
+ if (textInput) {
+ textInput->sendInputMethodEvent(event);
+ } else {
+ event->ignore();
+ }
+}
+
+bool QWaylandInputMethodControl::enabled() const
+{
+ Q_D(const QWaylandInputMethodControl);
+
+ return d->enabled;
+}
+
+void QWaylandInputMethodControl::setEnabled(bool enabled)
+{
+ Q_D(QWaylandInputMethodControl);
+
+ if (d->enabled == enabled)
+ return;
+
+ d->enabled = enabled;
+ emit enabledChanged(enabled);
+#ifndef QT_NO_IM
+ emit updateInputMethod(Qt::ImQueryInput);
+#endif
+}
+
+void QWaylandInputMethodControl::surfaceEnabled(QWaylandSurface *surface)
+{
+ Q_D(QWaylandInputMethodControl);
+
+ if (surface == d->surface)
+ setEnabled(true);
+}
+
+void QWaylandInputMethodControl::surfaceDisabled(QWaylandSurface *surface)
+{
+ Q_D(QWaylandInputMethodControl);
+
+ if (surface == d->surface)
+ setEnabled(false);
+}
+
+void QWaylandInputMethodControl::setSurface(QWaylandSurface *surface)
+{
+ Q_D(QWaylandInputMethodControl);
+
+ if (d->surface == surface)
+ return;
+
+ d->surface = surface;
+
+ QWaylandTextInput *textInput = d->textInput();
+ setEnabled(textInput && textInput->isSurfaceEnabled(d->surface));
+}
+
+void QWaylandInputMethodControl::defaultInputDeviceChanged()
+{
+ Q_D(QWaylandInputMethodControl);
+
+ disconnect(d->textInput(), 0, this, 0);
+
+ d->inputDevice = d->compositor->defaultInputDevice();
+ QWaylandTextInput *textInput = d->textInput();
+
+ connect(textInput, &QWaylandTextInput::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled);
+ connect(textInput, &QWaylandTextInput::surfaceDisabled, this, &QWaylandInputMethodControl::surfaceDisabled);
+
+ setEnabled(textInput && textInput->isSurfaceEnabled(d->surface));
+}
+
+QWaylandInputMethodControlPrivate::QWaylandInputMethodControlPrivate(QWaylandSurface *surface)
+ : QObjectPrivate()
+ , compositor(surface->compositor())
+ , inputDevice(compositor->defaultInputDevice())
+ , surface(surface)
+ , enabled(false)
+{
+}
+
+QWaylandTextInput *QWaylandInputMethodControlPrivate::textInput() const
+{
+ return QWaylandTextInput::findIn(inputDevice);
+}
diff --git a/src/compositor/compositor_api/qwaylandinputpanel.cpp b/src/compositor/compositor_api/qwaylandinputmethodcontrol.h
index 6f774cd98..f71650294 100644
--- a/src/compositor/compositor_api/qwaylandinputpanel.cpp
+++ b/src/compositor/compositor_api/qwaylandinputmethodcontrol.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
+** Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
@@ -34,50 +34,51 @@
**
****************************************************************************/
-#include "qwaylandinputpanel.h"
+#ifndef QWAYLANDINPUTMETHODCONTROL_H
+#define QWAYLANDINPUTMETHODCONTROL_H
-#include <QtWaylandCompositor/QWaylandCompositor>
-
-#include <private/qobject_p.h>
-
-#include "qwlinputpanel_p.h"
+#include <QObject>
QT_BEGIN_NAMESPACE
-QWaylandInputPanel::QWaylandInputPanel(QWaylandCompositor *compositor)
- : QWaylandExtensionTemplate(compositor, *new QWaylandInputPanelPrivate(compositor))
-{
-}
+class QWaylandCompositor;
+class QWaylandInputMethodControlPrivate;
+class QWaylandSurface;
+class QInputMethodEvent;
-QWaylandSurface *QWaylandInputPanel::focus() const
+class QWaylandInputMethodControl : public QObject
{
- Q_D(const QWaylandInputPanel);
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWaylandInputMethodControl)
+ Q_DISABLE_COPY(QWaylandInputMethodControl)
- return d->focus();
-}
+ Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
+public:
+ explicit QWaylandInputMethodControl(QWaylandSurface *surface);
-bool QWaylandInputPanel::visible() const
-{
- Q_D(const QWaylandInputPanel);
+#ifndef QT_NO_IM
+ QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const;
+#endif
- return d->inputPanelVisible();
-}
+ void inputMethodEvent(QInputMethodEvent *event);
-QRect QWaylandInputPanel::cursorRectangle() const
-{
- Q_D(const QWaylandInputPanel);
+ bool enabled() const;
+ void setEnabled(bool enabled);
- return d->cursorRectangle();
-}
+ void setSurface(QWaylandSurface *surface);
-const struct wl_interface *QWaylandInputPanel::interface()
-{
- return QWaylandInputPanelPrivate::interface();
-}
+Q_SIGNALS:
+ void enabledChanged(bool enabled);
+#ifndef QT_NO_IM
+ void updateInputMethod(Qt::InputMethodQueries queries);
+#endif
-QByteArray QWaylandInputPanel::interfaceName()
-{
- return QWaylandInputPanelPrivate::interfaceName();
-}
+private:
+ void defaultInputDeviceChanged();
+ void surfaceEnabled(QWaylandSurface *surface);
+ void surfaceDisabled(QWaylandSurface *surface);
+};
QT_END_NAMESPACE
+
+#endif // QWAYLANDINPUTMETHODCONTROL_H
diff --git a/src/compositor/compositor_api/qwaylandinputpanel.h b/src/compositor/compositor_api/qwaylandinputmethodcontrol_p.h
index d29743140..a687e5299 100644
--- a/src/compositor/compositor_api/qwaylandinputpanel.h
+++ b/src/compositor/compositor_api/qwaylandinputmethodcontrol_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
+** Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
@@ -34,45 +34,47 @@
**
****************************************************************************/
-#ifndef QWAYLANDINPUTPANEL_H
-#define QWAYLANDINPUTPANEL_H
+#ifndef QWAYLANDINPUTMETHODCONTROL_P_H
+#define QWAYLANDINPUTMETHODCONTROL_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
#include <QtWaylandCompositor/qwaylandexport.h>
-#include <QtWaylandCompositor/qwaylandextension.h>
+#include <QtWaylandCompositor/qwaylandinputmethodcontrol.h>
-#include <QObject>
-#include <QRect>
+#include <QtCore/private/qobject_p.h>
QT_BEGIN_NAMESPACE
class QWaylandCompositor;
-class QWaylandInputPanelPrivate;
+class QWaylandInputDevice;
class QWaylandSurface;
+class QWaylandTextInput;
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandInputPanel : public QWaylandExtensionTemplate<QWaylandInputPanel>
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandInputMethodControlPrivate : public QObjectPrivate
{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QWaylandInputPanel)
-
- Q_PROPERTY(QWaylandSurface* focus READ focus NOTIFY focusChanged)
- Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged)
- Q_PROPERTY(QRect cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged)
+ Q_DECLARE_PUBLIC(QWaylandInputMethodControl)
public:
- explicit QWaylandInputPanel(QWaylandCompositor *compositor);
+ explicit QWaylandInputMethodControlPrivate(QWaylandSurface *surface);
- QWaylandSurface *focus() const;
- bool visible() const;
- QRect cursorRectangle() const;
+ QWaylandTextInput *textInput() const;
- static const struct wl_interface *interface();
- static QByteArray interfaceName();
-Q_SIGNALS:
- void focusChanged();
- void visibleChanged();
- void cursorRectangleChanged();
+ QWaylandCompositor *compositor;
+ QWaylandInputDevice *inputDevice;
+ QWaylandSurface *surface;
+ bool enabled;
};
QT_END_NAMESPACE
-#endif // QWAYLANDINPUTPANEL_H
+#endif // QWAYLANDINPUTMETHODCONTROL_P_H
diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp
index 8fd759bda..bee12b4a5 100644
--- a/src/compositor/compositor_api/qwaylandquickitem.cpp
+++ b/src/compositor/compositor_api/qwaylandquickitem.cpp
@@ -37,6 +37,8 @@
#include "qwaylandquickitem.h"
#include "qwaylandquickitem_p.h"
#include "qwaylandquicksurface.h"
+#include "qwaylandinputmethodcontrol.h"
+#include "qwaylandtextinput.h"
#include <QtWaylandCompositor/qwaylandcompositor.h>
#include <QtWaylandCompositor/qwaylandinput.h>
#include <QtWaylandCompositor/qwaylandbufferref.h>
@@ -54,6 +56,7 @@
#include <wayland-server.h>
#include <QThread>
+
QT_BEGIN_NAMESPACE
QMutex *QWaylandQuickItemPrivate::mutex = 0;
@@ -459,6 +462,21 @@ void QWaylandQuickItem::mouseUngrabEvent()
}
}
+#ifndef QT_NO_IM
+/*!
+ * \internal
+ */
+void QWaylandQuickItem::inputMethodEvent(QInputMethodEvent *event)
+{
+ Q_D(QWaylandQuickItem);
+ if (d->shouldSendInputEvents()) {
+ d->oldSurface->inputMethodControl()->inputMethodEvent(event);
+ } else {
+ event->ignore();
+ }
+}
+#endif
+
/*!
* \internal
*/
@@ -480,6 +498,9 @@ void QWaylandQuickItem::handleSurfaceChanged()
disconnect(d->oldSurface, &QWaylandSurface::sizeChanged, this, &QWaylandQuickItem::updateSize);
disconnect(d->oldSurface, &QWaylandSurface::configure, this, &QWaylandQuickItem::updateBuffer);
disconnect(d->oldSurface, &QWaylandSurface::redraw, this, &QQuickItem::update);
+#ifndef QT_NO_IM
+ disconnect(d->oldSurface->inputMethodControl(), &QWaylandInputMethodControl::updateInputMethod, this, &QWaylandQuickItem::updateInputMethod);
+#endif
}
if (QWaylandSurface *newSurface = d->view->surface()) {
connect(newSurface, &QWaylandSurface::mappedChanged, this, &QWaylandQuickItem::surfaceMappedChanged);
@@ -487,6 +508,9 @@ void QWaylandQuickItem::handleSurfaceChanged()
connect(newSurface, &QWaylandSurface::sizeChanged, this, &QWaylandQuickItem::updateSize);
connect(newSurface, &QWaylandSurface::configure, this, &QWaylandQuickItem::updateBuffer);
connect(newSurface, &QWaylandSurface::redraw, this, &QQuickItem::update);
+#ifndef QT_NO_IM
+ connect(newSurface->inputMethodControl(), &QWaylandInputMethodControl::updateInputMethod, this, &QWaylandQuickItem::updateInputMethod);
+#endif
if (d->sizeFollowsSurface) {
setWidth(newSurface->size().width());
setHeight(newSurface->size().height());
@@ -502,6 +526,9 @@ void QWaylandQuickItem::handleSurfaceChanged()
}
surfaceChangedEvent(d->view->surface(), d->oldSurface);
d->oldSurface = d->view->surface();
+#ifndef QT_NO_IM
+ updateInputMethod(Qt::ImQueryInput);
+#endif
}
/*!
@@ -510,7 +537,7 @@ void QWaylandQuickItem::handleSurfaceChanged()
*/
void QWaylandQuickItem::takeFocus(QWaylandInputDevice *device)
{
- setFocus(true);
+ forceActiveFocus();
if (!surface())
return;
@@ -520,6 +547,9 @@ void QWaylandQuickItem::takeFocus(QWaylandInputDevice *device)
target = compositor()->defaultInputDevice();
}
target->setKeyboardFocus(surface());
+ QWaylandTextInput *textInput = QWaylandTextInput::findIn(target);
+ if (textInput)
+ textInput->setFocus(surface());
}
/*!
@@ -632,6 +662,23 @@ void QWaylandQuickItem::setSizeFollowsSurface(bool sizeFollowsSurface)
emit sizeFollowsSurfaceChanged();
}
+#ifndef QT_NO_IM
+QVariant QWaylandQuickItem::inputMethodQuery(Qt::InputMethodQuery query) const
+{
+ return inputMethodQuery(query, QVariant());
+}
+
+QVariant QWaylandQuickItem::inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const
+{
+ Q_D(const QWaylandQuickItem);
+
+ if (query == Qt::ImEnabled)
+ return QVariant((flags() & ItemAcceptsInputMethod) != 0);
+
+ return d->oldSurface->inputMethodControl()->inputMethodQuery(query, argument);
+}
+#endif
+
/*!
\qmlproperty bool QtWayland::QWaylandSurfaceItem::paintEnabled
@@ -698,6 +745,17 @@ void QWaylandQuickItem::beforeSync()
}
}
+#ifndef QT_NO_IM
+void QWaylandQuickItem::updateInputMethod(Qt::InputMethodQueries queries)
+{
+ Q_D(QWaylandQuickItem);
+
+ setFlag(QQuickItem::ItemAcceptsInputMethod,
+ d->oldSurface ? d->oldSurface->inputMethodControl()->enabled() : false);
+ QQuickItem::updateInputMethod(queries | Qt::ImEnabled);
+}
+#endif
+
QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
{
Q_D(QWaylandQuickItem);
diff --git a/src/compositor/compositor_api/qwaylandquickitem.h b/src/compositor/compositor_api/qwaylandquickitem.h
index 81ea5213b..9dab65acf 100644
--- a/src/compositor/compositor_api/qwaylandquickitem.h
+++ b/src/compositor/compositor_api/qwaylandquickitem.h
@@ -99,6 +99,11 @@ public:
bool sizeFollowsSurface() const;
void setSizeFollowsSurface(bool sizeFollowsSurface);
+#ifndef QT_NO_IM
+ QVariant inputMethodQuery(Qt::InputMethodQuery query) const Q_DECL_OVERRIDE;
+ Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const;
+#endif
+
protected:
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
@@ -114,6 +119,10 @@ protected:
void touchEvent(QTouchEvent *event) Q_DECL_OVERRIDE;
void mouseUngrabEvent() Q_DECL_OVERRIDE;
+#ifndef QT_NO_IM
+ void inputMethodEvent(QInputMethodEvent *event) Q_DECL_OVERRIDE;
+#endif
+
virtual void surfaceChangedEvent(QWaylandSurface *newSurface, QWaylandSurface *oldSurface);
public Q_SLOTS:
virtual void takeFocus(QWaylandInputDevice *device = 0);
@@ -129,6 +138,9 @@ private Q_SLOTS:
void updateBuffer(bool hasBuffer);
void updateWindow();
void beforeSync();
+#ifndef QT_NO_IM
+ void updateInputMethod(Qt::InputMethodQueries queries);
+#endif
Q_SIGNALS:
void surfaceChanged();
diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp
index 97e4b6a80..3a16ed27a 100644
--- a/src/compositor/compositor_api/qwaylandsurface.cpp
+++ b/src/compositor/compositor_api/qwaylandsurface.cpp
@@ -43,6 +43,7 @@
#include "wayland_wrapper/qwlregion_p.h"
#include "extensions/qwlextendedsurface_p.h"
+#include "qwaylandinputmethodcontrol_p.h"
#include <QtWaylandCompositor/QWaylandCompositor>
#include <QtWaylandCompositor/QWaylandClient>
@@ -124,13 +125,13 @@ QWaylandSurfacePrivate::QWaylandSurfacePrivate()
, client(Q_NULLPTR)
, buffer(0)
, role(0)
- , inputPanelSurface(0)
, inputRegion(infiniteRegion())
, isCursorSurface(false)
, destroyed(false)
, mapped(false)
, isInitialized(false)
, contentOrientation(Qt::PrimaryOrientation)
+ , inputMethodControl(Q_NULLPTR)
, subsurface(0)
{
pending.buffer = 0;
@@ -426,6 +427,7 @@ void QWaylandSurface::initialize(QWaylandCompositor *compositor, QWaylandClient
d->client = client;
d->init(client->client(), id, version);
d->isInitialized = true;
+ d->inputMethodControl = new QWaylandInputMethodControl(this);
#ifndef QT_NO_DEBUG
QWaylandSurfacePrivate::removeUninitializedSurface(d);
#endif
@@ -588,16 +590,6 @@ void QWaylandSurface::sendFrameCallbacks()
}
/*!
- * Returns true if the QWaylandSurface has an input panel surface. Otherwise returns false.
- */
-bool QWaylandSurface::hasInputPanelSurface() const
-{
- Q_D(const QWaylandSurface);
-
- return d->inputPanelSurface != 0;
-}
-
-/*!
* Returns true if the QWaylandSurface's input region contains the point \a p.
* Otherwise returns false.
*/
@@ -660,6 +652,12 @@ bool QWaylandSurface::isCursorSurface() const
return d->isCursorSurface;
}
+QWaylandInputMethodControl *QWaylandSurface::inputMethodControl() const
+{
+ Q_D(const QWaylandSurface);
+ return d->inputMethodControl;
+}
+
/*!
* Updates the surface with the compositor's retained clipboard selection. While this
* is done automatically when the surface receives keyboard focus, this function is
diff --git a/src/compositor/compositor_api/qwaylandsurface.h b/src/compositor/compositor_api/qwaylandsurface.h
index a782e5bae..6abdbdef5 100644
--- a/src/compositor/compositor_api/qwaylandsurface.h
+++ b/src/compositor/compositor_api/qwaylandsurface.h
@@ -59,6 +59,7 @@ class QWaylandCompositor;
class QWaylandBufferRef;
class QWaylandView;
class QWaylandSurfaceOp;
+class QWaylandInputMethodControl;
class QWaylandSurfaceRole
{
@@ -112,8 +113,6 @@ public:
QWaylandCompositor *compositor() const;
- bool hasInputPanelSurface() const;
-
bool inputRegionContains(const QPoint &p) const;
Q_INVOKABLE void destroy();
@@ -133,6 +132,8 @@ public:
void markAsCursorSurface(bool cursorSurface);
bool isCursorSurface() const;
+ QWaylandInputMethodControl *inputMethodControl() const;
+
public Q_SLOTS:
void updateSelection();
diff --git a/src/compositor/compositor_api/qwaylandsurface_p.h b/src/compositor/compositor_api/qwaylandsurface_p.h
index 635820931..d8b289c63 100644
--- a/src/compositor/compositor_api/qwaylandsurface_p.h
+++ b/src/compositor/compositor_api/qwaylandsurface_p.h
@@ -56,7 +56,6 @@
#include <QtWaylandCompositor/qwaylandsurface.h>
#include <QtWaylandCompositor/qwaylandbufferref.h>
-#include <QtWaylandCompositor/private/qwlinputpanelsurface_p.h>
#include <QtWaylandCompositor/private/qwlregion_p.h>
#include <QtCore/QVector>
@@ -78,6 +77,7 @@ class QWaylandCompositor;
class QWaylandSurface;
class QWaylandView;
class QWaylandSurfaceInterface;
+class QWaylandInputMethodControl;
namespace QtWayland {
class FrameCallback;
@@ -105,8 +105,6 @@ public:
void notifyViewsAboutDestruction();
- void setInputPanelSurface(QtWayland::InputPanelSurface *ips) { inputPanelSurface = ips; }
-
#ifndef QT_NO_DEBUG
static void addUninitializedSurface(QWaylandSurfacePrivate *surface);
static void removeUninitializedSurface(QWaylandSurfacePrivate *surface);
@@ -161,8 +159,6 @@ public: //member variables
QList<QtWayland::FrameCallback *> pendingFrameCallbacks;
QList<QtWayland::FrameCallback *> frameCallbacks;
- QtWayland::InputPanelSurface *inputPanelSurface;
-
QRegion inputRegion;
QRegion opaqueRegion;
@@ -175,6 +171,7 @@ public: //member variables
bool isInitialized;
Qt::ScreenOrientation contentOrientation;
QWindow::Visibility visibility;
+ QWaylandInputMethodControl *inputMethodControl;
class Subsurface : public QtWaylandServer::wl_subsurface
{
diff --git a/src/compositor/extensions/extensions.pri b/src/compositor/extensions/extensions.pri
index 03be3905e..1d34803f0 100644
--- a/src/compositor/extensions/extensions.pri
+++ b/src/compositor/extensions/extensions.pri
@@ -4,8 +4,7 @@ WAYLANDSERVERSOURCES += \
../extensions/touch-extension.xml \
../extensions/qtkey-extension.xml \
../extensions/windowmanager.xml \
- ../3rdparty/protocol/input-method.xml \
- ../3rdparty/protocol/text.xml \
+ ../3rdparty/protocol/text-input-unstable-v2.xml \
../3rdparty/protocol/xdg-shell.xml \
HEADERS += \
@@ -14,14 +13,12 @@ HEADERS += \
extensions/qwlqtkey_p.h \
extensions/qwaylandwlshell.h \
extensions/qwaylandwlshell_p.h \
+ extensions/qwaylandtextinput.h \
+ extensions/qwaylandtextinput_p.h \
+ extensions/qwaylandtextinputmanager.h \
+ extensions/qwaylandtextinputmanager_p.h \
extensions/qwaylandwindowmanagerextension.h \
extensions/qwaylandwindowmanagerextension_p.h \
- extensions/qwltextinput_p.h \
- extensions/qwltextinputmanager_p.h \
- extensions/qwlinputpanel_p.h \
- extensions/qwlinputpanelsurface_p.h \
- extensions/qwlinputmethod_p.h \
- extensions/qwlinputmethodcontext_p.h \
extensions/qwaylandxdgshell.h \
extensions/qwaylandxdgshell_p.h \
@@ -30,13 +27,9 @@ SOURCES += \
extensions/qwlqttouch.cpp \
extensions/qwlqtkey.cpp \
extensions/qwaylandwlshell.cpp \
+ extensions/qwaylandtextinput.cpp \
+ extensions/qwaylandtextinputmanager.cpp \
extensions/qwaylandwindowmanagerextension.cpp \
- extensions/qwltextinput.cpp \
- extensions/qwltextinputmanager.cpp \
- extensions/qwlinputpanel.cpp \
- extensions/qwlinputpanelsurface.cpp \
- extensions/qwlinputmethod.cpp \
- extensions/qwlinputmethodcontext.cpp \
extensions/qwaylandxdgshell.cpp \
qtHaveModule(quick) {
diff --git a/src/compositor/extensions/qwaylandtextinput.cpp b/src/compositor/extensions/qwaylandtextinput.cpp
new file mode 100644
index 000000000..31166ddb2
--- /dev/null
+++ b/src/compositor/extensions/qwaylandtextinput.cpp
@@ -0,0 +1,591 @@
+/****************************************************************************
+**
+** Copyright (C) 2013-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandtextinput.h"
+#include "qwaylandtextinput_p.h"
+
+#include <QtWaylandCompositor/QWaylandCompositor>
+#include <QtWaylandCompositor/private/qwaylandinput_p.h>
+
+#include "qwaylandsurface.h"
+#include "qwaylandview.h"
+#include "qwaylandxkb.h"
+#include "qwaylandinputmethodeventbuilder.h"
+
+#include <QGuiApplication>
+#include <QInputMethodEvent>
+
+QT_BEGIN_NAMESPACE
+
+QWaylandTextInputClientState::QWaylandTextInputClientState()
+ : hints(0)
+ , cursorRectangle()
+ , surroundingText()
+ , cursorPosition(0)
+ , anchorPosition(0)
+ , preferredLanguage()
+ , changedState()
+{
+}
+
+Qt::InputMethodQueries QWaylandTextInputClientState::updatedQueries(const QWaylandTextInputClientState &other) const
+{
+ Qt::InputMethodQueries queries;
+
+ if (hints != other.hints)
+ queries |= Qt::ImHints;
+ if (cursorRectangle != other.cursorRectangle)
+ queries |= Qt::ImCursorRectangle;
+ if (surroundingText != other.surroundingText)
+ queries |= Qt::ImSurroundingText | Qt::ImCurrentSelection;
+ if (cursorPosition != other.cursorPosition)
+ queries |= Qt::ImCursorPosition | Qt::ImCurrentSelection;
+ if (anchorPosition != other.anchorPosition)
+ queries |= Qt::ImAnchorPosition | Qt::ImCurrentSelection;
+ if (preferredLanguage != other.preferredLanguage)
+ queries |= Qt::ImPreferredLanguage;
+
+ return queries;
+}
+
+Qt::InputMethodQueries QWaylandTextInputClientState::mergeChanged(const QWaylandTextInputClientState &other) {
+ Qt::InputMethodQueries queries;
+
+ if ((other.changedState & Qt::ImHints) && hints != other.hints) {
+ hints = other.hints;
+ queries |= Qt::ImHints;
+ }
+
+ if ((other.changedState & Qt::ImCursorRectangle) && cursorRectangle != other.cursorRectangle) {
+ cursorRectangle = other.cursorRectangle;
+ queries |= Qt::ImCursorRectangle;
+ }
+
+ if ((other.changedState & Qt::ImSurroundingText) && surroundingText != other.surroundingText) {
+ surroundingText = other.surroundingText;
+ queries |= Qt::ImSurroundingText | Qt::ImCurrentSelection;
+ }
+
+ if ((other.changedState & Qt::ImCursorPosition) && cursorPosition != other.cursorPosition) {
+ cursorPosition = other.cursorPosition;
+ queries |= Qt::ImCursorPosition | Qt::ImCurrentSelection;
+ }
+
+ if ((other.changedState & Qt::ImAnchorPosition) && anchorPosition != other.anchorPosition) {
+ anchorPosition = other.anchorPosition;
+ queries |= Qt::ImAnchorPosition | Qt::ImCurrentSelection;
+ }
+
+ if ((other.changedState & Qt::ImPreferredLanguage) && preferredLanguage != other.preferredLanguage) {
+ preferredLanguage = other.preferredLanguage;
+ queries |= Qt::ImPreferredLanguage;
+ }
+
+ return queries;
+}
+
+QWaylandTextInputPrivate::QWaylandTextInputPrivate(QWaylandCompositor *compositor)
+ : QWaylandExtensionTemplatePrivate()
+ , QtWaylandServer::zwp_text_input_v2()
+ , compositor(compositor)
+ , focus(nullptr)
+ , focusResource(nullptr)
+ , focusDestroyListener()
+ , inputPanelVisible(false)
+ , currentState(new QWaylandTextInputClientState)
+ , pendingState(new QWaylandTextInputClientState)
+ , serial(0)
+ , enabledSurfaces()
+{
+}
+
+void QWaylandTextInputPrivate::sendInputMethodEvent(QInputMethodEvent *event)
+{
+ if (!focusResource || !focusResource->handle)
+ return;
+
+ if (event->replacementLength() > 0 || event->replacementStart() != 0) {
+ if (event->replacementStart() <= 0 && (event->replacementLength() >= -event->replacementStart())) {
+ const int selectionStart = qMin(currentState->cursorPosition, currentState->anchorPosition);
+ const int selectionEnd = qMax(currentState->cursorPosition, currentState->anchorPosition);
+ const int before = currentState->surroundingText.midRef(selectionStart + event->replacementStart(), -event->replacementStart()).toUtf8().size();
+ const int after = currentState->surroundingText.midRef(selectionEnd, event->replacementLength() + event->replacementStart()).toUtf8().size();
+ send_delete_surrounding_text(focusResource->handle, before, after);
+ } else {
+ // TODO: Implement this case
+ qWarning() << "Not yet supported case of replacement. Start:" << event->replacementStart() << "length:" << event->replacementLength();
+ }
+ }
+ foreach (const QInputMethodEvent::Attribute &attribute, event->attributes()) {
+ if (attribute.type == QInputMethodEvent::Selection) {
+ const int cursorAfterCommit = qMin(currentState->cursorPosition, currentState->anchorPosition) + event->replacementStart() + event->commitString().length();
+ QString textAfterCommit = currentState->surroundingText;
+ textAfterCommit.remove(qMin(currentState->cursorPosition, currentState->anchorPosition),
+ qAbs(currentState->cursorPosition - currentState->anchorPosition));
+ textAfterCommit.replace(qMin(currentState->cursorPosition, currentState->anchorPosition) + event->replacementStart(),
+ event->replacementLength(), event->commitString());
+
+ int cursor = textAfterCommit.midRef(qMin(attribute.start, cursorAfterCommit), qAbs(attribute.start - cursorAfterCommit)).toUtf8().size();
+ int anchor = textAfterCommit.midRef(qMin(attribute.length, cursorAfterCommit), qAbs(attribute.length - cursorAfterCommit)).toUtf8().size();
+ send_cursor_position(focusResource->handle,
+ attribute.start < cursorAfterCommit ? -cursor : cursor,
+ attribute.start < cursorAfterCommit ? -anchor : anchor);
+ }
+ }
+ send_commit_string(focusResource->handle, event->commitString());
+ foreach (const QInputMethodEvent::Attribute &attribute, event->attributes()) {
+ if (attribute.type == QInputMethodEvent::Cursor) {
+ int index = event->preeditString().leftRef(attribute.start).toUtf8().size();
+ send_preedit_cursor(focusResource->handle, index);
+ } else if (attribute.type == QInputMethodEvent::TextFormat) {
+ int start = currentState->surroundingText.leftRef(attribute.start).toUtf8().size();
+ int end = currentState->surroundingText.leftRef(attribute.start + attribute.length).toUtf8().size();
+ // TODO add support for different stylesQWaylandTextInput
+ send_preedit_styling(focusResource->handle, start, end - start, preedit_style_default);
+ }
+ }
+ send_preedit_string(focusResource->handle, event->preeditString(), event->preeditString());
+}
+
+void QWaylandTextInputPrivate::sendKeyEvent(QKeyEvent *event)
+{
+ if (!focusResource || !focusResource->handle)
+ return;
+
+ // TODO add support for modifiers
+
+ foreach (xkb_keysym_t keysym, QWaylandXkb::toKeysym(event)) {
+ send_keysym(focusResource->handle, event->timestamp(), keysym,
+ event->type() == QEvent::KeyPress ? WL_KEYBOARD_KEY_STATE_PRESSED : WL_KEYBOARD_KEY_STATE_RELEASED,
+ 0);
+ }
+}
+
+void QWaylandTextInputPrivate::sendInputPanelState()
+{
+ if (!focusResource || !focusResource->handle)
+ return;
+
+ QInputMethod *inputMethod = qApp->inputMethod();
+ const QRectF& keyboardRect = inputMethod->keyboardRectangle();
+ const QRectF& sceneInputRect = inputMethod->inputItemTransform().mapRect(inputMethod->inputItemRectangle());
+ const QRectF& localRect = sceneInputRect.intersected(keyboardRect).translated(-sceneInputRect.topLeft());
+
+ send_input_panel_state(focusResource->handle,
+ inputMethod->isVisible() ? input_panel_visibility_visible : input_panel_visibility_hidden,
+ localRect.x(), localRect.y(), localRect.width(), localRect.height());
+}
+
+void QWaylandTextInputPrivate::sendTextDirection()
+{
+ if (!focusResource || !focusResource->handle)
+ return;
+
+ const Qt::LayoutDirection direction = qApp->inputMethod()->inputDirection();
+ send_text_direction(focusResource->handle,
+ (direction == Qt::LeftToRight) ? text_direction_ltr :
+ (direction == Qt::RightToLeft) ? text_direction_rtl : text_direction_auto);
+}
+
+void QWaylandTextInputPrivate::sendLocale()
+{
+ if (!focusResource || !focusResource->handle)
+ return;
+
+ const QLocale locale = qApp->inputMethod()->locale();
+ send_language(focusResource->handle, locale.bcp47Name());
+}
+
+QVariant QWaylandTextInputPrivate::inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const
+{
+ switch (property) {
+ case Qt::ImHints:
+ return QVariant(static_cast<int>(currentState->hints));
+ case Qt::ImCursorRectangle:
+ return currentState->cursorRectangle;
+ case Qt::ImFont:
+ // Not supported
+ return QVariant();
+ case Qt::ImCursorPosition:
+ return currentState->cursorPosition;
+ case Qt::ImSurroundingText:
+ return currentState->surroundingText;
+ case Qt::ImCurrentSelection:
+ return currentState->surroundingText.mid(qMin(currentState->cursorPosition, currentState->anchorPosition),
+ qAbs(currentState->anchorPosition - currentState->cursorPosition));
+ case Qt::ImMaximumTextLength:
+ // Not supported
+ return QVariant();
+ case Qt::ImAnchorPosition:
+ return currentState->anchorPosition;
+ case Qt::ImAbsolutePosition:
+ // We assume the surrounding text is our whole document for now
+ return currentState->cursorPosition;
+ case Qt::ImTextAfterCursor:
+ if (argument.isValid())
+ return currentState->surroundingText.mid(currentState->cursorPosition, argument.toInt());
+ return currentState->surroundingText.mid(currentState->cursorPosition);
+ case Qt::ImTextBeforeCursor:
+ if (argument.isValid())
+ return currentState->surroundingText.left(currentState->cursorPosition).right(argument.toInt());
+ return currentState->surroundingText.left(currentState->cursorPosition);
+ case Qt::ImPreferredLanguage:
+ return currentState->preferredLanguage;
+
+ default:
+ return QVariant();
+ }
+}
+
+void QWaylandTextInputPrivate::setFocus(QWaylandSurface *surface)
+{
+ Q_Q(QWaylandTextInput);
+
+ if (focusResource && focus != surface) {
+ uint32_t serial = compositor->nextSerial();
+ send_leave(focusResource->handle, serial, focus->resource());
+ focusDestroyListener.reset();
+ }
+
+ Resource *resource = surface ? resourceMap().value(surface->waylandClient()) : 0;
+
+ if (resource && (focus != surface || focusResource != resource)) {
+ uint32_t serial = compositor->nextSerial();
+ currentState.reset(new QWaylandTextInputClientState);
+ pendingState.reset(new QWaylandTextInputClientState);
+ send_enter(resource->handle, serial, surface->resource());
+ focusResource = resource;
+ sendInputPanelState();
+ sendLocale();
+ sendTextDirection();
+ focusDestroyListener.listenForDestruction(surface->resource());
+ if (inputPanelVisible && q->isSurfaceEnabled(surface))
+ qApp->inputMethod()->show();
+ }
+
+ focusResource = resource;
+ focus = surface;
+}
+
+void QWaylandTextInputPrivate::zwp_text_input_v2_bind_resource(Resource *resource)
+{
+ send_modifiers_map(resource->handle, QByteArray(""));
+}
+
+void QWaylandTextInputPrivate::zwp_text_input_v2_destroy_resource(Resource *resource)
+{
+ if (focusResource == resource)
+ focusResource = 0;
+}
+
+void QWaylandTextInputPrivate::zwp_text_input_v2_destroy(Resource *resource)
+{
+ wl_resource_destroy(resource->handle);
+}
+
+void QWaylandTextInputPrivate::zwp_text_input_v2_enable(Resource *resource, wl_resource *surface)
+{
+ Q_Q(QWaylandTextInput);
+
+ QWaylandSurface *s = QWaylandSurface::fromResource(surface);
+ enabledSurfaces.insert(resource, s);
+ emit q->surfaceEnabled(s);
+}
+
+void QWaylandTextInputPrivate::zwp_text_input_v2_disable(QtWaylandServer::zwp_text_input_v2::Resource *resource, wl_resource *)
+{
+ Q_Q(QWaylandTextInput);
+
+ QWaylandSurface *s = enabledSurfaces.take(resource);
+ emit q->surfaceDisabled(s);
+}
+
+void QWaylandTextInputPrivate::zwp_text_input_v2_show_input_panel(Resource *)
+{
+ inputPanelVisible = true;
+
+ qApp->inputMethod()->show();
+}
+
+void QWaylandTextInputPrivate::zwp_text_input_v2_hide_input_panel(Resource *)
+{
+ inputPanelVisible = false;
+
+ qApp->inputMethod()->hide();
+}
+
+void QWaylandTextInputPrivate::zwp_text_input_v2_set_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height)
+{
+ if (resource != focusResource)
+ return;
+
+ pendingState->cursorRectangle = QRect(x, y, width, height);
+
+ pendingState->changedState |= Qt::ImCursorRectangle;
+}
+
+void QWaylandTextInputPrivate::zwp_text_input_v2_update_state(Resource *resource, uint32_t serial, uint32_t flags)
+{
+ Q_Q(QWaylandTextInput);
+
+ qCDebug(qLcCompositorInputMethods) << "update_state" << serial << flags;
+
+ if (resource != focusResource)
+ return;
+
+ if (flags == update_state_reset || flags == update_state_enter) {
+ qCDebug(qLcCompositorInputMethods) << "QInputMethod::reset()";
+ qApp->inputMethod()->reset();
+ }
+
+ this->serial = serial;
+
+ Qt::InputMethodQueries queries;
+ if (flags == update_state_change) {
+ queries = currentState->mergeChanged(*pendingState.data());
+ } else {
+ queries = pendingState->updatedQueries(*currentState.data());
+ currentState.swap(pendingState);
+ }
+
+ pendingState.reset(new QWaylandTextInputClientState);
+
+ if (queries) {
+ qCDebug(qLcCompositorInputMethods) << "QInputMethod::update()" << queries;
+
+ emit q->updateInputMethod(queries);
+ }
+}
+
+void QWaylandTextInputPrivate::zwp_text_input_v2_set_content_type(Resource *resource, uint32_t hint, uint32_t purpose)
+{
+ if (resource != focusResource)
+ return;
+
+ pendingState->hints = 0;
+
+ if ((hint & content_hint_auto_completion) == 0
+ && (hint & content_hint_auto_correction) == 0)
+ pendingState->hints |= Qt::ImhNoPredictiveText;
+ if ((hint & content_hint_auto_capitalization) == 0)
+ pendingState->hints |= Qt::ImhNoAutoUppercase;
+ if ((hint & content_hint_lowercase) != 0)
+ pendingState->hints |= Qt::ImhPreferLowercase;
+ if ((hint & content_hint_uppercase) != 0)
+ pendingState->hints |= Qt::ImhPreferUppercase;
+ if ((hint & content_hint_hidden_text) != 0)
+ pendingState->hints |= Qt::ImhHiddenText;
+ if ((hint & content_hint_sensitive_data) != 0)
+ pendingState->hints |= Qt::ImhSensitiveData;
+ if ((hint & content_hint_latin) != 0)
+ pendingState->hints |= Qt::ImhLatinOnly;
+ if ((hint & content_hint_multiline) != 0)
+ pendingState->hints |= Qt::ImhMultiLine;
+
+ switch (purpose) {
+ case content_purpose_normal:
+ break;
+ case content_purpose_alpha:
+ pendingState->hints |= Qt::ImhUppercaseOnly | Qt::ImhLowercaseOnly;
+ break;
+ case content_purpose_digits:
+ pendingState->hints |= Qt::ImhDigitsOnly;
+ break;
+ case content_purpose_number:
+ pendingState->hints |= Qt::ImhFormattedNumbersOnly;
+ break;
+ case content_purpose_phone:
+ pendingState->hints |= Qt::ImhDialableCharactersOnly;
+ break;
+ case content_purpose_url:
+ pendingState->hints |= Qt::ImhUrlCharactersOnly;
+ break;
+ case content_purpose_email:
+ pendingState->hints |= Qt::ImhEmailCharactersOnly;
+ break;
+ case content_purpose_name:
+ case content_purpose_password:
+ break;
+ case content_purpose_date:
+ pendingState->hints |= Qt::ImhDate;
+ break;
+ case content_purpose_time:
+ pendingState->hints |= Qt::ImhTime;
+ break;
+ case content_purpose_datetime:
+ pendingState->hints |= Qt::ImhDate | Qt::ImhTime;
+ break;
+ case content_purpose_terminal:
+ default:
+ break;
+ }
+
+ pendingState->changedState |= Qt::ImHints;
+}
+
+void QWaylandTextInputPrivate::zwp_text_input_v2_set_preferred_language(Resource *resource, const QString &language)
+{
+ if (resource != focusResource)
+ return;
+
+ pendingState->preferredLanguage = language;
+
+ pendingState->changedState |= Qt::ImPreferredLanguage;
+}
+
+void QWaylandTextInputPrivate::zwp_text_input_v2_set_surrounding_text(Resource *resource, const QString &text, int32_t cursor, int32_t anchor)
+{
+ if (resource != focusResource)
+ return;
+
+ pendingState->surroundingText = text;
+ pendingState->cursorPosition = QWaylandInputMethodEventBuilder::indexFromWayland(text, cursor);
+ pendingState->anchorPosition = QWaylandInputMethodEventBuilder::indexFromWayland(text, anchor);
+
+ pendingState->changedState |= Qt::ImSurroundingText | Qt::ImCursorPosition | Qt::ImAnchorPosition;
+}
+
+QWaylandTextInput::QWaylandTextInput(QWaylandObject *container, QWaylandCompositor *compositor)
+ : QWaylandExtensionTemplate(container, *new QWaylandTextInputPrivate(compositor))
+{
+ connect(&d_func()->focusDestroyListener, &QWaylandDestroyListener::fired,
+ this, &QWaylandTextInput::focusSurfaceDestroyed);
+
+ connect(qApp->inputMethod(), &QInputMethod::visibleChanged,
+ this, &QWaylandTextInput::sendInputPanelState);
+ connect(qApp->inputMethod(), &QInputMethod::keyboardRectangleChanged,
+ this, &QWaylandTextInput::sendInputPanelState);
+ connect(qApp->inputMethod(), &QInputMethod::inputDirectionChanged,
+ this, &QWaylandTextInput::sendTextDirection);
+ connect(qApp->inputMethod(), &QInputMethod::localeChanged,
+ this, &QWaylandTextInput::sendLocale);
+}
+
+QWaylandTextInput::~QWaylandTextInput()
+{
+}
+
+void QWaylandTextInput::sendInputMethodEvent(QInputMethodEvent *event)
+{
+ Q_D(QWaylandTextInput);
+
+ d->sendInputMethodEvent(event);
+}
+
+void QWaylandTextInput::sendKeyEvent(QKeyEvent *event)
+{
+ Q_D(QWaylandTextInput);
+
+ d->sendKeyEvent(event);
+}
+
+void QWaylandTextInput::sendInputPanelState()
+{
+ Q_D(QWaylandTextInput);
+
+ d->sendInputPanelState();
+}
+
+void QWaylandTextInput::sendTextDirection()
+{
+ Q_D(QWaylandTextInput);
+
+ d->sendTextDirection();
+}
+
+void QWaylandTextInput::sendLocale()
+{
+ Q_D(QWaylandTextInput);
+
+ d->sendLocale();
+}
+
+QVariant QWaylandTextInput::inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const
+{
+ const Q_D(QWaylandTextInput);
+
+ return d->inputMethodQuery(property, argument);
+}
+
+QWaylandSurface *QWaylandTextInput::focus() const
+{
+ const Q_D(QWaylandTextInput);
+
+ return d->focus;
+}
+
+void QWaylandTextInput::setFocus(QWaylandSurface *surface)
+{
+ Q_D(QWaylandTextInput);
+
+ d->setFocus(surface);
+}
+
+void QWaylandTextInput::focusSurfaceDestroyed(void *)
+{
+ Q_D(QWaylandTextInput);
+
+ d->focusDestroyListener.reset();
+
+ d->focus = nullptr;
+ d->focusResource = nullptr;
+}
+
+bool QWaylandTextInput::isSurfaceEnabled(QWaylandSurface *surface) const
+{
+ const Q_D(QWaylandTextInput);
+
+ return d->enabledSurfaces.values().contains(surface);
+}
+
+void QWaylandTextInput::add(::wl_client *client, uint32_t id, int version)
+{
+ Q_D(QWaylandTextInput);
+
+ d->add(client, id, version);
+}
+
+const wl_interface *QWaylandTextInput::interface()
+{
+ return QWaylandTextInputPrivate::interface();
+}
+
+QByteArray QWaylandTextInput::interfaceName()
+{
+ return QWaylandTextInputPrivate::interfaceName();
+}
+
+QT_END_NAMESPACE
diff --git a/src/compositor/extensions/qwlinputpanelsurface_p.h b/src/compositor/extensions/qwaylandtextinput.h
index e11923bd0..100384e76 100644
--- a/src/compositor/extensions/qwlinputpanelsurface_p.h
+++ b/src/compositor/extensions/qwaylandtextinput.h
@@ -1,7 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
-** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
+** Copyright (C) 2013-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
@@ -35,61 +34,53 @@
**
****************************************************************************/
-#ifndef QTWAYLAND_QWLINPUTPANELSURFACE_P_H
-#define QTWAYLAND_QWLINPUTPANELSURFACE_P_H
+#ifndef QWAYLANDTEXTINPUT_H
+#define QWAYLANDTEXTINPUT_H
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtWaylandCompositor/private/qwayland-server-input-method.h>
-
-#include <QWaylandSurface>
+#include <QtWaylandCompositor/QWaylandExtension>
QT_BEGIN_NAMESPACE
-class QWaylandOutput;
+class QWaylandTextInputPrivate;
-namespace QtWayland {
+class QInputMethodEvent;
+class QKeyEvent;
+class QWaylandSurface;
-class InputPanelSurface : public QtWaylandServer::wl_input_panel_surface
+class QWaylandTextInput : public QWaylandExtensionTemplate<QWaylandTextInput>
{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWaylandTextInput)
public:
- enum Type {
- Invalid,
- Toplevel,
- OverlayPanel
- };
+ explicit QWaylandTextInput(QWaylandObject *container, QWaylandCompositor *compositor);
+ ~QWaylandTextInput();
- InputPanelSurface(struct ::wl_client *client, int id, QWaylandSurface *surface);
+ void sendInputMethodEvent(QInputMethodEvent *event);
+ void sendKeyEvent(QKeyEvent *event);
- Type type() const;
+ QVariant inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const;
- QWaylandOutput *output() const;
- wl_input_panel_surface::position position() const;
+ QWaylandSurface *focus() const;
+ void setFocus(QWaylandSurface *surface);
-protected:
- void input_panel_surface_set_overlay_panel(Resource *resource) Q_DECL_OVERRIDE;
- void input_panel_surface_set_toplevel(Resource *resource, wl_resource *output_resource, uint32_t position) Q_DECL_OVERRIDE;
+ bool isSurfaceEnabled(QWaylandSurface *surface) const;
-private:
- QWaylandSurface *m_surface;
+ void add(::wl_client *client, uint32_t id, int version);
+ static const struct wl_interface *interface();
+ static QByteArray interfaceName();
- Type m_type;
+Q_SIGNALS:
+ void updateInputMethod(Qt::InputMethodQueries queries);
+ void surfaceEnabled(QWaylandSurface *surface);
+ void surfaceDisabled(QWaylandSurface *surface);
- QWaylandOutput *m_output;
- wl_input_panel_surface::position m_position;
+private:
+ void focusSurfaceDestroyed(void *);
+ void sendInputPanelState();
+ void sendTextDirection();
+ void sendLocale();
};
-} // namespace QtWayland
-
QT_END_NAMESPACE
-#endif // QTWAYLAND_QWLINPUTPANELSURFACE_P_H
+#endif // QWAYLANDTEXTINPUT_H
diff --git a/src/compositor/extensions/qwaylandtextinput_p.h b/src/compositor/extensions/qwaylandtextinput_p.h
new file mode 100644
index 000000000..79706a7e2
--- /dev/null
+++ b/src/compositor/extensions/qwaylandtextinput_p.h
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDTEXTINPUT_P_H
+#define QWAYLANDTEXTINPUT_P_H
+
+#include <QtWaylandCompositor/private/qwaylandextension_p.h>
+#include <QtWaylandCompositor/private/qwayland-server-text-input-unstable-v2.h>
+#include <QtWaylandCompositor/QWaylandDestroyListener>
+
+#include <QtCore/QObject>
+#include <QtCore/QMap>
+#include <QtCore/QRect>
+#include <QtCore/QVector>
+#include <QtGui/QInputMethod>
+#include <QtWaylandCompositor/QWaylandSurface>
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QT_BEGIN_NAMESPACE
+
+class QInputMethodEvent;
+class QKeyEvent;
+class QWaylandCompositor;
+class QWaylandView;
+
+class QWaylandTextInputClientState {
+public:
+ QWaylandTextInputClientState();
+
+ Qt::InputMethodQueries updatedQueries(const QWaylandTextInputClientState &other) const;
+ Qt::InputMethodQueries mergeChanged(const QWaylandTextInputClientState &other);
+
+ Qt::InputMethodHints hints;
+ QRect cursorRectangle;
+ QString surroundingText;
+ int cursorPosition;
+ int anchorPosition;
+ QString preferredLanguage;
+
+ Qt::InputMethodQueries changedState;
+};
+
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandTextInputPrivate : public QWaylandExtensionTemplatePrivate, public QtWaylandServer::zwp_text_input_v2
+{
+ Q_DECLARE_PUBLIC(QWaylandTextInput)
+public:
+ explicit QWaylandTextInputPrivate(QWaylandCompositor *compositor);
+
+ void sendInputMethodEvent(QInputMethodEvent *event);
+ void sendKeyEvent(QKeyEvent *event);
+ void sendInputPanelState();
+ void sendTextDirection();
+ void sendLocale();
+
+ QVariant inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const;
+
+ void setFocus(QWaylandSurface *surface);
+
+ QWaylandCompositor *compositor;
+
+ QWaylandSurface *focus;
+ Resource *focusResource;
+ QWaylandDestroyListener focusDestroyListener;
+
+ bool inputPanelVisible;
+
+ QScopedPointer<QWaylandTextInputClientState> currentState;
+ QScopedPointer<QWaylandTextInputClientState> pendingState;
+
+ uint32_t serial;
+
+ QHash<Resource *, QWaylandSurface*> enabledSurfaces;
+
+protected:
+ void zwp_text_input_v2_bind_resource(Resource *resource) Q_DECL_OVERRIDE;
+ void zwp_text_input_v2_destroy_resource(Resource *resource) Q_DECL_OVERRIDE;
+
+ void zwp_text_input_v2_destroy(Resource *resource) Q_DECL_OVERRIDE;
+ void zwp_text_input_v2_enable(Resource *resource, wl_resource *surface) Q_DECL_OVERRIDE;
+ void zwp_text_input_v2_disable(Resource *resource, wl_resource *surface) Q_DECL_OVERRIDE;
+ void zwp_text_input_v2_show_input_panel(Resource *resource) Q_DECL_OVERRIDE;
+ void zwp_text_input_v2_hide_input_panel(Resource *resource) Q_DECL_OVERRIDE;
+ void zwp_text_input_v2_set_surrounding_text(Resource *resource, const QString &text, int32_t cursor, int32_t anchor) Q_DECL_OVERRIDE;
+ void zwp_text_input_v2_set_content_type(Resource *resource, uint32_t hint, uint32_t purpose) Q_DECL_OVERRIDE;
+ void zwp_text_input_v2_set_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) Q_DECL_OVERRIDE;
+ void zwp_text_input_v2_set_preferred_language(Resource *resource, const QString &language) Q_DECL_OVERRIDE;
+ void zwp_text_input_v2_update_state(Resource *resource, uint32_t serial, uint32_t flags) Q_DECL_OVERRIDE;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDTEXTINPUT_P_H
diff --git a/src/compositor/extensions/qwaylandtextinputmanager.cpp b/src/compositor/extensions/qwaylandtextinputmanager.cpp
new file mode 100644
index 000000000..62e8ac88c
--- /dev/null
+++ b/src/compositor/extensions/qwaylandtextinputmanager.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2013-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandtextinputmanager.h"
+#include "qwaylandtextinputmanager_p.h"
+
+#include <QtWaylandCompositor/QWaylandCompositor>
+#include <QtWaylandCompositor/QWaylandInputDevice>
+
+#include "qwaylandtextinput.h"
+
+QT_BEGIN_NAMESPACE
+
+QWaylandTextInputManagerPrivate::QWaylandTextInputManagerPrivate()
+ : QWaylandExtensionTemplatePrivate()
+ , QtWaylandServer::zwp_text_input_manager_v2()
+{
+}
+
+void QWaylandTextInputManagerPrivate::zwp_text_input_manager_v2_get_text_input(Resource *resource, uint32_t id, struct ::wl_resource *seat)
+{
+ Q_Q(QWaylandTextInputManager);
+ QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(q->extensionContainer());
+ QWaylandInputDevice *inputDevice = QWaylandInputDevice::fromSeatResource(seat);
+ QWaylandTextInput *textInput = QWaylandTextInput::findIn(inputDevice);
+ if (!textInput) {
+ textInput = new QWaylandTextInput(inputDevice, compositor);
+ }
+ textInput->add(resource->client(), id, wl_resource_get_version(resource->handle));
+}
+
+QWaylandTextInputManager::QWaylandTextInputManager()
+ : QWaylandExtensionTemplate<QWaylandTextInputManager>(*new QWaylandTextInputManagerPrivate)
+{
+}
+
+QWaylandTextInputManager::QWaylandTextInputManager(QWaylandCompositor *compositor)
+ : QWaylandExtensionTemplate<QWaylandTextInputManager>(compositor, *new QWaylandTextInputManagerPrivate)
+{
+}
+
+void QWaylandTextInputManager::initialize()
+{
+ Q_D(QWaylandTextInputManager);
+
+ QWaylandExtensionTemplate::initialize();
+ QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer());
+ if (!compositor) {
+ qWarning() << "Failed to find QWaylandCompositor when initializing QWaylandTextInputManager";
+ return;
+ }
+ d->init(compositor->display(), 1);
+}
+
+const wl_interface *QWaylandTextInputManager::interface()
+{
+ return QWaylandTextInputManagerPrivate::interface();
+}
+
+QByteArray QWaylandTextInputManager::interfaceName()
+{
+ return QWaylandTextInputManagerPrivate::interfaceName();
+}
+
+QT_END_NAMESPACE
diff --git a/src/compositor/extensions/qwltextinputmanager.cpp b/src/compositor/extensions/qwaylandtextinputmanager.h
index 9c7dd72f4..6c250d58c 100644
--- a/src/compositor/extensions/qwltextinputmanager.cpp
+++ b/src/compositor/extensions/qwaylandtextinputmanager.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
+** Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
@@ -34,31 +34,31 @@
**
****************************************************************************/
-#include "qwltextinputmanager_p.h"
+#ifndef QWAYLANDTEXTINPUTMANAGER_H
+#define QWAYLANDTEXTINPUTMANAGER_H
-#include <QtWaylandCompositor/QWaylandCompositor>
-#include "qwltextinput_p.h"
+#include <QtWaylandCompositor/QWaylandExtension>
+
+#include <QtCore/QSize>
QT_BEGIN_NAMESPACE
-namespace QtWayland {
+class QWaylandTextInputManagerPrivate;
-TextInputManager::TextInputManager(QWaylandCompositor *compositor)
- : QWaylandExtensionTemplate(compositor)
- , QtWaylandServer::wl_text_input_manager(compositor->display(), 1)
- , m_compositor(compositor)
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandTextInputManager : public QWaylandExtensionTemplate<QWaylandTextInputManager>
{
-}
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWaylandTextInputManager)
+public:
+ QWaylandTextInputManager();
+ QWaylandTextInputManager(QWaylandCompositor *compositor);
-TextInputManager::~TextInputManager()
-{
-}
+ void initialize() Q_DECL_OVERRIDE;
-void TextInputManager::text_input_manager_create_text_input(Resource *resource, uint32_t id)
-{
- new TextInput(this, m_compositor, resource->client(), id);
-}
-
-} // namespace QtWayland
+ static const struct wl_interface *interface();
+ static QByteArray interfaceName();
+};
QT_END_NAMESPACE
+
+#endif // QWAYLANDTEXTINPUTMANAGER_H
diff --git a/src/compositor/extensions/qwltextinputmanager_p.h b/src/compositor/extensions/qwaylandtextinputmanager_p.h
index 0125bdcae..8052301c9 100644
--- a/src/compositor/extensions/qwltextinputmanager_p.h
+++ b/src/compositor/extensions/qwaylandtextinputmanager_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
+** Copyright (C) 2013-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
@@ -34,11 +34,12 @@
**
****************************************************************************/
-#ifndef QTWAYLAND_QWLTEXTINPUTMANAGER_P_H
-#define QTWAYLAND_QWLTEXTINPUTMANAGER_P_H
+#ifndef QWAYLANDTEXTINPUTMANAGER_P_H
+#define QWAYLANDTEXTINPUTMANAGER_P_H
-#include <QtWaylandCompositor/QWaylandExtension>
-#include <QtWaylandCompositor/private/qwayland-server-text.h>
+#include <QtWaylandCompositor/private/qwaylandextension_p.h>
+
+#include <QtWaylandCompositor/private/qwayland-server-text-input-unstable-v2.h>
//
// W A R N I N G
@@ -53,26 +54,16 @@
QT_BEGIN_NAMESPACE
-class QWaylandCompositor;
-
-namespace QtWayland {
-
-class TextInputManager : public QWaylandExtensionTemplate<TextInputManager>, public QtWaylandServer::wl_text_input_manager
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandTextInputManagerPrivate : public QWaylandExtensionTemplatePrivate, public QtWaylandServer::zwp_text_input_manager_v2
{
- Q_OBJECT
+ Q_DECLARE_PUBLIC(QWaylandTextInputManager)
public:
- TextInputManager(QWaylandCompositor *compositor);
- ~TextInputManager();
+ QWaylandTextInputManagerPrivate();
protected:
- void text_input_manager_create_text_input(Resource *resource, uint32_t id) Q_DECL_OVERRIDE;
-
-private:
- QWaylandCompositor *m_compositor;
+ void zwp_text_input_manager_v2_get_text_input(Resource *resource, uint32_t id, struct ::wl_resource *seat) Q_DECL_OVERRIDE;
};
-} // namespace QtWayland
-
QT_END_NAMESPACE
-#endif // QTWAYLAND_QWLTEXTINPUTMANAGER_P_H
+#endif // QWAYLANDTEXTINPUTMANAGER_P_H
diff --git a/src/compositor/extensions/qwlinputmethod.cpp b/src/compositor/extensions/qwlinputmethod.cpp
deleted file mode 100644
index 6cf23bcb1..000000000
--- a/src/compositor/extensions/qwlinputmethod.cpp
+++ /dev/null
@@ -1,152 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwlinputmethod_p.h"
-
-#include <QtWaylandCompositor/QWaylandCompositor>
-#include <QtWaylandCompositor/QWaylandKeyboard>
-#include <QtWaylandCompositor/QWaylandInputDevice>
-#include "qwlinputmethodcontext_p.h"
-#include "qwlinputpanel_p.h"
-#include "qwltextinput_p.h"
-
-QT_BEGIN_NAMESPACE
-
-namespace QtWayland {
-
-InputMethod::InputMethod(QWaylandInputDevice *seat)
- : QWaylandExtensionTemplate<InputMethod>(seat)
- , QtWaylandServer::wl_input_method(seat->compositor()->display(), 1)
- , m_seat(seat)
- , m_resource(0)
- , m_textInput()
- , m_context()
-{
- connect(seat->keyboard(), &QWaylandKeyboard::focusChanged, this, &InputMethod::focusChanged);
-}
-
-InputMethod::~InputMethod()
-{
-}
-
-void InputMethod::activate(TextInput *textInput)
-{
- if (!m_resource) {
- qDebug("Cannot activate (no input method running).");
- return;
- }
-
- if (m_textInput) {
- Q_ASSERT(m_textInput != textInput);
- m_textInput->deactivate(this);
- }
- m_textInput = textInput;
- m_context = new InputMethodContext(m_resource->client(), textInput);
-
- send_activate(m_resource->handle, m_context->resource()->handle);
-
- QWaylandInputPanelPrivate *panel = QWaylandInputPanelPrivate::findIn(compositor());
- if (panel) {
- panel->setFocus(textInput->focus());
- panel->setCursorRectangle(textInput->cursorRectangle());
- panel->setInputPanelVisible(textInput->inputPanelVisible());
- }
-}
-
-void InputMethod::deactivate()
-{
- if (!m_resource) {
- qDebug("Cannot deactivate (no input method running).");
- return;
- }
-
- send_deactivate(m_resource->handle, m_context->resource()->handle);
- m_textInput = 0;
- m_context = 0;
-
- QWaylandInputPanelPrivate *panel = QWaylandInputPanelPrivate::findIn(compositor());
- if (panel) {
- panel->setFocus(0);
- panel->setCursorRectangle(QRect());
- panel->setInputPanelVisible(false);
- }
-}
-
-void InputMethod::focusChanged(QWaylandSurface *surface)
-{
- if (!m_textInput)
- return;
-
- if (!surface || m_textInput->focus() != surface) {
- m_textInput->deactivate(this);
- }
-}
-
-bool InputMethod::isBound() const
-{
- return m_resource != 0;
-}
-
-InputMethodContext *InputMethod::context() const
-{
- return m_context;
-}
-
-TextInput *InputMethod::textInput() const
-{
- return m_textInput;
-}
-
-void InputMethod::input_method_bind_resource(Resource *resource)
-{
- if (m_resource) {
- wl_resource_post_error(resource->handle, WL_DISPLAY_ERROR_INVALID_OBJECT, "interface object already bound");
- wl_resource_destroy(resource->handle);
- return;
- }
-
- m_resource = resource;
-}
-
-void InputMethod::input_method_destroy_resource(Resource *resource)
-{
- Q_ASSERT(resource == m_resource);
- m_resource = 0;
-}
-
-} // namespace QtWayland
-
-QT_END_NAMESPACE
diff --git a/src/compositor/extensions/qwlinputmethod_p.h b/src/compositor/extensions/qwlinputmethod_p.h
deleted file mode 100644
index 69348df6c..000000000
--- a/src/compositor/extensions/qwlinputmethod_p.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTWAYLAND_QWLINPUTMETHOD_H
-#define QTWAYLAND_QWLINPUTMETHOD_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtWaylandCompositor/private/qwayland-server-input-method.h>
-#include <QtWaylandCompositor/QWaylandExtension>
-#include <QtWaylandCompositor/QWaylandInputDevice>
-
-#include <QObject>
-#include <QScopedPointer>
-
-#include <QtWaylandCompositor/QWaylandSurface>
-
-QT_BEGIN_NAMESPACE
-
-class QWaylandInputDevice;
-class QWaylandCompositor;
-
-namespace QtWayland {
-
-class InputMethodContext;
-class TextInput;
-
-class InputMethod : public QWaylandExtensionTemplate<InputMethod> , public QtWaylandServer::wl_input_method
-{
- Q_OBJECT
-public:
- explicit InputMethod(QWaylandInputDevice *seat);
- ~InputMethod();
-
- QWaylandCompositor *compositor() const { return m_seat->compositor(); }
-
- void activate(TextInput *textInput);
- void deactivate();
-
- bool isBound() const;
-
- InputMethodContext *context() const;
- TextInput *textInput() const;
-
-protected:
- void input_method_bind_resource(Resource *resource);
- void input_method_destroy_resource(Resource *resource);
-
-private Q_SLOTS:
- void focusChanged(QWaylandSurface *surface);
-
-private:
- QWaylandInputDevice *m_seat;
- Resource *m_resource;
- TextInput *m_textInput;
- InputMethodContext *m_context;
-};
-
-} // namespace QtWayland
-
-QT_END_NAMESPACE
-
-#endif // QTWAYLAND_QWLINPUTMETHOD_H
diff --git a/src/compositor/extensions/qwlinputmethodcontext.cpp b/src/compositor/extensions/qwlinputmethodcontext.cpp
deleted file mode 100644
index 6421d5e76..000000000
--- a/src/compositor/extensions/qwlinputmethodcontext.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwlinputmethodcontext_p.h"
-
-#include "qwltextinput_p.h"
-
-QT_BEGIN_NAMESPACE
-
-namespace QtWayland {
-
-InputMethodContext::InputMethodContext(wl_client *client, TextInput *textInput)
- : QtWaylandServer::wl_input_method_context(client, 0, 1)
- , m_textInput(textInput)
-{
-}
-
-InputMethodContext::~InputMethodContext()
-{
-}
-
-void InputMethodContext::input_method_context_destroy_resource(Resource *)
-{
- delete this;
-}
-
-void InputMethodContext::input_method_context_destroy(Resource *resource)
-{
- wl_resource_destroy(resource->handle);
-}
-
-void InputMethodContext::input_method_context_commit_string(Resource *, uint32_t serial, const QString &text)
-{
- m_textInput->send_commit_string(serial, text);
-}
-
-void InputMethodContext::input_method_context_cursor_position(Resource *, int32_t index, int32_t anchor)
-{
- m_textInput->send_cursor_position(index, anchor);
-}
-
-void InputMethodContext::input_method_context_delete_surrounding_text(Resource *, int32_t index, uint32_t length)
-{
- m_textInput->send_delete_surrounding_text(index, length);
-}
-
-void InputMethodContext::input_method_context_language(Resource *, uint32_t serial, const QString &language)
-{
- m_textInput->send_language(serial, language);
-}
-
-void InputMethodContext::input_method_context_keysym(Resource *, uint32_t serial, uint32_t time, uint32_t sym, uint32_t state, uint32_t modifiers)
-{
- m_textInput->send_keysym(serial, time, sym, state, modifiers);
-}
-
-void InputMethodContext::input_method_context_modifiers_map(Resource *, wl_array *map)
-{
- QByteArray modifiersArray(static_cast<char *>(map->data), map->size);
- m_textInput->send_modifiers_map(modifiersArray);
-}
-
-void InputMethodContext::input_method_context_preedit_cursor(Resource *, int32_t index)
-{
- m_textInput->send_preedit_cursor(index);
-}
-
-void InputMethodContext::input_method_context_preedit_string(Resource *, uint32_t serial, const QString &text, const QString &commit)
-{
- m_textInput->send_preedit_string(serial, text, commit);
-}
-
-void InputMethodContext::input_method_context_preedit_styling(Resource *, uint32_t index, uint32_t length, uint32_t style)
-{
- m_textInput->send_preedit_styling(index, length, style);
-}
-
-void InputMethodContext::input_method_context_grab_keyboard(Resource *, uint32_t keyboard)
-{
- Q_UNUSED(keyboard);
-}
-
-void InputMethodContext::input_method_context_key(Resource *, uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
-{
- Q_UNUSED(serial);
- Q_UNUSED(time);
- Q_UNUSED(key);
- Q_UNUSED(state);
-}
-
-void InputMethodContext::input_method_context_modifiers(Resource *, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group)
-{
- Q_UNUSED(serial);
- Q_UNUSED(mods_depressed);
- Q_UNUSED(mods_latched);
- Q_UNUSED(mods_locked);
- Q_UNUSED(group);
-}
-
-} // namespace QtWayland
-
-QT_END_NAMESPACE
diff --git a/src/compositor/extensions/qwlinputmethodcontext_p.h b/src/compositor/extensions/qwlinputmethodcontext_p.h
deleted file mode 100644
index febadc957..000000000
--- a/src/compositor/extensions/qwlinputmethodcontext_p.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTWAYLAND_QWLINPUTMETHODCONTEXT_P_H
-#define QTWAYLAND_QWLINPUTMETHODCONTEXT_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtWaylandCompositor/private/qwayland-server-input-method.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace QtWayland {
-
-class TextInput;
-
-class InputMethodContext : public QtWaylandServer::wl_input_method_context
-{
-public:
- explicit InputMethodContext(struct ::wl_client *client, TextInput *textInput);
- ~InputMethodContext();
-
-protected:
- void input_method_context_destroy_resource(Resource *resource) Q_DECL_OVERRIDE;
- void input_method_context_destroy(Resource *resource) Q_DECL_OVERRIDE;
-
- void input_method_context_commit_string(Resource *resource, uint32_t serial, const QString &text) Q_DECL_OVERRIDE;
- void input_method_context_cursor_position(Resource *resource, int32_t index, int32_t anchor) Q_DECL_OVERRIDE;
- void input_method_context_delete_surrounding_text(Resource *resource, int32_t index, uint32_t length) Q_DECL_OVERRIDE;
- void input_method_context_language(Resource *resource, uint32_t serial, const QString &language) Q_DECL_OVERRIDE;
- void input_method_context_keysym(Resource *resource, uint32_t serial, uint32_t time, uint32_t sym, uint32_t state, uint32_t modifiers) Q_DECL_OVERRIDE;
- void input_method_context_modifiers_map(Resource *resource, wl_array *map) Q_DECL_OVERRIDE;
- void input_method_context_preedit_cursor(Resource *resource, int32_t index) Q_DECL_OVERRIDE;
- void input_method_context_preedit_string(Resource *resource, uint32_t serial, const QString &text, const QString &commit) Q_DECL_OVERRIDE;
- void input_method_context_preedit_styling(Resource *resource, uint32_t index, uint32_t length, uint32_t style) Q_DECL_OVERRIDE;
- void input_method_context_grab_keyboard(Resource *resource, uint32_t keyboard) Q_DECL_OVERRIDE;
- void input_method_context_key(Resource *resource, uint32_t serial, uint32_t time, uint32_t key, uint32_t state) Q_DECL_OVERRIDE;
- void input_method_context_modifiers(Resource *resource, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group) Q_DECL_OVERRIDE;
-
-private:
- TextInput *m_textInput;
-};
-
-} // namespace QtWayland
-
-QT_END_NAMESPACE
-
-#endif // QTWAYLAND_QWLINPUTMETHODCONTEXT_P_H
diff --git a/src/compositor/extensions/qwlinputpanel.cpp b/src/compositor/extensions/qwlinputpanel.cpp
deleted file mode 100644
index 8f41f0ca3..000000000
--- a/src/compositor/extensions/qwlinputpanel.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwlinputpanel_p.h"
-
-#include <QtWaylandCompositor/qwaylandinputpanel.h>
-#include <QtWaylandCompositor/QWaylandCompositor>
-
-#include "qwlinputmethod_p.h"
-#include "qwlinputpanelsurface_p.h"
-#include "qwltextinput_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QWaylandInputPanelPrivate::QWaylandInputPanelPrivate(QWaylandCompositor *compositor)
- : QWaylandExtensionTemplatePrivate()
- , QtWaylandServer::wl_input_panel()
- , m_compositor(compositor)
- , m_focus()
- , m_inputPanelVisible(false)
- , m_cursorRectangle()
-{
- init(compositor->display(), 1);
-}
-
-QWaylandInputPanelPrivate::~QWaylandInputPanelPrivate()
-{
-}
-
-QWaylandInputPanel *QWaylandInputPanelPrivate::waylandInputPanel() const
-{
- QWaylandInputPanel *panel = const_cast<QWaylandInputPanel *>(q_func());
- return panel;
-}
-
-QWaylandSurface *QWaylandInputPanelPrivate::focus() const
-{
- return m_focus;
-}
-
-void QWaylandInputPanelPrivate::setFocus(QWaylandSurface *focus)
-{
- Q_Q(QWaylandInputPanel);
- if (m_focus == focus)
- return;
-
- m_focus = focus;
-
- Q_EMIT q->focusChanged();
-}
-
-bool QWaylandInputPanelPrivate::inputPanelVisible() const
-{
- return m_inputPanelVisible;
-}
-
-void QWaylandInputPanelPrivate::setInputPanelVisible(bool inputPanelVisible)
-{
- Q_Q(QWaylandInputPanel);
- if (m_inputPanelVisible == inputPanelVisible)
- return;
-
- m_inputPanelVisible = inputPanelVisible;
-
- q->visibleChanged();
-}
-
-QRect QWaylandInputPanelPrivate::cursorRectangle() const
-{
- return m_cursorRectangle;
-}
-
-void QWaylandInputPanelPrivate::setCursorRectangle(const QRect &cursorRectangle)
-{
- Q_Q(QWaylandInputPanel);
- if (m_cursorRectangle == cursorRectangle)
- return;
-
- m_cursorRectangle = cursorRectangle;
-
- Q_EMIT q->cursorRectangleChanged();
-}
-
-QWaylandInputPanelPrivate *QWaylandInputPanelPrivate::findIn(QWaylandObject *container)
-{
- QWaylandInputPanel *panel = QWaylandInputPanel::findIn(container);
- if (!panel)
- return Q_NULLPTR;
- return panel->d_func();
-}
-
-void QWaylandInputPanelPrivate::input_panel_get_input_panel_surface(Resource *resource, uint32_t id, wl_resource *surface)
-{
- new QtWayland::InputPanelSurface(resource->client(), id, QWaylandSurface::fromResource(surface));
-}
-
-QT_END_NAMESPACE
diff --git a/src/compositor/extensions/qwlinputpanel_p.h b/src/compositor/extensions/qwlinputpanel_p.h
deleted file mode 100644
index 97720f050..000000000
--- a/src/compositor/extensions/qwlinputpanel_p.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTWAYLAND_QWLINPUTPANEL_P_H
-#define QTWAYLAND_QWLINPUTPANEL_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtWaylandCompositor/qwaylandexport.h>
-#include <QtWaylandCompositor/qwaylandinputpanel.h>
-
-#include <QtWaylandCompositor/private/qwaylandextension_p.h>
-#include <QtWaylandCompositor/private/qwayland-server-input-method.h>
-
-#include <QRect>
-#include <QScopedPointer>
-
-QT_BEGIN_NAMESPACE
-
-namespace QtWayland {
-class TextInput;
-}
-
-
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandInputPanelPrivate : public QWaylandExtensionTemplatePrivate, public QtWaylandServer::wl_input_panel
-{
- Q_DECLARE_PUBLIC(QWaylandInputPanel)
-public:
- QWaylandInputPanelPrivate(QWaylandCompositor *compositor);
- ~QWaylandInputPanelPrivate();
-
- QWaylandInputPanel *waylandInputPanel() const;
-
- QWaylandSurface *focus() const;
- void setFocus(QWaylandSurface *focus);
-
- bool inputPanelVisible() const;
- void setInputPanelVisible(bool inputPanelVisible);
-
- QRect cursorRectangle() const;
- void setCursorRectangle(const QRect &cursorRectangle);
-
- static QWaylandInputPanelPrivate *findIn(QWaylandObject *container);
-protected:
- void input_panel_get_input_panel_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface) Q_DECL_OVERRIDE;
-
-private:
- QWaylandCompositor *m_compositor;
-
- QWaylandSurface *m_focus;
- bool m_inputPanelVisible;
- QRect m_cursorRectangle;
-};
-
-QT_END_NAMESPACE
-
-#endif // QTWAYLAND_QWLINPUTPANEL_P_H
diff --git a/src/compositor/extensions/qwlinputpanelsurface.cpp b/src/compositor/extensions/qwlinputpanelsurface.cpp
deleted file mode 100644
index c54520aad..000000000
--- a/src/compositor/extensions/qwlinputpanelsurface.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
-** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwlinputpanelsurface_p.h"
-
-#include <QtWaylandCompositor/private/qwaylandsurface_p.h>
-#include <QtWaylandCompositor/QWaylandOutput>
-
-QT_BEGIN_NAMESPACE
-
-namespace QtWayland {
-
-InputPanelSurface::InputPanelSurface(wl_client *client, int id, QWaylandSurface *surface)
- : QtWaylandServer::wl_input_panel_surface(client, id, 1)
- , m_surface(surface)
- , m_type(Invalid)
- , m_output(0)
- , m_position()
-{
- QWaylandSurfacePrivate::get(surface)->setInputPanelSurface(this);
-}
-
-InputPanelSurface::Type InputPanelSurface::type() const
-{
- return m_type;
-}
-
-QWaylandOutput *InputPanelSurface::output() const
-{
- return m_output;
-}
-
-QtWaylandServer::wl_input_panel_surface::position InputPanelSurface::position() const
-{
- return m_position;
-}
-
-void InputPanelSurface::input_panel_surface_set_overlay_panel(Resource *)
-{
- m_type = OverlayPanel;
-}
-
-void InputPanelSurface::input_panel_surface_set_toplevel(Resource *, wl_resource *output_resource, uint32_t position)
-{
- m_type = Toplevel;
- m_output = QWaylandOutput::fromResource(output_resource);
- m_position = static_cast<wl_input_panel_surface::position>(position);
-}
-
-QT_END_NAMESPACE
-
-} // namespace QtWayland
diff --git a/src/compositor/extensions/qwltextinput.cpp b/src/compositor/extensions/qwltextinput.cpp
deleted file mode 100644
index 7546ab6a0..000000000
--- a/src/compositor/extensions/qwltextinput.cpp
+++ /dev/null
@@ -1,212 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwltextinput_p.h"
-
-#include "qwlinputmethod_p.h"
-#include "qwlinputmethodcontext_p.h"
-#include "qwlinputpanel_p.h"
-#include <QtWaylandCompositor/QWaylandInputPanel>
-#include <QtWaylandCompositor/QWaylandCompositor>
-#include <QtWaylandCompositor/private/qwaylandinput_p.h>
-
-#include <algorithm>
-
-QT_BEGIN_NAMESPACE
-
-namespace QtWayland {
-
-TextInput::TextInput(QWaylandObject *container, QWaylandCompositor *compositor, struct ::wl_client *client, int id)
- : QWaylandExtensionTemplate(container)
- , wl_text_input(client, id, 1)
- , m_compositor(compositor)
- , m_focus()
- , m_inputPanelVisible()
- , m_cursorRectangle()
-{
-}
-
-QWaylandSurface *TextInput::focus() const
-{
- return m_focus;
-}
-
-bool TextInput::inputPanelVisible() const
-{
- return m_inputPanelVisible;
-}
-
-QRect TextInput::cursorRectangle() const
-{
- return m_cursorRectangle;
-}
-
-void TextInput::deactivate(InputMethod *inputMethod)
-{
- if (m_activeInputMethods.removeOne(inputMethod))
- inputMethod->deactivate();
-
- if (m_activeInputMethods.isEmpty())
- send_leave();
-}
-
-void TextInput::text_input_destroy_resource(Resource *)
-{
- Q_FOREACH (InputMethod *inputMethod, m_activeInputMethods) {
- deactivate(inputMethod);
- }
-
- delete this;
-}
-
-void TextInput::text_input_activate(Resource *, wl_resource *seat, wl_resource *surface)
-{
- QWaylandSurface *oldSurface = m_focus;
- m_focus = QWaylandSurface::fromResource(surface);
-
- if (oldSurface != m_focus)
- send_leave();
-
- bool wasEmpty = m_activeInputMethods.isEmpty();
-
- InputMethod *inputMethod = InputMethod::findIn(QWaylandInputDevice::fromSeatResource(seat));
-
- if (inputMethod && !m_activeInputMethods.contains(inputMethod)) {
- m_activeInputMethods.append(inputMethod);
- inputMethod->activate(this);
- }
-
- if (wasEmpty || oldSurface != m_focus)
- send_enter(surface);
-}
-
-void TextInput::text_input_deactivate(Resource *, wl_resource *seat)
-{
- InputMethod *inputMethod = InputMethod::findIn(QWaylandInputDevice::fromSeatResource(seat));
-
- if (inputMethod)
- deactivate(inputMethod);
-}
-
-static bool isInputMethodBound(InputMethod *inputMethod)
-{
- return inputMethod->isBound();
-}
-
-void TextInput::text_input_show_input_panel(Resource *)
-{
- m_inputPanelVisible = true;
-
- if (std::find_if(m_activeInputMethods.cbegin(), m_activeInputMethods.cend(), isInputMethodBound) != m_activeInputMethods.cend()){
- QWaylandInputPanelPrivate *panel = QWaylandInputPanelPrivate::findIn(m_compositor);
- if (panel)
- panel->setInputPanelVisible(true);
- }
-}
-
-void TextInput::text_input_hide_input_panel(Resource *)
-{
- m_inputPanelVisible = false;
-
- if (std::find_if(m_activeInputMethods.cbegin(), m_activeInputMethods.cend(), isInputMethodBound) != m_activeInputMethods.cend()) {
- QWaylandInputPanelPrivate *panel = QWaylandInputPanelPrivate::findIn(m_compositor);
- if (panel)
- panel->setInputPanelVisible(false);
- }
-}
-
-void TextInput::text_input_set_cursor_rectangle(Resource *, int32_t x, int32_t y, int32_t width, int32_t height)
-{
- m_cursorRectangle = QRect(x, y, width, height);
-
- if (!m_activeInputMethods.isEmpty()) {
- QWaylandInputPanelPrivate *panel = QWaylandInputPanelPrivate::findIn(m_compositor);
- if (panel)
- panel->setCursorRectangle(m_cursorRectangle);
- }
-}
-
-void TextInput::text_input_reset(Resource *)
-{
- Q_FOREACH (InputMethod *inputMethod, m_activeInputMethods) {
- if (inputMethod->context())
- inputMethod->context()->send_reset();
- }
-}
-
-void TextInput::text_input_commit_state(Resource *, uint32_t serial)
-{
- Q_FOREACH (InputMethod *inputMethod, m_activeInputMethods) {
- if (inputMethod->context())
- inputMethod->context()->send_commit_state(serial);
- }
-}
-
-void TextInput::text_input_set_content_type(Resource *, uint32_t hint, uint32_t purpose)
-{
- Q_FOREACH (InputMethod *inputMethod, m_activeInputMethods) {
- if (inputMethod->context())
- inputMethod->context()->send_content_type(hint, purpose);
- }
-}
-
-void TextInput::text_input_set_preferred_language(Resource *, const QString &language)
-{
- Q_FOREACH (InputMethod *inputMethod, m_activeInputMethods) {
- if (inputMethod->context())
- inputMethod->context()->send_preferred_language(language);
- }
-}
-
-void TextInput::text_input_set_surrounding_text(Resource *, const QString &text, uint32_t cursor, uint32_t anchor)
-{
- Q_FOREACH (InputMethod *inputMethod, m_activeInputMethods) {
- if (inputMethod->context())
- inputMethod->context()->send_surrounding_text(text, cursor, anchor);
- }
-}
-
-void TextInput::text_input_invoke_action(Resource *, uint32_t button, uint32_t index)
-{
- Q_FOREACH (InputMethod *inputMethod, m_activeInputMethods) {
- if (inputMethod->context())
- inputMethod->context()->send_invoke_action(button, index);
- }
-}
-
-} // namespace QtWayland
-
-QT_END_NAMESPACE
diff --git a/src/compositor/extensions/qwltextinput_p.h b/src/compositor/extensions/qwltextinput_p.h
deleted file mode 100644
index 02adc5cae..000000000
--- a/src/compositor/extensions/qwltextinput_p.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTWAYLAND_QWLTEXTINPUT_P_H
-#define QTWAYLAND_QWLTEXTINPUT_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtWaylandCompositor/QWaylandExtension>
-#include <QtWaylandCompositor/private/qwayland-server-text.h>
-
-#include <QRect>
-
-QT_BEGIN_NAMESPACE
-
-class QWaylandSurface;
-class QWaylandCompositor;
-
-namespace QtWayland {
-
-class InputMethod;
-
-class TextInput : public QWaylandExtensionTemplate<TextInput>, public QtWaylandServer::wl_text_input
-{
-public:
- explicit TextInput(QWaylandObject *container, QWaylandCompositor *compositor, struct ::wl_client *client, int id);
-
- QWaylandSurface *focus() const;
-
- bool inputPanelVisible() const;
- QRect cursorRectangle() const;
-
- void deactivate(InputMethod *inputMethod);
-
-protected:
- void text_input_destroy_resource(Resource *resource) Q_DECL_OVERRIDE;
-
- void text_input_activate(Resource *resource, wl_resource *seat, wl_resource *surface) Q_DECL_OVERRIDE;
- void text_input_deactivate(Resource *resource, wl_resource *seat) Q_DECL_OVERRIDE;
- void text_input_show_input_panel(Resource *resource) Q_DECL_OVERRIDE;
- void text_input_hide_input_panel(Resource *resource) Q_DECL_OVERRIDE;
- void text_input_reset(Resource *resource) Q_DECL_OVERRIDE;
- void text_input_commit_state(Resource *resource, uint32_t serial) Q_DECL_OVERRIDE;
- void text_input_set_content_type(Resource *resource, uint32_t hint, uint32_t purpose) Q_DECL_OVERRIDE;
- void text_input_set_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) Q_DECL_OVERRIDE;
- void text_input_set_preferred_language(Resource *resource, const QString &language) Q_DECL_OVERRIDE;
- void text_input_set_surrounding_text(Resource *resource, const QString &text, uint32_t cursor, uint32_t anchor) Q_DECL_OVERRIDE;
- void text_input_invoke_action(Resource *resource, uint32_t button, uint32_t index) Q_DECL_OVERRIDE;
-
-private:
- QWaylandCompositor *m_compositor;
- QList<InputMethod*> m_activeInputMethods;
- QWaylandSurface *m_focus;
-
- bool m_inputPanelVisible;
- QRect m_cursorRectangle;
-
-};
-
-} // namespace QtWayland
-
-QT_END_NAMESPACE
-
-#endif // QTWAYLAND_QWLTEXTINPUT_P_H