Push window resize and scale factor messages to bevy_window_events#24046
Merged
alice-i-cecile merged 5 commits intobevyengine:mainfrom May 4, 2026
Merged
Push window resize and scale factor messages to bevy_window_events#24046alice-i-cecile merged 5 commits intobevyengine:mainfrom
bevy_window_events#24046alice-i-cecile merged 5 commits intobevyengine:mainfrom
Conversation
Contributor
|
Welcome, new contributor! Please make sure you've read our contributing guide, as well as our policy regarding AI usage, and we look forward to reviewing your pull request shortly ✨ |
bevy_window_eventsbevy_window_events
alice-i-cecile
requested changes
Apr 30, 2026
Member
There was a problem hiding this comment.
Oh, that explains this bug! Very good fix.
Three things to fix up before we merge:
- A small omission in the other code path, see comment.
setup_react_to_scale_factor_change_test_appshould more realistic (it doesn't check WindowEvent).- A similar test (or redesigned test) for window resizing.
alice-i-cecile
approved these changes
May 1, 2026
kfc35
approved these changes
May 1, 2026
Contributor
kfc35
left a comment
There was a problem hiding this comment.
Looks good! Thank you for your first contribution 🎊
Member
|
CI failure in https://github.com/bevyengine/bevy/actions/runs/25295357200/job/74153180619 is real. Let us know if you'd like help; this is quite obscure :) |
Contributor
Author
|
Sorry about that, I think it's fixed. Thanks for pointing me in the right direction |
cart
pushed a commit
to chronicl/bevy
that referenced
this pull request
May 4, 2026
…evyengine#24046) I was initially using `MessageReader<WindowResized>` in my system for my app but once my system grew to use more and more window events, I refactored to using `MessageReader<WindowEvent>` and matching on its variants. This is where I ran into the issue of the `WindowEvent::WindowResized` case never matching. When making this PR, I noticed `WindowEvent::WindowBackendScaleFactorChanged` and `WindowEvent::WindowScaleFactorChanged` had the same issue. # Objective Fixes bevyengine#15268 ## Solution Instead of writing into `MessageWriter<WindowResized>`, `MessageWriter<WindowBackendScaleFactorChanged>` and `MessageWriter<WindowScaleFactorChanged>`, push into `bevy_window_events` where it gets sent to the `forward_bevy_events` function for syncing the messages. ## Testing I made local modifications to the `window_resizing` example to use a `MessageReader<WindowEvent>` instead of `MessageReader<WindowResized>` like so: ```rs fn on_resize_system( mut text: Single<&mut Text, With<ResolutionText>>, mut resize_reader: MessageReader<WindowEvent>, ) { for e in resize_reader.read() { if let WindowEvent::WindowResized(e) = e { // When resolution is being changed text.0 = format!("{:.1} x {:.1}", e.width, e.height); } } } ``` I ran this example on linux wayland.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I was initially using
MessageReader<WindowResized>in my system for my app but once my system grew to use more and more window events, I refactored to usingMessageReader<WindowEvent>and matching on its variants. This is where I ran into the issue of theWindowEvent::WindowResizedcase never matching.When making this PR, I noticed
WindowEvent::WindowBackendScaleFactorChangedandWindowEvent::WindowScaleFactorChangedhad the same issue.Objective
Fixes #15268
Solution
Instead of writing into
MessageWriter<WindowResized>,MessageWriter<WindowBackendScaleFactorChanged>andMessageWriter<WindowScaleFactorChanged>, push intobevy_window_eventswhere it gets sent to theforward_bevy_eventsfunction for syncing the messages.Testing
I made local modifications to the
window_resizingexample to use aMessageReader<WindowEvent>instead ofMessageReader<WindowResized>like so:I ran this example on linux wayland.