Skip to content

Commit 9ebd0c4

Browse files
authored
Merge pull request #775 from multiplex55/codex/decide-on-require_button-implementation-or-removal
Remove `require_button`, add `debug_logging`, default no-match to pass-through, and update tests/UI
2 parents 6fe19d4 + 6405cb6 commit 9ebd0c4

4 files changed

Lines changed: 19 additions & 13 deletions

File tree

src/gui/mouse_gesture_settings_dialog.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,7 @@ impl MouseGestureSettingsDialog {
118118
let mut changed = false;
119119
changed |= ui.checkbox(&mut self.settings.enabled, "Enable mouse gestures").changed();
120120
changed |= ui
121-
.checkbox(
122-
&mut self.settings.require_button,
123-
"Require trigger button to be held",
124-
)
121+
.checkbox(&mut self.settings.debug_logging, "Enable debug logging")
125122
.changed();
126123

127124
ui.separator();
@@ -247,6 +244,7 @@ impl MouseGestureSettingsDialog {
247244
.changed();
248245
});
249246
});
247+
ui.small("Fallback runs when a gesture does not match; default is pass-through right-click.");
250248

251249
if changed {
252250
self.dirty = true;

src/mouse_gestures/service.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use std::time::{Duration, Instant};
2020
#[derive(Debug, Clone, PartialEq)]
2121
pub struct MouseGestureConfig {
2222
pub enabled: bool,
23+
pub debug_logging: bool,
2324
pub trail_interval_ms: u64,
2425
pub recognition_interval_ms: u64,
2526
pub deadzone_px: f32,
@@ -44,6 +45,7 @@ impl Default for MouseGestureConfig {
4445
fn default() -> Self {
4546
Self {
4647
enabled: false,
48+
debug_logging: false,
4749
trail_interval_ms: 16,
4850
recognition_interval_ms: 40,
4951
deadzone_px: 12.0,
@@ -59,7 +61,7 @@ impl Default for MouseGestureConfig {
5961
long_threshold_y: 30.0,
6062
max_tokens: 10,
6163
cancel_behavior: CancelBehavior::DoNothing,
62-
no_match_behavior: NoMatchBehavior::DoNothing,
64+
no_match_behavior: NoMatchBehavior::PassThroughClick,
6365
wheel_cycle_gate: WheelCycleGate::Deadzone,
6466
practice_mode: false,
6567
}
@@ -432,6 +434,9 @@ fn worker_loop(
432434
let _ = tracker.feed_point(cursor_pos, ms);
433435

434436
let tokens = tracker.tokens_string();
437+
if config.debug_logging {
438+
tracing::debug!(tokens = %tokens, "mouse gesture tokens");
439+
}
435440

436441
// If we produced any tokens, treat it as a gesture (swallow right click).
437442
if !tokens.is_empty() {

src/plugins/mouse_gestures.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ const PLUGIN_NAME: &str = "mouse_gestures";
2424
pub struct MouseGestureSettings {
2525
#[serde(default = "default_enabled")]
2626
pub enabled: bool,
27-
#[serde(default = "default_require_button")]
28-
pub require_button: bool,
27+
#[serde(default = "default_debug_logging")]
28+
pub debug_logging: bool,
2929
#[serde(default = "default_show_trail")]
3030
pub show_trail: bool,
3131
#[serde(default = "default_trail_color")]
@@ -52,7 +52,7 @@ impl Default for MouseGestureSettings {
5252
fn default() -> Self {
5353
Self {
5454
enabled: default_enabled(),
55-
require_button: default_require_button(),
55+
debug_logging: default_debug_logging(),
5656
show_trail: default_show_trail(),
5757
trail_color: default_trail_color(),
5858
trail_width: default_trail_width(),
@@ -71,8 +71,8 @@ fn default_enabled() -> bool {
7171
true
7272
}
7373

74-
fn default_require_button() -> bool {
75-
true
74+
fn default_debug_logging() -> bool {
75+
false
7676
}
7777

7878
fn default_show_trail() -> bool {
@@ -104,7 +104,7 @@ fn default_cancel_behavior() -> CancelBehavior {
104104
}
105105

106106
fn default_no_match_behavior() -> NoMatchBehavior {
107-
NoMatchBehavior::DoNothing
107+
NoMatchBehavior::PassThroughClick
108108
}
109109

110110
fn default_wheel_cycle_gate() -> WheelCycleGate {
@@ -161,6 +161,7 @@ impl MouseGestureRuntime {
161161
fn apply(&self) {
162162
let mut config = MouseGestureConfig::default();
163163
config.enabled = self.settings.enabled && self.plugin_enabled;
164+
config.debug_logging = self.settings.debug_logging;
164165
config.trail_start_move_px = self.settings.trail_start_move_px;
165166
config.show_trail = self.settings.show_trail;
166167
config.trail_color = self.settings.trail_color;
@@ -465,7 +466,7 @@ impl Plugin for MouseGesturesPlugin {
465466
.checkbox(&mut cfg.enabled, "Enable mouse gestures")
466467
.changed();
467468
changed |= ui
468-
.checkbox(&mut cfg.require_button, "Require gesture button held")
469+
.checkbox(&mut cfg.debug_logging, "Enable debug logging")
469470
.changed();
470471

471472
changed |= ui
@@ -571,6 +572,7 @@ impl Plugin for MouseGesturesPlugin {
571572
.changed();
572573
});
573574
});
575+
ui.small("Fallback runs when a gesture does not match; default is pass-through right-click.");
574576

575577
// Only write+apply when something changed.
576578
if changed {

tests/mouse_gestures_plugin.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ fn mouse_gestures_settings_ignore_legacy_fields() {
5656
let value = serde_json::json!({
5757
"enabled": true,
5858
"require_button": false,
59+
"debug_logging": true,
5960
"show_trail": true,
6061
"trail_color": [255, 0, 0, 255],
6162
"trail_width": 2.0,
@@ -70,5 +71,5 @@ fn mouse_gestures_settings_ignore_legacy_fields() {
7071
let parsed: MouseGestureSettings =
7172
serde_json::from_value(value).expect("deserialize legacy settings");
7273
assert!(parsed.enabled);
73-
assert!(!parsed.require_button);
74+
assert!(parsed.debug_logging);
7475
}

0 commit comments

Comments
 (0)