Merge remote-tracking branch 'upstream/master' into yoda-wayland-only

# Conflicts:
#	Cargo.lock
#	Cargo.toml
#	wgpu/Cargo.toml
#	wgpu/src/window/compositor.rs
This commit is contained in:
Lionel DARNIS 2026-08-19 21:44:35 +02:00
commit d24bcd0272
36 changed files with 475 additions and 209 deletions

View file

@ -1,24 +1,20 @@
//! Wayland specific shell
//!
use std::{borrow::Cow, collections::HashMap, sync::Arc};
use std::collections::HashMap;
#[cfg(all(feature = "cctk", target_os = "linux"))]
use cctk::sctk::reexports::client::Connection;
use iced_graphics::{Compositor, compositor};
use iced_graphics::compositor;
use iced_runtime::{
core::{Vector, window},
platform_specific, user_interface,
user_interface,
};
use winit::raw_window_handle::HasWindowHandle;
#[cfg(all(feature = "cctk", target_os = "linux"))]
#[cfg(wayland_platform)]
pub mod wayland;
#[cfg(all(feature = "cctk", target_os = "linux"))]
#[cfg(wayland_platform)]
pub use wayland::*;
#[cfg(all(feature = "cctk", target_os = "linux"))]
use wayland_backend::client::Backend;
use crate::{CreateCompositor, Program, WindowManager};
@ -35,7 +31,7 @@ pub type UserInterfaces<'a, P> = HashMap<
#[derive(Debug)]
pub enum Event {
#[cfg(all(feature = "cctk", target_os = "linux"))]
#[cfg(wayland_platform)]
Wayland(sctk_event::SctkEvent),
}
@ -61,7 +57,7 @@ impl SurfaceIdWrapper {
#[derive(Debug, Default)]
pub struct PlatformSpecific {
#[cfg(all(feature = "cctk", target_os = "linux"))]
#[cfg(wayland_platform)]
wayland: WaylandSpecific,
}
@ -71,7 +67,7 @@ impl PlatformSpecific {
action: iced_runtime::platform_specific::Action,
) {
match action {
#[cfg(all(feature = "cctk", target_os = "linux"))]
#[cfg(wayland_platform)]
iced_runtime::platform_specific::Action::Wayland(a) => {
self.send_wayland(wayland::Action::Action(a));
}
@ -82,14 +78,14 @@ impl PlatformSpecific {
&mut self,
keep: F,
) {
#[cfg(all(feature = "cctk", target_os = "linux"))]
#[cfg(wayland_platform)]
{
self.wayland.retain_subsurfaces(keep);
}
}
pub(crate) fn clear_subsurface_list(&mut self) {
#[cfg(all(feature = "cctk", target_os = "linux"))]
#[cfg(wayland_platform)]
{
self.wayland.clear_subsurface_list();
}
@ -100,7 +96,7 @@ impl PlatformSpecific {
id: window::Id,
window: &dyn HasWindowHandle,
) {
#[cfg(all(feature = "cctk", target_os = "linux"))]
#[cfg(wayland_platform)]
{
use cctk::sctk::reexports::client::{
Proxy, protocol::wl_surface::WlSurface,
@ -151,7 +147,7 @@ impl PlatformSpecific {
pub(crate) fn create_surface(
&mut self,
) -> Option<Box<dyn HasWindowHandle + Send + Sync + 'static>> {
#[cfg(all(feature = "cctk", target_os = "linux"))]
#[cfg(wayland_platform)]
{
self.wayland.create_surface()
}
@ -170,7 +166,7 @@ impl PlatformSpecific {
data: &[u8],
offset: Vector,
) {
#[cfg(all(feature = "cctk", target_os = "linux"))]
#[cfg(wayland_platform)]
{
return self.wayland.update_surface_shm(
surface, width, height, scale, data, offset,
@ -198,7 +194,7 @@ pub(crate) async fn handle_event<'a, 'b, P>(
P: Program,
{
match e {
#[cfg(all(feature = "cctk", target_os = "linux"))]
#[cfg(wayland_platform)]
Event::Wayland(e) => {
platform_specific
.wayland

View file

@ -874,6 +874,11 @@ impl SctkState {
_ = wl_surface.frame(&self.queue_handle, wl_surface.clone());
if let Some(old) = self.blur_surfaces.remove(&settings.id) {
old.destroy();
}
_ = self.corner_radii.remove(&settings.id);
if let Some(blur) = self.pending_blur.remove(&settings.id) {
self.apply_blur(settings.id, Some(blur), &wl_surface);
}
@ -1011,6 +1016,12 @@ impl SctkState {
layer_surface.set_input_region(Some(&region));
region.destroy();
}
if let Some(old) = self.blur_surfaces.remove(&id) {
old.destroy();
}
_ = self.corner_radii.remove(&id);
if let Some(blur) = self.pending_blur.remove(&id) {
self.apply_blur(id, Some(blur), &wl_surface);
}
@ -1268,11 +1279,11 @@ impl SctkState {
|| self.layer_surfaces.iter().any(|l| l.id == settings.parent && p.data.parent.wl_surface() == l.surface.wl_surface()))
) {
let existing = &mut self.popups[existing];
let size = if settings.positioner.size.is_none() {
log::info!("No configured popup size");
(1, 1)
let size = if let Some(size) = settings.positioner.size {
size
} else {
settings.positioner.size.unwrap()
let guard = existing.common.lock().unwrap();
(guard.size.width, guard.size.height)
};
let Ok(positioner) = XdgPositioner::new(&self.xdg_shell_state)
.map_err(PopupCreationError::PositionerCreationFailed) else {
@ -1392,7 +1403,7 @@ impl SctkState {
},
};
let mut to_destroy = vec![sctk_popup];
// TODO optionally destroy parents if they request to be destroyed with children
while let Some(popup_to_destroy_last) = to_destroy.last().and_then(|popup| self
.popups
.iter()
@ -1839,6 +1850,7 @@ impl SctkState {
s: &WlSurface,
) {
let existing_blur = self.blur_surfaces.entry(id);
match (existing_blur, rectangles) {
(Entry::Occupied(occupied_entry), None) => {
let blur_surface = occupied_entry.remove();
@ -2021,6 +2033,11 @@ impl SctkState {
region.destroy();
}
if let Some(old) = self.blur_surfaces.remove(&settings.id) {
old.destroy();
}
_ = self.corner_radii.remove(&settings.id);
if let Some(blur) = self.pending_blur.remove(&settings.id) {
_ = self.apply_blur(settings.id, Some(blur), &wl_surface);
}

View file

@ -1,8 +1,5 @@
use crate::{
event_loop::state::FrameStatus,
platform_specific::wayland::{
event_loop::state::SctkState, sctk_event::SctkEvent,
},
use crate::platform_specific::wayland::{
event_loop::state::SctkState, sctk_event::SctkEvent,
};
use cctk::sctk::{
delegate_pointer,
@ -50,14 +47,6 @@ impl PointerHandler for SctkState {
continue;
}
let entry = self
.frame_status
.entry(e.surface.id())
.or_insert(FrameStatus::RequestedRedraw);
if matches!(entry, FrameStatus::Received) {
*entry = FrameStatus::Ready;
}
self.sctk_events.push(SctkEvent::PointerEvent {
variant: PointerEvent {
surface: e.surface.clone(),

View file

@ -27,6 +27,15 @@ impl LayerShellHandler for SctkState {
None => return,
};
if let Some(id) = self.id_map.remove(&layer.surface.wl_surface().id()) {
if let Some(blurred) = self.blur_surfaces.remove(&id) {
blurred.destroy();
}
_ = self.corner_radii.remove(&id);
_ = self.destroyed.insert(id);
}
self.sctk_events.push(SctkEvent::LayerSurfaceEvent {
variant: LayerSurfaceEventVariant::Done,
id: layer.surface.wl_surface().clone(),

View file

@ -84,6 +84,11 @@ impl PopupHandler for SctkState {
for popup in to_destroy.into_iter().rev() {
if let Some(id) = self.id_map.remove(&popup.popup.wl_surface().id())
{
if let Some(blurred) = self.blur_surfaces.remove(&id) {
blurred.destroy();
}
_ = self.corner_radii.remove(&id);
_ = self.destroyed.insert(id);
}