Merge pull request #4615 from fufesou/fix/trackpad_flutter_macos
debug, macos trackpad, flutter
This commit is contained in:
commit
8e398a5871
@ -614,11 +614,6 @@ impl Enigo {
|
|||||||
scroll_direction *= -1;
|
scroll_direction *= -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fix scroll distance for track pad
|
|
||||||
if is_track_pad {
|
|
||||||
length *= 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(src) = self.event_source.as_ref() {
|
if let Some(src) = self.event_source.as_ref() {
|
||||||
for _ in 0..length {
|
for _ in 0..length {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -53,7 +53,11 @@ use scrap::{
|
|||||||
ImageFormat, ImageRgb,
|
ImageFormat, ImageRgb,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::common::{self, is_keyboard_mode_supported};
|
use crate::common::{
|
||||||
|
self,
|
||||||
|
input::{MOUSE_TYPE_TRACKPAD, MOUSE_TYPE_WHEEL},
|
||||||
|
is_keyboard_mode_supported,
|
||||||
|
};
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
use crate::common::{check_clipboard, ClipboardContext, CLIPBOARD_INTERVAL};
|
use crate::common::{check_clipboard, ClipboardContext, CLIPBOARD_INTERVAL};
|
||||||
@ -1908,10 +1912,10 @@ pub async fn handle_test_delay(t: TestDelay, peer: &mut Stream) {
|
|||||||
#[cfg(all(target_os = "macos"))]
|
#[cfg(all(target_os = "macos"))]
|
||||||
fn check_scroll_on_mac(mask: i32, x: i32, y: i32) -> bool {
|
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.
|
// flutter version we set mask type bit to 4 when track pad scrolling.
|
||||||
if mask & 7 == 4 {
|
if mask & 7 == MOUSE_TYPE_TRACKPAD {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if mask & 3 != 3 {
|
if mask & 3 != MOUSE_TYPE_WHEEL {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let btn = mask >> 3;
|
let btn = mask >> 3;
|
||||||
@ -1972,9 +1976,12 @@ pub fn send_mouse(
|
|||||||
if command {
|
if command {
|
||||||
mouse_event.modifiers.push(ControlKey::Meta.into());
|
mouse_event.modifiers.push(ControlKey::Meta.into());
|
||||||
}
|
}
|
||||||
#[cfg(all(target_os = "macos"))]
|
#[cfg(all(target_os = "macos", not(feature = "flutter")))]
|
||||||
if check_scroll_on_mac(mask, x, y) {
|
if check_scroll_on_mac(mask, x, y) {
|
||||||
mouse_event.modifiers.push(ControlKey::Scroll.into());
|
let factor = 3;
|
||||||
|
mouse_event.mask = MOUSE_TYPE_TRACKPAD;
|
||||||
|
mouse_event.x *= factor;
|
||||||
|
mouse_event.y *= factor;
|
||||||
}
|
}
|
||||||
interface.swap_modifier_mouse(&mut mouse_event);
|
interface.swap_modifier_mouse(&mut mouse_event);
|
||||||
msg_out.set_mouse_event(mouse_event);
|
msg_out.set_mouse_event(mouse_event);
|
||||||
|
@ -835,12 +835,13 @@ pub fn handle_mouse_(evt: &MouseEvent, conn: i32) {
|
|||||||
x = -x;
|
x = -x;
|
||||||
y = -y;
|
y = -y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(target_os = "macos", target_os = "windows"))]
|
||||||
|
let is_track_pad = evt_type == MOUSE_TYPE_TRACKPAD;
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
{
|
{
|
||||||
// TODO: support track pad on win.
|
// TODO: support track pad on win.
|
||||||
let is_track_pad = evt
|
|
||||||
.modifiers
|
|
||||||
.contains(&EnumOrUnknown::new(ControlKey::Scroll));
|
|
||||||
|
|
||||||
// fix shift + scroll(down/up)
|
// fix shift + scroll(down/up)
|
||||||
if !is_track_pad
|
if !is_track_pad
|
||||||
@ -861,7 +862,7 @@ pub fn handle_mouse_(evt: &MouseEvent, conn: i32) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
if evt_type == MOUSE_TYPE_WHEEL {
|
if is_track_pad {
|
||||||
x *= WHEEL_DELTA as i32;
|
x *= WHEEL_DELTA as i32;
|
||||||
y *= WHEEL_DELTA as i32;
|
y *= WHEEL_DELTA as i32;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user