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
16 changes: 16 additions & 0 deletions .changes/android-breaking-changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
"tao": minor
---

**Breaking change:** The Android activity should now reference and call the following external functions:

```
private external fun onActivityCreate(activity)
private external fun start()
private external fun resume()
private external fun pause()
private external fun stop()
private external fun onActivitySaveInstanceState()
private external fun onActivityDestroy(activity)
private external fun onActivityLowMemory()
```
18 changes: 18 additions & 0 deletions .changes/multi-window-mobile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
"tao": minor
---

Added multi-window support for iOS and Android.

Leverages [scenes](https://developer.apple.com/documentation/uikit/scenes) on iOS and [Activity embedding](https://developer.android.com/develop/ui/views/layout/activity-embedding) on Android.

iOS:

- Added Event::SceneRequested (on iPad the user can request a new window to be open - e.g. by long pressing the app icon and selecting "New window")
- Request new scene to be created on Window::new (if needed, main scene is detected automatically) and assign the window instance later when it gets connected

Android:

- Create new activity on Window::new (if needed, main activity is detected automatically)
- Added builder methods to determine the activity to be created
- System determines what to do with the activity (new stack, next to another one.. based on the embedding rules)
116 changes: 108 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 33 additions & 21 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,52 @@ version = "0.34.5"
description = "Cross-platform window manager library."
authors = [
"Tauri Programme within The Commons Conservancy",
"The winit contributors"
"The winit contributors",
]
edition = "2021"
rust-version = "1.74"
keywords = [ "windowing" ]
keywords = ["windowing"]
license = "Apache-2.0"
readme = "README.md"
repository = "https://github.com/tauri-apps/tao"
documentation = "https://docs.rs/tao"
categories = [ "gui" ]
categories = ["gui"]
include = ["/README.md", "src/**/*.rs", "examples/**/*.rs", "LICENSE*"]

[package.metadata.docs.rs]
features = [ "rwh_04", "rwh_05", "rwh_06", "serde", "x11" ]
features = ["rwh_04", "rwh_05", "rwh_06", "serde", "x11"]
default-target = "x86_64-unknown-linux-gnu"
targets = [
"i686-pc-windows-msvc",
"x86_64-pc-windows-msvc",
"i686-unknown-linux-gnu",
"x86_64-unknown-linux-gnu",
"x86_64-apple-darwin"
"x86_64-apple-darwin",
]

[features]
default = [ "rwh_06", "x11" ]
serde = [ "dep:serde", "dpi/serde" ]
rwh_04 = [ "dep:rwh_04" ]
rwh_05 = [ "dep:rwh_05" ]
rwh_06 = [ "dep:rwh_06" ]
x11 = [ "dep:gdkx11-sys", "dep:x11-dl" ]
default = ["rwh_06", "x11"]
serde = ["dep:serde", "dpi/serde"]
rwh_04 = ["dep:rwh_04"]
rwh_05 = ["dep:rwh_05"]
rwh_06 = ["dep:rwh_06"]
x11 = ["dep:gdkx11-sys", "dep:x11-dl"]

[workspace]
members = [ "tao-macros" ]
members = ["tao-macros"]

[dependencies]
lazy_static = "1"
libc = "0.2"
log = "0.4"
serde = { version = "1", optional = true, features = [ "serde_derive" ] }
serde = { version = "1", optional = true, features = ["serde_derive"] }
rwh_04 = { package = "raw-window-handle", version = "0.4", optional = true }
rwh_05 = { package = "raw-window-handle", version = "0.5", features = [ "std" ], optional = true }
rwh_06 = { package = "raw-window-handle", version = "0.6", features = [ "std" ], optional = true }
rwh_05 = { package = "raw-window-handle", version = "0.5", features = [
"std",
], optional = true }
rwh_06 = { package = "raw-window-handle", version = "0.6", features = [
"std",
], optional = true }
bitflags = "2"
crossbeam-channel = "0.5"
url = "2"
Expand All @@ -64,9 +68,9 @@ unicode-segmentation = "1.11"
windows-version = "0.1"
windows-core = "0.61"

[target."cfg(target_os = \"windows\")".dependencies.windows]
version = "0.61"
features = [
[target."cfg(target_os = \"windows\")".dependencies.windows]
version = "0.61"
features = [
"Win32_Devices_HumanInterfaceDevice",
"Win32_Foundation",
"Win32_Globalization",
Expand All @@ -92,7 +96,7 @@ windows-core = "0.61"
"Win32_UI_Input_Touch",
"Win32_UI_Shell",
"Win32_UI_TextServices",
"Win32_UI_WindowsAndMessaging"
"Win32_UI_WindowsAndMessaging",
]

[target."cfg(any(target_os = \"android\", target_os = \"windows\"))".dependencies]
Expand All @@ -102,7 +106,6 @@ once_cell = "1"
jni = "0.21"
ndk = "0.9"
ndk-sys = "0.6"
ndk-context = "0.1"
tao-macros = { version = "0.1.0", path = "./tao-macros" }

[target."cfg(any(target_os = \"ios\", target_os = \"macos\"))".dependencies]
Expand Down Expand Up @@ -142,13 +145,22 @@ objc2-app-kit = { version = "0.3", default-features = false, features = [
"NSScreen",
"NSView",
"NSWindow",
"NSUserActivity"
"NSUserActivity",
] }
core-foundation = "0.10"
core-graphics = "0.24"
dispatch = "0.2"
scopeguard = "1.2"

[target."cfg(target_os = \"ios\")".dependencies]
objc2-ui-kit = { version = "0.3", features = [
"UIResponder",
"UIScene",
"UISceneOptions",
"UIOpenURLContext",
] }
objc2-foundation = { version = "0.3", default-features = false }

[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
gtk = "0.18"
gdkx11-sys = { version = "0.18", optional = true }
Expand Down
24 changes: 24 additions & 0 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,21 @@ pub enum Event<'a, T: 'static> {
/// - **Other**: Unsupported.
#[non_exhaustive]
Reopen { has_visible_windows: bool },

/// Emitted when a scene is requested by the system.
///
/// This event is emitted when a scene is requested by the system.
/// Scenes created by tao's window builder are not emitted with this event.
/// It is also not emitted for the main scene.
#[cfg(target_os = "ios")]
SceneRequested {
/// Scene that was requested by the system.
scene: objc2::rc::Retained<objc2_ui_kit::UIScene>,
/// Options that were used to request the scene.
///
/// This lets you determine why the scene was requested.
options: objc2::rc::Retained<objc2_ui_kit::UISceneConnectionOptions>,
},
}

impl<T: Clone> Clone for Event<'static, T> {
Expand Down Expand Up @@ -170,6 +185,11 @@ impl<T: Clone> Clone for Event<'static, T> {
} => Reopen {
has_visible_windows: *has_visible_windows,
},
#[cfg(target_os = "ios")]
SceneRequested { scene, options } => SceneRequested {
scene: scene.clone(),
options: options.clone(),
},
}
}
}
Expand All @@ -194,6 +214,8 @@ impl<'a, T> Event<'a, T> {
} => Ok(Reopen {
has_visible_windows,
}),
#[cfg(target_os = "ios")]
SceneRequested { scene, options } => Ok(SceneRequested { scene, options }),
}
}

Expand All @@ -220,6 +242,8 @@ impl<'a, T> Event<'a, T> {
} => Some(Reopen {
has_visible_windows,
}),
#[cfg(target_os = "ios")]
SceneRequested { scene, options } => Some(SceneRequested { scene, options }),
}
}
}
Expand Down
Loading
Loading