diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a95f6188e1f3..72e371878b26 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -136,8 +136,6 @@ jobs: - name: Selectively upgrade url run: cargo update -p url@2.0.0 --precise 2.3.0 # Needed to fix WlTouch trait bounds - - name: Selectively upgrade client-toolkit - run: cargo update -p smithay-client-toolkit@0.21.0 --precise 0.21.1 - name: Rust toolchain uses: dtolnay/rust-toolchain@1.87 - name: Check diff --git a/Cargo.toml b/Cargo.toml index 072c78e9991c..7ab8ba38ea1a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -148,3 +148,16 @@ harness = false [profile.release-with-debug] inherits = "release" debug = true + +[patch.crates-io] +wayland-sys = { git = "https://github.com/smithay/wayland-rs" } +wayland-egl = { git = "https://github.com/smithay/wayland-rs" } +wayland-backend = { git = "https://github.com/smithay/wayland-rs" } +wayland-server = { git = "https://github.com/smithay/wayland-rs" } +wayland-scanner = { git = "https://github.com/smithay/wayland-rs" } +wayland-client = { git = "https://github.com/smithay/wayland-rs" } +wayland-protocols = { git = "https://github.com/smithay/wayland-rs" } +wayland-protocols-wlr = { git = "https://github.com/smithay/wayland-rs" } +wayland-cursor = { git = "https://github.com/smithay/wayland-rs" } +winit = { git = "https://github.com/ids1024/winit", branch = "wayland-update" } +gbm = { git = "https://github.com/ids1024/gbm.rs", branch = "wayland-rs" } diff --git a/anvil/src/shell/grabs.rs b/anvil/src/shell/grabs.rs index ca2b17dd6a58..ca0ab2700983 100644 --- a/anvil/src/shell/grabs.rs +++ b/anvil/src/shell/grabs.rs @@ -279,7 +279,7 @@ bitflags::bitflags! { impl From for ResizeEdge { #[inline] fn from(x: xdg_toplevel::ResizeEdge) -> Self { - Self::from_bits(x as u32).unwrap() + Self::from_bits(u32::from(x)).unwrap() } } diff --git a/anvil/src/state.rs b/anvil/src/state.rs index 0719343f6567..3917b6acd703 100644 --- a/anvil/src/state.rs +++ b/anvil/src/state.rs @@ -15,7 +15,6 @@ use smithay::{ RenderElementStates, default_primary_scanout_output_compare, utils::select_dmabuf_feedback, }, }, - delegate_dispatch2, desktop::{ PopupKind, PopupManager, Space, space::SpaceElement, @@ -645,8 +644,6 @@ impl ImageCopyCaptureHandler for AnvilState { } } -delegate_dispatch2!(@ AnvilState); - impl AnvilState { pub fn init( display: Display>, diff --git a/examples/compositor.rs b/examples/compositor.rs index 714d4c44a4aa..63fb539cae4f 100644 --- a/examples/compositor.rs +++ b/examples/compositor.rs @@ -1,6 +1,5 @@ use std::sync::Arc; -use smithay::delegate_dispatch2; use smithay::reexports::wayland_server::Display; use smithay::wayland::compositor::{CompositorClientState, CompositorHandler, CompositorState}; @@ -74,5 +73,3 @@ impl AsMut for App { &mut self.compositor_state } } - -delegate_dispatch2!(App); diff --git a/examples/minimal.rs b/examples/minimal.rs index d288cb54ac03..d82c572c3f97 100644 --- a/examples/minimal.rs +++ b/examples/minimal.rs @@ -291,5 +291,3 @@ impl ClientData for ClientState { println!("disconnected"); } } - -smithay::delegate_dispatch2!(App); diff --git a/examples/seat.rs b/examples/seat.rs index 0bc280629470..00b1036afdf4 100644 --- a/examples/seat.rs +++ b/examples/seat.rs @@ -106,5 +106,3 @@ impl CompositorHandler for App { fn commit(&mut self, _surface: &WlSurface) {} } - -smithay::delegate_dispatch2!(App); diff --git a/smallvil/src/grabs/resize_grab.rs b/smallvil/src/grabs/resize_grab.rs index 276dc6891e3a..7e0f1aa10d87 100644 --- a/smallvil/src/grabs/resize_grab.rs +++ b/smallvil/src/grabs/resize_grab.rs @@ -39,7 +39,7 @@ bitflags::bitflags! { impl From for ResizeEdge { #[inline] fn from(x: xdg_toplevel::ResizeEdge) -> Self { - Self::from_bits(x as u32).unwrap() + Self::from_bits(u32::from(x)).unwrap() } } diff --git a/smallvil/src/handlers/mod.rs b/smallvil/src/handlers/mod.rs index fafba61e79ff..ddc551f98c18 100644 --- a/smallvil/src/handlers/mod.rs +++ b/smallvil/src/handlers/mod.rs @@ -86,5 +86,3 @@ impl WaylandDndGrabHandler for Smallvil { // impl OutputHandler for Smallvil {} - -smithay::delegate_dispatch2!(Smallvil); diff --git a/src/backend/egl/display.rs b/src/backend/egl/display.rs index 0b0ce91f7b73..453ef6f67ad7 100644 --- a/src/backend/egl/display.rs +++ b/src/backend/egl/display.rs @@ -865,7 +865,7 @@ impl EGLDisplay { ffi::egl::BindWaylandDisplayWL(**self.display, display_ptr as *mut _) }) .map_err(Error::OtherEGLDisplayAlreadyBound)?; - let reader = EGLBufferReader::new(self.display.clone(), display_ptr); + let reader = EGLBufferReader::new(self.display.clone(), display_ptr as _); let mut global = BUFFER_READER.lock().unwrap(); if global.as_ref().and_then(|x| x.upgrade()).is_some() { warn!("Double bind_wl_display, smithay does not support this, please report"); @@ -1065,7 +1065,7 @@ impl EGLBufferReader { let query = wrap_egl_call_bool(|| unsafe { ffi::egl::QueryWaylandBufferWL( **self.display, - buffer.id().as_ptr() as _, + buffer.id().as_ptr().unwrap().as_ptr(), ffi::egl::EGL_TEXTURE_FORMAT, &mut format, ) @@ -1095,7 +1095,7 @@ impl EGLBufferReader { wrap_egl_call_bool(|| unsafe { ffi::egl::QueryWaylandBufferWL( **self.display, - buffer.id().as_ptr() as _, + buffer.id().as_ptr().unwrap().as_ptr(), ffi::egl::WIDTH as i32, &mut width, ) @@ -1106,7 +1106,7 @@ impl EGLBufferReader { wrap_egl_call_bool(|| unsafe { ffi::egl::QueryWaylandBufferWL( **self.display, - buffer.id().as_ptr() as _, + buffer.id().as_ptr().unwrap().as_ptr(), ffi::egl::HEIGHT as i32, &mut height, ) @@ -1128,7 +1128,7 @@ impl EGLBufferReader { unsafe { ffi::egl::QueryWaylandBufferWL( **self.display, - buffer.id().as_ptr() as _, + buffer.id().as_ptr().unwrap().as_ptr(), ffi::egl::WAYLAND_Y_INVERTED_WL, &mut inverted, ) @@ -1152,7 +1152,7 @@ impl EGLBufferReader { **self.display, ffi::egl::NO_CONTEXT, ffi::egl::WAYLAND_BUFFER_WL, - buffer.id().as_ptr() as *mut _, + buffer.id().as_ptr().unwrap().as_ptr(), out.as_ptr(), ) }) @@ -1188,7 +1188,7 @@ impl EGLBufferReader { if unsafe { ffi::egl::QueryWaylandBufferWL( **self.display, - buffer.id().as_ptr() as _, + buffer.id().as_ptr().unwrap().as_ptr(), ffi::egl::WIDTH as _, &mut width, ) == 0 @@ -1200,7 +1200,7 @@ impl EGLBufferReader { if unsafe { ffi::egl::QueryWaylandBufferWL( **self.display, - buffer.id().as_ptr() as _, + buffer.id().as_ptr().unwrap().as_ptr(), ffi::egl::HEIGHT as _, &mut height, ) == 0 diff --git a/src/backend/egl/native.rs b/src/backend/egl/native.rs index b98b94f72096..c1754ee33b91 100644 --- a/src/backend/egl/native.rs +++ b/src/backend/egl/native.rs @@ -408,7 +408,7 @@ unsafe impl EGLNativeSurface for wegl::WlEglSurface { ffi::egl::CreatePlatformWindowSurfaceEXT( display.handle, config_id, - self.ptr() as *mut _, + self.ptr().as_ptr(), WINIT_SURFACE_ATTRIBUTES.as_ptr(), ) }) diff --git a/src/backend/renderer/element/mod.rs b/src/backend/renderer/element/mod.rs index b68779367abd..95a69a2614c1 100644 --- a/src/backend/renderer/element/mod.rs +++ b/src/backend/renderer/element/mod.rs @@ -172,7 +172,7 @@ impl Id { #[cfg(feature = "wayland_frontend")] pub fn from_wayland_resource(resource: &R) -> Self { Id { - inner: InnerId::WaylandResource(resource.id()), + inner: InnerId::WaylandResource(resource.id().clone()), namespace: None, } } diff --git a/src/backend/winit/mod.rs b/src/backend/winit/mod.rs index 4f1d971536a8..b8b62c979b98 100644 --- a/src/backend/winit/mod.rs +++ b/src/backend/winit/mod.rs @@ -235,7 +235,7 @@ where let size = window.surface_size(); let surface = unsafe { wegl::WlEglSurface::new_from_raw( - handle.surface.as_ptr() as *mut _, + std::ptr::NonNull::new(handle.surface.as_ptr() as *mut _).unwrap(), size.width as i32, size.height as i32, ) diff --git a/src/utils/iter.rs b/src/utils/iter.rs index eb9185de18a5..242d59f85421 100644 --- a/src/utils/iter.rs +++ b/src/utils/iter.rs @@ -9,10 +9,10 @@ pub struct LockedClientObjsIter<'a, T: 'static, G, F> { pub guard: MutexGuard<'a, G>, } -pub(crate) fn new_locked_obj_iter_from_vec( - guard: MutexGuard<'_, Vec>>, - client: ClientId, -) -> impl Iterator + '_ { +pub(crate) fn new_locked_obj_iter_from_vec<'a, T: Resource + 'static>( + guard: MutexGuard<'a, Vec>>, + client: &'a ClientId, +) -> impl Iterator + 'a { new_locked_obj_iter(guard, client, |guard| guard.iter()) } @@ -23,7 +23,7 @@ pub(crate) fn new_locked_obj_iter< F: for<'b> FnOnce(&'b G) -> std::slice::Iter<'b, Weak>, >( guard: MutexGuard<'a, G>, - client: ClientId, + client: &'a ClientId, iterator_fn: F, ) -> impl Iterator + 'a { let iterator = unsafe { @@ -33,10 +33,9 @@ pub(crate) fn new_locked_obj_iter< }; let iterator = iterator.filter_map(move |p| { - let client = &client; p.upgrade() .ok() - .filter(|p| p.client().is_some_and(|c| c.id() == *client)) + .filter(|p| p.client().is_some_and(|c| c.id() == client)) }); LockedClientObjsIter::<'a, T, G, _>::new_internal(iterator, guard) diff --git a/src/wayland/alpha_modifier/dispatch.rs b/src/wayland/alpha_modifier/dispatch.rs index f0ac34b6e1c4..81a93f7c0c3b 100644 --- a/src/wayland/alpha_modifier/dispatch.rs +++ b/src/wayland/alpha_modifier/dispatch.rs @@ -3,14 +3,15 @@ use wayland_protocols::wp::alpha_modifier::v1::server::{ wp_alpha_modifier_v1::{self, WpAlphaModifierV1}, }; -use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, New, Resource, backend::ClientId}; +use wayland_server::{ + Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, backend::ClientId, +}; use super::{AlphaModifierSurfaceCachedState, AlphaModifierSurfaceData, AlphaModifierSurfaceUserData}; -use crate::wayland::{Dispatch2, GlobalData, GlobalDispatch2, compositor}; +use crate::wayland::{GlobalData, compositor}; -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, D: 'static, { fn bind( @@ -25,9 +26,8 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, D: 'static, { fn request( @@ -72,7 +72,7 @@ where } } -impl Dispatch2 for AlphaModifierSurfaceUserData { +impl Dispatch for AlphaModifierSurfaceUserData { fn request( &self, _state: &mut D, @@ -128,7 +128,7 @@ impl Dispatch2 for AlphaModifierSurfaceUserData } } - fn destroyed(&self, _state: &mut D, _client: ClientId, _object: &WpAlphaModifierSurfaceV1) { + fn destroyed(&self, _state: &mut D, _client: &ClientId, _object: &WpAlphaModifierSurfaceV1) { // Nothing to do here, graceful Destroy is already handled with double buffering // and in case of client close WlSurface destroyed handler will clean up the data anyway, // so there is no point in queuing new update diff --git a/src/wayland/alpha_modifier/mod.rs b/src/wayland/alpha_modifier/mod.rs index d6bc168bda36..0fa6d96ca236 100644 --- a/src/wayland/alpha_modifier/mod.rs +++ b/src/wayland/alpha_modifier/mod.rs @@ -20,8 +20,6 @@ //! struct ClientState { compositor_state: CompositorClientState } //! impl wayland_server::backend::ClientData for ClientState {} //! -//! smithay::delegate_dispatch2!(State); -//! //! impl CompositorHandler for State { //! fn compositor_state(&mut self) -> &mut CompositorState { //! &mut self.compositor_state @@ -54,13 +52,8 @@ use std::sync::{ atomic::{self, AtomicBool}, }; -use wayland_protocols::wp::alpha_modifier::v1::server::{ - wp_alpha_modifier_surface_v1::WpAlphaModifierSurfaceV1, wp_alpha_modifier_v1::WpAlphaModifierV1, -}; -use wayland_server::{ - Dispatch, DisplayHandle, GlobalDispatch, Resource, Weak, backend::GlobalId, - protocol::wl_surface::WlSurface, -}; +use wayland_protocols::wp::alpha_modifier::v1::server::wp_alpha_modifier_v1::WpAlphaModifierV1; +use wayland_server::{DisplayHandle, Resource, Weak, backend::GlobalId, protocol::wl_surface::WlSurface}; use super::compositor::Cacheable; @@ -137,7 +130,7 @@ impl AlphaModifierSurfaceData { } } -/// User data of [WpAlphaModifierSurfaceV1] object +/// User data of [`WpAlphaModifierSurfaceV1`][wayland_protocols::wp::alpha_modifier::v1::server::wp_alpha_modifier_surface_v1] object #[derive(Debug)] pub struct AlphaModifierSurfaceUserData(Mutex>); @@ -161,10 +154,7 @@ impl AlphaModifierState { /// Regiseter new [WpAlphaModifierV1] global pub fn new(display: &DisplayHandle) -> AlphaModifierState where - D: GlobalDispatch - + Dispatch - + Dispatch - + 'static, + D: 'static, { let global = display.create_global::(1, GlobalData); diff --git a/src/wayland/background_effect/dispatch.rs b/src/wayland/background_effect/dispatch.rs index 860c9889c68c..4094b7772799 100644 --- a/src/wayland/background_effect/dispatch.rs +++ b/src/wayland/background_effect/dispatch.rs @@ -1,7 +1,7 @@ use crate::wayland::background_effect::{BackgroundEffectSurfaceData, ExtBackgroundEffectHandler}; use crate::wayland::compositor; use crate::wayland::{ - Dispatch2, GlobalData, GlobalDispatch2, + GlobalData, background_effect::{BackgroundEffectSurfaceCachedState, BackgroundEffectSurfaceUserData}, compositor::with_states, }; @@ -13,12 +13,9 @@ use wayland_protocols::ext::background_effect::v1::server::{ Error as SurfaceError, ExtBackgroundEffectSurfaceV1, Request as SurfaceRequest, }, }; -use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, New, Resource}; +use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource}; -impl GlobalDispatch2 for GlobalData -where - D: Dispatch, -{ +impl GlobalDispatch for GlobalData { fn bind( &self, state: &mut D, @@ -32,10 +29,7 @@ where } } -impl Dispatch2 for GlobalData -where - D: Dispatch, -{ +impl Dispatch for GlobalData { fn request( &self, _state: &mut D, @@ -73,7 +67,7 @@ where } } -impl Dispatch2 +impl Dispatch for BackgroundEffectSurfaceUserData { fn request( @@ -131,7 +125,7 @@ impl Dispatch2 fn destroyed( &self, _state: &mut D, - _client_id: wayland_server::backend::ClientId, + _client_id: &wayland_server::backend::ClientId, _object: &ExtBackgroundEffectSurfaceV1, ) { // No-op: cleanup is handled by double-buffering and surface destruction diff --git a/src/wayland/background_effect/mod.rs b/src/wayland/background_effect/mod.rs index 763be21e45f2..54131177e361 100644 --- a/src/wayland/background_effect/mod.rs +++ b/src/wayland/background_effect/mod.rs @@ -25,8 +25,6 @@ //! // Blur region is stored in wl_surface [BackgroundEffectSurfaceCachedState] //! } //! } -//! -//! smithay::delegate_dispatch2!(State); //! ``` use std::sync::{ @@ -41,9 +39,7 @@ use crate::wayland::{ use wayland_protocols::ext::background_effect::v1::server::ext_background_effect_manager_v1::{ self, ExtBackgroundEffectManagerV1, }; -use wayland_server::{ - DisplayHandle, GlobalDispatch, Resource, Weak, backend::GlobalId, protocol::wl_surface::WlSurface, -}; +use wayland_server::{DisplayHandle, Resource, Weak, backend::GlobalId, protocol::wl_surface::WlSurface}; pub use ext_background_effect_manager_v1::Capability; @@ -144,7 +140,7 @@ impl BackgroundEffectState { /// Regiseter new [ExtBackgroundEffectManagerV1] global pub fn new(display: &DisplayHandle) -> BackgroundEffectState where - D: ExtBackgroundEffectHandler + GlobalDispatch, + D: ExtBackgroundEffectHandler, { let global = display.create_global::(1, GlobalData); BackgroundEffectState { global } diff --git a/src/wayland/buffer/mod.rs b/src/wayland/buffer/mod.rs index 57164b3d7c42..479f40d9002a 100644 --- a/src/wayland/buffer/mod.rs +++ b/src/wayland/buffer/mod.rs @@ -13,8 +13,7 @@ use wayland_server::protocol::wl_buffer; /// # For buffer abstractions /// /// Buffer abstractions (such as [`shm`](crate::wayland::shm)) should require this trait in their -/// [`delegate_dispatch`](wayland_server::delegate_dispatch) implementations to notify the compositor when a -/// buffer is destroyed. +/// mplementations to notify the compositor when a buffer is destroyed. pub trait BufferHandler { /// Called when the client has destroyed the buffer. /// diff --git a/src/wayland/commit_timing/mod.rs b/src/wayland/commit_timing/mod.rs index 6cd6f2caea73..57bacc4d0c7e 100644 --- a/src/wayland/commit_timing/mod.rs +++ b/src/wayland/commit_timing/mod.rs @@ -20,8 +20,6 @@ //! // insert the CommitTimingManagerState into your state //! // .. //! -//! smithay::delegate_dispatch2!(State); -//! //! // You're now ready to go! //! ``` //! @@ -92,10 +90,7 @@ use wayland_server::{ use crate::{ utils::Time, - wayland::{ - Dispatch2, GlobalDispatch2, - compositor::{add_blocker, add_pre_commit_hook}, - }, + wayland::compositor::{add_blocker, add_pre_commit_hook}, }; use super::compositor::{Barrier, with_states}; @@ -114,7 +109,6 @@ impl CommitTimingManagerState { /// remove or disable this global in the future. pub fn new(display: &DisplayHandle) -> Self where - D: GlobalDispatch, D: 'static, { Self::new_internal::(display, true) @@ -126,7 +120,6 @@ impl CommitTimingManagerState { /// remove or disable this global in the future. pub fn unmanaged(display: &DisplayHandle) -> Self where - D: GlobalDispatch, D: 'static, { Self::new_internal::(display, false) @@ -134,7 +127,6 @@ impl CommitTimingManagerState { fn new_internal(display: &DisplayHandle, is_managed: bool) -> Self where - D: GlobalDispatch, D: 'static, { let global = @@ -160,9 +152,8 @@ pub struct CommitTimingManagerData { is_managed: bool, } -impl GlobalDispatch2 for CommitTimingManagerData +impl GlobalDispatch for CommitTimingManagerData where - D: Dispatch, D: 'static, { fn bind( @@ -177,9 +168,8 @@ where } } -impl Dispatch2 for CommitTimingManagerData +impl Dispatch for CommitTimingManagerData where - D: Dispatch, D: 'static, { fn request( @@ -257,7 +247,7 @@ struct CommitTimerMarker(Option); #[derive(Debug)] pub struct CommitTimerData(Weak); -impl Dispatch2 for CommitTimerData +impl Dispatch for CommitTimerData where D: 'static, { diff --git a/src/wayland/compositor/handlers.rs b/src/wayland/compositor/handlers.rs index c18aef346a7b..c734ff307250 100644 --- a/src/wayland/compositor/handlers.rs +++ b/src/wayland/compositor/handlers.rs @@ -4,7 +4,7 @@ use std::sync::{ }; use wayland_server::{ - DataInit, Dispatch, DisplayHandle, New, Resource, WEnum, + DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, protocol::{ wl_callback::{self, WlCallback}, wl_compositor::{self, WlCompositor}, @@ -20,7 +20,7 @@ use crate::utils::{ alive_tracker::{AliveTracker, IsAlive}, }; -use crate::wayland::{Dispatch2, GlobalData, GlobalDispatch2}; +use crate::wayland::GlobalData; use super::{ AlreadyHasRole, BufferAssignment, CompositorHandler, Damage, Rectangle, RectangleKind, RegionAttributes, @@ -35,11 +35,8 @@ use tracing::trace; * wl_compositor */ -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, - D: Dispatch, - D: Dispatch, D: CompositorHandler, D: 'static, { @@ -55,10 +52,8 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, - D: Dispatch, D: CompositorHandler, D: 'static, { @@ -156,9 +151,8 @@ pub struct SurfaceUserData { pub(super) user_state_type: (std::any::TypeId, &'static str), } -impl Dispatch2 for SurfaceUserData +impl Dispatch for SurfaceUserData where - D: Dispatch, D: CompositorHandler, D: 'static, { @@ -278,15 +272,13 @@ where PrivateSurfaceData::commit(surface, handle, state); } wl_surface::Request::SetBufferTransform { transform } => { - if let WEnum::Value(transform) = transform { - PrivateSurfaceData::with_states(surface, |states| { - states - .cached_state - .get::() - .pending() - .buffer_transform = transform; - }); - } + PrivateSurfaceData::with_states(surface, |states| { + states + .cached_state + .get::() + .pending() + .buffer_transform = transform; + }); } wl_surface::Request::SetBufferScale { scale } => { if scale >= 1 { @@ -340,7 +332,7 @@ where } } - fn destroyed(&self, state: &mut D, _client_id: wayland_server::backend::ClientId, surface: &WlSurface) { + fn destroyed(&self, state: &mut D, _client_id: &wayland_server::backend::ClientId, surface: &WlSurface) { // We let the destruction hooks run first and then tell the compositor handler the surface was // destroyed. self.alive_tracker.destroy_notify(); @@ -373,7 +365,7 @@ pub struct RegionUserData { pub(crate) inner: Mutex, } -impl Dispatch2 for RegionUserData +impl Dispatch for RegionUserData where D: CompositorHandler, { @@ -416,10 +408,8 @@ where * wl_subcompositor */ -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, - D: Dispatch, D: CompositorHandler, D: 'static, { @@ -435,9 +425,8 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, D: CompositorHandler, D: 'static, { @@ -552,7 +541,7 @@ pub fn is_effectively_sync(surface: &wl_surface::WlSurface) -> bool { } } -impl Dispatch2 for SubsurfaceUserData +impl Dispatch for SubsurfaceUserData where D: CompositorHandler, D: 'static, @@ -622,7 +611,7 @@ where fn destroyed( &self, _state: &mut D, - _client_id: wayland_server::backend::ClientId, + _client_id: &wayland_server::backend::ClientId, _object: &WlSubsurface, ) { PrivateSurfaceData::unset_parent(&self.surface); @@ -641,7 +630,7 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where D: CompositorHandler, D: 'static, diff --git a/src/wayland/compositor/mod.rs b/src/wayland/compositor/mod.rs index 81bac6db544e..b534279b24d2 100644 --- a/src/wayland/compositor/mod.rs +++ b/src/wayland/compositor/mod.rs @@ -60,8 +60,6 @@ //! } //! } //! -//! smithay::delegate_dispatch2!(State); -//! //! // You're now ready to go! //! ``` //! @@ -131,7 +129,7 @@ use wayland_server::backend::GlobalId; use wayland_server::protocol::wl_compositor::WlCompositor; use wayland_server::protocol::wl_subcompositor::WlSubcompositor; use wayland_server::protocol::{wl_buffer, wl_callback, wl_output, wl_region, wl_surface::WlSurface}; -use wayland_server::{Client, DisplayHandle, GlobalDispatch, Resource}; +use wayland_server::{Client, DisplayHandle, Resource}; /// The role of a subsurface surface. pub const SUBSURFACE_ROLE: &str = "subsurface"; @@ -695,7 +693,7 @@ impl CompositorState { /// [`wl_subcompositor`]: wayland_server::protocol::wl_subcompositor pub fn new(display: &DisplayHandle) -> Self where - D: GlobalDispatch + GlobalDispatch + 'static, + D: CompositorHandler + 'static, { Self::new_with_version::(display, 5) } @@ -709,14 +707,14 @@ impl CompositorState { /// [`wl_compositor`]: wayland_server::protocol::wl_compositor pub fn new_v6(display: &DisplayHandle) -> Self where - D: GlobalDispatch + GlobalDispatch + 'static, + D: CompositorHandler + 'static, { Self::new_with_version::(display, 6) } fn new_with_version(display: &DisplayHandle, version: u32) -> Self where - D: GlobalDispatch + GlobalDispatch + 'static, + D: CompositorHandler + 'static, { let compositor = display.create_global::(version, GlobalData); let subcompositor = display.create_global::(1, GlobalData); diff --git a/src/wayland/content_type/dispatch.rs b/src/wayland/content_type/dispatch.rs index 7ffacef8e995..2921b033d53d 100644 --- a/src/wayland/content_type/dispatch.rs +++ b/src/wayland/content_type/dispatch.rs @@ -2,14 +2,15 @@ use wayland_protocols::wp::content_type::v1::server::{ wp_content_type_manager_v1::{self, WpContentTypeManagerV1}, wp_content_type_v1::{self, WpContentTypeV1}, }; -use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, New, Resource, backend::ClientId}; +use wayland_server::{ + Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, backend::ClientId, +}; use super::{ContentTypeSurfaceCachedState, ContentTypeSurfaceData, ContentTypeUserData}; -use crate::wayland::{Dispatch2, GlobalData, GlobalDispatch2, compositor}; +use crate::wayland::{GlobalData, compositor}; -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, D: 'static, { fn bind( @@ -24,9 +25,8 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, D: 'static, { fn request( @@ -71,7 +71,7 @@ where } } -impl Dispatch2 for ContentTypeUserData { +impl Dispatch for ContentTypeUserData { fn request( &self, _state: &mut D, @@ -83,9 +83,6 @@ impl Dispatch2 for ContentTypeUserData { ) { match request { wp_content_type_v1::Request::SetContentType { content_type } => { - let wayland_server::WEnum::Value(content_type) = content_type else { - return; - }; let Some(surface) = self.wl_surface() else { return; }; @@ -124,7 +121,7 @@ impl Dispatch2 for ContentTypeUserData { } } - fn destroyed(&self, _state: &mut D, _client: ClientId, _object: &WpContentTypeV1) { + fn destroyed(&self, _state: &mut D, _client: &ClientId, _object: &WpContentTypeV1) { // Nothing to do here, graceful Destroy is already handled with double buffering // and in case of client close WlSurface destroyed handler will clean up the data anyway, // so there is no point in queuing new update diff --git a/src/wayland/content_type/mod.rs b/src/wayland/content_type/mod.rs index da99a7ad68a5..44556d9da707 100644 --- a/src/wayland/content_type/mod.rs +++ b/src/wayland/content_type/mod.rs @@ -17,8 +17,6 @@ //! struct ClientState { compositor_state: CompositorClientState } //! impl wayland_server::backend::ClientData for ClientState {} //! -//! smithay::delegate_dispatch2!(State); -//! //! impl CompositorHandler for State { //! fn compositor_state(&mut self) -> &mut CompositorState { //! &mut self.compositor_state @@ -55,9 +53,7 @@ use std::sync::{ use wayland_protocols::wp::content_type::v1::server::{ wp_content_type_manager_v1::WpContentTypeManagerV1, wp_content_type_v1, }; -use wayland_server::{ - DisplayHandle, GlobalDispatch, Resource, Weak, backend::GlobalId, protocol::wl_surface::WlSurface, -}; +use wayland_server::{DisplayHandle, Resource, Weak, backend::GlobalId, protocol::wl_surface::WlSurface}; use super::compositor::Cacheable; @@ -156,7 +152,7 @@ impl ContentTypeState { /// Regiseter new [WpContentTypeManagerV1] global pub fn new(display: &DisplayHandle) -> ContentTypeState where - D: GlobalDispatch + 'static, + D: 'static, { let global = display.create_global::(1, GlobalData); diff --git a/src/wayland/cursor_shape.rs b/src/wayland/cursor_shape.rs index 11132f581670..183e5f94d23b 100644 --- a/src/wayland/cursor_shape.rs +++ b/src/wayland/cursor_shape.rs @@ -106,8 +106,6 @@ //! # } //! //! let state = CursorShapeManagerState::new::(&display.handle()); -//! -//! smithay::delegate_dispatch2!(State); //! ``` use wayland_protocols::wp::cursor_shape::v1::server::wp_cursor_shape_device_v1::Request as ShapeRequest; @@ -116,21 +114,19 @@ use wayland_protocols::wp::cursor_shape::v1::server::wp_cursor_shape_device_v1:: use wayland_protocols::wp::cursor_shape::v1::server::wp_cursor_shape_manager_v1::Request as ManagerRequest; use wayland_protocols::wp::cursor_shape::v1::server::wp_cursor_shape_manager_v1::WpCursorShapeManagerV1 as CursorShapeManager; use wayland_protocols::wp::tablet::zv2::server::zwp_tablet_tool_v2::ZwpTabletToolV2; -use wayland_server::GlobalDispatch; use wayland_server::Resource; -use wayland_server::WEnum; use wayland_server::Weak; -use wayland_server::{Dispatch, DisplayHandle, backend::GlobalId}; +use wayland_server::{Dispatch, DisplayHandle, GlobalDispatch, backend::GlobalId}; use crate::input::SeatHandler; use crate::input::WeakSeat; use crate::input::pointer::{CursorIcon, CursorImageStatus}; use crate::input::tablet::TabletSeatHandler; use crate::utils::Serial; +use crate::wayland::GlobalData; use crate::wayland::seat::{WaylandFocus, pointer::allow_setting_cursor}; use crate::wayland::tablet_manager::TabletToolUserData; use crate::wayland::tablet_manager::tablet_tool; -use crate::wayland::{Dispatch2, GlobalData, GlobalDispatch2}; use super::seat::PointerUserData; @@ -144,9 +140,9 @@ impl CursorShapeManagerState { /// Register new [CursorShapeManager] global. pub fn new(display: &DisplayHandle) -> Self where - D: GlobalDispatch, - D: Dispatch, - D: SeatHandler, + D: TabletSeatHandler, + ::PointerFocus: WaylandFocus, + ::ToolFocus: WaylandFocus, D: 'static, { let global = display.create_global::(2, GlobalData); @@ -159,10 +155,11 @@ impl CursorShapeManagerState { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, - D: SeatHandler, + D: TabletSeatHandler, + ::PointerFocus: WaylandFocus, + ::ToolFocus: WaylandFocus, D: 'static, { fn bind( @@ -177,10 +174,11 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch>, - D: SeatHandler, + D: TabletSeatHandler, + ::PointerFocus: WaylandFocus, + ::ToolFocus: WaylandFocus, D: 'static, { fn request( @@ -249,7 +247,7 @@ pub(crate) enum CursorShapeDeviceUserDataInner { Tablet(Weak), } -impl Dispatch2 for CursorShapeDeviceUserData +impl Dispatch for CursorShapeDeviceUserData where D: SeatHandler + TabletSeatHandler, ::PointerFocus: WaylandFocus, @@ -266,10 +264,7 @@ where _data_init: &mut wayland_server::DataInit<'_, D>, ) { match request { - ShapeRequest::SetShape { - serial, - shape: WEnum::Value(shape), - } => { + ShapeRequest::SetShape { serial, shape } => { match &self.0 { CursorShapeDeviceUserDataInner::Pointer { seat } => { let Some(seat) = seat.upgrade() else { @@ -313,9 +308,6 @@ where } } } - ShapeRequest::SetShape { .. } => { - // Ignore unknown shapes. - } ShapeRequest::Destroy => {} _ => unreachable!(), } diff --git a/src/wayland/dispatch2.rs b/src/wayland/dispatch2.rs deleted file mode 100644 index be4bc7060b17..000000000000 --- a/src/wayland/dispatch2.rs +++ /dev/null @@ -1,91 +0,0 @@ -use wayland_server::{Client, DataInit, DisplayHandle, New, Resource, backend::ClientId}; - -/// A simplified version of [`wayland_server::Dispatch`] -/// -/// A future version of `wayland-server` will replace `Dispatch` with this. -pub trait Dispatch2 { - /// Called when a request from a client is processed. - fn request( - &self, - state: &mut State, - client: &Client, - resource: &I, - request: I::Request, - dhandle: &DisplayHandle, - data_init: &mut DataInit<'_, State>, - ); - - /// Called when the object this user data is associated with has been destroyed. - fn destroyed(&self, _state: &mut State, _client: ClientId, _resource: &I) {} -} - -/// A simplified version of [`wayland_server::GlobalDispatch`] -/// -/// A future version of `wayland-server` will replace `GlobalDispatch` with this. -pub trait GlobalDispatch2 { - /// Called when a client has bound this global. - fn bind( - &self, - state: &mut State, - handle: &DisplayHandle, - client: &Client, - resource: New, - data_init: &mut DataInit<'_, State>, - ); - - /// Checks if the global should be advertised to some client. - fn can_view(&self, _client: &Client) -> bool { - true - } -} - -/// Implement `Dispatch` and `GlobalDispatch` for every implementation of [`Dispatch2`] and -/// [`GlobalDispatch2`]. -#[macro_export] -macro_rules! delegate_dispatch2 { - ($(@< $( $lt:tt $( : $clt:tt $(+ $dlt:tt )* )? ),+ >)? $ty:ty) => { - impl<$( $( $lt $( : $clt $(+ $dlt )* )? ),+, )? I, UserData> $crate::reexports::wayland_server::Dispatch for $ty - where - I: $crate::reexports::wayland_server::Resource, - UserData: $crate::wayland::Dispatch2 { - fn request( - state: &mut Self, - client: &$crate::reexports::wayland_server::Client, - resource: &I, - request: ::Request, - data: &UserData, - dhandle: &$crate::reexports::wayland_server::DisplayHandle, - data_init: &mut $crate::reexports::wayland_server::DataInit<'_, Self>, - ) { - data.request(state, client, resource, request, dhandle, data_init); - } - - fn destroyed(state: &mut Self, client: $crate::reexports::wayland_server::backend::ClientId, resource: &I, data: &UserData) { - data.destroyed(state, client, resource); - } - } - - impl<$( $( $lt $( : $clt $(+ $dlt )* )? ),+, )? I, UserData> $crate::reexports::wayland_server::GlobalDispatch for $ty - where - I: $crate::reexports::wayland_server::Resource, - UserData: $crate::wayland::GlobalDispatch2 { - fn bind( - state: &mut Self, - dhandle: &$crate::reexports::wayland_server::DisplayHandle, - client: &$crate::reexports::wayland_server::Client, - resource: $crate::reexports::wayland_server::New, - data: &UserData, - data_init: &mut $crate::reexports::wayland_server::DataInit<'_, Self>, - ) { - data.bind(state, dhandle, client, resource, data_init); - } - - fn can_view( - client: $crate::reexports::wayland_server::Client, - data: &UserData - ) -> bool { - data.can_view(&client) - } - } - }; -} diff --git a/src/wayland/dmabuf/dispatch.rs b/src/wayland/dmabuf/dispatch.rs index 400d659de7a6..ee77c1a3069b 100644 --- a/src/wayland/dmabuf/dispatch.rs +++ b/src/wayland/dmabuf/dispatch.rs @@ -5,15 +5,13 @@ use wayland_protocols::wp::linux_dmabuf::zv1::server::{ zwp_linux_buffer_params_v1, zwp_linux_dmabuf_feedback_v1, zwp_linux_dmabuf_v1, }; use wayland_server::{ - Client, DataInit, Dispatch, DisplayHandle, New, Resource, backend::ClientId, protocol::wl_buffer, + Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, backend::ClientId, + protocol::wl_buffer, }; use crate::{ backend::allocator::dmabuf::{Dmabuf, MAX_PLANES, Plane}, - wayland::{ - Dispatch2, GlobalDispatch2, buffer::BufferHandler, compositor, - dmabuf::SurfaceDmabufFeedbackStateInner, - }, + wayland::{buffer::BufferHandler, compositor, dmabuf::SurfaceDmabufFeedbackStateInner}, }; use super::{ @@ -21,7 +19,7 @@ use super::{ ImportNotifier, Modifier, SurfaceDmabufFeedbackState, }; -impl Dispatch2 for Dmabuf +impl Dispatch for Dmabuf where D: BufferHandler, { @@ -43,17 +41,14 @@ where } } - fn destroyed(&self, data: &mut D, _client: ClientId, buffer: &wl_buffer::WlBuffer) { + fn destroyed(&self, data: &mut D, _client: &ClientId, buffer: &wl_buffer::WlBuffer) { data.buffer_destroyed(buffer); } } -impl Dispatch2 for DmabufData +impl Dispatch for DmabufData where - D: Dispatch - + Dispatch - + DmabufHandler - + 'static, + D: DmabufHandler + 'static, { fn request( &self, @@ -143,7 +138,7 @@ where } } -impl Dispatch2 for DmabufFeedbackData { +impl Dispatch for DmabufFeedbackData { fn request( &self, _state: &mut D, @@ -173,9 +168,9 @@ impl Dispatch2 for } } -impl GlobalDispatch2 for DmabufGlobalData +impl GlobalDispatch for DmabufGlobalData where - D: Dispatch + 'static, + D: DmabufHandler + 'static, { fn bind( &self, @@ -221,9 +216,9 @@ where } } -impl Dispatch2 for DmabufParamsData +impl Dispatch for DmabufParamsData where - D: Dispatch + BufferHandler + DmabufHandler, + D: DmabufHandler, { fn request( &self, diff --git a/src/wayland/dmabuf/mod.rs b/src/wayland/dmabuf/mod.rs index edd3b83eea4d..b9a6af426db8 100644 --- a/src/wayland/dmabuf/mod.rs +++ b/src/wayland/dmabuf/mod.rs @@ -72,8 +72,6 @@ //! } //! } //! -//! smithay::delegate_dispatch2!(State); -//! //! # let mut display = wayland_server::Display::::new().unwrap(); //! # let display_handle = display.handle(); //! // First a DmabufState must be created. This type is used to create some "DmabufGlobal"s @@ -178,8 +176,6 @@ //! dmabuf_global, //! }; //! -//! smithay::delegate_dispatch2!(State); -//! //! // Rest of the compositor goes here... //! ``` @@ -203,7 +199,7 @@ use wayland_protocols::wp::linux_dmabuf::zv1::server::{ zwp_linux_dmabuf_v1, }; use wayland_server::{ - Client, Dispatch, DisplayHandle, GlobalDispatch, Resource, WEnum, + Client, DisplayHandle, Resource, backend::{GlobalId, InvalidId}, protocol::{ wl_buffer::{self, WlBuffer}, @@ -453,7 +449,7 @@ impl DmabufFeedback { /// Send this feedback to the provided [`ZwpLinuxDmabufFeedbackV1`](zwp_linux_dmabuf_feedback_v1::ZwpLinuxDmabufFeedbackV1) pub fn send(&self, feedback: &zwp_linux_dmabuf_feedback_v1::ZwpLinuxDmabufFeedbackV1) { if feedback.version() <= 5 { - feedback.main_device(self.0.main_device.to_ne_bytes().to_vec()); + feedback.main_device(&self.0.main_device.to_ne_bytes()); } feedback.format_table( self.0.format_table.file.as_fd(), @@ -466,14 +462,14 @@ impl DmabufFeedback { .iter() .filter(|tranche| tranche.version_range.contains(&feedback.version())) { - feedback.tranche_target_device(tranche.target_device.to_ne_bytes().to_vec()); + feedback.tranche_target_device(&tranche.target_device.to_ne_bytes()); let mut flags = tranche.flags; if feedback.version() <= 5 { flags.remove(TrancheFlags::Sampling); } feedback.tranche_flags(flags); feedback.tranche_formats( - tranche + &tranche .indices .iter() .flat_map(|i| (*i as u16).to_ne_bytes()) @@ -597,10 +593,7 @@ impl DmabufState { formats: impl IntoIterator, ) -> DmabufGlobal where - D: GlobalDispatch - + BufferHandler - + DmabufHandler - + 'static, + D: BufferHandler + DmabufHandler + 'static, { self.create_global_with_filter::(display, formats, |_| true) } @@ -620,10 +613,7 @@ impl DmabufState { filter: F, ) -> DmabufGlobal where - D: GlobalDispatch - + BufferHandler - + DmabufHandler - + 'static, + D: DmabufHandler + 'static, F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, { let formats = formats.into_iter().collect::>(); @@ -644,10 +634,7 @@ impl DmabufState { default_feedback: &DmabufFeedback, ) -> DmabufGlobal where - D: GlobalDispatch - + BufferHandler - + DmabufHandler - + 'static, + D: DmabufHandler + 'static, { self.create_global_with_filter_and_default_feedback::(display, default_feedback, |_| true) } @@ -666,10 +653,7 @@ impl DmabufState { filter: F, ) -> DmabufGlobal where - D: GlobalDispatch - + BufferHandler - + DmabufHandler - + 'static, + D: DmabufHandler + 'static, F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, { self.create_global_with_filter_and_optional_default_feedback::( @@ -688,10 +672,7 @@ impl DmabufState { filter: F, ) -> DmabufGlobal where - D: GlobalDispatch - + BufferHandler - + DmabufHandler - + 'static, + D: DmabufHandler + 'static, F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, { let id = global_id::next(); @@ -771,7 +752,7 @@ impl DmabufState { /// This operation is permanent and there is no way to re-enable a global. pub fn disable_global(&mut self, display: &DisplayHandle, global: &DmabufGlobal) { if let Some(global_state) = self.globals.get(&global.id) { - display.disable_global::(global_state.id.clone()); + display.disable_global::(&global_state.id); } } @@ -782,7 +763,7 @@ impl DmabufState { pub fn destroy_global(&mut self, display: &DisplayHandle, global: DmabufGlobal) { if global_id::remove(global.id) { if let Some(global_state) = self.globals.remove(&global.id) { - display.remove_global::(global_state.id); + display.remove_global::(&global_state.id); } } } @@ -878,11 +859,7 @@ impl ImportNotifier { /// This can return [`InvalidId`] if the client the buffer was imported from has died. pub fn successful(mut self) -> Result where - D: Dispatch - + Dispatch - + BufferHandler - + DmabufHandler - + 'static, + D: BufferHandler + DmabufHandler + 'static, { let client = self.inner.client(); @@ -1055,7 +1032,7 @@ impl DmabufParamsData { width: i32, height: i32, format: u32, - flags: WEnum, + flags: zwp_linux_buffer_params_v1::Flags, _node: Option, ) -> Option { // We cannot create a dmabuf if the parameters have already been used. diff --git a/src/wayland/drm_lease/mod.rs b/src/wayland/drm_lease/mod.rs index 0fd220a6d5c7..edb36210c546 100644 --- a/src/wayland/drm_lease/mod.rs +++ b/src/wayland/drm_lease/mod.rs @@ -49,8 +49,6 @@ //! fn lease_destroyed(&mut self, node: DrmNode, lease_id: u32) { self.active_leases.retain(|l| l.id() != lease_id); } //! } //! -//! smithay::delegate_dispatch2!(State); -//! //! # let mut display = wayland_server::Display::::new().unwrap(); //! # let display_handle = display.handle(); //! # let drm_device: DrmDevice = todo!(); @@ -91,10 +89,7 @@ use wayland_protocols::wp::drm_lease::v1::server::*; use wayland_server::backend::GlobalId; use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource}; -use crate::{ - backend::drm::{DrmDevice, DrmDeviceFd, DrmNode, NodeType, PlaneClaim}, - wayland::{Dispatch2, GlobalDispatch2}, -}; +use crate::backend::drm::{DrmDevice, DrmDeviceFd, DrmNode, NodeType, PlaneClaim}; /// Delegate type for a drm_lease global #[derive(Debug)] @@ -385,9 +380,7 @@ impl DrmLeaseState { /// Create a new DRM lease global for a given [`DrmNode`]. pub fn new(display: &DisplayHandle, drm_node: &DrmNode) -> Result where - D: DrmLeaseHandler - + GlobalDispatch - + 'static, + D: DrmLeaseHandler + 'static, { Self::new_with_filter::(display, drm_node, |_| true) } @@ -401,9 +394,7 @@ impl DrmLeaseState { filter: F, ) -> Result where - D: DrmLeaseHandler - + GlobalDispatch - + 'static, + D: DrmLeaseHandler + 'static, F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, { let path = drm_node @@ -434,9 +425,7 @@ impl DrmLeaseState { /// Add a connector, that is free to be leased to clients. pub fn add_connector(&mut self, connector: connector::Handle, name: String, description: String) where - D: DrmLeaseHandler - + Dispatch - + 'static, + D: DrmLeaseHandler + 'static, { if self.connectors.iter().any(|conn| conn.handle == connector) { return; @@ -481,7 +470,7 @@ impl DrmLeaseState { for instance in &lease_connector.known_instances { instance.withdrawn(); if let Some(client) = instance.client() { - clients.insert(client.id()); + clients.insert(client.id().clone()); } } } @@ -513,7 +502,7 @@ impl DrmLeaseState { for instance in connector.known_instances.drain(..) { instance.withdrawn(); if let Some(client) = instance.client() { - clients.insert(client.id()); + clients.insert(client.id().clone()); } } connector.enabled = false; @@ -532,18 +521,14 @@ impl DrmLeaseState { /// Resume all connectors temporarily (e.g. upon gaining DRM master as the session becomes active) pub fn resume(&mut self) where - D: DrmLeaseHandler - + Dispatch - + 'static, + D: DrmLeaseHandler + 'static, { self.resume_internal::(None); } fn resume_internal(&mut self, connectors: Option<&HashSet>) where - D: DrmLeaseHandler - + Dispatch - + 'static, + D: DrmLeaseHandler + 'static, { for (instance, client) in self .known_lease_devices @@ -577,9 +562,7 @@ impl DrmLeaseState { fn remove_lease(&mut self, id: u32) -> Option where - D: DrmLeaseHandler - + Dispatch - + 'static, + D: DrmLeaseHandler + 'static, { let lease_ref = { { @@ -607,7 +590,7 @@ impl DrmLeaseState { D: DrmLeaseHandler + 'static, { if let Some(global) = self.global.take() { - self.dh.disable_global::(global); + self.dh.disable_global::(&global); } } } @@ -638,9 +621,7 @@ impl DrmLeaseConnector { client: &Client, ) -> Option where - D: DrmLeaseHandler - + Dispatch - + 'static, + D: DrmLeaseHandler + 'static, { if let Ok(lease_connector) = client .create_resource::( @@ -665,12 +646,9 @@ impl DrmLeaseConnector { } } -impl GlobalDispatch2 for DrmLeaseDeviceGlobalData +impl GlobalDispatch for DrmLeaseDeviceGlobalData where - D: DrmLeaseHandler - + Dispatch - + Dispatch - + 'static, + D: DrmLeaseHandler + 'static, { fn bind( &self, @@ -712,11 +690,9 @@ pub struct DrmLeaseDeviceData { node: DrmNode, } -impl Dispatch2 for DrmLeaseDeviceData +impl Dispatch for DrmLeaseDeviceData where - D: DrmLeaseHandler - + Dispatch - + 'static, + D: DrmLeaseHandler + 'static, { fn request( &self, @@ -755,7 +731,7 @@ pub struct DrmLeaseConnectorData { node: DrmNode, } -impl Dispatch2 for DrmLeaseConnectorData +impl Dispatch for DrmLeaseConnectorData where D: DrmLeaseHandler + 'static, { @@ -773,7 +749,7 @@ where fn destroyed( &self, state: &mut D, - _client: wayland_server::backend::ClientId, + _client: &wayland_server::backend::ClientId, resource: &wp_drm_lease_connector_v1::WpDrmLeaseConnectorV1, ) { let drm_lease_state = state.drm_lease_state(self.node); @@ -783,9 +759,9 @@ where } } -impl Dispatch2 for DrmLeaseRequestData +impl Dispatch for DrmLeaseRequestData where - D: DrmLeaseHandler + Dispatch + 'static, + D: DrmLeaseHandler + 'static, { fn request( &self, @@ -898,11 +874,9 @@ where } } -impl Dispatch2 for DrmLeaseData +impl Dispatch for DrmLeaseData where - D: DrmLeaseHandler - + Dispatch - + 'static, + D: DrmLeaseHandler + 'static, { fn request( &self, @@ -918,7 +892,7 @@ where fn destroyed( &self, state: &mut D, - _client: wayland_server::backend::ClientId, + _client: &wayland_server::backend::ClientId, _resource: &wp_drm_lease_v1::WpDrmLeaseV1, ) { let drm_lease_state = state.drm_lease_state(self.node); diff --git a/src/wayland/drm_syncobj/mod.rs b/src/wayland/drm_syncobj/mod.rs index 7340c18e9d0e..0b6d87b8d39e 100644 --- a/src/wayland/drm_syncobj/mod.rs +++ b/src/wayland/drm_syncobj/mod.rs @@ -34,8 +34,6 @@ //! } else { //! None //! }; -//! -//! smithay::delegate_dispatch2!(State); //! ``` use std::{ @@ -58,10 +56,7 @@ use super::{ compositor::{self, BufferAssignment, Cacheable, HookId, SurfaceAttributes, with_states}, dmabuf::get_dmabuf, }; -use crate::{ - backend::drm::DrmDeviceFd, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, -}; +use crate::{backend::drm::DrmDeviceFd, wayland::GlobalData}; mod sync_point; pub use sync_point::*; @@ -133,8 +128,7 @@ impl DrmSyncobjState { /// The `import_device` will be used to import the syncobj fds, and wait on them. pub fn new(display: &DisplayHandle, import_device: DrmDeviceFd) -> Self where - D: GlobalDispatch, - D: 'static, + D: DrmSyncobjHandler + 'static, { Self::new_with_filter::(display, import_device, |_| true) } @@ -144,8 +138,7 @@ impl DrmSyncobjState { /// The `import_device` will be used to import the syncobj fds, and wait on them. pub fn new_with_filter(display: &DisplayHandle, import_device: DrmDeviceFd, filter: F) -> Self where - D: GlobalDispatch, - D: 'static, + D: DrmSyncobjHandler + 'static, F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, { let global = display.create_global::( @@ -204,9 +197,9 @@ impl<'a> CloseGuard<'a> { } } -impl GlobalDispatch2 for DrmSyncobjGlobalData +impl GlobalDispatch for DrmSyncobjGlobalData where - D: Dispatch, + D: DrmSyncobjHandler, { fn bind( &self, @@ -296,10 +289,8 @@ fn destruction_hook(_data: &mut D, surface: &WlSurface) { }); } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, - D: Dispatch, D: DrmSyncobjHandler, { fn request( @@ -385,7 +376,7 @@ pub struct DrmSyncobjSurfaceData { destruction_hook_id: HookId, } -impl Dispatch2 for DrmSyncobjSurfaceData +impl Dispatch for DrmSyncobjSurfaceData where D: DrmSyncobjHandler, { @@ -486,7 +477,7 @@ pub struct DrmSyncobjTimelineData { timeline: DrmTimeline, } -impl Dispatch2 for DrmSyncobjTimelineData { +impl Dispatch for DrmSyncobjTimelineData { fn request( &self, _state: &mut D, @@ -505,7 +496,7 @@ impl Dispatch2 for DrmSync fn destroyed( &self, state: &mut D, - _client: wayland_server::backend::ClientId, + _client: &wayland_server::backend::ClientId, _resource: &WpLinuxDrmSyncobjTimelineV1, ) { if let Some(state) = state.drm_syncobj_state() { diff --git a/src/wayland/fifo/mod.rs b/src/wayland/fifo/mod.rs index 9e6b7ef48c61..484301e509bc 100644 --- a/src/wayland/fifo/mod.rs +++ b/src/wayland/fifo/mod.rs @@ -20,8 +20,6 @@ //! // insert the FifoManagerState into your state //! // .. //! -//! smithay::delegate_dispatch2!(State); -//! //! // You're now ready to go! //! ``` //! @@ -89,10 +87,7 @@ use wayland_server::{ protocol::wl_surface::WlSurface, }; -use crate::wayland::{ - Dispatch2, GlobalDispatch2, - compositor::{add_blocker, add_pre_commit_hook}, -}; +use crate::wayland::compositor::{add_blocker, add_pre_commit_hook}; use super::compositor::{Barrier, Cacheable, is_sync_subsurface, with_states}; @@ -110,8 +105,6 @@ impl FifoManagerState { /// remove or disable this global in the future. pub fn new(display: &DisplayHandle) -> Self where - D: GlobalDispatch, - D: Dispatch, D: 'static, { Self::new_internal::(display, true) @@ -123,8 +116,6 @@ impl FifoManagerState { /// remove or disable this global in the future. pub fn unmanaged(display: &DisplayHandle) -> Self where - D: GlobalDispatch, - D: Dispatch, D: 'static, { Self::new_internal::(display, false) @@ -132,7 +123,6 @@ impl FifoManagerState { fn new_internal(display: &DisplayHandle, is_managed: bool) -> Self where - D: GlobalDispatch, D: 'static, { let global = display.create_global::(1, FifoManagerData { is_managed }); @@ -157,9 +147,8 @@ pub struct FifoManagerData { is_managed: bool, } -impl GlobalDispatch2 for FifoManagerData +impl GlobalDispatch for FifoManagerData where - D: Dispatch, D: 'static, { fn bind( @@ -174,9 +163,8 @@ where } } -impl Dispatch2 for FifoManagerData +impl Dispatch for FifoManagerData where - D: Dispatch, D: 'static, { fn request( @@ -286,7 +274,7 @@ struct FifoMarker(Option); #[derive(Debug)] pub struct FifoData(Weak); -impl Dispatch2 for FifoData +impl Dispatch for FifoData where D: 'static, { diff --git a/src/wayland/fixes.rs b/src/wayland/fixes.rs index c1e7b819697d..bd29564f5aa2 100644 --- a/src/wayland/fixes.rs +++ b/src/wayland/fixes.rs @@ -6,7 +6,7 @@ use wayland_server::{ protocol::wl_fixes, }; -use crate::wayland::{Dispatch2, GlobalData, GlobalDispatch2}; +use crate::wayland::GlobalData; /// Delegate type for handling wl fixes requests. #[derive(Debug, Clone)] @@ -18,8 +18,6 @@ impl FixesState { /// Creates a new delegate type for handling [`wl_fixes::WlFixes`] events. pub fn new(display: &DisplayHandle) -> Self where - D: GlobalDispatch, - D: Dispatch, D: 'static, { let global = display.create_global::(1, GlobalData); @@ -32,9 +30,8 @@ impl FixesState { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, D: 'static, { fn bind( @@ -49,7 +46,7 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where D: 'static, { diff --git a/src/wayland/foreign_toplevel_list/mod.rs b/src/wayland/foreign_toplevel_list/mod.rs index 90d1739283d0..f94489891ea6 100644 --- a/src/wayland/foreign_toplevel_list/mod.rs +++ b/src/wayland/foreign_toplevel_list/mod.rs @@ -9,8 +9,6 @@ //! foreign_toplevel_list: ForeignToplevelListState, //! } //! -//! smithay::delegate_dispatch2!(State); -//! //! impl ForeignToplevelListHandler for State { //! fn foreign_toplevel_list_state(&mut self) -> &mut ForeignToplevelListState { //! &mut self.foreign_toplevel_list @@ -46,10 +44,7 @@ use wayland_server::{ backend::{ClientId, GlobalId}, }; -use crate::{ - utils::user_data::UserDataMap, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, -}; +use crate::{utils::user_data::UserDataMap, wayland::GlobalData}; /// Handler for foreign toplevel list protocol pub trait ForeignToplevelListHandler: 'static { @@ -297,8 +292,7 @@ impl ForeignToplevelListState { /// Register new [ExtForeignToplevelListV1] global pub fn new(dh: &DisplayHandle) -> Self where - D: ForeignToplevelListHandler - + GlobalDispatch, + D: ForeignToplevelListHandler, { Self::new_with_filter::(dh, |_| true) } @@ -309,8 +303,7 @@ impl ForeignToplevelListState { can_view: impl Fn(&Client) -> bool + Send + Sync + 'static, ) -> Self where - D: ForeignToplevelListHandler - + GlobalDispatch, + D: ForeignToplevelListHandler, { let global = dh.create_global::( 1, @@ -340,7 +333,7 @@ impl ForeignToplevelListState { app_id: impl Into, ) -> ForeignToplevelHandle where - D: ForeignToplevelListHandler + Dispatch, + D: ForeignToplevelListHandler, { self.new_toplevel_with_identifier::( title, @@ -363,7 +356,7 @@ impl ForeignToplevelListState { identifier: impl Into, ) -> ForeignToplevelHandle where - D: ForeignToplevelListHandler + Dispatch, + D: ForeignToplevelListHandler, { let identifier = identifier.into(); assert!( @@ -443,11 +436,10 @@ impl std::fmt::Debug for ForeignToplevelListGlobalData { } } -impl GlobalDispatch2 +impl GlobalDispatch for ForeignToplevelListGlobalData where - D: Dispatch - + Dispatch, + D: ForeignToplevelListHandler, { fn bind( &self, @@ -492,7 +484,7 @@ where } } -impl Dispatch2 for GlobalData { +impl Dispatch for GlobalData { fn request( &self, state: &mut D, @@ -512,7 +504,7 @@ impl Dispatch2 for G } } - fn destroyed(&self, state: &mut D, _client: ClientId, resource: &ExtForeignToplevelListV1) { + fn destroyed(&self, state: &mut D, _client: &ClientId, resource: &ExtForeignToplevelListV1) { state .foreign_toplevel_list_state() .list_instances @@ -520,7 +512,7 @@ impl Dispatch2 for G } } -impl Dispatch2 for ForeignToplevelHandle { +impl Dispatch for ForeignToplevelHandle { fn request( &self, _state: &mut D, @@ -536,7 +528,7 @@ impl Dispatch2 for } } - fn destroyed(&self, _state: &mut D, _client: ClientId, resource: &ExtForeignToplevelHandleV1) { + fn destroyed(&self, _state: &mut D, _client: &ClientId, resource: &ExtForeignToplevelHandleV1) { self.remove_instance(resource); } } diff --git a/src/wayland/fractional_scale/mod.rs b/src/wayland/fractional_scale/mod.rs index 3429bd46c578..1667a8fabad5 100644 --- a/src/wayland/fractional_scale/mod.rs +++ b/src/wayland/fractional_scale/mod.rs @@ -34,8 +34,6 @@ //! } //! } //! -//! smithay::delegate_dispatch2!(State); -//! //! // You're now ready to go! //! ``` //! @@ -71,7 +69,7 @@ use wayland_server::{ use super::compositor::{SurfaceData, with_states}; -use crate::wayland::{Dispatch2, GlobalData, GlobalDispatch2}; +use crate::wayland::GlobalData; /// State of the wp_fractional_scale_manager_v1 Global #[derive(Debug)] @@ -83,11 +81,7 @@ impl FractionalScaleManagerState { /// Create new [`wp_fraction_scale_manager`](wayland_protocols::wp::fractional_scale::v1::server::wp_fractional_scale_manager_v1) global. pub fn new(display: &DisplayHandle) -> FractionalScaleManagerState where - D: GlobalDispatch - + Dispatch - + Dispatch - + 'static, - D: FractionalScaleHandler, + D: FractionalScaleHandler + 'static, { FractionalScaleManagerState { global: display @@ -103,10 +97,8 @@ impl FractionalScaleManagerState { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch - + Dispatch, D: FractionalScaleHandler, { fn bind( @@ -121,9 +113,8 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, D: FractionalScaleHandler, { fn request( @@ -179,7 +170,7 @@ where #[derive(Debug)] pub struct FractionalScaleData(Weak); -impl Dispatch2 for FractionalScaleData +impl Dispatch for FractionalScaleData where D: FractionalScaleHandler, { diff --git a/src/wayland/idle_inhibit/inhibitor.rs b/src/wayland/idle_inhibit/inhibitor.rs index 9b5705a82c14..1049cc7fddd5 100644 --- a/src/wayland/idle_inhibit/inhibitor.rs +++ b/src/wayland/idle_inhibit/inhibitor.rs @@ -3,9 +3,8 @@ use _idle_inhibit::zwp_idle_inhibitor_v1::{Request, ZwpIdleInhibitorV1}; use wayland_protocols::wp::idle_inhibit::zv1::server as _idle_inhibit; use wayland_server::protocol::wl_surface::WlSurface; -use wayland_server::{Client, DataInit, DisplayHandle}; +use wayland_server::{Client, DataInit, Dispatch, DisplayHandle}; -use crate::wayland::Dispatch2; use crate::wayland::idle_inhibit::IdleInhibitHandler; /// State of zwp_idle_inhibitor_v1. @@ -21,7 +20,7 @@ impl IdleInhibitorState { } } -impl Dispatch2 for IdleInhibitorState +impl Dispatch for IdleInhibitorState where D: IdleInhibitHandler, D: 'static, diff --git a/src/wayland/idle_inhibit/mod.rs b/src/wayland/idle_inhibit/mod.rs index 6ea1cb0b9d8a..daa0f1cc5a95 100644 --- a/src/wayland/idle_inhibit/mod.rs +++ b/src/wayland/idle_inhibit/mod.rs @@ -27,20 +27,17 @@ //! } //! } //! -//! smithay::delegate_dispatch2!(State); -//! //! // You're now ready to go! //! ``` use _idle_inhibit::zwp_idle_inhibit_manager_v1::{Request, ZwpIdleInhibitManagerV1}; -use _idle_inhibit::zwp_idle_inhibitor_v1::ZwpIdleInhibitorV1; use wayland_protocols::wp::idle_inhibit::zv1::server as _idle_inhibit; use wayland_server::backend::GlobalId; use wayland_server::protocol::wl_surface::WlSurface; use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New}; +use crate::wayland::GlobalData; use crate::wayland::idle_inhibit::inhibitor::IdleInhibitorState; -use crate::wayland::{Dispatch2, GlobalData, GlobalDispatch2}; pub mod inhibitor; @@ -56,7 +53,6 @@ impl IdleInhibitManagerState { /// Create new [`zwp_idle_inhibit_manager`](ZwpIdleInhibitManagerV1) global. pub fn new(display: &DisplayHandle) -> Self where - D: GlobalDispatch, D: IdleInhibitHandler, D: 'static, { @@ -71,9 +67,8 @@ impl IdleInhibitManagerState { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, D: IdleInhibitHandler, D: 'static, { @@ -89,9 +84,8 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, D: IdleInhibitHandler, D: 'static, { diff --git a/src/wayland/idle_notify/mod.rs b/src/wayland/idle_notify/mod.rs index f15f6b8db16e..c30ec96512f6 100644 --- a/src/wayland/idle_notify/mod.rs +++ b/src/wayland/idle_notify/mod.rs @@ -41,8 +41,6 @@ //! } //! } //! -//! smithay::delegate_dispatch2!(State); -//! //! // On input you should notify the idle_notifier //! // state.idle_notifier.notify_activity(&seat); //! ``` @@ -69,7 +67,7 @@ use wayland_server::{ use crate::{ input::{Seat, SeatHandler}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, + wayland::GlobalData, }; /// Handler trait for ext-idle-notify @@ -121,7 +119,6 @@ impl IdleNotifierState { /// Create new [`ExtIdleNotifierV1`] global. pub fn new(display: &DisplayHandle, loop_handle: LoopHandle<'static, D>) -> Self where - D: GlobalDispatch, D: IdleNotifierHandler, D: 'static, { @@ -244,9 +241,8 @@ impl IdleNotifierState { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, D: IdleNotifierHandler, D: 'static, { @@ -262,9 +258,8 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, D: IdleNotifierHandler, D: 'static, { @@ -334,7 +329,7 @@ where } } -impl Dispatch2 for IdleNotificationUserData +impl Dispatch for IdleNotificationUserData where D: IdleNotifierHandler, { @@ -353,7 +348,7 @@ where } } - fn destroyed(&self, state: &mut D, _client: ClientId, notification: &ExtIdleNotificationV1) { + fn destroyed(&self, state: &mut D, _client: &ClientId, notification: &ExtIdleNotificationV1) { let state = state.idle_notifier_state(); if let Some(notifications) = state.notifications.get_mut(&self.seat) { notifications.retain(|x| x != notification); diff --git a/src/wayland/image_capture_source/mod.rs b/src/wayland/image_capture_source/mod.rs index 099a8ca37ced..6a8c3c59498a 100644 --- a/src/wayland/image_capture_source/mod.rs +++ b/src/wayland/image_capture_source/mod.rs @@ -54,8 +54,6 @@ //! //! let image_capture_source = ImageCaptureSourceState::new(); //! let output_capture_source = OutputCaptureSourceState::new::(&display_handle); -//! -//! smithay::delegate_dispatch2!(State); //! ``` //! //! ### With Toplevel Capture @@ -107,8 +105,6 @@ //! let image_capture_source = ImageCaptureSourceState::new(); //! let output_capture_source = OutputCaptureSourceState::new::(&display_handle); //! let toplevel_capture_source = ToplevelCaptureSourceState::new::(&display_handle); -//! -//! smithay::delegate_dispatch2!(State); //! ``` //! //! ### Custom Capture Sources @@ -143,8 +139,8 @@ use wayland_server::{ use crate::output::Output; use crate::utils::user_data::UserDataMap; +use crate::wayland::GlobalData; use crate::wayland::foreign_toplevel_list::ForeignToplevelHandle; -use crate::wayland::{Dispatch2, GlobalData, GlobalDispatch2}; // ============================================================================ // Core types @@ -294,9 +290,7 @@ impl ImageCaptureSourceState { /// /// This is required by both [`OutputCaptureSourceHandler`] and /// [`ToplevelCaptureSourceHandler`]. -pub trait ImageCaptureSourceHandler: - Dispatch + 'static -{ +pub trait ImageCaptureSourceHandler: 'static { /// Called when a capture source is destroyed. /// /// Use this to clean up any compositor-side state associated with the source. @@ -310,7 +304,7 @@ pub trait ImageCaptureSourceHandler: } // Dispatch for the capture source resource -impl Dispatch2 for ImageCaptureSourceData +impl Dispatch for ImageCaptureSourceData where D: ImageCaptureSourceHandler, { @@ -334,7 +328,7 @@ where fn destroyed( &self, state: &mut D, - _client: wayland_server::backend::ClientId, + _client: &wayland_server::backend::ClientId, _resource: &ExtImageCaptureSourceV1, ) { self.source.mark_destroyed(); @@ -395,11 +389,7 @@ impl OutputCaptureSourceState { /// Handler for output capture sources. /// /// Implement this to enable output capture. Requires [`ImageCaptureSourceHandler`]. -pub trait OutputCaptureSourceHandler: - ImageCaptureSourceHandler - + GlobalDispatch - + Dispatch -{ +pub trait OutputCaptureSourceHandler: ImageCaptureSourceHandler { /// Returns a mutable reference to the [`OutputCaptureSourceState`]. fn output_capture_source_state(&mut self) -> &mut OutputCaptureSourceState; @@ -415,7 +405,7 @@ pub trait OutputCaptureSourceHandler: } } -impl GlobalDispatch2 for OutputCaptureSourceGlobalData +impl GlobalDispatch for OutputCaptureSourceGlobalData where D: OutputCaptureSourceHandler, { @@ -435,7 +425,7 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where D: OutputCaptureSourceHandler, { @@ -533,11 +523,7 @@ impl ToplevelCaptureSourceState { /// /// Compositors with custom foreign-toplevel implementations should NOT use /// this. Instead, handle the protocol directly and use [`ImageCaptureSource::new()`]. -pub trait ToplevelCaptureSourceHandler: - ImageCaptureSourceHandler - + GlobalDispatch - + Dispatch -{ +pub trait ToplevelCaptureSourceHandler: ImageCaptureSourceHandler { /// Returns a mutable reference to the [`ToplevelCaptureSourceState`]. fn toplevel_capture_source_state(&mut self) -> &mut ToplevelCaptureSourceState; @@ -553,7 +539,7 @@ pub trait ToplevelCaptureSourceHandler: } } -impl GlobalDispatch2 for ToplevelCaptureSourceGlobalData +impl GlobalDispatch for ToplevelCaptureSourceGlobalData where D: ToplevelCaptureSourceHandler, { @@ -573,7 +559,7 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where D: ToplevelCaptureSourceHandler, { diff --git a/src/wayland/image_copy_capture/mod.rs b/src/wayland/image_copy_capture/mod.rs index 66dfe8d69141..dc7c2b96b2ea 100644 --- a/src/wayland/image_copy_capture/mod.rs +++ b/src/wayland/image_copy_capture/mod.rs @@ -66,8 +66,6 @@ //! # let mut display = wayland_server::Display::::new().unwrap(); //! # let display_handle = display.handle(); //! let state = ImageCopyCaptureState::new::(&display_handle); -//! -//! smithay::delegate_dispatch2!(State); //! ``` //! //! ## Session Lifecycle @@ -112,10 +110,10 @@ use crate::wayland::image_capture_source::ImageCaptureSource; // Buffer validation imports use crate::backend::renderer::{BufferType, buffer_type}; +use crate::wayland::GlobalData; #[cfg(feature = "backend_drm")] use crate::wayland::dmabuf::get_dmabuf; use crate::wayland::shm::with_buffer_contents; -use crate::wayland::{Dispatch2, GlobalData, GlobalDispatch2}; // Re-export FailureReason for convenience pub use wayland_protocols::ext::image_copy_capture::v1::server::ext_image_copy_capture_frame_v1::FailureReason as CaptureFailureReason; @@ -271,14 +269,14 @@ impl SessionRef { #[cfg(feature = "backend_drm")] if let Some(dma) = constraints.dma.as_ref() { - let node = Vec::from(dma.node.dev_id().to_ne_bytes()); - self.obj.dmabuf_device(node); + let node = dma.node.dev_id().to_ne_bytes(); + self.obj.dmabuf_device(&node); for (fmt, modifiers) in &dma.formats { let modifiers = modifiers .iter() .flat_map(|modifier| u64::from(*modifier).to_ne_bytes()) .collect::>(); - self.obj.dmabuf_format(*fmt as u32, modifiers); + self.obj.dmabuf_format(*fmt as u32, &modifiers); } } @@ -440,14 +438,14 @@ impl CursorSessionRef { } #[cfg(feature = "backend_drm")] if let Some(dma) = constraints.dma.as_ref() { - let node = Vec::from(dma.node.dev_id().to_ne_bytes()); - session_obj.dmabuf_device(node); + let node = dma.node.dev_id().to_ne_bytes(); + session_obj.dmabuf_device(&node); for (fmt, modifiers) in &dma.formats { let modifiers = modifiers .iter() .flat_map(|modifier| u64::from(*modifier).to_ne_bytes()) .collect::>(); - session_obj.dmabuf_format(*fmt as u32, modifiers); + session_obj.dmabuf_format(*fmt as u32, &modifiers); } } session_obj.done(); @@ -769,15 +767,7 @@ impl Drop for Frame { /// Handler trait for the image copy capture protocol. /// /// Implement this on your compositor's state type to handle capture requests. -pub trait ImageCopyCaptureHandler: - GlobalDispatch - + Dispatch - + Dispatch - + Dispatch - + Dispatch - + Dispatch - + 'static -{ +pub trait ImageCopyCaptureHandler: 'static { /// Returns a mutable reference to the [`ImageCopyCaptureState`] delegate type. fn image_copy_capture_state(&mut self) -> &mut ImageCopyCaptureState; @@ -954,7 +944,7 @@ impl ImageCopyCaptureState { // Dispatch implementations // ============================================================================ -impl GlobalDispatch2 for ImageCopyCaptureGlobalData +impl GlobalDispatch for ImageCopyCaptureGlobalData where D: ImageCopyCaptureHandler, { @@ -974,7 +964,7 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where D: ImageCopyCaptureHandler, { @@ -1014,10 +1004,7 @@ where return; }; - let draw_cursors = options - .into_result() - .map(|o| o.contains(ext_image_copy_capture_manager_v1::Options::PaintCursors)) - .unwrap_or(false); + let draw_cursors = options.contains(ext_image_copy_capture_manager_v1::Options::PaintCursors); let inner = Arc::new(Mutex::new(SessionInner::new( capture_source.clone(), draw_cursors, @@ -1107,7 +1094,7 @@ where } } -impl Dispatch2 for SessionData +impl Dispatch for SessionData where D: ImageCopyCaptureHandler, { @@ -1139,7 +1126,7 @@ where fn destroyed( &self, state: &mut D, - _client: wayland_server::backend::ClientId, + _client: &wayland_server::backend::ClientId, resource: &ExtImageCopyCaptureSessionV1, ) { let session_ref = SessionRef { @@ -1152,7 +1139,7 @@ where } // Dispatch for session created from cursor session's get_capture_session -impl Dispatch2 for CursorSessionData +impl Dispatch for CursorSessionData where D: ImageCopyCaptureHandler, { @@ -1182,7 +1169,7 @@ where } } -impl Dispatch2 for CursorSessionData +impl Dispatch for CursorSessionData where D: ImageCopyCaptureHandler, { @@ -1221,14 +1208,14 @@ where } #[cfg(feature = "backend_drm")] if let Some(dma) = constraints.dma.as_ref() { - let node = Vec::from(dma.node.dev_id().to_ne_bytes()); - obj.dmabuf_device(node); + let node = dma.node.dev_id().to_ne_bytes(); + obj.dmabuf_device(&node); for (fmt, modifiers) in &dma.formats { let modifiers = modifiers .iter() .flat_map(|modifier| u64::from(*modifier).to_ne_bytes()) .collect::>(); - obj.dmabuf_format(*fmt as u32, modifiers); + obj.dmabuf_format(*fmt as u32, &modifiers); } } obj.done(); @@ -1244,7 +1231,7 @@ where fn destroyed( &self, state: &mut D, - _client: wayland_server::backend::ClientId, + _client: &wayland_server::backend::ClientId, resource: &ExtImageCopyCaptureCursorSessionV1, ) { let session_ref = CursorSessionRef { @@ -1256,7 +1243,7 @@ where } } -impl Dispatch2 for FrameData +impl Dispatch for FrameData where D: ImageCopyCaptureHandler, { @@ -1372,7 +1359,7 @@ where fn destroyed( &self, state: &mut D, - _client: wayland_server::backend::ClientId, + _client: &wayland_server::backend::ClientId, resource: &ExtImageCopyCaptureFrameV1, ) { let frame_ref = FrameRef { diff --git a/src/wayland/input_method/input_method_handle.rs b/src/wayland/input_method/input_method_handle.rs index fc73a979e301..5dad84bce097 100644 --- a/src/wayland/input_method/input_method_handle.rs +++ b/src/wayland/input_method/input_method_handle.rs @@ -4,11 +4,7 @@ use std::{ }; use tracing::warn; -use wayland_protocols_misc::zwp_input_method_v2::server::{ - zwp_input_method_keyboard_grab_v2::ZwpInputMethodKeyboardGrabV2, - zwp_input_method_v2::{self, ZwpInputMethodV2}, - zwp_input_popup_surface_v2::ZwpInputPopupSurfaceV2, -}; +use wayland_protocols_misc::zwp_input_method_v2::server::zwp_input_method_v2::{self, ZwpInputMethodV2}; use wayland_server::{ Client, DataInit, Dispatch, DisplayHandle, Resource, protocol::wl_keyboard::KeymapFormat, }; @@ -17,7 +13,7 @@ use wayland_server::{backend::ClientId, protocol::wl_surface::WlSurface}; use crate::{ input::{SeatHandler, keyboard::KeyboardHandle}, utils::{Logical, Rectangle, SERIAL_COUNTER, alive_tracker::AliveTracker}, - wayland::{Dispatch2, compositor, seat::WaylandFocus, text_input::TextInputHandle}, + wayland::{compositor, seat::WaylandFocus, text_input::TextInputHandle}, }; use super::{ @@ -185,10 +181,8 @@ impl fmt::Debug for InputMethodUserData { } } -impl Dispatch2 for InputMethodUserData +impl Dispatch for InputMethodUserData where - D: Dispatch, - D: Dispatch>, D: SeatHandler, D: InputMethodHandler, ::KeyboardFocus: WaylandFocus, @@ -319,7 +313,7 @@ where } } - fn destroyed(&self, _state: &mut D, _client: ClientId, _input_method: &ZwpInputMethodV2) { + fn destroyed(&self, _state: &mut D, _client: &ClientId, _input_method: &ZwpInputMethodV2) { self.handle.inner.lock().unwrap().instance = None; self.text_input_handle.leave(); } diff --git a/src/wayland/input_method/input_method_keyboard_grab.rs b/src/wayland/input_method/input_method_keyboard_grab.rs index bf80676350a5..44cea1e24775 100644 --- a/src/wayland/input_method/input_method_keyboard_grab.rs +++ b/src/wayland/input_method/input_method_keyboard_grab.rs @@ -6,7 +6,7 @@ use std::{ use wayland_protocols_misc::zwp_input_method_v2::server::zwp_input_method_keyboard_grab_v2::{ self, ZwpInputMethodKeyboardGrabV2, }; -use wayland_server::backend::ClientId; +use wayland_server::{Dispatch, backend::ClientId}; use crate::input::{ SeatHandler, @@ -19,7 +19,6 @@ use crate::wayland::text_input::TextInputHandle; use crate::{ backend::input::{InputTime, KeyState, Keycode}, utils::Serial, - wayland::Dispatch2, }; #[derive(Default, Debug)] @@ -98,8 +97,8 @@ impl fmt::Debug for InputMethodKeyboardUserData { } } -impl Dispatch2 for InputMethodKeyboardUserData { - fn destroyed(&self, state: &mut D, _client: ClientId, _object: &ZwpInputMethodKeyboardGrabV2) { +impl Dispatch for InputMethodKeyboardUserData { + fn destroyed(&self, state: &mut D, _client: &ClientId, _object: &ZwpInputMethodKeyboardGrabV2) { self.handle.inner.lock().unwrap().grab = None; self.keyboard_handle.unset_grab(state); } diff --git a/src/wayland/input_method/input_method_popup_surface.rs b/src/wayland/input_method/input_method_popup_surface.rs index 30befc91ec15..582848846c44 100644 --- a/src/wayland/input_method/input_method_popup_surface.rs +++ b/src/wayland/input_method/input_method_popup_surface.rs @@ -3,14 +3,11 @@ use std::sync::{Arc, Mutex}; use wayland_protocols_misc::zwp_input_method_v2::server::zwp_input_popup_surface_v2::{ self, ZwpInputPopupSurfaceV2, }; -use wayland_server::{Resource, backend::ClientId, protocol::wl_surface::WlSurface}; - -use crate::{ - utils::{ - Logical, Point, Rectangle, - alive_tracker::{AliveTracker, IsAlive}, - }, - wayland::Dispatch2, +use wayland_server::{Dispatch, Resource, backend::ClientId, protocol::wl_surface::WlSurface}; + +use crate::utils::{ + Logical, Point, Rectangle, + alive_tracker::{AliveTracker, IsAlive}, }; /// Handle to a popup surface @@ -130,7 +127,7 @@ pub struct InputMethodPopupSurfaceUserData { pub(super) alive_tracker: AliveTracker, } -impl Dispatch2 for InputMethodPopupSurfaceUserData { +impl Dispatch for InputMethodPopupSurfaceUserData { fn request( &self, _state: &mut D, @@ -148,7 +145,7 @@ impl Dispatch2 for InputMethodPopupSurfaceUserData } } - fn destroyed(&self, _state: &mut D, _client: ClientId, _object: &ZwpInputPopupSurfaceV2) { + fn destroyed(&self, _state: &mut D, _client: &ClientId, _object: &ZwpInputPopupSurfaceV2) { self.alive_tracker.destroy_notify(); } } diff --git a/src/wayland/input_method/mod.rs b/src/wayland/input_method/mod.rs index 297eebf46e4a..8ebee27cadb9 100644 --- a/src/wayland/input_method/mod.rs +++ b/src/wayland/input_method/mod.rs @@ -24,8 +24,6 @@ //! } //! } //! -//! smithay::delegate_dispatch2!(State); -//! //! # let mut display = wayland_server::Display::::new().unwrap(); //! # let display_handle = display.handle(); //! @@ -62,15 +60,14 @@ use wayland_server::{ protocol::wl_surface::WlSurface, }; -use wayland_protocols_misc::zwp_input_method_v2::server::{ - zwp_input_method_manager_v2::{self, ZwpInputMethodManagerV2}, - zwp_input_method_v2::ZwpInputMethodV2, +use wayland_protocols_misc::zwp_input_method_v2::server::zwp_input_method_manager_v2::{ + self, ZwpInputMethodManagerV2, }; use crate::{ input::{Seat, SeatHandler}, utils::{Logical, Rectangle}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, + wayland::{GlobalData, seat::WaylandFocus}, }; pub use input_method_handle::{InputMethodHandle, InputMethodUserData}; @@ -90,7 +87,7 @@ mod input_method_popup_surface; pub use input_method_popup_surface::{PopupParent, PopupSurface}; /// Adds input method popup to compositor state -pub trait InputMethodHandler { +pub trait InputMethodHandler: SeatHandler { /// Add a popup surface to compositor state. fn new_popup(&mut self, surface: PopupSurface); @@ -134,11 +131,8 @@ impl InputMethodManagerState { /// Initialize a text input manager global. pub fn new(display: &DisplayHandle, filter: F) -> Self where - D: GlobalDispatch, - D: Dispatch, - D: Dispatch>, - D: SeatHandler, - D: 'static, + D: InputMethodHandler + 'static, + ::KeyboardFocus: WaylandFocus, F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, { let data = InputMethodManagerGlobalData { @@ -155,12 +149,10 @@ impl InputMethodManagerState { } } -impl GlobalDispatch2 for InputMethodManagerGlobalData +impl GlobalDispatch for InputMethodManagerGlobalData where - D: Dispatch, - D: Dispatch>, - D: SeatHandler, - D: 'static, + D: InputMethodHandler + 'static, + ::KeyboardFocus: WaylandFocus, { fn bind( &self, @@ -178,11 +170,10 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch>, - D: SeatHandler + InputMethodHandler, - D: 'static, + D: InputMethodHandler + 'static, + ::KeyboardFocus: WaylandFocus, { fn request( &self, diff --git a/src/wayland/keyboard_shortcuts_inhibit/dispatch.rs b/src/wayland/keyboard_shortcuts_inhibit/dispatch.rs index b29d883826dd..54286ea9e423 100644 --- a/src/wayland/keyboard_shortcuts_inhibit/dispatch.rs +++ b/src/wayland/keyboard_shortcuts_inhibit/dispatch.rs @@ -8,15 +8,12 @@ use wayland_protocols::wp::keyboard_shortcuts_inhibit::zv1::server::{ zwp_keyboard_shortcuts_inhibitor_v1::{self, ZwpKeyboardShortcutsInhibitorV1}, }; use wayland_server::{ - Dispatch, Resource, + Dispatch, GlobalDispatch, Resource, backend::{ClientId, ObjectId}, protocol::wl_surface::WlSurface, }; -use crate::{ - input::{Seat, SeatHandler}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, -}; +use crate::{input::Seat, wayland::GlobalData}; use super::KeyboardShortcutsInhibitHandler; @@ -30,11 +27,9 @@ pub struct KeyboardShortcutsInhibitorUserData { pub(crate) is_active: AtomicBool, } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where D: KeyboardShortcutsInhibitHandler, - D: Dispatch, - D: Dispatch, { fn bind( &self, @@ -48,11 +43,9 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where D: KeyboardShortcutsInhibitHandler, - D: SeatHandler, - D: Dispatch, { fn request( &self, @@ -65,7 +58,7 @@ where ) { match request { zwp_keyboard_shortcuts_inhibit_manager_v1::Request::InhibitShortcuts { id, surface, seat } => { - let seat_id = seat.id(); + let seat_id = seat.id().clone(); if handler .keyboard_shortcuts_inhibit_state() @@ -111,7 +104,7 @@ where } } -impl Dispatch2 for KeyboardShortcutsInhibitorUserData +impl Dispatch for KeyboardShortcutsInhibitorUserData where D: KeyboardShortcutsInhibitHandler, { @@ -130,7 +123,7 @@ where } } - fn destroyed(&self, handler: &mut D, _client: ClientId, wl_inhibitor: &ZwpKeyboardShortcutsInhibitorV1) { + fn destroyed(&self, handler: &mut D, _client: &ClientId, wl_inhibitor: &ZwpKeyboardShortcutsInhibitorV1) { self.is_active.store(false, atomic::Ordering::Release); let state = handler.keyboard_shortcuts_inhibit_state(); diff --git a/src/wayland/keyboard_shortcuts_inhibit/mod.rs b/src/wayland/keyboard_shortcuts_inhibit/mod.rs index 92fcf6f0aaab..6567b7eac6e0 100644 --- a/src/wayland/keyboard_shortcuts_inhibit/mod.rs +++ b/src/wayland/keyboard_shortcuts_inhibit/mod.rs @@ -10,7 +10,7 @@ use wayland_protocols::wp::keyboard_shortcuts_inhibit::zv1::server::{ zwp_keyboard_shortcuts_inhibitor_v1::ZwpKeyboardShortcutsInhibitorV1, }; use wayland_server::{ - Dispatch, DisplayHandle, GlobalDispatch, Resource, + DisplayHandle, Resource, backend::{GlobalId, ObjectId}, protocol::{wl_seat::WlSeat, wl_surface::WlSurface}, }; @@ -43,7 +43,7 @@ impl SeatInhibitors { self.0.iter().any(|i| i.is_active()) } - fn remove(&mut self, id: ObjectId) -> Option { + fn remove(&mut self, id: &ObjectId) -> Option { self.0 .iter() .position(|i| i.inhibitor.id() == id) @@ -71,10 +71,7 @@ impl KeyboardShortcutsInhibitState { /// Regiseter new [ZwpKeyboardShortcutsInhibitManagerV1] global pub fn new(display: &DisplayHandle) -> Self where - D: GlobalDispatch, - D: Dispatch, - D: Dispatch, - D: 'static, + D: KeyboardShortcutsInhibitHandler + 'static, { let manager_global = display.create_global::(1, GlobalData); @@ -235,7 +232,7 @@ where /// WP Keyboard shortcuts inhibit handler #[allow(unused_variables)] -pub trait KeyboardShortcutsInhibitHandler { +pub trait KeyboardShortcutsInhibitHandler: SeatHandler { /// [KeyboardShortcutsInhibitState] getter fn keyboard_shortcuts_inhibit_state(&mut self) -> &mut KeyboardShortcutsInhibitState; diff --git a/src/wayland/mod.rs b/src/wayland/mod.rs index 5bc9f0bc4cbe..bafbb4b782b7 100644 --- a/src/wayland/mod.rs +++ b/src/wayland/mod.rs @@ -54,8 +54,6 @@ pub mod commit_timing; pub mod compositor; pub mod content_type; pub mod cursor_shape; -mod dispatch2; -pub use dispatch2::{Dispatch2, GlobalDispatch2}; pub mod dmabuf; #[cfg(feature = "backend_drm")] pub mod drm_lease; diff --git a/src/wayland/output/handlers.rs b/src/wayland/output/handlers.rs index 05655930aa1d..27ab124e85da 100644 --- a/src/wayland/output/handlers.rs +++ b/src/wayland/output/handlers.rs @@ -7,11 +7,11 @@ use wayland_protocols::xdg::xdg_output::zv1::server::{ zxdg_output_v1::{self, ZxdgOutputV1}, }; use wayland_server::{ - Client, DataInit, Dispatch, DisplayHandle, New, Resource, + Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, protocol::wl_output::{self, Mode as WMode, WlOutput}, }; -use crate::wayland::{Dispatch2, GlobalData, GlobalDispatch2, compositor::CompositorHandler}; +use crate::wayland::{GlobalData, compositor::CompositorHandler}; use super::{Output, OutputHandler, OutputUserData, WlOutputData, xdg::XdgOutput}; @@ -19,9 +19,8 @@ use super::{Output, OutputHandler, OutputUserData, WlOutputData, xdg::XdgOutput} * Wl Output */ -impl GlobalDispatch2 for WlOutputData +impl GlobalDispatch for WlOutputData where - D: Dispatch, D: OutputHandler, D: CompositorHandler, D: 'static, @@ -100,7 +99,7 @@ where } } -impl Dispatch2 for OutputUserData { +impl Dispatch for OutputUserData { fn request( &self, _state: &mut D, @@ -112,7 +111,7 @@ impl Dispatch2 for OutputUserData { ) { } - fn destroyed(&self, _state: &mut D, _client_id: wayland_server::backend::ClientId, output: &WlOutput) { + fn destroyed(&self, _state: &mut D, _client_id: &wayland_server::backend::ClientId, output: &WlOutput) { if let Some(o) = self.output.upgrade() { o.inner .0 @@ -128,10 +127,9 @@ impl Dispatch2 for OutputUserData { * XDG Output */ -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, - D: Dispatch, + D: OutputHandler, D: 'static, { fn bind( @@ -146,9 +144,9 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, + D: OutputHandler, D: CompositorHandler, D: 'static, { @@ -200,7 +198,7 @@ pub struct XdgOutputUserData { pub(super) client_scale: Arc, } -impl Dispatch2 for XdgOutputUserData { +impl Dispatch for XdgOutputUserData { fn request( &self, _state: &mut D, @@ -215,7 +213,7 @@ impl Dispatch2 for XdgOutputUserData { fn destroyed( &self, _state: &mut D, - _client_id: wayland_server::backend::ClientId, + _client_id: &wayland_server::backend::ClientId, xdg_output: &ZxdgOutputV1, ) { self.xdg_output diff --git a/src/wayland/output/mod.rs b/src/wayland/output/mod.rs index 27f120307577..0a9114b0e038 100644 --- a/src/wayland/output/mod.rs +++ b/src/wayland/output/mod.rs @@ -64,8 +64,6 @@ //! # fn client_compositor_state<'a>(&self, client: &'a Client) -> &'a CompositorClientState { unimplemented!() } //! # fn commit(&mut self, surface: &WlSurface) {} //! # } -//! -//! smithay::delegate_dispatch2!(State); //! ``` mod handlers; @@ -84,7 +82,7 @@ use tracing::info; use wayland_protocols::xdg::xdg_output::zv1::server::zxdg_output_manager_v1::ZxdgOutputManagerV1; use wayland_protocols::xdg::xdg_output::zv1::server::zxdg_output_v1::ZxdgOutputV1; use wayland_server::{ - Client, DisplayHandle, GlobalDispatch, Resource, + Client, DisplayHandle, Resource, backend::{ClientId, GlobalId}, protocol::{ wl_output::{Mode as WMode, Subpixel as WlSubpixel, Transform, WlOutput}, @@ -94,7 +92,7 @@ use wayland_server::{ use crate::{ utils::{Logical, Point}, - wayland::GlobalData, + wayland::{GlobalData, compositor::CompositorHandler}, }; pub use self::handlers::XdgOutputUserData; @@ -112,7 +110,7 @@ pub struct WlOutputData { } /// Events initiated by the clients interacting with outputs -pub trait OutputHandler { +pub trait OutputHandler: CompositorHandler { /// A client bound a new `wl_output` instance. fn output_bound(&mut self, _output: Output, _wl_output: WlOutput) {} } @@ -128,9 +126,7 @@ impl OutputManagerState { /// Create new output manager with xdg output support pub fn new_with_xdg_output(display: &DisplayHandle) -> Self where - D: GlobalDispatch, - D: GlobalDispatch, - D: 'static, + D: OutputHandler + 'static, { let xdg_output_manager = display.create_global::(3, GlobalData); @@ -203,8 +199,7 @@ impl Output { /// multiple times. pub fn create_global(&self, display: &DisplayHandle) -> GlobalId where - D: GlobalDispatch, - D: 'static, + D: OutputHandler + 'static, { info!(output = self.name(), "Creating new wl_output"); self.inner.0.lock().unwrap().handle = Some(display.backend_handle().downgrade()); @@ -292,11 +287,11 @@ impl Output { } /// This function returns all managed [WlOutput] matching the provided [Client] - pub fn client_outputs<'a>(&'a self, client: &Client) -> impl Iterator + 'a { + pub fn client_outputs<'a>(&'a self, client: &'a Client) -> impl Iterator + 'a { self.client_outputs_internal(client.id()) } - fn client_outputs_internal(&self, client: ClientId) -> impl Iterator + '_ { + fn client_outputs_internal<'a>(&'a self, client: &'a ClientId) -> impl Iterator + 'a { let guard = self.inner.0.lock().unwrap(); new_locked_obj_iter(guard, client, |inner| inner.instances.iter()) @@ -316,7 +311,7 @@ impl Output { drop(inner); if let Some(client) = client { - for output in self.client_outputs_internal(client) { + for output in self.client_outputs_internal(&client) { surface.enter(&output); } } @@ -337,7 +332,7 @@ impl Output { drop(inner); if let Some(client) = client { - for output in self.client_outputs_internal(client) { + for output in self.client_outputs_internal(&client) { surface.leave(&output); } } @@ -360,7 +355,7 @@ impl Output { }; if let Ok(client) = handle.get_client(surface.id()) { - for output in self.client_outputs_internal(client) { + for output in self.client_outputs_internal(&client) { surface.leave(&output); } } diff --git a/src/wayland/pointer_constraints.rs b/src/wayland/pointer_constraints.rs index 81fb26450cd0..701e2e8ccfbc 100644 --- a/src/wayland/pointer_constraints.rs +++ b/src/wayland/pointer_constraints.rs @@ -17,7 +17,7 @@ use wayland_protocols::wp::pointer_constraints::zv1::server::{ zwp_pointer_constraints_v1::{self, Lifetime, ZwpPointerConstraintsV1}, }; use wayland_server::{ - Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, WEnum, backend::GlobalId, + Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, backend::GlobalId, protocol::wl_surface::WlSurface, }; @@ -25,7 +25,7 @@ use super::compositor::{self, RegionAttributes}; use crate::{ input::{SeatHandler, pointer::PointerHandle}, utils::{Logical, Point}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2, seat::PointerUserData}, + wayland::{GlobalData, seat::PointerUserData}, }; const VERSION: u32 = 1; @@ -77,7 +77,7 @@ pub struct ConfinedPointer { handle: zwp_confined_pointer_v1::ZwpConfinedPointerV1, region: Option, pending_region: Option, - lifetime: WEnum, + lifetime: Lifetime, active: AtomicBool, } @@ -94,7 +94,7 @@ pub struct LockedPointer { handle: zwp_locked_pointer_v1::ZwpLockedPointerV1, region: Option, pending_region: Option, - lifetime: WEnum, + lifetime: Lifetime, cursor_position_hint: Option>, pending_cursor_position_hint: Option>, active: AtomicBool, @@ -183,7 +183,7 @@ impl PointerConstraintRef< } }; - if deactivated && self.lifetime() == WEnum::Value(Lifetime::Oneshot) { + if deactivated && self.lifetime() == Lifetime::Oneshot { self.entry.remove_entry(); } } @@ -207,7 +207,7 @@ impl PointerConstraint { } } - fn lifetime(&self) -> WEnum { + fn lifetime(&self) -> Lifetime { match self { PointerConstraint::Confined(confined) => confined.lifetime, PointerConstraint::Locked(locked) => locked.lifetime, @@ -241,12 +241,7 @@ impl PointerConstraintsState { /// Create a new pointer constraints global pub fn new(display: &DisplayHandle) -> Self where - D: GlobalDispatch, - D: Dispatch, - D: Dispatch>, - D: Dispatch>, - D: SeatHandler, - D: 'static, + D: PointerConstraintsHandler + 'static, { let global = display.create_global::(VERSION, GlobalData); @@ -384,13 +379,9 @@ fn remove_constraint( } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch>, - D: Dispatch>, - D: SeatHandler, - D: PointerConstraintsHandler, - D: 'static, + D: PointerConstraintsHandler + 'static, { fn request( &self, @@ -474,9 +465,9 @@ where } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch + SeatHandler + 'static, + D: PointerConstraintsHandler + 'static, { fn bind( &self, @@ -490,7 +481,7 @@ where } } -impl Dispatch2 for PointerConstraintUserData +impl Dispatch for PointerConstraintUserData where D: SeatHandler, D: PointerConstraintsHandler, @@ -527,7 +518,7 @@ where fn destroyed( &self, state: &mut D, - _client: wayland_server::backend::ClientId, + _client: &wayland_server::backend::ClientId, _resource: &ZwpConfinedPointerV1, ) { let Some(pointer) = &self.pointer else { @@ -538,7 +529,7 @@ where } } -impl Dispatch2 for PointerConstraintUserData +impl Dispatch for PointerConstraintUserData where D: SeatHandler, D: PointerConstraintsHandler, @@ -580,7 +571,7 @@ where fn destroyed( &self, state: &mut D, - _client: wayland_server::backend::ClientId, + _client: &wayland_server::backend::ClientId, _resource: &ZwpLockedPointerV1, ) { let Some(pointer) = &self.pointer else { diff --git a/src/wayland/pointer_gestures.rs b/src/wayland/pointer_gestures.rs index 4b6413005f67..9fc02ba1241f 100644 --- a/src/wayland/pointer_gestures.rs +++ b/src/wayland/pointer_gestures.rs @@ -92,8 +92,6 @@ //! # } //! # } //! let state = PointerGesturesState::new::(&display.handle()); -//! -//! smithay::delegate_dispatch2!(State); //! ``` use std::sync::{Arc, Mutex, atomic::Ordering}; @@ -122,7 +120,7 @@ use crate::{ }, }, utils::{SERIAL_COUNTER, Serial}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2, seat::PointerUserData}, + wayland::{GlobalData, seat::PointerUserData}, }; const MANAGER_VERSION: u32 = 3; @@ -385,11 +383,6 @@ impl PointerGesturesState { /// Register new [ZwpPointerGesturesV1] global pub fn new(display: &DisplayHandle) -> Self where - D: GlobalDispatch, - D: Dispatch, - D: Dispatch>, - D: Dispatch>, - D: Dispatch>, D: SeatHandler, D: 'static, { @@ -404,11 +397,8 @@ impl PointerGesturesState { } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch>, - D: Dispatch>, - D: Dispatch>, D: SeatHandler, D: 'static, { @@ -464,9 +454,9 @@ where } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch + SeatHandler + 'static, + D: SeatHandler + 'static, { fn bind( &self, @@ -480,7 +470,7 @@ where } } -impl Dispatch2 for PointerGestureUserData +impl Dispatch for PointerGestureUserData where D: SeatHandler, D: 'static, @@ -500,7 +490,7 @@ where } } - fn destroyed(&self, _state: &mut D, _: ClientId, object: &ZwpPointerGestureSwipeV1) { + fn destroyed(&self, _state: &mut D, _: &ClientId, object: &ZwpPointerGestureSwipeV1) { if let Some(ref handle) = self.handle { handle .wp_pointer_gestures @@ -512,7 +502,7 @@ where } } -impl Dispatch2 for PointerGestureUserData +impl Dispatch for PointerGestureUserData where D: SeatHandler, D: 'static, @@ -532,7 +522,7 @@ where } } - fn destroyed(&self, _state: &mut D, _: ClientId, object: &ZwpPointerGesturePinchV1) { + fn destroyed(&self, _state: &mut D, _: &ClientId, object: &ZwpPointerGesturePinchV1) { if let Some(ref handle) = self.handle { handle .wp_pointer_gestures @@ -544,7 +534,7 @@ where } } -impl Dispatch2 for PointerGestureUserData +impl Dispatch for PointerGestureUserData where D: SeatHandler, D: 'static, @@ -564,7 +554,7 @@ where } } - fn destroyed(&self, _state: &mut D, _: ClientId, object: &ZwpPointerGestureHoldV1) { + fn destroyed(&self, _state: &mut D, _: &ClientId, object: &ZwpPointerGestureHoldV1) { if let Some(ref handle) = self.handle { handle .wp_pointer_gestures diff --git a/src/wayland/pointer_warp.rs b/src/wayland/pointer_warp.rs index d3271b892f64..a1fa782bc119 100644 --- a/src/wayland/pointer_warp.rs +++ b/src/wayland/pointer_warp.rs @@ -42,8 +42,6 @@ //! // Pointer warp was requested by the client //! } //! } -//! -//! smithay::delegate_dispatch2!(State); //! ``` use std::sync::atomic::Ordering; @@ -58,7 +56,7 @@ use wayland_server::{ use crate::{ input::SeatHandler, utils::{Client as ClientCords, Logical, Point, Serial}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2, seat::PointerUserData}, + wayland::{GlobalData, seat::PointerUserData}, }; /// Handler trait for pointer warp events. @@ -93,7 +91,7 @@ impl PointerWarpManager { /// Creates a new delegate type for handling [WpPointerWarpV1] events. pub fn new(display: &DisplayHandle) -> Self where - D: PointerWarpHandler + GlobalDispatch, + D: PointerWarpHandler, { let global = display.create_global::(1, GlobalData); Self { global } @@ -105,9 +103,9 @@ impl PointerWarpManager { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, + D: PointerWarpHandler, { fn bind( &self, @@ -121,7 +119,7 @@ where } } -impl Dispatch2 for GlobalData { +impl Dispatch for GlobalData { fn request( &self, state: &mut D, diff --git a/src/wayland/presentation/mod.rs b/src/wayland/presentation/mod.rs index 54b5ce6c8f84..7216001faba3 100644 --- a/src/wayland/presentation/mod.rs +++ b/src/wayland/presentation/mod.rs @@ -18,8 +18,6 @@ //! 1 // the id of the clock //! ); //! -//! smithay::delegate_dispatch2!(State); -//! //! // You're now ready to go! //! ``` //! @@ -76,10 +74,7 @@ use wayland_server::{ Dispatch, DisplayHandle, GlobalDispatch, Resource, Weak, backend::GlobalId, protocol::wl_surface, }; -use crate::{ - output::Output, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, -}; +use crate::{output::Output, wayland::GlobalData}; use super::compositor::{Cacheable, with_states}; @@ -98,10 +93,7 @@ impl PresentationState { /// the event loop in the future. pub fn new(display: &DisplayHandle, clk_id: u32) -> Self where - D: GlobalDispatch - + Dispatch - + Dispatch - + 'static, + D: 'static, { PresentationState { global: display @@ -121,11 +113,7 @@ pub struct PresentationData { clk_id: u32, } -impl GlobalDispatch2 for PresentationData -where - D: Dispatch, - D: Dispatch, -{ +impl GlobalDispatch for PresentationData { fn bind( &self, _state: &mut D, @@ -139,10 +127,7 @@ where } } -impl Dispatch2 for PresentationData -where - D: Dispatch, -{ +impl Dispatch for PresentationData { fn request( &self, _state: &mut D, @@ -173,7 +158,7 @@ where } } -impl Dispatch2 for GlobalData { +impl Dispatch for GlobalData { fn request( &self, _state: &mut D, diff --git a/src/wayland/relative_pointer.rs b/src/wayland/relative_pointer.rs index 5aadfbb98c28..89d8c346b092 100644 --- a/src/wayland/relative_pointer.rs +++ b/src/wayland/relative_pointer.rs @@ -80,8 +80,6 @@ //! # } //! # } //! let state = RelativePointerManagerState::new::(&display.handle()); -//! -//! smithay::delegate_dispatch2!(State); //! ``` use std::sync::{Arc, Mutex, atomic::Ordering}; @@ -102,7 +100,7 @@ use crate::{ SeatHandler, pointer::{PointerHandle, RelativeMotionEvent}, }, - wayland::{Dispatch2, GlobalData, GlobalDispatch2, seat::PointerUserData}, + wayland::{GlobalData, seat::PointerUserData}, }; const MANAGER_VERSION: u32 = 1; @@ -172,9 +170,6 @@ impl RelativePointerManagerState { /// Register new [ZwpRelativePointerV1] global pub fn new(display: &DisplayHandle) -> Self where - D: GlobalDispatch, - D: Dispatch, - D: Dispatch>, D: SeatHandler, D: 'static, { @@ -189,9 +184,8 @@ impl RelativePointerManagerState { } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch>, D: SeatHandler, D: 'static, { @@ -222,9 +216,9 @@ where } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch + SeatHandler + 'static, + D: SeatHandler + 'static, { fn bind( &self, @@ -238,7 +232,7 @@ where } } -impl Dispatch2 for RelativePointerUserData +impl Dispatch for RelativePointerUserData where D: SeatHandler, D: 'static, @@ -258,7 +252,7 @@ where } } - fn destroyed(&self, _state: &mut D, _: ClientId, object: &ZwpRelativePointerV1) { + fn destroyed(&self, _state: &mut D, _: &ClientId, object: &ZwpRelativePointerV1) { if let Some(ref handle) = self.handle { handle .wp_relative diff --git a/src/wayland/seat/keyboard.rs b/src/wayland/seat/keyboard.rs index f13e1e384425..47a655c9cb63 100644 --- a/src/wayland/seat/keyboard.rs +++ b/src/wayland/seat/keyboard.rs @@ -2,7 +2,7 @@ use std::{cell::RefCell, fmt}; use tracing::{instrument, trace, warn}; use wayland_server::{ - Client, DisplayHandle, Resource, + Client, Dispatch, DisplayHandle, Resource, backend::{ClientId, ObjectId}, protocol::{ wl_keyboard::{self, KeyState as WlKeyState, WlKeyboard}, @@ -19,7 +19,6 @@ use crate::{ }, utils::{HookId, Serial, iter::new_locked_obj_iter_from_vec}, wayland::{ - Dispatch2, compositor::{add_destruction_hook, remove_destruction_hook, with_states}, input_method::InputMethodSeat, text_input::TextInputSeat, @@ -44,7 +43,7 @@ where } /// Return all raw [`WlKeyboard`] instances for a particular [`Client`] - pub fn client_keyboards<'a>(&'a self, client: &Client) -> impl Iterator + 'a { + pub fn client_keyboards<'a>(&'a self, client: &'a Client) -> impl Iterator + 'a { let guard = self.arc.known_kbds.lock().unwrap(); new_locked_obj_iter_from_vec(guard, client.id()) @@ -79,7 +78,7 @@ where if focused.same_client_as(&kbd.id()) { let serialized = guard.mods_state.serialized; let keys = serialize_pressed_keys(guard.pressed_keys.iter().copied()); - kbd.enter((*serial).into(), &focused.wl_surface().unwrap(), keys); + kbd.enter((*serial).into(), &focused.wl_surface().unwrap(), &keys); // Modifiers must be send after enter event. kbd.modifiers( (*serial).into(), @@ -117,7 +116,7 @@ impl fmt::Debug for KeyboardUserData { } } -impl Dispatch2 for KeyboardUserData +impl Dispatch for KeyboardUserData where D: 'static, D: SeatHandler, @@ -133,7 +132,7 @@ where ) { } - fn destroyed(&self, _state: &mut D, _client_id: ClientId, keyboard: &WlKeyboard) { + fn destroyed(&self, _state: &mut D, _client_id: &ClientId, keyboard: &WlKeyboard) { if let Some(ref handle) = self.handle { handle .arc @@ -214,7 +213,7 @@ pub(crate) fn enter_internal( *seat.get_keyboard().unwrap().arc.last_enter.lock().unwrap() = Some(serial); let serialized_keys = serialize_pressed_keys(keys); for_each_focused_kbds(seat, surface, |kbd| { - kbd.enter(serial.into(), surface, serialized_keys.clone()) + kbd.enter(serial.into(), surface, &serialized_keys) }); let seat_clone = seat.clone(); diff --git a/src/wayland/seat/mod.rs b/src/wayland/seat/mod.rs index 3740623c6461..62ec39c51ba6 100644 --- a/src/wayland/seat/mod.rs +++ b/src/wayland/seat/mod.rs @@ -45,8 +45,6 @@ //! } //! # impl PointerConstraintsHandler for State {} //! -//! smithay::delegate_dispatch2!(State); -//! //! # impl CompositorHandler for State { //! # fn compositor_state(&mut self) -> &mut CompositorState { unimplemented!() } //! # fn client_compositor_state<'a>(&self, client: &'a Client) -> &'a CompositorClientState { unimplemented!() } @@ -73,7 +71,6 @@ mod touch; use std::{borrow::Cow, fmt, sync::Arc}; use crate::input::{Inner, Seat, SeatHandler, SeatRc, SeatState}; -use crate::wayland::{Dispatch2, GlobalDispatch2}; pub use self::{ keyboard::KeyboardUserData, @@ -85,11 +82,8 @@ use wayland_server::{ Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, backend::{ClientId, GlobalId, ObjectId}, protocol::{ - wl_keyboard::WlKeyboard, - wl_pointer::WlPointer, wl_seat::{self, WlSeat}, wl_surface, - wl_touch::WlTouch, }, }; @@ -167,9 +161,10 @@ impl SeatState { /// in case you want to remove it. pub fn new_wl_seat(&mut self, display: &DisplayHandle, name: N) -> Seat where - D: GlobalDispatch> + SeatHandler + 'static, + D: SeatHandler + CompositorHandler + 'static, ::PointerFocus: WaylandFocus, ::KeyboardFocus: WaylandFocus, + ::TouchFocus: WaylandFocus, N: Into, { let Seat { arc } = self.new_seat(name); @@ -225,17 +220,12 @@ impl fmt::Debug for SeatUserData { } } -impl Dispatch2 for SeatUserData +impl Dispatch for SeatUserData where - D: Dispatch>, - D: Dispatch>, - D: Dispatch>, - D: SeatHandler, - D: CompositorHandler, + D: SeatHandler + CompositorHandler + 'static, ::PointerFocus: WaylandFocus, ::KeyboardFocus: WaylandFocus, ::TouchFocus: WaylandFocus, - D: 'static, { fn request( &self, @@ -307,7 +297,7 @@ where } } - fn destroyed(&self, _state: &mut D, _: ClientId, seat: &WlSeat) { + fn destroyed(&self, _state: &mut D, _: &ClientId, seat: &WlSeat) { self.arc .inner .lock() @@ -317,14 +307,12 @@ where } } -impl GlobalDispatch2 for SeatGlobalData +impl GlobalDispatch for SeatGlobalData where - D: Dispatch>, - D: Dispatch>, - D: Dispatch>, - D: Dispatch>, - D: SeatHandler, - D: 'static, + D: SeatHandler + CompositorHandler + 'static, + ::PointerFocus: WaylandFocus, + ::KeyboardFocus: WaylandFocus, + ::TouchFocus: WaylandFocus, { fn bind( &self, diff --git a/src/wayland/seat/pointer.rs b/src/wayland/seat/pointer.rs index c41d6b74f208..d38316860aa2 100644 --- a/src/wayland/seat/pointer.rs +++ b/src/wayland/seat/pointer.rs @@ -2,7 +2,7 @@ use std::sync::{Arc, Mutex, atomic::Ordering}; use portable_atomic::AtomicF64; use wayland_server::{ - Client, DisplayHandle, Resource, Weak, + Client, Dispatch, DisplayHandle, Resource, Weak, backend::{ClientId, ObjectId}, protocol::{ wl_pointer::{ @@ -26,7 +26,7 @@ use crate::{ }, utils::{Client as ClientCoords, Point, Serial, iter::new_locked_obj_iter_from_vec}, wayland::{ - Dispatch2, compositor, + compositor, pointer_constraints::{ConstraintRemove, PointerConstraintsHandler, with_pointer_constraint}, }, }; @@ -53,7 +53,7 @@ impl PointerHandle { } /// Return all raw [`WlPointer`] instances for a particular [`Client`] - pub fn client_pointers<'a>(&'a self, client: &Client) -> impl Iterator + 'a { + pub fn client_pointers<'a>(&'a self, client: &'a Client) -> impl Iterator + 'a { let guard = self.wl_pointer.known_pointers.lock().unwrap(); new_locked_obj_iter_from_vec(guard, client.id()) } @@ -387,7 +387,7 @@ pub struct PointerUserData { pub(crate) client_scale: Arc, } -impl Dispatch2 for PointerUserData +impl Dispatch for PointerUserData where D: SeatHandler, ::PointerFocus: WaylandFocus, @@ -475,7 +475,7 @@ where }; } - fn destroyed(&self, _state: &mut D, _: ClientId, pointer: &WlPointer) { + fn destroyed(&self, _state: &mut D, _: &ClientId, pointer: &WlPointer) { if let Some(ref handle) = self.handle { handle .wl_pointer diff --git a/src/wayland/seat/touch.rs b/src/wayland/seat/touch.rs index 5cbf0165bf07..a592c826c670 100644 --- a/src/wayland/seat/touch.rs +++ b/src/wayland/seat/touch.rs @@ -2,13 +2,12 @@ use std::sync::{Arc, atomic::Ordering}; use portable_atomic::AtomicF64; use wayland_server::{ - Client, DisplayHandle, Resource, + Client, Dispatch, DisplayHandle, Resource, backend::ClientId, protocol::wl_touch::{self, WlTouch}, }; use super::SeatHandler; -use crate::wayland::Dispatch2; use crate::wayland::compositor::CompositorHandler; use crate::wayland::seat::wl_surface::WlSurface; use crate::{input::touch::TouchHandle, wayland::seat::WaylandFocus}; @@ -77,7 +76,7 @@ impl TouchHandle { } /// Return all raw [`WlTouch`] instances for a particular [`Client`] - pub fn client_touch<'a>(&'a self, client: &Client) -> impl Iterator + 'a { + pub fn client_touch<'a>(&'a self, client: &'a Client) -> impl Iterator + 'a { let guard = self.known_instances.lock().unwrap(); new_locked_obj_iter_from_vec(guard, client.id()) } @@ -216,7 +215,7 @@ pub struct TouchUserData { pub(crate) client_scale: Arc, } -impl Dispatch2 for TouchUserData +impl Dispatch for TouchUserData where D: SeatHandler, D: 'static, @@ -232,7 +231,7 @@ where ) { } - fn destroyed(&self, _state: &mut D, _client_id: ClientId, touch: &WlTouch) { + fn destroyed(&self, _state: &mut D, _client_id: &ClientId, touch: &WlTouch) { if let Some(ref handle) = self.handle { handle .known_instances diff --git a/src/wayland/security_context/mod.rs b/src/wayland/security_context/mod.rs index dd99377af073..3c9726ff1f26 100644 --- a/src/wayland/security_context/mod.rs +++ b/src/wayland/security_context/mod.rs @@ -14,7 +14,7 @@ use wayland_server::{ backend::{ClientId, GlobalId}, }; -use crate::wayland::{Dispatch2, GlobalData, GlobalDispatch2}; +use crate::wayland::GlobalData; mod listener_source; pub use listener_source::SecurityContextListenerSource; @@ -69,10 +69,7 @@ impl SecurityContextState { /// created through a security context for the protocol to be correct and secure. pub fn new(display: &DisplayHandle, filter: F) -> Self where - D: GlobalDispatch, - D: Dispatch, - D: Dispatch, - D: 'static, + D: SecurityContextHandler + 'static, F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, { let global_data = SecurityContextGlobalData { @@ -95,10 +92,9 @@ pub struct SecurityContextGlobalData { filter: Box Fn(&'c Client) -> bool + Send + Sync>, } -impl GlobalDispatch2 for SecurityContextGlobalData +impl GlobalDispatch for SecurityContextGlobalData where - D: Dispatch, - D: 'static, + D: SecurityContextHandler + 'static, { fn bind( &self, @@ -116,10 +112,9 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, - D: 'static, + D: SecurityContextHandler + 'static, { fn request( &self, @@ -151,7 +146,7 @@ where } } -impl Dispatch2 for SecurityContextUserData +impl Dispatch for SecurityContextUserData where D: SecurityContextHandler + 'static, { @@ -213,7 +208,7 @@ where sandbox_engine: builder.sandbox_engine, app_id: builder.app_id, instance_id: builder.instance_id, - creator_client_id: client.id(), + creator_client_id: client.id().clone(), }; match listener_source { Ok(listener_source) => state.context_created(listener_source, security_context), diff --git a/src/wayland/selection/data_device/device.rs b/src/wayland/selection/data_device/device.rs index c9542e0dad0b..bea7f3cbd85e 100644 --- a/src/wayland/selection/data_device/device.rs +++ b/src/wayland/selection/data_device/device.rs @@ -2,7 +2,7 @@ use std::cell::RefCell; use tracing::debug; use wayland_server::{ - Client, DataInit, DisplayHandle, Resource, + Client, DataInit, Dispatch, DisplayHandle, Resource, protocol::{ wl_data_device::{self, WlDataDevice}, wl_seat::WlSeat, @@ -13,7 +13,7 @@ use crate::{ input::{Seat, SeatHandler, dnd::DndFocus}, utils::Serial, wayland::{ - Dispatch2, compositor, + compositor, seat::WaylandFocus, selection::{ SelectionTarget, @@ -36,10 +36,9 @@ pub struct DataDeviceUserData { pub(crate) wl_seat: WlSeat, } -impl Dispatch2 for DataDeviceUserData +impl Dispatch for DataDeviceUserData where D: DataDeviceHandler, - D: SeatHandler, ::PointerFocus: DndFocus, ::TouchFocus: DndFocus, ::KeyboardFocus: WaylandFocus, @@ -196,7 +195,12 @@ where } } - fn destroyed(&self, _state: &mut D, _client: wayland_server::backend::ClientId, resource: &WlDataDevice) { + fn destroyed( + &self, + _state: &mut D, + _client: &wayland_server::backend::ClientId, + resource: &WlDataDevice, + ) { if let Some(seat) = Seat::::from_resource(&self.wl_seat) { if let Some(seat_data) = seat.user_data().get::>>() { seat_data.borrow_mut().retain_devices(|ndd| match ndd { diff --git a/src/wayland/selection/data_device/mod.rs b/src/wayland/selection/data_device/mod.rs index 3eaa99834475..564c469192fe 100644 --- a/src/wayland/selection/data_device/mod.rs +++ b/src/wayland/selection/data_device/mod.rs @@ -70,8 +70,6 @@ //! // ... override default implementations here to customize handling ... //! } //! -//! smithay::delegate_dispatch2!(State); -//! //! // You're now ready to go! //! ``` @@ -85,8 +83,8 @@ use std::{ use smallvec::SmallVec; use tracing::instrument; use wayland_server::{ - Client, DisplayHandle, GlobalDispatch, Resource, - backend::{ClientId, GlobalId, Handle, ObjectData, ObjectId, protocol::Message}, + Client, DisplayHandle, Resource, + backend::{ClientId, GlobalId, Handle, ObjectData, ObjectId, protocol::OwnedMessage}, protocol::{ wl_data_device_manager::{DndAction as WlDndAction, WlDataDeviceManager}, wl_data_offer::{self, WlDataOffer}, @@ -103,7 +101,7 @@ use crate::{ dnd::{DndAction, DndFocus, GrabType, OfferData, Source}, }, utils::{Logical, Point, Serial}, - wayland::GlobalData, + wayland::{GlobalData, seat::WaylandFocus}, }; mod device; @@ -222,8 +220,8 @@ where self: Arc, dh: &Handle, handler: &mut D, - _client_id: ClientId, - msg: Message, + _client_id: &ClientId, + msg: OwnedMessage, ) -> Option>> { let dh = DisplayHandle::from(dh.clone()); if let Ok((resource, request)) = WlDataOffer::parse_request(&dh, msg) { @@ -237,8 +235,8 @@ where self: Arc, _handle: &Handle, _data: &mut D, - _client_id: ClientId, - _object_id: ObjectId, + _client_id: &ClientId, + _object_id: &ObjectId, ) { } } @@ -324,9 +322,6 @@ fn handle_dnd( preferred_action, } => { if let Some(source) = source.as_ref() { - let dnd_actions = dnd_actions.into_result().unwrap_or(WlDndAction::None); - let preferred_action = preferred_action.into_result().unwrap_or(WlDndAction::None); - // preferred_action must only contain one bitflag at the same time if ![ WlDndAction::None, @@ -461,7 +456,7 @@ impl DndFocus for WlSurface { // create a data offer let offer = handle .create_object::( - client.clone(), + &client, WlDataOffer::interface(), device.version(), Arc::new(WlDndDataOffer { @@ -582,8 +577,10 @@ impl DataDeviceState { /// Regiseter new [WlDataDeviceManager] global pub fn new(display: &DisplayHandle) -> Self where - D: GlobalDispatch + 'static, - D: DataDeviceHandler, + D: DataDeviceHandler + 'static, + ::PointerFocus: DndFocus, + ::TouchFocus: DndFocus, + ::KeyboardFocus: WaylandFocus, { let manager_global = display.create_global::(3, GlobalData); @@ -761,29 +758,28 @@ mod handlers { use tracing::error; use wayland_server::{ - Dispatch, DisplayHandle, - protocol::{ - wl_data_device::WlDataDevice, - wl_data_device_manager::{self, WlDataDeviceManager}, - wl_data_source::WlDataSource, - }, + Dispatch, DisplayHandle, GlobalDispatch, + protocol::wl_data_device_manager::{self, WlDataDeviceManager}, }; use crate::{ - input::Seat, - wayland::selection::{device::SelectionDevice, seat_data::SeatData}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, + input::{Seat, SeatHandler, dnd::DndFocus}, + wayland::{ + GlobalData, + seat::WaylandFocus, + selection::{device::SelectionDevice, seat_data::SeatData}, + }, }; use super::DataDeviceHandler; use super::{device::DataDeviceUserData, source::DataSourceUserData}; - impl GlobalDispatch2 for GlobalData + impl GlobalDispatch for GlobalData where - D: Dispatch, - D: Dispatch, - D: Dispatch, D: DataDeviceHandler, + ::PointerFocus: DndFocus, + ::TouchFocus: DndFocus, + ::KeyboardFocus: WaylandFocus, D: 'static, { fn bind( @@ -798,11 +794,12 @@ mod handlers { } } - impl Dispatch2 for GlobalData + impl Dispatch for GlobalData where - D: Dispatch, - D: Dispatch, D: DataDeviceHandler, + ::PointerFocus: DndFocus, + ::TouchFocus: DndFocus, + ::KeyboardFocus: WaylandFocus, D: 'static, { fn request( diff --git a/src/wayland/selection/data_device/source.rs b/src/wayland/selection/data_device/source.rs index 09ac7ebdbe86..be74afd889a6 100644 --- a/src/wayland/selection/data_device/source.rs +++ b/src/wayland/selection/data_device/source.rs @@ -4,10 +4,10 @@ use std::{ os::fd::{AsFd, OwnedFd}, sync::Mutex, }; -use tracing::{debug, error}; +use tracing::debug; use wayland_server::{ - DisplayHandle, Resource, + Dispatch, DisplayHandle, Resource, backend::ClientId, protocol::{ wl_data_source::{self, WlDataSource}, @@ -20,7 +20,6 @@ use crate::input::{ dnd::{DndAction, Source, SourceMetadata}, }; use crate::utils::{IsAlive, alive_tracker::AliveTracker}; -use crate::wayland::Dispatch2; use crate::wayland::selection::offer::OfferReplySource; use crate::wayland::selection::seat_data::SeatData; use crate::wayland::selection::source::SelectionSourceProvider; @@ -45,7 +44,7 @@ impl DataSourceUserData { } } -impl Dispatch2 for DataSourceUserData +impl Dispatch for DataSourceUserData where D: DataDeviceHandler, D: 'static, @@ -65,20 +64,15 @@ where wl_data_source::Request::Offer { mime_type } => { data.mime_types.push(mime_type); } - wl_data_source::Request::SetActions { dnd_actions } => match dnd_actions { - wayland_server::WEnum::Value(dnd_actions) => { - data.dnd_actions = DndAction::vec_from_wl(dnd_actions); - } - wayland_server::WEnum::Unknown(action) => { - error!("Unknown dnd_action: {:?}", action); - } - }, + wl_data_source::Request::SetActions { dnd_actions } => { + data.dnd_actions = DndAction::vec_from_wl(dnd_actions); + } wl_data_source::Request::Destroy => {} _ => unreachable!(), } } - fn destroyed(&self, state: &mut D, _client: ClientId, source: &WlDataSource) { + fn destroyed(&self, state: &mut D, _client: &ClientId, source: &WlDataSource) { self.alive_tracker.destroy_notify(); // Remove the source from the used ones. diff --git a/src/wayland/selection/device.rs b/src/wayland/selection/device.rs index 088a64a1e94f..556866e32ab9 100644 --- a/src/wayland/selection/device.rs +++ b/src/wayland/selection/device.rs @@ -38,7 +38,7 @@ impl SelectionDevice { selection_dispatch!(self; Self(device) => device.version()) } - pub fn id(&self) -> ObjectId { + pub fn id(&self) -> &ObjectId { selection_dispatch!(self; Self(device) => device.id()) } diff --git a/src/wayland/selection/ext_data_control/device.rs b/src/wayland/selection/ext_data_control/device.rs index a58f7c177908..0e717206abda 100644 --- a/src/wayland/selection/ext_data_control/device.rs +++ b/src/wayland/selection/ext_data_control/device.rs @@ -5,10 +5,9 @@ use wayland_protocols::ext::data_control::v1::server::ext_data_control_device_v1 }; use wayland_server::Resource; use wayland_server::protocol::wl_seat::WlSeat; -use wayland_server::{Client, DisplayHandle}; +use wayland_server::{Client, Dispatch, DisplayHandle}; use crate::input::Seat; -use crate::wayland::Dispatch2; use crate::wayland::selection::device::SelectionDevice; use crate::wayland::selection::offer::OfferReplySource; use crate::wayland::selection::seat_data::SeatData; @@ -24,7 +23,7 @@ pub struct ExtDataControlDeviceUserData { pub(crate) wl_seat: WlSeat, } -impl Dispatch2 for ExtDataControlDeviceUserData +impl Dispatch for ExtDataControlDeviceUserData where D: DataControlHandler, D: 'static, @@ -134,7 +133,7 @@ where fn destroyed( &self, _state: &mut D, - _client: wayland_server::backend::ClientId, + _client: &wayland_server::backend::ClientId, resource: &ExtDataControlDeviceV1, ) { if let Some(seat) = Seat::::from_resource(&self.wl_seat) { diff --git a/src/wayland/selection/ext_data_control/mod.rs b/src/wayland/selection/ext_data_control/mod.rs index 2d4905e3e825..0297aff7c1ee 100644 --- a/src/wayland/selection/ext_data_control/mod.rs +++ b/src/wayland/selection/ext_data_control/mod.rs @@ -48,8 +48,6 @@ //! // ... override default implementations here to customize handling ... //! } //! -//! smithay::delegate_dispatch2!(State); -//! //! // You're now ready to go! //! ``` //! @@ -62,7 +60,7 @@ use wayland_protocols::ext::data_control::v1::server::ext_data_control_manager_v use wayland_protocols::ext::data_control::v1::server::ext_data_control_source_v1::ExtDataControlSourceV1; use wayland_server::backend::GlobalId; use wayland_server::protocol::wl_seat::WlSeat; -use wayland_server::{Client, DisplayHandle, GlobalDispatch}; +use wayland_server::{Client, DisplayHandle}; mod device; mod source; @@ -100,7 +98,7 @@ impl DataControlState { filter: F, ) -> Self where - D: GlobalDispatch + 'static, + D: DataControlHandler + 'static, F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, { let data = ExtDataControlManagerGlobalData { @@ -141,18 +139,15 @@ mod handlers { use std::cell::RefCell; use tracing::error; - use wayland_protocols::ext::data_control::v1::server::{ - ext_data_control_device_v1::ExtDataControlDeviceV1, - ext_data_control_manager_v1::{self, ExtDataControlManagerV1}, - ext_data_control_source_v1::ExtDataControlSourceV1, + use wayland_protocols::ext::data_control::v1::server::ext_data_control_manager_v1::{ + self, ExtDataControlManagerV1, }; - use wayland_server::{Client, Dispatch, DisplayHandle}; + use wayland_server::{Client, Dispatch, DisplayHandle, GlobalDispatch}; use crate::input::Seat; use crate::wayland::selection::SelectionTarget; use crate::wayland::selection::device::SelectionDevice; use crate::wayland::selection::seat_data::SeatData; - use crate::wayland::{Dispatch2, GlobalDispatch2}; use super::DataControlHandler; use super::ExtDataControlDeviceUserData; @@ -160,9 +155,8 @@ mod handlers { use super::ExtDataControlManagerUserData; use super::ExtDataControlSourceUserData; - impl GlobalDispatch2 for ExtDataControlManagerGlobalData + impl GlobalDispatch for ExtDataControlManagerGlobalData where - D: Dispatch, D: DataControlHandler, D: 'static, { @@ -187,10 +181,8 @@ mod handlers { } } - impl Dispatch2 for ExtDataControlManagerUserData + impl Dispatch for ExtDataControlManagerUserData where - D: Dispatch, - D: Dispatch, D: DataControlHandler, D: 'static, { diff --git a/src/wayland/selection/ext_data_control/source.rs b/src/wayland/selection/ext_data_control/source.rs index 4c05b1199d9b..9babb4959dbc 100644 --- a/src/wayland/selection/ext_data_control/source.rs +++ b/src/wayland/selection/ext_data_control/source.rs @@ -1,11 +1,10 @@ use std::cell::RefCell; use std::sync::Mutex; -use wayland_server::DisplayHandle; use wayland_server::backend::ClientId; +use wayland_server::{Dispatch, DisplayHandle}; use crate::input::Seat; -use crate::wayland::Dispatch2; use crate::wayland::selection::SelectionTarget; use crate::wayland::selection::offer::OfferReplySource; use crate::wayland::selection::seat_data::SeatData; @@ -40,7 +39,7 @@ pub struct SourceMetadata { pub mime_types: Vec, } -impl Dispatch2 for ExtDataControlSourceUserData +impl Dispatch for ExtDataControlSourceUserData where D: DataControlHandler, D: 'static, @@ -64,7 +63,7 @@ where } } - fn destroyed(&self, state: &mut D, _client: ClientId, source: &ExtDataControlSourceV1) { + fn destroyed(&self, state: &mut D, _client: &ClientId, source: &ExtDataControlSourceV1) { // Remove the source from the used ones. let seat = match state .data_control_state() diff --git a/src/wayland/selection/offer.rs b/src/wayland/selection/offer.rs index 86f16aead377..6bcfe52d0782 100644 --- a/src/wayland/selection/offer.rs +++ b/src/wayland/selection/offer.rs @@ -1,4 +1,3 @@ -use std::os::unix::io::OwnedFd; use std::sync::Arc; use tracing::debug; @@ -13,7 +12,7 @@ use wayland_protocols_wlr::data_control::v1::server::zwlr_data_control_offer_v1: }; use wayland_server::DisplayHandle; use wayland_server::backend::ObjectId; -use wayland_server::backend::protocol::Message; +use wayland_server::backend::protocol::OwnedMessage; use wayland_server::backend::{ClientId, Handle, ObjectData}; use wayland_server::protocol::wl_data_offer; use wayland_server::protocol::wl_seat::WlSeat; @@ -68,7 +67,7 @@ impl SelectionOffer { pub fn new( dh: &DisplayHandle, device: &SelectionDevice, - client_id: ClientId, + client_id: &ClientId, data: OfferReplySource, ) -> Self where @@ -127,8 +126,8 @@ where self: Arc, dh: &Handle, handle: &mut D, - _: ClientId, - msg: Message, + _: &ClientId, + msg: OwnedMessage, ) -> Option>> { let dh = DisplayHandle::from(dh.clone()); @@ -192,5 +191,5 @@ where None } - fn destroyed(self: Arc, _: &Handle, _: &mut D, _: ClientId, _: ObjectId) {} + fn destroyed(self: Arc, _: &Handle, _: &mut D, _: &ClientId, _: &ObjectId) {} } diff --git a/src/wayland/selection/primary_selection/device.rs b/src/wayland/selection/primary_selection/device.rs index 5d10d16258d8..4a6e1cb483ec 100644 --- a/src/wayland/selection/primary_selection/device.rs +++ b/src/wayland/selection/primary_selection/device.rs @@ -4,12 +4,11 @@ use tracing::debug; use wayland_protocols::wp::primary_selection::zv1::server::zwp_primary_selection_device_v1::{ self as primary_device, ZwpPrimarySelectionDeviceV1 as PrimaryDevice, }; -use wayland_server::{Client, DataInit, DisplayHandle, Resource, protocol::wl_seat::WlSeat}; +use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, Resource, protocol::wl_seat::WlSeat}; use crate::{ input::{Seat, SeatHandler}, wayland::{ - Dispatch2, seat::WaylandFocus, selection::{ SelectionHandler, SelectionTarget, @@ -29,7 +28,7 @@ pub struct PrimaryDeviceUserData { pub(crate) wl_seat: WlSeat, } -impl Dispatch2 for PrimaryDeviceUserData +impl Dispatch for PrimaryDeviceUserData where D: PrimarySelectionHandler, D: SelectionHandler, @@ -106,7 +105,7 @@ where fn destroyed( &self, _state: &mut D, - _client: wayland_server::backend::ClientId, + _client: &wayland_server::backend::ClientId, resource: &PrimaryDevice, ) { if let Some(seat) = Seat::::from_resource(&self.wl_seat) { diff --git a/src/wayland/selection/primary_selection/mod.rs b/src/wayland/selection/primary_selection/mod.rs index 73a3b03b3c02..0c85bf6ce277 100644 --- a/src/wayland/selection/primary_selection/mod.rs +++ b/src/wayland/selection/primary_selection/mod.rs @@ -66,8 +66,6 @@ //! // ... override default implementations here to customize handling ... //! } //! -//! delegate_dispatch2!(State); -//! //! // You're now ready to go! //! ``` @@ -83,11 +81,11 @@ use wayland_protocols::wp::primary_selection::zv1::{ }; use wayland_server::backend::GlobalId; use wayland_server::protocol::wl_seat::WlSeat; -use wayland_server::{Client, DisplayHandle, GlobalDispatch}; +use wayland_server::{Client, DisplayHandle}; use crate::{ input::{Seat, SeatHandler}, - wayland::selection::SelectionTarget, + wayland::{seat::WaylandFocus, selection::SelectionTarget}, }; mod device; @@ -129,8 +127,9 @@ impl PrimarySelectionState { /// Register new [`PrimaryDeviceManager`] global pub fn new(display: &DisplayHandle) -> Self where - D: GlobalDispatch + 'static, - D: PrimarySelectionHandler, + D: PrimarySelectionHandler + 'static, + ::PointerFocus: WaylandFocus, + ::KeyboardFocus: WaylandFocus, { Self::new_with_filter::(display, |_| true) } @@ -140,8 +139,9 @@ impl PrimarySelectionState { /// Filters can be used to limit visibility of a global to certain clients. pub fn new_with_filter(display: &DisplayHandle, filter: F) -> Self where - D: GlobalDispatch + 'static, - D: PrimarySelectionHandler, + D: PrimarySelectionHandler + 'static, + ::PointerFocus: WaylandFocus, + ::KeyboardFocus: WaylandFocus, F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, { let data = PrimaryDeviceManagerGlobalData { @@ -307,19 +307,16 @@ mod handlers { use std::cell::RefCell; use tracing::error; - use wayland_protocols::wp::primary_selection::zv1::server::{ - zwp_primary_selection_device_manager_v1::{ - self as primary_device_manager, ZwpPrimarySelectionDeviceManagerV1 as PrimaryDeviceManager, - }, - zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1 as PrimaryDevice, - zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1 as PrimarySource, + use wayland_protocols::wp::primary_selection::zv1::server::zwp_primary_selection_device_manager_v1::{ + self as primary_device_manager, ZwpPrimarySelectionDeviceManagerV1 as PrimaryDeviceManager, }; - use wayland_server::{Dispatch, DisplayHandle}; + use wayland_server::{Dispatch, DisplayHandle, GlobalDispatch}; use crate::{ input::{Seat, SeatHandler}, wayland::{ - Dispatch2, GlobalData, GlobalDispatch2, + GlobalData, + seat::WaylandFocus, selection::{device::SelectionDevice, seat_data::SeatData}, }, }; @@ -329,12 +326,10 @@ mod handlers { PrimaryDeviceManagerGlobalData, device::PrimaryDeviceUserData, source::PrimarySourceUserData, }; - impl GlobalDispatch2 for PrimaryDeviceManagerGlobalData + impl GlobalDispatch for PrimaryDeviceManagerGlobalData where - D: Dispatch, - D: Dispatch, - D: Dispatch, D: PrimarySelectionHandler, + ::KeyboardFocus: WaylandFocus, D: 'static, { fn bind( @@ -353,12 +348,11 @@ mod handlers { } } - impl Dispatch2 for GlobalData + impl Dispatch for GlobalData where - D: Dispatch, - D: Dispatch, D: PrimarySelectionHandler, D: SeatHandler, + ::KeyboardFocus: WaylandFocus, D: 'static, { fn request( diff --git a/src/wayland/selection/primary_selection/source.rs b/src/wayland/selection/primary_selection/source.rs index cb0fbcbd770f..e00014311cc7 100644 --- a/src/wayland/selection/primary_selection/source.rs +++ b/src/wayland/selection/primary_selection/source.rs @@ -3,14 +3,11 @@ use std::{cell::RefCell, sync::Mutex}; use wayland_protocols::wp::primary_selection::zv1::server::zwp_primary_selection_source_v1::{ self as primary_source, ZwpPrimarySelectionSourceV1 as PrimarySource, }; -use wayland_server::{DisplayHandle, backend::ClientId}; +use wayland_server::{Dispatch, DisplayHandle, backend::ClientId}; use crate::{ input::Seat, - wayland::{ - Dispatch2, - selection::{offer::OfferReplySource, seat_data::SeatData, source::SelectionSourceProvider}, - }, + wayland::selection::{offer::OfferReplySource, seat_data::SeatData, source::SelectionSourceProvider}, }; use super::PrimarySelectionHandler; @@ -38,7 +35,7 @@ impl PrimarySourceUserData { } } -impl Dispatch2 for PrimarySourceUserData +impl Dispatch for PrimarySourceUserData where D: PrimarySelectionHandler, D: 'static, @@ -64,7 +61,7 @@ where } } - fn destroyed(&self, state: &mut D, _client: ClientId, source: &PrimarySource) { + fn destroyed(&self, state: &mut D, _client: &ClientId, source: &PrimarySource) { // Remove the source from the used ones. let seat = match state .primary_selection_state() diff --git a/src/wayland/selection/seat_data.rs b/src/wayland/selection/seat_data.rs index effe84aff355..76924f3d112e 100644 --- a/src/wayland/selection/seat_data.rs +++ b/src/wayland/selection/seat_data.rs @@ -184,12 +184,12 @@ impl SeatData { // the currently focused one as a client. let client_id = match device { SelectionDevice::WlrDataControl(device) => { - dh.get_client(device.id()).ok().map(|c| c.id()) + dh.get_client(device.id()).ok().map(|c| c.id().clone()) } SelectionDevice::ExtDataControl(device) => { - dh.get_client(device.id()).ok().map(|c| c.id()) + dh.get_client(device.id()).ok().map(|c| c.id().clone()) } - _ => client.map(|c| c.id()), + _ => client.map(|c| c.id().clone()), }; let client_id = match client_id { @@ -197,7 +197,7 @@ impl SeatData { None => continue, }; - let offer = SelectionOffer::new::(dh, device, client_id, selection.clone()); + let offer = SelectionOffer::new::(dh, device, &client_id, selection.clone()); device.offer(&offer); diff --git a/src/wayland/selection/wlr_data_control/device.rs b/src/wayland/selection/wlr_data_control/device.rs index 6048dd19b9f9..4420a6164dc2 100644 --- a/src/wayland/selection/wlr_data_control/device.rs +++ b/src/wayland/selection/wlr_data_control/device.rs @@ -5,10 +5,9 @@ use wayland_protocols_wlr::data_control::v1::server::zwlr_data_control_device_v1 self, ZwlrDataControlDeviceV1, }; use wayland_server::protocol::wl_seat::WlSeat; -use wayland_server::{Client, DisplayHandle, Resource}; +use wayland_server::{Client, Dispatch, DisplayHandle, Resource}; use crate::input::Seat; -use crate::wayland::Dispatch2; use crate::wayland::selection::device::SelectionDevice; use crate::wayland::selection::offer::OfferReplySource; use crate::wayland::selection::seat_data::SeatData; @@ -24,7 +23,7 @@ pub struct DataControlDeviceUserData { pub(crate) wl_seat: WlSeat, } -impl Dispatch2 for DataControlDeviceUserData +impl Dispatch for DataControlDeviceUserData where D: DataControlHandler, D: 'static, @@ -134,7 +133,7 @@ where fn destroyed( &self, _state: &mut D, - _client: wayland_server::backend::ClientId, + _client: &wayland_server::backend::ClientId, resource: &ZwlrDataControlDeviceV1, ) { if let Some(seat) = Seat::::from_resource(&self.wl_seat) { diff --git a/src/wayland/selection/wlr_data_control/mod.rs b/src/wayland/selection/wlr_data_control/mod.rs index 00748892f05a..ddea29e2fa01 100644 --- a/src/wayland/selection/wlr_data_control/mod.rs +++ b/src/wayland/selection/wlr_data_control/mod.rs @@ -48,8 +48,6 @@ //! // ... override default implementations here to customize handling ... //! } //! -//! smithay::delegate_dispatch2!(State); -//! //! // You're now ready to go! //! ``` //! @@ -63,7 +61,7 @@ use wayland_protocols_wlr::data_control::v1::server::zwlr_data_control_manager_v use wayland_protocols_wlr::data_control::v1::server::zwlr_data_control_source_v1::ZwlrDataControlSourceV1; use wayland_server::backend::GlobalId; use wayland_server::protocol::wl_seat::WlSeat; -use wayland_server::{Client, DisplayHandle, GlobalDispatch}; +use wayland_server::{Client, DisplayHandle}; mod device; mod source; @@ -101,7 +99,7 @@ impl DataControlState { filter: F, ) -> Self where - D: GlobalDispatch + 'static, + D: DataControlHandler + 'static, F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, { let data = DataControlManagerGlobalData { @@ -146,17 +144,16 @@ mod handlers { use std::sync::Arc; use tracing::error; - use wayland_protocols_wlr::data_control::v1::server::zwlr_data_control_device_v1::ZwlrDataControlDeviceV1; + use wayland_protocols_wlr::data_control::v1::server::zwlr_data_control_manager_v1; use wayland_protocols_wlr::data_control::v1::server::zwlr_data_control_manager_v1::ZwlrDataControlManagerV1; - use wayland_protocols_wlr::data_control::v1::server::zwlr_data_control_source_v1::ZwlrDataControlSourceV1; - use wayland_server::{Client, Dispatch, DisplayHandle}; + + use wayland_server::{Client, Dispatch, DisplayHandle, GlobalDispatch}; use crate::input::Seat; use crate::wayland::selection::SelectionTarget; use crate::wayland::selection::device::SelectionDevice; use crate::wayland::selection::seat_data::SeatData; - use crate::wayland::{Dispatch2, GlobalDispatch2}; use super::DataControlDeviceUserData; use super::DataControlHandler; @@ -164,11 +161,8 @@ mod handlers { use super::DataControlManagerUserData; use super::DataControlSourceUserData; - impl GlobalDispatch2 for DataControlManagerGlobalData + impl GlobalDispatch for DataControlManagerGlobalData where - D: Dispatch, - D: Dispatch, - D: Dispatch, D: DataControlHandler, D: 'static, { @@ -193,10 +187,8 @@ mod handlers { } } - impl Dispatch2 for DataControlManagerUserData + impl Dispatch for DataControlManagerUserData where - D: Dispatch, - D: Dispatch, D: DataControlHandler, D: 'static, { diff --git a/src/wayland/selection/wlr_data_control/source.rs b/src/wayland/selection/wlr_data_control/source.rs index b9fbeb0fb207..7fd8d79b1462 100644 --- a/src/wayland/selection/wlr_data_control/source.rs +++ b/src/wayland/selection/wlr_data_control/source.rs @@ -4,11 +4,10 @@ use std::sync::Mutex; use wayland_protocols_wlr::data_control::v1::server::zwlr_data_control_source_v1::{ self, ZwlrDataControlSourceV1, }; -use wayland_server::DisplayHandle; use wayland_server::backend::ClientId; +use wayland_server::{Dispatch, DisplayHandle}; use crate::input::Seat; -use crate::wayland::Dispatch2; use crate::wayland::selection::SelectionTarget; use crate::wayland::selection::offer::OfferReplySource; use crate::wayland::selection::seat_data::SeatData; @@ -39,7 +38,7 @@ pub struct SourceMetadata { pub mime_types: Vec, } -impl Dispatch2 for DataControlSourceUserData +impl Dispatch for DataControlSourceUserData where D: DataControlHandler, D: 'static, @@ -63,7 +62,7 @@ where } } - fn destroyed(&self, state: &mut D, _client: ClientId, source: &ZwlrDataControlSourceV1) { + fn destroyed(&self, state: &mut D, _client: &ClientId, source: &ZwlrDataControlSourceV1) { // Remove the source from the used ones. let seat = match state .data_control_state() diff --git a/src/wayland/session_lock/lock.rs b/src/wayland/session_lock/lock.rs index e7430a9e3816..66655811fc97 100644 --- a/src/wayland/session_lock/lock.rs +++ b/src/wayland/session_lock/lock.rs @@ -5,13 +5,11 @@ use std::sync::{Arc, Mutex}; use crate::wayland::compositor::SurfaceAttributes; use crate::wayland::compositor::{self, BufferAssignment}; -use _session_lock::ext_session_lock_surface_v1::ExtSessionLockSurfaceV1; use _session_lock::ext_session_lock_v1::{Error, ExtSessionLockV1, Request}; use wayland_protocols::ext::session_lock::v1::server::{self as _session_lock}; use wayland_server::protocol::wl_output::WlOutput; use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, Resource}; -use crate::wayland::Dispatch2; use crate::wayland::session_lock::surface::{ExtLockSurfaceUserData, LockSurface, LockSurfaceAttributes}; use crate::wayland::session_lock::{LockStatus, SessionLockHandler}; @@ -34,11 +32,9 @@ impl SessionLockState { } } -impl Dispatch2 for SessionLockState +impl Dispatch for SessionLockState where - D: Dispatch, - D: SessionLockHandler, - D: 'static, + D: SessionLockHandler + 'static, { fn request( &self, @@ -133,7 +129,7 @@ where } } - fn destroyed(&self, state: &mut D, _client: wayland_server::backend::ClientId, lock: &ExtSessionLockV1) { + fn destroyed(&self, state: &mut D, _client: &wayland_server::backend::ClientId, lock: &ExtSessionLockV1) { let mut lock_status = state.lock_state().lock_status.lock().unwrap(); if lock_status.is_locked_by(lock) { // The client has disconnected without unlocking the session, so reset our state. It diff --git a/src/wayland/session_lock/mod.rs b/src/wayland/session_lock/mod.rs index 6ac4f8d3550a..c4f155fb8df2 100644 --- a/src/wayland/session_lock/mod.rs +++ b/src/wayland/session_lock/mod.rs @@ -43,8 +43,6 @@ //! } //! } //! -//! smithay::delegate_dispatch2!(State); -//! //! // You're now ready to go! //! ``` @@ -58,7 +56,7 @@ use wayland_server::protocol::wl_output::WlOutput; use wayland_server::protocol::wl_surface::WlSurface; use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New}; -use crate::wayland::{Dispatch2, GlobalData, GlobalDispatch2}; +use crate::wayland::GlobalData; mod lock; mod surface; @@ -97,11 +95,7 @@ impl SessionLockManagerState { /// Create new [`ExtSessionLockManagerV1`] global. pub fn new(display: &DisplayHandle, filter: F) -> Self where - D: GlobalDispatch, - D: Dispatch, - D: Dispatch, - D: SessionLockHandler, - D: 'static, + D: SessionLockHandler + 'static, F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, { let data = SessionLockManagerGlobalData { @@ -122,11 +116,9 @@ pub struct SessionLockManagerGlobalData { filter: Box Fn(&'c Client) -> bool + Send + Sync>, } -impl GlobalDispatch2 for SessionLockManagerGlobalData +impl GlobalDispatch for SessionLockManagerGlobalData where - D: Dispatch, - D: SessionLockHandler, - D: 'static, + D: SessionLockHandler + 'static, { fn bind( &self, @@ -144,11 +136,9 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, - D: SessionLockHandler, - D: 'static, + D: SessionLockHandler + 'static, { fn request( &self, diff --git a/src/wayland/session_lock/surface.rs b/src/wayland/session_lock/surface.rs index 490047e0eb88..53de4ac768d7 100644 --- a/src/wayland/session_lock/surface.rs +++ b/src/wayland/session_lock/surface.rs @@ -12,9 +12,8 @@ use tracing::trace_span; use wayland_protocols::ext::session_lock::v1::server::ext_session_lock_v1::ExtSessionLockV1; use wayland_protocols::ext::session_lock::v1::server::{self as _session_lock, ext_session_lock_surface_v1}; use wayland_server::protocol::wl_surface::WlSurface; -use wayland_server::{Client, DataInit, DisplayHandle, Resource, Weak}; +use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, Resource, Weak}; -use crate::wayland::Dispatch2; use crate::wayland::session_lock::SessionLockHandler; /// User data for ext-session-lock surfaces. @@ -27,7 +26,7 @@ pub struct ExtLockSurfaceUserData { pub(super) done: Arc, } -impl Dispatch2 for ExtLockSurfaceUserData +impl Dispatch for ExtLockSurfaceUserData where D: SessionLockHandler, D: 'static, @@ -74,7 +73,7 @@ where fn destroyed( &self, _state: &mut D, - _client: wayland_server::backend::ClientId, + _client: &wayland_server::backend::ClientId, _resource: &ExtSessionLockSurfaceV1, ) { if let Ok(surface) = self.surface.upgrade() { diff --git a/src/wayland/shell/kde/decoration.rs b/src/wayland/shell/kde/decoration.rs index 2bb4dc3a1315..02ec326190c0 100644 --- a/src/wayland/shell/kde/decoration.rs +++ b/src/wayland/shell/kde/decoration.rs @@ -26,8 +26,6 @@ //! &self.kde_decoration_state //! } //! } -//! -//! smithay::delegate_dispatch2!(State); //! ``` use wayland_protocols_misc::server_decoration::server::org_kde_kwin_server_decoration::{ @@ -38,9 +36,7 @@ use wayland_protocols_misc::server_decoration::server::org_kde_kwin_server_decor }; use wayland_server::backend::GlobalId; use wayland_server::protocol::wl_surface::WlSurface; -use wayland_server::{Client, Dispatch, DisplayHandle, GlobalDispatch, WEnum}; - -use crate::wayland::GlobalData; +use wayland_server::{Client, DisplayHandle}; /// KDE server decoration handler. pub trait KdeDecorationHandler { @@ -61,15 +57,8 @@ pub trait KdeDecorationHandler { /// **It is up to the compositor to prevent feedback loops**, a client is free to ignore modes /// suggested by [`OrgKdeKwinServerDecoration::mode`] and instead request their preferred mode /// instead. - fn request_mode( - &mut self, - _surface: &WlSurface, - decoration: &OrgKdeKwinServerDecoration, - mode: WEnum, - ) { - if let WEnum::Value(mode) = mode { - decoration.mode(mode); - } + fn request_mode(&mut self, _surface: &WlSurface, decoration: &OrgKdeKwinServerDecoration, mode: Mode) { + decoration.mode(mode); } /// Handle decoration object removal for a surface. @@ -98,11 +87,7 @@ impl KdeDecorationState { /// Create a new KDE server decoration global. pub fn new(display: &DisplayHandle, default_mode: DefaultMode) -> Self where - D: GlobalDispatch - + Dispatch - + Dispatch - + KdeDecorationHandler - + 'static, + D: KdeDecorationHandler + 'static, { Self::new_with_filter::(display, default_mode, |_| true) } @@ -112,11 +97,7 @@ impl KdeDecorationState { /// Filters can be used to limit visibility of a global to certain clients. pub fn new_with_filter(display: &DisplayHandle, default_mode: DefaultMode, filter: F) -> Self where - D: GlobalDispatch - + Dispatch - + Dispatch - + KdeDecorationHandler - + 'static, + D: KdeDecorationHandler + 'static, F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, { let data = KdeDecorationManagerGlobalData { diff --git a/src/wayland/shell/kde/handlers.rs b/src/wayland/shell/kde/handlers.rs index ebb100e64ebe..0ab532ae8b96 100644 --- a/src/wayland/shell/kde/handlers.rs +++ b/src/wayland/shell/kde/handlers.rs @@ -7,19 +7,16 @@ use wayland_protocols_misc::server_decoration::server::org_kde_kwin_server_decor use wayland_protocols_misc::server_decoration::server::org_kde_kwin_server_decoration_manager::{ OrgKdeKwinServerDecorationManager, Request as ManagerRequest, }; -use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, New, Resource}; +use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource}; +use crate::wayland::GlobalData; use crate::wayland::shell::kde::decoration::KdeDecorationHandler; -use crate::wayland::{Dispatch2, GlobalData, GlobalDispatch2}; use super::decoration::{KdeDecorationManagerGlobalData, KwinServerDecorationData}; -impl GlobalDispatch2 for KdeDecorationManagerGlobalData +impl GlobalDispatch for KdeDecorationManagerGlobalData where - D: Dispatch - + Dispatch - + KdeDecorationHandler - + 'static, + D: KdeDecorationHandler + 'static, { fn bind( &self, @@ -43,9 +40,9 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch + KdeDecorationHandler + 'static, + D: KdeDecorationHandler + 'static, { fn request( &self, @@ -70,7 +67,7 @@ where } } -impl Dispatch2 for KwinServerDecorationData +impl Dispatch for KwinServerDecorationData where D: KdeDecorationHandler + 'static, { diff --git a/src/wayland/shell/wlr_layer/handlers.rs b/src/wayland/shell/wlr_layer/handlers.rs index fc9a40cf687e..6bf5570b9bcc 100644 --- a/src/wayland/shell/wlr_layer/handlers.rs +++ b/src/wayland/shell/wlr_layer/handlers.rs @@ -4,14 +4,14 @@ use wayland_protocols_wlr::layer_shell::v1::server::zwlr_layer_shell_v1::{self, use wayland_protocols_wlr::layer_shell::v1::server::zwlr_layer_surface_v1; use wayland_protocols_wlr::layer_shell::v1::server::zwlr_layer_surface_v1::ZwlrLayerSurfaceV1; use wayland_server::protocol::wl_surface; -use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, Resource, Weak}; +use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, Resource, Weak}; use crate::utils::{ Serial, alive_tracker::{AliveTracker, IsAlive}, }; use crate::wayland::shell::xdg::XdgPopupSurfaceData; -use crate::wayland::{Dispatch2, GlobalData, GlobalDispatch2, compositor, shell::wlr_layer::Layer}; +use crate::wayland::{GlobalData, compositor, shell::wlr_layer::Layer}; use super::{ Anchor, KeyboardInteractivity, LayerSurfaceAttributes, LayerSurfaceCachedState, LayerSurfaceData, @@ -24,10 +24,8 @@ use super::LAYER_SURFACE_ROLE; * layer_shell */ -impl GlobalDispatch2 for WlrLayerShellGlobalData +impl GlobalDispatch for WlrLayerShellGlobalData where - D: Dispatch, - D: Dispatch, D: WlrLayerShellHandler, D: 'static, { @@ -47,9 +45,8 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, D: WlrLayerShellHandler, D: 'static, { @@ -171,7 +168,7 @@ impl IsAlive for ZwlrLayerSurfaceV1 { } } -impl Dispatch2 for WlrLayerSurfaceUserData +impl Dispatch for WlrLayerSurfaceUserData where D: WlrLayerShellHandler, { @@ -334,7 +331,7 @@ where fn destroyed( &self, state: &mut D, - _client_id: wayland_server::backend::ClientId, + _client_id: &wayland_server::backend::ClientId, layer_surface: &ZwlrLayerSurfaceV1, ) { self.alive_tracker.destroy_notify(); diff --git a/src/wayland/shell/wlr_layer/mod.rs b/src/wayland/shell/wlr_layer/mod.rs index 8e3d3ce214f1..8e027f15bae5 100644 --- a/src/wayland/shell/wlr_layer/mod.rs +++ b/src/wayland/shell/wlr_layer/mod.rs @@ -39,8 +39,6 @@ //! } //! } //! -//! smithay::delegate_dispatch2!(State); -//! //! // You're now ready to go! //! ``` @@ -51,7 +49,7 @@ use wayland_protocols_wlr::layer_shell::v1::server::{ zwlr_layer_shell_v1::ZwlrLayerShellV1, zwlr_layer_surface_v1, }; use wayland_server::{ - Client, DisplayHandle, GlobalDispatch, Resource as _, + Client, DisplayHandle, Resource as _, backend::GlobalId, protocol::{wl_output::WlOutput, wl_surface}, }; @@ -216,8 +214,7 @@ impl WlrLayerShellState { /// Create a new `wlr_layer_shell` global pub fn new(display: &DisplayHandle) -> WlrLayerShellState where - D: GlobalDispatch, - D: 'static, + D: WlrLayerShellHandler + 'static, { Self::new_with_filter::(display, |_| true) } @@ -225,8 +222,7 @@ impl WlrLayerShellState { /// Create a new `wlr_layer_shell` global with a client filter pub fn new_with_filter(display: &DisplayHandle, filter: F) -> WlrLayerShellState where - D: GlobalDispatch, - D: 'static, + D: WlrLayerShellHandler + 'static, F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, { let shell_global = display.create_global::( diff --git a/src/wayland/shell/wlr_layer/types.rs b/src/wayland/shell/wlr_layer/types.rs index 6847012a551d..7fe8643d3b1b 100644 --- a/src/wayland/shell/wlr_layer/types.rs +++ b/src/wayland/shell/wlr_layer/types.rs @@ -1,7 +1,6 @@ use std::cmp::Ordering; use wayland_protocols_wlr::layer_shell::v1::server::{zwlr_layer_shell_v1, zwlr_layer_surface_v1}; -use wayland_server::WEnum; /// Available layers for surfaces /// @@ -22,18 +21,18 @@ pub enum Layer { Overlay, } -impl TryFrom> for Layer { +impl TryFrom for Layer { type Error = (zwlr_layer_shell_v1::Error, String); #[inline] - fn try_from(layer: WEnum) -> Result { + fn try_from(layer: zwlr_layer_shell_v1::Layer) -> Result { use zwlr_layer_shell_v1::Layer; match layer { - WEnum::Value(Layer::Background) => Ok(Self::Background), - WEnum::Value(Layer::Bottom) => Ok(Self::Bottom), - WEnum::Value(Layer::Top) => Ok(Self::Top), - WEnum::Value(Layer::Overlay) => Ok(Self::Overlay), + Layer::Background => Ok(Self::Background), + Layer::Bottom => Ok(Self::Bottom), + Layer::Top => Ok(Self::Top), + Layer::Overlay => Ok(Self::Overlay), layer => Err(( zwlr_layer_shell_v1::Error::InvalidLayer, format!("invalid layer: {layer:?}"), @@ -100,17 +99,17 @@ impl Default for KeyboardInteractivity { } } -impl TryFrom> for KeyboardInteractivity { +impl TryFrom for KeyboardInteractivity { type Error = (zwlr_layer_surface_v1::Error, String); #[inline] - fn try_from(ki: WEnum) -> Result { + fn try_from(ki: zwlr_layer_surface_v1::KeyboardInteractivity) -> Result { use zwlr_layer_surface_v1::KeyboardInteractivity; match ki { - WEnum::Value(KeyboardInteractivity::None) => Ok(Self::None), - WEnum::Value(KeyboardInteractivity::Exclusive) => Ok(Self::Exclusive), - WEnum::Value(KeyboardInteractivity::OnDemand) => Ok(Self::OnDemand), + KeyboardInteractivity::None => Ok(Self::None), + KeyboardInteractivity::Exclusive => Ok(Self::Exclusive), + KeyboardInteractivity::OnDemand => Ok(Self::OnDemand), ki => Err(( zwlr_layer_surface_v1::Error::InvalidKeyboardInteractivity, format!("wrong keyboard interactivity value: {ki:?}"), @@ -158,17 +157,12 @@ impl Default for Anchor { } } -impl TryFrom> for Anchor { +impl TryFrom for Anchor { type Error = (zwlr_layer_surface_v1::Error, String); #[inline] - fn try_from(anchor: WEnum) -> Result { - let a = if let WEnum::Value(anchor) = anchor { - Anchor::from_bits(anchor.bits()) - } else { - None - }; - + fn try_from(anchor: zwlr_layer_surface_v1::Anchor) -> Result { + let a = Anchor::from_bits(anchor.bits()); a.ok_or(( zwlr_layer_surface_v1::Error::InvalidAnchor, format!("invalid anchor {anchor:?}"), diff --git a/src/wayland/shell/xdg/decoration.rs b/src/wayland/shell/xdg/decoration.rs index 941a075a95cf..e0a34e2a171e 100644 --- a/src/wayland/shell/xdg/decoration.rs +++ b/src/wayland/shell/xdg/decoration.rs @@ -89,8 +89,6 @@ //! } //! # impl PointerConstraintsHandler for State {} //! -//! smithay::delegate_dispatch2!(State); -//! //! // You are ready to go! // TODO: Describe how to change decoration mode. @@ -99,11 +97,11 @@ use wayland_protocols::xdg::decoration::zv1::server::{ zxdg_toplevel_decoration_v1::{self, Mode}, }; use wayland_server::{ - Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, WEnum, backend::GlobalId, + Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, backend::GlobalId, }; use super::{ToplevelSurface, XdgShellHandler}; -use crate::wayland::{Dispatch2, GlobalData, GlobalDispatch2, shell::xdg::XdgShellSurfaceUserData}; +use crate::wayland::{GlobalData, shell::xdg::XdgShellSurfaceUserData}; /// Delegate type for handling xdg decoration events. #[derive(Debug)] @@ -123,11 +121,7 @@ impl XdgDecorationState { /// A global id is also returned to allow destroying the global in the future. pub fn new(display: &DisplayHandle) -> XdgDecorationState where - D: GlobalDispatch< - zxdg_decoration_manager_v1::ZxdgDecorationManagerV1, - XdgDecorationManagerGlobalData, - > + Dispatch - + 'static, + D: XdgDecorationHandler + 'static, { Self::new_with_filter::(display, |_| true) } @@ -139,11 +133,7 @@ impl XdgDecorationState { /// A global id is also returned to allow destroying the global in the future. pub fn new_with_filter(display: &DisplayHandle, filter: F) -> XdgDecorationState where - D: GlobalDispatch< - zxdg_decoration_manager_v1::ZxdgDecorationManagerV1, - XdgDecorationManagerGlobalData, - > + Dispatch - + 'static, + D: XdgDecorationHandler + 'static, F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, { let data = XdgDecorationManagerGlobalData { @@ -162,7 +152,7 @@ impl XdgDecorationState { } /// Handler trait for xdg decoration events. -pub trait XdgDecorationHandler { +pub trait XdgDecorationHandler: XdgShellHandler { /// Notification the client supports server side decoration on the toplevel. fn new_decoration(&mut self, toplevel: ToplevelSurface); @@ -180,14 +170,10 @@ pub(super) fn send_decoration_configure( id.configure(mode) } -impl GlobalDispatch2 +impl GlobalDispatch for XdgDecorationManagerGlobalData where - D: Dispatch - + Dispatch - + XdgShellHandler - + XdgDecorationHandler - + 'static, + D: XdgDecorationHandler + 'static, { fn bind( &self, @@ -205,12 +191,9 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch - + XdgShellHandler - + XdgDecorationHandler - + 'static, + D: XdgDecorationHandler + 'static, { fn request( &self, @@ -263,7 +246,7 @@ where // zxdg_toplevel_decoration_v1 -impl Dispatch2 for ToplevelSurface +impl Dispatch for ToplevelSurface where D: XdgDecorationHandler, { @@ -280,9 +263,7 @@ where match request { Request::SetMode { mode } => { - if let WEnum::Value(mode) = mode { - state.request_mode(self.clone(), mode); - } + state.request_mode(self.clone(), mode); } Request::UnsetMode => { diff --git a/src/wayland/shell/xdg/dialog.rs b/src/wayland/shell/xdg/dialog.rs index a845ac5e18e1..3d1dc030bce8 100644 --- a/src/wayland/shell/xdg/dialog.rs +++ b/src/wayland/shell/xdg/dialog.rs @@ -77,8 +77,6 @@ //! } //! # impl PointerConstraintsHandler for State {} //! -//! smithay::delegate_dispatch2!(State); -//! //! // You are ready to go! use wayland_protocols::xdg::dialog::v1::server::{ @@ -92,7 +90,7 @@ use wayland_server::{ use super::{ToplevelSurface, XdgShellHandler}; use crate::wayland::{ - Dispatch2, GlobalData, GlobalDispatch2, compositor, + GlobalData, compositor, shell::xdg::{XdgShellSurfaceUserData, XdgToplevelSurfaceData}, }; @@ -108,7 +106,7 @@ impl XdgDialogState { /// A global id is also returned to allow destroying the global in the future. pub fn new(display: &DisplayHandle) -> XdgDialogState where - D: GlobalDispatch + Dispatch + 'static, + D: XdgDialogHandler + 'static, { let global = display.create_global::(1, GlobalData); XdgDialogState { global } @@ -131,10 +129,7 @@ pub trait XdgDialogHandler: XdgShellHandler { // xdg_wm_dialog_v1 -impl GlobalDispatch2 for GlobalData -where - D: Dispatch, -{ +impl GlobalDispatch for GlobalData { fn bind( &self, _: &mut D, @@ -147,10 +142,7 @@ where } } -impl Dispatch2 for GlobalData -where - D: Dispatch, -{ +impl Dispatch for GlobalData { fn request( &self, state: &mut D, @@ -196,7 +188,7 @@ where // xdg_dialog_v1 -impl Dispatch2 for ToplevelSurface { +impl Dispatch for ToplevelSurface { fn request( &self, state: &mut D, diff --git a/src/wayland/shell/xdg/handlers/positioner.rs b/src/wayland/shell/xdg/handlers/positioner.rs index b8cfa10cbb1d..e54a8eb7f8bc 100644 --- a/src/wayland/shell/xdg/handlers/positioner.rs +++ b/src/wayland/shell/xdg/handlers/positioner.rs @@ -1,10 +1,10 @@ use std::sync::Mutex; -use crate::{utils::Rectangle, utils::Serial, wayland::Dispatch2}; +use crate::{utils::Rectangle, utils::Serial}; use wayland_protocols::xdg::shell::server::{xdg_positioner, xdg_positioner::XdgPositioner}; -use wayland_server::{DataInit, DisplayHandle, Resource, WEnum}; +use wayland_server::{DataInit, Dispatch, DisplayHandle, Resource}; use super::{PositionerState, XdgShellHandler}; @@ -18,7 +18,7 @@ pub struct XdgPositionerUserData { pub(crate) inner: Mutex, } -impl Dispatch2 for XdgPositionerUserData +impl Dispatch for XdgPositionerUserData where D: XdgShellHandler, D: 'static, @@ -55,21 +55,15 @@ where } } xdg_positioner::Request::SetAnchor { anchor } => { - if let WEnum::Value(anchor) = anchor { - state.anchor_edges = anchor; - } + state.anchor_edges = anchor; } xdg_positioner::Request::SetGravity { gravity } => { - if let WEnum::Value(gravity) = gravity { - state.gravity = gravity; - } + state.gravity = gravity; } xdg_positioner::Request::SetConstraintAdjustment { constraint_adjustment, } => { - if let WEnum::Value(constraint_adjustment) = constraint_adjustment { - state.constraint_adjustment = constraint_adjustment; - } + state.constraint_adjustment = constraint_adjustment; } xdg_positioner::Request::SetOffset { x, y } => { state.offset = (x, y).into(); diff --git a/src/wayland/shell/xdg/handlers/surface.rs b/src/wayland/shell/xdg/handlers/surface.rs index f046222dd918..bdafe5c81285 100644 --- a/src/wayland/shell/xdg/handlers/surface.rs +++ b/src/wayland/shell/xdg/handlers/surface.rs @@ -9,7 +9,7 @@ use crate::wayland::shell::xdg::{XdgPopupSurfaceData, XdgToplevelSurfaceData}; use crate::{ utils::{Rectangle, Serial}, wayland::{ - Dispatch2, compositor, + compositor, shell::xdg::{PopupState, XDG_POPUP_ROLE, XDG_TOPLEVEL_ROLE}, }, }; @@ -45,10 +45,8 @@ pub struct XdgSurfaceUserData { pub(crate) has_active_role: AtomicBool, } -impl Dispatch2 for XdgSurfaceUserData +impl Dispatch for XdgSurfaceUserData where - D: Dispatch, - D: Dispatch, D: XdgShellHandler, D: 'static, { diff --git a/src/wayland/shell/xdg/handlers/surface/popup.rs b/src/wayland/shell/xdg/handlers/surface/popup.rs index eb2cb5566e1d..e0da47df6ea7 100644 --- a/src/wayland/shell/xdg/handlers/surface/popup.rs +++ b/src/wayland/shell/xdg/handlers/surface/popup.rs @@ -3,7 +3,6 @@ use std::sync::atomic::Ordering; use crate::{ utils::Serial, wayland::{ - Dispatch2, compositor::{self, with_states}, shell::xdg::{PopupCachedState, SurfaceCachedState, XdgPopupSurfaceData, XdgPositionerUserData}, }, @@ -11,11 +10,11 @@ use crate::{ use wayland_protocols::xdg::shell::server::xdg_popup::{self, XdgPopup}; -use wayland_server::{DataInit, DisplayHandle, Resource, backend::ClientId}; +use wayland_server::{DataInit, Dispatch, DisplayHandle, Resource, backend::ClientId}; use super::{PopupConfigure, XdgShellHandler, XdgShellSurfaceUserData, XdgSurfaceUserData}; -impl Dispatch2 for XdgShellSurfaceUserData +impl Dispatch for XdgShellSurfaceUserData where D: XdgShellHandler, D: 'static, @@ -72,7 +71,7 @@ where } } - fn destroyed(&self, state: &mut D, _client_id: ClientId, xdg_popup: &XdgPopup) { + fn destroyed(&self, state: &mut D, _client_id: &ClientId, xdg_popup: &XdgPopup) { self.alive_tracker.destroy_notify(); // remove this surface from the known ones (as well as any leftover dead surface) diff --git a/src/wayland/shell/xdg/handlers/surface/toplevel.rs b/src/wayland/shell/xdg/handlers/surface/toplevel.rs index 41576b119fc2..a87c57f205d8 100644 --- a/src/wayland/shell/xdg/handlers/surface/toplevel.rs +++ b/src/wayland/shell/xdg/handlers/surface/toplevel.rs @@ -3,7 +3,7 @@ use std::sync::atomic::Ordering; use crate::{ utils::Serial, wayland::{ - Dispatch2, compositor, + compositor, shell::{ is_valid_parent, xdg::{ToplevelCachedState, XdgToplevelSurfaceData}, @@ -16,14 +16,14 @@ use wayland_protocols::xdg::{ shell::server::xdg_toplevel::{self, XdgToplevel}, }; -use wayland_server::{DataInit, DisplayHandle, Resource, WEnum, backend::ClientId, protocol::wl_surface}; +use wayland_server::{DataInit, Dispatch, DisplayHandle, Resource, backend::ClientId, protocol::wl_surface}; use super::{ SurfaceCachedState, ToplevelConfigure, XdgShellHandler, XdgShellSurfaceUserData, XdgSurfaceUserData, XdgToplevelSurfaceRoleAttributes, }; -impl Dispatch2 for XdgShellSurfaceUserData +impl Dispatch for XdgShellSurfaceUserData where D: XdgShellHandler, D: 'static, @@ -119,13 +119,11 @@ where XdgShellHandler::move_request(state, handle, seat, serial); } xdg_toplevel::Request::Resize { seat, serial, edges } => { - if let WEnum::Value(edges) = edges { - // This has to be handled by the compositor - let handle = make_toplevel_handle(toplevel); - let serial = Serial::from(serial); + // This has to be handled by the compositor + let handle = make_toplevel_handle(toplevel); + let serial = Serial::from(serial); - XdgShellHandler::resize_request(state, handle, seat, serial, edges); - } + XdgShellHandler::resize_request(state, handle, seat, serial, edges); } xdg_toplevel::Request::SetMaxSize { width, height } => { with_toplevel_pending_state(self, |toplevel_data| { @@ -163,7 +161,7 @@ where } } - fn destroyed(&self, state: &mut D, _client_id: ClientId, xdg_toplevel: &XdgToplevel) { + fn destroyed(&self, state: &mut D, _client_id: &ClientId, xdg_toplevel: &XdgToplevel) { self.alive_tracker.destroy_notify(); self.decoration.lock().unwrap().take(); @@ -298,11 +296,11 @@ pub fn send_toplevel_configure( ::std::mem::forget(capabilities); unsafe { Vec::from_raw_parts(ptr as *mut u8, len * 4, cap * 4) } }; - resource.wm_capabilities(capabilities); + resource.wm_capabilities(&capabilities); } // Send the toplevel configure - resource.configure(width, height, states); + resource.configure(width, height, &states); // Send the base xdg_surface configure event to mark // The configure as finished diff --git a/src/wayland/shell/xdg/handlers/wm_base.rs b/src/wayland/shell/xdg/handlers/wm_base.rs index 01dd898765f7..ba25a40ae2f0 100644 --- a/src/wayland/shell/xdg/handlers/wm_base.rs +++ b/src/wayland/shell/xdg/handlers/wm_base.rs @@ -4,22 +4,19 @@ use indexmap::IndexSet; use crate::{ utils::{IsAlive, Serial, alive_tracker::AliveTracker}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, + wayland::GlobalData, }; -use wayland_protocols::xdg::shell::server::{ - xdg_positioner::XdgPositioner, xdg_surface, xdg_surface::XdgSurface, xdg_wm_base, xdg_wm_base::XdgWmBase, -}; +use wayland_protocols::xdg::shell::server::{xdg_surface, xdg_wm_base, xdg_wm_base::XdgWmBase}; -use wayland_server::{DataInit, Dispatch, DisplayHandle, New, Resource, Weak, backend::ClientId}; +use wayland_server::{ + DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, Weak, backend::ClientId, +}; use super::{ShellClient, ShellClientData, XdgPositionerUserData, XdgShellHandler, XdgSurfaceUserData}; -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, - D: Dispatch, - D: Dispatch, D: XdgShellHandler, D: 'static, { @@ -37,10 +34,8 @@ where } } -impl Dispatch2 for XdgWmBaseUserData +impl Dispatch for XdgWmBaseUserData where - D: Dispatch, - D: Dispatch, D: XdgShellHandler, D: 'static, { @@ -102,7 +97,7 @@ where } } - fn destroyed(&self, state: &mut D, _client_id: ClientId, wm_base: &XdgWmBase) { + fn destroyed(&self, state: &mut D, _client_id: &ClientId, wm_base: &XdgWmBase) { XdgShellHandler::client_destroyed(state, ShellClient::new(wm_base)); self.alive_tracker.destroy_notify(); } diff --git a/src/wayland/shell/xdg/mod.rs b/src/wayland/shell/xdg/mod.rs index f9d78627125f..34c56d40731e 100644 --- a/src/wayland/shell/xdg/mod.rs +++ b/src/wayland/shell/xdg/mod.rs @@ -102,8 +102,6 @@ //! } //! # impl PointerConstraintsHandler for State {} //! -//! smithay::delegate_dispatch2!(State); -//! //! // You're now ready to go! //! ``` //! @@ -144,7 +142,7 @@ use wayland_protocols::xdg::shell::server::xdg_wm_base::XdgWmBase; use wayland_protocols::xdg::shell::server::{xdg_popup, xdg_positioner, xdg_toplevel, xdg_wm_base}; use wayland_server::backend::GlobalId; use wayland_server::{ - DisplayHandle, GlobalDispatch, Resource, + DisplayHandle, Resource, protocol::{wl_output, wl_seat, wl_surface}, }; @@ -954,7 +952,7 @@ impl ToplevelStateSet { } fn version_needed_for_state(state: &xdg_toplevel::State) -> u32 { - match state { + match *state { xdg_toplevel::State::TiledLeft | xdg_toplevel::State::TiledRight | xdg_toplevel::State::TiledTop @@ -1226,7 +1224,7 @@ impl XdgShellState { /// Create a new `xdg_shell` global with all [`WmCapabilities`](xdg_toplevel::WmCapabilities) pub fn new(display: &DisplayHandle) -> XdgShellState where - D: GlobalDispatch + 'static, + D: XdgShellHandler + 'static, { Self::new_with_capabilities::( display, @@ -1245,7 +1243,7 @@ impl XdgShellState { capabilities: impl Into, ) -> XdgShellState where - D: GlobalDispatch + 'static, + D: XdgShellHandler + 'static, { let global = display.create_global::(7, GlobalData); diff --git a/src/wayland/shm/handlers.rs b/src/wayland/shm/handlers.rs index 7de3c66c3c9d..6016b3d08ad3 100644 --- a/src/wayland/shm/handlers.rs +++ b/src/wayland/shm/handlers.rs @@ -1,5 +1,5 @@ use crate::wayland::{ - Dispatch2, GlobalData, GlobalDispatch2, + GlobalData, buffer::BufferHandler, shm::{ShmBufferUserData, wl_bytes_per_pixel}, }; @@ -11,7 +11,7 @@ use super::{ use std::{num::NonZeroUsize, os::unix::io::AsRawFd, sync::Arc}; use wayland_server::{ - DataInit, Dispatch, DisplayHandle, New, Resource, WEnum, + DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, backend::ClientId, protocol::{ wl_buffer, @@ -20,10 +20,8 @@ use wayland_server::{ }, }; -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, - D: Dispatch, D: ShmHandler, D: 'static, { @@ -44,9 +42,9 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch + ShmHandler + 'static, + D: ShmHandler + 'static, { fn request( &self, @@ -94,9 +92,9 @@ where * wl_shm_pool */ -impl Dispatch2 for ShmPoolUserData +impl Dispatch for ShmPoolUserData where - D: Dispatch + BufferHandler + ShmHandler + 'static, + D: ShmHandler + 'static, { fn request( &self, @@ -147,39 +145,28 @@ where return; } - match format { - WEnum::Value(format) => { - if !state.shm_state().formats.contains(&format) { - pool.post_error( - wl_shm::Error::InvalidFormat, - format!("format {format:?} not supported"), - ); + if !state.shm_state().formats.contains(&format) { + pool.post_error( + wl_shm::Error::InvalidFormat, + format!("format {format:?} not supported"), + ); - return; - } + return; + } - let data = ShmBufferUserData { - pool: arc_pool.clone(), - data: BufferData { - offset, - width, - height, - stride, - format, - }, - destruction_hooks: Default::default(), - }; - - data_init.init(buffer, data); - } + let data = ShmBufferUserData { + pool: arc_pool.clone(), + data: BufferData { + offset, + width, + height, + stride, + format, + }, + destruction_hooks: Default::default(), + }; - WEnum::Unknown(unknown) => { - pool.post_error( - wl_shm::Error::InvalidFormat, - format!("unknown format 0x{unknown:x}"), - ); - } - } + data_init.init(buffer, data); } Request::Resize { size } => { @@ -207,7 +194,7 @@ where } } -impl Dispatch2 for ShmBufferUserData +impl Dispatch for ShmBufferUserData where D: BufferHandler, D: 'static, @@ -230,7 +217,7 @@ where } } - fn destroyed(&self, data: &mut D, _client: ClientId, buffer: &wl_buffer::WlBuffer) { + fn destroyed(&self, data: &mut D, _client: &ClientId, buffer: &wl_buffer::WlBuffer) { // Clone to drop the mutex guard let destruction_hooks = self.destruction_hooks.lock().unwrap().clone(); for hook in destruction_hooks.iter() { diff --git a/src/wayland/shm/mod.rs b/src/wayland/shm/mod.rs index aee6f96799cb..8acc6e33ba30 100644 --- a/src/wayland/shm/mod.rs +++ b/src/wayland/shm/mod.rs @@ -48,8 +48,6 @@ //! &self.shm_state //! } //! } -//! -//! smithay::delegate_dispatch2!(State); //! ``` //! //! Then, when you have a [`WlBuffer`](wayland_server::protocol::wl_buffer::WlBuffer) @@ -102,12 +100,11 @@ use std::{ }; use wayland_server::{ - Dispatch, DisplayHandle, GlobalDispatch, Resource, WEnum, + DisplayHandle, Resource, backend::GlobalId, protocol::{ wl_buffer, wl_shm::{self, WlShm}, - wl_shm_pool::WlShmPool, }, }; @@ -142,12 +139,7 @@ impl ShmState { /// remove this global in the future. pub fn new(display: &DisplayHandle, formats: impl IntoIterator) -> ShmState where - D: GlobalDispatch - + Dispatch - + Dispatch - + BufferHandler - + ShmHandler - + 'static, + D: ShmHandler + 'static, { let mut formats = formats.into_iter().collect::>(); @@ -182,7 +174,7 @@ impl ShmState { } /// Shm global handler -pub trait ShmHandler { +pub trait ShmHandler: BufferHandler { /// Return the Shm global state fn shm_state(&self) -> &ShmState; } @@ -298,15 +290,11 @@ where /// Returns the bpp of the format /// /// Note: This will return 0 for formats that don't have a specified width. -pub fn wl_bytes_per_pixel(format: WEnum) -> i32 { - match format { - WEnum::Value(f) => { - shm_format_to_fourcc(f).map_or(0, |fourcc| get_bpp(fourcc).map_or(0, |bpp| bpp / 8)) - } - WEnum::Unknown(_) => 0, - } - .try_into() - .unwrap() +pub fn wl_bytes_per_pixel(format: wl_shm::Format) -> i32 { + shm_format_to_fourcc(format) + .map_or(0, |fourcc| get_bpp(fourcc).map_or(0, |bpp| bpp / 8)) + .try_into() + .unwrap() } macro_rules! shm_format_table { diff --git a/src/wayland/single_pixel_buffer/handlers.rs b/src/wayland/single_pixel_buffer/handlers.rs index e9127198a2e4..41013c91a7c7 100644 --- a/src/wayland/single_pixel_buffer/handlers.rs +++ b/src/wayland/single_pixel_buffer/handlers.rs @@ -1,18 +1,17 @@ -use crate::wayland::{Dispatch2, GlobalData, GlobalDispatch2, buffer::BufferHandler}; +use crate::wayland::{GlobalData, buffer::BufferHandler}; use super::SinglePixelBufferUserData; use wayland_protocols::wp::single_pixel_buffer::v1::server::wp_single_pixel_buffer_manager_v1::{ self, WpSinglePixelBufferManagerV1, }; use wayland_server::{ - DataInit, Dispatch, DisplayHandle, New, + DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, protocol::wl_buffer::{self, WlBuffer}, }; -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, - D: 'static, + D: BufferHandler, { fn bind( &self, @@ -26,10 +25,9 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, - D: 'static, + D: BufferHandler, { fn request( &self, @@ -56,7 +54,7 @@ where } } -impl Dispatch2 for SinglePixelBufferUserData +impl Dispatch for SinglePixelBufferUserData where D: BufferHandler, { diff --git a/src/wayland/single_pixel_buffer/mod.rs b/src/wayland/single_pixel_buffer/mod.rs index 737c132d7cb1..07d1db262d0a 100644 --- a/src/wayland/single_pixel_buffer/mod.rs +++ b/src/wayland/single_pixel_buffer/mod.rs @@ -30,8 +30,6 @@ //! } //! } //! -//! smithay::delegate_dispatch2!(State); -//! //! // You're now ready to go! //! ``` //! @@ -46,11 +44,9 @@ //! ``` use wayland_protocols::wp::single_pixel_buffer::v1::server::wp_single_pixel_buffer_manager_v1::WpSinglePixelBufferManagerV1; -use wayland_server::{ - Dispatch, DisplayHandle, GlobalDispatch, Resource, backend::GlobalId, protocol::wl_buffer::WlBuffer, -}; +use wayland_server::{DisplayHandle, Resource, backend::GlobalId, protocol::wl_buffer::WlBuffer}; -use crate::wayland::GlobalData; +use crate::wayland::{GlobalData, buffer::BufferHandler}; mod handlers; @@ -67,9 +63,7 @@ impl SinglePixelBufferState { /// remove or disable this global in the future. pub fn new(display: &DisplayHandle) -> Self where - D: GlobalDispatch, - D: Dispatch, - D: 'static, + D: BufferHandler + 'static, { let global = display.create_global::(1, GlobalData); diff --git a/src/wayland/tablet_manager/mod.rs b/src/wayland/tablet_manager/mod.rs index cd1589de8214..2c1cf246a7fd 100644 --- a/src/wayland/tablet_manager/mod.rs +++ b/src/wayland/tablet_manager/mod.rs @@ -61,8 +61,6 @@ //! } //! } //! -//! smithay::delegate_dispatch2!(State); -//! //! # impl CompositorHandler for State { //! # fn compositor_state(&mut self) -> &mut CompositorState { unimplemented!() } //! # fn client_compositor_state<'a>(&self, client: &'a Client) -> &'a CompositorClientState { unimplemented!() } @@ -84,14 +82,9 @@ use crate::{ Seat, SeatHandler, tablet::{TabletSeat, TabletSeatHandler}, }, - wayland::{Dispatch2, GlobalData, GlobalDispatch2, compositor::CompositorHandler, seat::WaylandFocus}, -}; -use wayland_protocols::wp::tablet::zv2::server::{ - zwp_tablet_manager_v2::{self, ZwpTabletManagerV2}, - zwp_tablet_seat_v2::ZwpTabletSeatV2, - zwp_tablet_tool_v2::ZwpTabletToolV2, - zwp_tablet_v2::ZwpTabletV2, + wayland::{GlobalData, compositor::CompositorHandler, seat::WaylandFocus}, }; +use wayland_protocols::wp::tablet::zv2::server::zwp_tablet_manager_v2::{self, ZwpTabletManagerV2}; use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, backend::GlobalId}; const MANAGER_VERSION: u32 = 1; @@ -114,12 +107,8 @@ impl TabletManagerState { /// Initialize a tablet manager global. pub fn new(display: &DisplayHandle) -> Self where - D: GlobalDispatch, - D: Dispatch, - D: Dispatch>, - D: Dispatch>, - D: TabletSeatHandler, - D: 'static, + D: CompositorHandler + SeatHandler + TabletSeatHandler + 'static, + ::ToolFocus: WaylandFocus, { let global = display.create_global::(MANAGER_VERSION, GlobalData); @@ -132,11 +121,10 @@ impl TabletManagerState { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, - D: Dispatch>, - D: TabletSeatHandler, + D: CompositorHandler + SeatHandler + TabletSeatHandler + 'static, + ::ToolFocus: WaylandFocus, { fn bind( &self, @@ -150,13 +138,9 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch>, - D: Dispatch, - D: Dispatch>, - D: SeatHandler + TabletSeatHandler + 'static, - D: CompositorHandler, + D: CompositorHandler + SeatHandler + TabletSeatHandler + 'static, ::ToolFocus: WaylandFocus, { fn request( @@ -195,7 +179,7 @@ where fn destroyed( &self, _state: &mut D, - _client: wayland_server::backend::ClientId, + _client: &wayland_server::backend::ClientId, _resource: &ZwpTabletManagerV2, ) { } diff --git a/src/wayland/tablet_manager/tablet.rs b/src/wayland/tablet_manager/tablet.rs index 226ce2b28eca..cb612aed94b6 100644 --- a/src/wayland/tablet_manager/tablet.rs +++ b/src/wayland/tablet_manager/tablet.rs @@ -7,10 +7,7 @@ use wayland_server::{ Client, Dispatch, DisplayHandle, Resource, Weak, backend::ObjectId, protocol::wl_surface::WlSurface, }; -use crate::{ - input::tablet::{Tablet, TabletDescriptor, TabletRc, TabletSeat, TabletSeatHandler, WeakTablet}, - wayland::Dispatch2, -}; +use crate::input::tablet::{Tablet, TabletDescriptor, TabletRc, TabletSeat, TabletSeatHandler, WeakTablet}; impl Tablet { fn new_bound(descriptor: TabletDescriptor) -> Self { @@ -41,8 +38,7 @@ impl TabletSeat { /// [`TabletToolHandle`]: crate::input::tablet::tool::TabletToolHandle pub fn add_wp_tablet(&self, dh: &DisplayHandle, tablet_desc: &TabletDescriptor) -> Tablet where - D: Dispatch, - D: 'static, + D: TabletSeatHandler + 'static, { let inner = &mut *self.arc.lock().unwrap(); @@ -88,7 +84,6 @@ impl WpTabletHandle { tablet: Tablet, desc: &TabletDescriptor, ) where - D: Dispatch, D: 'static, { if !self.bound { @@ -101,7 +96,7 @@ impl WpTabletHandle { seat.version(), TabletUserData { tablet: tablet.downgrade(), - seat_id: seat.id(), + seat_id: seat.id().clone(), }, ) .unwrap(); @@ -151,7 +146,7 @@ impl Drop for WpTabletHandle { } } -impl Dispatch2 for TabletUserData +impl Dispatch for TabletUserData where D: 'static, { @@ -166,7 +161,12 @@ where ) { } - fn destroyed(&self, _state: &mut D, _client: wayland_server::backend::ClientId, wp_tablet: &ZwpTabletV2) { + fn destroyed( + &self, + _state: &mut D, + _client: &wayland_server::backend::ClientId, + wp_tablet: &ZwpTabletV2, + ) { let Some(tablet) = self.tablet.upgrade() else { return; }; diff --git a/src/wayland/tablet_manager/tablet_seat.rs b/src/wayland/tablet_manager/tablet_seat.rs index 46d44d62aa86..05ace3c2e17e 100644 --- a/src/wayland/tablet_manager/tablet_seat.rs +++ b/src/wayland/tablet_manager/tablet_seat.rs @@ -1,16 +1,9 @@ -use wayland_protocols::wp::tablet::zv2::server::{ - zwp_tablet_seat_v2::ZwpTabletSeatV2, zwp_tablet_tool_v2::ZwpTabletToolV2, zwp_tablet_v2::ZwpTabletV2, -}; +use wayland_protocols::wp::tablet::zv2::server::zwp_tablet_seat_v2::ZwpTabletSeatV2; use wayland_server::{Client, Dispatch, DisplayHandle, Resource}; use crate::{ input::tablet::{TabletSeat, TabletSeatHandler}, - wayland::{ - Dispatch2, - compositor::CompositorHandler, - seat::WaylandFocus, - tablet_manager::{TabletToolUserData, tablet::TabletUserData}, - }, + wayland::{compositor::CompositorHandler, seat::WaylandFocus}, }; impl TabletSeat { @@ -21,8 +14,6 @@ impl TabletSeat { seat: &ZwpTabletSeatV2, client: &Client, ) where - D: Dispatch, - D: Dispatch>, D: CompositorHandler, ::ToolFocus: WaylandFocus, D: 'static, @@ -52,7 +43,7 @@ pub struct TabletSeatUserData { pub(super) handle: TabletSeat, } -impl Dispatch2 for TabletSeatUserData +impl Dispatch for TabletSeatUserData where D: TabletSeatHandler + 'static, { @@ -67,7 +58,7 @@ where ) { } - fn destroyed(&self, _state: &mut D, _client: wayland_server::backend::ClientId, seat: &ZwpTabletSeatV2) { + fn destroyed(&self, _state: &mut D, _client: &wayland_server::backend::ClientId, seat: &ZwpTabletSeatV2) { self.handle .arc .lock() diff --git a/src/wayland/tablet_manager/tablet_tool.rs b/src/wayland/tablet_manager/tablet_tool.rs index 28beeb0aeb9e..69af3cef76d2 100644 --- a/src/wayland/tablet_manager/tablet_tool.rs +++ b/src/wayland/tablet_manager/tablet_tool.rs @@ -25,7 +25,6 @@ use crate::{ }, utils::{Client as ClientCoords, Clock, Monotonic, Point, Serial, iter::new_locked_obj_iter_from_vec}, wayland::{ - Dispatch2, compositor::{self, CompositorHandler}, seat::{CURSOR_IMAGE_ROLE, WaylandFocus}, }, @@ -56,7 +55,7 @@ impl TabletToolHandle { } /// Return the raw [`ZwpTabletToolV2`] instance for a particular [`Client`] - pub fn client_tools<'a>(&'a self, client: &Client) -> impl Iterator + 'a { + pub fn client_tools<'a>(&'a self, client: &'a Client) -> impl Iterator + 'a { let guard = self.arc.wp_tablet_tool.known_instances.lock().unwrap(); new_locked_obj_iter_from_vec(guard, client.id()) } @@ -78,7 +77,6 @@ impl TabletSeat { tool_desc: &TabletToolDescriptor, ) -> TabletToolHandle where - D: Dispatch>, D: CompositorHandler, ::ToolFocus: WaylandFocus, { @@ -101,7 +99,6 @@ impl TabletSeat { default_grab: F, ) -> TabletToolHandle where - D: Dispatch>, D: CompositorHandler, ::ToolFocus: WaylandFocus, F: Fn() -> Box> + Send + 'static, @@ -153,7 +150,6 @@ impl WpTabletToolHandle { handle: TabletToolHandle, desc: &TabletToolDescriptor, ) where - D: Dispatch>, D: CompositorHandler, D: TabletSeatHandler, ::ToolFocus: WaylandFocus, @@ -170,7 +166,7 @@ impl WpTabletToolHandle { seat.version(), TabletToolUserData { handle: handle.downgrade(), - seat_id: seat.id(), + seat_id: seat.id().clone(), client_scale, }, ) @@ -410,7 +406,7 @@ impl From for zwp_tablet_tool_v2::ButtonState { } } -impl Dispatch2 for TabletToolUserData +impl Dispatch for TabletToolUserData where D: TabletSeatHandler, ::ToolFocus: WaylandFocus, @@ -493,7 +489,7 @@ where } } - fn destroyed(&self, _state: &mut D, _client: ClientId, tool: &ZwpTabletToolV2) { + fn destroyed(&self, _state: &mut D, _client: &ClientId, tool: &ZwpTabletToolV2) { let Some(handle) = self.handle.upgrade() else { return; }; diff --git a/src/wayland/text_input/mod.rs b/src/wayland/text_input/mod.rs index b03ceca1d920..28d9cbeca09f 100644 --- a/src/wayland/text_input/mod.rs +++ b/src/wayland/text_input/mod.rs @@ -15,8 +15,6 @@ //! //! # struct State { seat_state: SeatState }; //! -//! smithay::delegate_dispatch2!(State); -//! //! # let mut display = Display::::new().unwrap(); //! # let display_handle = display.handle(); //! @@ -46,15 +44,14 @@ //! ``` //! -use wayland_protocols::wp::text_input::zv3::server::{ - zwp_text_input_manager_v3::{self, ZwpTextInputManagerV3}, - zwp_text_input_v3::ZwpTextInputV3, +use wayland_protocols::wp::text_input::zv3::server::zwp_text_input_manager_v3::{ + self, ZwpTextInputManagerV3, }; use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, backend::GlobalId}; use crate::{ input::{Seat, SeatHandler}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, + wayland::GlobalData, }; pub use text_input_handle::TextInputHandle; @@ -90,10 +87,7 @@ impl TextInputManagerState { /// Initialize a text input manager global. pub fn new(display: &DisplayHandle) -> Self where - D: GlobalDispatch, - D: Dispatch, - D: Dispatch, - D: 'static, + D: SeatHandler + 'static, { let global = display.create_global::(MANAGER_VERSION, GlobalData); @@ -106,11 +100,9 @@ impl TextInputManagerState { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, - D: Dispatch, - D: 'static, + D: SeatHandler + 'static, { fn bind( &self, @@ -124,11 +116,9 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, - D: SeatHandler, - D: 'static, + D: SeatHandler + 'static, { fn request( &self, diff --git a/src/wayland/text_input/text_input_handle.rs b/src/wayland/text_input/text_input_handle.rs index 026cf2e01d24..a203065534af 100644 --- a/src/wayland/text_input/text_input_handle.rs +++ b/src/wayland/text_input/text_input_handle.rs @@ -6,11 +6,11 @@ use wayland_protocols::wp::text_input::zv3::server::zwp_text_input_v3::{ self, ChangeCause, ContentHint, ContentPurpose, ZwpTextInputV3, }; use wayland_server::backend::{ClientId, ObjectId}; -use wayland_server::{Resource, protocol::wl_surface::WlSurface}; +use wayland_server::{Dispatch, Resource, protocol::wl_surface::WlSurface}; use crate::input::SeatHandler; use crate::utils::{Logical, Rectangle}; -use crate::wayland::{Dispatch2, input_method::InputMethodHandle}; +use crate::wayland::input_method::InputMethodHandle; #[derive(Default, Debug)] pub(crate) struct TextInput { @@ -54,7 +54,7 @@ impl TextInput { .instances .iter() .filter(|instance| instance.instance.id().same_client_as(&surface_id)) - .find(|instance| &instance.instance.id() == active_id) + .find(|instance| instance.instance.id() == active_id) { f(&text_input.instance, surface, text_input.serial); } @@ -214,7 +214,7 @@ pub struct TextInputUserData { pub(crate) input_method_handle: InputMethodHandle, } -impl Dispatch2 for TextInputUserData +impl Dispatch for TextInputUserData where D: SeatHandler, D: 'static, @@ -275,15 +275,19 @@ where zwp_text_input_v3::Request::SetSurroundingText { text, cursor, anchor } => { pending_state.surrounding_text = Some((text, cursor as u32, anchor as u32)); } - zwp_text_input_v3::Request::SetTextChangeCause { cause } => { + zwp_text_input_v3::Request::SetTextChangeCause { mut cause } => { // Guard against clients sending us unknown values from future versions. - let cause = cause.into_result().unwrap_or(ChangeCause::Other); + if cause.available_since().is_some_and(|v| v > resource.version()) { + cause = ChangeCause::Other; + } pending_state.text_change_cause = Some(cause); } - zwp_text_input_v3::Request::SetContentType { hint, purpose } => { + zwp_text_input_v3::Request::SetContentType { hint, mut purpose } => { // Guard against clients sending us unknown values from future versions. let hint = ContentHint::from_bits_truncate(u32::from(hint)); - let purpose = purpose.into_result().unwrap_or(ContentPurpose::Normal); + if purpose.available_since().is_some_and(|v| v > resource.version()) { + purpose = ContentPurpose::Normal; + } pending_state.content_type = Some((hint, purpose)); } zwp_text_input_v3::Request::SetCursorRectangle { x, y, width, height } => { @@ -294,14 +298,14 @@ where let _ = pending_state; let active_text_input_id = &mut guard.active_text_input_id; - if active_text_input_id.is_some() && *active_text_input_id != Some(resource.id()) { + if active_text_input_id.is_some() && active_text_input_id.as_ref() != Some(resource.id()) { debug!("discarding text_input request since we already have an active one"); return; } match new_state.enable { Some(true) => { - *active_text_input_id = Some(resource.id()); + *active_text_input_id = Some(resource.id().clone()); // Drop the guard before calling to other subsystem. drop(guard); self.input_method_handle.activate_input_method(state, &focus); @@ -314,7 +318,7 @@ where return; } None => { - if *active_text_input_id != Some(resource.id()) { + if active_text_input_id.as_ref() != Some(resource.id()) { debug!("discarding text_input requests before enabling it"); return; } @@ -358,7 +362,7 @@ where } } - fn destroyed(&self, state: &mut D, _client: ClientId, text_input: &ZwpTextInputV3) { + fn destroyed(&self, state: &mut D, _client: &ClientId, text_input: &ZwpTextInputV3) { let destroyed_id = text_input.id(); let deactivate_im = { let mut inner = self.handle.inner.lock().unwrap(); diff --git a/src/wayland/viewporter/mod.rs b/src/wayland/viewporter/mod.rs index a9e32c5ca177..85aa7d6e360d 100644 --- a/src/wayland/viewporter/mod.rs +++ b/src/wayland/viewporter/mod.rs @@ -20,8 +20,6 @@ //! &display.handle(), // the display //! ); //! -//! smithay::delegate_dispatch2!(State); -//! //! # impl CompositorHandler for State { //! # fn compositor_state(&mut self) -> &mut CompositorState { unimplemented!() } //! # fn client_compositor_state<'a>(&self, client: &'a Client) -> &'a CompositorClientState { unimplemented!() } @@ -59,7 +57,7 @@ use wayland_server::{ use crate::{ utils::{Client, Logical, Rectangle, Size}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, + wayland::GlobalData, }; use super::compositor::{self, Cacheable, CompositorHandler, SurfaceData, with_states}; @@ -79,10 +77,7 @@ impl ViewporterState { /// the event loop in the future. pub fn new(display: &DisplayHandle) -> ViewporterState where - D: GlobalDispatch - + Dispatch - + Dispatch - + 'static, + D: CompositorHandler + 'static, { ViewporterState { global: display.create_global::(1, GlobalData), @@ -95,10 +90,9 @@ impl ViewporterState { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, - D: Dispatch, + D: CompositorHandler, { fn bind( &self, @@ -112,9 +106,9 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, + D: CompositorHandler, { fn request( &self, @@ -184,7 +178,7 @@ where } } -impl Dispatch2 for ViewportState +impl Dispatch for ViewportState where D: CompositorHandler, { diff --git a/src/wayland/virtual_keyboard/mod.rs b/src/wayland/virtual_keyboard/mod.rs index a8039004c180..0a41e4cc5038 100644 --- a/src/wayland/virtual_keyboard/mod.rs +++ b/src/wayland/virtual_keyboard/mod.rs @@ -14,8 +14,6 @@ //! //! # struct State { seat_state: SeatState }; //! -//! smithay::delegate_dispatch2!(State); -//! //! # let mut display = Display::::new().unwrap(); //! # let display_handle = display.handle(); //! @@ -46,15 +44,14 @@ //! ``` //! -use wayland_protocols_misc::zwp_virtual_keyboard_v1::server::{ - zwp_virtual_keyboard_manager_v1::{self, ZwpVirtualKeyboardManagerV1}, - zwp_virtual_keyboard_v1::ZwpVirtualKeyboardV1, +use wayland_protocols_misc::zwp_virtual_keyboard_v1::server::zwp_virtual_keyboard_manager_v1::{ + self, ZwpVirtualKeyboardManagerV1, }; use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, backend::GlobalId}; use crate::{ input::{Seat, SeatHandler}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, + wayland::{GlobalData, seat::WaylandFocus}, }; use self::virtual_keyboard_handle::VirtualKeyboardHandle; @@ -79,7 +76,8 @@ pub struct VirtualKeyboardManagerGlobalData { fn create_global_with_filter(display: &DisplayHandle, filter: F) -> GlobalId where - D: GlobalDispatch + 'static, + D: SeatHandler + 'static, + ::KeyboardFocus: WaylandFocus, F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, { let data = VirtualKeyboardManagerGlobalData { @@ -93,11 +91,8 @@ impl VirtualKeyboardManagerState { /// Initialize a virtual keyboard manager global. pub fn new(display: &DisplayHandle, filter: F) -> Self where - D: GlobalDispatch, - D: Dispatch, - D: Dispatch>, - D: SeatHandler, - D: 'static, + D: SeatHandler + 'static, + ::KeyboardFocus: WaylandFocus, F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, { let global = create_global_with_filter::(display, filter); @@ -111,12 +106,10 @@ impl VirtualKeyboardManagerState { } } -impl GlobalDispatch2 for VirtualKeyboardManagerGlobalData +impl GlobalDispatch for VirtualKeyboardManagerGlobalData where - D: Dispatch, - D: Dispatch>, - D: SeatHandler, - D: 'static, + D: SeatHandler + 'static, + ::KeyboardFocus: WaylandFocus, { fn bind( &self, @@ -134,11 +127,10 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch>, - D: SeatHandler, - D: 'static, + D: SeatHandler + 'static, + ::KeyboardFocus: WaylandFocus, { fn request( &self, diff --git a/src/wayland/virtual_keyboard/virtual_keyboard_handle.rs b/src/wayland/virtual_keyboard/virtual_keyboard_handle.rs index 40e3ee45d8c2..dda43d1386db 100644 --- a/src/wayland/virtual_keyboard/virtual_keyboard_handle.rs +++ b/src/wayland/virtual_keyboard/virtual_keyboard_handle.rs @@ -5,12 +5,11 @@ use std::{ }; use tracing::debug; -use wayland_protocols_misc::zwp_virtual_keyboard_v1::server::zwp_virtual_keyboard_v1::Error::NoKeymap; use wayland_protocols_misc::zwp_virtual_keyboard_v1::server::zwp_virtual_keyboard_v1::{ self, ZwpVirtualKeyboardV1, }; use wayland_server::{ - Client, DataInit, DisplayHandle, Resource, + Client, DataInit, Dispatch, DisplayHandle, Resource, protocol::wl_keyboard::{KeyState, KeymapFormat}, }; use xkbcommon::xkb; @@ -19,10 +18,7 @@ use crate::input::keyboard::{KeyboardTarget, KeymapFile, ModifiersState}; use crate::{ input::{Seat, SeatHandler}, utils::SERIAL_COUNTER, - wayland::{ - Dispatch2, - seat::{WaylandFocus, keyboard::for_each_focused_kbds}, - }, + wayland::seat::{WaylandFocus, keyboard::for_each_focused_kbds}, }; #[derive(Debug, Default)] @@ -71,7 +67,7 @@ impl fmt::Debug for VirtualKeyboardUserData { } } -impl Dispatch2 for VirtualKeyboardUserData +impl Dispatch for VirtualKeyboardUserData where D: SeatHandler + 'static, ::KeyboardFocus: WaylandFocus, @@ -95,7 +91,10 @@ where let vk_state = match virtual_data.state.as_mut() { Some(vk_state) => vk_state, None => { - virtual_keyboard.post_error(NoKeymap, "`key` sent before keymap."); + virtual_keyboard.post_error( + zwp_virtual_keyboard_v1::Error::NoKeymap, + "`key` sent before keymap.", + ); return; } }; @@ -131,7 +130,10 @@ where let state = match virtual_data.state.as_mut() { Some(state) => state, None => { - virtual_keyboard.post_error(NoKeymap, "`modifiers` sent before keymap."); + virtual_keyboard.post_error( + zwp_virtual_keyboard_v1::Error::NoKeymap, + "`modifiers` sent before keymap.", + ); return; } }; @@ -172,7 +174,7 @@ where D: SeatHandler + 'static, { // Only libxkbcommon compatible keymaps are supported. - if format != KeymapFormat::XkbV1 as u32 { + if format != u32::from(KeymapFormat::XkbV1) { debug!("Unsupported keymap format: {format:?}"); return; } diff --git a/src/wayland/xdg_activation/dispatch.rs b/src/wayland/xdg_activation/dispatch.rs index b9680590a41c..5c6fd20c80ac 100644 --- a/src/wayland/xdg_activation/dispatch.rs +++ b/src/wayland/xdg_activation/dispatch.rs @@ -4,17 +4,15 @@ use std::sync::{ }; use wayland_protocols::xdg::activation::v1::server::{xdg_activation_token_v1, xdg_activation_v1}; -use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, New, Resource}; +use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource}; use super::{ActivationTokenData, TokenBuilder, XdgActivationHandler, XdgActivationTokenData}; -use crate::wayland::{Dispatch2, GlobalData, GlobalDispatch2}; +use crate::wayland::GlobalData; -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch - + XdgActivationHandler - + 'static, + D: XdgActivationHandler + 'static, { fn request( &self, @@ -58,12 +56,9 @@ where } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch - + Dispatch - + XdgActivationHandler - + 'static, + D: XdgActivationHandler + 'static, { fn bind( &self, @@ -77,7 +72,7 @@ where } } -impl Dispatch2 for ActivationTokenData +impl Dispatch for ActivationTokenData where D: XdgActivationHandler, { @@ -142,7 +137,7 @@ where let mut guard = self.build.lock().unwrap(); XdgActivationTokenData::new( - Some(client.id()), + Some(client.id().clone()), guard.serial.take(), guard.app_id.take(), guard.surface.take(), diff --git a/src/wayland/xdg_activation/mod.rs b/src/wayland/xdg_activation/mod.rs index 37c213c3e444..8bc081402dd1 100644 --- a/src/wayland/xdg_activation/mod.rs +++ b/src/wayland/xdg_activation/mod.rs @@ -31,9 +31,6 @@ //! } //! } //! -//! // Delegate xdg activation handling for State to XdgActivationState. -//! smithay::delegate_dispatch2!(State); -//! //! # let mut display = wayland_server::Display::::new().unwrap(); //! # let display_handle = display.handle(); //! let state = State { @@ -52,7 +49,7 @@ use std::{ use wayland_protocols::xdg::activation::v1::server::xdg_activation_v1; use wayland_server::{ - Dispatch, DisplayHandle, GlobalDispatch, + DisplayHandle, backend::{ClientId, GlobalId}, protocol::{wl_seat::WlSeat, wl_surface::WlSurface}, }; @@ -179,10 +176,7 @@ impl XdgActivationState { /// In order to use this abstraction, your `D` type needs to implement [`XdgActivationHandler`]. pub fn new(display: &DisplayHandle) -> XdgActivationState where - D: GlobalDispatch - + Dispatch - + XdgActivationHandler - + 'static, + D: XdgActivationHandler + 'static, { let global = display.create_global::(1, GlobalData); diff --git a/src/wayland/xdg_foreign/handlers.rs b/src/wayland/xdg_foreign/handlers.rs index ce7c0004ac33..a026b285bcff 100644 --- a/src/wayland/xdg_foreign/handlers.rs +++ b/src/wayland/xdg_foreign/handlers.rs @@ -6,10 +6,12 @@ use wayland_protocols::xdg::foreign::zv2::server::{ zxdg_imported_v2::{self, ZxdgImportedV2}, zxdg_importer_v2::{self, ZxdgImporterV2}, }; -use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, New, Resource, backend::ClientId}; +use wayland_server::{ + Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, backend::ClientId, +}; use crate::wayland::{ - Dispatch2, GlobalData, GlobalDispatch2, compositor, + GlobalData, compositor, shell::{ is_valid_parent, xdg::{XDG_TOPLEVEL_ROLE, XdgShellHandler, XdgToplevelSurfaceData}, @@ -22,9 +24,9 @@ use super::{ExportedState, XdgExportedUserData, XdgForeignHandle, XdgForeignHand // Export // -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, + D: XdgForeignHandler, { fn bind( &self, @@ -38,9 +40,8 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, D: XdgForeignHandler, { fn request( @@ -86,7 +87,7 @@ where } } -impl Dispatch2 for XdgExportedUserData +impl Dispatch for XdgExportedUserData where D: XdgForeignHandler + XdgShellHandler, { @@ -101,7 +102,7 @@ where ) { } - fn destroyed(&self, state: &mut D, _client: ClientId, _resource: &ZxdgExportedV2) { + fn destroyed(&self, state: &mut D, _client: &ClientId, _resource: &ZxdgExportedV2) { // Revoke the previously exported surface. // This invalidates any relationship the importer may have set up using the xdg_imported created given the handle sent via xdg_exported.handle. invalidate_all_relationships(state, &self.handle); @@ -113,9 +114,9 @@ where // Import // -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, + D: XdgForeignHandler, { fn bind( &self, @@ -129,9 +130,9 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, + D: XdgForeignHandler, { fn request( &self, @@ -172,7 +173,7 @@ where } } -impl Dispatch2 for XdgImportedUserData +impl Dispatch for XdgImportedUserData where D: XdgForeignHandler + XdgShellHandler, { @@ -237,7 +238,7 @@ where } } - fn destroyed(&self, state: &mut D, _client: ClientId, resource: &ZxdgImportedV2) { + fn destroyed(&self, state: &mut D, _client: &ClientId, resource: &ZxdgImportedV2) { if let Some((_, exported_state)) = state .xdg_foreign_state() .exported diff --git a/src/wayland/xdg_foreign/mod.rs b/src/wayland/xdg_foreign/mod.rs index 9ac99ba8202c..c493a41d1a61 100644 --- a/src/wayland/xdg_foreign/mod.rs +++ b/src/wayland/xdg_foreign/mod.rs @@ -38,14 +38,14 @@ use rand::distr::{Alphanumeric, SampleString}; use wayland_protocols::xdg::foreign::zv2::server::{ zxdg_exporter_v2::ZxdgExporterV2, zxdg_imported_v2::ZxdgImportedV2, zxdg_importer_v2::ZxdgImporterV2, }; -use wayland_server::{DisplayHandle, GlobalDispatch, backend::GlobalId, protocol::wl_surface::WlSurface}; +use wayland_server::{DisplayHandle, backend::GlobalId, protocol::wl_surface::WlSurface}; -use crate::wayland::GlobalData; +use crate::wayland::{GlobalData, shell::xdg::XdgShellHandler}; mod handlers; /// A trait implemented to be notified of activation requests using the xdg foreign protocol. -pub trait XdgForeignHandler: 'static { +pub trait XdgForeignHandler: XdgShellHandler + 'static { /// Returns the xdg foreign state. fn xdg_foreign_state(&mut self) -> &mut XdgForeignState; } @@ -107,8 +107,6 @@ impl XdgForeignState { pub fn new(display: &DisplayHandle) -> Self where D: XdgForeignHandler, - D: GlobalDispatch, - D: GlobalDispatch, { let exporter = display.create_global::(1, GlobalData); let importer = display.create_global::(1, GlobalData); diff --git a/src/wayland/xdg_system_bell.rs b/src/wayland/xdg_system_bell.rs index 5006003fee2e..3f81f59af225 100644 --- a/src/wayland/xdg_system_bell.rs +++ b/src/wayland/xdg_system_bell.rs @@ -21,8 +21,6 @@ //! println!("Ring got called"); //! } //! } -//! -//! smithay::delegate_dispatch2!(State); //! ``` use wayland_protocols::xdg::system_bell::v1::server::xdg_system_bell_v1::{self, XdgSystemBellV1}; @@ -31,7 +29,7 @@ use wayland_server::{ protocol::wl_surface::WlSurface, }; -use crate::wayland::{Dispatch2, GlobalData, GlobalDispatch2}; +use crate::wayland::GlobalData; /// Handler for xdg ring request pub trait XdgSystemBellHandler: 'static { @@ -49,7 +47,7 @@ impl XdgSystemBellState { /// Register new [XdgSystemBellV1] global pub fn new(display: &DisplayHandle) -> Self where - D: XdgSystemBellHandler + GlobalDispatch, + D: XdgSystemBellHandler, { let global_id = display.create_global::(1, GlobalData); Self { global_id } @@ -61,10 +59,7 @@ impl XdgSystemBellState { } } -impl GlobalDispatch2 for GlobalData -where - D: Dispatch, -{ +impl GlobalDispatch for GlobalData { fn bind( &self, _state: &mut D, @@ -77,7 +72,7 @@ where } } -impl Dispatch2 for GlobalData { +impl Dispatch for GlobalData { fn request( &self, state: &mut D, diff --git a/src/wayland/xdg_toplevel_icon.rs b/src/wayland/xdg_toplevel_icon.rs index 2a22b1e4b37a..8dad67fd76c4 100644 --- a/src/wayland/xdg_toplevel_icon.rs +++ b/src/wayland/xdg_toplevel_icon.rs @@ -22,8 +22,6 @@ //! dbg!(wl_surface); //! } //! } -//! -//! smithay::delegate_dispatch2!(State); //! ``` use std::{ @@ -48,7 +46,7 @@ use wayland_server::{ use crate::{ utils::HookId, wayland::{ - Dispatch2, GlobalData, GlobalDispatch2, + GlobalData, compositor::{self, Cacheable}, shell::xdg::XdgShellSurfaceUserData, shm::ShmBufferUserData, @@ -235,7 +233,7 @@ impl XdgToplevelIconManager { /// Creates a new delegate type for handling xdg toplevel icon events. pub fn new(display: &DisplayHandle) -> Self where - D: XdgToplevelIconHandler + GlobalDispatch, + D: XdgToplevelIconHandler, { let data = Arc::new(Mutex::new(ManagerGlobalData::default())); let global = display @@ -267,10 +265,8 @@ impl XdgToplevelIconManager { } } -impl GlobalDispatch2 +impl GlobalDispatch for XdgToplevelIconManagerUserData -where - D: Dispatch, { fn bind( &self, @@ -289,10 +285,7 @@ where } } -impl Dispatch2 for GlobalData -where - D: Dispatch, -{ +impl Dispatch for GlobalData { fn request( &self, state: &mut D, @@ -335,7 +328,7 @@ where } } -impl Dispatch2 for XdgToplevelIconUserData { +impl Dispatch for XdgToplevelIconUserData { fn request( &self, _state: &mut D, @@ -402,7 +395,7 @@ impl Dispatch2 for XdgToplevelI } } - fn destroyed(&self, _state: &mut D, _client: ClientId, _resource: &XdgToplevelIconV1) { + fn destroyed(&self, _state: &mut D, _client: &ClientId, _resource: &XdgToplevelIconV1) { self.unregister_all_hooks(); } } diff --git a/src/wayland/xdg_toplevel_tag.rs b/src/wayland/xdg_toplevel_tag.rs index 4e12c4377979..10abfe2a4691 100644 --- a/src/wayland/xdg_toplevel_tag.rs +++ b/src/wayland/xdg_toplevel_tag.rs @@ -26,8 +26,6 @@ //! dbg!(description); //! } //! } -//! -//! smithay::delegate_dispatch2!(State); //! ``` use std::sync::{Arc, Mutex}; @@ -41,9 +39,7 @@ use wayland_server::{ Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, backend::GlobalId, }; -use crate::wayland::{ - Dispatch2, GlobalData, GlobalDispatch2, compositor, shell::xdg::XdgShellSurfaceUserData, -}; +use crate::wayland::{GlobalData, compositor, shell::xdg::XdgShellSurfaceUserData}; /// Data associated with WlSurface /// Represents the client pending state @@ -106,7 +102,7 @@ impl XdgToplevelTagManager { /// Creates a new delegate type for handling xdg toplevel tag events. pub fn new(display: &DisplayHandle) -> Self where - D: XdgToplevelTagHandler + GlobalDispatch, + D: XdgToplevelTagHandler, { let global = display.create_global::(1, GlobalData); XdgToplevelTagManager { global } @@ -118,9 +114,9 @@ impl XdgToplevelTagManager { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, + D: XdgToplevelTagHandler, { fn bind( &self, @@ -134,7 +130,7 @@ where } } -impl Dispatch2 for GlobalData { +impl Dispatch for GlobalData { fn request( &self, state: &mut D, diff --git a/src/wayland/xwayland_keyboard_grab.rs b/src/wayland/xwayland_keyboard_grab.rs index 8720a890d4b3..8475a3bd4cb3 100644 --- a/src/wayland/xwayland_keyboard_grab.rs +++ b/src/wayland/xwayland_keyboard_grab.rs @@ -39,9 +39,6 @@ //! todo!() //! } //! } -//! -//! // implement Dispatch for the keyboard grab types -//! smithay::delegate_dispatch2!(State); //! ``` use wayland_protocols::xwayland::keyboard_grab::zv1::server::{ @@ -60,7 +57,7 @@ use crate::{ keyboard::{self, KeyboardGrab, KeyboardInnerHandle}, }, utils::{SERIAL_COUNTER, Serial}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, + wayland::GlobalData, xwayland::XWaylandClientData, }; @@ -161,9 +158,7 @@ impl XWaylandKeyboardGrabState { /// Register new [ZwpXwaylandKeyboardGrabManagerV1] global pub fn new(display: &DisplayHandle) -> Self where - D: GlobalDispatch, - D: Dispatch, - D: Dispatch, + D: XWaylandKeyboardGrabHandler, D: 'static, { let global = @@ -178,9 +173,9 @@ impl XWaylandKeyboardGrabState { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch + 'static, + D: XWaylandKeyboardGrabHandler + 'static, { fn bind( &self, @@ -198,10 +193,9 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch + 'static, - D: XWaylandKeyboardGrabHandler, + D: XWaylandKeyboardGrabHandler + 'static, { fn request( &self, @@ -230,7 +224,7 @@ where } } -impl Dispatch2 for GlobalData { +impl Dispatch for GlobalData { fn request( &self, _state: &mut D, diff --git a/src/wayland/xwayland_shell.rs b/src/wayland/xwayland_shell.rs index 314bd2f4cdb4..a3bd7c950edd 100644 --- a/src/wayland/xwayland_shell.rs +++ b/src/wayland/xwayland_shell.rs @@ -119,9 +119,6 @@ //! fn move_request(&mut self, xwm: XwmId, window: X11Surface, button: u32) { /* ... */ } //! fn send_selection(&mut self, xwm: XwmId, selection: SelectionTarget, mime_type: String, fd: OwnedFd) { /* ... */ } //! } -//! -//! // implement Dispatch for your state. -//! smithay::delegate_dispatch2!(State); //! ``` use std::collections::HashMap; @@ -139,7 +136,7 @@ use wayland_server::{ use crate::{ input::SeatHandler, - wayland::{Dispatch2, GlobalData, GlobalDispatch2, compositor}, + wayland::{GlobalData, compositor}, xwayland::{X11Surface, XWaylandClientData, XwmHandler, xwm::XwmId}, }; @@ -160,9 +157,7 @@ impl XWaylandShellState { /// able to bind it. pub fn new(display: &DisplayHandle) -> Self where - D: GlobalDispatch, - D: Dispatch, - D: Dispatch, + D: XWaylandShellHandler, D: 'static, { let global = display.create_global::(VERSION, GlobalData); @@ -190,7 +185,7 @@ pub struct XWaylandSurfaceUserData { } /// Handler for the xwayland shell protocol. -pub trait XWaylandShellHandler { +pub trait XWaylandShellHandler: XwmHandler + SeatHandler { /// Retrieves the global state. fn xwayland_shell_state(&mut self) -> &mut XWaylandShellState; @@ -219,9 +214,9 @@ impl compositor::Cacheable for XWaylandShellCachedState { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, + D: XWaylandShellHandler, D: 'static, { fn bind( @@ -240,10 +235,9 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, - D: XWaylandShellHandler + XwmHandler + SeatHandler, + D: XWaylandShellHandler, D: 'static, { fn request( @@ -275,11 +269,10 @@ where } } -impl Dispatch2 for XWaylandSurfaceUserData +impl Dispatch for XWaylandSurfaceUserData where D: XWaylandShellHandler, D: 'static, - D: XwmHandler, { fn request( &self, @@ -313,7 +306,7 @@ where } } -fn serial_commit_hook( +fn serial_commit_hook( state: &mut D, _dh: &DisplayHandle, surface: &WlSurface, diff --git a/src/xwayland/xserver.rs b/src/xwayland/xserver.rs index 4d2ef4c28db9..e96600301c7f 100644 --- a/src/xwayland/xserver.rs +++ b/src/xwayland/xserver.rs @@ -380,7 +380,7 @@ pub struct XWaylandClientData { } impl ClientData for XWaylandClientData { - fn disconnected(&self, _client_id: ClientId, reason: DisconnectReason) { + fn disconnected(&self, _client_id: &ClientId, reason: DisconnectReason) { if let DisconnectReason::ProtocolError(err) = reason { error!("Xwayland disconnected: {}", err); } diff --git a/test_clients/Cargo.toml b/test_clients/Cargo.toml index d18f5b389707..2b4ac2bda7f9 100644 --- a/test_clients/Cargo.toml +++ b/test_clients/Cargo.toml @@ -5,6 +5,7 @@ edition = "2024" license = "MIT" [dependencies] -smithay-client-toolkit = "0.19.2" +# smithay-client-toolkit = "0.19.2" +smithay-client-toolkit = { git = "https://github.com/ids1024/client-toolkit", branch = "wayland-update" } tracing = { version = "0.1.37" } tracing-subscriber = { version = "0.3.16", features = ["env-filter"] } diff --git a/test_clients/src/bin/test_pointer_constraints.rs b/test_clients/src/bin/test_pointer_constraints.rs index 9b7b42ea6c81..6d70f9a0297b 100644 --- a/test_clients/src/bin/test_pointer_constraints.rs +++ b/test_clients/src/bin/test_pointer_constraints.rs @@ -2,8 +2,6 @@ use smithay_client_toolkit::{ compositor::{CompositorHandler, CompositorState}, - delegate_compositor, delegate_output, delegate_pointer, delegate_pointer_constraints, delegate_registry, - delegate_seat, delegate_shm, delegate_xdg_shell, delegate_xdg_window, output::{OutputHandler, OutputState}, reexports::{ calloop, client as wayland_client, @@ -12,7 +10,6 @@ use smithay_client_toolkit::{ zwp_pointer_constraints_v1, }, }, - registry::{ProvidesRegistryState, RegistryState}, registry_handlers, seat::{ Capability, SeatHandler, SeatState, @@ -33,11 +30,11 @@ use smithay_client_toolkit::{ }; use wayland_client::{ - Connection, QueueHandle, delegate_noop, + Connection, Noop, QueueHandle, + globals::GlobalListHandler, protocol::{ wl_output::{self, WlOutput}, wl_pointer::WlPointer, - wl_region::WlRegion, wl_seat, wl_surface::{self, WlSurface}, }, @@ -60,7 +57,6 @@ fn main() { let pool = SlotPool::new(256 * 256 * 4, &shm).unwrap(); let mut simple_window = App { - registry_state: RegistryState::new(&globals), output_state: OutputState::new(&globals, &qh), compositor_state, seat_state: SeatState::new(&globals, &qh), @@ -87,7 +83,6 @@ fn main() { } struct App { - registry_state: RegistryState, output_state: OutputState, compositor_state: CompositorState, seat_state: SeatState, @@ -160,7 +155,7 @@ impl WindowHandler for App { } if let Some(pointer) = &self.pointer { - let region = self.compositor_state.wl_compositor().create_region(qh, ()); + let region = self.compositor_state.wl_compositor().create_region(qh, Noop); let w = self.width as i32; let h = self.height as i32; @@ -208,19 +203,6 @@ impl App { } } -delegate_compositor!(App); -delegate_output!(App); -delegate_shm!(App); - -delegate_xdg_shell!(App); -delegate_xdg_window!(App); - -delegate_registry!(App); -delegate_seat!(App); -delegate_pointer!(App); -delegate_pointer_constraints!(App); -delegate_noop!(App: WlRegion); - impl SeatHandler for App { fn seat_state(&mut self) -> &mut SeatState { &mut self.seat_state @@ -347,9 +329,6 @@ impl ShmHandler for App { } } -impl ProvidesRegistryState for App { - fn registry(&mut self) -> &mut RegistryState { - &mut self.registry_state - } +impl GlobalListHandler for App { registry_handlers![OutputState,]; } diff --git a/test_clients/src/bin/test_subsurface.rs b/test_clients/src/bin/test_subsurface.rs index c6da8706afb2..b78519045070 100644 --- a/test_clients/src/bin/test_subsurface.rs +++ b/test_clients/src/bin/test_subsurface.rs @@ -1,16 +1,12 @@ //! Attempt to reproduce https://github.com/Smithay/smithay/issues/1894 -use smithay_client_toolkit::delegate_subcompositor; use smithay_client_toolkit::reexports::client::protocol::wl_subsurface::WlSubsurface; use smithay_client_toolkit::reexports::{calloop, client as wayland_client}; use smithay_client_toolkit::subcompositor::SubcompositorState; use smithay_client_toolkit::{ compositor::{CompositorHandler, CompositorState}, - delegate_compositor, delegate_output, delegate_registry, delegate_shm, delegate_xdg_shell, - delegate_xdg_window, output::{OutputHandler, OutputState}, - registry::{ProvidesRegistryState, RegistryState}, registry_handlers, shell::{ WaylandSurface, @@ -27,6 +23,7 @@ use smithay_client_toolkit::{ use tracing::info; use wayland_client::{ Connection, QueueHandle, + globals::GlobalListHandler, protocol::{ wl_output::{self, WlOutput}, wl_surface::{self, WlSurface}, @@ -51,7 +48,6 @@ fn main() { let pool = SlotPool::new(256 * 256 * 4, &shm).unwrap(); let mut app = App { - registry_state: RegistryState::new(&globals), output_state: OutputState::new(&globals, &qh), shm, @@ -75,7 +71,6 @@ fn main() { } struct App { - registry_state: RegistryState, output_state: OutputState, shm: Shm, @@ -202,17 +197,6 @@ impl App { } } -delegate_compositor!(App); -delegate_subcompositor!(App); - -delegate_output!(App); -delegate_shm!(App); - -delegate_xdg_shell!(App); -delegate_xdg_window!(App); - -delegate_registry!(App); - impl OutputHandler for App { fn output_state(&mut self) -> &mut OutputState { &mut self.output_state @@ -228,9 +212,6 @@ impl ShmHandler for App { } } -impl ProvidesRegistryState for App { - fn registry(&mut self) -> &mut RegistryState { - &mut self.registry_state - } +impl GlobalListHandler for App { registry_handlers![OutputState,]; } diff --git a/test_clients/src/bin/test_xdg_map_unmap.rs b/test_clients/src/bin/test_xdg_map_unmap.rs index c2dcc3ce465a..cc070fc28ade 100644 --- a/test_clients/src/bin/test_xdg_map_unmap.rs +++ b/test_clients/src/bin/test_xdg_map_unmap.rs @@ -6,10 +6,7 @@ use smithay_client_toolkit::reexports::{calloop, client as wayland_client}; use smithay_client_toolkit::{ compositor::{CompositorHandler, CompositorState}, - delegate_compositor, delegate_output, delegate_registry, delegate_shm, delegate_xdg_shell, - delegate_xdg_window, output::{OutputHandler, OutputState}, - registry::{ProvidesRegistryState, RegistryState}, registry_handlers, shell::{ WaylandSurface, @@ -26,6 +23,7 @@ use smithay_client_toolkit::{ use tracing::info; use wayland_client::{ Connection, QueueHandle, + globals::GlobalListHandler, protocol::{ wl_output::{self, WlOutput}, wl_surface::{self, WlSurface}, @@ -47,7 +45,6 @@ fn main() { let pool = SlotPool::new(256 * 256 * 4, &shm).unwrap(); let mut simple_window = App { - registry_state: RegistryState::new(&globals), output_state: OutputState::new(&globals, &qh), shm, @@ -75,7 +72,6 @@ fn main() { } struct App { - registry_state: RegistryState, output_state: OutputState, shm: Shm, @@ -184,15 +180,6 @@ impl App { } } -delegate_compositor!(App); -delegate_output!(App); -delegate_shm!(App); - -delegate_xdg_shell!(App); -delegate_xdg_window!(App); - -delegate_registry!(App); - impl OutputHandler for App { fn output_state(&mut self) -> &mut OutputState { &mut self.output_state @@ -208,9 +195,6 @@ impl ShmHandler for App { } } -impl ProvidesRegistryState for App { - fn registry(&mut self) -> &mut RegistryState { - &mut self.registry_state - } +impl GlobalListHandler for App { registry_handlers![OutputState,]; } diff --git a/test_clients/src/lib.rs b/test_clients/src/lib.rs index 2be5139dc182..a809057d47bd 100644 --- a/test_clients/src/lib.rs +++ b/test_clients/src/lib.rs @@ -1,11 +1,11 @@ use smithay_client_toolkit::{ + compositor::{CompositorHandler, FrameCallbackData}, reexports::{ calloop, calloop_wayland_source::WaylandSource, client::{ self as wayland_client, - globals::GlobalList, - protocol::{wl_callback::WlCallback, wl_shm, wl_surface::WlSurface}, + protocol::{wl_shm, wl_surface::WlSurface}, }, }, shm::slot::{Buffer, SlotPool}, @@ -13,8 +13,8 @@ use smithay_client_toolkit::{ use calloop::EventLoop; use wayland_client::{ - Connection, Dispatch, QueueHandle, globals::GlobalListContents, globals::registry_queue_init, - protocol::wl_registry::WlRegistry, + Connection, QueueHandle, + globals::{GlobalList, GlobalListHandler}, }; pub fn init_logging() { @@ -30,12 +30,13 @@ pub fn init_logging() { pub fn init_connection() -> (EventLoop<'static, APP>, GlobalList, QueueHandle) where - APP: Dispatch + 'static, + APP: GlobalListHandler + 'static, { - let conn = Connection::connect_to_env().unwrap(); + let conn = unsafe { Connection::connect_to_env().unwrap() }; - let (globals, event_queue) = registry_queue_init(&conn).unwrap(); + let event_queue = conn.new_event_queue(); let qh = event_queue.handle(); + let globals = GlobalList::init(&conn, &qh).unwrap(); let event_loop: EventLoop = EventLoop::try_new().unwrap(); let loop_handle = event_loop.handle(); WaylandSource::new(conn.clone(), event_queue) @@ -70,8 +71,7 @@ pub fn draw( height: u32, shift: &mut u32, ) where - D: 'static, - D: Dispatch, + D: CompositorHandler + 'static, { let stride = width as i32 * 4; @@ -100,7 +100,7 @@ pub fn draw( wl_surface.damage_buffer(0, 0, width as i32, height as i32); - wl_surface.frame(qh, wl_surface.clone()); + wl_surface.frame(qh, FrameCallbackData(wl_surface.clone())); buffer.attach_to(wl_surface).expect("buffer attach"); wl_surface.commit();