Skip to content
Permalink
Browse files

use private dbus connection for im module so we don't conflict with k…

  • Loading branch information
wengxt committed Nov 9, 2019
1 parent 08a2e57 commit f7a5b3484bce1da4b54b6eb0cb5254126e985f2d
@@ -71,9 +71,10 @@ QString socketFile() {
return QString("%1/fcitx/dbus/%2").arg(home).arg(filename);
}

FcitxWatcher::FcitxWatcher(QObject *parent)
FcitxWatcher::FcitxWatcher(QDBusConnection sessionBus, QObject *parent)
: QObject(parent), m_fsWatcher(new QFileSystemWatcher(this)),
m_serviceWatcher(new QDBusServiceWatcher(this)), m_connection(nullptr),
m_sessionBus(sessionBus),
m_socketFile(socketFile()),
m_serviceName(QString("org.fcitx.Fcitx-%2").arg(displayNumber())),
m_availability(false) {}
@@ -90,7 +91,7 @@ QDBusConnection FcitxWatcher::connection() const {
if (m_connection) {
return *m_connection;
}
return QDBusConnection::sessionBus();
return m_sessionBus;
}

QString FcitxWatcher::service() const {
@@ -121,15 +122,15 @@ void FcitxWatcher::watch() {
connect(m_serviceWatcher,
SIGNAL(serviceOwnerChanged(QString, QString, QString)), this,
SLOT(imChanged(QString, QString, QString)));
m_serviceWatcher->setConnection(QDBusConnection::sessionBus());
m_serviceWatcher->setConnection(m_sessionBus);
m_serviceWatcher->addWatchedService(m_serviceName);
m_serviceWatcher->addWatchedService("org.freedesktop.portal.Fcitx");

if (QDBusConnection::sessionBus().interface()->isServiceRegistered(
if (m_sessionBus.interface()->isServiceRegistered(
m_serviceName)) {
m_mainPresent = true;
}
if (QDBusConnection::sessionBus().interface()->isServiceRegistered(
if (m_sessionBus.interface()->isServiceRegistered(
"org.freedesktop.portal.Fcitx")) {
m_portalPresent = true;
}
@@ -22,6 +22,7 @@
#define FCITXWATCHER_H_

#include <QObject>
#include <QDBusConnection>

class QDBusConnection;
class QFileSystemWatcher;
@@ -33,7 +34,7 @@ class QDBusServiceWatcher;
class FcitxWatcher : public QObject {
Q_OBJECT
public:
explicit FcitxWatcher(QObject *parent = nullptr);
explicit FcitxWatcher(QDBusConnection sessionBus, QObject *parent = nullptr);
~FcitxWatcher();
void watch();
void unwatch();
@@ -64,6 +65,7 @@ private slots:
QFileSystemWatcher *m_fsWatcher;
QDBusServiceWatcher *m_serviceWatcher;
QDBusConnection *m_connection;
QDBusConnection m_sessionBus;
QString m_socketFile;
QString m_serviceName;
bool m_availability = false;
@@ -87,7 +87,7 @@ struct xkb_context *_xkb_context_new_helper() {
}

QFcitxPlatformInputContext::QFcitxPlatformInputContext()
: m_watcher(new FcitxWatcher(this)), m_cursorPos(0),
: m_watcher(new FcitxWatcher(QDBusConnection::connectToBus(QDBusConnection::SessionBus, "fcitx-platform-input-context"), this)), m_cursorPos(0),
m_useSurroundingText(false),
m_syncMode(get_boolean_env("FCITX_QT_USE_SYNC", false)), m_destroy(false),
m_xkbContext(_xkb_context_new_helper()),
@@ -258,7 +258,7 @@ void QFcitxPlatformInputContext::update(Qt::InputMethodQueries queries) {
if (!setSurrounding) {
data.surroundingAnchor = -1;
data.surroundingCursor = -1;
data.surroundingText = QString::null;
data.surroundingText = QString();
removeCapability(data, CAPACITY_SURROUNDING_TEXT);
}
} while (0);
@@ -35,7 +35,6 @@
#include <unordered_map>
#include <xkbcommon/xkbcommon-compose.h>

class FcitxQtConnection;
class QFileSystemWatcher;
enum FcitxKeyEventType { FCITX_PRESS_KEY, FCITX_RELEASE_KEY };

0 comments on commit f7a5b34

Please sign in to comment.
You can’t perform that action at this time.