mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-03-15 17:21:02 +03:00
feat: show my cursor (#12745)
Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
use super::rdp_input::client::{RdpInputKeyboard, RdpInputMouse};
|
||||
use super::*;
|
||||
use crate::input::*;
|
||||
#[cfg(target_os = "windows")]
|
||||
use crate::whiteboard;
|
||||
#[cfg(target_os = "macos")]
|
||||
use dispatch::Queue;
|
||||
use enigo::{Enigo, Key, KeyboardControllable, MouseButton, MouseControllable};
|
||||
@@ -698,18 +700,25 @@ fn get_modifier_state(key: Key, en: &mut Enigo) -> bool {
|
||||
}
|
||||
|
||||
#[allow(unreachable_code)]
|
||||
pub fn handle_mouse(evt: &MouseEvent, conn: i32) {
|
||||
pub fn handle_mouse(
|
||||
evt: &MouseEvent,
|
||||
conn: i32,
|
||||
username: String,
|
||||
argb: u32,
|
||||
simulate: bool,
|
||||
show_cursor: bool,
|
||||
) {
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
// having GUI (--server has tray, it is GUI too), run main GUI thread, otherwise crash
|
||||
let evt = evt.clone();
|
||||
QUEUE.exec_async(move || handle_mouse_(&evt, conn));
|
||||
QUEUE.exec_async(move || handle_mouse_(&evt, conn, username, argb, simulate, show_cursor));
|
||||
return;
|
||||
}
|
||||
#[cfg(windows)]
|
||||
crate::portable_service::client::handle_mouse(evt, conn);
|
||||
crate::portable_service::client::handle_mouse(evt, conn, username, argb, simulate, show_cursor);
|
||||
#[cfg(not(windows))]
|
||||
handle_mouse_(evt, conn);
|
||||
handle_mouse_(evt, conn, username, argb, simulate, show_cursor);
|
||||
}
|
||||
|
||||
// to-do: merge handle_mouse and handle_pointer
|
||||
@@ -979,7 +988,24 @@ pub fn handle_pointer_(evt: &PointerDeviceEvent, conn: i32) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn handle_mouse_(evt: &MouseEvent, conn: i32) {
|
||||
pub fn handle_mouse_(
|
||||
evt: &MouseEvent,
|
||||
conn: i32,
|
||||
username: String,
|
||||
argb: u32,
|
||||
simulate: bool,
|
||||
_show_cursor: bool,
|
||||
) {
|
||||
if simulate {
|
||||
handle_mouse_simulation_(evt, conn);
|
||||
}
|
||||
#[cfg(target_os = "windows")]
|
||||
if _show_cursor {
|
||||
handle_mouse_show_cursor_(evt, conn, username, argb);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn handle_mouse_simulation_(evt: &MouseEvent, conn: i32) {
|
||||
if !active_mouse_(conn) {
|
||||
return;
|
||||
}
|
||||
@@ -1122,6 +1148,41 @@ pub fn handle_mouse_(evt: &MouseEvent, conn: i32) {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
pub fn handle_mouse_show_cursor_(evt: &MouseEvent, conn: i32, username: String, argb: u32) {
|
||||
let buttons = evt.mask >> 3;
|
||||
let evt_type = evt.mask & 0x7;
|
||||
match evt_type {
|
||||
MOUSE_TYPE_MOVE => {
|
||||
whiteboard::update_whiteboard(
|
||||
whiteboard::get_key_cursor(conn),
|
||||
whiteboard::CustomEvent::Cursor(whiteboard::Cursor {
|
||||
x: evt.x as _,
|
||||
y: evt.y as _,
|
||||
argb,
|
||||
btns: 0,
|
||||
text: username,
|
||||
}),
|
||||
);
|
||||
}
|
||||
MOUSE_TYPE_UP => {
|
||||
if buttons == MOUSE_BUTTON_LEFT {
|
||||
whiteboard::update_whiteboard(
|
||||
whiteboard::get_key_cursor(conn),
|
||||
whiteboard::CustomEvent::Cursor(whiteboard::Cursor {
|
||||
x: evt.x as _,
|
||||
y: evt.y as _,
|
||||
argb,
|
||||
btns: buttons,
|
||||
text: username,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn handle_scale(scale: i32) {
|
||||
let mut en = ENIGO.lock().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user