[client/idd] input: avoid replaying absolute position
Some checks failed
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / module (push) Has been cancelled
build / host-linux (push) Has been cancelled
build / host-windows-cross (push) Has been cancelled
build / host-windows-native (push) Has been cancelled
build / idd (push) Has been cancelled
build / obs (clang) (push) Has been cancelled
build / obs (gcc) (push) Has been cancelled
build / docs (push) Has been cancelled

This commit is contained in:
Geoffrey McRae
2026-08-09 02:07:38 +10:00
parent c89c01ae5a
commit 4367fbc277
3 changed files with 60 additions and 50 deletions

View File

@@ -146,7 +146,7 @@ struct LGMPInput
struct LGMPInputStats stats;
};
static void buildKeyboardPayload(const LGMPInput * input,
static bool buildKeyboardPayload(const LGMPInput * input,
KVMFRInputPayload * payload);
static bool queueMouse(LGMPInput * input, enum LGMPInputMouseMode mode,
int32_t x, int32_t y, int32_t wheel, uint32_t buttons,
@@ -484,12 +484,6 @@ static bool inputStateHeld(const LGMPInput * input)
return false;
}
static bool inputStateActive(const LGMPInput * input)
{
return input->mouseMode == LGMP_INPUT_MOUSE_ABSOLUTE ||
inputStateHeld(input);
}
static void discardProtocolState(LGMPInput * input)
{
input->pendingHead = 0;
@@ -504,18 +498,19 @@ static void discardProtocolState(LGMPInput * input)
static bool restoreInputState(LGMPInput * input, bool * wake)
{
if (!inputStateActive(input))
if (!inputStateHeld(input))
return true;
if (!claim(input, wake))
return false;
KVMFRInputPayload keyboard = { 0 };
buildKeyboardPayload(input, &keyboard);
if (!queuePayload(input, KVMFR_INPUT_MESSAGE_KEYBOARD,
const bool keyboardHeld = buildKeyboardPayload(input, &keyboard);
if (keyboardHeld && !queuePayload(input, KVMFR_INPUT_MESSAGE_KEYBOARD,
&keyboard, false, wake))
return false;
if (input->mouseMode != LGMP_INPUT_MOUSE_NONE &&
if (input->mouseButtons &&
input->mouseMode != LGMP_INPUT_MOUSE_NONE &&
!queueMouse(input, input->mouseMode, 0, 0, 0,
input->mouseButtons, false, wake))
return false;
@@ -1087,26 +1082,32 @@ static void inputSetStatusListener(void * opaque,
callback(callbackOpaque, &status);
}
static void buildKeyboardPayload(const LGMPInput * input,
static bool buildKeyboardPayload(const LGMPInput * input,
KVMFRInputPayload * payload)
{
bool held = false;
for (unsigned usage = 224; usage <= 231; ++usage)
if (input->keyState[usage])
{
payload->keyboard.modifiers |= 1U << (usage - 224);
held = true;
}
unsigned count = 0;
for (unsigned usage = 1; usage < 224; ++usage)
{
if (!input->keyState[usage])
continue;
held = true;
if (count == KVMFR_INPUT_KEYBOARD_KEY_COUNT)
{
memset(payload->keyboard.keys, 1,
sizeof(payload->keyboard.keys));
return;
return true;
}
payload->keyboard.keys[count++] = (uint8_t)usage;
}
return held;
}
static bool updateKey(void * opaque, int key, bool pressed)