summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-01-18 09:55:27 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-01-18 09:55:27 +0100
commit8bf238697226e827dc983f9d89afbd0e252c5254 (patch)
tree3594e998d60b130ab6b161aa00159e2311cbde0a /graphics
parent7289b6091b61b0aa448a756cfe32211c78a4cce0 (diff)
downloadiced-8bf238697226e827dc983f9d89afbd0e252c5254.tar.gz
iced-8bf238697226e827dc983f9d89afbd0e252c5254.tar.bz2
iced-8bf238697226e827dc983f9d89afbd0e252c5254.zip
Remove `Compositor` window generic
And update `glyphon` and `window_clipboard`
Diffstat (limited to 'graphics')
-rw-r--r--graphics/Cargo.toml1
-rw-r--r--graphics/src/compositor.rs23
-rw-r--r--graphics/src/lib.rs1
3 files changed, 21 insertions, 4 deletions
diff --git a/graphics/Cargo.toml b/graphics/Cargo.toml
index 6741d7cf..4f323f9e 100644
--- a/graphics/Cargo.toml
+++ b/graphics/Cargo.toml
@@ -21,6 +21,7 @@ web-colors = []
[dependencies]
iced_core.workspace = true
+iced_futures.workspace = true
bitflags.workspace = true
bytemuck.workspace = true
diff --git a/graphics/src/compositor.rs b/graphics/src/compositor.rs
index 6a4c7909..e6b9030b 100644
--- a/graphics/src/compositor.rs
+++ b/graphics/src/compositor.rs
@@ -2,13 +2,14 @@
//! surfaces.
use crate::{Error, Viewport};
-use iced_core::Color;
+use crate::core::Color;
+use crate::futures::{MaybeSend, MaybeSync};
use raw_window_handle::{HasDisplayHandle, HasWindowHandle};
use thiserror::Error;
/// A graphics compositor that can draw to windows.
-pub trait Compositor<W: HasWindowHandle + HasDisplayHandle>: Sized {
+pub trait Compositor: Sized {
/// The settings of the backend.
type Settings: Default;
@@ -19,7 +20,7 @@ pub trait Compositor<W: HasWindowHandle + HasDisplayHandle>: Sized {
type Surface;
/// Creates a new [`Compositor`].
- fn new(
+ fn new<W: Window + Clone>(
settings: Self::Settings,
compatible_window: Option<W>,
) -> Result<Self, Error>;
@@ -30,7 +31,7 @@ pub trait Compositor<W: HasWindowHandle + HasDisplayHandle>: Sized {
/// Crates a new [`Surface`] for the given window.
///
/// [`Surface`]: Self::Surface
- fn create_surface(
+ fn create_surface<W: Window + Clone>(
&mut self,
window: W,
width: u32,
@@ -77,6 +78,20 @@ pub trait Compositor<W: HasWindowHandle + HasDisplayHandle>: Sized {
) -> Vec<u8>;
}
+/// A window that can be used in a [`Compositor`].
+///
+/// This is just a convenient super trait of the `raw-window-handle`
+/// traits.
+pub trait Window:
+ HasWindowHandle + HasDisplayHandle + MaybeSend + MaybeSync + 'static
+{
+}
+
+impl<T> Window for T where
+ T: HasWindowHandle + HasDisplayHandle + MaybeSend + MaybeSync + 'static
+{
+}
+
/// Result of an unsuccessful call to [`Compositor::present`].
#[derive(Clone, PartialEq, Eq, Debug, Error)]
pub enum SurfaceError {
diff --git a/graphics/src/lib.rs b/graphics/src/lib.rs
index 7a213909..76de56bf 100644
--- a/graphics/src/lib.rs
+++ b/graphics/src/lib.rs
@@ -50,3 +50,4 @@ pub use transformation::Transformation;
pub use viewport::Viewport;
pub use iced_core as core;
+pub use iced_futures as futures;