diff options
Diffstat (limited to 'src/plugins/platforminputcontexts/ibus')
14 files changed, 368 insertions, 341 deletions
diff --git a/src/plugins/platforminputcontexts/ibus/CMakeLists.txt b/src/plugins/platforminputcontexts/ibus/CMakeLists.txt new file mode 100644 index 0000000000..54847e86fd --- /dev/null +++ b/src/plugins/platforminputcontexts/ibus/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +##################################################################### +## QIbusPlatformInputContextPlugin Plugin: +##################################################################### + +qt_internal_add_plugin(QIbusPlatformInputContextPlugin + OUTPUT_NAME ibusplatforminputcontextplugin + PLUGIN_TYPE platforminputcontexts + DEFAULT_IF FALSE + SOURCES + main.cpp + qibusinputcontextproxy.cpp qibusinputcontextproxy.h + qibusplatforminputcontext.cpp qibusplatforminputcontext.h + qibusproxy.cpp qibusproxy.h + qibusproxyportal.cpp qibusproxyportal.h + qibustypes.cpp qibustypes.h + LIBRARIES + Qt::Core + Qt::DBus + Qt::Gui + Qt::GuiPrivate + XKB::XKB +) diff --git a/src/plugins/platforminputcontexts/ibus/ibus.pro b/src/plugins/platforminputcontexts/ibus/ibus.pro deleted file mode 100644 index 9ba2297e38..0000000000 --- a/src/plugins/platforminputcontexts/ibus/ibus.pro +++ /dev/null @@ -1,22 +0,0 @@ -TARGET = ibusplatforminputcontextplugin - -QT += dbus gui-private xkbcommon_support-private -SOURCES += $$PWD/qibusplatforminputcontext.cpp \ - $$PWD/qibusproxy.cpp \ - $$PWD/qibusproxyportal.cpp \ - $$PWD/qibusinputcontextproxy.cpp \ - $$PWD/qibustypes.cpp \ - $$PWD/main.cpp - -HEADERS += $$PWD/qibusplatforminputcontext.h \ - $$PWD/qibusproxy.h \ - $$PWD/qibusproxyportal.h \ - $$PWD/qibusinputcontextproxy.h \ - $$PWD/qibustypes.h - -OTHER_FILES += $$PWD/ibus.json - -PLUGIN_TYPE = platforminputcontexts -PLUGIN_EXTENDS = - -PLUGIN_CLASS_NAME = QIbusPlatformInputContextPlugin -load(qt_plugin) diff --git a/src/plugins/platforminputcontexts/ibus/interfaces/org.freedesktop.IBus.InputContext.xml b/src/plugins/platforminputcontexts/ibus/interfaces/org.freedesktop.IBus.InputContext.xml index 9c67a38c57..30fa7431c3 100644 --- a/src/plugins/platforminputcontexts/ibus/interfaces/org.freedesktop.IBus.InputContext.xml +++ b/src/plugins/platforminputcontexts/ibus/interfaces/org.freedesktop.IBus.InputContext.xml @@ -2,6 +2,12 @@ "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> <node> <interface name="org.freedesktop.IBus.InputContext"> + <property name="ClientCommitPreedit" type="(b)" access="readwrite"> + <annotation name="org.qtproject.QtDBus.QtTypeName" value="QIBusPropTypeClientCommitPreedit"/> + </property> + <property name='ContentType' type='(uu)' access='readwrite'> + <annotation name="org.qtproject.QtDBus.QtTypeName" value="QIBusPropTypeContentType"/> + </property> <method name="ProcessKeyEvent"> <arg name="keyval" direction="in" type="u"/> <arg name="keycode" direction="in" type="u"/> @@ -14,6 +20,12 @@ <arg name="w" direction="in" type="i"/> <arg name="h" direction="in" type="i"/> </method> + <method name='SetCursorLocationRelative'> + <arg name="x" direction="in" type="i"/> + <arg name="y" direction="in" type="i"/> + <arg name="w" direction="in" type="i"/> + <arg name="h" direction="in" type="i"/> + </method> <method name="FocusIn"/> <method name="FocusOut"/> <method name="Reset"/> @@ -56,6 +68,12 @@ <arg name="cursor_pos" type="u"/> <arg name="visible" type="b"/> </signal> + <signal name="UpdatePreeditTextWithMode"> + <arg name="text" type="v"/> + <arg name="cursor_pos" type="u"/> + <arg name="visible" type="b"/> + <arg name="mode" type="u"/> + </signal> <signal name="ShowPreeditText"/> <signal name="HidePreeditText"/> <signal name="UpdateAuxiliaryText"> diff --git a/src/plugins/platforminputcontexts/ibus/main.cpp b/src/plugins/platforminputcontexts/ibus/main.cpp index 0a7da3b14c..d74be4bedf 100644 --- a/src/plugins/platforminputcontexts/ibus/main.cpp +++ b/src/plugins/platforminputcontexts/ibus/main.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include <qpa/qplatforminputcontextplugin_p.h> #include <QtCore/QStringList> @@ -45,6 +9,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + class QIbusPlatformInputContextPlugin : public QPlatformInputContextPlugin { Q_OBJECT @@ -58,13 +24,16 @@ QIBusPlatformInputContext *QIbusPlatformInputContextPlugin::create(const QString { Q_UNUSED(paramList); - if (system.compare(system, QLatin1String("ibus"), Qt::CaseInsensitive) == 0) { + if (system.compare(system, "ibus"_L1, Qt::CaseInsensitive) == 0) { qDBusRegisterMetaType<QIBusAttribute>(); qDBusRegisterMetaType<QIBusAttributeList>(); qDBusRegisterMetaType<QIBusText>(); + qDBusRegisterMetaType<QIBusPropTypeClientCommitPreedit>(); + qDBusRegisterMetaType<QIBusPropTypeContentType>(); return new QIBusPlatformInputContext; } - return 0; + + return nullptr; } QT_END_NAMESPACE diff --git a/src/plugins/platforminputcontexts/ibus/qibusinputcontextproxy.cpp b/src/plugins/platforminputcontexts/ibus/qibusinputcontextproxy.cpp index 793c9dd95c..248abbc32b 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusinputcontextproxy.cpp +++ b/src/plugins/platforminputcontexts/ibus/qibusinputcontextproxy.cpp @@ -2,7 +2,7 @@ * This file was generated by qdbusxml2cpp version 0.8 * Command line was: qdbusxml2cpp -N -p qibusinputcontextproxy -c QIBusInputContextProxy interfaces/org.freedesktop.IBus.InputContext.xml * - * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd. + * qdbusxml2cpp is Copyright (C) 2023 The Qt Company Ltd and other contributors. * * This is an auto-generated file. * This file may have been hand-edited. Look for HAND-EDIT comments diff --git a/src/plugins/platforminputcontexts/ibus/qibusinputcontextproxy.h b/src/plugins/platforminputcontexts/ibus/qibusinputcontextproxy.h index 396a213aaa..82e78aa35b 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusinputcontextproxy.h +++ b/src/plugins/platforminputcontexts/ibus/qibusinputcontextproxy.h @@ -2,14 +2,14 @@ * This file was generated by qdbusxml2cpp version 0.8 * Command line was: qdbusxml2cpp -N -p qibusinputcontextproxy -c QIBusInputContextProxy interfaces/org.freedesktop.IBus.InputContext.xml * - * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd. + * qdbusxml2cpp is Copyright (C) 2023 The Qt Company Ltd and other contributors. * * This is an auto-generated file. * Do not edit! All changes made to it will be lost. */ -#ifndef QIBUSINPUTCONTEXTPROXY_H_1394889529 -#define QIBUSINPUTCONTEXTPROXY_H_1394889529 +#ifndef QIBUSINPUTCONTEXTPROXY_H +#define QIBUSINPUTCONTEXTPROXY_H #include <QtCore/QObject> #include <QtCore/QByteArray> @@ -20,6 +20,9 @@ #include <QtCore/QVariant> #include <QtDBus/QtDBus> +// Added for QIBusPropTypeClientCommitPreedit and QIBusPropTypeContentType +#include "qibustypes.h" + /* * Proxy class for interface org.freedesktop.IBus.InputContext */ @@ -35,95 +38,114 @@ public: ~QIBusInputContextProxy(); + Q_PROPERTY(QIBusPropTypeClientCommitPreedit ClientCommitPreedit READ clientCommitPreedit WRITE setClientCommitPreedit) + inline QIBusPropTypeClientCommitPreedit clientCommitPreedit() const + { return qvariant_cast< QIBusPropTypeClientCommitPreedit >(property("ClientCommitPreedit")); } + inline void setClientCommitPreedit(const QIBusPropTypeClientCommitPreedit &value) + { setProperty("ClientCommitPreedit", QVariant::fromValue(value)); } + + Q_PROPERTY(QIBusPropTypeContentType ContentType READ contentType WRITE setContentType) + inline QIBusPropTypeContentType contentType() const + { return qvariant_cast< QIBusPropTypeContentType >(property("ContentType")); } + inline void setContentType(const QIBusPropTypeContentType &value) + { setProperty("ContentType", QVariant::fromValue(value)); } + public Q_SLOTS: // METHODS inline QDBusPendingReply<> Destroy() { QList<QVariant> argumentList; - return asyncCallWithArgumentList(QLatin1String("Destroy"), argumentList); + return asyncCallWithArgumentList(QStringLiteral("Destroy"), argumentList); } inline QDBusPendingReply<> Disable() { QList<QVariant> argumentList; - return asyncCallWithArgumentList(QLatin1String("Disable"), argumentList); + return asyncCallWithArgumentList(QStringLiteral("Disable"), argumentList); } inline QDBusPendingReply<> Enable() { QList<QVariant> argumentList; - return asyncCallWithArgumentList(QLatin1String("Enable"), argumentList); + return asyncCallWithArgumentList(QStringLiteral("Enable"), argumentList); } inline QDBusPendingReply<> FocusIn() { QList<QVariant> argumentList; - return asyncCallWithArgumentList(QLatin1String("FocusIn"), argumentList); + return asyncCallWithArgumentList(QStringLiteral("FocusIn"), argumentList); } inline QDBusPendingReply<> FocusOut() { QList<QVariant> argumentList; - return asyncCallWithArgumentList(QLatin1String("FocusOut"), argumentList); + return asyncCallWithArgumentList(QStringLiteral("FocusOut"), argumentList); } inline QDBusPendingReply<QDBusVariant> GetEngine() { QList<QVariant> argumentList; - return asyncCallWithArgumentList(QLatin1String("GetEngine"), argumentList); + return asyncCallWithArgumentList(QStringLiteral("GetEngine"), argumentList); } inline QDBusPendingReply<bool> IsEnabled() { QList<QVariant> argumentList; - return asyncCallWithArgumentList(QLatin1String("IsEnabled"), argumentList); + return asyncCallWithArgumentList(QStringLiteral("IsEnabled"), argumentList); } inline QDBusPendingReply<bool> ProcessKeyEvent(uint keyval, uint keycode, uint state) { QList<QVariant> argumentList; argumentList << QVariant::fromValue(keyval) << QVariant::fromValue(keycode) << QVariant::fromValue(state); - return asyncCallWithArgumentList(QLatin1String("ProcessKeyEvent"), argumentList); + return asyncCallWithArgumentList(QStringLiteral("ProcessKeyEvent"), argumentList); } inline QDBusPendingReply<> PropertyActivate(const QString &name, int state) { QList<QVariant> argumentList; argumentList << QVariant::fromValue(name) << QVariant::fromValue(state); - return asyncCallWithArgumentList(QLatin1String("PropertyActivate"), argumentList); + return asyncCallWithArgumentList(QStringLiteral("PropertyActivate"), argumentList); } inline QDBusPendingReply<> Reset() { QList<QVariant> argumentList; - return asyncCallWithArgumentList(QLatin1String("Reset"), argumentList); + return asyncCallWithArgumentList(QStringLiteral("Reset"), argumentList); } inline QDBusPendingReply<> SetCapabilities(uint caps) { QList<QVariant> argumentList; argumentList << QVariant::fromValue(caps); - return asyncCallWithArgumentList(QLatin1String("SetCapabilities"), argumentList); + return asyncCallWithArgumentList(QStringLiteral("SetCapabilities"), argumentList); } inline QDBusPendingReply<> SetCursorLocation(int x, int y, int w, int h) { QList<QVariant> argumentList; argumentList << QVariant::fromValue(x) << QVariant::fromValue(y) << QVariant::fromValue(w) << QVariant::fromValue(h); - return asyncCallWithArgumentList(QLatin1String("SetCursorLocation"), argumentList); + return asyncCallWithArgumentList(QStringLiteral("SetCursorLocation"), argumentList); + } + + inline QDBusPendingReply<> SetCursorLocationRelative(int x, int y, int w, int h) + { + QList<QVariant> argumentList; + argumentList << QVariant::fromValue(x) << QVariant::fromValue(y) << QVariant::fromValue(w) << QVariant::fromValue(h); + return asyncCallWithArgumentList(QStringLiteral("SetCursorLocationRelative"), argumentList); } inline QDBusPendingReply<> SetEngine(const QString &name) { QList<QVariant> argumentList; argumentList << QVariant::fromValue(name); - return asyncCallWithArgumentList(QLatin1String("SetEngine"), argumentList); + return asyncCallWithArgumentList(QStringLiteral("SetEngine"), argumentList); } inline QDBusPendingReply<> SetSurroundingText(const QDBusVariant &text, uint cursor_pos, uint anchor_pos) { QList<QVariant> argumentList; argumentList << QVariant::fromValue(text) << QVariant::fromValue(cursor_pos) << QVariant::fromValue(anchor_pos); - return asyncCallWithArgumentList(QLatin1String("SetSurroundingText"), argumentList); + return asyncCallWithArgumentList(QStringLiteral("SetSurroundingText"), argumentList); } Q_SIGNALS: // SIGNALS @@ -147,6 +169,7 @@ Q_SIGNALS: // SIGNALS void UpdateAuxiliaryText(const QDBusVariant &text, bool visible); void UpdateLookupTable(const QDBusVariant &table, bool visible); void UpdatePreeditText(const QDBusVariant &text, uint cursor_pos, bool visible); + void UpdatePreeditTextWithMode(const QDBusVariant &text, uint cursor_pos, bool visible, uint mode); void UpdateProperty(const QDBusVariant &prop); }; diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp index 47ac54927b..00c7884cda 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp +++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp @@ -1,67 +1,37 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qibusplatforminputcontext.h" -#include <QtDebug> +#include <QDebug> #include <QTextCharFormat> #include <QGuiApplication> +#include <QWindow> +#include <QEvent> +#include <QFile> +#include <QFileInfo> +#include <QStandardPaths> #include <QDBusVariant> -#include <qwindow.h> -#include <qevent.h> +#include <QDBusPendingReply> +#include <QDBusReply> +#include <QDBusServiceWatcher> + +#include "qibusproxy.h" +#include "qibusproxyportal.h" +#include "qibusinputcontextproxy.h" +#include "qibustypes.h" #include <qpa/qplatformcursor.h> #include <qpa/qplatformscreen.h> #include <qpa/qwindowsysteminterface_p.h> -#include <QtGui/private/qguiapplication_p.h> - -#include <QtXkbCommonSupport/private/qxkbcommon_p.h> +#include <private/qguiapplication_p.h> +#include <private/qxkbcommon_p.h> -#include "qibusproxy.h" -#include "qibusproxyportal.h" -#include "qibusinputcontextproxy.h" -#include "qibustypes.h" +#include <memory> #include <sys/types.h> #include <signal.h> -#include <QtDBus> #ifndef IBUS_RELEASE_MASK #define IBUS_RELEASE_MASK (1 << 30) @@ -73,30 +43,41 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + enum { debug = 0 }; class QIBusPlatformInputContextPrivate { + Q_DISABLE_COPY_MOVE(QIBusPlatformInputContextPrivate) public: + // This enum might be synced with IBusPreeditFocusMode + // in ibustypes.h of IBUS project + enum PreeditFocusMode { + PREEDIT_CLEAR = 0, + PREEDIT_COMMIT = 1, + }; + QIBusPlatformInputContextPrivate(); ~QIBusPlatformInputContextPrivate() { - delete context; - delete bus; - delete portalBus; - delete connection; + // dereference QDBusConnection to actually disconnect + serviceWatcher.setConnection(QDBusConnection(QString())); + context = nullptr; + portalBus = nullptr; + bus = nullptr; + QDBusConnection::disconnectFromBus("QIBusProxy"_L1); } static QString getSocketPath(); - QDBusConnection *createConnection(); + void createConnection(); void initBus(); void createBusProxy(); - QDBusConnection *connection; - QIBusProxy *bus; - QIBusProxyPortal *portalBus; // bus and portalBus are alternative. - QIBusInputContextProxy *context; + std::unique_ptr<QIBusProxy> bus; + std::unique_ptr<QIBusProxyPortal> portalBus; // bus and portalBus are alternative. + std::unique_ptr<QIBusInputContextProxy> context; QDBusServiceWatcher serviceWatcher; bool usePortal; // return value of shouldConnectIbusPortal @@ -106,6 +87,7 @@ public: QList<QInputMethodEvent::Attribute> attributes; bool needsSurroundingText; QLocale locale; + PreeditFocusMode preeditFocusMode = PREEDIT_COMMIT; // for backward compatibility }; @@ -177,8 +159,6 @@ void QIBusPlatformInputContext::invokeAction(QInputMethod::Action a, int) void QIBusPlatformInputContext::reset() { - QPlatformInputContext::reset(); - if (!d->busConnected) return; @@ -189,8 +169,6 @@ void QIBusPlatformInputContext::reset() void QIBusPlatformInputContext::commit() { - QPlatformInputContext::commit(); - if (!d->busConnected) return; @@ -201,10 +179,18 @@ void QIBusPlatformInputContext::commit() return; } - if (!d->predit.isEmpty()) { - QInputMethodEvent event; - event.setCommitString(d->predit); - QCoreApplication::sendEvent(input, &event); + if (d->preeditFocusMode == QIBusPlatformInputContextPrivate::PREEDIT_COMMIT) { + if (!d->predit.isEmpty()) { + QInputMethodEvent event; + event.setCommitString(d->predit); + QCoreApplication::sendEvent(input, &event); + } + } else { + if (!d->predit.isEmpty()) { + // Clear the existing preedit + QInputMethodEvent event; + QCoreApplication::sendEvent(input, &event); + } } d->context->Reset(); @@ -239,7 +225,6 @@ void QIBusPlatformInputContext::update(Qt::InputMethodQueries q) d->context->SetSurroundingText(dbusText, cursorPosition, anchorPosition); } - QPlatformInputContext::update(q); } void QIBusPlatformInputContext::cursorRectChanged() @@ -248,16 +233,37 @@ void QIBusPlatformInputContext::cursorRectChanged() return; QRect r = qApp->inputMethod()->cursorRectangle().toRect(); - if(!r.isValid()) + if (!r.isValid()) return; QWindow *inputWindow = qApp->focusWindow(); if (!inputWindow) return; - r.moveTopLeft(inputWindow->mapToGlobal(r.topLeft())); + if (!inputWindow->screen()) + return; + + if (QGuiApplication::platformName().startsWith("wayland"_L1)) { + auto margins = inputWindow->frameMargins(); + r.translate(margins.left(), margins.top()); + qreal scale = inputWindow->devicePixelRatio(); + QRect newRect = QRect(r.x() * scale, r.y() * scale, r.width() * scale, r.height() * scale); + if (debug) + qDebug() << "microFocus" << newRect; + d->context->SetCursorLocationRelative(newRect.x(), newRect.y(), + newRect.width(), newRect.height()); + return; + } + + // x11/xcb + auto screenGeometry = inputWindow->screen()->geometry(); + auto point = inputWindow->mapToGlobal(r.topLeft()); + qreal scale = inputWindow->devicePixelRatio(); + auto native = (point - screenGeometry.topLeft()) * scale + screenGeometry.topLeft(); + QRect newRect(native, r.size() * scale); if (debug) - qDebug() << "microFocus" << r; - d->context->SetCursorLocation(r.x(), r.y(), r.width(), r.height()); + qDebug() << "microFocus" << newRect; + d->context->SetCursorLocation(newRect.x(), newRect.y(), + newRect.width(), newRect.height()); } void QIBusPlatformInputContext::setFocusObject(QObject *object) @@ -268,7 +274,7 @@ void QIBusPlatformInputContext::setFocusObject(QObject *object) // It would seem natural here to call FocusOut() on the input method if we // transition from an IME accepted focus object to one that does not accept it. // Mysteriously however that is not sufficient to fix bug QTBUG-63066. - if (!inputMethodAccepted()) + if (object && !inputMethodAccepted()) return; if (debug) @@ -328,6 +334,15 @@ void QIBusPlatformInputContext::updatePreeditText(const QDBusVariant &text, uint d->predit = t.text; } +void QIBusPlatformInputContext::updatePreeditTextWithMode(const QDBusVariant &text, uint cursorPos, bool visible, uint mode) +{ + updatePreeditText(text, cursorPos, visible); + if (mode > 0) + d->preeditFocusMode = QIBusPlatformInputContextPrivate::PreeditFocusMode::PREEDIT_COMMIT; + else + d->preeditFocusMode = QIBusPlatformInputContextPrivate::PreeditFocusMode::PREEDIT_CLEAR; +} + void QIBusPlatformInputContext::forwardKeyEvent(uint keyval, uint keycode, uint state) { if (!qApp) @@ -504,7 +519,7 @@ void QIBusPlatformInputContext::filterEventFinished(QDBusPendingCallWatcher *cal if (!filtered) { #ifndef QT_NO_CONTEXTMENU if (type == QEvent::KeyPress && qtcode == Qt::Key_Menu - && window != NULL) { + && window != nullptr) { const QPoint globalPos = window->screen()->handle()->cursor()->pos(); const QPoint pos = window->mapFromGlobal(globalPos); QWindowSystemInterfacePrivate::ContextMenuEvent contextMenuEvent(window, false, pos, @@ -534,12 +549,12 @@ void QIBusPlatformInputContext::socketChanged(const QString &str) m_timer.stop(); - if (d->context) - disconnect(d->context); - if (d->bus && d->bus->isValid()) - disconnect(d->bus); - if (d->connection) - d->connection->disconnectFromBus(QLatin1String("QIBusProxy")); + // dereference QDBusConnection to actually disconnect + d->serviceWatcher.setConnection(QDBusConnection(QString())); + d->context = nullptr; + d->bus = nullptr; + d->busConnected = false; + QDBusConnection::disconnectFromBus("QIBusProxy"_L1); m_timer.start(100); } @@ -591,37 +606,34 @@ void QIBusPlatformInputContext::globalEngineChanged(const QString &engine_name) void QIBusPlatformInputContext::connectToContextSignals() { if (d->bus && d->bus->isValid()) { - connect(d->bus, SIGNAL(GlobalEngineChanged(QString)), this, SLOT(globalEngineChanged(QString))); + connect(d->bus.get(), SIGNAL(GlobalEngineChanged(QString)), this, SLOT(globalEngineChanged(QString))); } if (d->context) { - connect(d->context, SIGNAL(CommitText(QDBusVariant)), SLOT(commitText(QDBusVariant))); - connect(d->context, SIGNAL(UpdatePreeditText(QDBusVariant,uint,bool)), this, SLOT(updatePreeditText(QDBusVariant,uint,bool))); - connect(d->context, SIGNAL(ForwardKeyEvent(uint,uint,uint)), this, SLOT(forwardKeyEvent(uint,uint,uint))); - connect(d->context, SIGNAL(DeleteSurroundingText(int,uint)), this, SLOT(deleteSurroundingText(int,uint))); - connect(d->context, SIGNAL(RequireSurroundingText()), this, SLOT(surroundingTextRequired())); - connect(d->context, SIGNAL(HidePreeditText()), this, SLOT(hidePreeditText())); - connect(d->context, SIGNAL(ShowPreeditText()), this, SLOT(showPreeditText())); + connect(d->context.get(), SIGNAL(CommitText(QDBusVariant)), SLOT(commitText(QDBusVariant))); + connect(d->context.get(), SIGNAL(UpdatePreeditText(QDBusVariant,uint,bool)), this, SLOT(updatePreeditText(QDBusVariant,uint,bool))); + connect(d->context.get(), SIGNAL(UpdatePreeditTextWithMode(QDBusVariant,uint,bool,uint)), this, SLOT(updatePreeditTextWithMode(QDBusVariant,uint,bool,uint))); + connect(d->context.get(), SIGNAL(ForwardKeyEvent(uint,uint,uint)), this, SLOT(forwardKeyEvent(uint,uint,uint))); + connect(d->context.get(), SIGNAL(DeleteSurroundingText(int,uint)), this, SLOT(deleteSurroundingText(int,uint))); + connect(d->context.get(), SIGNAL(RequireSurroundingText()), this, SLOT(surroundingTextRequired())); + connect(d->context.get(), SIGNAL(HidePreeditText()), this, SLOT(hidePreeditText())); + connect(d->context.get(), SIGNAL(ShowPreeditText()), this, SLOT(showPreeditText())); } } -static inline bool checkRunningUnderFlatpak() +static inline bool checkNeedPortalSupport() { - return !QStandardPaths::locate(QStandardPaths::RuntimeLocation, QLatin1String("flatpak-info")).isEmpty(); + return QFileInfo::exists("/.flatpak-info"_L1) || qEnvironmentVariableIsSet("SNAP"); } static bool shouldConnectIbusPortal() { // honor the same env as ibus-gtk - return (checkRunningUnderFlatpak() || !qgetenv("IBUS_USE_PORTAL").isNull()); + return (checkNeedPortalSupport() || qEnvironmentVariableIsSet("IBUS_USE_PORTAL")); } QIBusPlatformInputContextPrivate::QIBusPlatformInputContextPrivate() - : connection(0), - bus(0), - portalBus(0), - context(0), - usePortal(shouldConnectIbusPortal()), + : usePortal(shouldConnectIbusPortal()), valid(false), busConnected(false), needsSurroundingText(false) @@ -645,42 +657,43 @@ QIBusPlatformInputContextPrivate::QIBusPlatformInputContextPrivate() void QIBusPlatformInputContextPrivate::initBus() { - connection = createConnection(); + createConnection(); busConnected = false; createBusProxy(); } void QIBusPlatformInputContextPrivate::createBusProxy() { - if (!connection || !connection->isConnected()) + QDBusConnection connection("QIBusProxy"_L1); + if (!connection.isConnected()) return; const char* ibusService = usePortal ? "org.freedesktop.portal.IBus" : "org.freedesktop.IBus"; QDBusReply<QDBusObjectPath> ic; if (usePortal) { - portalBus = new QIBusProxyPortal(QLatin1String(ibusService), - QLatin1String("/org/freedesktop/IBus"), - *connection); + portalBus = std::make_unique<QIBusProxyPortal>(QLatin1StringView(ibusService), + "/org/freedesktop/IBus"_L1, + connection); if (!portalBus->isValid()) { qWarning("QIBusPlatformInputContext: invalid portal bus."); return; } - ic = portalBus->CreateInputContext(QLatin1String("QIBusInputContext")); + ic = portalBus->CreateInputContext("QIBusInputContext"_L1); } else { - bus = new QIBusProxy(QLatin1String(ibusService), - QLatin1String("/org/freedesktop/IBus"), - *connection); + bus = std::make_unique<QIBusProxy>(QLatin1StringView(ibusService), + "/org/freedesktop/IBus"_L1, + connection); if (!bus->isValid()) { qWarning("QIBusPlatformInputContext: invalid bus."); return; } - ic = bus->CreateInputContext(QLatin1String("QIBusInputContext")); + ic = bus->CreateInputContext("QIBusInputContext"_L1); } serviceWatcher.removeWatchedService(ibusService); - serviceWatcher.setConnection(*connection); + serviceWatcher.setConnection(connection); serviceWatcher.addWatchedService(ibusService); if (!ic.isValid()) { @@ -688,7 +701,7 @@ void QIBusPlatformInputContextPrivate::createBusProxy() return; } - context = new QIBusInputContextProxy(QLatin1String(ibusService), ic.value().path(), *connection); + context = std::make_unique<QIBusInputContextProxy>(QLatin1StringView(ibusService), ic.value().path(), connection); if (!context->isValid()) { qWarning("QIBusPlatformInputContext: invalid input context."); @@ -705,6 +718,8 @@ void QIBusPlatformInputContextPrivate::createBusProxy() }; context->SetCapabilities(IBUS_CAP_PREEDIT_TEXT|IBUS_CAP_FOCUS|IBUS_CAP_SURROUNDING_TEXT); + context->setClientCommitPreedit(QIBusPropTypeClientCommitPreedit(true)); + if (debug) qDebug(">>>> bus connected!"); busConnected = true; @@ -712,36 +727,54 @@ void QIBusPlatformInputContextPrivate::createBusProxy() QString QIBusPlatformInputContextPrivate::getSocketPath() { - QByteArray display(qgetenv("DISPLAY")); - QByteArray host = "unix"; + QByteArray display; QByteArray displayNumber = "0"; + bool isWayland = false; + + if (qEnvironmentVariableIsSet("IBUS_ADDRESS_FILE")) { + QByteArray path = qgetenv("IBUS_ADDRESS_FILE"); + return QString::fromLocal8Bit(path); + } else if (qEnvironmentVariableIsSet("WAYLAND_DISPLAY")) { + display = qgetenv("WAYLAND_DISPLAY"); + isWayland = true; + } else { + display = qgetenv("DISPLAY"); + } + QByteArray host = "unix"; + + if (isWayland) { + displayNumber = display; + } else { + int pos = display.indexOf(':'); + if (pos > 0) + host = display.left(pos); + ++pos; + int pos2 = display.indexOf('.', pos); + if (pos2 > 0) + displayNumber = display.mid(pos, pos2 - pos); + else + displayNumber = display.mid(pos); + } - int pos = display.indexOf(':'); - if (pos > 0) - host = display.left(pos); - ++pos; - int pos2 = display.indexOf('.', pos); - if (pos2 > 0) - displayNumber = display.mid(pos, pos2 - pos); - else - displayNumber = display.mid(pos); if (debug) qDebug() << "host=" << host << "displayNumber" << displayNumber; return QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + - QLatin1String("/ibus/bus/") + - QLatin1String(QDBusConnection::localMachineId()) + - QLatin1Char('-') + QString::fromLocal8Bit(host) + QLatin1Char('-') + QString::fromLocal8Bit(displayNumber); + "/ibus/bus/"_L1 + + QLatin1StringView(QDBusConnection::localMachineId()) + + u'-' + QString::fromLocal8Bit(host) + u'-' + QString::fromLocal8Bit(displayNumber); } -QDBusConnection *QIBusPlatformInputContextPrivate::createConnection() +void QIBusPlatformInputContextPrivate::createConnection() { - if (usePortal) - return new QDBusConnection(QDBusConnection::connectToBus(QDBusConnection::SessionBus, QLatin1String("QIBusProxy"))); - QFile file(getSocketPath()); + if (usePortal) { + QDBusConnection::connectToBus(QDBusConnection::SessionBus, "QIBusProxy"_L1); + return; + } + QFile file(getSocketPath()); if (!file.open(QFile::ReadOnly)) - return 0; + return; QByteArray address; int pid = -1; @@ -760,9 +793,11 @@ QDBusConnection *QIBusPlatformInputContextPrivate::createConnection() if (debug) qDebug() << "IBUS_ADDRESS=" << address << "PID=" << pid; if (address.isEmpty() || pid < 0 || kill(pid, 0) != 0) - return 0; + return; - return new QDBusConnection(QDBusConnection::connectToBus(QString::fromLatin1(address), QLatin1String("QIBusProxy"))); + QDBusConnection::connectToBus(QString::fromLatin1(address), "QIBusProxy"_L1); } QT_END_NAMESPACE + +#include "moc_qibusplatforminputcontext.cpp" diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h index e9c9c55f6a..ef8c0b7c8f 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h +++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QIBUSPLATFORMINPUTCONTEXT_H #define QIBUSPLATFORMINPUTCONTEXT_H @@ -50,6 +14,8 @@ #include <QTimer> #include <QWindow> +#include "qibustypes.h" + QT_BEGIN_NAMESPACE class QIBusPlatformInputContextPrivate; @@ -102,6 +68,7 @@ public: public Q_SLOTS: void commitText(const QDBusVariant &text); void updatePreeditText(const QDBusVariant &text, uint cursor_pos, bool visible); + void updatePreeditTextWithMode(const QDBusVariant &text, uint cursor_pos, bool visible, uint mode); void forwardKeyEvent(uint keyval, uint keycode, uint state); void cursorRectChanged(); void deleteSurroundingText(int offset, uint n_chars); diff --git a/src/plugins/platforminputcontexts/ibus/qibusproxy.cpp b/src/plugins/platforminputcontexts/ibus/qibusproxy.cpp index 6b46e106ab..8f104a782d 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusproxy.cpp +++ b/src/plugins/platforminputcontexts/ibus/qibusproxy.cpp @@ -13,6 +13,8 @@ #include "qibusproxy.h" +#include <QDBusReply> + /* * Implementation of interface class QIBusProxy */ @@ -96,3 +98,4 @@ void QIBusProxy::globalEngineChanged(const QString &engine_name) emit GlobalEngineChanged(engine_name); } +#include "moc_qibusproxy.cpp" diff --git a/src/plugins/platforminputcontexts/ibus/qibusproxy.h b/src/plugins/platforminputcontexts/ibus/qibusproxy.h index c9876deebf..73aff1a3d9 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusproxy.h +++ b/src/plugins/platforminputcontexts/ibus/qibusproxy.h @@ -11,14 +11,15 @@ #ifndef QIBUSPROXY_H_1308831142 #define QIBUSPROXY_H_1308831142 -#include <QtCore/QObject> -#include <QtCore/QByteArray> -#include <QtCore/QList> -#include <QtCore/QMap> -#include <QtCore/QString> -#include <QtCore/QStringList> -#include <QtCore/QVariant> -#include <QtDBus/QtDBus> +#include <QObject> +#include <QByteArray> +#include <QList> +#include <QMap> +#include <QString> +#include <QStringList> +#include <QVariant> +#include <QDBusAbstractInterface> +#include <QDBusPendingReply> #include "qibustypes.h" @@ -109,7 +110,7 @@ public Q_SLOTS: // METHODS #endif QIBusEngineDesc getGlobalEngine(); -private: +private Q_SLOTS: void globalEngineChanged(const QString &engine_name); Q_SIGNALS: // SIGNALS diff --git a/src/plugins/platforminputcontexts/ibus/qibusproxyportal.cpp b/src/plugins/platforminputcontexts/ibus/qibusproxyportal.cpp index 50482e2d9a..dc5b37aa6e 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusproxyportal.cpp +++ b/src/plugins/platforminputcontexts/ibus/qibusproxyportal.cpp @@ -2,7 +2,7 @@ * This file was generated by qdbusxml2cpp version 0.8 * Command line was: qdbusxml2cpp -N -p qibusproxyportal -c QIBusProxyPortal interfaces/org.freedesktop.IBus.Portal.xml * - * qdbusxml2cpp is Copyright (C) 2017 The Qt Company Ltd. + * qdbusxml2cpp is Copyright (C) 2023 The Qt Company Ltd and other contributors. * * This is an auto-generated file. * This file may have been hand-edited. Look for HAND-EDIT comments diff --git a/src/plugins/platforminputcontexts/ibus/qibusproxyportal.h b/src/plugins/platforminputcontexts/ibus/qibusproxyportal.h index bdd1d9c395..450205f12a 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusproxyportal.h +++ b/src/plugins/platforminputcontexts/ibus/qibusproxyportal.h @@ -2,7 +2,7 @@ * This file was generated by qdbusxml2cpp version 0.8 * Command line was: qdbusxml2cpp -N -p qibusproxyportal -c QIBusProxyPortal interfaces/org.freedesktop.IBus.Portal.xml * - * qdbusxml2cpp is Copyright (C) 2017 The Qt Company Ltd. + * qdbusxml2cpp is Copyright (C) 2023 The Qt Company Ltd and other contributors. * * This is an auto-generated file. * Do not edit! All changes made to it will be lost. diff --git a/src/plugins/platforminputcontexts/ibus/qibustypes.cpp b/src/plugins/platforminputcontexts/ibus/qibustypes.cpp index 443df271a8..ab1a244b6d 100644 --- a/src/plugins/platforminputcontexts/ibus/qibustypes.cpp +++ b/src/plugins/platforminputcontexts/ibus/qibustypes.cpp @@ -1,44 +1,8 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qibustypes.h" -#include <QtDBus> + #include <QHash> QT_BEGIN_NAMESPACE @@ -214,7 +178,7 @@ QList<QInputMethodEvent::Attribute> QIBusAttributeList::imAttributes() const QHash<QPair<int, int>, QTextCharFormat> rangeAttrs; const int numAttributes = attributes.size(); - // Merge text fomats for identical ranges into a single QTextFormat. + // Merge text formats for identical ranges into a single QTextFormat. for (int i = 0; i < numAttributes; ++i) { const QIBusAttribute &attr = attributes.at(i); const QTextCharFormat &format = attr.format(); @@ -358,4 +322,44 @@ newest: argument.endStructure(); } +QIBusPropTypeClientCommitPreedit::QIBusPropTypeClientCommitPreedit(bool inClientCommitPreedit) + : clientCommitPreedit(inClientCommitPreedit) +{ +} + +void QIBusPropTypeClientCommitPreedit::serializeTo(QDBusArgument &argument) const +{ + argument.beginStructure(); + argument << clientCommitPreedit; + argument.endStructure(); +} + +void QIBusPropTypeClientCommitPreedit::deserializeFrom(const QDBusArgument &argument) +{ + argument.beginStructure(); + argument >> clientCommitPreedit; + argument.endStructure(); +} + +QIBusPropTypeContentType::QIBusPropTypeContentType(unsigned int inPurpose, unsigned int inHints) + : purpose(inPurpose) + , hints(inHints) +{ +} + +void QIBusPropTypeContentType::serializeTo(QDBusArgument &argument) const +{ + argument.beginStructure(); + argument << purpose << hints; + argument.endStructure(); +} + +void QIBusPropTypeContentType::deserializeFrom(const QDBusArgument &argument) +{ + argument.beginStructure(); + argument >> purpose; + argument >> hints; + argument.endStructure(); +} + QT_END_NAMESPACE diff --git a/src/plugins/platforminputcontexts/ibus/qibustypes.h b/src/plugins/platforminputcontexts/ibus/qibustypes.h index 217cd836fc..b697e432a0 100644 --- a/src/plugins/platforminputcontexts/ibus/qibustypes.h +++ b/src/plugins/platforminputcontexts/ibus/qibustypes.h @@ -1,45 +1,9 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QIBUSTYPES_H #define QIBUSTYPES_H -#include <qvector.h> +#include <qlist.h> #include <qevent.h> #include <QDBusArgument> #include <QTextCharFormat> @@ -92,7 +56,7 @@ public: quint32 start; quint32 end; }; -Q_DECLARE_TYPEINFO(QIBusAttribute, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(QIBusAttribute, Q_RELOCATABLE_TYPE); class QIBusAttributeList : private QIBusSerializable { @@ -104,9 +68,9 @@ public: void serializeTo(QDBusArgument &argument) const; void deserializeFrom(const QDBusArgument &argument); - QVector<QIBusAttribute> attributes; + QList<QIBusAttribute> attributes; }; -Q_DECLARE_TYPEINFO(QIBusAttributeList, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(QIBusAttributeList, Q_RELOCATABLE_TYPE); class QIBusText : private QIBusSerializable { @@ -119,7 +83,7 @@ public: QString text; QIBusAttributeList attributes; }; -Q_DECLARE_TYPEINFO(QIBusText, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(QIBusText, Q_RELOCATABLE_TYPE); class QIBusEngineDesc : private QIBusSerializable { @@ -147,7 +111,7 @@ public: QString textdomain; QString iconpropkey; }; -Q_DECLARE_TYPEINFO(QIBusEngineDesc, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(QIBusEngineDesc, Q_RELOCATABLE_TYPE); inline QDBusArgument &operator<<(QDBusArgument &argument, const QIBusAttribute &attribute) { attribute.serializeTo(argument); return argument; } @@ -169,6 +133,44 @@ inline QDBusArgument &operator<<(QDBusArgument &argument, const QIBusEngineDesc inline const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusEngineDesc &desc) { desc.deserializeFrom(argument); return argument; } +class QIBusPropTypeClientCommitPreedit +{ +public: + QIBusPropTypeClientCommitPreedit() {}; + + QIBusPropTypeClientCommitPreedit(bool inClientCommitPreedit); + + void serializeTo(QDBusArgument &argument) const; + void deserializeFrom(const QDBusArgument &argument); + + bool clientCommitPreedit; +}; +inline QDBusArgument &operator<<(QDBusArgument &argument, const QIBusPropTypeClientCommitPreedit &data) +{ data.serializeTo(argument); return argument; } +inline const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusPropTypeClientCommitPreedit &data) +{ data.deserializeFrom(argument); return argument; } + +class QIBusPropTypeContentType +{ +public: + QIBusPropTypeContentType() {}; + + QIBusPropTypeContentType(unsigned int inPurpose, unsigned int inHint); + + void serializeTo(QDBusArgument &argument) const; + void deserializeFrom(const QDBusArgument &argument); + + unsigned int purpose; + unsigned int hints; +}; +inline QDBusArgument &operator<<(QDBusArgument &argument, const QIBusPropTypeContentType &data) +{ data.serializeTo(argument); return argument; } +inline const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusPropTypeContentType &data) +{ data.deserializeFrom(argument); return argument; } + +Q_DECLARE_TYPEINFO(QIBusPropTypeClientCommitPreedit, Q_RELOCATABLE_TYPE); +Q_DECLARE_TYPEINFO(QIBusPropTypeContentType, Q_RELOCATABLE_TYPE); + QT_END_NAMESPACE Q_DECLARE_METATYPE(QIBusAttribute) @@ -176,4 +178,6 @@ Q_DECLARE_METATYPE(QIBusAttributeList) Q_DECLARE_METATYPE(QIBusText) Q_DECLARE_METATYPE(QIBusEngineDesc) +Q_DECLARE_METATYPE(QIBusPropTypeClientCommitPreedit) +Q_DECLARE_METATYPE(QIBusPropTypeContentType) #endif |