mirror of
https://github.com/debauchee/barrier.git
synced 2026-07-05 19:36:16 +08:00
Used MouseKeys accessibility function to show the mouse cursor
on a secondary screen when there's no physical mouse attached to the system. Kinda flaky when a mouse is attached or detached but seems to work well enough when the device is not attached to start with and not attached while running synergy.
This commit is contained in:
@@ -80,6 +80,12 @@ public:
|
||||
|
||||
// IKeyState overrides
|
||||
virtual void updateKeys();
|
||||
virtual void fakeKeyDown(KeyID id, KeyModifierMask mask,
|
||||
KeyButton button);
|
||||
virtual void fakeKeyRepeat(KeyID id, KeyModifierMask mask,
|
||||
SInt32 count, KeyButton button);
|
||||
virtual void fakeKeyUp(KeyButton button);
|
||||
virtual void fakeToggle(KeyModifierMask modifier);
|
||||
|
||||
// IPlatformScreen overrides
|
||||
virtual void enable();
|
||||
@@ -174,6 +180,16 @@ private:
|
||||
// job to update the key state
|
||||
void updateKeysCB(void*);
|
||||
|
||||
// determine whether the mouse is hidden by the system and force
|
||||
// it to be displayed if user has entered this secondary screen.
|
||||
void forceShowCursor();
|
||||
|
||||
// forceShowCursor uses MouseKeys to show the cursor. since we
|
||||
// don't actually want MouseKeys behavior we have to make sure
|
||||
// it applies when NumLock is in whatever state it's not in now.
|
||||
// this method does that.
|
||||
void updateForceShowCursor();
|
||||
|
||||
// our window proc
|
||||
static LRESULT CALLBACK wndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
@@ -250,6 +266,23 @@ private:
|
||||
IJob* m_suspend;
|
||||
IJob* m_resume;
|
||||
|
||||
// the system shows the mouse cursor when an internal display count
|
||||
// is >= 0. this count is maintained per application but there's
|
||||
// apparently a system wide count added to the application's count.
|
||||
// this system count is 0 if there's a mouse attached to the system
|
||||
// and -1 otherwise. the MouseKeys accessibility feature can modify
|
||||
// this system count by making the system appear to have a mouse.
|
||||
//
|
||||
// m_hasMouse is true iff there's a mouse attached to the system or
|
||||
// MouseKeys is simulating one. we track this so we can force the
|
||||
// cursor to be displayed when the user has entered this screen.
|
||||
// m_showingMouse is true when we're doing that.
|
||||
bool m_hasMouse;
|
||||
bool m_showingMouse;
|
||||
bool m_gotOldMouseKeys;
|
||||
MOUSEKEYS m_mouseKeys;
|
||||
MOUSEKEYS m_oldMouseKeys;
|
||||
|
||||
static CMSWindowsScreen* s_screen;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user