Use crates.io release of winit 🎉
This commit is contained in:
parent
b11ad9ff5e
commit
8d7aac96d7
9 changed files with 11 additions and 143 deletions
17
Cargo.lock
generated
17
Cargo.lock
generated
|
|
@ -1349,8 +1349,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "dpi"
|
||||
version = "0.1.1"
|
||||
source = "git+https://github.com/iced-rs/winit.git?rev=05b8ff17a06562f0a10bb46e6eaacbe2a95cb5ed#05b8ff17a06562f0a10bb46e6eaacbe2a95cb5ed"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d8b14ccef22fc6f5a8f4d7d768562a182c04ce9a3b3157b91390b52ddfdf1a76"
|
||||
|
||||
[[package]]
|
||||
name = "editor"
|
||||
|
|
@ -6336,13 +6337,6 @@ dependencies = [
|
|||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "url_handler"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"iced",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "urlencoding"
|
||||
version = "2.1.3"
|
||||
|
|
@ -7482,8 +7476,9 @@ checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650"
|
|||
|
||||
[[package]]
|
||||
name = "winit"
|
||||
version = "0.30.8"
|
||||
source = "git+https://github.com/iced-rs/winit.git?rev=05b8ff17a06562f0a10bb46e6eaacbe2a95cb5ed#05b8ff17a06562f0a10bb46e6eaacbe2a95cb5ed"
|
||||
version = "0.30.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c66d4b9ed69c4009f6321f762d6e61ad8a2389cd431b97cb1e146812e9e6c732"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"android-activity",
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ web-sys = "0.3.69"
|
|||
web-time = "1.1"
|
||||
wgpu = { version = "27.0", default-features = false, features = ["std", "wgsl"] }
|
||||
window_clipboard = { version = "0.5", default-features = false }
|
||||
winit = { git = "https://github.com/iced-rs/winit.git", rev = "05b8ff17a06562f0a10bb46e6eaacbe2a95cb5ed", default-features = false, features = ["rwh_06"] }
|
||||
winit = { version = "0.30", default-features = false, features = ["rwh_06"] }
|
||||
|
||||
[workspace.lints.rust]
|
||||
rust_2018_idioms = { level = "deny", priority = -1 }
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
[package]
|
||||
name = "url_handler"
|
||||
version = "0.1.0"
|
||||
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
|
||||
edition = "2024"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
iced.workspace = true
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
use iced::event;
|
||||
use iced::widget::{center, text};
|
||||
use iced::{Element, Subscription};
|
||||
|
||||
pub fn main() -> iced::Result {
|
||||
iced::application(App::default, App::update, App::view)
|
||||
.subscription(App::subscription)
|
||||
.run()
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
struct App {
|
||||
url: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
enum Message {
|
||||
UrlReceived(String),
|
||||
}
|
||||
|
||||
impl App {
|
||||
fn update(&mut self, message: Message) {
|
||||
match message {
|
||||
Message::UrlReceived(url) => {
|
||||
self.url = Some(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn subscription(&self) -> Subscription<Message> {
|
||||
event::listen_url().map(Message::UrlReceived)
|
||||
}
|
||||
|
||||
fn view(&self) -> Element<'_, Message> {
|
||||
let content = match &self.url {
|
||||
Some(url) => text(url),
|
||||
None => text("No URL received yet!"),
|
||||
};
|
||||
|
||||
center(content.size(48)).into()
|
||||
}
|
||||
}
|
||||
|
|
@ -37,8 +37,7 @@ where
|
|||
event: Event::Window(window::Event::RedrawRequested(_)),
|
||||
..
|
||||
}
|
||||
| subscription::Event::SystemThemeChanged(_)
|
||||
| subscription::Event::PlatformSpecific(_) => None,
|
||||
| subscription::Event::SystemThemeChanged(_) => None,
|
||||
subscription::Event::Interaction {
|
||||
window,
|
||||
event,
|
||||
|
|
@ -67,27 +66,6 @@ where
|
|||
event,
|
||||
status,
|
||||
} => f(event, status, window),
|
||||
subscription::Event::SystemThemeChanged(_)
|
||||
| subscription::Event::PlatformSpecific(_) => None,
|
||||
})
|
||||
}
|
||||
|
||||
/// Creates a [`Subscription`] that notifies of custom application URL
|
||||
/// received from the system.
|
||||
///
|
||||
/// _**Note:** Currently, it only triggers on macOS and 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
|
||||
pub fn listen_url() -> Subscription<String> {
|
||||
#[derive(Hash)]
|
||||
struct ListenUrl;
|
||||
|
||||
subscription::filter_map(ListenUrl, move |event| match event {
|
||||
subscription::Event::PlatformSpecific(
|
||||
subscription::PlatformSpecific::MacOS(
|
||||
subscription::MacOS::ReceivedUrl(url),
|
||||
),
|
||||
) => Some(url),
|
||||
_ => None,
|
||||
subscription::Event::SystemThemeChanged(_) => None,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,27 +30,6 @@ pub enum Event {
|
|||
|
||||
/// The system theme has changed.
|
||||
SystemThemeChanged(theme::Mode),
|
||||
|
||||
/// A platform specific event.
|
||||
PlatformSpecific(PlatformSpecific),
|
||||
}
|
||||
|
||||
/// A platform specific event
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum PlatformSpecific {
|
||||
/// A MacOS specific event
|
||||
MacOS(MacOS),
|
||||
}
|
||||
|
||||
/// Describes an event specific to MacOS
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
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),
|
||||
}
|
||||
|
||||
/// A stream of runtime events.
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@
|
|||
pub mod subscription {
|
||||
//! Write your own subscriptions.
|
||||
pub use crate::runtime::futures::subscription::{
|
||||
Event, EventStream, Hasher, MacOS, PlatformSpecific, Recipe,
|
||||
from_recipe, into_recipes,
|
||||
Event, EventStream, Hasher, Recipe, from_recipe, into_recipes,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -582,9 +582,7 @@ pub mod font {
|
|||
pub mod event {
|
||||
//! Handle events of a user interface.
|
||||
pub use crate::core::event::{Event, Status};
|
||||
pub use iced_futures::event::{
|
||||
listen, listen_raw, listen_url, listen_with,
|
||||
};
|
||||
pub use iced_futures::event::{listen, listen_raw, listen_with};
|
||||
}
|
||||
|
||||
pub mod keyboard {
|
||||
|
|
|
|||
|
|
@ -248,23 +248,6 @@ where
|
|||
);
|
||||
}
|
||||
|
||||
fn received_url(
|
||||
&mut self,
|
||||
event_loop: &winit::event_loop::ActiveEventLoop,
|
||||
url: String,
|
||||
) {
|
||||
self.process_event(
|
||||
event_loop,
|
||||
Event::EventLoopAwakened(
|
||||
winit::event::Event::PlatformSpecific(
|
||||
winit::event::PlatformSpecific::MacOS(
|
||||
winit::event::MacOS::ReceivedUrl(url),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
fn about_to_wait(
|
||||
&mut self,
|
||||
event_loop: &winit::event_loop::ActiveEventLoop,
|
||||
|
|
@ -761,19 +744,6 @@ async fn run_instance<P>(
|
|||
);
|
||||
}
|
||||
}
|
||||
event::Event::PlatformSpecific(
|
||||
event::PlatformSpecific::MacOS(
|
||||
event::MacOS::ReceivedUrl(url),
|
||||
),
|
||||
) => {
|
||||
runtime.broadcast(
|
||||
subscription::Event::PlatformSpecific(
|
||||
subscription::PlatformSpecific::MacOS(
|
||||
subscription::MacOS::ReceivedUrl(url),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
event::Event::UserEvent(action) => {
|
||||
run_action(
|
||||
action,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue