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
|
||||
final isPhysicalMouse = false.obs;
|
||||
int _lastMouseDownButtons = 0;
|
||||
int _lastButtons = 0;
|
||||
Offset lastMousePos = Offset.zero;
|
||||
|
||||
get id => parent.target?.id ?? "";
|
||||
@ -195,17 +195,17 @@ class InputModel {
|
||||
if (command) out['command'] = 'true';
|
||||
|
||||
// Check update event type and set buttons to be sent.
|
||||
int buttons = _lastMouseDownButtons;
|
||||
int buttons = _lastButtons;
|
||||
if (type == _kMouseEventMove) {
|
||||
// flutter may emit move event if one button is pressed and anoter button
|
||||
// is pressing or releasing.
|
||||
if (evt.buttons != _lastMouseDownButtons) {
|
||||
if (evt.buttons != _lastButtons) {
|
||||
// For simplicity
|
||||
// Just consider 3 - 1 ((Left + Right buttons) - Left button)
|
||||
// Do not consider 2 - 1 (Right button - Left button)
|
||||
// or 6 - 5 ((Right + Mid buttons) - (Left + Mid buttons))
|
||||
// and so on
|
||||
buttons = evt.buttons - _lastMouseDownButtons;
|
||||
buttons = evt.buttons - _lastButtons;
|
||||
if (buttons > 0) {
|
||||
type = _kMouseEventDown;
|
||||
} else {
|
||||
@ -218,7 +218,7 @@ class InputModel {
|
||||
buttons = evt.buttons;
|
||||
}
|
||||
}
|
||||
_lastMouseDownButtons = evt.buttons;
|
||||
_lastButtons = evt.buttons;
|
||||
|
||||
out['buttons'] = buttons;
|
||||
out['type'] = type;
|
||||
|
@ -74,9 +74,9 @@ pub fn is_x11() -> bool {
|
||||
#[inline]
|
||||
pub fn is_cursor_embedded() -> bool {
|
||||
if is_x11() {
|
||||
x11::is_cursor_embedded
|
||||
x11::IS_CURSOR_EMBEDDED
|
||||
} 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>);
|
||||
|
||||
#[allow(non_upper_case_globals)]
|
||||
pub const is_cursor_embedded: bool = true;
|
||||
pub const IS_CURSOR_EMBEDDED: bool = true;
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
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);
|
||||
|
||||
#[allow(non_upper_case_globals)]
|
||||
pub const is_cursor_embedded: bool = false;
|
||||
pub const IS_CURSOR_EMBEDDED: bool = false;
|
||||
|
||||
impl 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 _)?,
|
||||
"macos" => {
|
||||
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 {
|
||||
rdev::linux_code_to_macos_code(event.code as _)?
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user