unwrap -> ok to avoid unintended crash
This commit is contained in:
parent
35816d4fbb
commit
6bd730bc67
@ -109,7 +109,7 @@ enum ControlKey {
|
|||||||
/// meta key (also known as "windows"; "super"; and "command")
|
/// meta key (also known as "windows"; "super"; and "command")
|
||||||
Meta = 23;
|
Meta = 23;
|
||||||
/// option key on macOS (alt key on Linux and Windows)
|
/// option key on macOS (alt key on Linux and Windows)
|
||||||
Option = 24;
|
Option = 24; // deprecated, use Alt instead
|
||||||
PageDown = 25;
|
PageDown = 25;
|
||||||
PageUp = 26;
|
PageUp = 26;
|
||||||
Return = 27;
|
Return = 27;
|
||||||
@ -173,7 +173,7 @@ message KeyEvent {
|
|||||||
uint32 chr = 4;
|
uint32 chr = 4;
|
||||||
uint32 unicode = 5;
|
uint32 unicode = 5;
|
||||||
string seq = 6;
|
string seq = 6;
|
||||||
};
|
}
|
||||||
repeated ControlKey modifiers = 8;
|
repeated ControlKey modifiers = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,12 +194,12 @@ message CursorPosition {
|
|||||||
message Hash {
|
message Hash {
|
||||||
string salt = 1;
|
string salt = 1;
|
||||||
string challenge = 2;
|
string challenge = 2;
|
||||||
};
|
}
|
||||||
|
|
||||||
message Clipboard {
|
message Clipboard {
|
||||||
bool compress = 1;
|
bool compress = 1;
|
||||||
bytes content = 2;
|
bytes content = 2;
|
||||||
};
|
}
|
||||||
|
|
||||||
enum FileType {
|
enum FileType {
|
||||||
Dir = 1;
|
Dir = 1;
|
||||||
|
@ -605,7 +605,6 @@ pub fn toggle_blank_screen(_v: bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn block_input(_v: bool) -> bool {
|
pub fn block_input(_v: bool) -> bool {
|
||||||
//
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,7 +403,6 @@ pub fn toggle_blank_screen(_v: bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn block_input(_v: bool) -> bool {
|
pub fn block_input(_v: bool) -> bool {
|
||||||
//
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,7 +314,7 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
conn.tx_input.send(MessageInput::Exit).unwrap();
|
conn.tx_input.send(MessageInput::Exit).ok();
|
||||||
if let Err(e) = handler_input.join() {
|
if let Err(e) = handler_input.join() {
|
||||||
log::error!("Failed to join input thread, {:?}", e);
|
log::error!("Failed to join input thread, {:?}", e);
|
||||||
} else {
|
} else {
|
||||||
@ -347,36 +347,36 @@ impl Connection {
|
|||||||
MessageInput::BlockOn => {
|
MessageInput::BlockOn => {
|
||||||
if crate::platform::block_input(true) {
|
if crate::platform::block_input(true) {
|
||||||
block_input_mode = true;
|
block_input_mode = true;
|
||||||
tx_input_res.send(true).unwrap();
|
tx_input_res.send(true).ok();
|
||||||
} else {
|
} else {
|
||||||
tx_input_res.send(false).unwrap();
|
tx_input_res.send(false).ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MessageInput::BlockOff => {
|
MessageInput::BlockOff => {
|
||||||
if crate::platform::block_input(false) {
|
if crate::platform::block_input(false) {
|
||||||
block_input_mode = false;
|
block_input_mode = false;
|
||||||
tx_input_res.send(true).unwrap();
|
tx_input_res.send(true).ok();
|
||||||
} else {
|
} else {
|
||||||
tx_input_res.send(false).unwrap();
|
tx_input_res.send(false).ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MessageInput::PrivacyOn => {
|
MessageInput::PrivacyOn => {
|
||||||
if crate::platform::block_input(true) {
|
if crate::platform::block_input(true) {
|
||||||
block_input_mode = true;
|
block_input_mode = true;
|
||||||
tx_input_res.send(true).unwrap();
|
tx_input_res.send(true).ok();
|
||||||
} else {
|
} else {
|
||||||
tx_input_res.send(false).unwrap();
|
tx_input_res.send(false).ok();
|
||||||
}
|
}
|
||||||
tx_blank.send(MessageInput::PrivacyOn).unwrap();
|
tx_blank.send(MessageInput::PrivacyOn).ok();
|
||||||
}
|
}
|
||||||
MessageInput::PrivacyOff => {
|
MessageInput::PrivacyOff => {
|
||||||
if crate::platform::block_input(false) {
|
if crate::platform::block_input(false) {
|
||||||
block_input_mode = false;
|
block_input_mode = false;
|
||||||
tx_input_res.send(true).unwrap();
|
tx_input_res.send(true).ok();
|
||||||
} else {
|
} else {
|
||||||
tx_input_res.send(false).unwrap();
|
tx_input_res.send(false).ok();
|
||||||
}
|
}
|
||||||
tx_blank.send(MessageInput::PrivacyOff).unwrap();
|
tx_blank.send(MessageInput::PrivacyOff).ok();
|
||||||
}
|
}
|
||||||
MessageInput::Exit => break,
|
MessageInput::Exit => break,
|
||||||
},
|
},
|
||||||
@ -388,7 +388,7 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tx_blank.send(MessageInput::Exit).unwrap();
|
tx_blank.send(MessageInput::Exit).ok();
|
||||||
if let Err(_) = handler_blank.join() {
|
if let Err(_) = handler_blank.join() {
|
||||||
log::error!("Failed to join blank thread handler");
|
log::error!("Failed to join blank thread handler");
|
||||||
} else {
|
} else {
|
||||||
@ -786,7 +786,7 @@ impl Connection {
|
|||||||
.send(MessageInput::InputFunc(Box::new(move || {
|
.send(MessageInput::InputFunc(Box::new(move || {
|
||||||
handle_mouse(&me, conn_id)
|
handle_mouse(&me, conn_id)
|
||||||
})))
|
})))
|
||||||
.unwrap();
|
.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(message::Union::key_event(mut me)) => {
|
Some(message::Union::key_event(mut me)) => {
|
||||||
@ -805,13 +805,13 @@ impl Connection {
|
|||||||
.send(MessageInput::InputFunc(Box::new(move || {
|
.send(MessageInput::InputFunc(Box::new(move || {
|
||||||
handle_key(&me)
|
handle_key(&me)
|
||||||
})))
|
})))
|
||||||
.unwrap();
|
.ok();
|
||||||
} else if let Some(key_event::Union::seq(_)) = me.union {
|
} else if let Some(key_event::Union::seq(_)) = me.union {
|
||||||
self.tx_input
|
self.tx_input
|
||||||
.send(MessageInput::InputFunc(Box::new(move || {
|
.send(MessageInput::InputFunc(Box::new(move || {
|
||||||
handle_key(&me)
|
handle_key(&me)
|
||||||
})))
|
})))
|
||||||
.unwrap();
|
.ok();
|
||||||
} else {
|
} else {
|
||||||
self.tx_input
|
self.tx_input
|
||||||
.send(MessageInput::InputFunc(Box::new(move || {
|
.send(MessageInput::InputFunc(Box::new(move || {
|
||||||
@ -820,12 +820,12 @@ impl Connection {
|
|||||||
me.down = false;
|
me.down = false;
|
||||||
handle_key(&me);
|
handle_key(&me);
|
||||||
})))
|
})))
|
||||||
.unwrap();
|
.ok();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.tx_input
|
self.tx_input
|
||||||
.send(MessageInput::InputFunc(Box::new(move || handle_key(&me))))
|
.send(MessageInput::InputFunc(Box::new(move || handle_key(&me))))
|
||||||
.unwrap();
|
.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1005,7 +1005,7 @@ impl Connection {
|
|||||||
match q {
|
match q {
|
||||||
BoolOption::Yes => {
|
BoolOption::Yes => {
|
||||||
self.privacy_mode = true;
|
self.privacy_mode = true;
|
||||||
self.tx_input.send(MessageInput::PrivacyOn).unwrap();
|
self.tx_input.send(MessageInput::PrivacyOn).ok();
|
||||||
if self.rx_input_res.recv().unwrap() {
|
if self.rx_input_res.recv().unwrap() {
|
||||||
log::info!("Privacy mode on");
|
log::info!("Privacy mode on");
|
||||||
} else {
|
} else {
|
||||||
@ -1016,7 +1016,7 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
BoolOption::No => {
|
BoolOption::No => {
|
||||||
self.privacy_mode = false;
|
self.privacy_mode = false;
|
||||||
self.tx_input.send(MessageInput::PrivacyOff).unwrap();
|
self.tx_input.send(MessageInput::PrivacyOff).ok();
|
||||||
if self.rx_input_res.recv().unwrap() {
|
if self.rx_input_res.recv().unwrap() {
|
||||||
log::info!("Privacy mode off");
|
log::info!("Privacy mode off");
|
||||||
} else {
|
} else {
|
||||||
@ -1031,7 +1031,7 @@ impl Connection {
|
|||||||
if let Ok(q) = o.block_input.enum_value() {
|
if let Ok(q) = o.block_input.enum_value() {
|
||||||
match q {
|
match q {
|
||||||
BoolOption::Yes => {
|
BoolOption::Yes => {
|
||||||
self.tx_input.send(MessageInput::BlockOn).unwrap();
|
self.tx_input.send(MessageInput::BlockOn).ok();
|
||||||
if self.rx_input_res.recv().unwrap() {
|
if self.rx_input_res.recv().unwrap() {
|
||||||
log::info!("Block input mode on");
|
log::info!("Block input mode on");
|
||||||
} else {
|
} else {
|
||||||
@ -1041,7 +1041,7 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
BoolOption::No => {
|
BoolOption::No => {
|
||||||
self.tx_input.send(MessageInput::BlockOff).unwrap();
|
self.tx_input.send(MessageInput::BlockOff).ok();
|
||||||
if self.rx_input_res.recv().unwrap() {
|
if self.rx_input_res.recv().unwrap() {
|
||||||
log::info!("Block input mode off");
|
log::info!("Block input mode off");
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user