Skip to main content

window.WindowManager

Manage the current window object.

Hierarchy#

Constructors#

constructor#

new WindowManager(label)

Parameters#

NameType
labelWindowLabel

Inherited from#

WebviewWindowHandle.constructor

Defined in#

window.ts:233

Properties#

label#

label: WindowLabel

Window label.

Inherited from#

WebviewWindowHandle.label

Defined in#

window.ts:229


listeners#

listeners: Object

Local event listeners.

Index signature#

▪ [key: string]: EventCallback<any>[]

Inherited from#

WebviewWindowHandle.listeners

Defined in#

window.ts:231

Methods#

_handleTauriEvent#

_handleTauriEvent<T>(event, handler): boolean

Type parameters#

Name
T

Parameters#

NameType
eventstring
handlerEventCallback<T>

Returns#

boolean

Inherited from#

WebviewWindowHandle._handleTauriEvent

Defined in#

window.ts:295


center#

center(): Promise<void>

Centers the window.

Returns#

Promise<void>

A promise indicating the success or failure of the operation.

Defined in#

window.ts:489


close#

close(): Promise<void>

Closes the window.

Returns#

Promise<void>

A promise indicating the success or failure of the operation.

Defined in#

window.ts:734


emit#

emit(event, payload?): Promise<void>

Emits an event to the backend, tied to the webview window.

Parameters#

NameTypeDescription
eventstringEvent name.
payload?stringEvent payload.

Returns#

Promise<void>

Inherited from#

WebviewWindowHandle.emit

Defined in#

window.ts:284


hide#

hide(): Promise<void>

Sets the window visibility to false.

Returns#

Promise<void>

A promise indicating the success or failure of the operation.

Defined in#

window.ts:714


innerPosition#

innerPosition(): Promise<PhysicalPosition>

The position of the top-left hand corner of the window's client area relative to the top-left hand corner of the desktop.

Returns#

Promise<PhysicalPosition>

Defined in#

window.ts:332


innerSize#

innerSize(): Promise<PhysicalSize>

The physical size of the window's client area. The client area is the content of the window, excluding the title bar and borders.

Returns#

Promise<PhysicalSize>

Defined in#

window.ts:367


isDecorated#

isDecorated(): Promise<boolean>

Gets the window's current decorated state.

Returns#

Promise<boolean>

Defined in#

window.ts:434


isFullscreen#

isFullscreen(): Promise<boolean>

Gets the window's current fullscreen state.

Returns#

Promise<boolean>

Defined in#

window.ts:402


isMaximized#

isMaximized(): Promise<boolean>

Gets the window's current maximized state.

Returns#

Promise<boolean>

Defined in#

window.ts:418


isResizable#

isResizable(): Promise<boolean>

Gets the window's current resizable state.

Returns#

Promise<boolean>

Defined in#

window.ts:450


isVisible#

isVisible(): Promise<boolean>

Gets the window's current visible state.

Returns#

Promise<boolean>

Defined in#

window.ts:466


listen#

listen<T>(event, handler): Promise<UnlistenFn>

Listen to an event emitted by the backend that is tied to the webview window.

Type parameters#

Name
T

Parameters#

NameTypeDescription
eventEventNameEvent name.
handlerEventCallback<T>Event handler.

Returns#

Promise<UnlistenFn>

A promise resolving to a function to unlisten to the event.

Inherited from#

WebviewWindowHandle.listen

Defined in#

window.ts:246


maximize#

maximize(): Promise<void>

Maximizes the window.

Returns#

Promise<void>

A promise indicating the success or failure of the operation.

Defined in#

window.ts:594


minimize#

minimize(): Promise<void>

Minimizes the window.

Returns#

Promise<void>

A promise indicating the success or failure of the operation.

Defined in#

window.ts:654


once#

once<T>(event, handler): Promise<UnlistenFn>

Listen to an one-off event emitted by the backend that is tied to the webview window.

Type parameters#

Name
T

Parameters#

NameTypeDescription
eventstringEvent name.
handlerEventCallback<T>Event handler.

Returns#

Promise<UnlistenFn>

A promise resolving to a function to unlisten to the event.

Inherited from#

WebviewWindowHandle.once

Defined in#

window.ts:267


outerPosition#

outerPosition(): Promise<PhysicalPosition>

The position of the top-left hand corner of the window relative to the top-left hand corner of the desktop.

Returns#

Promise<PhysicalPosition>

Defined in#

window.ts:348


outerSize#

outerSize(): Promise<PhysicalSize>

The physical size of the entire window. These dimensions include the title bar and borders. If you don't want that (and you usually don't), use inner_size instead.

Returns#

Promise<PhysicalSize>

Defined in#

window.ts:386


requestUserAttention#

requestUserAttention(requestType): Promise<void>

Requests user attention to the window, this has no effect if the application is already focused. How requesting for user attention manifests is platform dependent, see UserAttentionType for details.

Providing null will unset the request for user attention. Unsetting the request for user attention might not be done automatically by the WM when the window receives input.

Platform-specific#

  • macOS: null has no effect.

Parameters#

NameType
requestTypenull | UserAttentionType

Returns#

Promise<void>

A promise indicating the success or failure of the operation.

Defined in#

window.ts:519


scaleFactor#

scaleFactor(): Promise<number>

The scale factor that can be used to map physical pixels to logical pixels.

Returns#

Promise<number>

Defined in#

window.ts:316


setAlwaysOnTop#

setAlwaysOnTop(alwaysOnTop): Promise<void>

Whether the window should always be on top of other windows.

Parameters#

NameTypeDescription
alwaysOnTopbooleanWhether the window should always be on top of other windows or not.

Returns#

Promise<void>

A promise indicating the success or failure of the operation.

Defined in#

window.ts:777


setDecorations#

setDecorations(decorations): Promise<void>

Whether the window should have borders and bars.

Parameters#

NameTypeDescription
decorationsbooleanWhether the window should have borders and bars.

Returns#

Promise<void>

A promise indicating the success or failure of the operation.

Defined in#

window.ts:755


setFocus#

setFocus(): Promise<void>

Bring the window to front and focus.

Returns#

Promise<void>

A promise indicating the success or failure of the operation.

Defined in#

window.ts:985


setFullscreen#

setFullscreen(fullscreen): Promise<void>

Sets the window fullscreen state.

Parameters#

NameTypeDescription
fullscreenbooleanWhether the window should go to fullscreen or not.

Returns#

Promise<void>

A promise indicating the success or failure of the operation.

Defined in#

window.ts:964


setIcon#

setIcon(icon): Promise<void>

Sets the window icon.

Parameters#

NameTypeDescription
iconstring | number[]Icon bytes or path to the icon file.

Returns#

Promise<void>

A promise indicating the success or failure of the operation.

Defined in#

window.ts:1006


setMaxSize#

setMaxSize(size): Promise<void>

Sets the window max size. If the size argument is undefined, the max size is unset.

example

import { appWindow, LogicalSize } from '@tauri-apps/api/window'
await appWindow.setMaxSize(new LogicalSize(600, 500))

Parameters#

NameTypeDescription
sizeundefined | PhysicalSize | LogicalSizeThe logical or physical size.

Returns#

Promise<void>

A promise indicating the success or failure of the operation.

Defined in#

window.ts:884


setMinSize#

setMinSize(size): Promise<void>

Sets the window min size. If the size argument is not provided, the min size is unset.

example

import { appWindow, PhysicalSize } from '@tauri-apps/api/window'
await appWindow.setMinSize(new PhysicalSize(600, 500))

Parameters#

NameTypeDescription
sizeundefined | PhysicalSize | LogicalSizeThe logical or physical size.

Returns#

Promise<void>

A promise indicating the success or failure of the operation.

Defined in#

window.ts:842


setPosition#

setPosition(position): Promise<void>

Sets the window position.

example

import { appWindow, LogicalPosition } from '@tauri-apps/api/window'
await appWindow.setPosition(new LogicalPosition(600, 500))

Parameters#

NameTypeDescription
positionPhysicalPosition | LogicalPositionThe new position, in logical or physical pixels.

Returns#

Promise<void>

A promise indicating the success or failure of the operation.

Defined in#

window.ts:926


setResizable#

setResizable(resizable): Promise<void>

Updates the window resizable flag.

Parameters#

NameType
resizableboolean

Returns#

Promise<void>

A promise indicating the success or failure of the operation.

Defined in#

window.ts:551


setSize#

setSize(size): Promise<void>

Resizes the window.

example

import { appWindow, LogicalSize } from '@tauri-apps/api/window'
await appWindow.setSize(new LogicalSize(600, 500))

Parameters#

NameTypeDescription
sizePhysicalSize | LogicalSizeThe logical or physical size.

Returns#

Promise<void>

A promise indicating the success or failure of the operation.

Defined in#

window.ts:804


setSkipTaskbar#

setSkipTaskbar(skip): Promise<void>

Whether to show the window icon in the task bar or not.

Parameters#

NameTypeDescription
skipbooleantrue to hide window icon, false to show it.

Returns#

Promise<void>

A promise indicating the success or failure of the operation.

Defined in#

window.ts:1030


setTitle#

setTitle(title): Promise<void>

Sets the window title.

Parameters#

NameTypeDescription
titlestringThe new title

Returns#

Promise<void>

A promise indicating the success or failure of the operation.

Defined in#

window.ts:573


show#

show(): Promise<void>

Sets the window visibility to true.

Returns#

Promise<void>

A promise indicating the success or failure of the operation.

Defined in#

window.ts:694


startDragging#

startDragging(): Promise<void>

Starts dragging the window.

Returns#

Promise<void>

A promise indicating the success or failure of the operation.

Defined in#

window.ts:1051


toggleMaximize#

toggleMaximize(): Promise<void>

Toggles the window maximized state.

Returns#

Promise<void>

A promise indicating the success or failure of the operation.

Defined in#

window.ts:634


unmaximize#

unmaximize(): Promise<void>

Unmaximizes the window.

Returns#

Promise<void>

A promise indicating the success or failure of the operation.

Defined in#

window.ts:614


unminimize#

unminimize(): Promise<void>

Unminimizes the window.

Returns#

Promise<void>

A promise indicating the success or failure of the operation.

Defined in#

window.ts:674