refactor: Change mouse keys functions names to expose actual behavior

This commit is contained in:
Nick Bolton 2025-07-28 17:02:29 +01:00
parent db55c3f0e7
commit 9033198aed
2 changed files with 16 additions and 16 deletions

View file

@ -111,7 +111,7 @@ MSWindowsScreen::MSWindowsScreen(
updateScreenShape(); updateScreenShape();
m_class = createWindowClass(); m_class = createWindowClass();
m_window = createWindow(m_class, kAppName); m_window = createWindow(m_class, kAppName);
forceShowCursor(); setupMouseKeys();
LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d %s", m_x, m_y, m_w, m_h, m_multimon ? "(multi-monitor)" : "")); LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d %s", m_x, m_y, m_w, m_h, m_multimon ? "(multi-monitor)" : ""));
LOG((CLOG_DEBUG "window is 0x%08x", m_window)); LOG((CLOG_DEBUG "window is 0x%08x", m_window));
@ -225,7 +225,7 @@ void MSWindowsScreen::disable()
} }
m_isOnScreen = m_isPrimary; m_isOnScreen = m_isPrimary;
forceShowCursor(); setupMouseKeys();
} }
void MSWindowsScreen::enter() void MSWindowsScreen::enter()
@ -255,7 +255,7 @@ void MSWindowsScreen::enter()
// now on screen // now on screen
m_isOnScreen = true; m_isOnScreen = true;
forceShowCursor(); setupMouseKeys();
} }
bool MSWindowsScreen::canLeave() bool MSWindowsScreen::canLeave()
@ -312,7 +312,7 @@ void MSWindowsScreen::leave()
// now off screen // now off screen
m_isOnScreen = false; m_isOnScreen = false;
forceShowCursor(); setupMouseKeys();
} }
bool MSWindowsScreen::setClipboard(ClipboardID, const IClipboard *src) bool MSWindowsScreen::setClipboard(ClipboardID, const IClipboard *src)
@ -721,7 +721,7 @@ void MSWindowsScreen::updateKeys()
void MSWindowsScreen::fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, const std::string &lang) void MSWindowsScreen::fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, const std::string &lang)
{ {
PlatformScreen::fakeKeyDown(id, mask, button, lang); PlatformScreen::fakeKeyDown(id, mask, button, lang);
updateForceShowCursor(); updateMouseKeys();
} }
bool MSWindowsScreen::fakeKeyRepeat( bool MSWindowsScreen::fakeKeyRepeat(
@ -729,21 +729,21 @@ bool MSWindowsScreen::fakeKeyRepeat(
) )
{ {
bool result = PlatformScreen::fakeKeyRepeat(id, mask, count, button, lang); bool result = PlatformScreen::fakeKeyRepeat(id, mask, count, button, lang);
updateForceShowCursor(); updateMouseKeys();
return result; return result;
} }
bool MSWindowsScreen::fakeKeyUp(KeyButton button) bool MSWindowsScreen::fakeKeyUp(KeyButton button)
{ {
bool result = PlatformScreen::fakeKeyUp(button); bool result = PlatformScreen::fakeKeyUp(button);
updateForceShowCursor(); updateMouseKeys();
return result; return result;
} }
void MSWindowsScreen::fakeAllKeysUp() void MSWindowsScreen::fakeAllKeysUp()
{ {
PlatformScreen::fakeAllKeysUp(); PlatformScreen::fakeAllKeysUp();
updateForceShowCursor(); updateMouseKeys();
} }
HCURSOR HCURSOR
@ -980,12 +980,12 @@ bool MSWindowsScreen::onEvent(HWND, UINT msg, WPARAM wParam, LPARAM lParam, LRES
return true; return true;
case WM_DEVICECHANGE: case WM_DEVICECHANGE:
forceShowCursor(); setupMouseKeys();
break; break;
case WM_SETTINGCHANGE: case WM_SETTINGCHANGE:
if (wParam == SPI_SETMOUSEKEYS) { if (wParam == SPI_SETMOUSEKEYS) {
forceShowCursor(); setupMouseKeys();
} }
break; break;
} }
@ -1582,7 +1582,7 @@ void MSWindowsScreen::updateKeysCB(void *)
} }
} }
void MSWindowsScreen::forceShowCursor() void MSWindowsScreen::setupMouseKeys()
{ {
// check for mouse // check for mouse
m_hasMouse = (GetSystemMetrics(SM_MOUSEPRESENT) != 0); m_hasMouse = (GetSystemMetrics(SM_MOUSEPRESENT) != 0);
@ -1598,7 +1598,7 @@ void MSWindowsScreen::forceShowCursor()
if (m_gotOldMouseKeys) { if (m_gotOldMouseKeys) {
m_mouseKeys = m_oldMouseKeys; m_mouseKeys = m_oldMouseKeys;
m_showingMouse = true; m_showingMouse = true;
updateForceShowCursor(); updateMouseKeys();
} }
} else { } else {
if (m_gotOldMouseKeys) { if (m_gotOldMouseKeys) {
@ -1609,7 +1609,7 @@ void MSWindowsScreen::forceShowCursor()
} }
} }
void MSWindowsScreen::updateForceShowCursor() void MSWindowsScreen::updateMouseKeys()
{ {
DWORD oldFlags = m_mouseKeys.dwFlags; DWORD oldFlags = m_mouseKeys.dwFlags;

View file

@ -211,13 +211,13 @@ private: // HACK
// determine whether the mouse is hidden by the system and force // determine whether the mouse is hidden by the system and force
// it to be displayed if user has entered this secondary screen. // it to be displayed if user has entered this secondary screen.
void forceShowCursor(); void setupMouseKeys();
// forceShowCursor uses MouseKeys to show the cursor. since we // setupMouseKeys uses MouseKeys to show the cursor. since we
// don't actually want MouseKeys behavior we have to make sure // don't actually want MouseKeys behavior we have to make sure
// it applies when NumLock is in whatever state it's not in now. // it applies when NumLock is in whatever state it's not in now.
// this method does that. // this method does that.
void updateForceShowCursor(); void updateMouseKeys();
// our window proc // our window proc
static LRESULT CALLBACK wndProc(HWND, UINT, WPARAM, LPARAM); static LRESULT CALLBACK wndProc(HWND, UINT, WPARAM, LPARAM);