refactor: remove anon enum in IKeyState and replace with static s_numButtons
This commit is contained in:
committed by
Chris Rizzitello
parent
422b4c3a23
commit
b9964b5e90
@ -24,11 +24,7 @@ class IKeyState : public IInterface
|
||||
{
|
||||
public:
|
||||
explicit IKeyState(const IEventQueue *events);
|
||||
|
||||
enum
|
||||
{
|
||||
kNumButtons = 0x200
|
||||
};
|
||||
inline static const auto s_numButtons = 0x200;
|
||||
|
||||
//! Key event data
|
||||
class KeyInfo
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
#include <iterator>
|
||||
#include <list>
|
||||
|
||||
static const KeyButton kButtonMask = (KeyButton)(IKeyState::kNumButtons - 1);
|
||||
static const KeyButton kButtonMask = (KeyButton)(IKeyState::s_numButtons - 1);
|
||||
|
||||
static const KeyID s_decomposeTable[] = {
|
||||
// spacing version of dead keys
|
||||
@ -943,7 +943,7 @@ bool KeyState::fakeKeyUp(KeyButton serverID)
|
||||
void KeyState::fakeAllKeysUp()
|
||||
{
|
||||
Keystrokes keys;
|
||||
for (KeyButton i = 0; i < IKeyState::kNumButtons; ++i) {
|
||||
for (KeyButton i = 0; i < IKeyState::s_numButtons; ++i) {
|
||||
if (m_syntheticKeys[i] > 0) {
|
||||
keys.push_back(Keystroke(i, false, false, m_keyClientData[i]));
|
||||
m_keys[i] = 0;
|
||||
|
||||
@ -204,20 +204,20 @@ private:
|
||||
// current keyboard state (> 0 if pressed, 0 otherwise). this is
|
||||
// initialized to the keyboard state according to the system then
|
||||
// it tracks synthesized events.
|
||||
int32_t m_keys[kNumButtons];
|
||||
int32_t m_keys[s_numButtons];
|
||||
|
||||
// synthetic keyboard state (> 0 if pressed, 0 otherwise). this
|
||||
// tracks the synthesized keyboard state. if m_keys[n] > 0 but
|
||||
// m_syntheticKeys[n] == 0 then the key was pressed locally and
|
||||
// not synthesized yet.
|
||||
int32_t m_syntheticKeys[kNumButtons];
|
||||
int32_t m_syntheticKeys[s_numButtons];
|
||||
|
||||
// client data for each pressed key
|
||||
uint32_t m_keyClientData[kNumButtons];
|
||||
uint32_t m_keyClientData[s_numButtons];
|
||||
|
||||
// server keyboard state. an entry is 0 if not the key isn't pressed
|
||||
// otherwise it's the local KeyButton synthesized for the server key.
|
||||
KeyButton m_serverKeys[kNumButtons];
|
||||
KeyButton m_serverKeys[s_numButtons];
|
||||
|
||||
IEventQueue *m_events;
|
||||
|
||||
|
||||
@ -302,7 +302,7 @@ void MSWindowsScreen::leave()
|
||||
m_hook.setMode(kHOOK_RELAY_EVENTS);
|
||||
|
||||
m_primaryKeyDownList.clear();
|
||||
for (KeyButton i = 0; i < IKeyState::kNumButtons; ++i) {
|
||||
for (KeyButton i = 0; i < IKeyState::s_numButtons; ++i) {
|
||||
if (m_keyState->isKeyDown(i)) {
|
||||
m_primaryKeyDownList.push_back(i);
|
||||
LOG((CLOG_DEBUG1 "key button %d is down before leaving to another screen", i));
|
||||
@ -1549,10 +1549,10 @@ bool MSWindowsScreen::mapPressFromEvent(WPARAM msg, LPARAM) const
|
||||
void MSWindowsScreen::updateKeysCB(void *)
|
||||
{
|
||||
// record which keys we think are down
|
||||
bool down[IKeyState::kNumButtons];
|
||||
bool down[IKeyState::s_numButtons];
|
||||
bool sendFixes = (isPrimary() && !m_isOnScreen);
|
||||
if (sendFixes) {
|
||||
for (KeyButton i = 0; i < IKeyState::kNumButtons; ++i) {
|
||||
for (KeyButton i = 0; i < IKeyState::s_numButtons; ++i) {
|
||||
down[i] = m_keyState->isKeyDown(i);
|
||||
}
|
||||
}
|
||||
@ -1569,7 +1569,7 @@ void MSWindowsScreen::updateKeysCB(void *)
|
||||
// send key releases for these keys to the active client.
|
||||
if (sendFixes) {
|
||||
KeyModifierMask mask = pollActiveModifiers();
|
||||
for (KeyButton i = 0; i < IKeyState::kNumButtons; ++i) {
|
||||
for (KeyButton i = 0; i < IKeyState::s_numButtons; ++i) {
|
||||
if (down[i] && !m_keyState->isKeyDown(i)) {
|
||||
m_keyState->sendKeyEvent(getEventTarget(), false, false, kKeyNone, mask, 1, i);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user