Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/fix-linux-gtk-fixed-webview-position.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wry": patch
---

On Linux, fix positioned child webviews in a `gtk::Fixed` losing their position after a layout pass. `WebView::set_bounds` now positions the webview via `gtk::Fixed::move_` (plus `set_size_request`) rather than a bare `size_allocate`, which the `gtk::Fixed` resets to the child's stored put-coordinate on the next size-allocate. This makes positioned multi-webview layouts created with `WebViewBuilderExtUnix::new_gtk` / `build_gtk` over a `gtk::Fixed` hold their bounds across resizes.
14 changes: 14 additions & 0 deletions src/webkitgtk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,20 @@ impl InnerWebView {
}

if self.is_in_fixed_parent {
// Position the webview via its parent `gtk::Fixed`'s `move_` (which persists
// across layout passes) and `set_size_request`, in addition to the
// immediate `size_allocate`. A bare `size_allocate` only sets a transient
// allocation that the `gtk::Fixed` resets to the child's stored
// put-coordinate on the next size-allocate, so the requested position was
// dropped on the first relayout.
if let Some(fixed) = self
.webview
.parent()
.and_then(|p| p.downcast::<gtk::Fixed>().ok())
{
fixed.move_(&self.webview, x, y);
}
self.webview.set_size_request(width, height);
self
.webview
.size_allocate(&gtk::Allocation::new(x, y, width, height));
Expand Down