chore: cargo fmt

This commit is contained in:
Ashley Wulber 2026-06-25 15:27:31 -04:00 committed by Ashley Wulber
parent 633ed14411
commit c781ff6199
24 changed files with 192 additions and 172 deletions

View file

@ -1,5 +1,5 @@
use iced::widget::{button, column, text, Column};
use iced::Center; use iced::Center;
use iced::widget::{Column, button, column, text};
pub fn main() -> iced::Result { pub fn main() -> iced::Result {
iced::run(Counter::update, Counter::view) iced::run(Counter::update, Counter::view)
@ -42,7 +42,7 @@ impl Counter {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use iced_test::{Error, simulator}; use iced_test::{simulator, Error};
#[test] #[test]
fn it_counts() -> Result<(), Error> { fn it_counts() -> Result<(), Error> {

View file

@ -3,20 +3,20 @@ use std::{
sync::atomic::{AtomicU64, Ordering}, sync::atomic::{AtomicU64, Ordering},
}; };
use iced::{Element, id::Id};
use iced::{ use iced::{
Event, Length, Rectangle,
clipboard::{ clipboard::{
dnd::{self, DndAction, DndDestinationRectangle, DndEvent, OfferEvent}, dnd::{self, DndAction, DndDestinationRectangle, DndEvent, OfferEvent},
mime::AllowedMimeTypes, mime::AllowedMimeTypes,
}, },
event, event,
id::Internal, id::Internal,
mouse, overlay, mouse, overlay, Event, Length, Rectangle,
}; };
use iced::{id::Id, Element};
use iced_core::{ use iced_core::{
self, Clipboard, Layout, Shell, Widget, layout, self, layout,
widget::{Tree, tree}, widget::{tree, Tree},
Clipboard, Layout, Shell, Widget,
}; };
pub fn dnd_destination<'a, Message: 'static>( pub fn dnd_destination<'a, Message: 'static>(

View file

@ -1,16 +1,16 @@
use std::any::Any; use std::any::Any;
use iced::Element;
use iced::id::Id; use iced::id::Id;
use iced::widget::container; use iced::widget::container;
use iced::Element;
use iced::{ use iced::{
Event, Length, Point, Rectangle,
clipboard::dnd::{DndAction, DndEvent, SourceEvent}, clipboard::dnd::{DndAction, DndEvent, SourceEvent},
event, mouse, overlay, event, mouse, overlay, Event, Length, Point, Rectangle,
}; };
use iced_core::{ use iced_core::{
Clipboard, Shell, layout, renderer, layout, renderer,
widget::{Tree, tree}, widget::{tree, Tree},
Clipboard, Shell,
}; };
use iced_core::{Layout, Widget}; use iced_core::{Layout, Widget};
@ -41,7 +41,7 @@ impl<
Message: 'static, Message: 'static,
AppMessage: 'static, AppMessage: 'static,
D: iced::clipboard::mime::AsMimeTypes + std::marker::Send + 'static, D: iced::clipboard::mime::AsMimeTypes + std::marker::Send + 'static,
> DndSource<'a, Message, AppMessage, D> > DndSource<'a, Message, AppMessage, D>
{ {
pub fn new(child: impl Into<Element<'a, Message>>) -> Self { pub fn new(child: impl Into<Element<'a, Message>>) -> Self {
Self { Self {
@ -123,7 +123,7 @@ impl<
Message: 'static, Message: 'static,
AppMessage: 'static, AppMessage: 'static,
D: iced::clipboard::mime::AsMimeTypes + std::marker::Send + 'static, D: iced::clipboard::mime::AsMimeTypes + std::marker::Send + 'static,
> Widget<Message, iced::Theme, iced::Renderer> > Widget<Message, iced::Theme, iced::Renderer>
for DndSource<'a, Message, AppMessage, D> for DndSource<'a, Message, AppMessage, D>
{ {
fn children(&self) -> Vec<Tree> { fn children(&self) -> Vec<Tree> {
@ -361,7 +361,7 @@ impl<
Message: 'static, Message: 'static,
AppMessage: 'static, AppMessage: 'static,
D: iced::clipboard::mime::AsMimeTypes + std::marker::Send + 'static, D: iced::clipboard::mime::AsMimeTypes + std::marker::Send + 'static,
> From<DndSource<'a, Message, AppMessage, D>> for Element<'a, Message> > From<DndSource<'a, Message, AppMessage, D>> for Element<'a, Message>
{ {
fn from(e: DndSource<'a, Message, AppMessage, D>) -> Element<'a, Message> { fn from(e: DndSource<'a, Message, AppMessage, D>) -> Element<'a, Message> {
Element::new(e) Element::new(e)

View file

@ -7,7 +7,6 @@ use cctk::sctk::reexports::{
use iced::platform_specific::shell::commands::subsurface::get_subsurface; use iced::platform_specific::shell::commands::subsurface::get_subsurface;
use iced::{ use iced::{
Element, Length, Subscription, Task,
event::wayland::Event as WaylandEvent, event::wayland::Event as WaylandEvent,
platform_specific::{ platform_specific::{
runtime::wayland::subsurface::SctkSubsurfaceSettings, runtime::wayland::subsurface::SctkSubsurfaceSettings,
@ -15,6 +14,7 @@ use iced::{
}, },
widget::{button, column, text, text_input}, widget::{button, column, text, text_input},
window::{self, Id, Settings}, window::{self, Id, Settings},
Element, Length, Subscription, Task,
}; };
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};

View file

@ -6,7 +6,7 @@ use dnd::{DndDestinationRectangle, DndSurface};
use iced_core::clipboard::DndSource; use iced_core::clipboard::DndSource;
use window_clipboard::mime::{AllowedMimeTypes, AsMimeTypes}; use window_clipboard::mime::{AllowedMimeTypes, AsMimeTypes};
use crate::{oneshot, task, Action, Task}; use crate::{Action, Task, oneshot, task};
/// An action to be performed on the system. /// An action to be performed on the system.
pub enum DndAction { pub enum DndAction {

View file

@ -36,7 +36,7 @@ impl fmt::Debug for Action {
f, f,
"Action::ActivationAction::Activate {{ window: {:?}, token: {:?} }}", "Action::ActivationAction::Activate {{ window: {:?}, token: {:?} }}",
window, token, window, token,
) ),
} }
} }
} }

View file

@ -296,7 +296,8 @@ impl Compositor {
}); });
// Request SHADER_F16 only if the adapter supports it (e.g., not available in WebGL2) // Request SHADER_F16 only if the adapter supports it (e.g., not available in WebGL2)
let required_features = if adapter.features().contains(wgpu::Features::SHADER_F16) { let required_features =
if adapter.features().contains(wgpu::Features::SHADER_F16) {
wgpu::Features::SHADER_F16 wgpu::Features::SHADER_F16
} else { } else {
wgpu::Features::empty() wgpu::Features::empty()

View file

@ -293,9 +293,12 @@ where
.zip(&mut tree.children) .zip(&mut tree.children)
.zip(layout.children()) .zip(layout.children())
.for_each(|((child, state), c_layout)| { .for_each(|((child, state), c_layout)| {
child child.as_widget_mut().operate(
.as_widget_mut() state,
.operate(state, c_layout.with_virtual_offset(layout.virtual_offset()), renderer, operation); c_layout.with_virtual_offset(layout.virtual_offset()),
renderer,
operation,
);
}); });
}); });
} }
@ -318,7 +321,13 @@ where
.zip(layout.children()) .zip(layout.children())
{ {
child.as_widget_mut().update( child.as_widget_mut().update(
tree, event, c_layout.with_virtual_offset(layout.virtual_offset()), cursor, renderer, clipboard, shell, tree,
event,
c_layout.with_virtual_offset(layout.virtual_offset()),
cursor,
renderer,
clipboard,
shell,
viewport, viewport,
); );
} }
@ -337,9 +346,13 @@ where
.zip(&tree.children) .zip(&tree.children)
.zip(layout.children()) .zip(layout.children())
.map(|((child, tree), c_layout)| { .map(|((child, tree), c_layout)| {
child child.as_widget().mouse_interaction(
.as_widget() tree,
.mouse_interaction(tree, c_layout.with_virtual_offset(layout.virtual_offset()), cursor, viewport, renderer) c_layout.with_virtual_offset(layout.virtual_offset()),
cursor,
viewport,
renderer,
)
}) })
.max() .max()
.unwrap_or_default() .unwrap_or_default()

View file

@ -179,7 +179,10 @@ where
{ {
let color = color.map(Into::into); let color = color.map(Into::into);
self.style(move |_theme| Style { color, ..Style::default() }) self.style(move |_theme| Style {
color,
..Style::default()
})
} }
/// Sets the default style class of the [`Rich`] text. /// Sets the default style class of the [`Rich`] text.

View file

@ -40,12 +40,6 @@ pub mod clipboard;
pub mod conversion; pub mod conversion;
pub mod platform_specific; pub mod platform_specific;
#[cfg(feature = "program")]
pub mod program;
#[cfg(feature = "system")]
pub mod system;
mod error; mod error;
mod proxy; mod proxy;
mod window; mod window;
@ -195,7 +189,10 @@ where
control_sender: mpsc::UnboundedSender<Control>, control_sender: mpsc::UnboundedSender<Control>,
#[cfg(feature = "a11y")] #[cfg(feature = "a11y")]
adapters: std::collections::HashMap<window::Id, (u64, iced_accessibility::accesskit_winit::Adapter)>, adapters: std::collections::HashMap<
window::Id,
(u64, iced_accessibility::accesskit_winit::Adapter),
>,
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
is_booted: std::rc::Rc<std::cell::RefCell<bool>>, is_booted: std::rc::Rc<std::cell::RefCell<bool>>,
@ -501,9 +498,15 @@ where
} }
}; };
} }
let window: Arc<dyn winit::window::Window + 'static> = Arc::from(window); let window: Arc<
dyn winit::window::Window + 'static,
> = Arc::from(window);
#[cfg(feature = "a11y")] #[cfg(feature = "a11y")]
self.init_adapter(event_loop, id, window.clone()); self.init_adapter(
event_loop,
id,
window.clone(),
);
self.process_event( self.process_event(
event_loop, event_loop,
@ -572,11 +575,13 @@ where
.expect("Send event"); .expect("Send event");
} }
Control::Winit(id, e) => { Control::Winit(id, e) => {
#[cfg(all(feature = "cctk", target_os = "linux"))] #[cfg(all(
feature = "cctk",
target_os = "linux"
))]
{ {
if matches!(e, WindowEvent::RedrawRequested) if matches!(e, WindowEvent::RedrawRequested)
{ {
for id in crate::subsurface_widget::subsurface_ids(id) { for id in crate::subsurface_widget::subsurface_ids(id) {
_ = self.sender _ = self.sender
.unbounded_send(Event::Winit( .unbounded_send(Event::Winit(
@ -619,7 +624,7 @@ where
#[cfg(feature = "a11y")] #[cfg(feature = "a11y")]
Control::Cleanup(id) => { Control::Cleanup(id) => {
_ = self.adapters.remove(&id); _ = self.adapters.remove(&id);
}, }
}, },
_ => { _ => {
break; break;
@ -634,19 +639,21 @@ where
} }
#[cfg(feature = "a11y")] #[cfg(feature = "a11y")]
fn init_adapter(&mut self, event_loop: &(dyn winit::event_loop::ActiveEventLoop + 'static), id: core::window::Id, window: Arc<dyn winit::window::Window + 'static>) { fn init_adapter(
&mut self,
event_loop: &(dyn winit::event_loop::ActiveEventLoop + 'static),
id: core::window::Id,
window: Arc<dyn winit::window::Window + 'static>,
) {
use crate::a11y::*; use crate::a11y::*;
use iced_accessibility::accesskit::{ use iced_accessibility::accesskit::{
ActivationHandler, Node, NodeId, Role, ActivationHandler, Node, NodeId, Role, Tree, TreeUpdate,
Tree, TreeUpdate,
}; };
use iced_accessibility::accesskit_winit::Adapter; use iced_accessibility::accesskit_winit::Adapter;
let node_id = let node_id = iced_runtime::core::id::window_node_id();
iced_runtime::core::id::window_node_id();
let activation_handler = let activation_handler = WinitActivationHandler {
WinitActivationHandler {
proxy: self.control_sender.clone(), proxy: self.control_sender.clone(),
title: String::new(), title: String::new(),
}; };
@ -656,8 +663,7 @@ where
proxy: self.control_sender.clone(), proxy: self.control_sender.clone(),
}; };
let deactivation_handler = let deactivation_handler = WinitDeactivationHandler {
WinitDeactivationHandler {
proxy: self.control_sender.clone(), proxy: self.control_sender.clone(),
}; };
@ -674,8 +680,6 @@ where
), ),
), ),
); );
} }
} }
@ -879,9 +883,8 @@ async fn run_instance<P>(
exit_on_close_request, exit_on_close_request,
make_visible, make_visible,
on_open, on_open,
resize_border resize_border,
} => { } => {
#[cfg(all(feature = "cctk", target_os = "linux"))] #[cfg(all(feature = "cctk", target_os = "linux"))]
platform_specific_handler.send_wayland( platform_specific_handler.send_wayland(
platform_specific::Action::TrackWindow(window.clone(), id), platform_specific::Action::TrackWindow(window.clone(), id),
@ -937,7 +940,7 @@ async fn run_instance<P>(
compositor, compositor,
exit_on_close_request, exit_on_close_request,
system_theme, system_theme,
resize_border resize_border,
); );
window.raw.set_theme(conversion::window_theme( window.raw.set_theme(conversion::window_theme(
@ -1053,8 +1056,8 @@ async fn run_instance<P>(
// XX must force update to corner radius before the surface is committed. // XX must force update to corner radius before the surface is committed.
#[cfg(all(feature = "cctk", target_os = "linux"))] #[cfg(all(feature = "cctk", target_os = "linux"))]
if (window.surface_version != window.state.surface_version() if (window.surface_version != window.state.surface_version()
|| window.logical_size() != window.state.logical_size() || window.logical_size() != window.state.logical_size())
) && !crate::subsurface_widget::is_subsurface(window_id) && !crate::subsurface_widget::is_subsurface(window_id)
{ {
platform_specific_handler.send_wayland( platform_specific_handler.send_wayland(
platform_specific::Action::ResizeWindow(id), platform_specific::Action::ResizeWindow(id),
@ -1320,9 +1323,7 @@ async fn run_instance<P>(
continue; continue;
}; };
// Initiates a drag resize window state when found. // Initiates a drag resize window state when found.
if let Some(func) = if let Some(func) = window.drag_resize_window_func.as_mut() {
window.drag_resize_window_func.as_mut()
{
if func(window.raw.as_ref(), &event) { if func(window.raw.as_ref(), &event) {
continue; continue;
} }
@ -1348,7 +1349,9 @@ async fn run_instance<P>(
if matches!(event, winit::event::WindowEvent::CloseRequested) if matches!(event, winit::event::WindowEvent::CloseRequested)
&& window.exit_on_close_request && window.exit_on_close_request
{ {
_ = run_action!(Action::Window(runtime::window::Action::Close(id))); _ = run_action!(Action::Window(
runtime::window::Action::Close(id)
));
} else { } else {
window.state.update(&program, window.raw.as_ref(), &event); window.state.update(&program, window.raw.as_ref(), &event);
@ -1736,7 +1739,6 @@ async fn run_instance<P>(
}; };
// search windows for widget with operation // search windows for widget with operation
if result.is_none() { if result.is_none() {
log::warn!( log::warn!(
"start_dnd: widget {:?} not found; drag will fail", "start_dnd: widget {:?} not found; drag will fail",

View file

@ -1,8 +1,8 @@
use crate::core::window::Id as SurfaceId; use crate::core::window::Id as SurfaceId;
use iced_runtime::{ use iced_runtime::{
self, self, Action, Task,
platform_specific::{self, wayland}, platform_specific::{self, wayland},
task, Action, Task, task,
}; };
pub fn request_token( pub fn request_token(

View file

@ -1,11 +1,11 @@
use iced_futures::core::window; use iced_futures::core::window;
use iced_runtime::{ use iced_runtime::{
self, self, Action, Task,
platform_specific::{ platform_specific::{
self, self,
wayland::{self, CornerRadius}, wayland::{self, CornerRadius},
}, },
task, Action, Task, task,
}; };
pub fn corner_radius( pub fn corner_radius(

View file

@ -1,7 +1,7 @@
use iced_runtime::{ use iced_runtime::{
self, self, Action, Task,
platform_specific::{self, wayland}, platform_specific::{self, wayland},
task, Action, Task, task,
}; };
pub fn inhibit_shortcuts(inhibit: bool) -> Task<()> { pub fn inhibit_shortcuts(inhibit: bool) -> Task<()> {

View file

@ -1,7 +1,8 @@
use iced_futures::core::window::Id; use iced_futures::core::window::Id;
use iced_runtime::{ use iced_runtime::{
Action, Task,
platform_specific::{self, wayland}, platform_specific::{self, wayland},
task, Action, Task, task,
}; };
/// Request subscription for overlap notification events on the surface /// Request subscription for overlap notification events on the surface

View file

@ -1,9 +1,9 @@
use crate::core::window::Id as SurfaceId; use crate::core::window::Id as SurfaceId;
use cctk::sctk::reexports::client::protocol::wl_output::WlOutput; use cctk::sctk::reexports::client::protocol::wl_output::WlOutput;
use iced_runtime::{ use iced_runtime::{
self, self, Action, Task,
platform_specific::{self, wayland}, platform_specific::{self, wayland},
task, Action, Task, task,
}; };
pub fn lock<Message>() -> Task<Message> { pub fn lock<Message>() -> Task<Message> {

View file

@ -1,12 +1,12 @@
use crate::core::window::Id as SurfaceId; use crate::core::window::Id as SurfaceId;
pub use cctk::sctk::shell::wlr_layer::{Anchor, KeyboardInteractivity, Layer}; pub use cctk::sctk::shell::wlr_layer::{Anchor, KeyboardInteractivity, Layer};
use iced_runtime::{ use iced_runtime::{
self, self, Action, Task,
platform_specific::{ platform_specific::{
self, self,
wayland::{self, subsurface::SctkSubsurfaceSettings}, wayland::{self, subsurface::SctkSubsurfaceSettings},
}, },
task, Action, Task, task,
}; };
pub fn get_subsurface<Message>( pub fn get_subsurface<Message>(

View file

@ -1,8 +1,8 @@
use cctk::sctk::reexports::calloop; use cctk::sctk::reexports::calloop;
use iced_futures::futures::{ use iced_futures::futures::{
Sink,
channel::mpsc, channel::mpsc,
task::{Context, Poll}, task::{Context, Poll},
Sink,
}; };
use std::pin::Pin; use std::pin::Pin;

View file

@ -1,7 +1,11 @@
use crate::{ use crate::{
Control, Control,
handlers::{ handlers::{
activation::IcedRequestData, ext_background_effect, overlap::{OverlapNotificationV1, OverlapNotifyV1}, shell::corner_radius::CornerRadiusWrapper, text_input::{Preedit, TextInputManager} activation::IcedRequestData,
ext_background_effect,
overlap::{OverlapNotificationV1, OverlapNotifyV1},
shell::corner_radius::CornerRadiusWrapper,
text_input::{Preedit, TextInputManager},
}, },
platform_specific::{ platform_specific::{
Event, Event,
@ -37,11 +41,10 @@ use winit::{
use cctk::{ use cctk::{
cosmic_protocols::{ cosmic_protocols::{
corner_radius::v1::client::{ corner_radius::v1::client::cosmic_corner_radius_manager_v1::CosmicCornerRadiusManagerV1,
cosmic_corner_radius_manager_v1::CosmicCornerRadiusManagerV1,
},
overlap_notify::v1::client::zcosmic_overlap_notification_v1::ZcosmicOverlapNotificationV1, overlap_notify::v1::client::zcosmic_overlap_notification_v1::ZcosmicOverlapNotificationV1,
}, sctk::{ },
sctk::{
activation::{ActivationState, RequestData}, activation::{ActivationState, RequestData},
compositor::CompositorState, compositor::CompositorState,
error::GlobalError, error::GlobalError,
@ -59,7 +62,8 @@ use cctk::{
wl_surface::{self, WlSurface}, wl_surface::{self, WlSurface},
wl_touch::WlTouch, wl_touch::WlTouch,
}, },
}, protocols_wlr::layer_shell::v1::client::zwlr_layer_surface_v1::ZwlrLayerSurfaceV1, },
protocols_wlr::layer_shell::v1::client::zwlr_layer_surface_v1::ZwlrLayerSurfaceV1,
}, },
registry::RegistryState, registry::RegistryState,
seat::{ seat::{
@ -84,7 +88,9 @@ use cctk::{
}, },
}, },
shm::{Shm, multi::MultiPool}, shm::{Shm, multi::MultiPool},
}, toplevel_info::ToplevelInfoState, toplevel_management::ToplevelManagerState },
toplevel_info::ToplevelInfoState,
toplevel_management::ToplevelManagerState,
}; };
use iced_runtime::{ use iced_runtime::{
core::{self, Point, touch}, core::{self, Point, touch},
@ -99,7 +105,10 @@ use iced_runtime::{
}, },
}; };
use wayland_protocols::{ use wayland_protocols::{
ext::background_effect::v1::client::{ext_background_effect_manager_v1, ext_background_effect_surface_v1::ExtBackgroundEffectSurfaceV1}, ext::background_effect::v1::client::{
ext_background_effect_manager_v1,
ext_background_effect_surface_v1::ExtBackgroundEffectSurfaceV1,
},
wp::{ wp::{
fractional_scale::v1::client::wp_fractional_scale_v1::WpFractionalScaleV1, fractional_scale::v1::client::wp_fractional_scale_v1::WpFractionalScaleV1,
keyboard_shortcuts_inhibit::zv1::client::{ keyboard_shortcuts_inhibit::zv1::client::{
@ -333,7 +342,6 @@ pub struct SctkPopupData {
pub(crate) grab: bool, pub(crate) grab: bool,
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct SctkCornerRadius(Arc<CornerRadiusWrapper>); pub struct SctkCornerRadius(Arc<CornerRadiusWrapper>);
@ -870,8 +878,6 @@ impl SctkState {
self.apply_blur(settings.id, Some(blur), &wl_surface); self.apply_blur(settings.id, Some(blur), &wl_surface);
} }
let wp_viewport = self.viewporter_state.as_ref().map(|state| { let wp_viewport = self.viewporter_state.as_ref().map(|state| {
let viewport = let viewport =
state.get_viewport(popup.wl_surface(), &self.queue_handle); state.get_viewport(popup.wl_surface(), &self.queue_handle);
@ -904,7 +910,7 @@ impl SctkState {
}); });
if let Some(corners) = self.pending_corner_radius.remove(&settings.id) { if let Some(corners) = self.pending_corner_radius.remove(&settings.id) {
self.handle_action(Action::RoundedCorners ( self.handle_action(Action::RoundedCorners(
settings.id, settings.id,
Some(corners), Some(corners),
)); ));
@ -1009,7 +1015,6 @@ impl SctkState {
self.apply_blur(id, Some(blur), &wl_surface); self.apply_blur(id, Some(blur), &wl_surface);
} }
let wp_viewport = self.viewporter_state.as_ref().map(|state| { let wp_viewport = self.viewporter_state.as_ref().map(|state| {
state.get_viewport(layer_surface.wl_surface(), &self.queue_handle) state.get_viewport(layer_surface.wl_surface(), &self.queue_handle)
}); });
@ -1043,10 +1048,7 @@ impl SctkState {
common: common.clone(), common: common.clone(),
}); });
if let Some(corners) = self.pending_corner_radius.remove(&id) { if let Some(corners) = self.pending_corner_radius.remove(&id) {
_ = self.handle_action(Action::RoundedCorners( _ = self.handle_action(Action::RoundedCorners(id, Some(corners)));
id,
Some(corners),
));
} }
layer_surface.commit(); layer_surface.commit();
Ok((id, CommonSurface::Layer(layer_surface), common)) Ok((id, CommonSurface::Layer(layer_surface), common))
@ -1173,7 +1175,6 @@ impl SctkState {
_ = self.destroyed.insert(destroyed); _ = self.destroyed.insert(destroyed);
} }
send_event(&self.events_sender, &self.proxy, SctkEvent::LayerSurfaceEvent { send_event(&self.events_sender, &self.proxy, SctkEvent::LayerSurfaceEvent {
variant: LayerSurfaceEventVariant::Done, variant: LayerSurfaceEventVariant::Done,
id: l.surface.wl_surface().clone(), id: l.surface.wl_surface().clone(),
@ -1492,7 +1493,6 @@ impl SctkState {
// update positioner // update positioner
sctk_popup.data.positioner.set_size(w as i32, h as i32); sctk_popup.data.positioner.set_size(w as i32, h as i32);
sctk_popup.popup.reposition(&sctk_popup.data.positioner, TOKEN_CTR.fetch_add(1, std::sync::atomic::Ordering::Relaxed)); let surface = sctk_popup.popup.wl_surface().clone(); sctk_popup.popup.reposition(&sctk_popup.data.positioner, TOKEN_CTR.fetch_add(1, std::sync::atomic::Ordering::Relaxed)); let surface = sctk_popup.popup.wl_surface().clone();
dbg!("repositioning...");
_ = send_event(&self.events_sender, &self.proxy, _ = send_event(&self.events_sender, &self.proxy,
SctkEvent::PopupEvent { variant: crate::sctk_event::PopupEventVariant::Size(size.0, size.1), toplevel_id: sctk_popup.data.parent.wl_surface().clone(), parent_id: sctk_popup.data.parent.wl_surface().clone(), id: surface }); SctkEvent::PopupEvent { variant: crate::sctk_event::PopupEventVariant::Size(size.0, size.1), toplevel_id: sctk_popup.data.parent.wl_surface().clone(), parent_id: sctk_popup.data.parent.wl_surface().clone(), id: surface });
} }
@ -1832,13 +1832,18 @@ impl SctkState {
Ok(()) Ok(())
} }
fn apply_blur(&mut self, id: core::window::Id, rectangles: Option<Vec<Rectangle>>, s: &WlSurface) { fn apply_blur(
&mut self,
id: core::window::Id,
rectangles: Option<Vec<Rectangle>>,
s: &WlSurface,
) {
let existing_blur = self.blur_surfaces.entry(id); let existing_blur = self.blur_surfaces.entry(id);
match (existing_blur, rectangles) { match (existing_blur, rectangles) {
(Entry::Occupied(occupied_entry), None) => { (Entry::Occupied(occupied_entry), None) => {
let blur_surface = occupied_entry.remove(); let blur_surface = occupied_entry.remove();
blur_surface.destroy(); blur_surface.destroy();
}, }
(Entry::Occupied(mut occupied_entry), Some(rectangles)) => { (Entry::Occupied(mut occupied_entry), Some(rectangles)) => {
let blur_surface = occupied_entry.get_mut(); let blur_surface = occupied_entry.get_mut();
let region = self let region = self
@ -1856,11 +1861,10 @@ impl SctkState {
// update existing blur surfaces // update existing blur surfaces
blur_surface.set_blur_region(Some(&region)); blur_surface.set_blur_region(Some(&region));
}
},
(Entry::Vacant(..), None) => { (Entry::Vacant(..), None) => {
// nothing to remove // nothing to remove
}, }
(Entry::Vacant(vacant_entry), Some(rectangles)) => { (Entry::Vacant(vacant_entry), Some(rectangles)) => {
if self.ext_background_effect_manager.is_none() { if self.ext_background_effect_manager.is_none() {
log::error!("Blur effect is not supported."); log::error!("Blur effect is not supported.");
@ -1879,13 +1883,13 @@ impl SctkState {
); );
} }
let blur_manager = self.ext_background_effect_manager.as_mut().unwrap(); let blur_manager =
self.ext_background_effect_manager.as_mut().unwrap();
let blur_surface = blur_manager.blur(s, &self.queue_handle); let blur_surface = blur_manager.blur(s, &self.queue_handle);
blur_surface.set_blur_region(Some(&region)); blur_surface.set_blur_region(Some(&region));
_ = vacant_entry.insert(blur_surface); _ = vacant_entry.insert(blur_surface);
},
} }
}
} }
pub fn get_subsurface( pub fn get_subsurface(
@ -2021,7 +2025,6 @@ impl SctkState {
_ = self.apply_blur(settings.id, Some(blur), &wl_surface); _ = self.apply_blur(settings.id, Some(blur), &wl_surface);
} }
let wp_viewport = subsurface_state.wp_viewporter.get_viewport( let wp_viewport = subsurface_state.wp_viewporter.get_viewport(
&wl_surface, &wl_surface,
&self.queue_handle, &self.queue_handle,
@ -2097,10 +2100,7 @@ impl SctkState {
self.subsurfaces self.subsurfaces
.sort_by(|a, b| b.instance.z.cmp(&a.instance.z)); .sort_by(|a, b| b.instance.z.cmp(&a.instance.z));
if let Some(corners) = self.pending_corner_radius.remove(&id) { if let Some(corners) = self.pending_corner_radius.remove(&id) {
self.handle_action(Action::RoundedCorners ( self.handle_action(Action::RoundedCorners(id, Some(corners)));
id,
Some(corners),
));
} }
wl_surface.commit(); wl_surface.commit();

View file

@ -9,12 +9,12 @@ use crate::{
use cctk::sctk::{ use cctk::sctk::{
delegate_touch, delegate_touch,
reexports::client::{ reexports::client::{
protocol::{wl_surface::WlSurface, wl_touch::WlTouch},
Connection, Proxy, QueueHandle, Connection, Proxy, QueueHandle,
protocol::{wl_surface::WlSurface, wl_touch::WlTouch},
}, },
seat::touch::TouchHandler, seat::touch::TouchHandler,
}; };
use iced_runtime::core::{touch, Point}; use iced_runtime::core::{Point, touch};
impl TouchHandler for SctkState { impl TouchHandler for SctkState {
fn down( fn down(

View file

@ -1,8 +1,7 @@
use crate::{ use crate::{
event_loop::state::CommonSurface, event_loop::state::CommonSurface,
platform_specific::wayland::{ platform_specific::wayland::{
event_loop::state::receive_frame, event_loop::state::receive_frame, handlers::SctkState,
handlers::SctkState,
sctk_event::SctkEvent, sctk_event::SctkEvent,
}, },
}; };

View file

@ -1,13 +1,13 @@
use crate::platform_specific::wayland::{ use crate::platform_specific::wayland::{
event_loop::state::{receive_frame, SctkState}, event_loop::state::{SctkState, receive_frame},
sctk_event::{LayerSurfaceEventVariant, SctkEvent}, sctk_event::{LayerSurfaceEventVariant, SctkEvent},
}; };
use cctk::sctk::{ use cctk::sctk::{
delegate_layer, delegate_layer,
reexports::client::Proxy, reexports::client::Proxy,
shell::{ shell::{
wlr_layer::{Anchor, KeyboardInteractivity, LayerShellHandler},
WaylandSurface, WaylandSurface,
wlr_layer::{Anchor, KeyboardInteractivity, LayerShellHandler},
}, },
}; };
use std::fmt::Debug; use std::fmt::Debug;

View file

@ -1,4 +1,4 @@
pub mod corner_radius;
pub mod layer; pub mod layer;
pub mod xdg_popup; pub mod xdg_popup;
pub mod xdg_window; pub mod xdg_window;
pub mod corner_radius;

View file

@ -1,10 +1,10 @@
//! Handling of the wp-viewporter. //! Handling of the wp-viewporter.
use cctk::sctk::reexports::client::Dispatch;
use cctk::sctk::reexports::client::globals::{BindError, GlobalList}; use cctk::sctk::reexports::client::globals::{BindError, GlobalList};
use cctk::sctk::reexports::client::protocol::wl_surface::WlSurface; use cctk::sctk::reexports::client::protocol::wl_surface::WlSurface;
use cctk::sctk::reexports::client::Dispatch;
use cctk::sctk::reexports::client::{ use cctk::sctk::reexports::client::{
delegate_dispatch, Connection, Proxy, QueueHandle, Connection, Proxy, QueueHandle, delegate_dispatch,
}; };
use cctk::sctk::reexports::protocols::wp::viewporter::client::wp_viewport::WpViewport; use cctk::sctk::reexports::protocols::wp::viewporter::client::wp_viewport::WpViewport;
use cctk::sctk::reexports::protocols::wp::viewporter::client::wp_viewporter::WpViewporter; use cctk::sctk::reexports::protocols::wp::viewporter::client::wp_viewporter::WpViewporter;

View file

@ -21,6 +21,7 @@ use iced_runtime::core::{Vector, window};
use raw_window_handle::{DisplayHandle, HasDisplayHandle, HasWindowHandle}; use raw_window_handle::{DisplayHandle, HasDisplayHandle, HasWindowHandle};
use raw_window_handle::{HasRawDisplayHandle, RawWindowHandle}; use raw_window_handle::{HasRawDisplayHandle, RawWindowHandle};
use sctk_event::SctkEvent; use sctk_event::SctkEvent;
use std::sync::OnceLock;
use std::{collections::HashMap, sync::Arc}; use std::{collections::HashMap, sync::Arc};
use subsurface_widget::{SubsurfaceInstance, SubsurfaceState}; use subsurface_widget::{SubsurfaceInstance, SubsurfaceState};
use wayland_backend::client::ObjectId; use wayland_backend::client::ObjectId;