From b62a4fde2887ece011a0f5d993f57beaf2d7cd47 Mon Sep 17 00:00:00 2001 From: oneshinyboi Date: Mon, 27 Jul 2026 00:04:27 -0500 Subject: [PATCH] preserve pointer mods while swiping --- wayvr/src/overlays/keyboard/mod.rs | 9 +++++++-- wayvr/src/overlays/keyboard/swipe_type.rs | 16 ++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/wayvr/src/overlays/keyboard/mod.rs b/wayvr/src/overlays/keyboard/mod.rs index 88aabb09..eb3e7b9a 100644 --- a/wayvr/src/overlays/keyboard/mod.rs +++ b/wayvr/src/overlays/keyboard/mod.rs @@ -481,7 +481,7 @@ fn handle_mouse_motion( if pos.x >= 0.0 && pos.x <= 1.0 && pos.y >= 0.0 && pos.y <= 1.0 { if let Some(label) = key_label.first() { - swipe_manager.add_swipe(pos, label.chars().next().unwrap_or_default(), device); + swipe_manager.add_swipe(pos, label.chars().next().unwrap_or_default(), device, None); } } } @@ -509,7 +509,7 @@ fn handle_press( { if let Some(pos) = within_key_pos { if let Some(label) = key_label.first() { - swipe_manager.add_swipe(pos, label.chars().next().unwrap_or_default(), device); + swipe_manager.add_swipe(pos, label.chars().next().unwrap_or_default(), device, Some(button.index)); } } } @@ -570,6 +570,11 @@ fn handle_release(app: &mut AppState, key: &KeyState, k_cap_type: &KeyCapType, k } } else { // pointer must have been released on the same key it was pressed on + keyboard.modifiers |= match swipe_manager.current_swipe_mouse_button_index() { + Some(MouseButtonIndex::Right) => SHIFT, + Some(MouseButtonIndex::Middle) => keyboard.alt_modifier, + _ => 0, + }; swipe_manager.reset(); // drop swipe tracking that was started on press app.hid_provider diff --git a/wayvr/src/overlays/keyboard/swipe_type.rs b/wayvr/src/overlays/keyboard/swipe_type.rs index b4b24757..aab67af3 100644 --- a/wayvr/src/overlays/keyboard/swipe_type.rs +++ b/wayvr/src/overlays/keyboard/swipe_type.rs @@ -10,7 +10,7 @@ use std::time::Instant; use super_swipe_type::keyboard_manager::QwertyKeyboardGrid; use super_swipe_type::swipe_orchestrator::SwipeOrchestrator; use super_swipe_type::{SwipePoint}; -use wgui::event::DeviceBitmask; +use wgui::event::{DeviceBitmask, MouseButtonIndex}; use crate::subsystem::input::InputFocus; const PREDICTION_SUGGESTION_COUNT: usize = 5; @@ -34,6 +34,7 @@ pub struct SwipeTypingManager { swipe_left_first_key: bool, first_swipe_char: char, current_swipe_device: Option, + current_swipe_mouse_button_index: Option, last_swiped_word: Option, } @@ -134,6 +135,7 @@ impl SwipeTypingManager { swipe_left_first_key: false, first_swipe_char: char::default(), current_swipe_device: None, + current_swipe_mouse_button_index: None, last_swiped_word: None, }, candidate_receiver, @@ -170,13 +172,15 @@ impl SwipeTypingManager { self.first_swipe_char = char::default(); self.swipe_left_first_key = false; self.current_swipe_device = None; + self.current_swipe_mouse_button_index = None; } - fn start_swipe(&mut self, key_label: char, device: DeviceBitmask) -> Instant { + fn start_swipe(&mut self, key_label: char, device: DeviceBitmask, index: Option) -> Instant { let now = Instant::now(); self.swipe_start_time = Some(now); self.first_swipe_char = key_label.to_ascii_lowercase(); self.current_swipe_device = Some(device); + self.current_swipe_mouse_button_index = index; now } @@ -187,8 +191,12 @@ impl SwipeTypingManager { pub fn is_current_swipe_empty(&self) -> bool { self.current_swipe.is_empty() } + + pub fn current_swipe_mouse_button_index(&self) -> Option { + self.current_swipe_mouse_button_index + } - pub fn add_swipe(&mut self, within_key_pos_normalized: &Vec2, key_label: char, device: DeviceBitmask) { + pub fn add_swipe(&mut self, within_key_pos_normalized: &Vec2, key_label: char, device: DeviceBitmask, index: Option) { if let Some(pos) = self.keyboard_gird.key_positions.get(&key_label.to_ascii_lowercase()) { if let Some(current_device) = self.current_swipe_device { if current_device != device { @@ -209,7 +217,7 @@ impl SwipeTypingManager { let start_time = match self.swipe_start_time { Some(time) => time, - None => self.start_swipe(key_label, device), + None => self.start_swipe(key_label, device, index), }; let within_key_pos_from_center = Vec2 {