-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com> Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
- Loading branch information
1 parent
d36c8e0
commit 4e807a5
Showing
16 changed files
with
239 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"tauri": patch | ||
--- | ||
|
||
**Breaking change:** The `Window::hwnd` method now returns *HWND* from `windows-rs` crate instead of *c_void* on Windows. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"tauri-runtime-wry": minor | ||
"tauri-runtime": minor | ||
"tauri": minor | ||
--- | ||
|
||
Support window parenting on macOS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Parent Window Example | ||
|
||
Run the following at the root directory of the repository to try it out: `cargo run --example parent-window`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<style> | ||
#response { | ||
white-space: pre-wrap; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div id="window-label"></div> | ||
<div id="container"></div> | ||
<div id="response"></div> | ||
|
||
<script> | ||
var WebviewWindow = window.__TAURI__.window.WebviewWindow | ||
var thisTauriWindow = window.__TAURI__.window.getCurrent() | ||
var windowLabel = thisTauriWindow.label | ||
var windowLabelContainer = document.getElementById('window-label') | ||
windowLabelContainer.innerText = 'This is the ' + windowLabel + ' window.' | ||
|
||
var container = document.getElementById('container') | ||
|
||
var responseContainer = document.getElementById('response') | ||
function runCommand(commandName, args, optional) { | ||
window.__TAURI__ | ||
.invoke(commandName, args) | ||
.then((response) => { | ||
responseContainer.innerText += `Ok(${response})\n\n` | ||
}) | ||
.catch((error) => { | ||
responseContainer.innerText += `Err(${error})\n\n` | ||
}) | ||
} | ||
window.__TAURI__.event.listen('tauri://window-created', function (event) { | ||
responseContainer.innerText += 'Got window-created event\n\n' | ||
}) | ||
|
||
var createWindowButton = document.createElement('button') | ||
var windowNumber = 1 | ||
createWindowButton.innerHTML = 'Create child window '+windowNumber | ||
createWindowButton.addEventListener('click', function () { | ||
runCommand('create_child_window', { id: 'child-'+windowNumber }) | ||
windowNumber += 1 | ||
createWindowButton.innerHTML = 'Create child window '+windowNumber | ||
}) | ||
container.appendChild(createWindowButton) | ||
</script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Generated by Cargo | ||
# will have compiled files and executables | ||
/target/ | ||
WixTools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Copyright {20\d{2}(-20\d{2})?} Tauri Programme within The Commons Conservancy | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-License-Identifier: MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[package] | ||
name = "parent-window" | ||
version = "0.1.0" | ||
description = "An example Tauri Multi-Window Application" | ||
edition = "2021" | ||
rust-version = "1.57" | ||
license = "Apache-2.0 OR MIT" | ||
|
||
[build-dependencies] | ||
tauri-build = { path = "../../../core/tauri-build" } | ||
|
||
[dependencies] | ||
tauri = { path = "../../../core/tauri" } | ||
|
||
[features] | ||
default = [ "custom-protocol" ] | ||
custom-protocol = [ "tauri/custom-protocol" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-License-Identifier: MIT | ||
|
||
use tauri_build::{try_build, Attributes, WindowsAttributes}; | ||
|
||
fn main() { | ||
if let Err(error) = try_build( | ||
Attributes::new() | ||
.windows_attributes(WindowsAttributes::new().window_icon_path("../../.icons/icon.ico")), | ||
) { | ||
panic!("error found during tauri-build: {:#?}", error); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-License-Identifier: MIT | ||
|
||
use tauri::{command, window, AppHandle, Manager, WindowUrl}; | ||
|
||
#[command] | ||
pub 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()) | ||
.title("Child") | ||
.inner_size(400.0, 300.0); | ||
|
||
#[cfg(target_os = "macos")] | ||
let child = child.parent_window(main.ns_window().unwrap()); | ||
#[cfg(windows)] | ||
let child = child.parent_window(main.hwnd().unwrap()); | ||
|
||
child.build().unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-License-Identifier: MIT | ||
|
||
#![cfg_attr( | ||
all(not(debug_assertions), target_os = "windows"), | ||
windows_subsystem = "windows" | ||
)] | ||
|
||
use tauri::{WindowBuilder, WindowUrl}; | ||
|
||
mod commands; | ||
|
||
fn main() { | ||
tauri::Builder::default() | ||
.on_page_load(|window, _payload| { | ||
let label = window.label().to_string(); | ||
window.listen("clicked".to_string(), move |_payload| { | ||
println!("got 'clicked' event on window '{}'", label); | ||
}); | ||
}) | ||
.invoke_handler(tauri::generate_handler![commands::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 | ||
.run(tauri::generate_context!( | ||
"../../examples/parent-window/src-tauri/tauri.conf.json" | ||
)) | ||
.expect("failed to run tauri application"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"build": { | ||
"distDir": [ | ||
"../index.html" | ||
], | ||
"devPath": [ | ||
"../index.html" | ||
], | ||
"withGlobalTauri": true | ||
}, | ||
"tauri": { | ||
"bundle": { | ||
"active": true, | ||
"targets": "all", | ||
"identifier": "com.tauri.dev", | ||
"icon": [ | ||
"../../.icons/32x32.png", | ||
"../../.icons/128x128.png", | ||
"../../.icons/128x128@2x.png", | ||
"../../.icons/icon.icns", | ||
"../../.icons/icon.ico" | ||
], | ||
"resources": [], | ||
"externalBin": [], | ||
"copyright": "", | ||
"category": "DeveloperTool" | ||
}, | ||
"allowlist": {}, | ||
"security": { | ||
"csp": "default-src 'self'" | ||
}, | ||
"updater": { | ||
"active": false | ||
} | ||
} | ||
} |