-
-
Notifications
You must be signed in to change notification settings - Fork 3
fix: webview tracking #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fixed an issue where the embedded webview position would sometimes be incorrect when the window moved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes webview positioning issues that occurred when windows were moved or resized. The changes address the tracking and positioning of embedded webviews by improving event handling and component management.
- Enhanced window event handling to track both window moves and resizes
- Updated component insertion/removal to use safer try_* methods
- Optimized webview positioning updates with deduplication logic
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/bevy_webview_wry/src/webview/protocol.rs | Switched to safer try_insert and try_remove methods for component management |
| crates/bevy_webview_wry/src/webview/load_webview.rs | Added window move tracking, improved event handling with deduplication, and refined webview positioning logic |
Comments suppressed due to low confidence (1)
crates/bevy_webview_wry/src/webview/load_webview.rs:337
- [nitpick] The variable name 'windows' could be more descriptive. Consider renaming to 'processed_windows' or 'handled_windows' to clarify its purpose as a deduplication tracker.
let mut windows = bevy::platform::collections::HashSet::new();
| App, Commands, Entity, Name, NonSend, NonSendMut, Or, Plugin, PreUpdate, Query, Res, Window, | ||
| With, Without, | ||
| }; | ||
| use bevy::prelude::*; |
Copilot
AI
Jul 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Using wildcard imports (use bevy::prelude::*;) can make code less readable and may introduce naming conflicts. Consider importing only the specific items needed or using the previous explicit import style.
| use bevy::prelude::*; | |
| use bevy::prelude::{App, Plugin, PreUpdate, Update, WindowMoved, on_event}; |
| wry_webview | ||
| .ns_window() | ||
| .setFrame_display(ns_window.contentRectForFrameRect(ns_window.frame()), true); | ||
| let wry_ns_window = wry_webview.ns_window(); |
Copilot
AI
Jul 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change from true to false for the display parameter in setFrame_display should be documented. This parameter controls whether the window is immediately redrawn, and the change may have performance implications.
| let wry_ns_window = wry_webview.ns_window(); | |
| let wry_ns_window = wry_webview.ns_window(); | |
| // The `display` parameter is set to `false` to avoid immediate redraw of the window. | |
| // This is intentional to optimize performance, as the redraw is handled elsewhere. |
Fixed an issue where the embedded webview position would sometimes be incorrect when the window moved.