Skip to content

[bug] the Monitor class not correctly initialize #4672

Description

@parrotdance

Describe the bug

const monitor = await currentMonitor()
if (monitor) {
  const { size, scaleFactor } = monitor
  size.toLogical(scaleFactor); // <--- [Error] toLogical does not exist on size
}

I have searched and read #2599 and #2621, and I think if we return a Monitor instance here:

/**
 * Returns the monitor on which the window currently resides.
 * Returns `null` if current monitor can't be detected.
 */
async function currentMonitor(): Promise<Monitor | null> {
  return invokeTauriCommand({
    __tauriModule: 'Window',
    message: {
      cmd: 'manage',
      data: {
        cmd: {
          type: 'currentMonitor'
        }
      }
    }
  })
} // .then(res => new Monitor( ... ))

this problem might be solved.

Reproduction

No response

Expected behavior

No response

Platform and versions

$ yarn tauri info
  › Node.js: 16.14.2
  › npm: 8.5.0
  › pnpm: Not installed!
  › yarn: 1.22.17
  › rustup: 1.24.3
  › rustc: 1.62.0
  › cargo: 1.62.0
  › Rust toolchain: stable-x86_64-pc-windows-msvc

Packages
  › @tauri-apps/cli [NPM]: 1.0.3
  › @tauri-apps/api [NPM]: 1.0.2
  › tauri [RUST]: 1.0.3,
  › tauri-build [RUST]: 1.0.3,
  › tao [RUST]: 0.12.1,
  › wry [RUST]: 0.19.0,

App
  › build-type: bundle
  › CSP: unset
  › distDir: ../dist
  › devPath: http://localhost:3000/

App directory structure
  ├─ node_modules
  ├─ src
  └─ src-tauri
Done in 14.76s.

Stack trace

No response

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions