Skip to content

Commit

Permalink
On macOS, fix initial focused state
Browse files Browse the repository at this point in the history
The synthetic focused event was queued after the real event was send
leading to focused issues on startup.

Fixes rust-windowing#2695.
  • Loading branch information
kchibisov committed Mar 1, 2023
1 parent 1f6ea58 commit 53b27af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ And please only add new entries to the top of this list, right below the `# Unre
- On Wayland, fix rare crash on DPI change
- Web: Added support for `Window::theme`.
- On Wayland, fix rounding issues when doing resize.
- On macOS, fix wrong focused state on startup.

# 0.28.1

Expand Down
6 changes: 4 additions & 2 deletions src/platform_impl/macos/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,10 @@ impl WinitWindow {

let delegate = WinitWindowDelegate::new(&this, attrs.fullscreen.is_some());

// XXX Send `Focused(false)` right after creating the window delegate, so we won't
// obscure the real focused events on the startup.
delegate.queue_event(WindowEvent::Focused(false));

// Set fullscreen mode after we setup everything
this.set_fullscreen(attrs.fullscreen.map(Into::into));

Expand All @@ -485,8 +489,6 @@ impl WinitWindow {
this.set_maximized(attrs.maximized);
}

delegate.queue_event(WindowEvent::Focused(false));

Ok((this, delegate))
}

Expand Down

0 comments on commit 53b27af

Please sign in to comment.