Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/gui/mouse_gesture_settings_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,7 @@ impl MouseGestureSettingsDialog {
let mut changed = false;
changed |= ui.checkbox(&mut self.settings.enabled, "Enable mouse gestures").changed();
changed |= ui
.checkbox(
&mut self.settings.require_button,
"Require trigger button to be held",
)
.checkbox(&mut self.settings.debug_logging, "Enable debug logging")
.changed();

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

if changed {
self.dirty = true;
Expand Down
7 changes: 6 additions & 1 deletion src/mouse_gestures/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use std::time::{Duration, Instant};
#[derive(Debug, Clone, PartialEq)]
pub struct MouseGestureConfig {
pub enabled: bool,
pub debug_logging: bool,
pub trail_interval_ms: u64,
pub recognition_interval_ms: u64,
pub deadzone_px: f32,
Expand All @@ -44,6 +45,7 @@ impl Default for MouseGestureConfig {
fn default() -> Self {
Self {
enabled: false,
debug_logging: false,
trail_interval_ms: 16,
recognition_interval_ms: 40,
deadzone_px: 12.0,
Expand All @@ -59,7 +61,7 @@ impl Default for MouseGestureConfig {
long_threshold_y: 30.0,
max_tokens: 10,
cancel_behavior: CancelBehavior::DoNothing,
no_match_behavior: NoMatchBehavior::DoNothing,
no_match_behavior: NoMatchBehavior::PassThroughClick,
wheel_cycle_gate: WheelCycleGate::Deadzone,
practice_mode: false,
}
Expand Down Expand Up @@ -432,6 +434,9 @@ fn worker_loop(
let _ = tracker.feed_point(cursor_pos, ms);

let tokens = tracker.tokens_string();
if config.debug_logging {
tracing::debug!(tokens = %tokens, "mouse gesture tokens");
}

// If we produced any tokens, treat it as a gesture (swallow right click).
if !tokens.is_empty() {
Expand Down
16 changes: 9 additions & 7 deletions src/plugins/mouse_gestures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ const PLUGIN_NAME: &str = "mouse_gestures";
pub struct MouseGestureSettings {
#[serde(default = "default_enabled")]
pub enabled: bool,
#[serde(default = "default_require_button")]
pub require_button: bool,
#[serde(default = "default_debug_logging")]
pub debug_logging: bool,
#[serde(default = "default_show_trail")]
pub show_trail: bool,
#[serde(default = "default_trail_color")]
Expand All @@ -52,7 +52,7 @@ impl Default for MouseGestureSettings {
fn default() -> Self {
Self {
enabled: default_enabled(),
require_button: default_require_button(),
debug_logging: default_debug_logging(),
show_trail: default_show_trail(),
trail_color: default_trail_color(),
trail_width: default_trail_width(),
Expand All @@ -71,8 +71,8 @@ fn default_enabled() -> bool {
true
}

fn default_require_button() -> bool {
true
fn default_debug_logging() -> bool {
false
}

fn default_show_trail() -> bool {
Expand Down Expand Up @@ -104,7 +104,7 @@ fn default_cancel_behavior() -> CancelBehavior {
}

fn default_no_match_behavior() -> NoMatchBehavior {
NoMatchBehavior::DoNothing
NoMatchBehavior::PassThroughClick
}

fn default_wheel_cycle_gate() -> WheelCycleGate {
Expand Down Expand Up @@ -161,6 +161,7 @@ impl MouseGestureRuntime {
fn apply(&self) {
let mut config = MouseGestureConfig::default();
config.enabled = self.settings.enabled && self.plugin_enabled;
config.debug_logging = self.settings.debug_logging;
config.trail_start_move_px = self.settings.trail_start_move_px;
config.show_trail = self.settings.show_trail;
config.trail_color = self.settings.trail_color;
Expand Down Expand Up @@ -465,7 +466,7 @@ impl Plugin for MouseGesturesPlugin {
.checkbox(&mut cfg.enabled, "Enable mouse gestures")
.changed();
changed |= ui
.checkbox(&mut cfg.require_button, "Require gesture button held")
.checkbox(&mut cfg.debug_logging, "Enable debug logging")
.changed();

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

// Only write+apply when something changed.
if changed {
Expand Down
3 changes: 2 additions & 1 deletion tests/mouse_gestures_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ fn mouse_gestures_settings_ignore_legacy_fields() {
let value = serde_json::json!({
"enabled": true,
"require_button": false,
"debug_logging": true,
"show_trail": true,
"trail_color": [255, 0, 0, 255],
"trail_width": 2.0,
Expand All @@ -70,5 +71,5 @@ fn mouse_gestures_settings_ignore_legacy_fields() {
let parsed: MouseGestureSettings =
serde_json::from_value(value).expect("deserialize legacy settings");
assert!(parsed.enabled);
assert!(!parsed.require_button);
assert!(parsed.debug_logging);
}