Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Oct 1, 2024
1 parent cfbb646 commit ad3e1c6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 30 deletions.
2 changes: 1 addition & 1 deletion plugins/barcode-scanner/api-iife.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/positioner/api-iife.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 5 additions & 25 deletions plugins/positioner/guest-js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@
// SPDX-License-Identifier: MIT

import { invoke } from '@tauri-apps/api/core'
import type {
TrayIconClickEvent,
TrayIconEnterEvent,
TrayIconEvent,
TrayIconLeaveEvent,
TrayIconMoveEvent
} from '@tauri-apps/api/tray'
import type { TrayIconEvent } from '@tauri-apps/api/tray'

/**
* Well known window positions.
Expand Down Expand Up @@ -46,26 +40,12 @@ export async function moveWindow(to: Position): Promise<void> {
}

export async function handleIconState(event: TrayIconEvent): Promise<void> {
if ('click' in event) {
await invokeSetTrayIconState(event.click.rect)
} else if ('enter' in event) {
await invokeSetTrayIconState(event.enter.rect)
} else if ('leave' in event) {
await invokeSetTrayIconState(event.leave.rect)
} else if ('move' in event) {
await invokeSetTrayIconState(event.move.rect)
}
await invokeSetTrayIconState(event.rect)
}

async function invokeSetTrayIconState(
rect:
| TrayIconClickEvent['rect']
| TrayIconEnterEvent['rect']
| TrayIconLeaveEvent['rect']
| TrayIconMoveEvent['rect']
) {
async function invokeSetTrayIconState(rect: TrayIconEvent['rect']) {
await invoke('plugin:positioner|set_tray_icon_state', {
position: rect.position.Physical,
size: rect.size.Physical
position: rect.position,
size: rect.size
})
}
7 changes: 5 additions & 2 deletions plugins/positioner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ fn set_tray_icon_state<R: Runtime>(

/// 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, set_tray_icon_state]);
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| {
Expand Down
2 changes: 1 addition & 1 deletion plugins/window-state/api-iife.js

Large diffs are not rendered by default.

0 comments on commit ad3e1c6

Please sign in to comment.