Refacotr env of keyboard && enter view
This commit is contained in:
parent
8df3000b6b
commit
abf78ab6f7
@ -49,7 +49,7 @@ packages:
|
|||||||
name: async
|
name: async
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.8.2"
|
version: "2.9.0"
|
||||||
back_button_interceptor:
|
back_button_interceptor:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -147,7 +147,7 @@ packages:
|
|||||||
name: characters
|
name: characters
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
version: "1.2.1"
|
||||||
charcode:
|
charcode:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -168,7 +168,7 @@ packages:
|
|||||||
name: clock
|
name: clock
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.1.1"
|
||||||
code_builder:
|
code_builder:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -324,7 +324,7 @@ packages:
|
|||||||
name: fake_async
|
name: fake_async
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.0"
|
version: "1.3.1"
|
||||||
ffi:
|
ffi:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -621,14 +621,14 @@ packages:
|
|||||||
name: matcher
|
name: matcher
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.11"
|
version: "0.12.12"
|
||||||
material_color_utilities:
|
material_color_utilities:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: material_color_utilities
|
name: material_color_utilities
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.1.4"
|
version: "0.1.5"
|
||||||
menu_base:
|
menu_base:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -642,7 +642,7 @@ packages:
|
|||||||
name: meta
|
name: meta
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.7.0"
|
version: "1.8.0"
|
||||||
mime:
|
mime:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -719,7 +719,7 @@ packages:
|
|||||||
name: path
|
name: path
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.1"
|
version: "1.8.2"
|
||||||
path_provider:
|
path_provider:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -971,7 +971,7 @@ packages:
|
|||||||
name: source_span
|
name: source_span
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.2"
|
version: "1.9.0"
|
||||||
sqflite:
|
sqflite:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1013,7 +1013,7 @@ packages:
|
|||||||
name: string_scanner
|
name: string_scanner
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.1.1"
|
||||||
synchronized:
|
synchronized:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1027,14 +1027,14 @@ packages:
|
|||||||
name: term_glyph
|
name: term_glyph
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
version: "1.2.1"
|
||||||
test_api:
|
test_api:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.4.9"
|
version: "0.4.12"
|
||||||
timing:
|
timing:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -712,16 +712,6 @@ pub fn make_fd_flutter(id: i32, entries: &Vec<FileEntry>, only_count: bool) -> S
|
|||||||
serde_json::to_string(&m).unwrap_or("".into())
|
serde_json::to_string(&m).unwrap_or("".into())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_keyboard_mode() -> String {
|
|
||||||
return std::env::var("KEYBOARD_MODE")
|
|
||||||
.unwrap_or(String::from("legacy"))
|
|
||||||
.to_lowercase();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn save_keyboard_mode(value: String) {
|
|
||||||
std::env::set_var("KEYBOARD_MODE", value);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(target_os = "linux"))]
|
#[cfg(not(target_os = "linux"))]
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
pub static ref IS_X11: Mutex<bool> = Mutex::new(false);
|
pub static ref IS_X11: Mutex<bool> = Mutex::new(false);
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
use crate::common::{get_keyboard_mode, save_keyboard_mode};
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
ops::{Deref, DerefMut},
|
ops::{Deref, DerefMut},
|
||||||
@ -540,18 +539,6 @@ impl SciterSession {
|
|||||||
self.close_state.insert(k, v);
|
self.close_state.insert(k, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn enter(&mut self) {
|
|
||||||
#[cfg(windows)]
|
|
||||||
crate::platform::windows::stop_system_key_propagate(true);
|
|
||||||
IS_IN.store(true, Ordering::SeqCst);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn leave(&mut self) {
|
|
||||||
#[cfg(windows)]
|
|
||||||
crate::platform::windows::stop_system_key_propagate(false);
|
|
||||||
IS_IN.store(false, Ordering::SeqCst);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_key_event(&self, down_or_up: i32, name: &str, code: i32) -> Option<KeyEvent> {
|
fn get_key_event(&self, down_or_up: i32, name: &str, code: i32) -> Option<KeyEvent> {
|
||||||
let mut key_event = KeyEvent::new();
|
let mut key_event = KeyEvent::new();
|
||||||
if down_or_up == 2 {
|
if down_or_up == 2 {
|
||||||
|
@ -7,7 +7,6 @@ use crate::client::{
|
|||||||
QualityStatus, KEY_MAP, SERVER_KEYBOARD_ENABLED,
|
QualityStatus, KEY_MAP, SERVER_KEYBOARD_ENABLED,
|
||||||
};
|
};
|
||||||
use crate::{client::Data, client::Interface};
|
use crate::{client::Data, client::Interface};
|
||||||
use crate::common::{get_keyboard_mode, save_keyboard_mode};
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
|
|
||||||
use hbb_common::config::{Config, LocalConfig, PeerConfig};
|
use hbb_common::config::{Config, LocalConfig, PeerConfig};
|
||||||
@ -61,11 +60,13 @@ impl<T: InvokeUi> Session<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_keyboard_mode(&self) -> String {
|
pub fn get_keyboard_mode(&self) -> String {
|
||||||
return get_keyboard_mode();
|
return std::env::var("KEYBOARD_MODE")
|
||||||
|
.unwrap_or(String::from("legacy"))
|
||||||
|
.to_lowercase();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn save_keyboard_mode(&self, value: String) {
|
pub fn save_keyboard_mode(&self, value: String) {
|
||||||
save_keyboard_mode(value);
|
std::env::set_var("KEYBOARD_MODE", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn save_view_style(&mut self, value: String) {
|
pub fn save_view_style(&mut self, value: String) {
|
||||||
@ -726,8 +727,29 @@ impl<T: InvokeUi> Session<T> {
|
|||||||
self.send_key_event(key_event, KeyboardMode::Legacy);
|
self.send_key_event(key_event, KeyboardMode::Legacy);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_flutter_key_event(&self, name: &str, keycode: i32, scancode:i32, down_or_up: bool){
|
pub fn enter(&self) {
|
||||||
if scancode < 0 || keycode < 0{
|
#[cfg(windows)]
|
||||||
|
crate::platform::windows::stop_system_key_propagate(true);
|
||||||
|
IS_IN.store(true, Ordering::SeqCst);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn leave(&self) {
|
||||||
|
for key in TO_RELEASE.lock().unwrap().iter() {
|
||||||
|
self.map_keyboard_mode(false, *key, None)
|
||||||
|
}
|
||||||
|
#[cfg(windows)]
|
||||||
|
crate::platform::windows::stop_system_key_propagate(false);
|
||||||
|
IS_IN.store(false, Ordering::SeqCst);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn handle_flutter_key_event(
|
||||||
|
&self,
|
||||||
|
name: &str,
|
||||||
|
keycode: i32,
|
||||||
|
scancode: i32,
|
||||||
|
down_or_up: bool,
|
||||||
|
) {
|
||||||
|
if scancode < 0 || keycode < 0 {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let keycode: u32 = keycode as u32;
|
let keycode: u32 = keycode as u32;
|
||||||
@ -739,12 +761,12 @@ impl<T: InvokeUi> Session<T> {
|
|||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
let key = rdev::get_win_key(keycode, scancode);
|
let key = rdev::get_win_key(keycode, scancode);
|
||||||
|
|
||||||
let event_type = if down_or_up{
|
let event_type = if down_or_up {
|
||||||
KeyPress(key)
|
KeyPress(key)
|
||||||
}else{
|
} else {
|
||||||
KeyRelease(key)
|
KeyRelease(key)
|
||||||
};
|
};
|
||||||
let evt = Event{
|
let evt = Event {
|
||||||
time: std::time::SystemTime::now(),
|
time: std::time::SystemTime::now(),
|
||||||
name: Option::Some(name.to_owned()),
|
name: Option::Some(name.to_owned()),
|
||||||
code: keycode as _,
|
code: keycode as _,
|
||||||
@ -827,7 +849,7 @@ impl<T: InvokeUi> Session<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.legacy_modifiers(&mut key_event, alt, ctrl, shift, command);
|
self.legacy_modifiers(&mut key_event, alt, ctrl, shift, command);
|
||||||
if v == 1 {
|
if v == 1 {
|
||||||
key_event.down = true;
|
key_event.down = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user