window: linux fixes
This commit is contained in:
+45
-12
@@ -95,6 +95,7 @@ pub async fn open_full_window(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "linux"))]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn open_window(
|
pub async fn open_window(
|
||||||
app_handle: AppHandle,
|
app_handle: AppHandle,
|
||||||
@@ -107,7 +108,7 @@ pub async fn open_window(
|
|||||||
existing.set_focus().map_err(|e| e.to_string())?;
|
existing.set_focus().map_err(|e| e.to_string())?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let os = std::env::consts::OS;
|
let os = std::env::consts::OS;
|
||||||
|
|
||||||
let default_height = if os == "windows" { 755.0 } else { 725.0 };
|
let default_height = if os == "windows" { 755.0 } else { 725.0 };
|
||||||
@@ -131,10 +132,9 @@ pub async fn open_window(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let window = builder.build().map_err(|e| e.to_string())?;
|
let window = builder.build().map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
std::thread::sleep(std::time::Duration::from_millis(750));
|
std::thread::sleep(std::time::Duration::from_millis(750));
|
||||||
|
|
||||||
// window.center().map_err(|e| e.to_string())?;
|
|
||||||
let monitor = window
|
let monitor = window
|
||||||
.current_monitor()
|
.current_monitor()
|
||||||
.map_err(|e| e.to_string())?
|
.map_err(|e| e.to_string())?
|
||||||
@@ -159,18 +159,51 @@ pub async fn open_window(
|
|||||||
y: y + final_offset,
|
y: y + final_offset,
|
||||||
}))
|
}))
|
||||||
.map_err(|e| e.to_string())?;
|
.map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
window.set_zoom(1.0).map_err(|e| e.to_string())?;
|
window.set_zoom(1.0).map_err(|e| e.to_string())?;
|
||||||
window.show().map_err(|e| e.to_string())?;
|
window.show().map_err(|e| e.to_string())?;
|
||||||
window.set_focus().map_err(|e| e.to_string())?;
|
window.set_focus().map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
Ok(())
|
||||||
window
|
}
|
||||||
.set_position(tauri::Position::Physical(tauri::PhysicalPosition {
|
|
||||||
x: x + final_offset,
|
#[cfg(target_os = "linux")]
|
||||||
y: y + final_offset,
|
#[tauri::command]
|
||||||
}))
|
pub async fn open_window(
|
||||||
.map_err(|e| e.to_string())?;
|
app_handle: AppHandle,
|
||||||
|
name: String,
|
||||||
|
url: String,
|
||||||
|
width: Option<f64>,
|
||||||
|
height: Option<f64>,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
if let Some(existing) = app_handle.get_webview_window(&name) {
|
||||||
|
existing.set_focus().map_err(|e| e.to_string())?;
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
let width = width.unwrap_or(840.0);
|
||||||
|
let height = height.unwrap_or(725.0);
|
||||||
|
|
||||||
|
let builder = WebviewWindowBuilder::new(&app_handle, &name, WebviewUrl::App(url.into()))
|
||||||
|
.title(&name)
|
||||||
|
.inner_size(width, height)
|
||||||
|
.min_inner_size(700.0, 700.0)
|
||||||
|
.max_inner_size(1000.0, 1000.0)
|
||||||
|
.resizable(true)
|
||||||
|
.visible(false)
|
||||||
|
.focused(false)
|
||||||
|
.decorations(true)
|
||||||
|
.zoom_hotkeys_enabled(false);
|
||||||
|
|
||||||
|
let window = builder.build().map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
|
window.center().map_err(|e| e.to_string())?;
|
||||||
|
window.set_zoom(1.0).map_err(|e| e.to_string())?;
|
||||||
|
window.show().map_err(|e| e.to_string())?;
|
||||||
|
window.set_focus().map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
|
window.set_resizable(false).map_err(|e| e.to_string())?;
|
||||||
|
window.set_resizable(true).map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user