Fixed clicking location
Template tests / tests (push) Successful in 1m48s

This commit is contained in:
Iisyourdad
2026-06-11 16:00:01 -05:00
parent ec9371b43a
commit 646d6c4716
+9 -1
View File
@@ -424,7 +424,15 @@ class CaptureService {
this.clickWatcherButtonDown = false; this.clickWatcherButtonDown = false;
if (process.platform === 'linux' && hasBinary('xinput')) { if (process.platform === 'linux' && hasBinary('xinput')) {
// Stream raw button events from the X server; one capture per press. // Stream raw button events from the X server; one capture per press.
this.clickWatcher = spawn('xinput', ['test-xi2', '--root'], { stdio: ['ignore', 'pipe', 'ignore'] }); // xinput block-buffers stdout when piped, so a press event can sit
// in its buffer until later motion events flush it — by then the
// cursor read in onOsClick lands where the mouse moved *after* the
// click. stdbuf -oL forces line-buffering so events (and the cursor
// read) line up with the actual click instant.
const argv = hasBinary('stdbuf')
? ['stdbuf', '-oL', 'xinput', 'test-xi2', '--root']
: ['xinput', 'test-xi2', '--root'];
this.clickWatcher = spawn(argv[0], argv.slice(1), { stdio: ['ignore', 'pipe', 'ignore'] });
this.clickWatcher.stdout.on('data', (chunk) => { this.clickWatcher.stdout.on('data', (chunk) => {
this.processClickWatcherData(chunk.toString(), 'linux'); this.processClickWatcherData(chunk.toString(), 'linux');
}); });