From cba895e7239e5919aa15adfb4e71ad72fb6c0806 Mon Sep 17 00:00:00 2001 From: Andrey Butirsky Date: Thu, 20 Aug 2020 16:09:43 +0000 Subject: [PATCH] fix: keyboard layout applet doesn't show actual layout BUG: 425343 --- keyboard_layout.h | 2 +- keyboard_layout_switching.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/keyboard_layout.h b/keyboard_layout.h index fb72ffd94..f44cc92e0 100644 --- a/keyboard_layout.h +++ b/keyboard_layout.h @@ -44,6 +44,7 @@ public: void checkLayoutChange(); void resetLayout(); + void updateNotifier(); void keyEvent(KeyEvent *event) override; @@ -61,7 +62,6 @@ private: void switchToNextLayout(); void switchToPreviousLayout(); void switchToLayout(xkb_layout_index_t index); - void updateNotifier(); void reinitNotifierMenu(); void loadShortcuts(); Xkb *m_xkb; diff --git a/keyboard_layout_switching.cpp b/keyboard_layout_switching.cpp index 5c3bda34b..49bbc7247 100644 --- a/keyboard_layout_switching.cpp +++ b/keyboard_layout_switching.cpp @@ -34,7 +34,11 @@ Policy::~Policy() = default; void Policy::setLayout(quint32 layout) { + const quint32 previousLayout = m_xkb->currentLayout(); m_xkb->switchToLayout(layout); + if (previousLayout != m_xkb->currentLayout()) { + m_layout->updateNotifier(); + } } quint32 Policy::layout() const @@ -92,7 +96,7 @@ GlobalPolicy::GlobalPolicy(Xkb *xkb, KeyboardLayout *_layout, const KConfigGroup [this, xkb] (const QString &name) { Q_UNUSED(name) if (xkb->numberOfLayouts() > 1) { - xkb->switchToLayout(m_config.readEntry(defaultLayoutEntryKey(), 0)); + setLayout(m_config.readEntry(defaultLayoutEntryKey(), 0)); } } );