From e37cea2d6b2ff9050d027c90f136949b063992cb Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Tue, 8 Jul 2025 14:19:40 -0400 Subject: [PATCH] refactor: replace anon Enum in XWindowsKeyState with static vars --- src/lib/platform/XWindowsKeyState.cpp | 6 +++--- src/lib/platform/XWindowsKeyState.h | 11 ++++------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/lib/platform/XWindowsKeyState.cpp b/src/lib/platform/XWindowsKeyState.cpp index 8f956f983..4401ff329 100644 --- a/src/lib/platform/XWindowsKeyState.cpp +++ b/src/lib/platform/XWindowsKeyState.cpp @@ -71,17 +71,17 @@ void XWindowsKeyState::init(const Display *display, bool useXKB) m_xkb = nullptr; } #endif - setActiveGroup(kGroupPoll); + setActiveGroup(s_groupPoll); } void XWindowsKeyState::setActiveGroup(int32_t group) { - if (group == kGroupPollAndSet) { + if (group == s_groupPollAndSet) { // we need to set the group to -1 in order for pollActiveGroup() to // actually poll for the group m_group = -1; m_group = pollActiveGroup(); - } else if (group == kGroupPoll) { + } else if (group == s_groupPoll) { m_group = -1; } else { assert(group >= 0); diff --git a/src/lib/platform/XWindowsKeyState.h b/src/lib/platform/XWindowsKeyState.h index ad485d025..d387b6afe 100644 --- a/src/lib/platform/XWindowsKeyState.h +++ b/src/lib/platform/XWindowsKeyState.h @@ -32,11 +32,8 @@ class XWindowsKeyState : public KeyState { public: using KeycodeList = std::vector; - enum - { - kGroupPoll = -1, - kGroupPollAndSet = -2 - }; + inline static const auto s_groupPoll = -1; + inline static const auto s_groupPollAndSet = -2; XWindowsKeyState(Display *, bool useXKB, IEventQueue *events); XWindowsKeyState(Display *, bool useXKB, IEventQueue *events, deskflow::KeyMap &keyMap); @@ -48,9 +45,9 @@ public: //! Set active group /*! Sets the active group to \p group. This is the group returned by - \c pollActiveGroup(). If \p group is \c kGroupPoll then + \c pollActiveGroup(). If \p group is \c s_groupPoll then \c pollActiveGroup() will really poll, but that's a slow operation - on X11. If \p group is \c kGroupPollAndSet then this will poll the + on X11. If \p group is \c s_groupPollAndSet then this will poll the active group now and use it for future calls to \c pollActiveGroup(). */ void setActiveGroup(int32_t group);