From d53ccc857da4d4cda769904342aeb5a82a64f146 Mon Sep 17 00:00:00 2001 From: Bingus Date: Wed, 12 Jul 2023 19:21:05 -0700 Subject: refactored window storage; new helper window events (Destroyed, Created); clippy + fmt; --- graphics/src/compositor.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'graphics/src/compositor.rs') diff --git a/graphics/src/compositor.rs b/graphics/src/compositor.rs index f7b86045..32111008 100644 --- a/graphics/src/compositor.rs +++ b/graphics/src/compositor.rs @@ -24,6 +24,9 @@ pub trait Compositor: Sized { compatible_window: Option<&W>, ) -> Result<(Self, Self::Renderer), Error>; + /// Creates a [`Renderer`] for the [`Compositor`]. + fn renderer(&self) -> Self::Renderer; + /// Crates a new [`Surface`] for the given window. /// /// [`Surface`]: Self::Surface -- cgit From 6740c2c5d6b24399dab1343abdfec5daf4b03c98 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 29 Nov 2023 22:46:47 +0100 Subject: Fix broken intra-doc links --- graphics/src/compositor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'graphics/src/compositor.rs') diff --git a/graphics/src/compositor.rs b/graphics/src/compositor.rs index e0b1e20f..78731a98 100644 --- a/graphics/src/compositor.rs +++ b/graphics/src/compositor.rs @@ -24,7 +24,7 @@ pub trait Compositor: Sized { compatible_window: Option<&W>, ) -> Result<(Self, Self::Renderer), Error>; - /// Creates a [`Renderer`] for the [`Compositor`]. + /// Creates a [`Self::Renderer`] for the [`Compositor`]. fn renderer(&self) -> Self::Renderer; /// Crates a new [`Surface`] for the given window. -- cgit From b152ecda63238136f77b6eda3c582fa1eff99737 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 2 Dec 2023 20:49:47 +0100 Subject: Separate `Compositor::new` from `Compositor::create_renderer` --- graphics/src/compositor.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'graphics/src/compositor.rs') diff --git a/graphics/src/compositor.rs b/graphics/src/compositor.rs index 78731a98..b8b575b4 100644 --- a/graphics/src/compositor.rs +++ b/graphics/src/compositor.rs @@ -22,10 +22,10 @@ pub trait Compositor: Sized { fn new( settings: Self::Settings, compatible_window: Option<&W>, - ) -> Result<(Self, Self::Renderer), Error>; + ) -> Result; /// Creates a [`Self::Renderer`] for the [`Compositor`]. - fn renderer(&self) -> Self::Renderer; + fn create_renderer(&self) -> Self::Renderer; /// Crates a new [`Surface`] for the given window. /// -- cgit From 7289b6091b61b0aa448a756cfe32211c78a4cce0 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Tue, 9 Jan 2024 07:19:15 -0800 Subject: WIP raw-window-handle 0.6 --- graphics/src/compositor.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'graphics/src/compositor.rs') diff --git a/graphics/src/compositor.rs b/graphics/src/compositor.rs index b8b575b4..6a4c7909 100644 --- a/graphics/src/compositor.rs +++ b/graphics/src/compositor.rs @@ -4,11 +4,11 @@ use crate::{Error, Viewport}; use iced_core::Color; -use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle}; +use raw_window_handle::{HasDisplayHandle, HasWindowHandle}; use thiserror::Error; /// A graphics compositor that can draw to windows. -pub trait Compositor: Sized { +pub trait Compositor: Sized { /// The settings of the backend. type Settings: Default; @@ -19,9 +19,9 @@ pub trait Compositor: Sized { type Surface; /// Creates a new [`Compositor`]. - fn new( + fn new( settings: Self::Settings, - compatible_window: Option<&W>, + compatible_window: Option, ) -> Result; /// Creates a [`Self::Renderer`] for the [`Compositor`]. @@ -30,9 +30,9 @@ pub trait Compositor: Sized { /// Crates a new [`Surface`] for the given window. /// /// [`Surface`]: Self::Surface - fn create_surface( + fn create_surface( &mut self, - window: &W, + window: W, width: u32, height: u32, ) -> Self::Surface; -- cgit From 8bf238697226e827dc983f9d89afbd0e252c5254 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 18 Jan 2024 09:55:27 +0100 Subject: Remove `Compositor` window generic And update `glyphon` and `window_clipboard` --- graphics/src/compositor.rs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'graphics/src/compositor.rs') 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: Sized { +pub trait Compositor: Sized { /// The settings of the backend. type Settings: Default; @@ -19,7 +20,7 @@ pub trait Compositor: Sized { type Surface; /// Creates a new [`Compositor`]. - fn new( + fn new( settings: Self::Settings, compatible_window: Option, ) -> Result; @@ -30,7 +31,7 @@ pub trait Compositor: Sized { /// Crates a new [`Surface`] for the given window. /// /// [`Surface`]: Self::Surface - fn create_surface( + fn create_surface( &mut self, window: W, width: u32, @@ -77,6 +78,20 @@ pub trait Compositor: Sized { ) -> Vec; } +/// 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 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 { -- cgit From 5fc49edc55a0e64c4c46ca55eddafe9d4e8232e1 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 18 Jan 2024 10:06:30 +0100 Subject: Make `compatible_window` mandatory in `Compositor` --- graphics/src/compositor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'graphics/src/compositor.rs') diff --git a/graphics/src/compositor.rs b/graphics/src/compositor.rs index e6b9030b..0188f4d8 100644 --- a/graphics/src/compositor.rs +++ b/graphics/src/compositor.rs @@ -22,7 +22,7 @@ pub trait Compositor: Sized { /// Creates a new [`Compositor`]. fn new( settings: Self::Settings, - compatible_window: Option, + compatible_window: W, ) -> Result; /// Creates a [`Self::Renderer`] for the [`Compositor`]. -- cgit