Merge pull request #2724 from fufesou/fix/linux_to_mac
fix linux to mac, keyboard input
This commit is contained in:
commit
1867502ef7
@ -50,7 +50,7 @@ class InputModel {
|
|||||||
|
|
||||||
// mouse
|
// mouse
|
||||||
final isPhysicalMouse = false.obs;
|
final isPhysicalMouse = false.obs;
|
||||||
int _lastMouseDownButtons = 0;
|
int _lastButtons = 0;
|
||||||
Offset lastMousePos = Offset.zero;
|
Offset lastMousePos = Offset.zero;
|
||||||
|
|
||||||
get id => parent.target?.id ?? "";
|
get id => parent.target?.id ?? "";
|
||||||
@ -195,17 +195,17 @@ class InputModel {
|
|||||||
if (command) out['command'] = 'true';
|
if (command) out['command'] = 'true';
|
||||||
|
|
||||||
// Check update event type and set buttons to be sent.
|
// Check update event type and set buttons to be sent.
|
||||||
int buttons = _lastMouseDownButtons;
|
int buttons = _lastButtons;
|
||||||
if (type == _kMouseEventMove) {
|
if (type == _kMouseEventMove) {
|
||||||
// flutter may emit move event if one button is pressed and anoter button
|
// flutter may emit move event if one button is pressed and anoter button
|
||||||
// is pressing or releasing.
|
// is pressing or releasing.
|
||||||
if (evt.buttons != _lastMouseDownButtons) {
|
if (evt.buttons != _lastButtons) {
|
||||||
// For simplicity
|
// For simplicity
|
||||||
// Just consider 3 - 1 ((Left + Right buttons) - Left button)
|
// Just consider 3 - 1 ((Left + Right buttons) - Left button)
|
||||||
// Do not consider 2 - 1 (Right button - Left button)
|
// Do not consider 2 - 1 (Right button - Left button)
|
||||||
// or 6 - 5 ((Right + Mid buttons) - (Left + Mid buttons))
|
// or 6 - 5 ((Right + Mid buttons) - (Left + Mid buttons))
|
||||||
// and so on
|
// and so on
|
||||||
buttons = evt.buttons - _lastMouseDownButtons;
|
buttons = evt.buttons - _lastButtons;
|
||||||
if (buttons > 0) {
|
if (buttons > 0) {
|
||||||
type = _kMouseEventDown;
|
type = _kMouseEventDown;
|
||||||
} else {
|
} else {
|
||||||
@ -218,7 +218,7 @@ class InputModel {
|
|||||||
buttons = evt.buttons;
|
buttons = evt.buttons;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_lastMouseDownButtons = evt.buttons;
|
_lastButtons = evt.buttons;
|
||||||
|
|
||||||
out['buttons'] = buttons;
|
out['buttons'] = buttons;
|
||||||
out['type'] = type;
|
out['type'] = type;
|
||||||
|
@ -74,9 +74,9 @@ pub fn is_x11() -> bool {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_cursor_embedded() -> bool {
|
pub fn is_cursor_embedded() -> bool {
|
||||||
if is_x11() {
|
if is_x11() {
|
||||||
x11::is_cursor_embedded
|
x11::IS_CURSOR_EMBEDDED
|
||||||
} else {
|
} else {
|
||||||
wayland::is_cursor_embedded
|
wayland::IS_CURSOR_EMBEDDED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ use std::{io, sync::RwLock, time::Duration};
|
|||||||
pub struct Capturer(Display, Box<dyn Recorder>, bool, Vec<u8>);
|
pub struct Capturer(Display, Box<dyn Recorder>, bool, Vec<u8>);
|
||||||
|
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
pub const is_cursor_embedded: bool = true;
|
pub const IS_CURSOR_EMBEDDED: bool = true;
|
||||||
|
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
static ref MAP_ERR: RwLock<Option<fn(err: String)-> io::Error>> = Default::default();
|
static ref MAP_ERR: RwLock<Option<fn(err: String)-> io::Error>> = Default::default();
|
||||||
|
@ -4,7 +4,7 @@ use std::{io, ops, time::Duration};
|
|||||||
pub struct Capturer(x11::Capturer);
|
pub struct Capturer(x11::Capturer);
|
||||||
|
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
pub const is_cursor_embedded: bool = false;
|
pub const IS_CURSOR_EMBEDDED: bool = false;
|
||||||
|
|
||||||
impl Capturer {
|
impl Capturer {
|
||||||
pub fn new(display: Display, yuv: bool) -> io::Result<Capturer> {
|
pub fn new(display: Display, yuv: bool) -> io::Result<Capturer> {
|
||||||
|
@ -636,7 +636,7 @@ pub fn map_keyboard_mode(event: &Event, mut key_event: KeyEvent) -> Option<KeyEv
|
|||||||
"windows" => rdev::linux_code_to_win_scancode(event.code as _)?,
|
"windows" => rdev::linux_code_to_win_scancode(event.code as _)?,
|
||||||
"macos" => {
|
"macos" => {
|
||||||
if hbb_common::config::LocalConfig::get_kb_layout_type() == "ISO" {
|
if hbb_common::config::LocalConfig::get_kb_layout_type() == "ISO" {
|
||||||
rdev::linux_code_to_macos_iso_code(event.scan_code)?
|
rdev::linux_code_to_macos_iso_code(event.code as _)?
|
||||||
} else {
|
} else {
|
||||||
rdev::linux_code_to_macos_code(event.code as _)?
|
rdev::linux_code_to_macos_code(event.code as _)?
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user