refactor: KeyMap EType => enum class KeyType
This commit is contained in:
@ -1228,7 +1228,7 @@ bool KeyMap::KeyItem::operator==(const KeyItem &x) const
|
||||
// KeyMap::Keystroke
|
||||
//
|
||||
|
||||
KeyMap::Keystroke::Keystroke(KeyButton button, bool press, bool repeat, uint32_t data) : m_type(kButton)
|
||||
KeyMap::Keystroke::Keystroke(KeyButton button, bool press, bool repeat, uint32_t data) : m_type(KeyType::Button)
|
||||
{
|
||||
m_data.m_button.m_button = button;
|
||||
m_data.m_button.m_press = press;
|
||||
@ -1236,7 +1236,7 @@ KeyMap::Keystroke::Keystroke(KeyButton button, bool press, bool repeat, uint32_t
|
||||
m_data.m_button.m_client = data;
|
||||
}
|
||||
|
||||
KeyMap::Keystroke::Keystroke(int32_t group, bool absolute, bool restore) : m_type(kGroup)
|
||||
KeyMap::Keystroke::Keystroke(int32_t group, bool absolute, bool restore) : m_type(KeyType::Group)
|
||||
{
|
||||
m_data.m_group.m_group = group;
|
||||
m_data.m_group.m_absolute = absolute;
|
||||
|
||||
@ -71,10 +71,10 @@ public:
|
||||
class Keystroke
|
||||
{
|
||||
public:
|
||||
enum EType
|
||||
enum class KeyType
|
||||
{
|
||||
kButton, //!< Synthesize button
|
||||
kGroup //!< Set new group
|
||||
Button, //!< Synthesize button
|
||||
Group //!< Set new group
|
||||
};
|
||||
|
||||
Keystroke(KeyButton, bool press, bool repeat, uint32_t clientData);
|
||||
@ -103,7 +103,7 @@ public:
|
||||
Group m_group;
|
||||
};
|
||||
|
||||
EType m_type{};
|
||||
KeyType m_type{};
|
||||
Data m_data{};
|
||||
};
|
||||
|
||||
|
||||
@ -874,7 +874,7 @@ bool KeyState::fakeKeyRepeat(KeyID id, KeyModifierMask mask, int32_t count, KeyB
|
||||
// replace key up with previous KeyButton but leave key down
|
||||
// alone so it uses the new KeyButton.
|
||||
for (auto &key : keys) {
|
||||
if (key.m_type == Keystroke::kButton && key.m_data.m_button.m_button == localID) {
|
||||
if (key.m_type == Keystroke::KeyType::Button && key.m_data.m_button.m_button == localID) {
|
||||
key.m_data.m_button.m_button = oldLocalID;
|
||||
break;
|
||||
}
|
||||
@ -1067,20 +1067,21 @@ void KeyState::fakeKeys(const Keystrokes &keys, uint32_t count)
|
||||
// generate key events
|
||||
LOG((CLOG_DEBUG1 "keystrokes:"));
|
||||
for (auto k = keys.begin(); k != keys.end();) {
|
||||
if (k->m_type == Keystroke::kButton && k->m_data.m_button.m_repeat) {
|
||||
if (k->m_type == Keystroke::KeyType::Button && k->m_data.m_button.m_repeat) {
|
||||
// repeat from here up to but not including the next key
|
||||
// with m_repeat == false count times.
|
||||
Keystrokes::const_iterator start = k;
|
||||
while (count-- > 0) {
|
||||
// send repeating events
|
||||
for (k = start; k != keys.end() && k->m_type == Keystroke::kButton && k->m_data.m_button.m_repeat; ++k) {
|
||||
for (k = start; k != keys.end() && k->m_type == Keystroke::KeyType::Button && k->m_data.m_button.m_repeat;
|
||||
++k) {
|
||||
fakeKey(*k);
|
||||
}
|
||||
}
|
||||
|
||||
// note -- k is now on the first non-repeat key after the
|
||||
// repeat keys, exactly where we'd like to continue from.
|
||||
} else if (k->m_type != Keystroke::kGroup || (!k->m_data.m_group.m_restore && m_isLangSyncEnabled)) {
|
||||
} else if (k->m_type != Keystroke::KeyType::Group || (!k->m_data.m_group.m_restore && m_isLangSyncEnabled)) {
|
||||
// send event
|
||||
fakeKey(*k);
|
||||
|
||||
|
||||
@ -231,7 +231,7 @@ void EiKeyState::getKeyMap(deskflow::KeyMap &keyMap)
|
||||
void EiKeyState::fakeKey(const Keystroke &keystroke)
|
||||
{
|
||||
switch (keystroke.m_type) {
|
||||
case Keystroke::kButton:
|
||||
case Keystroke::KeyType::Button:
|
||||
LOG_DEBUG1(
|
||||
"fake key: %03x (%08x) %s", keystroke.m_data.m_button.m_button, keystroke.m_data.m_button.m_client,
|
||||
keystroke.m_data.m_button.m_press ? "down" : "up"
|
||||
|
||||
@ -1163,7 +1163,7 @@ void MSWindowsKeyState::getKeyMap(deskflow::KeyMap &keyMap)
|
||||
void MSWindowsKeyState::fakeKey(const Keystroke &keystroke)
|
||||
{
|
||||
switch (keystroke.m_type) {
|
||||
case Keystroke::kButton: {
|
||||
case Keystroke::KeyType::Button: {
|
||||
LOG(
|
||||
(CLOG_DEBUG1 " %03x (%08x) %s", keystroke.m_data.m_button.m_button, keystroke.m_data.m_button.m_client,
|
||||
keystroke.m_data.m_button.m_press ? "down" : "up")
|
||||
@ -1201,7 +1201,7 @@ void MSWindowsKeyState::fakeKey(const Keystroke &keystroke)
|
||||
break;
|
||||
}
|
||||
|
||||
case Keystroke::kGroup:
|
||||
case Keystroke::KeyType::Group:
|
||||
// we don't restore the group. we'd like to but we can't be
|
||||
// sure the restoring group change will be processed after the
|
||||
// key events.
|
||||
|
||||
@ -594,7 +594,7 @@ void OSXKeyState::postKeyboardKey(CGKeyCode virtualKey, bool keyDown)
|
||||
void OSXKeyState::fakeKey(const Keystroke &keystroke)
|
||||
{
|
||||
switch (keystroke.m_type) {
|
||||
case Keystroke::kButton: {
|
||||
case Keystroke::KeyType::Button: {
|
||||
bool keyDown = keystroke.m_data.m_button.m_press;
|
||||
uint32_t client = keystroke.m_data.m_button.m_client;
|
||||
KeyButton button = keystroke.m_data.m_button.m_button;
|
||||
@ -614,7 +614,7 @@ void OSXKeyState::fakeKey(const Keystroke &keystroke)
|
||||
break;
|
||||
}
|
||||
|
||||
case Keystroke::kGroup: {
|
||||
case Keystroke::KeyType::Group: {
|
||||
int32_t group = keystroke.m_data.m_group.m_group;
|
||||
if (!keystroke.m_data.m_group.m_restore) {
|
||||
if (keystroke.m_data.m_group.m_absolute) {
|
||||
|
||||
@ -265,7 +265,7 @@ bool XWindowsKeyState::setCurrentLanguageWithDBus(int32_t group) const
|
||||
void XWindowsKeyState::fakeKey(const Keystroke &keystroke)
|
||||
{
|
||||
switch (keystroke.m_type) {
|
||||
case Keystroke::kButton:
|
||||
case Keystroke::KeyType::Button:
|
||||
if (keystroke.m_data.m_button.m_repeat) {
|
||||
int c = keystroke.m_data.m_button.m_button;
|
||||
int i = (c >> 3);
|
||||
@ -281,7 +281,7 @@ void XWindowsKeyState::fakeKey(const Keystroke &keystroke)
|
||||
);
|
||||
break;
|
||||
|
||||
case Keystroke::kGroup:
|
||||
case Keystroke::KeyType::Group:
|
||||
if (keystroke.m_data.m_group.m_restore) {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -290,7 +290,7 @@ TEST(KeyStateTests, fakeKeyRepeat_validKey_returnsTrue)
|
||||
MockEventQueue eventQueue;
|
||||
KeyStateImpl keyState(eventQueue, keyMap);
|
||||
s_stubKeyItem.m_client = 0;
|
||||
s_stubKeystroke.m_type = deskflow::KeyMap::Keystroke::kButton;
|
||||
s_stubKeystroke.m_type = deskflow::KeyMap::Keystroke::KeyType::Button;
|
||||
s_stubKeystroke.m_data.m_button.m_button = 2;
|
||||
|
||||
// set the button to 1 for fakeKeyDown call
|
||||
|
||||
Reference in New Issue
Block a user