feat: support track pad scroll on flutter
This commit is contained in:
@@ -1572,9 +1572,14 @@ pub async fn handle_test_delay(t: TestDelay, peer: &mut Stream) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether is track pad scrolling.
|
||||
#[inline]
|
||||
#[cfg(all(target_os = "macos", not(feature = "flutter")))]
|
||||
#[cfg(all(target_os = "macos"))]
|
||||
fn check_scroll_on_mac(mask: i32, x: i32, y: i32) -> bool {
|
||||
// flutter version we set mask type bit to 4 when track pad scrolling.
|
||||
if mask & 7 == 4 {
|
||||
return true;
|
||||
}
|
||||
if mask & 3 != 3 {
|
||||
return false;
|
||||
}
|
||||
@@ -1597,7 +1602,7 @@ fn check_scroll_on_mac(mask: i32, x: i32, y: i32) -> bool {
|
||||
///
|
||||
/// * `mask` - Mouse event.
|
||||
/// * mask = buttons << 3 | type
|
||||
/// * type, 1: down, 2: up, 3: wheel
|
||||
/// * type, 1: down, 2: up, 3: wheel, 4: trackpad
|
||||
/// * buttons, 1: left, 2: right, 4: middle
|
||||
/// * `x` - X coordinate.
|
||||
/// * `y` - Y coordinate.
|
||||
@@ -1636,7 +1641,7 @@ pub fn send_mouse(
|
||||
if command {
|
||||
mouse_event.modifiers.push(ControlKey::Meta.into());
|
||||
}
|
||||
#[cfg(all(target_os = "macos", not(feature = "flutter")))]
|
||||
#[cfg(all(target_os = "macos"))]
|
||||
if check_scroll_on_mac(mask, x, y) {
|
||||
mouse_event.modifiers.push(ControlKey::Scroll.into());
|
||||
}
|
||||
|
||||
@@ -156,6 +156,7 @@ pub fn session_reconnect(id: String) {
|
||||
|
||||
pub fn session_toggle_option(id: String, value: String) {
|
||||
if let Some(session) = SESSIONS.write().unwrap().get_mut(&id) {
|
||||
log::warn!("toggle option {}", value);
|
||||
session.toggle_option(value);
|
||||
}
|
||||
}
|
||||
@@ -907,6 +908,7 @@ pub fn session_send_mouse(id: String, msg: String) {
|
||||
"down" => 1,
|
||||
"up" => 2,
|
||||
"wheel" => 3,
|
||||
"trackpad" => 4,
|
||||
_ => 0,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -513,7 +513,7 @@ pub fn handle_mouse_(evt: &MouseEvent) {
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
3 => {
|
||||
3 | 4 => {
|
||||
#[allow(unused_mut)]
|
||||
let mut x = evt.x;
|
||||
#[allow(unused_mut)]
|
||||
|
||||
Reference in New Issue
Block a user