Create conversion function for user_attention in iced_winit
This commit is contained in:
parent
d95b9bf244
commit
6855961358
3 changed files with 21 additions and 11 deletions
|
|
@ -674,16 +674,10 @@ pub fn run_command<A, E>(
|
|||
window::Action::ToggleDecorations => {
|
||||
window.set_decorations(!window.is_decorated())
|
||||
}
|
||||
window::Action::RequestUserAttention(attention_type) => window
|
||||
.request_user_attention(match attention_type {
|
||||
Some(window::UserAttention::Critical) => {
|
||||
Some(winit::window::UserAttentionType::Critical)
|
||||
}
|
||||
Some(window::UserAttention::Informational) => Some(
|
||||
winit::window::UserAttentionType::Informational,
|
||||
),
|
||||
None => None,
|
||||
}),
|
||||
window::Action::RequestUserAttention(user_attention) => window
|
||||
.request_user_attention(
|
||||
user_attention.map(conversion::user_attention),
|
||||
),
|
||||
},
|
||||
command::Action::System(action) => match action {
|
||||
system::Action::QueryInformation(_tag) => {
|
||||
|
|
|
|||
|
|
@ -493,6 +493,22 @@ pub fn key_code(
|
|||
}
|
||||
}
|
||||
|
||||
/// Converts some [`UserAttention`] into it's `winit` counterpart.
|
||||
///
|
||||
/// [`UserAttention`]: window::UserAttention
|
||||
pub fn user_attention(
|
||||
user_attention: window::UserAttention,
|
||||
) -> winit::window::UserAttentionType {
|
||||
match user_attention {
|
||||
window::UserAttention::Critical => {
|
||||
winit::window::UserAttentionType::Critical
|
||||
}
|
||||
window::UserAttention::Informational => {
|
||||
winit::window::UserAttentionType::Informational
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// As defined in: http://www.unicode.org/faq/private_use.html
|
||||
pub(crate) fn is_private_use_character(c: char) -> bool {
|
||||
matches!(
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
use crate::command::{self, Command};
|
||||
use iced_native::window;
|
||||
|
||||
pub use window::{Event, Mode};
|
||||
pub use window::{Event, Mode, UserAttention};
|
||||
|
||||
/// Closes the current window and exits the application.
|
||||
pub fn close<Message>() -> Command<Message> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue