chore(wayland): window state handling

This commit is contained in:
Ashley Wulber 2025-09-25 15:39:14 -04:00
parent e73bbddbca
commit bc85d82426
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820
4 changed files with 18 additions and 1 deletions

View file

@ -1,8 +1,12 @@
#![allow(missing_docs)]
use cctk::sctk::reexports::csd_frame::WindowState;
/// window events
#[derive(Debug, PartialEq, Clone)]
pub enum WindowEvent {
/// Window suggested bounds.
SuggestedBounds(Option<crate::Size>),
/// Window state
WindowState(WindowState),
}

View file

@ -199,6 +199,7 @@ pub fn window_event(
event: winit::event::WindowEvent,
scale_factor: f64,
modifiers: winit::keyboard::ModifiersState,
window: &dyn winit::window::Window,
) -> Option<Event> {
use winit::event::Ime;
use winit::event::WindowEvent;
@ -436,7 +437,18 @@ pub fn window_event(
),
)))
}
#[cfg(feature = "wayland")]
WindowEvent::WindowStateChanged => {
use cctk::sctk::reexports::csd_frame::WindowState;
use winit::platform::wayland::WindowExtWayland;
let s = window.window_state();
Some(Event::PlatformSpecific(iced_futures::core::event::PlatformSpecific::Wayland(
iced_runtime::core::event::wayland::Event::Window(
iced_runtime::core::event::wayland::WindowEvent::WindowState(s.unwrap_or(WindowState::empty()))
),
)))
}
_ => None,
}
}

View file

@ -1283,6 +1283,7 @@ async fn run_instance<P>(
event,
window.state.scale_factor(),
window.state.modifiers(),
window.raw.as_ref(),
) {
events.push((Some(id), event));
}

View file

@ -1,4 +1,4 @@
use iced_futures::core::{border::Radius, window};
use iced_futures::core::window;
use iced_runtime::{
self,
platform_specific::{