Skip to content

Commit

Permalink
Auto-Type: Support multiple Xkb layouts
Browse files Browse the repository at this point in the history
Completely rewritten XCB Auto-Type keymap system.

 - supports multiple simultaneous layouts
 - prefers current layout if it has all keysyms available
 - removed hardcoded KeySymMap
 - removed clunky custom KeySym emulation

Biggest breaking change is removing KeySym emulation for keys that
do not exist in any of the layouts currently in use. It would be
possible to make it work but if you are trying to type syms that
are not available in any of your layouts you are abusing it. It
also adds unnecessary complexity and opens up timing issues when
the keymap is modified on-the-fly. Now we are just reading it.

This also workarounds a Qt related issue where QX11Info::display()
returns a connection to X server that fails to receive updated
keymap data when client settings change. We use our own connection
now to get it working.
  • Loading branch information
hifi authored and droidmonkey committed Mar 26, 2021
1 parent 2423bed commit 4d07507
Show file tree
Hide file tree
Showing 15 changed files with 121 additions and 349 deletions.
1 change: 1 addition & 0 deletions src/autotype/AutoType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ AutoType::parseSequence(const QString& entrySequence, const Entry* entry, QStrin
const int maxRepetition = 100;

QList<QSharedPointer<AutoTypeAction>> actions;
actions << QSharedPointer<AutoTypeBegin>::create();
actions << QSharedPointer<AutoTypeDelay>::create(qMax(0, config()->get(Config::AutoTypeDelay).toInt()), true);

// Replace escaped braces with a template for easier regex
Expand Down
5 changes: 5 additions & 0 deletions src/autotype/AutoTypeAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,8 @@ void AutoTypeClearField::exec(AutoTypeExecutor* executor) const
{
executor->execClearField(this);
}

void AutoTypeBegin::exec(AutoTypeExecutor* executor) const
{
executor->execBegin(this);
}
7 changes: 7 additions & 0 deletions src/autotype/AutoTypeAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,17 @@ class KEEPASSXC_EXPORT AutoTypeClearField : public AutoTypeAction
void exec(AutoTypeExecutor* executor) const override;
};

class KEEPASSXC_EXPORT AutoTypeBegin : public AutoTypeAction
{
public:
void exec(AutoTypeExecutor* executor) const override;
};

class KEEPASSXC_EXPORT AutoTypeExecutor
{
public:
virtual ~AutoTypeExecutor() = default;
virtual void execBegin(const AutoTypeBegin* action) = 0;
virtual void execType(const AutoTypeKey* action) = 0;
virtual void execClearField(const AutoTypeClearField* action) = 0;

Expand Down
5 changes: 5 additions & 0 deletions src/autotype/mac/AutoTypeMac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ AutoTypeExecutorMac::AutoTypeExecutorMac(AutoTypePlatformMac* platform)
{
}

void AutoTypeExecutorMac::execBegin(const AutoTypeBegin* action)
{
Q_UNUSED(action);
}

void AutoTypeExecutorMac::execType(const AutoTypeKey* action)
{
if (action->modifiers & Qt::ShiftModifier) {
Expand Down
1 change: 1 addition & 0 deletions src/autotype/mac/AutoTypeMac.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class AutoTypeExecutorMac : public AutoTypeExecutor
public:
explicit AutoTypeExecutorMac(AutoTypePlatformMac* platform);

void execBegin(const AutoTypeBegin* action) override;
void execType(const AutoTypeKey* action) override;
void execClearField(const AutoTypeClearField* action) override;

Expand Down
5 changes: 5 additions & 0 deletions src/autotype/test/AutoTypeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ AutoTypeExecutorTest::AutoTypeExecutorTest(AutoTypePlatformTest* platform)
{
}

void AutoTypeExecutorTest::execBegin(const AutoTypeBegin* action)
{
Q_UNUSED(action);
}

void AutoTypeExecutorTest::execType(const AutoTypeKey* action)
{
m_platform->addAction(action);
Expand Down
1 change: 1 addition & 0 deletions src/autotype/test/AutoTypeTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class AutoTypeExecutorTest : public AutoTypeExecutor
public:
explicit AutoTypeExecutorTest(AutoTypePlatformTest* platform);

void execBegin(const AutoTypeBegin* action) override;
void execType(const AutoTypeKey* action) override;
void execClearField(const AutoTypeClearField* action) override;

Expand Down
5 changes: 5 additions & 0 deletions src/autotype/windows/AutoTypeWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@ AutoTypeExecutorWin::AutoTypeExecutorWin(AutoTypePlatformWin* platform)
{
}

void AutoTypeExecutorWin::execBegin(const AutoTypeBegin* action)
{
Q_UNUSED(action);
}

void AutoTypeExecutorWin::execType(const AutoTypeKey* action)
{
if (action->modifiers & Qt::ShiftModifier) {
Expand Down
1 change: 1 addition & 0 deletions src/autotype/windows/AutoTypeWindows.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class AutoTypeExecutorWin : public AutoTypeExecutor
public:
explicit AutoTypeExecutorWin(AutoTypePlatformWin* platform);

void execBegin(const AutoTypeBegin* action) override;
void execType(const AutoTypeKey* action) override;
void execClearField(const AutoTypeClearField* action) override;

Expand Down
Loading

0 comments on commit 4d07507

Please sign in to comment.