fix: no OSD indication when switching keyboard layout with Application Policy
When deciding do OSD or not, we need to consider not only last saved layout, but last actual layout also, when comparing it to current one. DIGEST: BUG: 425590master
parent
4559d30399
commit
769c8959d8
|
@ -198,7 +198,9 @@ void KeyboardInputRedirection::processKey(uint32_t key, InputRedirection::Keyboa
|
|||
}
|
||||
|
||||
if (!autoRepeat) {
|
||||
const quint32 previousLayout = m_xkb->currentLayout();
|
||||
m_xkb->updateKey(key, state);
|
||||
m_keyboardLayout->checkLayoutChange(previousLayout);
|
||||
}
|
||||
|
||||
const xkb_keysym_t keySym = m_xkb->currentKeysym();
|
||||
|
@ -227,10 +229,11 @@ void KeyboardInputRedirection::processModifiers(uint32_t modsDepressed, uint32_t
|
|||
if (!m_inited) {
|
||||
return;
|
||||
}
|
||||
const quint32 previousLayout = m_xkb->currentLayout();
|
||||
// TODO: send to proper Client and also send when active Client changes
|
||||
m_xkb->updateModifiers(modsDepressed, modsLatched, modsLocked, group);
|
||||
m_modifiersChangedSpy->updateModifiers(modifiers());
|
||||
m_keyboardLayout->checkLayoutChange();
|
||||
m_keyboardLayout->checkLayoutChange(previousLayout);
|
||||
}
|
||||
|
||||
void KeyboardInputRedirection::processKeymapChange(int fd, uint32_t size)
|
||||
|
|
|
@ -132,20 +132,23 @@ void KeyboardLayout::initNotifierItem()
|
|||
|
||||
void KeyboardLayout::switchToNextLayout()
|
||||
{
|
||||
const quint32 previousLayout = m_xkb->currentLayout();
|
||||
m_xkb->switchToNextLayout();
|
||||
checkLayoutChange();
|
||||
checkLayoutChange(previousLayout);
|
||||
}
|
||||
|
||||
void KeyboardLayout::switchToPreviousLayout()
|
||||
{
|
||||
const quint32 previousLayout = m_xkb->currentLayout();
|
||||
m_xkb->switchToPreviousLayout();
|
||||
checkLayoutChange();
|
||||
checkLayoutChange(previousLayout);
|
||||
}
|
||||
|
||||
void KeyboardLayout::switchToLayout(xkb_layout_index_t index)
|
||||
{
|
||||
const quint32 previousLayout = m_xkb->currentLayout();
|
||||
m_xkb->switchToLayout(index);
|
||||
checkLayoutChange();
|
||||
checkLayoutChange(previousLayout);
|
||||
}
|
||||
|
||||
void KeyboardLayout::reconfigure()
|
||||
|
@ -200,23 +203,19 @@ void KeyboardLayout::loadShortcuts()
|
|||
}
|
||||
}
|
||||
|
||||
void KeyboardLayout::keyEvent(KeyEvent *event)
|
||||
{
|
||||
if (!event->isAutoRepeat()) {
|
||||
checkLayoutChange();
|
||||
}
|
||||
}
|
||||
|
||||
void KeyboardLayout::checkLayoutChange()
|
||||
void KeyboardLayout::checkLayoutChange(quint32 previousLayout)
|
||||
{
|
||||
// Get here on key event or DBus call.
|
||||
// m_layout - layout saved last time OSD occurred
|
||||
// previousLayout - actual layout just before potential layout change
|
||||
// We need OSD if current layout deviates from any of these
|
||||
const auto layout = m_xkb->currentLayout();
|
||||
if (m_layout == layout) {
|
||||
return;
|
||||
if (m_layout != layout || previousLayout != layout) {
|
||||
m_layout = layout;
|
||||
notifyLayoutChange();
|
||||
updateNotifier();
|
||||
emit layoutChanged();
|
||||
}
|
||||
m_layout = layout;
|
||||
notifyLayoutChange();
|
||||
updateNotifier();
|
||||
emit layoutChanged();
|
||||
}
|
||||
|
||||
void KeyboardLayout::notifyLayoutChange()
|
||||
|
@ -304,8 +303,9 @@ bool KeyboardLayoutDBusInterface::setLayout(const QString &layout)
|
|||
if (it == layouts.end()) {
|
||||
return false;
|
||||
}
|
||||
const quint32 previousLayout = m_xkb->currentLayout();
|
||||
m_xkb->switchToLayout(it.key());
|
||||
m_keyboardLayout->checkLayoutChange();
|
||||
m_keyboardLayout->checkLayoutChange(previousLayout);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,12 +42,10 @@ public:
|
|||
|
||||
void init();
|
||||
|
||||
void checkLayoutChange();
|
||||
void checkLayoutChange(quint32 previousLayout);
|
||||
void resetLayout();
|
||||
void updateNotifier();
|
||||
|
||||
void keyEvent(KeyEvent *event) override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void layoutChanged();
|
||||
void layoutsReconfigured();
|
||||
|
|
Loading…
Reference in New Issue