mirror of https://github.com/jetkvm/kvm.git
Compare commits
1 Commits
eb22ff2ab9
...
93dbd280fb
| Author | SHA1 | Date |
|---|---|---|
|
|
93dbd280fb |
|
|
@ -1136,7 +1136,9 @@ func rpcDoExecuteKeyboardMacro(ctx context.Context, macro []hidrpc.KeyboardMacro
|
|||
|
||||
// don't report keyboard state changes while executing the macro
|
||||
gadget.SuspendKeyDownMessages()
|
||||
defer gadget.ResumeSuspendKeyDownMessages()
|
||||
defer func() {
|
||||
gadget.ResumeSuspendKeyDownMessages()
|
||||
}()
|
||||
|
||||
for i, step := range macro {
|
||||
delay := time.Duration(step.Delay) * time.Millisecond
|
||||
|
|
@ -1157,8 +1159,7 @@ func rpcDoExecuteKeyboardMacro(ctx context.Context, macro []hidrpc.KeyboardMacro
|
|||
case <-time.After(delay):
|
||||
// Sleep completed normally
|
||||
case <-ctx.Done():
|
||||
// make sure keyboard state is reset and the client gets notified
|
||||
gadget.ResumeSuspendKeyDownMessages()
|
||||
// make sure keyboard state is reset
|
||||
err := rpcKeyboardReport(0, keyboardClearStateKeys)
|
||||
if err != nil {
|
||||
logger.Warn().Err(err).Msg("failed to reset keyboard state")
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import { TextAreaWithLabel } from "@components/TextArea";
|
|||
|
||||
// uint32 max value / 4
|
||||
const pasteMaxLength = 1073741824;
|
||||
const defaultDelay = 20;
|
||||
|
||||
export default function PasteModal() {
|
||||
const TextAreaRef = useRef<HTMLTextAreaElement>(null);
|
||||
|
|
@ -28,10 +27,10 @@ export default function PasteModal() {
|
|||
const { executeMacro, cancelExecuteMacro } = useKeyboard();
|
||||
|
||||
const [invalidChars, setInvalidChars] = useState<string[]>([]);
|
||||
const [delayValue, setDelayValue] = useState(defaultDelay);
|
||||
const [delayValue, setDelayValue] = useState(20);
|
||||
const delay = useMemo(() => {
|
||||
if (delayValue < 0 || delayValue > 65534) {
|
||||
return defaultDelay;
|
||||
return 20;
|
||||
}
|
||||
return delayValue;
|
||||
}, [delayValue]);
|
||||
|
|
@ -41,7 +40,7 @@ export default function PasteModal() {
|
|||
const delayClassName = useMemo(() => debugMode ? "" : "hidden", [debugMode]);
|
||||
|
||||
const { setKeyboardLayout } = useSettingsStore();
|
||||
const { selectedKeyboard } = useKeyboardLayout();
|
||||
const { selectedKeyboard } = useKeyboardLayout();
|
||||
|
||||
useEffect(() => {
|
||||
send("getKeyboardLayout", {}, (resp: JsonRpcResponse) => {
|
||||
|
|
@ -195,11 +194,11 @@ export default function PasteModal() {
|
|||
setDelayValue(parseInt(e.target.value, 10));
|
||||
}}
|
||||
/>
|
||||
{delayValue < defaultDelay || delayValue > 65534 && (
|
||||
{delayValue < 0 || delayValue > 65534 && (
|
||||
<div className="mt-2 flex items-center gap-x-2">
|
||||
<ExclamationCircleIcon className="h-4 w-4 text-red-500 dark:text-red-400" />
|
||||
<span className="text-xs text-red-500 dark:text-red-400">
|
||||
Delay should be between 20 and 65534
|
||||
Delay must be between 0 and 65534
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
|
|
|
|||
Loading…
Reference in New Issue