mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-05 08:25:32 +00:00
This change allows to press F24 as ordered output sentinel from keyman-system-service. This is part of implementing serialized output with keyman-system-service instead of requiring a patched ibus. The problem both approaches try to solve is that with non-compliant apps it is not possible to directly delete characters from the context. Instead we have to emit a backspace key before we can commit the new characters. However, the backspace key press goes through a different code path in ibus and so it can happen that the commit gets processed before the backspace which then deletes from the characters we just added instead of from the old content. The previous implementation solved this by forwarding a F24 ordered output sentinel key to ibus and relying on the patched ibus to send that back to us. When we received the F24 key we committed the characters that we queued when we forwarded the F24 key (implemented in #7079). The new approach implemented in this change instead sends the F24 ordered output sentinel key through keyman-system-service and so follows the regular key processing without requiring a patched ibus to send the key back to us. The rest of the algorithm stays mostly the same: when we receive the F24 key we commit the characters previously queued. The difference to the previous implementation is that we now also queue the backspace keys that we generate. Part-of: #10799
48 lines
795 B
C++
48 lines
795 B
C++
// A KeyboardDevice mock.
|
|
#include <dirent.h>
|
|
#include <fcntl.h>
|
|
#include <iostream>
|
|
#include <string.h>
|
|
#include <string>
|
|
#include <unistd.h>
|
|
|
|
#ifndef KeyboardDevice
|
|
#define KeyboardDevice KeyboardDeviceMock
|
|
#endif
|
|
|
|
#include "KeyboardDevice.h"
|
|
|
|
using namespace std;
|
|
|
|
KeyboardDeviceMock::KeyboardDeviceMock() {
|
|
dev = nullptr;
|
|
fd = -1;
|
|
hasCapsLockLed = 1;
|
|
debug = false;
|
|
}
|
|
|
|
KeyboardDeviceMock::~KeyboardDeviceMock() {
|
|
}
|
|
|
|
void KeyboardDeviceMock::Close() {
|
|
}
|
|
|
|
bool
|
|
KeyboardDeviceMock::Initialize(const char* name) {
|
|
return true;
|
|
}
|
|
|
|
bool
|
|
KeyboardDeviceMock::HasCapsLockLed() {
|
|
return true;
|
|
}
|
|
|
|
void
|
|
KeyboardDeviceMock::SetCapsLockLed(bool on) {
|
|
hasCapsLockLed = on ? 1 : 0;
|
|
}
|
|
|
|
bool
|
|
KeyboardDeviceMock::GetCapsLockLed() {
|
|
return hasCapsLockLed == 1;
|
|
}
|