dpi
Ce contenu n’est pas encore disponible dans votre langue.
Classes
Section titled “Classes”LogicalPosition
Section titled “LogicalPosition”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L214
A position represented in logical pixels.
For an explanation of what logical pixels are, see description of LogicalSize.
2.0.0
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new LogicalPosition(x, y): LogicalPosition;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L219
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
x |
number |
y |
number |
Returns
Section titled “Returns”Constructor
Section titled “Constructor”new LogicalPosition(object): LogicalPosition;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L220
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
object |
{ Logical: { x: number; y: number; }; } |
object.Logical |
{ x: number; y: number; } |
object.Logical.x |
number |
object.Logical.y |
number |
Returns
Section titled “Returns”Constructor
Section titled “Constructor”new LogicalPosition(object): LogicalPosition;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L221
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
object |
{ x: number; y: number; } |
object.x |
number |
object.y |
number |
Returns
Section titled “Returns”Properties
Section titled “Properties”| Property | Modifier | Type | Default value | Defined in |
|---|---|---|---|---|
type |
readonly |
"Logical" |
'Logical' |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L215 |
x |
public |
number |
undefined |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L216 |
y |
public |
number |
undefined |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L217 |
Methods
Section titled “Methods”__TAURI_TO_IPC_KEY__()
Section titled “__TAURI_TO_IPC_KEY__()”__TAURI_TO_IPC_KEY__(): object;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L261
Returns
Section titled “Returns”object
| Name | Type | Defined in |
|---|---|---|
x |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L263 |
y |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L264 |
toJSON()
Section titled “toJSON()”toJSON(): object;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L268
Returns
Section titled “Returns”object
| Name | Type | Defined in |
|---|---|---|
x |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L263 |
y |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L264 |
toPhysical()
Section titled “toPhysical()”toPhysical(scaleFactor): PhysicalPosition;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L257
Converts the logical position to a physical one.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
scaleFactor |
number |
Returns
Section titled “Returns”Example
Section titled “Example”import { LogicalPosition } from '@tauri-apps/api/dpi';import { getCurrentWindow } from '@tauri-apps/api/window';
const appWindow = getCurrentWindow();const factor = await appWindow.scaleFactor();const position = new LogicalPosition(400, 500);const physical = position.toPhysical(factor);2.0.0
LogicalSize
Section titled “LogicalSize”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L16
A size represented in logical pixels.
Logical pixels are scaled according to the window’s DPI scale.
Most browser APIs (i.e. MouseEvent’s clientX) will return logical pixels.
For logical-pixel-based position, see LogicalPosition.
2.0.0
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new LogicalSize(width, height): LogicalSize;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L21
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
width |
number |
height |
number |
Returns
Section titled “Returns”Constructor
Section titled “Constructor”new LogicalSize(object): LogicalSize;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L22
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
object |
{ Logical: { height: number; width: number; }; } |
object.Logical |
{ height: number; width: number; } |
object.Logical.height |
number |
object.Logical.width |
number |
Returns
Section titled “Returns”Constructor
Section titled “Constructor”new LogicalSize(object): LogicalSize;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L23
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
object |
{ height: number; width: number; } |
object.height |
number |
object.width |
number |
Returns
Section titled “Returns”Properties
Section titled “Properties”| Property | Modifier | Type | Default value | Defined in |
|---|---|---|---|---|
height |
public |
number |
undefined |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L19 |
type |
readonly |
"Logical" |
'Logical' |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L17 |
width |
public |
number |
undefined |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L18 |
Methods
Section titled “Methods”__TAURI_TO_IPC_KEY__()
Section titled “__TAURI_TO_IPC_KEY__()”__TAURI_TO_IPC_KEY__(): object;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L63
Returns
Section titled “Returns”object
| Name | Type | Defined in |
|---|---|---|
height |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L66 |
width |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L65 |
toJSON()
Section titled “toJSON()”toJSON(): object;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L70
Returns
Section titled “Returns”object
| Name | Type | Defined in |
|---|---|---|
height |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L66 |
width |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L65 |
toPhysical()
Section titled “toPhysical()”toPhysical(scaleFactor): PhysicalSize;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L59
Converts the logical size to a physical one.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
scaleFactor |
number |
Returns
Section titled “Returns”Example
Section titled “Example”import { LogicalSize } from '@tauri-apps/api/dpi';import { getCurrentWindow } from '@tauri-apps/api/window';
const appWindow = getCurrentWindow();const factor = await appWindow.scaleFactor();const size = new LogicalSize(400, 500);const physical = size.toPhysical(factor);2.0.0
PhysicalPosition
Section titled “PhysicalPosition”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L281
A position represented in physical pixels.
For an explanation of what physical pixels are, see description of PhysicalSize.
2.0.0
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new PhysicalPosition(x, y): PhysicalPosition;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L286
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
x |
number |
y |
number |
Returns
Section titled “Returns”Constructor
Section titled “Constructor”new PhysicalPosition(object): PhysicalPosition;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L287
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
object |
{ Physical: { x: number; y: number; }; } |
object.Physical |
{ x: number; y: number; } |
object.Physical.x |
number |
object.Physical.y |
number |
Returns
Section titled “Returns”Constructor
Section titled “Constructor”new PhysicalPosition(object): PhysicalPosition;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L288
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
object |
{ x: number; y: number; } |
object.x |
number |
object.y |
number |
Returns
Section titled “Returns”Properties
Section titled “Properties”| Property | Modifier | Type | Default value | Defined in |
|---|---|---|---|---|
type |
readonly |
"Physical" |
'Physical' |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L282 |
x |
public |
number |
undefined |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L283 |
y |
public |
number |
undefined |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L284 |
Methods
Section titled “Methods”__TAURI_TO_IPC_KEY__()
Section titled “__TAURI_TO_IPC_KEY__()”__TAURI_TO_IPC_KEY__(): object;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L328
Returns
Section titled “Returns”object
| Name | Type | Defined in |
|---|---|---|
x |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L330 |
y |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L331 |
toJSON()
Section titled “toJSON()”toJSON(): object;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L335
Returns
Section titled “Returns”object
| Name | Type | Defined in |
|---|---|---|
x |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L330 |
y |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L331 |
toLogical()
Section titled “toLogical()”toLogical(scaleFactor): LogicalPosition;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L324
Converts the physical position to a logical one.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
scaleFactor |
number |
Returns
Section titled “Returns”Example
Section titled “Example”import { PhysicalPosition } from '@tauri-apps/api/dpi';import { getCurrentWindow } from '@tauri-apps/api/window';
const appWindow = getCurrentWindow();const factor = await appWindow.scaleFactor();const position = new PhysicalPosition(400, 500);const physical = position.toLogical(factor);2.0.0
PhysicalSize
Section titled “PhysicalSize”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L87
A size represented in physical pixels.
Physical pixels represent actual screen pixels, and are DPI-independent.
For high-DPI windows, this means that any point in the window on the screen
will have a different position in logical pixels LogicalSize.
For physical-pixel-based position, see PhysicalPosition.
2.0.0
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new PhysicalSize(width, height): PhysicalSize;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L92
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
width |
number |
height |
number |
Returns
Section titled “Returns”Constructor
Section titled “Constructor”new PhysicalSize(object): PhysicalSize;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L93
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
object |
{ Physical: { height: number; width: number; }; } |
object.Physical |
{ height: number; width: number; } |
object.Physical.height |
number |
object.Physical.width |
number |
Returns
Section titled “Returns”Constructor
Section titled “Constructor”new PhysicalSize(object): PhysicalSize;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L94
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
object |
{ height: number; width: number; } |
object.height |
number |
object.width |
number |
Returns
Section titled “Returns”Properties
Section titled “Properties”| Property | Modifier | Type | Default value | Defined in |
|---|---|---|---|---|
height |
public |
number |
undefined |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L90 |
type |
readonly |
"Physical" |
'Physical' |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L88 |
width |
public |
number |
undefined |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L89 |
Methods
Section titled “Methods”__TAURI_TO_IPC_KEY__()
Section titled “__TAURI_TO_IPC_KEY__()”__TAURI_TO_IPC_KEY__(): object;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L130
Returns
Section titled “Returns”object
| Name | Type | Defined in |
|---|---|---|
height |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L133 |
width |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L132 |
toJSON()
Section titled “toJSON()”toJSON(): object;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L137
Returns
Section titled “Returns”object
| Name | Type | Defined in |
|---|---|---|
height |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L133 |
width |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L132 |
toLogical()
Section titled “toLogical()”toLogical(scaleFactor): LogicalSize;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L126
Converts the physical size to a logical one.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
scaleFactor |
number |
Returns
Section titled “Returns”Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const appWindow = getCurrentWindow();const factor = await appWindow.scaleFactor();const size = await appWindow.innerSize(); // PhysicalSizeconst logical = size.toLogical(factor);Position
Section titled “Position”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L372
A position represented either in physical or in logical pixels.
This type is basically a union type of LogicalSize and PhysicalSize
but comes in handy when using tauri::Position in Rust as an argument to a command, as this class
automatically serializes into a valid format so it can be deserialized correctly into tauri::Position
So instead of
import { invoke } from '@tauri-apps/api/core';import { LogicalPosition, PhysicalPosition } from '@tauri-apps/api/dpi';
const position: LogicalPosition | PhysicalPosition = someFunction(); // where someFunction returns either LogicalPosition or PhysicalPositionconst validPosition = position instanceof LogicalPosition ? { Logical: { x: position.x, y: position.y } } : { Physical: { x: position.x, y: position.y } }await invoke("do_something_with_position", { position: validPosition });You can just use Position
import { invoke } from '@tauri-apps/api/core';import { LogicalPosition, PhysicalPosition, Position } from '@tauri-apps/api/dpi';
const position: LogicalPosition | PhysicalPosition = someFunction(); // where someFunction returns either LogicalPosition or PhysicalPositionconst validPosition = new Position(position);await invoke("do_something_with_position", { position: validPosition });2.1.0
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Position(position): Position;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L375
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
position |
| PhysicalPosition | LogicalPosition |
Returns
Section titled “Returns”Properties
Section titled “Properties”| Property | Type | Defined in |
|---|---|---|
position |
| PhysicalPosition | LogicalPosition |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L373 |
Methods
Section titled “Methods”__TAURI_TO_IPC_KEY__()
Section titled “__TAURI_TO_IPC_KEY__()”__TAURI_TO_IPC_KEY__(): object;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L391
Returns
Section titled “Returns”object
toJSON()
Section titled “toJSON()”toJSON(): object;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L400
Returns
Section titled “Returns”object
toLogical()
Section titled “toLogical()”toLogical(scaleFactor): LogicalPosition;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L379
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
scaleFactor |
number |
Returns
Section titled “Returns”toPhysical()
Section titled “toPhysical()”toPhysical(scaleFactor): PhysicalPosition;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L385
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
scaleFactor |
number |
Returns
Section titled “Returns”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L174
A size represented either in physical or in logical pixels.
This type is basically a union type of LogicalSize and PhysicalSize
but comes in handy when using tauri::Size in Rust as an argument to a command, as this class
automatically serializes into a valid format so it can be deserialized correctly into tauri::Size
So instead of
import { invoke } from '@tauri-apps/api/core';import { LogicalSize, PhysicalSize } from '@tauri-apps/api/dpi';
const size: LogicalSize | PhysicalSize = someFunction(); // where someFunction returns either LogicalSize or PhysicalSizeconst validSize = size instanceof LogicalSize ? { Logical: { width: size.width, height: size.height } } : { Physical: { width: size.width, height: size.height } }await invoke("do_something_with_size", { size: validSize });You can just use Size
import { invoke } from '@tauri-apps/api/core';import { LogicalSize, PhysicalSize, Size } from '@tauri-apps/api/dpi';
const size: LogicalSize | PhysicalSize = someFunction(); // where someFunction returns either LogicalSize or PhysicalSizeconst validSize = new Size(size);await invoke("do_something_with_size", { size: validSize });2.1.0
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Size(size): Size;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L177
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
size |
| PhysicalSize | LogicalSize |
Returns
Section titled “Returns”Properties
Section titled “Properties”| Property | Type | Defined in |
|---|---|---|
size |
| PhysicalSize | LogicalSize |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L175 |
Methods
Section titled “Methods”__TAURI_TO_IPC_KEY__()
Section titled “__TAURI_TO_IPC_KEY__()”__TAURI_TO_IPC_KEY__(): object;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L193
Returns
Section titled “Returns”object
toJSON()
Section titled “toJSON()”toJSON(): object;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L202
Returns
Section titled “Returns”object
toLogical()
Section titled “toLogical()”toLogical(scaleFactor): LogicalSize;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L181
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
scaleFactor |
number |
Returns
Section titled “Returns”toPhysical()
Section titled “toPhysical()”toPhysical(scaleFactor): PhysicalSize;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L187
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
scaleFactor |
number |
Returns
Section titled “Returns”© 2026 Tauri Contributors. CC-BY / MIT