keyboard_layout: always expose dbus interface

our plasmoid only listens to signals when the interface was found.
also when switching from 2 to 1 layout we'd emit a signal that the
layouts changed but then we'd throw away our interface leaving
the client wondering what happened to us (and consequently
printing warnings because our service wasn't found)

this specifically resulted in the plasmoid not getting layout event
changes when switching from 1 to >1

BUG: 449531
This commit is contained in:
Harald Sitter 2024-03-13 16:10:43 +01:00 committed by Vlad Zahorodnii
parent 2663756ebf
commit 645db7fc90
3 changed files with 0 additions and 46 deletions

View file

@ -58,7 +58,6 @@ private Q_SLOTS:
void testReconfigure();
void testChangeLayoutThroughDBus();
void testPerLayoutShortcut();
void testDBusServiceExport();
void testVirtualDesktopPolicy();
void testWindowPolicy();
void testApplicationPolicy();
@ -307,36 +306,6 @@ void KeyboardLayoutTest::testPerLayoutShortcut()
Test::keyboardKeyReleased(KEY_LEFTCTRL, timestamp++);
}
void KeyboardLayoutTest::testDBusServiceExport()
{
// verifies that the dbus service is only exported if there are at least two layouts
// first configure layouts, with just one layout
layoutGroup.writeEntry("LayoutList", QStringLiteral("us"));
layoutGroup.sync();
reconfigureLayouts();
auto xkb = input()->keyboard()->xkb();
QCOMPARE(xkb->numberOfLayouts(), 1u);
// default layout is English
QCOMPARE(xkb->layoutName(), QStringLiteral("English (US)"));
// with one layout we should not have the dbus interface
QVERIFY(!QDBusConnection::sessionBus().interface()->isServiceRegistered(QStringLiteral("org.kde.keyboard")).value());
// reconfigure to two layouts
layoutGroup.writeEntry("LayoutList", QStringLiteral("us,de"));
layoutGroup.sync();
reconfigureLayouts();
QCOMPARE(xkb->numberOfLayouts(), 2u);
QVERIFY(QDBusConnection::sessionBus().interface()->isServiceRegistered(QStringLiteral("org.kde.keyboard")).value());
// and back to one layout
layoutGroup.writeEntry("LayoutList", QStringLiteral("us"));
layoutGroup.sync();
reconfigureLayouts();
QCOMPARE(xkb->numberOfLayouts(), 1u);
QVERIFY(!QDBusConnection::sessionBus().interface()->isServiceRegistered(QStringLiteral("org.kde.keyboard")).value());
}
void KeyboardLayoutTest::testVirtualDesktopPolicy()
{
layoutGroup.writeEntry("LayoutList", QStringLiteral("us,de,de(neo)"));

View file

@ -67,20 +67,7 @@ void KeyboardLayout::init()
SLOT(reconfigure()));
reconfigure();
}
void KeyboardLayout::initDBusInterface()
{
if (m_xkb->numberOfLayouts() <= 1) {
if (m_dbusInterface) {
m_dbusInterface->deleteLater();
m_dbusInterface = nullptr;
}
return;
}
if (m_dbusInterface) {
return;
}
m_dbusInterface = new KeyboardLayoutDBusInterface(m_xkb, m_configGroup, this);
connect(this, &KeyboardLayout::layoutChanged,
m_dbusInterface, &KeyboardLayoutDBusInterface::layoutChanged);
@ -139,7 +126,6 @@ void KeyboardLayout::resetLayout()
m_layout = m_xkb->currentLayout();
loadShortcuts();
initDBusInterface();
Q_EMIT layoutsReconfigured();
}

View file

@ -55,7 +55,6 @@ private Q_SLOTS:
void reconfigure();
private:
void initDBusInterface();
void notifyLayoutChange();
void switchToLayout(xkb_layout_index_t index);
void loadShortcuts();