mirror of
https://github.com/AkiChase/scrcpy-mask
synced 2024-11-09 09:41:17 +08:00
fix(Device): retrieve device screen size on reconnect
This commit is contained in:
parent
943454edc5
commit
4b48a6a563
@ -6,6 +6,8 @@ pub struct ClientInfo {
|
||||
pub device_name: String,
|
||||
pub device_id: String,
|
||||
pub scid: String,
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
}
|
||||
|
||||
impl ClientInfo {
|
||||
@ -14,8 +16,15 @@ impl ClientInfo {
|
||||
device_name,
|
||||
device_id,
|
||||
scid,
|
||||
width: 0,
|
||||
height: 0,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_size(&mut self, width: i32, height: i32) {
|
||||
self.width = width;
|
||||
self.height = height;
|
||||
}
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
|
@ -166,6 +166,12 @@ async fn handle_device_message(
|
||||
"height": height
|
||||
})
|
||||
.to_string();
|
||||
share::CLIENT_INFO
|
||||
.lock()
|
||||
.unwrap()
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.set_size(width, height);
|
||||
device_reply_sender.send(msg).await?;
|
||||
}
|
||||
};
|
||||
|
@ -118,6 +118,8 @@ onActivated(async () => {
|
||||
// restore controledDevice if client exists
|
||||
if (curClientInfo) {
|
||||
message.warning(t("pages.Device.alreadyControled"));
|
||||
store.screenSizeW = curClientInfo.width;
|
||||
store.screenSizeH = curClientInfo.height;
|
||||
store.controledDevice = {
|
||||
scid: curClientInfo.scid,
|
||||
deviceName: curClientInfo.device_name,
|
||||
|
@ -33,6 +33,8 @@ export async function getCurClientInfo(): Promise<{
|
||||
device_name: string;
|
||||
device_id: string;
|
||||
scid: string;
|
||||
width: number;
|
||||
height: number;
|
||||
} | null> {
|
||||
return await invoke("get_cur_client_info");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user