[fix] support selective mouse button release across desktop platforms

This commit is contained in:
dijunkun
2026-10-22 16:10:34 +08:00
parent f6a2637540
commit 5e494bfa3b
10 changed files with 115 additions and 21 deletions
+7 -2
View File
@@ -111,12 +111,17 @@ bool Input::Apply(const RemoteAction& action) {
bool Input::Release() {
for (const auto& change : ReconcileKeyboardState(keys_, {}))
Key({change.key_code, change.scan_code, change.extended}, false);
for (int button = 0; button < 3; ++button)
if (buttons_ & (1u << button)) Pointer(2 + button * 2, x_, y_, 0);
ReleaseMouseButtons(7);
// Failed releases remain pending so a later cleanup can retry them.
have_key_sequence_ = false;
return keys_.empty() && buttons_ == 0;
}
unsigned Input::ReleaseMouseButtons(unsigned mask) {
mask &= 7;
for (int button = 0; button < 3; ++button)
if (buttons_ & mask & (1u << button)) Pointer(2 + button * 2, x_, y_, 0);
return mask & ~buttons_;
}
bool Input::LockWorkstation() {
// The public Harmony shortcut is Meta+L. Never carry a prior remote drag or
// modifier into it, and retain failed releases for the normal cleanup path.
+1
View File
@@ -16,6 +16,7 @@ class Input {
bool Configure(int width, int height, int display);
bool Apply(const RemoteAction& action);
bool Release();
unsigned ReleaseMouseButtons(unsigned mask);
bool LockWorkstation();
private:
bool Key(const KeyboardKey& key, bool down);