mirror of
https://github.com/tauri-apps/tauri.git
synced 2025-01-01 23:42:33 +03:00
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
This commit is contained in:
parent
1377f8e13b
commit
6f41a27124
5
.changes/api-monitor-class-initialization.md
Normal file
5
.changes/api-monitor-class-initialization.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"api": "patch"
|
||||
---
|
||||
|
||||
Initialize `Monitor` instances with the correct classes for `position` and `size` fields instead of plain object.
|
File diff suppressed because one or more lines are too long
@ -2035,6 +2035,17 @@ interface WindowOptions {
|
||||
theme?: Theme
|
||||
}
|
||||
|
||||
function mapMonitor(m: Monitor | null): Monitor | null {
|
||||
return m === null
|
||||
? null
|
||||
: {
|
||||
name: m.name,
|
||||
scaleFactor: m.scaleFactor,
|
||||
position: new PhysicalPosition(m.position.x, m.position.y),
|
||||
size: new PhysicalSize(m.size.width, m.size.height)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the monitor on which the window currently resides.
|
||||
* Returns `null` if current monitor can't be detected.
|
||||
@ -2047,7 +2058,7 @@ interface WindowOptions {
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function currentMonitor(): Promise<Monitor | null> {
|
||||
return invokeTauriCommand({
|
||||
return invokeTauriCommand<Monitor | null>({
|
||||
__tauriModule: 'Window',
|
||||
message: {
|
||||
cmd: 'manage',
|
||||
@ -2057,7 +2068,7 @@ async function currentMonitor(): Promise<Monitor | null> {
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}).then(mapMonitor)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2072,7 +2083,7 @@ async function currentMonitor(): Promise<Monitor | null> {
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function primaryMonitor(): Promise<Monitor | null> {
|
||||
return invokeTauriCommand({
|
||||
return invokeTauriCommand<Monitor | null>({
|
||||
__tauriModule: 'Window',
|
||||
message: {
|
||||
cmd: 'manage',
|
||||
@ -2082,7 +2093,7 @@ async function primaryMonitor(): Promise<Monitor | null> {
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}).then(mapMonitor)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2096,7 +2107,7 @@ async function primaryMonitor(): Promise<Monitor | null> {
|
||||
* @since 1.0.0
|
||||
*/
|
||||
async function availableMonitors(): Promise<Monitor[]> {
|
||||
return invokeTauriCommand({
|
||||
return invokeTauriCommand<Monitor[]>({
|
||||
__tauriModule: 'Window',
|
||||
message: {
|
||||
cmd: 'manage',
|
||||
@ -2106,7 +2117,7 @@ async function availableMonitors(): Promise<Monitor[]> {
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}).then((ms) => ms.map(mapMonitor) as Monitor[])
|
||||
}
|
||||
|
||||
export {
|
||||
|
Loading…
Reference in New Issue
Block a user