Provide new Window trait to window::run

Co-authored-by: flakes <cxxjoe@gmail.com>
This commit is contained in:
Héctor Ramón Jiménez 2025-11-20 00:20:24 +01:00
parent 2bbc7385e0
commit bbba0942f8
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
4 changed files with 48 additions and 14 deletions

View file

@ -1613,13 +1613,8 @@ fn run_action<'a, P, C>(
let _ = channel.send(window.raw.id().into());
}
}
window::Action::RunWithHandle(id, f) => {
use window::raw_window_handle::HasWindowHandle;
if let Some(handle) = window_manager
.get_mut(id)
.and_then(|window| window.raw.window_handle().ok())
{
window::Action::Run(id, f) => {
if let Some(handle) = window_manager.get_mut(id) {
f(handle);
}
}

View file

@ -17,6 +17,7 @@ use crate::core::{
};
use crate::graphics::Compositor;
use crate::program::{self, Program};
use crate::runtime::window::raw_window_handle;
use winit::dpi::{LogicalPosition, LogicalSize};
use winit::monitor::MonitorHandle;
@ -299,6 +300,36 @@ where
}
}
impl<P, C> raw_window_handle::HasWindowHandle for Window<P, C>
where
P: Program,
C: Compositor<Renderer = P::Renderer>,
{
fn window_handle(
&self,
) -> Result<
raw_window_handle::WindowHandle<'_>,
raw_window_handle::HandleError,
> {
self.raw.window_handle()
}
}
impl<P, C> raw_window_handle::HasDisplayHandle for Window<P, C>
where
P: Program,
C: Compositor<Renderer = P::Renderer>,
{
fn display_handle(
&self,
) -> Result<
raw_window_handle::DisplayHandle<'_>,
raw_window_handle::HandleError,
> {
self.raw.display_handle()
}
}
struct Preedit<Renderer>
where
Renderer: text::Renderer,