fix: add focus click with hold time before drag to activate target window
This commit is contained in:
3 files changed
+17
-3
No files matched your search
Generated
+1
-1
@@ -196,7 +196,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mousefree"
|
name = "mousefree"
|
||||||
version = "1.0.2"
|
version = "1.0.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"fontdue",
|
"fontdue",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "mousefree"
|
name = "mousefree"
|
||||||
version = "1.0.2"
|
version = "1.0.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
description = "Keyboard-driven mouse navigation for Wayland"
|
description = "Keyboard-driven mouse navigation for Wayland"
|
||||||
|
|||||||
+15
-1
@@ -43,6 +43,8 @@ const MOD_ALT: u32 = 8;
|
|||||||
|
|
||||||
// Drag animation timing.
|
// Drag animation timing.
|
||||||
const DRAG_SETTLE_MS: u64 = 25;
|
const DRAG_SETTLE_MS: u64 = 25;
|
||||||
|
const DRAG_FOCUS_CLICK_HOLD_MS: u64 = 50;
|
||||||
|
const DRAG_FOCUS_CLICK_PAUSE_MS: u64 = 500;
|
||||||
const DRAG_PRESS_SETTLE_MS: u64 = 60;
|
const DRAG_PRESS_SETTLE_MS: u64 = 60;
|
||||||
const DRAG_INTERP_STEPS: u32 = 12;
|
const DRAG_INTERP_STEPS: u32 = 12;
|
||||||
const DRAG_STEP_DELAY_MS: u64 = 2;
|
const DRAG_STEP_DELAY_MS: u64 = 2;
|
||||||
@@ -311,11 +313,23 @@ impl WaylandBackend {
|
|||||||
self.teardown_surface()?;
|
self.teardown_surface()?;
|
||||||
let (sw, sh) = (self.state.screen_w, self.state.screen_h);
|
let (sw, sh) = (self.state.screen_w, self.state.screen_h);
|
||||||
|
|
||||||
// 1. Move to the drag origin and let focus settle.
|
// 1. Click at the drag origin to activate/focus the target window.
|
||||||
|
// Without this, apps like zellij ignore the drag because the
|
||||||
|
// surface isn't activated yet.
|
||||||
self.send_motion(x1, y1, sw, sh)?;
|
self.send_motion(x1, y1, sw, sh)?;
|
||||||
self.roundtrip("motion to drag start")?;
|
self.roundtrip("motion to drag start")?;
|
||||||
sleep(Duration::from_millis(DRAG_SETTLE_MS));
|
sleep(Duration::from_millis(DRAG_SETTLE_MS));
|
||||||
|
|
||||||
|
self.send_button(BTN_LEFT, ButtonState::Pressed)?;
|
||||||
|
self.roundtrip("focus click press")?;
|
||||||
|
sleep(Duration::from_millis(DRAG_FOCUS_CLICK_HOLD_MS));
|
||||||
|
self.send_button(BTN_LEFT, ButtonState::Released)?;
|
||||||
|
self.roundtrip("focus click release")?;
|
||||||
|
|
||||||
|
// Wait past the double-click window so the focus click and the
|
||||||
|
// upcoming press-and-hold are never interpreted as a double-click.
|
||||||
|
sleep(Duration::from_millis(DRAG_FOCUS_CLICK_PAUSE_MS));
|
||||||
|
|
||||||
// 2. Press and hold — give the app time to register the press.
|
// 2. Press and hold — give the app time to register the press.
|
||||||
self.send_button(BTN_LEFT, ButtonState::Pressed)?;
|
self.send_button(BTN_LEFT, ButtonState::Pressed)?;
|
||||||
self.roundtrip("press at drag start")?;
|
self.roundtrip("press at drag start")?;
|
||||||
|
|||||||
Reference in new issue
Block a user