Skip to content

[bug] WindowEvent::Focused does not get fired for App run callback #6460

@NurMarvin

Description

@NurMarvin

Describe the bug

The WindowEvent::Focused event does not get fired when listening for it via the App run callback.

Reproduction

  1. Consider the following code:
app.run(move |app_handle, e| {
    match e {
        RunEvent::WindowEvent { event, .. } => {
            match event {
                WindowEvent::Focused(focused) => {
                    println!("Focused: {}", focused);
                }
                _ => (),
            }
        }
        _ => (),
    }
});
  1. Start the program
  2. Try to change the focus state of the window
  3. Observe

Expected behavior

The event should fire printing "Focused: true" or "Focused: false" to the console depending on the focused state of the window.

Platform and versions

Environment
  › OS: Windows 10.0.22621 X64
  › Webview2: 110.0.1587.69
  › MSVC: 
      - Visual Studio Community 2019
  › Node.js: 18.14.0
  › npm: 9.3.1
  › pnpm: 7.23.0
  › yarn: 1.22.19
  › rustup: 1.25.2
  › rustc: 1.69.0-nightly
  › cargo: 1.69.0-nightly
  › Rust toolchain: nightly-x86_64-pc-windows-msvc 

Packages
  › @tauri-apps/cli [NPM]: 1.2.3
  › @tauri-apps/api [NPM]: 1.2.0
  › tauri [RUST]: 1.2.4,
  › tauri-build [RUST]: 1.2.1,
  › tao [RUST]: 0.15.8,
  › wry [RUST]: 0.23.4,

App
  › build-type: bundle
  › CSP: unset
  › distDir: ../dist
  › devPath: http://localhost:1420/
  › framework: React
  › bundler: Vite

App directory structure
  ├─ .git
  ├─ .vscode
  ├─ dist
  ├─ node_modules
  ├─ public
  ├─ src
  └─ src-tauri

Stack trace

No response

Additional context

Adding a handler for it via on_window_event works fine

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions