mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
fix, win mouse, touchpad scroll
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
@@ -6,6 +6,10 @@ use crate::{
|
||||
common::make_fd_to_json,
|
||||
flutter::{self, SESSIONS},
|
||||
flutter::{session_add, session_start_},
|
||||
server::input_service::{
|
||||
MOUSE_BUTTON_BACK, MOUSE_BUTTON_FORWARD, MOUSE_BUTTON_LEFT, MOUSE_BUTTON_RIGHT,
|
||||
MOUSE_BUTTON_WHEEL, MOUSE_TYPE_DOWN, MOUSE_TYPE_TRACKPAD, MOUSE_TYPE_UP, MOUSE_TYPE_WHEEL,
|
||||
},
|
||||
ui_interface::{self, *},
|
||||
};
|
||||
use flutter_rust_bridge::{StreamSink, SyncReturn};
|
||||
@@ -1054,20 +1058,20 @@ pub fn session_send_mouse(id: String, msg: String) {
|
||||
let mut mask = 0;
|
||||
if let Some(_type) = m.get("type") {
|
||||
mask = match _type.as_str() {
|
||||
"down" => 1,
|
||||
"up" => 2,
|
||||
"wheel" => 3,
|
||||
"trackpad" => 4,
|
||||
"down" => MOUSE_TYPE_DOWN,
|
||||
"up" => MOUSE_TYPE_UP,
|
||||
"wheel" => MOUSE_TYPE_WHEEL,
|
||||
"trackpad" => MOUSE_TYPE_TRACKPAD,
|
||||
_ => 0,
|
||||
};
|
||||
}
|
||||
if let Some(buttons) = m.get("buttons") {
|
||||
mask |= match buttons.as_str() {
|
||||
"left" => 0x01,
|
||||
"right" => 0x02,
|
||||
"wheel" => 0x04,
|
||||
"back" => 0x08,
|
||||
"forward" => 0x10,
|
||||
"left" => MOUSE_BUTTON_LEFT,
|
||||
"right" => MOUSE_BUTTON_RIGHT,
|
||||
"wheel" => MOUSE_BUTTON_WHEEL,
|
||||
"back" => MOUSE_BUTTON_BACK,
|
||||
"forward" => MOUSE_BUTTON_FORWARD,
|
||||
_ => 0,
|
||||
} << 3;
|
||||
}
|
||||
|
||||
@@ -17,9 +17,22 @@ use std::{
|
||||
thread,
|
||||
time::{self, Duration, Instant},
|
||||
};
|
||||
use winapi::um::winuser::WHEEL_DELTA;
|
||||
|
||||
const INVALID_CURSOR_POS: i32 = i32::MIN;
|
||||
|
||||
pub const MOUSE_TYPE_MOVE: i32 = 0;
|
||||
pub const MOUSE_TYPE_DOWN: i32 = 1;
|
||||
pub const MOUSE_TYPE_UP: i32 = 2;
|
||||
pub const MOUSE_TYPE_WHEEL: i32 = 3;
|
||||
pub const MOUSE_TYPE_TRACKPAD: i32 = 4;
|
||||
|
||||
pub const MOUSE_BUTTON_LEFT: i32 = 0x01;
|
||||
pub const MOUSE_BUTTON_RIGHT: i32 = 0x02;
|
||||
pub const MOUSE_BUTTON_WHEEL: i32 = 0x04;
|
||||
pub const MOUSE_BUTTON_BACK: i32 = 0x08;
|
||||
pub const MOUSE_BUTTON_FORWARD: i32 = 0x10;
|
||||
|
||||
#[derive(Default)]
|
||||
struct StateCursor {
|
||||
hcursor: u64,
|
||||
@@ -777,7 +790,7 @@ pub fn handle_mouse_(evt: &MouseEvent, conn: i32) {
|
||||
}
|
||||
}
|
||||
match evt_type {
|
||||
0 => {
|
||||
MOUSE_TYPE_MOVE => {
|
||||
en.mouse_move_to(evt.x, evt.y);
|
||||
*LATEST_PEER_INPUT_CURSOR.lock().unwrap() = Input {
|
||||
conn,
|
||||
@@ -786,43 +799,43 @@ pub fn handle_mouse_(evt: &MouseEvent, conn: i32) {
|
||||
y: evt.y,
|
||||
};
|
||||
}
|
||||
1 => match buttons {
|
||||
0x01 => {
|
||||
MOUSE_TYPE_DOWN => match buttons {
|
||||
MOUSE_BUTTON_LEFT => {
|
||||
allow_err!(en.mouse_down(MouseButton::Left));
|
||||
}
|
||||
0x02 => {
|
||||
MOUSE_BUTTON_RIGHT => {
|
||||
allow_err!(en.mouse_down(MouseButton::Right));
|
||||
}
|
||||
0x04 => {
|
||||
MOUSE_BUTTON_WHEEL => {
|
||||
allow_err!(en.mouse_down(MouseButton::Middle));
|
||||
}
|
||||
0x08 => {
|
||||
MOUSE_BUTTON_BACK => {
|
||||
allow_err!(en.mouse_down(MouseButton::Back));
|
||||
}
|
||||
0x10 => {
|
||||
MOUSE_BUTTON_FORWARD => {
|
||||
allow_err!(en.mouse_down(MouseButton::Forward));
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
2 => match buttons {
|
||||
0x01 => {
|
||||
MOUSE_TYPE_UP => match buttons {
|
||||
MOUSE_BUTTON_LEFT => {
|
||||
en.mouse_up(MouseButton::Left);
|
||||
}
|
||||
0x02 => {
|
||||
MOUSE_BUTTON_RIGHT => {
|
||||
en.mouse_up(MouseButton::Right);
|
||||
}
|
||||
0x04 => {
|
||||
MOUSE_BUTTON_WHEEL => {
|
||||
en.mouse_up(MouseButton::Middle);
|
||||
}
|
||||
0x08 => {
|
||||
MOUSE_BUTTON_BACK => {
|
||||
en.mouse_up(MouseButton::Back);
|
||||
}
|
||||
0x10 => {
|
||||
MOUSE_BUTTON_FORWARD => {
|
||||
en.mouse_up(MouseButton::Forward);
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
3 | 4 => {
|
||||
MOUSE_TYPE_WHEEL | MOUSE_TYPE_TRACKPAD => {
|
||||
#[allow(unused_mut)]
|
||||
let mut x = evt.x;
|
||||
#[allow(unused_mut)]
|
||||
@@ -857,14 +870,20 @@ pub fn handle_mouse_(evt: &MouseEvent, conn: i32) {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
if evt_type == MOUSE_TYPE_WHEEL {
|
||||
x *= WHEEL_DELTA as i32;
|
||||
y *= WHEEL_DELTA as i32;
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
{
|
||||
if x != 0 {
|
||||
en.mouse_scroll_x(x);
|
||||
}
|
||||
if y != 0 {
|
||||
en.mouse_scroll_y(y);
|
||||
}
|
||||
if x != 0 {
|
||||
en.mouse_scroll_x(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
||||
Reference in New Issue
Block a user