summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml2
-rw-r--r--examples/url_handler/Cargo.toml4
-rw-r--r--examples/url_handler/src/main.rs18
-rw-r--r--glutin/src/application.rs5
-rw-r--r--native/src/event.rs25
-rw-r--r--winit/src/application.rs5
6 files changed, 41 insertions, 18 deletions
diff --git a/Cargo.toml b/Cargo.toml
index f00a197c..789ece88 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -93,7 +93,7 @@ iced_futures = { version = "0.3", path = "futures" }
thiserror = "1.0"
[patch.crates-io]
-winit = { git="https://github.com/cryptowatch/winit", rev="f9180f3b3c0f4fb8fd8c65bd0adf641cd6b32dd0" }
+winit = { git="https://github.com/iced-rs/winit", rev="152eda9b2d995dd0f5b886a53bddac7c75738b47" }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
iced_winit = { version = "0.3", path = "winit" }
diff --git a/examples/url_handler/Cargo.toml b/examples/url_handler/Cargo.toml
index 595bdac0..911b2f25 100644
--- a/examples/url_handler/Cargo.toml
+++ b/examples/url_handler/Cargo.toml
@@ -7,6 +7,4 @@ publish = false
[dependencies]
iced = { path = "../.." }
-iced_native = { path = "../../native" }
-syslog="4.0"
-log="0.4" \ No newline at end of file
+iced_native = { path = "../../native" } \ No newline at end of file
diff --git a/examples/url_handler/src/main.rs b/examples/url_handler/src/main.rs
index 56d81031..f14e5227 100644
--- a/examples/url_handler/src/main.rs
+++ b/examples/url_handler/src/main.rs
@@ -1,8 +1,11 @@
use iced::{
- executor, Application, Command, Clipboard,
- Container, Element, Length, Settings, Subscription, Text,
+ executor, Application, Clipboard, Command, Container, Element, Length,
+ Settings, Subscription, Text,
+};
+use iced_native::{
+ event::{MacOS, PlatformSpecific},
+ Event,
};
-use iced_native::Event;
pub fn main() -> iced::Result {
App::run(Settings::default())
@@ -38,7 +41,10 @@ impl Application for App {
) -> Command<Message> {
match message {
Message::EventOccurred(event) => {
- if let Event::UrlReceived(url) = event{
+ if let Event::PlatformSpecific(PlatformSpecific::MacOS(
+ MacOS::ReceivedUrl(url),
+ )) = event
+ {
self.url = Some(url);
}
}
@@ -52,9 +58,9 @@ impl Application for App {
}
fn view(&mut self) -> Element<Message> {
- let content = match &self.url{
+ let content = match &self.url {
Some(url) => Text::new(format!("{}", url)),
- None => Text::new("No URL received yet!")
+ None => Text::new("No URL received yet!"),
};
Container::new(content.size(48))
diff --git a/glutin/src/application.rs b/glutin/src/application.rs
index 55293b3b..22dff149 100644
--- a/glutin/src/application.rs
+++ b/glutin/src/application.rs
@@ -237,8 +237,9 @@ async fn run_instance<A, E, C>(
context.window().request_redraw();
}
- event::Event::ReceivedUrl(url) => {
- events.push(iced_native::Event::UrlReceived(url));
+ event::Event::PlatformSpecific(event::PlatformSpecific::MacOS(event::MacOS::ReceivedUrl(url))) => {
+ use iced_native::event;
+ events.push(iced_native::Event::PlatformSpecific(event::PlatformSpecific::MacOS(event::MacOS::ReceivedUrl(url))));
}
event::Event::UserEvent(message) => {
messages.push(message);
diff --git a/native/src/event.rs b/native/src/event.rs
index 59c5c0cb..1c26b5f2 100644
--- a/native/src/event.rs
+++ b/native/src/event.rs
@@ -23,10 +23,27 @@ pub enum Event {
/// A touch event
Touch(touch::Event),
-
- // TODO: System(system::Event)?
- /// A url was received.
- UrlReceived(String),
+
+ /// A platform specific event
+ PlatformSpecific(PlatformSpecific),
+}
+
+/// A platform specific event
+#[derive(Debug, Clone, PartialEq)]
+pub enum PlatformSpecific {
+ /// A MacOS specific event
+ MacOS(MacOS),
+}
+
+/// Describes an event specific to MacOS
+#[derive(Debug, Clone, PartialEq)]
+pub enum MacOS {
+ /// Triggered when the app receives an URL from the system
+ ///
+ /// _**Note:** For this event to be triggered, the executable needs to be properly [bundled]!_
+ ///
+ /// [bundled]: https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html#//apple_ref/doc/uid/10000123i-CH101-SW19
+ ReceivedUrl(String),
}
/// The status of an [`Event`] after being processed.
diff --git a/winit/src/application.rs b/winit/src/application.rs
index 9f51ae68..ce57bd1d 100644
--- a/winit/src/application.rs
+++ b/winit/src/application.rs
@@ -310,8 +310,9 @@ async fn run_instance<A, E, C>(
window.request_redraw();
}
- event::Event::ReceivedUrl(url) => {
- events.push(iced_native::Event::UrlReceived(url));
+ event::Event::PlatformSpecific(event::PlatformSpecific::MacOS(event::MacOS::ReceivedUrl(url))) => {
+ use iced_native::event;
+ events.push(iced_native::Event::PlatformSpecific(event::PlatformSpecific::MacOS(event::MacOS::ReceivedUrl(url))));
}
event::Event::UserEvent(message) => {
messages.push(message);