Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Um comando direto ignora o prompt de revisão. Verifique a origem antes de executá-lo.
Close requested (call event.preventDefault() to cancel)
onResized(cb)
PhysicalSize
Window resized
onMoved(cb)
PhysicalPosition
Window moved
onFocusChanged(cb)
boolean
Focus gained/lost
onThemeChanged(cb)
Theme
System theme changed
onScaleChanged(cb)
{ scaleFactor, size }
DPI scale changed
onDragDropEvent(cb)
DragDropEvent
File drag-and-drop
JS Window State Methods
Method
Returns
Description
innerSize()
Promise<PhysicalSize>
Client area size
outerSize()
Promise<PhysicalSize>
Total window size
innerPosition()
Promise<PhysicalPosition>
Client area position
outerPosition()
Promise<PhysicalPosition>
Window frame position
isMaximized()
Promise<boolean>
Maximized state
isMinimized()
Promise<boolean>
Minimized state
isVisible()
Promise<boolean>
Visibility state
isFullscreen()
Promise<boolean>
Fullscreen state
title()
Promise<string>
Current title
JS Monitor Functions
Function
Returns
Import
availableMonitors()
Promise<Monitor[]>
@tauri-apps/api/window
currentMonitor()
Promise<Monitor | null>
@tauri-apps/api/window
primaryMonitor()
Promise<Monitor | null>
@tauri-apps/api/window
cursorPosition()
Promise<PhysicalPosition>
@tauri-apps/api/window
Size/Position Types
Type
Import
Description
LogicalSize
@tauri-apps/api/dpi
Size in logical pixels (DPI-independent)
PhysicalSize
@tauri-apps/api/dpi
Size in physical pixels
LogicalPosition
@tauri-apps/api/dpi
Position in logical pixels
PhysicalPosition
@tauri-apps/api/dpi
Position in physical pixels
Critical Warnings
NEVER use duplicate window labels -- each label MUST be unique across the application. Duplicate labels cause runtime panics in Rust and silent failures in JS.
NEVER call window.destroy() when window.close() suffices -- destroy() skips the CloseRequested event and prevents cleanup handlers from running.
NEVER forget to call api.prevent_close() inside CloseRequested if you want to cancel the close -- the window closes by default.
ALWAYS use app.get_webview_window("label") (not app.get_window("label")) in Tauri 2 -- get_window returns the raw Window, not the WebviewWindow.
ALWAYS check for None/null when retrieving windows by label -- the window may not exist yet or may have been closed.
Essential Patterns
Pattern 1: Creating Windows from Rust
use tauri::webview::WebviewWindowBuilder;
use tauri::WebviewUrl;
// In setup() or any context with Manager accessletwindow = WebviewWindowBuilder::new(
app,
"settings", // unique label
WebviewUrl::App("settings.html".into()), // URL to load
)
.title("Settings")
.inner_size(800.0, 600.0)
.center()
.resizable(true)
.build()?;
Window management requires core:window:default or specific permissions like core:window:allow-set-title, core:window:allow-close, core:window:allow-minimize, core:window:allow-maximize in the capability file.
Reference Links
references/methods.md -- Complete API signatures for WebviewWindowBuilder, Window (JS), and monitor functions