Skip to content

Commit

Permalink
fix(tauri): export WindowBuilder struct instead of trait, closes #3827
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored Mar 31, 2022
1 parent 50d135b commit 985d250
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 23 deletions.
5 changes: 5 additions & 0 deletions .changes/fix-window-builder-export.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri": patch
---

Fixes the `WindowBuilder` export.
4 changes: 2 additions & 2 deletions core/tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ pub use {
},
self::manager::Asset,
self::runtime::{
webview::{WebviewAttributes, WindowBuilder},
webview::WebviewAttributes,
window::{
dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize, Pixel, Position, Size},
FileDropEvent,
Expand All @@ -224,7 +224,7 @@ pub use {
config::{Config, WindowUrl},
Env, PackageInfo,
},
self::window::{Monitor, Window},
self::window::{Monitor, Window, WindowBuilder},
scope::*,
};

Expand Down
18 changes: 10 additions & 8 deletions examples/multiwindow/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ fn main() {
println!("got 'clicked' event on window '{}'", label);
});
})
.create_window(
"Rust".to_string(),
tauri::WindowUrl::App("index.html".into()),
|window_builder, webview_attributes| {
(window_builder.title("Tauri - Rust"), webview_attributes)
},
)
.unwrap() // safe to unwrap: window label is valid
.setup(|app| {
WindowBuilder::new(
app,
"Rust".to_string(),
tauri::WindowUrl::App("index.html".into()),
)
.title("Tauri - Rust")
.build()?;
Ok(())
})
.run(tauri::generate_context!(
"../../examples/multiwindow/tauri.conf.json"
))
Expand Down
22 changes: 9 additions & 13 deletions examples/parent-window/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

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

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

let child = window::WindowBuilder::new(&app, id, WindowUrl::default())
let child = WindowBuilder::new(&app, id, WindowUrl::default())
.title("Child")
.inner_size(400.0, 300.0);

Expand All @@ -37,17 +37,13 @@ fn main() {
});
})
.invoke_handler(tauri::generate_handler![create_child_window])
.create_window(
"main".to_string(),
WindowUrl::default(),
|window_builder, webview_attributes| {
(
window_builder.title("Main").inner_size(600.0, 400.0),
webview_attributes,
)
},
)
.unwrap() // safe to unwrap: window label is valid
.setup(|app| {
WindowBuilder::new(app, "main".to_string(), WindowUrl::default())
.title("Main")
.inner_size(600.0, 400.0)
.build()?;
Ok(())
}) // safe to unwrap: window label is valid
.run(tauri::generate_context!(
"../../examples/parent-window/tauri.conf.json"
))
Expand Down

0 comments on commit 985d250

Please sign in to comment.