summaryrefslogtreecommitdiffstats
path: root/winit
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-04-17 23:41:12 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-04-17 23:41:12 +0200
commit4bae457c37b499f3cfddbdac9ff37a34cbce61d5 (patch)
tree79af93b2f7fabca1687900b48b165c5c74dcd26f /winit
parentc0431aedd3bbef4161456f2fa5f29866e8f17fc5 (diff)
parent4b05f42fd6d18bf572b772dd60d6a4309ea5f343 (diff)
downloadiced-4bae457c37b499f3cfddbdac9ff37a34cbce61d5.tar.gz
iced-4bae457c37b499f3cfddbdac9ff37a34cbce61d5.tar.bz2
iced-4bae457c37b499f3cfddbdac9ff37a34cbce61d5.zip
Merge branch 'master' into advanced-text
Diffstat (limited to 'winit')
-rw-r--r--winit/Cargo.toml14
-rw-r--r--winit/README.md2
-rw-r--r--winit/src/application.rs21
-rw-r--r--winit/src/conversion.rs22
-rw-r--r--winit/src/lib.rs2
-rw-r--r--winit/src/settings.rs8
6 files changed, 47 insertions, 22 deletions
diff --git a/winit/Cargo.toml b/winit/Cargo.toml
index 1bf63804..58e13b3e 100644
--- a/winit/Cargo.toml
+++ b/winit/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "iced_winit"
-version = "0.8.0"
+version = "0.9.1"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2021"
description = "A winit runtime for Iced"
@@ -11,11 +11,16 @@ keywords = ["gui", "ui", "graphics", "interface", "widgets"]
categories = ["gui"]
[features]
+default = ["x11", "wayland", "wayland-dlopen", "wayland-csd-adwaita"]
trace = ["tracing", "tracing-core", "tracing-subscriber"]
chrome-trace = ["trace", "tracing-chrome"]
debug = ["iced_runtime/debug"]
system = ["sysinfo"]
application = []
+x11 = ["winit/x11"]
+wayland = ["winit/wayland"]
+wayland-dlopen = ["winit/wayland-dlopen"]
+wayland-csd-adwaita = ["winit/wayland-csd-adwaita"]
[dependencies]
window_clipboard = "0.2"
@@ -26,17 +31,18 @@ thiserror = "1.0"
version = "0.27"
git = "https://github.com/iced-rs/winit.git"
rev = "940457522e9fb9f5dac228b0ecfafe0138b4048c"
+default-features = false
[dependencies.iced_runtime]
-version = "0.9"
+version = "0.1"
path = "../runtime"
[dependencies.iced_graphics]
-version = "0.7"
+version = "0.8"
path = "../graphics"
[dependencies.iced_style]
-version = "0.7"
+version = "0.8"
path = "../style"
[dependencies.tracing]
diff --git a/winit/README.md b/winit/README.md
index 83810473..91307970 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.8"
+iced_winit = "0.9"
```
__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 48f94235..3d7c6e5d 100644
--- a/winit/src/application.rs
+++ b/winit/src/application.rs
@@ -179,13 +179,17 @@ where
.unwrap_or(None)
});
- let _ = match target {
- Some(node) => node
- .replace_child(&canvas, &node)
- .expect(&format!("Could not replace #{}", node.id())),
- None => body
- .append_child(&canvas)
- .expect("Append canvas to HTML body"),
+ match target {
+ Some(node) => {
+ let _ = node
+ .replace_with_with_node_1(&canvas)
+ .expect(&format!("Could not replace #{}", node.id()));
+ }
+ None => {
+ let _ = body
+ .append_child(&canvas)
+ .expect("Append canvas to HTML body");
+ }
};
}
@@ -762,6 +766,9 @@ pub fn run_command<A, E>(
mode,
));
}
+ window::Action::ChangeIcon(icon) => {
+ window.set_window_icon(conversion::icon(icon))
+ }
window::Action::FetchMode(tag) => {
let mode = if window.is_visible().unwrap_or(true) {
conversion::mode(window.fullscreen())
diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs
index 0759ad9d..a9262184 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.8/native
+//! [`iced_native`]: https://github.com/iced-rs/iced/tree/0.9/native
use crate::core::keyboard;
use crate::core::mouse;
use crate::core::touch;
@@ -219,7 +219,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.8/native
+/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.9/native
pub fn mouse_interaction(
interaction: mouse::Interaction,
) -> winit::window::CursorIcon {
@@ -237,13 +237,14 @@ pub fn mouse_interaction(
winit::window::CursorIcon::EwResize
}
Interaction::ResizingVertically => winit::window::CursorIcon::NsResize,
+ Interaction::NotAllowed => winit::window::CursorIcon::NotAllowed,
}
}
/// 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.8/native
+/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.9/native
pub fn mouse_button(mouse_button: winit::event::MouseButton) -> mouse::Button {
match mouse_button {
winit::event::MouseButton::Left => mouse::Button::Left,
@@ -259,7 +260,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.8/native
+/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.9/native
pub fn modifiers(
modifiers: winit::event::ModifiersState,
) -> keyboard::Modifiers {
@@ -286,7 +287,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.8/native
+/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.9/native
pub fn touch_event(
touch: winit::event::Touch,
scale_factor: f64,
@@ -317,7 +318,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.8/native
+/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.9/native
pub fn key_code(
virtual_keycode: winit::event::VirtualKeyCode,
) -> keyboard::KeyCode {
@@ -510,6 +511,15 @@ pub fn user_attention(
}
}
+/// Converts some [`Icon`] into it's `winit` counterpart.
+///
+/// Returns `None` if there is an error during the conversion.
+pub fn icon(icon: window::Icon) -> Option<winit::window::Icon> {
+ let (pixels, size) = icon.into_raw();
+
+ winit::window::Icon::from_rgba(pixels, size.width, size.height).ok()
+}
+
// As defined in: http://www.unicode.org/faq/private_use.html
pub(crate) fn is_private_use_character(c: char) -> bool {
matches!(
diff --git a/winit/src/lib.rs b/winit/src/lib.rs
index 5cde510a..9f6bcebb 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.8/native
+//! [`iced_native`]: https://github.com/iced-rs/iced/tree/0.9/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 5c64727b..be0ab329 100644
--- a/winit/src/settings.rs
+++ b/winit/src/settings.rs
@@ -22,6 +22,7 @@ mod platform;
pub use platform::PlatformSpecific;
use crate::conversion;
+use crate::core::window::Icon;
use crate::Position;
use winit::monitor::MonitorHandle;
@@ -84,7 +85,7 @@ pub struct Window {
pub always_on_top: bool,
/// The window icon, which is also usually used in the taskbar
- pub icon: Option<winit::window::Icon>,
+ pub icon: Option<Icon>,
/// Platform specific settings.
pub platform_specific: platform::PlatformSpecific,
@@ -126,8 +127,9 @@ impl Window {
.with_resizable(self.resizable)
.with_decorations(self.decorations)
.with_transparent(self.transparent)
- .with_window_icon(self.icon)
- .with_always_on_top(self.always_on_top);
+ .with_window_icon(self.icon.and_then(conversion::icon))
+ .with_always_on_top(self.always_on_top)
+ .with_visible(self.visible);
if let Some(position) = conversion::position(
primary_monitor.as_ref(),