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 Feb 24, 2023
1 parent a006cd7 commit 430e715
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/platform_impl/macos/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,10 @@ impl WinitWindow {
// Set fullscreen mode after we setup everything
this.set_fullscreen(attrs.fullscreen.map(Into::into));

// XXX This should be set before doing any active state manipulations, so we don't
// end up overwriting the real focused state.
delegate.queue_event(WindowEvent::Focused(false));

// Setting the window as key has to happen *after* we set the fullscreen
// state, since otherwise we'll briefly see the window at normal size
// before it transitions.
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 430e715

Please sign in to comment.