Refacotr env of keyboard && enter view
This commit is contained in:
parent
8df3000b6b
commit
abf78ab6f7
@ -49,7 +49,7 @@ packages:
|
||||
name: async
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.8.2"
|
||||
version: "2.9.0"
|
||||
back_button_interceptor:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -147,7 +147,7 @@ packages:
|
||||
name: characters
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
version: "1.2.1"
|
||||
charcode:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -168,7 +168,7 @@ packages:
|
||||
name: clock
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "1.1.1"
|
||||
code_builder:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -324,7 +324,7 @@ packages:
|
||||
name: fake_async
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
version: "1.3.1"
|
||||
ffi:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -621,14 +621,14 @@ packages:
|
||||
name: matcher
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.12.11"
|
||||
version: "0.12.12"
|
||||
material_color_utilities:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: material_color_utilities
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.1.4"
|
||||
version: "0.1.5"
|
||||
menu_base:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -642,7 +642,7 @@ packages:
|
||||
name: meta
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.7.0"
|
||||
version: "1.8.0"
|
||||
mime:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -719,7 +719,7 @@ packages:
|
||||
name: path
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.8.1"
|
||||
version: "1.8.2"
|
||||
path_provider:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -971,7 +971,7 @@ packages:
|
||||
name: source_span
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.8.2"
|
||||
version: "1.9.0"
|
||||
sqflite:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -1013,7 +1013,7 @@ packages:
|
||||
name: string_scanner
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "1.1.1"
|
||||
synchronized:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -1027,14 +1027,14 @@ packages:
|
||||
name: term_glyph
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
version: "1.2.1"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.4.9"
|
||||
version: "0.4.12"
|
||||
timing:
|
||||
dependency: transitive
|
||||
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())
|
||||
}
|
||||
|
||||
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"))]
|
||||
lazy_static::lazy_static! {
|
||||
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::{
|
||||
collections::HashMap,
|
||||
ops::{Deref, DerefMut},
|
||||
@ -540,18 +539,6 @@ impl SciterSession {
|
||||
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> {
|
||||
let mut key_event = KeyEvent::new();
|
||||
if down_or_up == 2 {
|
||||
|
@ -7,7 +7,6 @@ use crate::client::{
|
||||
QualityStatus, KEY_MAP, SERVER_KEYBOARD_ENABLED,
|
||||
};
|
||||
use crate::{client::Data, client::Interface};
|
||||
use crate::common::{get_keyboard_mode, save_keyboard_mode};
|
||||
use async_trait::async_trait;
|
||||
|
||||
use hbb_common::config::{Config, LocalConfig, PeerConfig};
|
||||
@ -61,11 +60,13 @@ impl<T: InvokeUi> Session<T> {
|
||||
}
|
||||
|
||||
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) {
|
||||
save_keyboard_mode(value);
|
||||
std::env::set_var("KEYBOARD_MODE", value);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
pub fn handle_flutter_key_event(&self, name: &str, keycode: i32, scancode:i32, down_or_up: bool){
|
||||
if scancode < 0 || keycode < 0{
|
||||
pub fn enter(&self) {
|
||||
#[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;
|
||||
}
|
||||
let keycode: u32 = keycode as u32;
|
||||
@ -739,12 +761,12 @@ impl<T: InvokeUi> Session<T> {
|
||||
#[cfg(target_os = "windows")]
|
||||
let key = rdev::get_win_key(keycode, scancode);
|
||||
|
||||
let event_type = if down_or_up{
|
||||
let event_type = if down_or_up {
|
||||
KeyPress(key)
|
||||
}else{
|
||||
} else {
|
||||
KeyRelease(key)
|
||||
};
|
||||
let evt = Event{
|
||||
let evt = Event {
|
||||
time: std::time::SystemTime::now(),
|
||||
name: Option::Some(name.to_owned()),
|
||||
code: keycode as _,
|
||||
@ -827,7 +849,7 @@ impl<T: InvokeUi> Session<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
self.legacy_modifiers(&mut key_event, alt, ctrl, shift, command);
|
||||
if v == 1 {
|
||||
key_event.down = true;
|
||||
|
Loading…
Reference in New Issue
Block a user