Aller au contenu

dpi

Ce contenu n’est pas encore disponible dans votre langue.

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

new LogicalPosition(x, y): LogicalPosition;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L219

Parameter Type
x number
y number

LogicalPosition

new LogicalPosition(object): LogicalPosition;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L220

Parameter Type
object { Logical: { x: number; y: number; }; }
object.Logical { x: number; y: number; }
object.Logical.x number
object.Logical.y number

LogicalPosition

new LogicalPosition(object): LogicalPosition;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L221

Parameter Type
object { x: number; y: number; }
object.x number
object.y number

LogicalPosition

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

__TAURI_TO_IPC_KEY__(): object;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L261

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(): object;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L268

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(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.

Parameter Type
scaleFactor number

PhysicalPosition

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


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

new LogicalSize(width, height): LogicalSize;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L21

Parameter Type
width number
height number

LogicalSize

new LogicalSize(object): LogicalSize;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L22

Parameter Type
object { Logical: { height: number; width: number; }; }
object.Logical { height: number; width: number; }
object.Logical.height number
object.Logical.width number

LogicalSize

new LogicalSize(object): LogicalSize;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L23

Parameter Type
object { height: number; width: number; }
object.height number
object.width number

LogicalSize

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

__TAURI_TO_IPC_KEY__(): object;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L63

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(): object;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L70

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(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.

Parameter Type
scaleFactor number

PhysicalSize

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


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

new PhysicalPosition(x, y): PhysicalPosition;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L286

Parameter Type
x number
y number

PhysicalPosition

new PhysicalPosition(object): PhysicalPosition;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L287

Parameter Type
object { Physical: { x: number; y: number; }; }
object.Physical { x: number; y: number; }
object.Physical.x number
object.Physical.y number

PhysicalPosition

new PhysicalPosition(object): PhysicalPosition;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L288

Parameter Type
object { x: number; y: number; }
object.x number
object.y number

PhysicalPosition

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

__TAURI_TO_IPC_KEY__(): object;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L328

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(): object;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L335

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(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.

Parameter Type
scaleFactor number

LogicalPosition

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


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

new PhysicalSize(width, height): PhysicalSize;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L92

Parameter Type
width number
height number

PhysicalSize

new PhysicalSize(object): PhysicalSize;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L93

Parameter Type
object { Physical: { height: number; width: number; }; }
object.Physical { height: number; width: number; }
object.Physical.height number
object.Physical.width number

PhysicalSize

new PhysicalSize(object): PhysicalSize;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L94

Parameter Type
object { height: number; width: number; }
object.height number
object.width number

PhysicalSize

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

__TAURI_TO_IPC_KEY__(): object;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L130

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(): object;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L137

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(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.

Parameter Type
scaleFactor number

LogicalSize

import { getCurrentWindow } from '@tauri-apps/api/window';
const appWindow = getCurrentWindow();
const factor = await appWindow.scaleFactor();
const size = await appWindow.innerSize(); // PhysicalSize
const logical = size.toLogical(factor);

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 PhysicalPosition
const 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 PhysicalPosition
const validPosition = new Position(position);
await invoke("do_something_with_position", { position: validPosition });

2.1.0

new Position(position): Position;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L375

Parameter Type
position | PhysicalPosition | LogicalPosition

Position

Property Type Defined in
position | PhysicalPosition | LogicalPosition Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L373

__TAURI_TO_IPC_KEY__(): object;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L391

object

toJSON(): object;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L400

object

toLogical(scaleFactor): LogicalPosition;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L379

Parameter Type
scaleFactor number

LogicalPosition

toPhysical(scaleFactor): PhysicalPosition;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L385

Parameter Type
scaleFactor number

PhysicalPosition


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 PhysicalSize
const 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 PhysicalSize
const validSize = new Size(size);
await invoke("do_something_with_size", { size: validSize });

2.1.0

new Size(size): Size;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L177

Parameter Type
size | PhysicalSize | LogicalSize

Size

Property Type Defined in
size | PhysicalSize | LogicalSize Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L175

__TAURI_TO_IPC_KEY__(): object;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L193

object

toJSON(): object;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L202

object

toLogical(scaleFactor): LogicalSize;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L181

Parameter Type
scaleFactor number

LogicalSize

toPhysical(scaleFactor): PhysicalSize;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L187

Parameter Type
scaleFactor number

PhysicalSize


© 2026 Tauri Contributors. CC-BY / MIT