Skip to content

Commit 985d250

Browse files
authored
fix(tauri): export WindowBuilder struct instead of trait, closes #3827 (#3833)
1 parent 50d135b commit 985d250

4 files changed

Lines changed: 26 additions & 23 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": patch
3+
---
4+
5+
Fixes the `WindowBuilder` export.

core/tauri/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ pub use {
211211
},
212212
self::manager::Asset,
213213
self::runtime::{
214-
webview::{WebviewAttributes, WindowBuilder},
214+
webview::WebviewAttributes,
215215
window::{
216216
dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize, Pixel, Position, Size},
217217
FileDropEvent,
@@ -224,7 +224,7 @@ pub use {
224224
config::{Config, WindowUrl},
225225
Env, PackageInfo,
226226
},
227-
self::window::{Monitor, Window},
227+
self::window::{Monitor, Window, WindowBuilder},
228228
scope::*,
229229
};
230230

examples/multiwindow/main.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@ fn main() {
1717
println!("got 'clicked' event on window '{}'", label);
1818
});
1919
})
20-
.create_window(
21-
"Rust".to_string(),
22-
tauri::WindowUrl::App("index.html".into()),
23-
|window_builder, webview_attributes| {
24-
(window_builder.title("Tauri - Rust"), webview_attributes)
25-
},
26-
)
27-
.unwrap() // safe to unwrap: window label is valid
20+
.setup(|app| {
21+
WindowBuilder::new(
22+
app,
23+
"Rust".to_string(),
24+
tauri::WindowUrl::App("index.html".into()),
25+
)
26+
.title("Tauri - Rust")
27+
.build()?;
28+
Ok(())
29+
})
2830
.run(tauri::generate_context!(
2931
"../../examples/multiwindow/tauri.conf.json"
3032
))

examples/parent-window/main.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99

1010
#[cfg(any(windows, target_os = "macos"))]
1111
use tauri::Manager;
12-
use tauri::{command, window, AppHandle, WindowBuilder, WindowUrl};
12+
use tauri::{command, window::WindowBuilder, AppHandle, WindowUrl};
1313

1414
#[command]
1515
fn create_child_window(id: String, app: AppHandle) {
1616
#[cfg(any(windows, target_os = "macos"))]
1717
let main = app.get_window("main").unwrap();
1818

19-
let child = window::WindowBuilder::new(&app, id, WindowUrl::default())
19+
let child = WindowBuilder::new(&app, id, WindowUrl::default())
2020
.title("Child")
2121
.inner_size(400.0, 300.0);
2222

@@ -37,17 +37,13 @@ fn main() {
3737
});
3838
})
3939
.invoke_handler(tauri::generate_handler![create_child_window])
40-
.create_window(
41-
"main".to_string(),
42-
WindowUrl::default(),
43-
|window_builder, webview_attributes| {
44-
(
45-
window_builder.title("Main").inner_size(600.0, 400.0),
46-
webview_attributes,
47-
)
48-
},
49-
)
50-
.unwrap() // safe to unwrap: window label is valid
40+
.setup(|app| {
41+
WindowBuilder::new(app, "main".to_string(), WindowUrl::default())
42+
.title("Main")
43+
.inner_size(600.0, 400.0)
44+
.build()?;
45+
Ok(())
46+
}) // safe to unwrap: window label is valid
5147
.run(tauri::generate_context!(
5248
"../../examples/parent-window/tauri.conf.json"
5349
))

0 commit comments

Comments
 (0)