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::Action::ToggleDecorations => {
|
||||||
window.set_decorations(!window.is_decorated())
|
window.set_decorations(!window.is_decorated())
|
||||||
}
|
}
|
||||||
window::Action::RequestUserAttention(attention_type) => window
|
window::Action::RequestUserAttention(user_attention) => window
|
||||||
.request_user_attention(match attention_type {
|
.request_user_attention(
|
||||||
Some(window::UserAttention::Critical) => {
|
user_attention.map(conversion::user_attention),
|
||||||
Some(winit::window::UserAttentionType::Critical)
|
),
|
||||||
}
|
|
||||||
Some(window::UserAttention::Informational) => Some(
|
|
||||||
winit::window::UserAttentionType::Informational,
|
|
||||||
),
|
|
||||||
None => None,
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
command::Action::System(action) => match action {
|
command::Action::System(action) => match action {
|
||||||
system::Action::QueryInformation(_tag) => {
|
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
|
// As defined in: http://www.unicode.org/faq/private_use.html
|
||||||
pub(crate) fn is_private_use_character(c: char) -> bool {
|
pub(crate) fn is_private_use_character(c: char) -> bool {
|
||||||
matches!(
|
matches!(
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
use crate::command::{self, Command};
|
use crate::command::{self, Command};
|
||||||
use iced_native::window;
|
use iced_native::window;
|
||||||
|
|
||||||
pub use window::{Event, Mode};
|
pub use window::{Event, Mode, UserAttention};
|
||||||
|
|
||||||
/// Closes the current window and exits the application.
|
/// Closes the current window and exits the application.
|
||||||
pub fn close<Message>() -> Command<Message> {
|
pub fn close<Message>() -> Command<Message> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue