-
-
Notifications
You must be signed in to change notification settings - Fork 359
Open
Labels
Description
Describe the bug
Setting a window's title using Window.set_title
inside of a callback registered in with_document_title_changed_handler
does nothing.
Steps To Reproduce
Replace examples/simple.rs
with the following code and run it. Observe the window title, and the message in stderr confirming that the callback is called with a valid title and window.
// Copyright 2020-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
use std::sync::Arc;
use tao::{
event::{Event, WindowEvent},
event_loop::{ControlFlow, EventLoop},
window::WindowBuilder,
};
use wry::WebViewBuilder;
fn main() -> wry::Result<()> {
let event_loop = EventLoop::new();
let window = Arc::new(WindowBuilder::new().build(&event_loop).unwrap());
let builder = WebViewBuilder::new()
.with_url("http://tauri.app")
.with_drag_drop_handler(|e| {
match e {
wry::DragDropEvent::Enter { paths, position } => {
println!("DragEnter: {position:?} {paths:?} ")
}
wry::DragDropEvent::Over { position } => println!("DragOver: {position:?} "),
wry::DragDropEvent::Drop { paths, position } => {
println!("DragDrop: {position:?} {paths:?} ")
}
wry::DragDropEvent::Leave => println!("DragLeave"),
_ => {}
}
true
}).with_document_title_changed_handler({
let window = Arc::downgrade(&window);
move |title| {
eprintln!("DEBUG: {title:?} {:?}", window.upgrade());
if let Some(window) = window.upgrade() {
window.set_title(&title);
}
}
});
#[cfg(any(
target_os = "windows",
target_os = "macos",
target_os = "ios",
target_os = "android"
))]
let _webview = builder.build(&window)?;
#[cfg(not(any(
target_os = "windows",
target_os = "macos",
target_os = "ios",
target_os = "android"
)))]
let _webview = {
use tao::platform::unix::WindowExtUnix;
use wry::WebViewBuilderExtUnix;
let vbox = window.default_vbox().unwrap();
builder.build_gtk(vbox)?
};
event_loop.run(move |event, _, control_flow| {
*control_flow = ControlFlow::Wait;
if let Event::WindowEvent {
event: WindowEvent::CloseRequested,
..
} = event
{
*control_flow = ControlFlow::Exit;
}
});
}
Expected behavior
The window's title changes to match the document title.
Screenshots
Platform and Versions (please complete the following information):
OS: Arch Linux, using Plasma 6.3.5
Rustc: 1.85.1
wry: 0.51.2
Additional context
Forcing xwayland by running via env WAYLAND_DISPLAY=asdf cargo run --example simple
makes the example work.