[positioner] handleIconState in JS (#1822)

* [positioner] handleIconState in JS

* update readme

* fix change file version

* fixes

---------

Co-authored-by: Lucas Nogueira <lucas@tauri.app>
This commit is contained in:
Jacob Bolda
2024-10-01 08:15:22 -05:00
committed by GitHub
parent 30bcf5dcc2
commit 2f7e32b5e0
11 changed files with 103 additions and 6 deletions
+19 -2
View File
@@ -63,10 +63,27 @@ async fn move_window<R: Runtime>(window: tauri::Window<R>, position: Position) -
window.move_window(position)
}
#[cfg(feature = "tray-icon")]
#[tauri::command]
fn set_tray_icon_state<R: Runtime>(
app: AppHandle<R>,
position: PhysicalPosition<f64>,
size: PhysicalSize<f64>,
) {
app.state::<Tray>()
.0
.lock()
.unwrap()
.replace((position, size));
}
/// The Tauri plugin that exposes [`WindowExt::move_window`] to the webview.
pub fn init<R: Runtime>() -> TauriPlugin<R> {
let plugin =
plugin::Builder::new("positioner").invoke_handler(tauri::generate_handler![move_window]);
let plugin = plugin::Builder::new("positioner").invoke_handler(tauri::generate_handler![
move_window,
#[cfg(feature = "tray-icon")]
set_tray_icon_state
]);
#[cfg(feature = "tray-icon")]
let plugin = plugin.setup(|app_handle, _api| {