mirror of
https://github.com/AkiChase/scrcpy-mask
synced 2024-11-14 05:21:42 +08:00
Merge pull request #44 from AkiChase/41-bug-window-error-when-start
fix(main): window default pos
This commit is contained in:
commit
a06dc4f811
@ -207,19 +207,27 @@ async fn main() {
|
|||||||
// restore window position and size
|
// restore window position and size
|
||||||
match store.get("maskArea") {
|
match store.get("maskArea") {
|
||||||
Some(value) => {
|
Some(value) => {
|
||||||
let pos_x = value["posX"].as_i64().unwrap_or(100);
|
let pos_x = value["posX"].as_i64();
|
||||||
let pos_y = value["posY"].as_i64().unwrap_or(100);
|
let pos_y = value["posY"].as_i64();
|
||||||
let size_w = value["sizeW"].as_i64().unwrap_or(800);
|
let size_w = value["sizeW"].as_i64().unwrap_or(800);
|
||||||
let size_h = value["sizeH"].as_i64().unwrap_or(600);
|
let size_h = value["sizeH"].as_i64().unwrap_or(600);
|
||||||
|
|
||||||
let main_window: tauri::WebviewWindow =
|
let main_window: tauri::WebviewWindow =
|
||||||
app.get_webview_window("main").unwrap();
|
app.get_webview_window("main").unwrap();
|
||||||
|
|
||||||
main_window.set_zoom(1.).unwrap_or(());
|
main_window.set_zoom(1.).unwrap_or(());
|
||||||
|
|
||||||
|
if pos_x.is_none() || pos_y.is_none() {
|
||||||
|
main_window.center().unwrap_or(());
|
||||||
|
} else {
|
||||||
main_window
|
main_window
|
||||||
.set_position(tauri::Position::Logical(tauri::LogicalPosition {
|
.set_position(tauri::Position::Logical(tauri::LogicalPosition {
|
||||||
x: (pos_x - 70) as f64,
|
x: (pos_x.unwrap() - 70) as f64,
|
||||||
y: (pos_y - 30) as f64,
|
y: (pos_y.unwrap() - 30) as f64,
|
||||||
}))
|
}))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
main_window
|
main_window
|
||||||
.set_size(tauri::Size::Logical(tauri::LogicalSize {
|
.set_size(tauri::Size::Logical(tauri::LogicalSize {
|
||||||
width: (size_w + 70) as f64,
|
width: (size_w + 70) as f64,
|
||||||
@ -230,23 +238,15 @@ async fn main() {
|
|||||||
None => {
|
None => {
|
||||||
let main_window: tauri::WebviewWindow =
|
let main_window: tauri::WebviewWindow =
|
||||||
app.get_webview_window("main").unwrap();
|
app.get_webview_window("main").unwrap();
|
||||||
|
|
||||||
|
main_window.center().unwrap_or(());
|
||||||
|
|
||||||
main_window
|
main_window
|
||||||
.set_size(tauri::Size::Logical(tauri::LogicalSize {
|
.set_size(tauri::Size::Logical(tauri::LogicalSize {
|
||||||
width: (800 + 70) as f64,
|
width: (800 + 70) as f64,
|
||||||
height: (600 + 30) as f64,
|
height: (600 + 30) as f64,
|
||||||
}))
|
}))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
store
|
|
||||||
.insert(
|
|
||||||
"maskArea".to_string(),
|
|
||||||
serde_json::json!({
|
|
||||||
"posX": 0,
|
|
||||||
"posY": 0,
|
|
||||||
"sizeW": 800,
|
|
||||||
"sizeH": 600
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user