SIGN IN SIGN UP
bevyengine / bevy UNCLAIMED

A refreshingly simple data-driven game engine built in Rust

0 0 86 Rust

fix: process window position before size in changed_windows (#23248)

## Summary

When a bevy app starts, winit creates the window on a default monitor.
If the app then sets the window's position to a location on a different
monitor with a different scale factor, both position and size may be
applied in the same pass through `changed_windows()`.

Currently, size is processed first (via `request_inner_size`), then
position (via `set_outer_position`). Since the window hasn't moved yet
when `request_inner_size` runs, it uses the default monitor's scale
factor for the size calculation — not the scale factor of the monitor
the window is about to move to. This produces the wrong size when the
two monitors have different scale factors.

This PR moves the position block above the size block so the window is
on the target monitor before `request_inner_size` runs.

## Context

This change is a **no-op with current released versions of winit**.
Today, winit's `set_outer_position` has a bug where it uses the window's
current monitor's scale factor instead of the target monitor's
([rust-windowing/winit#4505](https://github.com/rust-windowing/winit/pull/4505)),
so the window doesn't reliably land at the correct position regardless
of ordering.

Once winit merges that fix and bevy takes a dependency on a version that
includes it, the ordering will matter: `set_outer_position` will
correctly move the window to the target monitor, and
`request_inner_size` needs to run *after* that move so it sees the
correct `scale_factor()`.

The change is safe and backwards-compatible — it just reorders two
independent blocks within the same function.

## Testing

Tested on macOS (1x + 2x) and Windows (1x + 1.5x) with the patched
winit. Window appears at the correct position and size on the target
monitor.
N
natepiano committed
4ad55b0101f90bd027d3abce20d62cf5b95b5c83
Parent: 218069f
Committed by GitHub <noreply@github.com> on 3/9/2026, 9:38:37 PM