Commit 359eec5a authored by Andrey Butirsky's avatar Andrey Butirsky

fix: Keyboard Layout plugin: wrong property for passing Short Name

KWin Wayland initially misused the DBus API and passed Long layout Name
via currentLayoutDisplayName() method which is wrong.
Instead, the new currentLayoutLongName() property should be added,
and Short Name be passed via currentLayoutDisplayName() as it is for
X11.
parent 5c70dc21
......@@ -19,8 +19,8 @@ void KeyboardLayout::requestDBusData<KeyboardLayout::CurrentLayoutDisplayName>()
{ if (mIface) requestDBusData(mIface->getLayoutDisplayName(mCurrentLayout), mCurrentLayoutDisplayName, &KeyboardLayout::currentLayoutDisplayNameChanged); }
template<>
void KeyboardLayout::requestDBusData<KeyboardLayout::CurrentLayoutShortName>()
{ if (mIface) requestDBusData(mIface->getCurrentLayoutShortName(), mCurrentLayoutShortName, &KeyboardLayout::currentLayoutShortNameChanged); }
void KeyboardLayout::requestDBusData<KeyboardLayout::CurrentLayoutLongName>()
{ if (mIface) requestDBusData(mIface->getCurrentLayoutLongName(), mCurrentLayoutLongName, &KeyboardLayout::currentLayoutLongNameChanged); }
template<>
void KeyboardLayout::requestDBusData<KeyboardLayout::Layouts>()
......@@ -42,37 +42,50 @@ KeyboardLayout::KeyboardLayout(QObject* parent)
}
connect(mIface, &OrgKdeKeyboardLayoutsInterface::currentLayoutChanged,
this, &KeyboardLayout::onCurrentLayoutChanged);
this, [this](const QString &newLayout)
{
mCurrentLayout = newLayout;
requestDBusData<CurrentLayoutDisplayName>();
requestDBusData<CurrentLayoutLongName>();
});
connect(mIface, &OrgKdeKeyboardLayoutsInterface::layoutListChanged,
this, &KeyboardLayout::onLayoutListChanged);
this, [this]()
{
requestDBusData<CurrentLayout>();
requestDBusData<CurrentLayoutLongName>();
requestDBusData<Layouts>();
});
connect(this, &KeyboardLayout::currentLayoutChanged,
this, &KeyboardLayout::requestDBusData<CurrentLayoutDisplayName>);
requestDBusData<CurrentLayout>();
requestDBusData<CurrentLayoutShortName>();
requestDBusData<Layouts>();
emit mIface->OrgKdeKeyboardLayoutsInterface::layoutListChanged();
}
KeyboardLayout::~KeyboardLayout()
{
}
void KeyboardLayout::onCurrentLayoutChanged(const QString &newLayout)
{
mCurrentLayout = newLayout;
requestDBusData<CurrentLayoutShortName>();
requestDBusData<CurrentLayoutDisplayName>();
}
void KeyboardLayout::onLayoutListChanged()
void KeyboardLayout::setCurrentLayout(const QString &layout)
{
requestDBusData<CurrentLayout>();
requestDBusData<CurrentLayoutShortName>();
requestDBusData<Layouts>();
if (mIface) mIface->setLayout(layout);
}
void KeyboardLayout::setCurrentLayout(const QString &layout)
template<class T>
void KeyboardLayout::requestDBusData(QDBusPendingReply<T> pendingReply, T &out, void (KeyboardLayout::*notify)())
{
if (mIface) mIface->setLayout(layout);
const QDBusPendingCallWatcher * const watcher = new QDBusPendingCallWatcher(pendingReply, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this,
[this, &out, notify](QDBusPendingCallWatcher *watcher)
{
QDBusPendingReply<T> reply = *watcher;
if (reply.isError()) {
qCWarning(KEYBOARD_LAYOUT) << reply.error().message();
} else {
out = reply.value();
emit (this->*notify)();
}
watcher->deleteLater();
}
);
}
......@@ -27,9 +27,9 @@ class KeyboardLayout : public QObject
MEMBER mCurrentLayoutDisplayName
NOTIFY currentLayoutDisplayNameChanged)
Q_PROPERTY(QString currentLayoutShortName
MEMBER mCurrentLayoutShortName
NOTIFY currentLayoutShortNameChanged)
Q_PROPERTY(QString currentLayoutLongName
MEMBER mCurrentLayoutLongName
NOTIFY currentLayoutLongNameChanged)
Q_PROPERTY(QStringList layouts
MEMBER mLayouts
......@@ -42,46 +42,24 @@ public:
Q_SIGNALS:
void currentLayoutChanged();
void currentLayoutDisplayNameChanged();
void currentLayoutShortNameChanged();
void currentLayoutLongNameChanged();
void layoutsChanged();
private:
void setCurrentLayout(const QString &layout);
enum DBusData {CurrentLayout, CurrentLayoutDisplayName, CurrentLayoutShortName, Layouts};
enum DBusData {CurrentLayout, CurrentLayoutDisplayName, CurrentLayoutLongName, Layouts};
template<class T>
void requestDBusData(QDBusPendingReply<T> pendingReply, T &out, void (KeyboardLayout::*notify)());
template<DBusData>
inline void requestDBusData();
void onCurrentLayoutChanged(const QString &newLayout);
void onLayoutListChanged();
QStringList mLayouts;
QString mCurrentLayout;
QString mCurrentLayoutDisplayName;
QString mCurrentLayoutShortName;
QString mCurrentLayoutLongName;
QStringList mLayouts;
OrgKdeKeyboardLayoutsInterface *mIface;
};
template<class T>
void KeyboardLayout::requestDBusData(QDBusPendingReply<T> pendingReply, T &out, void (KeyboardLayout::*notify)())
{
const QDBusPendingCallWatcher * const watcher = new QDBusPendingCallWatcher(pendingReply, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this,
[this, &out, notify](QDBusPendingCallWatcher *watcher)
{
QDBusPendingReply<T> reply = *watcher;
if (reply.isError()) {
qCWarning(KEYBOARD_LAYOUT) << reply.error().message();
} else {
out = reply.value();
emit (this->*notify)();
}
watcher->deleteLater();
}
);
}
#endif // KEYBOARDLAYOUT_H
......@@ -14,7 +14,7 @@
<method name="getCurrentLayout">
<arg type="s" direction="out"/>
</method>
<method name="getCurrentLayoutShortName">
<method name="getCurrentLayoutLongName">
<arg type="s" direction="out"/>
</method>
<method name="getLayoutsList">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment