summaryrefslogtreecommitdiffstats
path: root/winit
diff options
context:
space:
mode:
authorLibravatar Giuliano Bellini <100347457+GyulyVGC@users.noreply.github.com>2023-02-22 21:23:04 +0100
committerLibravatar GitHub <noreply@github.com>2023-02-22 21:23:04 +0100
commit4f41927155e7d4bc38497b0e298a0b23ccea6ca1 (patch)
tree70b7dbc1afdc62dfeaf42f0c62e8f4c01e407729 /winit
parenta35d6d2e4d59f71309f31c87ea5150959d639185 (diff)
parent666f3cd143047e49a010f0c97eabc7136f92aa35 (diff)
downloadiced-4f41927155e7d4bc38497b0e298a0b23ccea6ca1.tar.gz
iced-4f41927155e7d4bc38497b0e298a0b23ccea6ca1.tar.bz2
iced-4f41927155e7d4bc38497b0e298a0b23ccea6ca1.zip
Merge branch 'iced-rs:master' into master
Diffstat (limited to '')
-rw-r--r--winit/Cargo.toml8
-rw-r--r--winit/README.md2
-rw-r--r--winit/src/application.rs49
-rw-r--r--winit/src/conversion.rs12
-rw-r--r--winit/src/lib.rs2
-rw-r--r--winit/src/settings.rs3
-rw-r--r--winit/src/window.rs28
7 files changed, 72 insertions, 32 deletions
diff --git a/winit/Cargo.toml b/winit/Cargo.toml
index dd975cbe..60e464c6 100644
--- a/winit/Cargo.toml
+++ b/winit/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "iced_winit"
-version = "0.7.0"
+version = "0.8.0"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2021"
description = "A winit runtime for Iced"
@@ -28,15 +28,15 @@ git = "https://github.com/iced-rs/winit.git"
rev = "940457522e9fb9f5dac228b0ecfafe0138b4048c"
[dependencies.iced_native]
-version = "0.8"
+version = "0.9"
path = "../native"
[dependencies.iced_graphics]
-version = "0.6"
+version = "0.7"
path = "../graphics"
[dependencies.iced_futures]
-version = "0.5"
+version = "0.6"
path = "../futures"
[dependencies.tracing]
diff --git a/winit/README.md b/winit/README.md
index 44286c2c..83810473 100644
--- a/winit/README.md
+++ b/winit/README.md
@@ -20,7 +20,7 @@ It exposes a renderer-agnostic `Application` trait that can be implemented and t
Add `iced_winit` as a dependency in your `Cargo.toml`:
```toml
-iced_winit = "0.7"
+iced_winit = "0.8"
```
__Iced moves fast and the `master` branch can contain breaking changes!__ If
diff --git a/winit/src/application.rs b/winit/src/application.rs
index c1836ed9..3fdec658 100644
--- a/winit/src/application.rs
+++ b/winit/src/application.rs
@@ -147,11 +147,15 @@ where
#[cfg(target_arch = "wasm32")]
let target = settings.window.platform_specific.target.clone();
- let builder = settings.window.into_builder(
- &application.title(),
- event_loop.primary_monitor(),
- settings.id,
- );
+ let should_be_visible = settings.window.visible;
+ let builder = settings
+ .window
+ .into_builder(
+ &application.title(),
+ event_loop.primary_monitor(),
+ settings.id,
+ )
+ .with_visible(false);
log::info!("Window builder: {:#?}", builder);
@@ -202,6 +206,7 @@ where
control_sender,
init_command,
window,
+ should_be_visible,
settings.exit_on_close_request,
);
@@ -268,6 +273,7 @@ async fn run_instance<A, E, C>(
mut control_sender: mpsc::UnboundedSender<winit::event_loop::ControlFlow>,
init_command: Command<A::Message>,
window: winit::window::Window,
+ should_be_visible: bool,
exit_on_close_request: bool,
) where
A: Application + 'static,
@@ -295,6 +301,10 @@ async fn run_instance<A, E, C>(
physical_size.height,
);
+ if should_be_visible {
+ window.set_visible(true);
+ }
+
run_command(
&application,
&mut cache,
@@ -737,11 +747,11 @@ pub fn run_command<A, E>(
height,
});
}
- window::Action::Maximize(value) => {
- window.set_maximized(value);
+ window::Action::Maximize(maximized) => {
+ window.set_maximized(maximized);
}
- window::Action::Minimize(value) => {
- window.set_minimized(value);
+ window::Action::Minimize(minimized) => {
+ window.set_minimized(minimized);
}
window::Action::Move { x, y } => {
window.set_outer_position(winit::dpi::LogicalPosition {
@@ -771,13 +781,24 @@ pub fn run_command<A, E>(
window.set_maximized(!window.is_maximized())
}
window::Action::ToggleDecorations => {
- window.set_decorations(!window.is_decorated())
+ window.set_decorations(!window.is_decorated());
}
- window::Action::RequestUserAttention(user_attention) => window
- .request_user_attention(
+ window::Action::RequestUserAttention(user_attention) => {
+ window.request_user_attention(
user_attention.map(conversion::user_attention),
- ),
- window::Action::GainFocus => window.focus_window(),
+ );
+ }
+ window::Action::GainFocus => {
+ window.focus_window();
+ }
+ window::Action::ChangeAlwaysOnTop(on_top) => {
+ window.set_always_on_top(on_top);
+ }
+ window::Action::FetchId(tag) => {
+ proxy
+ .send_event(tag(window.id().into()))
+ .expect("Send message to event loop");
+ }
},
command::Action::System(action) => match action {
system::Action::QueryInformation(_tag) => {
diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs
index e83e55ec..1b2ead36 100644
--- a/winit/src/conversion.rs
+++ b/winit/src/conversion.rs
@@ -1,7 +1,7 @@
//! Convert [`winit`] types into [`iced_native`] types, and viceversa.
//!
//! [`winit`]: https://github.com/rust-windowing/winit
-//! [`iced_native`]: https://github.com/iced-rs/iced/tree/0.7/native
+//! [`iced_native`]: https://github.com/iced-rs/iced/tree/0.8/native
use crate::keyboard;
use crate::mouse;
use crate::touch;
@@ -218,7 +218,7 @@ pub fn mode(mode: Option<winit::window::Fullscreen>) -> window::Mode {
/// Converts a `MouseCursor` from [`iced_native`] to a [`winit`] cursor icon.
///
/// [`winit`]: https://github.com/rust-windowing/winit
-/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.7/native
+/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.8/native
pub fn mouse_interaction(
interaction: mouse::Interaction,
) -> winit::window::CursorIcon {
@@ -242,7 +242,7 @@ pub fn mouse_interaction(
/// Converts a `MouseButton` from [`winit`] to an [`iced_native`] mouse button.
///
/// [`winit`]: https://github.com/rust-windowing/winit
-/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.7/native
+/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.8/native
pub fn mouse_button(mouse_button: winit::event::MouseButton) -> mouse::Button {
match mouse_button {
winit::event::MouseButton::Left => mouse::Button::Left,
@@ -258,7 +258,7 @@ pub fn mouse_button(mouse_button: winit::event::MouseButton) -> mouse::Button {
/// modifiers state.
///
/// [`winit`]: https://github.com/rust-windowing/winit
-/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.7/native
+/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.8/native
pub fn modifiers(
modifiers: winit::event::ModifiersState,
) -> keyboard::Modifiers {
@@ -285,7 +285,7 @@ pub fn cursor_position(
/// Converts a `Touch` from [`winit`] to an [`iced_native`] touch event.
///
/// [`winit`]: https://github.com/rust-windowing/winit
-/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.7/native
+/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.8/native
pub fn touch_event(
touch: winit::event::Touch,
scale_factor: f64,
@@ -316,7 +316,7 @@ pub fn touch_event(
/// Converts a `VirtualKeyCode` from [`winit`] to an [`iced_native`] key code.
///
/// [`winit`]: https://github.com/rust-windowing/winit
-/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.7/native
+/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.8/native
pub fn key_code(
virtual_keycode: winit::event::VirtualKeyCode,
) -> keyboard::KeyCode {
diff --git a/winit/src/lib.rs b/winit/src/lib.rs
index c3172319..3a33e174 100644
--- a/winit/src/lib.rs
+++ b/winit/src/lib.rs
@@ -11,7 +11,7 @@
//! Additionally, a [`conversion`] module is available for users that decide to
//! implement a custom event loop.
//!
-//! [`iced_native`]: https://github.com/iced-rs/iced/tree/0.7/native
+//! [`iced_native`]: https://github.com/iced-rs/iced/tree/0.8/native
//! [`winit`]: https://github.com/rust-windowing/winit
//! [`conversion`]: crate::conversion
#![doc(
diff --git a/winit/src/settings.rs b/winit/src/settings.rs
index 9bbdef5c..45f38833 100644
--- a/winit/src/settings.rs
+++ b/winit/src/settings.rs
@@ -114,8 +114,7 @@ impl Window {
.with_decorations(self.decorations)
.with_transparent(self.transparent)
.with_window_icon(self.icon)
- .with_always_on_top(self.always_on_top)
- .with_visible(self.visible);
+ .with_always_on_top(self.always_on_top);
if let Some(position) = conversion::position(
primary_monitor.as_ref(),
diff --git a/winit/src/window.rs b/winit/src/window.rs
index 6e3a383a..961562bd 100644
--- a/winit/src/window.rs
+++ b/winit/src/window.rs
@@ -23,13 +23,17 @@ pub fn resize<Message>(width: u32, height: u32) -> Command<Message> {
}
/// Maximizes the window.
-pub fn maximize<Message>(value: bool) -> Command<Message> {
- Command::single(command::Action::Window(window::Action::Maximize(value)))
+pub fn maximize<Message>(maximized: bool) -> Command<Message> {
+ Command::single(command::Action::Window(window::Action::Maximize(
+ maximized,
+ )))
}
/// Minimes the window.
-pub fn minimize<Message>(value: bool) -> Command<Message> {
- Command::single(command::Action::Window(window::Action::Minimize(value)))
+pub fn minimize<Message>(minimized: bool) -> Command<Message> {
+ Command::single(command::Action::Window(window::Action::Minimize(
+ minimized,
+ )))
}
/// Moves a window to the given logical coordinates.
@@ -84,3 +88,19 @@ pub fn request_user_attention<Message>(
pub fn gain_focus<Message>() -> Command<Message> {
Command::single(command::Action::Window(window::Action::GainFocus))
}
+
+/// Changes whether or not the window will always be on top of other windows.
+pub fn change_always_on_top<Message>(on_top: bool) -> Command<Message> {
+ Command::single(command::Action::Window(window::Action::ChangeAlwaysOnTop(
+ on_top,
+ )))
+}
+
+/// Fetches an identifier unique to the window.
+pub fn fetch_id<Message>(
+ f: impl FnOnce(u64) -> Message + 'static,
+) -> Command<Message> {
+ Command::single(command::Action::Window(window::Action::FetchId(Box::new(
+ f,
+ ))))
+}