The right alt in full mode is now AltGr: sticky like the other modifiers, it types the keymap's third/fourth level (sk: AltGr+J = ') instead of an Alt shortcut. In hold-keys mode it holds the physical right alt, since KWin resets the modifier state after an ISO_Level3_Shift keysym. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
58 lines
1.2 KiB
C++
58 lines
1.2 KiB
C++
#include "Modifiers.h"
|
|
|
|
ShiftState *Modifiers::find(const QString &name)
|
|
{
|
|
for (Entry &entry : m_entries) {
|
|
if (name == QLatin1StringView(entry.name))
|
|
return &entry.state;
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
void Modifiers::press(const QString &name, qint64 timeMs)
|
|
{
|
|
if (ShiftState *state = find(name))
|
|
state->press(timeMs);
|
|
}
|
|
|
|
void Modifiers::release(const QString &name)
|
|
{
|
|
if (ShiftState *state = find(name))
|
|
state->release();
|
|
}
|
|
|
|
void Modifiers::keyTyped()
|
|
{
|
|
for (Entry &entry : m_entries)
|
|
entry.state.characterTyped();
|
|
}
|
|
|
|
void Modifiers::clear()
|
|
{
|
|
for (Entry &entry : m_entries)
|
|
entry.state = {};
|
|
}
|
|
|
|
Qt::KeyboardModifiers Modifiers::active() const
|
|
{
|
|
Qt::KeyboardModifiers flags;
|
|
for (const Entry &entry : m_entries) {
|
|
if (entry.state.isActive())
|
|
flags |= entry.flag;
|
|
}
|
|
return flags & ~Qt::GroupSwitchModifier;
|
|
}
|
|
|
|
bool Modifiers::isAltGrActive() const
|
|
{
|
|
return m_entries.back().state.isActive();
|
|
}
|
|
|
|
QVariantMap Modifiers::modes() const
|
|
{
|
|
QVariantMap modes;
|
|
for (const Entry &entry : m_entries)
|
|
modes.insert(QString::fromLatin1(entry.name), int(entry.state.mode()));
|
|
return modes;
|
|
}
|