diff --git a/Cargo.toml b/Cargo.toml index aef1b55c1f67..abe7693cfcf1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -145,3 +145,12 @@ harness = false [profile.release-with-debug] inherits = "release" debug = true + +[patch.crates-io] +wayland-sys = { git = "https://github.com/smithay/wayland-rs", branch = "dispatch" } +wayland-egl = { git = "https://github.com/smithay/wayland-rs", branch = "dispatch" } +wayland-backend = { git = "https://github.com/smithay/wayland-rs", branch = "dispatch" } +wayland-server = { git = "https://github.com/smithay/wayland-rs", branch = "dispatch" } +# wayland-client = { git = "https://github.com/smithay/wayland-rs", branch = "dispatch" } +# wayland-protocols = { git = "https://github.com/smithay/wayland-rs", branch = "dispatch" } +# wayland-protocols-wlr = { git = "https://github.com/smithay/wayland-rs", branch = "dispatch" } diff --git a/anvil/src/state.rs b/anvil/src/state.rs index d92372e61d15..31f40ef0bede 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, @@ -607,8 +606,6 @@ impl ImageCopyCaptureHandler for AnvilState { } } -delegate_dispatch2!(@ AnvilState); - impl AnvilState { pub fn init( display: Display>, diff --git a/src/wayland/alpha_modifier/dispatch.rs b/src/wayland/alpha_modifier/dispatch.rs index f0ac34b6e1c4..7e19613be167 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, diff --git a/src/wayland/alpha_modifier/mod.rs b/src/wayland/alpha_modifier/mod.rs index d6bc168bda36..db2ccc79e73e 100644 --- a/src/wayland/alpha_modifier/mod.rs +++ b/src/wayland/alpha_modifier/mod.rs @@ -161,10 +161,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..470d0c96126b 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( diff --git a/src/wayland/background_effect/mod.rs b/src/wayland/background_effect/mod.rs index 763be21e45f2..ad4b663af699 100644 --- a/src/wayland/background_effect/mod.rs +++ b/src/wayland/background_effect/mod.rs @@ -144,7 +144,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/commit_timing/mod.rs b/src/wayland/commit_timing/mod.rs index fe1d446a8f41..5218163e5fe8 100644 --- a/src/wayland/commit_timing/mod.rs +++ b/src/wayland/commit_timing/mod.rs @@ -92,10 +92,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 +111,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 +122,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 +129,6 @@ impl CommitTimingManagerState { fn new_internal(display: &DisplayHandle, is_managed: bool) -> Self where - D: GlobalDispatch, D: 'static, { let global = @@ -160,9 +154,8 @@ pub struct CommitTimingManagerData { is_managed: bool, } -impl GlobalDispatch2 for CommitTimingManagerData +impl GlobalDispatch for CommitTimingManagerData where - D: Dispatch, D: 'static, { fn bind( @@ -177,9 +170,8 @@ where } } -impl Dispatch2 for CommitTimingManagerData +impl Dispatch for CommitTimingManagerData where - D: Dispatch, D: 'static, { fn request( @@ -257,7 +249,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..d973bda51962 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, WEnum, 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, { @@ -373,7 +367,7 @@ pub struct RegionUserData { pub(crate) inner: Mutex, } -impl Dispatch2 for RegionUserData +impl Dispatch for RegionUserData where D: CompositorHandler, { @@ -416,10 +410,8 @@ where * wl_subcompositor */ -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, - D: Dispatch, D: CompositorHandler, D: 'static, { @@ -435,9 +427,8 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, D: CompositorHandler, D: 'static, { @@ -552,7 +543,7 @@ pub fn is_effectively_sync(surface: &wl_surface::WlSurface) -> bool { } } -impl Dispatch2 for SubsurfaceUserData +impl Dispatch for SubsurfaceUserData where D: CompositorHandler, D: 'static, @@ -641,7 +632,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 169b7560a683..aee3d9b09465 100644 --- a/src/wayland/compositor/mod.rs +++ b/src/wayland/compositor/mod.rs @@ -684,7 +684,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) } @@ -698,14 +698,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..7799fc4dee7e 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, diff --git a/src/wayland/content_type/mod.rs b/src/wayland/content_type/mod.rs index da99a7ad68a5..f346c9657399 100644 --- a/src/wayland/content_type/mod.rs +++ b/src/wayland/content_type/mod.rs @@ -156,7 +156,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 0c6cf1e6ba5b..aac6809cc7a7 100644 --- a/src/wayland/cursor_shape.rs +++ b/src/wayland/cursor_shape.rs @@ -103,18 +103,17 @@ 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::utils::Serial; +use crate::wayland::GlobalData; use crate::wayland::seat::{WaylandFocus, pointer::allow_setting_cursor}; -use crate::wayland::{Dispatch2, GlobalData, GlobalDispatch2}; use super::seat::PointerUserData; use super::tablet_manager::{TabletSeatHandler, TabletToolUserData}; @@ -129,9 +128,8 @@ impl CursorShapeManagerState { /// Register new [CursorShapeManager] global. pub fn new(display: &DisplayHandle) -> Self where - D: GlobalDispatch, - D: Dispatch, - D: SeatHandler, + D: TabletSeatHandler, + ::PointerFocus: WaylandFocus, D: 'static, { let global = display.create_global::(2, GlobalData); @@ -144,10 +142,10 @@ impl CursorShapeManagerState { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, - D: SeatHandler, + D: TabletSeatHandler, + ::PointerFocus: WaylandFocus, D: 'static, { fn bind( @@ -162,10 +160,10 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch>, - D: SeatHandler, + D: TabletSeatHandler, + ::PointerFocus: WaylandFocus, D: 'static, { fn request( @@ -234,7 +232,7 @@ pub(crate) enum CursorShapeDeviceUserDataInner { Tablet(Weak), } -impl Dispatch2 for CursorShapeDeviceUserData +impl Dispatch for CursorShapeDeviceUserData where D: SeatHandler + TabletSeatHandler, ::PointerFocus: WaylandFocus, 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 beff84a2c9aa..604876e9c961 100644 --- a/src/wayland/dmabuf/dispatch.rs +++ b/src/wayland/dmabuf/dispatch.rs @@ -4,15 +4,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::{ @@ -20,7 +18,7 @@ use super::{ ImportNotifier, Modifier, SurfaceDmabufFeedbackState, }; -impl Dispatch2 for Dmabuf +impl Dispatch for Dmabuf where D: BufferHandler, { @@ -47,12 +45,9 @@ where } } -impl Dispatch2 for DmabufData +impl Dispatch for DmabufData where - D: Dispatch - + Dispatch - + DmabufHandler - + 'static, + D: DmabufHandler + 'static, { fn request( &self, @@ -141,7 +136,7 @@ where } } -impl Dispatch2 for DmabufFeedbackData { +impl Dispatch for DmabufFeedbackData { fn request( &self, _state: &mut D, @@ -171,9 +166,9 @@ impl Dispatch2 for } } -impl GlobalDispatch2 for DmabufGlobalData +impl GlobalDispatch for DmabufGlobalData where - D: Dispatch + 'static, + D: DmabufHandler + 'static, { fn bind( &self, @@ -219,9 +214,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 1892db50b788..29858b10fe68 100644 --- a/src/wayland/dmabuf/mod.rs +++ b/src/wayland/dmabuf/mod.rs @@ -575,10 +575,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) } @@ -598,10 +595,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::>(); @@ -622,10 +616,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) } @@ -644,10 +635,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::( @@ -666,10 +654,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(); @@ -854,11 +839,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(); diff --git a/src/wayland/drm_lease/mod.rs b/src/wayland/drm_lease/mod.rs index 7607bc521732..a011e4d1561c 100644 --- a/src/wayland/drm_lease/mod.rs +++ b/src/wayland/drm_lease/mod.rs @@ -91,10 +91,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)] @@ -383,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) } @@ -399,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 @@ -432,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; @@ -530,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 @@ -575,9 +562,7 @@ impl DrmLeaseState { fn remove_lease(&mut self, id: u32) -> Option where - D: DrmLeaseHandler - + Dispatch - + 'static, + D: DrmLeaseHandler + 'static, { let lease_ref = { if let Some(pos) = self @@ -638,9 +623,7 @@ impl DrmLeaseConnector { client: &Client, ) -> Option where - D: DrmLeaseHandler - + Dispatch - + 'static, + D: DrmLeaseHandler + 'static, { if let Ok(lease_connector) = client .create_resource::( @@ -665,12 +648,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 +692,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 +733,7 @@ pub struct DrmLeaseConnectorData { node: DrmNode, } -impl Dispatch2 for DrmLeaseConnectorData +impl Dispatch for DrmLeaseConnectorData where D: DrmLeaseHandler + 'static, { @@ -783,9 +761,9 @@ where } } -impl Dispatch2 for DrmLeaseRequestData +impl Dispatch for DrmLeaseRequestData where - D: DrmLeaseHandler + Dispatch + 'static, + D: DrmLeaseHandler + 'static, { fn request( &self, @@ -898,11 +876,9 @@ where } } -impl Dispatch2 for DrmLeaseData +impl Dispatch for DrmLeaseData where - D: DrmLeaseHandler - + Dispatch - + 'static, + D: DrmLeaseHandler + 'static, { fn request( &self, diff --git a/src/wayland/drm_syncobj/mod.rs b/src/wayland/drm_syncobj/mod.rs index ab58331a40ed..9436b295993d 100644 --- a/src/wayland/drm_syncobj/mod.rs +++ b/src/wayland/drm_syncobj/mod.rs @@ -58,10 +58,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 +130,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 +140,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 +199,9 @@ impl<'a> CloseGuard<'a> { } } -impl GlobalDispatch2 for DrmSyncobjGlobalData +impl GlobalDispatch for DrmSyncobjGlobalData where - D: Dispatch, + D: DrmSyncobjHandler, { fn bind( &self, @@ -296,10 +291,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 +378,7 @@ pub struct DrmSyncobjSurfaceData { destruction_hook_id: HookId, } -impl Dispatch2 for DrmSyncobjSurfaceData +impl Dispatch for DrmSyncobjSurfaceData where D: DrmSyncobjHandler, { @@ -486,7 +479,7 @@ pub struct DrmSyncobjTimelineData { timeline: DrmTimeline, } -impl Dispatch2 for DrmSyncobjTimelineData { +impl Dispatch for DrmSyncobjTimelineData { fn request( &self, _state: &mut D, diff --git a/src/wayland/fifo/mod.rs b/src/wayland/fifo/mod.rs index 5088b98375ee..608dc5f511df 100644 --- a/src/wayland/fifo/mod.rs +++ b/src/wayland/fifo/mod.rs @@ -89,10 +89,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 +107,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 +118,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 +125,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 +149,8 @@ pub struct FifoManagerData { is_managed: bool, } -impl GlobalDispatch2 for FifoManagerData +impl GlobalDispatch for FifoManagerData where - D: Dispatch, D: 'static, { fn bind( @@ -174,9 +165,8 @@ where } } -impl Dispatch2 for FifoManagerData +impl Dispatch for FifoManagerData where - D: Dispatch, D: 'static, { fn request( @@ -286,7 +276,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 7d3d2dd4df77..eae51a9f77d4 100644 --- a/src/wayland/foreign_toplevel_list/mod.rs +++ b/src/wayland/foreign_toplevel_list/mod.rs @@ -46,10 +46,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 { @@ -292,8 +289,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) } @@ -304,8 +300,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, @@ -335,7 +330,7 @@ impl ForeignToplevelListState { app_id: impl Into, ) -> ForeignToplevelHandle where - D: ForeignToplevelListHandler + Dispatch, + D: ForeignToplevelListHandler, { let handle = ForeignToplevelHandle::new( title.into(), @@ -407,11 +402,10 @@ impl std::fmt::Debug for ForeignToplevelListGlobalData { } } -impl GlobalDispatch2 +impl GlobalDispatch for ForeignToplevelListGlobalData where - D: Dispatch - + Dispatch, + D: ForeignToplevelListHandler, { fn bind( &self, @@ -456,7 +450,7 @@ where } } -impl Dispatch2 for GlobalData { +impl Dispatch for GlobalData { fn request( &self, state: &mut D, @@ -484,7 +478,7 @@ impl Dispatch2 for G } } -impl Dispatch2 for ForeignToplevelHandle { +impl Dispatch for ForeignToplevelHandle { fn request( &self, _state: &mut D, diff --git a/src/wayland/fractional_scale/mod.rs b/src/wayland/fractional_scale/mod.rs index 90a16bcb2a19..ef237643d49c 100644 --- a/src/wayland/fractional_scale/mod.rs +++ b/src/wayland/fractional_scale/mod.rs @@ -71,7 +71,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 +83,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 +99,8 @@ impl FractionalScaleManagerState { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch - + Dispatch, D: FractionalScaleHandler, { fn bind( @@ -121,9 +115,8 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, D: FractionalScaleHandler, { fn request( @@ -179,7 +172,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..45fcd7907648 100644 --- a/src/wayland/idle_inhibit/inhibitor.rs +++ b/src/wayland/idle_inhibit/inhibitor.rs @@ -5,7 +5,7 @@ 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 crate::wayland::Dispatch2; +use crate::wayland::Dispatch; use crate::wayland::idle_inhibit::IdleInhibitHandler; /// State of zwp_idle_inhibitor_v1. @@ -21,7 +21,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..0f31af4b69ef 100644 --- a/src/wayland/idle_inhibit/mod.rs +++ b/src/wayland/idle_inhibit/mod.rs @@ -39,8 +39,8 @@ 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 +56,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 +70,8 @@ impl IdleInhibitManagerState { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, D: IdleInhibitHandler, D: 'static, { @@ -89,9 +87,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 ac012d2875d6..42c96ef6e7e1 100644 --- a/src/wayland/idle_notify/mod.rs +++ b/src/wayland/idle_notify/mod.rs @@ -61,7 +61,7 @@ use wayland_server::{ use crate::{ input::{Seat, SeatHandler}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, + wayland::GlobalData, }; /// Handler trait for ext-idle-notify @@ -113,7 +113,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, { @@ -236,9 +235,8 @@ impl IdleNotifierState { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, D: IdleNotifierHandler, D: 'static, { @@ -254,9 +252,8 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, D: IdleNotifierHandler, D: 'static, { @@ -326,7 +323,7 @@ where } } -impl Dispatch2 for IdleNotificationUserData +impl Dispatch for IdleNotificationUserData where D: IdleNotifierHandler, { diff --git a/src/wayland/image_capture_source/mod.rs b/src/wayland/image_capture_source/mod.rs index 099a8ca37ced..2a92815ee2be 100644 --- a/src/wayland/image_capture_source/mod.rs +++ b/src/wayland/image_capture_source/mod.rs @@ -143,8 +143,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 +294,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 +308,7 @@ pub trait ImageCaptureSourceHandler: } // Dispatch for the capture source resource -impl Dispatch2 for ImageCaptureSourceData +impl Dispatch for ImageCaptureSourceData where D: ImageCaptureSourceHandler, { @@ -395,11 +393,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 +409,7 @@ pub trait OutputCaptureSourceHandler: } } -impl GlobalDispatch2 for OutputCaptureSourceGlobalData +impl GlobalDispatch for OutputCaptureSourceGlobalData where D: OutputCaptureSourceHandler, { @@ -435,7 +429,7 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where D: OutputCaptureSourceHandler, { @@ -533,11 +527,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 +543,7 @@ pub trait ToplevelCaptureSourceHandler: } } -impl GlobalDispatch2 for ToplevelCaptureSourceGlobalData +impl GlobalDispatch for ToplevelCaptureSourceGlobalData where D: ToplevelCaptureSourceHandler, { @@ -573,7 +563,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 a67fe7cad292..f7a81d12f8b7 100644 --- a/src/wayland/image_copy_capture/mod.rs +++ b/src/wayland/image_copy_capture/mod.rs @@ -112,10 +112,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; @@ -755,15 +755,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; @@ -940,7 +932,7 @@ impl ImageCopyCaptureState { // Dispatch implementations // ============================================================================ -impl GlobalDispatch2 for ImageCopyCaptureGlobalData +impl GlobalDispatch for ImageCopyCaptureGlobalData where D: ImageCopyCaptureHandler, { @@ -960,7 +952,7 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where D: ImageCopyCaptureHandler, { @@ -1093,7 +1085,7 @@ where } } -impl Dispatch2 for SessionData +impl Dispatch for SessionData where D: ImageCopyCaptureHandler, { @@ -1138,7 +1130,7 @@ where } // Dispatch for session created from cursor session's get_capture_session -impl Dispatch2 for CursorSessionData +impl Dispatch for CursorSessionData where D: ImageCopyCaptureHandler, { @@ -1168,7 +1160,7 @@ where } } -impl Dispatch2 for CursorSessionData +impl Dispatch for CursorSessionData where D: ImageCopyCaptureHandler, { @@ -1242,7 +1234,7 @@ where } } -impl Dispatch2 for FrameData +impl Dispatch for FrameData where D: ImageCopyCaptureHandler, { diff --git a/src/wayland/input_method/input_method_handle.rs b/src/wayland/input_method/input_method_handle.rs index af28164b4562..d4ed7ea39985 100644 --- a/src/wayland/input_method/input_method_handle.rs +++ b/src/wayland/input_method/input_method_handle.rs @@ -17,7 +17,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 +185,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, diff --git a/src/wayland/input_method/input_method_keyboard_grab.rs b/src/wayland/input_method/input_method_keyboard_grab.rs index a1f99bbfe38b..5afdde3529e6 100644 --- a/src/wayland/input_method/input_method_keyboard_grab.rs +++ b/src/wayland/input_method/input_method_keyboard_grab.rs @@ -19,7 +19,7 @@ use crate::wayland::text_input::TextInputHandle; use crate::{ backend::input::{KeyState, Keycode}, utils::Serial, - wayland::Dispatch2, + wayland::Dispatch, }; #[derive(Default, Debug)] @@ -98,7 +98,7 @@ impl fmt::Debug for InputMethodKeyboardUserData { } } -impl Dispatch2 for InputMethodKeyboardUserData { +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..978c12b8475e 100644 --- a/src/wayland/input_method/input_method_popup_surface.rs +++ b/src/wayland/input_method/input_method_popup_surface.rs @@ -10,7 +10,7 @@ use crate::{ Logical, Point, Rectangle, alive_tracker::{AliveTracker, IsAlive}, }, - wayland::Dispatch2, + wayland::Dispatch, }; /// Handle to a popup surface @@ -130,7 +130,7 @@ pub struct InputMethodPopupSurfaceUserData { pub(super) alive_tracker: AliveTracker, } -impl Dispatch2 for InputMethodPopupSurfaceUserData { +impl Dispatch for InputMethodPopupSurfaceUserData { fn request( &self, _state: &mut D, diff --git a/src/wayland/input_method/mod.rs b/src/wayland/input_method/mod.rs index a9135a37b701..cb1e4c4fe38d 100644 --- a/src/wayland/input_method/mod.rs +++ b/src/wayland/input_method/mod.rs @@ -68,7 +68,7 @@ use wayland_protocols_misc::zwp_input_method_v2::server::{ use crate::{ input::{Seat, SeatHandler}, utils::{Logical, Rectangle}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, + wayland::{GlobalData, seat::WaylandFocus}, }; pub use input_method_handle::{InputMethodHandle, InputMethodUserData}; @@ -88,7 +88,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); @@ -132,11 +132,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 { @@ -153,12 +150,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, @@ -176,11 +171,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..aa3479985168 100644 --- a/src/wayland/keyboard_shortcuts_inhibit/dispatch.rs +++ b/src/wayland/keyboard_shortcuts_inhibit/dispatch.rs @@ -8,14 +8,14 @@ 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}, + wayland::GlobalData, }; use super::KeyboardShortcutsInhibitHandler; @@ -30,11 +30,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 +46,9 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where D: KeyboardShortcutsInhibitHandler, - D: SeatHandler, - D: Dispatch, { fn request( &self, @@ -111,7 +107,7 @@ where } } -impl Dispatch2 for KeyboardShortcutsInhibitorUserData +impl Dispatch for KeyboardShortcutsInhibitorUserData where D: KeyboardShortcutsInhibitHandler, { diff --git a/src/wayland/keyboard_shortcuts_inhibit/mod.rs b/src/wayland/keyboard_shortcuts_inhibit/mod.rs index 76e0eaac2042..c72d981f16d3 100644 --- a/src/wayland/keyboard_shortcuts_inhibit/mod.rs +++ b/src/wayland/keyboard_shortcuts_inhibit/mod.rs @@ -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); @@ -227,7 +224,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..6701c3a49f57 100644 --- a/src/wayland/mod.rs +++ b/src/wayland/mod.rs @@ -47,6 +47,7 @@ //! are not, for example). //! +pub use wayland_server::{Dispatch, GlobalDispatch}; // XXX pub mod alpha_modifier; pub mod background_effect; pub mod buffer; @@ -54,8 +55,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 9072682476c4..99aae83fa09f 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, @@ -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, { @@ -201,7 +199,7 @@ pub struct XdgOutputUserData { pub(super) client_scale: Arc, } -impl Dispatch2 for XdgOutputUserData { +impl Dispatch for XdgOutputUserData { fn request( &self, _state: &mut D, diff --git a/src/wayland/output/mod.rs b/src/wayland/output/mod.rs index e49c8749da45..aff0b3e984aa 100644 --- a/src/wayland/output/mod.rs +++ b/src/wayland/output/mod.rs @@ -93,7 +93,7 @@ use wayland_server::{ use crate::{ utils::{Logical, Point}, - wayland::GlobalData, + wayland::{GlobalData, compositor::CompositorHandler}, }; pub use self::handlers::XdgOutputUserData; @@ -111,7 +111,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) {} } @@ -127,9 +127,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); @@ -202,8 +200,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()); diff --git a/src/wayland/pointer_constraints.rs b/src/wayland/pointer_constraints.rs index 628b3cd7a50d..593bc8bcd52c 100644 --- a/src/wayland/pointer_constraints.rs +++ b/src/wayland/pointer_constraints.rs @@ -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; @@ -220,12 +220,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); @@ -352,13 +347,9 @@ fn remove_constraint(surface: &WlSurface, pointer: &Po }); } -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, @@ -442,9 +433,9 @@ where } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch + SeatHandler + 'static, + D: PointerConstraintsHandler + 'static, { fn bind( &self, @@ -458,10 +449,9 @@ where } } -impl Dispatch2 for PointerConstraintUserData +impl Dispatch for PointerConstraintUserData where - D: SeatHandler, - D: 'static, + D: PointerConstraintsHandler + 'static, { fn request( &self, @@ -505,10 +495,9 @@ where } } -impl Dispatch2 for PointerConstraintUserData +impl Dispatch for PointerConstraintUserData where - D: SeatHandler, - D: 'static, + D: PointerConstraintsHandler + 'static, { fn request( &self, diff --git a/src/wayland/pointer_gestures.rs b/src/wayland/pointer_gestures.rs index 83de01901f8e..8c160850f28c 100644 --- a/src/wayland/pointer_gestures.rs +++ b/src/wayland/pointer_gestures.rs @@ -120,7 +120,7 @@ use crate::{ }, }, utils::{SERIAL_COUNTER, Serial}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2, seat::PointerUserData}, + wayland::{GlobalData, seat::PointerUserData}, }; const MANAGER_VERSION: u32 = 3; @@ -378,11 +378,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, { @@ -397,11 +392,8 @@ impl PointerGesturesState { } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch>, - D: Dispatch>, - D: Dispatch>, D: SeatHandler, D: 'static, { @@ -457,9 +449,9 @@ where } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch + SeatHandler + 'static, + D: SeatHandler + 'static, { fn bind( &self, @@ -473,7 +465,7 @@ where } } -impl Dispatch2 for PointerGestureUserData +impl Dispatch for PointerGestureUserData where D: SeatHandler, D: 'static, @@ -505,7 +497,7 @@ where } } -impl Dispatch2 for PointerGestureUserData +impl Dispatch for PointerGestureUserData where D: SeatHandler, D: 'static, @@ -537,7 +529,7 @@ where } } -impl Dispatch2 for PointerGestureUserData +impl Dispatch for PointerGestureUserData where D: SeatHandler, D: 'static, diff --git a/src/wayland/pointer_warp.rs b/src/wayland/pointer_warp.rs index c3a658c837a9..b1ec734a5ade 100644 --- a/src/wayland/pointer_warp.rs +++ b/src/wayland/pointer_warp.rs @@ -56,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. @@ -91,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 } @@ -103,9 +103,9 @@ impl PointerWarpManager { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, + D: PointerWarpHandler, { fn bind( &self, @@ -119,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..bc2d2b2c9c41 100644 --- a/src/wayland/presentation/mod.rs +++ b/src/wayland/presentation/mod.rs @@ -76,10 +76,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 +95,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 +115,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 +129,7 @@ where } } -impl Dispatch2 for PresentationData -where - D: Dispatch, -{ +impl Dispatch for PresentationData { fn request( &self, _state: &mut D, @@ -173,7 +160,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 00ddbf72c2c8..59c6435a23f1 100644 --- a/src/wayland/relative_pointer.rs +++ b/src/wayland/relative_pointer.rs @@ -101,7 +101,7 @@ use crate::{ SeatHandler, pointer::{PointerHandle, RelativeMotionEvent}, }, - wayland::{Dispatch2, GlobalData, GlobalDispatch2, seat::PointerUserData}, + wayland::{GlobalData, seat::PointerUserData}, }; const MANAGER_VERSION: u32 = 1; @@ -170,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, { @@ -187,9 +184,8 @@ impl RelativePointerManagerState { } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch>, D: SeatHandler, D: 'static, { @@ -220,9 +216,9 @@ where } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch + SeatHandler + 'static, + D: SeatHandler + 'static, { fn bind( &self, @@ -236,7 +232,7 @@ where } } -impl Dispatch2 for RelativePointerUserData +impl Dispatch for RelativePointerUserData where D: SeatHandler, D: 'static, diff --git a/src/wayland/seat/keyboard.rs b/src/wayland/seat/keyboard.rs index f20ea0ed11c4..f7a43a8d35a1 100644 --- a/src/wayland/seat/keyboard.rs +++ b/src/wayland/seat/keyboard.rs @@ -19,7 +19,7 @@ use crate::{ }, utils::{HookId, Serial, iter::new_locked_obj_iter_from_vec}, wayland::{ - Dispatch2, + Dispatch, compositor::{add_destruction_hook, remove_destruction_hook, with_states}, input_method::InputMethodSeat, text_input::TextInputSeat, @@ -117,7 +117,7 @@ impl fmt::Debug for KeyboardUserData { } } -impl Dispatch2 for KeyboardUserData +impl Dispatch for KeyboardUserData where D: 'static, D: SeatHandler, diff --git a/src/wayland/seat/mod.rs b/src/wayland/seat/mod.rs index 5ce48d0924a4..fc0f123f737f 100644 --- a/src/wayland/seat/mod.rs +++ b/src/wayland/seat/mod.rs @@ -71,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, @@ -165,7 +164,7 @@ 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, N: Into, @@ -223,15 +222,11 @@ 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, ::KeyboardFocus: WaylandFocus, - D: 'static, + ::PointerFocus: WaylandFocus, { fn request( &self, @@ -313,14 +308,11 @@ 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, { fn bind( &self, diff --git a/src/wayland/seat/pointer.rs b/src/wayland/seat/pointer.rs index ac4a0e6f907d..36aa07f200a7 100644 --- a/src/wayland/seat/pointer.rs +++ b/src/wayland/seat/pointer.rs @@ -25,7 +25,7 @@ use crate::{ }, }, utils::{Client as ClientCoords, Point, Serial, iter::new_locked_obj_iter_from_vec}, - wayland::{Dispatch2, compositor, pointer_constraints::with_pointer_constraint}, + wayland::{Dispatch, compositor, pointer_constraints::with_pointer_constraint}, }; use super::{SeatHandler, WaylandFocus}; @@ -348,7 +348,7 @@ pub struct PointerUserData { pub(crate) client_scale: Arc, } -impl Dispatch2 for PointerUserData +impl Dispatch for PointerUserData where D: SeatHandler, ::PointerFocus: WaylandFocus, diff --git a/src/wayland/seat/touch.rs b/src/wayland/seat/touch.rs index a372370cba6c..cfec02e77fe3 100644 --- a/src/wayland/seat/touch.rs +++ b/src/wayland/seat/touch.rs @@ -13,7 +13,7 @@ use crate::input::{ Seat, touch::{MotionEvent, OrientationEvent, ShapeEvent, UpEvent}, }; -use crate::wayland::Dispatch2; +use crate::wayland::Dispatch; use crate::{input::touch::DownEvent, wayland::seat::wl_surface::WlSurface}; use crate::{input::touch::TouchHandle, utils::Serial}; @@ -136,7 +136,7 @@ pub struct TouchUserData { pub(crate) client_scale: Arc, } -impl Dispatch2 for TouchUserData +impl Dispatch for TouchUserData where D: SeatHandler, D: 'static, diff --git a/src/wayland/security_context/mod.rs b/src/wayland/security_context/mod.rs index dd99377af073..20b930a952bc 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, { diff --git a/src/wayland/selection/data_device/device.rs b/src/wayland/selection/data_device/device.rs index c9542e0dad0b..ce2c5f2aeecb 100644 --- a/src/wayland/selection/data_device/device.rs +++ b/src/wayland/selection/data_device/device.rs @@ -13,7 +13,7 @@ use crate::{ input::{Seat, SeatHandler, dnd::DndFocus}, utils::Serial, wayland::{ - Dispatch2, compositor, + Dispatch, 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, diff --git a/src/wayland/selection/data_device/mod.rs b/src/wayland/selection/data_device/mod.rs index 16a1a77db169..e991a419d71f 100644 --- a/src/wayland/selection/data_device/mod.rs +++ b/src/wayland/selection/data_device/mod.rs @@ -94,7 +94,7 @@ use crate::{ dnd::{DndAction, DndFocus, GrabType, OfferData, Source}, }, utils::{Logical, Point, Serial}, - wayland::GlobalData, + wayland::{GlobalData, seat::WaylandFocus}, }; mod device; @@ -573,8 +573,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); @@ -752,7 +754,7 @@ mod handlers { use tracing::error; use wayland_server::{ - Dispatch, DisplayHandle, + Dispatch, DisplayHandle, GlobalDispatch, protocol::{ wl_data_device::WlDataDevice, wl_data_device_manager::{self, WlDataDeviceManager}, @@ -761,20 +763,23 @@ mod handlers { }; 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( @@ -789,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..c0da1b384ec5 100644 --- a/src/wayland/selection/data_device/source.rs +++ b/src/wayland/selection/data_device/source.rs @@ -20,7 +20,7 @@ use crate::input::{ dnd::{DndAction, Source, SourceMetadata}, }; use crate::utils::{IsAlive, alive_tracker::AliveTracker}; -use crate::wayland::Dispatch2; +use crate::wayland::Dispatch; use crate::wayland::selection::offer::OfferReplySource; use crate::wayland::selection::seat_data::SeatData; use crate::wayland::selection::source::SelectionSourceProvider; @@ -45,7 +45,7 @@ impl DataSourceUserData { } } -impl Dispatch2 for DataSourceUserData +impl Dispatch for DataSourceUserData where D: DataDeviceHandler, D: 'static, diff --git a/src/wayland/selection/ext_data_control/device.rs b/src/wayland/selection/ext_data_control/device.rs index a58f7c177908..cfcc425429e0 100644 --- a/src/wayland/selection/ext_data_control/device.rs +++ b/src/wayland/selection/ext_data_control/device.rs @@ -8,7 +8,7 @@ use wayland_server::protocol::wl_seat::WlSeat; use wayland_server::{Client, DisplayHandle}; use crate::input::Seat; -use crate::wayland::Dispatch2; +use crate::wayland::Dispatch; use crate::wayland::selection::device::SelectionDevice; use crate::wayland::selection::offer::OfferReplySource; use crate::wayland::selection::seat_data::SeatData; @@ -24,7 +24,7 @@ pub struct ExtDataControlDeviceUserData { pub(crate) wl_seat: WlSeat, } -impl Dispatch2 for ExtDataControlDeviceUserData +impl Dispatch for ExtDataControlDeviceUserData where D: DataControlHandler, D: 'static, diff --git a/src/wayland/selection/ext_data_control/mod.rs b/src/wayland/selection/ext_data_control/mod.rs index 148521d07079..b39066e6a961 100644 --- a/src/wayland/selection/ext_data_control/mod.rs +++ b/src/wayland/selection/ext_data_control/mod.rs @@ -92,7 +92,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 { @@ -138,13 +138,12 @@ mod handlers { ext_data_control_manager_v1::{self, ExtDataControlManagerV1}, ext_data_control_source_v1::ExtDataControlSourceV1, }; - 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; @@ -152,9 +151,8 @@ mod handlers { use super::ExtDataControlManagerUserData; use super::ExtDataControlSourceUserData; - impl GlobalDispatch2 for ExtDataControlManagerGlobalData + impl GlobalDispatch for ExtDataControlManagerGlobalData where - D: Dispatch, D: DataControlHandler, D: 'static, { @@ -179,10 +177,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..f5ffdf1c0c9e 100644 --- a/src/wayland/selection/ext_data_control/source.rs +++ b/src/wayland/selection/ext_data_control/source.rs @@ -5,7 +5,7 @@ use wayland_server::DisplayHandle; use wayland_server::backend::ClientId; use crate::input::Seat; -use crate::wayland::Dispatch2; +use crate::wayland::Dispatch; use crate::wayland::selection::SelectionTarget; use crate::wayland::selection::offer::OfferReplySource; use crate::wayland::selection::seat_data::SeatData; @@ -40,7 +40,7 @@ pub struct SourceMetadata { pub mime_types: Vec, } -impl Dispatch2 for ExtDataControlSourceUserData +impl Dispatch for ExtDataControlSourceUserData where D: DataControlHandler, D: 'static, diff --git a/src/wayland/selection/primary_selection/device.rs b/src/wayland/selection/primary_selection/device.rs index 5d10d16258d8..b9b8c8825295 100644 --- a/src/wayland/selection/primary_selection/device.rs +++ b/src/wayland/selection/primary_selection/device.rs @@ -9,7 +9,7 @@ use wayland_server::{Client, DataInit, DisplayHandle, Resource, protocol::wl_sea use crate::{ input::{Seat, SeatHandler}, wayland::{ - Dispatch2, + Dispatch, seat::WaylandFocus, selection::{ SelectionHandler, SelectionTarget, @@ -29,7 +29,7 @@ pub struct PrimaryDeviceUserData { pub(crate) wl_seat: WlSeat, } -impl Dispatch2 for PrimaryDeviceUserData +impl Dispatch for PrimaryDeviceUserData where D: PrimarySelectionHandler, D: SelectionHandler, diff --git a/src/wayland/selection/primary_selection/mod.rs b/src/wayland/selection/primary_selection/mod.rs index d3af95e46c01..0cf7a6744e46 100644 --- a/src/wayland/selection/primary_selection/mod.rs +++ b/src/wayland/selection/primary_selection/mod.rs @@ -79,7 +79,7 @@ use wayland_server::{Client, DisplayHandle, GlobalDispatch}; use crate::{ input::{Seat, SeatHandler}, - wayland::selection::SelectionTarget, + wayland::{seat::WaylandFocus, selection::SelectionTarget}, }; mod device; @@ -121,8 +121,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) } @@ -132,8 +133,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 { @@ -306,12 +308,13 @@ mod handlers { zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1 as PrimaryDevice, zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1 as PrimarySource, }; - 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}, }, }; @@ -321,12 +324,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( @@ -345,12 +346,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..2c607a797105 100644 --- a/src/wayland/selection/primary_selection/source.rs +++ b/src/wayland/selection/primary_selection/source.rs @@ -8,7 +8,7 @@ use wayland_server::{DisplayHandle, backend::ClientId}; use crate::{ input::Seat, wayland::{ - Dispatch2, + Dispatch, selection::{offer::OfferReplySource, seat_data::SeatData, source::SelectionSourceProvider}, }, }; @@ -38,7 +38,7 @@ impl PrimarySourceUserData { } } -impl Dispatch2 for PrimarySourceUserData +impl Dispatch for PrimarySourceUserData where D: PrimarySelectionHandler, D: 'static, diff --git a/src/wayland/selection/wlr_data_control/device.rs b/src/wayland/selection/wlr_data_control/device.rs index 6048dd19b9f9..f17d3b2bbc32 100644 --- a/src/wayland/selection/wlr_data_control/device.rs +++ b/src/wayland/selection/wlr_data_control/device.rs @@ -8,7 +8,7 @@ use wayland_server::protocol::wl_seat::WlSeat; use wayland_server::{Client, DisplayHandle, Resource}; use crate::input::Seat; -use crate::wayland::Dispatch2; +use crate::wayland::Dispatch; use crate::wayland::selection::device::SelectionDevice; use crate::wayland::selection::offer::OfferReplySource; use crate::wayland::selection::seat_data::SeatData; @@ -24,7 +24,7 @@ pub struct DataControlDeviceUserData { pub(crate) wl_seat: WlSeat, } -impl Dispatch2 for DataControlDeviceUserData +impl Dispatch for DataControlDeviceUserData where D: DataControlHandler, D: 'static, diff --git a/src/wayland/selection/wlr_data_control/mod.rs b/src/wayland/selection/wlr_data_control/mod.rs index 4c922f2178db..3ded3930ba09 100644 --- a/src/wayland/selection/wlr_data_control/mod.rs +++ b/src/wayland/selection/wlr_data_control/mod.rs @@ -93,7 +93,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 { @@ -142,13 +142,12 @@ mod handlers { 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; @@ -156,11 +155,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, { @@ -185,10 +181,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..9295c962bbf6 100644 --- a/src/wayland/selection/wlr_data_control/source.rs +++ b/src/wayland/selection/wlr_data_control/source.rs @@ -8,7 +8,7 @@ use wayland_server::DisplayHandle; use wayland_server::backend::ClientId; use crate::input::Seat; -use crate::wayland::Dispatch2; +use crate::wayland::Dispatch; use crate::wayland::selection::SelectionTarget; use crate::wayland::selection::offer::OfferReplySource; use crate::wayland::selection::seat_data::SeatData; @@ -39,7 +39,7 @@ pub struct SourceMetadata { pub mime_types: Vec, } -impl Dispatch2 for DataControlSourceUserData +impl Dispatch for DataControlSourceUserData where D: DataControlHandler, D: 'static, diff --git a/src/wayland/session_lock/lock.rs b/src/wayland/session_lock/lock.rs index 5655c9a7b4c7..6707c05292aa 100644 --- a/src/wayland/session_lock/lock.rs +++ b/src/wayland/session_lock/lock.rs @@ -10,7 +10,6 @@ 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::{Client, DataInit, Dispatch, DisplayHandle, Resource}; -use crate::wayland::Dispatch2; use crate::wayland::session_lock::SessionLockHandler; use crate::wayland::session_lock::surface::{ExtLockSurfaceUserData, LockSurface, LockSurfaceAttributes}; @@ -31,11 +30,9 @@ impl SessionLockState { } } -impl Dispatch2 for SessionLockState +impl Dispatch for SessionLockState where - D: Dispatch, - D: SessionLockHandler, - D: 'static, + D: SessionLockHandler + 'static, { fn request( &self, diff --git a/src/wayland/session_lock/mod.rs b/src/wayland/session_lock/mod.rs index c37d35c3016e..7aa773fa766f 100644 --- a/src/wayland/session_lock/mod.rs +++ b/src/wayland/session_lock/mod.rs @@ -58,7 +58,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; @@ -81,11 +81,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 { @@ -106,11 +102,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, @@ -128,11 +122,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 d8b2f2db04de..791e5690301b 100644 --- a/src/wayland/session_lock/surface.rs +++ b/src/wayland/session_lock/surface.rs @@ -12,7 +12,7 @@ use wayland_protocols::ext::session_lock::v1::server::{self as _session_lock, ex use wayland_server::protocol::wl_surface::WlSurface; use wayland_server::{Client, DataInit, DisplayHandle, Resource, Weak}; -use crate::wayland::Dispatch2; +use crate::wayland::Dispatch; use crate::wayland::session_lock::SessionLockHandler; /// User data for ext-session-lock surfaces. @@ -24,7 +24,7 @@ pub struct ExtLockSurfaceUserData { pub(crate) surface: Weak, } -impl Dispatch2 for ExtLockSurfaceUserData +impl Dispatch for ExtLockSurfaceUserData where D: SessionLockHandler, D: 'static, diff --git a/src/wayland/shell/kde/decoration.rs b/src/wayland/shell/kde/decoration.rs index 2bb4dc3a1315..785f9e9663a6 100644 --- a/src/wayland/shell/kde/decoration.rs +++ b/src/wayland/shell/kde/decoration.rs @@ -98,11 +98,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 +108,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..29542284d9f1 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, { diff --git a/src/wayland/shell/wlr_layer/mod.rs b/src/wayland/shell/wlr_layer/mod.rs index 60f3c774e6bf..6b43003e68a8 100644 --- a/src/wayland/shell/wlr_layer/mod.rs +++ b/src/wayland/shell/wlr_layer/mod.rs @@ -216,8 +216,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 +224,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/xdg/decoration.rs b/src/wayland/shell/xdg/decoration.rs index bb66b1f725e6..b6818ac243bf 100644 --- a/src/wayland/shell/xdg/decoration.rs +++ b/src/wayland/shell/xdg/decoration.rs @@ -95,7 +95,7 @@ use wayland_server::{ }; 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)] @@ -115,11 +115,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) } @@ -131,11 +127,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 { @@ -154,7 +146,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); @@ -172,14 +164,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, @@ -197,12 +185,9 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch - + XdgShellHandler - + XdgDecorationHandler - + 'static, + D: XdgDecorationHandler + 'static, { fn request( &self, @@ -255,7 +240,7 @@ where // zxdg_toplevel_decoration_v1 -impl Dispatch2 for ToplevelSurface +impl Dispatch for ToplevelSurface where D: XdgDecorationHandler, { diff --git a/src/wayland/shell/xdg/dialog.rs b/src/wayland/shell/xdg/dialog.rs index 098978eeac2c..08033b151adc 100644 --- a/src/wayland/shell/xdg/dialog.rs +++ b/src/wayland/shell/xdg/dialog.rs @@ -84,7 +84,7 @@ use wayland_server::{ use super::{ToplevelSurface, XdgShellHandler}; use crate::wayland::{ - Dispatch2, GlobalData, GlobalDispatch2, compositor, + GlobalData, compositor, shell::xdg::{XdgShellSurfaceUserData, XdgToplevelSurfaceData}, }; @@ -100,7 +100,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 } @@ -123,10 +123,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, @@ -139,10 +136,7 @@ where } } -impl Dispatch2 for GlobalData -where - D: Dispatch, -{ +impl Dispatch for GlobalData { fn request( &self, state: &mut D, @@ -188,7 +182,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..6391315fb860 100644 --- a/src/wayland/shell/xdg/handlers/positioner.rs +++ b/src/wayland/shell/xdg/handlers/positioner.rs @@ -1,6 +1,6 @@ use std::sync::Mutex; -use crate::{utils::Rectangle, utils::Serial, wayland::Dispatch2}; +use crate::{utils::Rectangle, utils::Serial, wayland::Dispatch}; use wayland_protocols::xdg::shell::server::{xdg_positioner, xdg_positioner::XdgPositioner}; @@ -18,7 +18,7 @@ pub struct XdgPositionerUserData { pub(crate) inner: Mutex, } -impl Dispatch2 for XdgPositionerUserData +impl Dispatch for XdgPositionerUserData where D: XdgShellHandler, D: 'static, diff --git a/src/wayland/shell/xdg/handlers/surface.rs b/src/wayland/shell/xdg/handlers/surface.rs index 8d7fd10876a6..c17a25ff5ffd 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..72cd6cde19ec 100644 --- a/src/wayland/shell/xdg/handlers/surface/popup.rs +++ b/src/wayland/shell/xdg/handlers/surface/popup.rs @@ -3,7 +3,7 @@ use std::sync::atomic::Ordering; use crate::{ utils::Serial, wayland::{ - Dispatch2, + Dispatch, compositor::{self, with_states}, shell::xdg::{PopupCachedState, SurfaceCachedState, XdgPopupSurfaceData, XdgPositionerUserData}, }, @@ -15,7 +15,7 @@ use wayland_server::{DataInit, DisplayHandle, Resource, backend::ClientId}; use super::{PopupConfigure, XdgShellHandler, XdgShellSurfaceUserData, XdgSurfaceUserData}; -impl Dispatch2 for XdgShellSurfaceUserData +impl Dispatch for XdgShellSurfaceUserData where D: XdgShellHandler, D: 'static, diff --git a/src/wayland/shell/xdg/handlers/surface/toplevel.rs b/src/wayland/shell/xdg/handlers/surface/toplevel.rs index 41576b119fc2..99598ca12b70 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, + Dispatch, compositor, shell::{ is_valid_parent, xdg::{ToplevelCachedState, XdgToplevelSurfaceData}, @@ -23,7 +23,7 @@ use super::{ XdgToplevelSurfaceRoleAttributes, }; -impl Dispatch2 for XdgShellSurfaceUserData +impl Dispatch for XdgShellSurfaceUserData where D: XdgShellHandler, D: 'static, diff --git a/src/wayland/shell/xdg/handlers/wm_base.rs b/src/wayland/shell/xdg/handlers/wm_base.rs index 01dd898765f7..256ba13b10b5 100644 --- a/src/wayland/shell/xdg/handlers/wm_base.rs +++ b/src/wayland/shell/xdg/handlers/wm_base.rs @@ -4,22 +4,21 @@ 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_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 +36,8 @@ where } } -impl Dispatch2 for XdgWmBaseUserData +impl Dispatch for XdgWmBaseUserData where - D: Dispatch, - D: Dispatch, D: XdgShellHandler, D: 'static, { diff --git a/src/wayland/shell/xdg/mod.rs b/src/wayland/shell/xdg/mod.rs index 8132a670f135..89479bfefea9 100644 --- a/src/wayland/shell/xdg/mod.rs +++ b/src/wayland/shell/xdg/mod.rs @@ -1218,7 +1218,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, @@ -1237,7 +1237,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..65e0c67b181e 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, WEnum, 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, @@ -207,7 +205,7 @@ where } } -impl Dispatch2 for ShmBufferUserData +impl Dispatch for ShmBufferUserData where D: BufferHandler, D: 'static, diff --git a/src/wayland/shm/mod.rs b/src/wayland/shm/mod.rs index aee6f96799cb..e2f512a734fb 100644 --- a/src/wayland/shm/mod.rs +++ b/src/wayland/shm/mod.rs @@ -142,12 +142,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 +177,7 @@ impl ShmState { } /// Shm global handler -pub trait ShmHandler { +pub trait ShmHandler: BufferHandler { /// Return the Shm global state fn shm_state(&self) -> &ShmState; } 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..bdd5e65cd222 100644 --- a/src/wayland/single_pixel_buffer/mod.rs +++ b/src/wayland/single_pixel_buffer/mod.rs @@ -50,7 +50,7 @@ use wayland_server::{ Dispatch, DisplayHandle, GlobalDispatch, Resource, backend::GlobalId, protocol::wl_buffer::WlBuffer, }; -use crate::wayland::GlobalData; +use crate::wayland::{GlobalData, buffer::BufferHandler}; mod handlers; @@ -67,9 +67,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 e7e010bd682d..73963459c028 100644 --- a/src/wayland/tablet_manager/mod.rs +++ b/src/wayland/tablet_manager/mod.rs @@ -95,7 +95,7 @@ use crate::{ input::{Seat, SeatHandler}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, + wayland::GlobalData, }; use wayland_protocols::wp::tablet::zv2::server::{ zwp_tablet_manager_v2::{self, ZwpTabletManagerV2}, @@ -141,11 +141,7 @@ impl TabletManagerState { /// Initialize a tablet manager global. pub fn new(display: &DisplayHandle) -> Self where - D: GlobalDispatch, - D: Dispatch, - D: Dispatch, - D: Dispatch, - D: 'static, + D: TabletSeatHandler + 'static, { let global = display.create_global::(MANAGER_VERSION, GlobalData); @@ -158,11 +154,9 @@ impl TabletManagerState { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, - D: Dispatch, - D: 'static, + D: TabletSeatHandler + 'static, { fn bind( &self, @@ -176,13 +170,9 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, - D: Dispatch, - D: Dispatch, - D: SeatHandler + TabletSeatHandler + 'static, - D: CompositorHandler, + D: TabletSeatHandler + 'static, { fn request( &self, diff --git a/src/wayland/tablet_manager/tablet.rs b/src/wayland/tablet_manager/tablet.rs index 1f4b650b84a7..9633fbc2849e 100644 --- a/src/wayland/tablet_manager/tablet.rs +++ b/src/wayland/tablet_manager/tablet.rs @@ -12,7 +12,7 @@ use wayland_server::{ protocol::wl_surface::WlSurface, }; -use crate::{backend::input::Device, wayland::Dispatch2}; +use crate::backend::input::Device; /// Description of graphics tablet device #[derive(Debug, Clone, Hash, Eq, PartialEq)] @@ -57,7 +57,6 @@ impl TabletHandle { seat: &ZwpTabletSeatV2, tablet: &TabletDescriptor, ) where - D: Dispatch, D: 'static, { let wl_tablet = client @@ -105,7 +104,7 @@ pub struct TabletUserData { handle: TabletHandle, } -impl Dispatch2 for TabletUserData +impl Dispatch for TabletUserData where D: 'static, { diff --git a/src/wayland/tablet_manager/tablet_seat.rs b/src/wayland/tablet_manager/tablet_seat.rs index 849d14628387..336ac82f0edc 100644 --- a/src/wayland/tablet_manager/tablet_seat.rs +++ b/src/wayland/tablet_manager/tablet_seat.rs @@ -8,7 +8,7 @@ use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, Resource, Weak, use crate::input::pointer::CursorImageStatus; use crate::{ backend::input::TabletToolDescriptor, - wayland::{Dispatch2, compositor::CompositorHandler}, + wayland::{compositor::CompositorHandler, tablet_manager::SeatHandler}, }; use super::tablet::{TabletDescriptor, TabletHandle}; @@ -39,7 +39,7 @@ impl fmt::Debug for TabletSeat { } /// Handler trait for Tablet Seats -pub trait TabletSeatHandler { +pub trait TabletSeatHandler: SeatHandler + CompositorHandler { /// Callback that will be notified whenever a client requests to set a custom tool image. fn tablet_tool_image(&mut self, tool: &TabletToolDescriptor, image: CursorImageStatus) { let _ = tool; @@ -65,8 +65,6 @@ impl TabletSeatHandle { seat: &ZwpTabletSeatV2, client: &Client, ) where - D: Dispatch, - D: Dispatch, D: TabletSeatHandler + 'static, D: CompositorHandler, { @@ -93,8 +91,7 @@ impl TabletSeatHandle { /// Returns new [TabletHandle] if tablet was not know by this seat, if tablet was already know it returns existing handle. pub fn add_tablet(&self, dh: &DisplayHandle, tablet_desc: &TabletDescriptor) -> TabletHandle where - D: Dispatch, - D: 'static, + D: TabletSeatHandler + 'static, { let inner = &mut *self.inner.lock().unwrap(); @@ -155,9 +152,7 @@ impl TabletSeatHandle { tool_desc: &TabletToolDescriptor, ) -> TabletToolHandle where - D: Dispatch, D: TabletSeatHandler + 'static, - D: CompositorHandler, { let inner = &mut *self.inner.lock().unwrap(); @@ -213,7 +208,7 @@ pub struct TabletSeatUserData { pub(super) handle: TabletSeatHandle, } -impl Dispatch2 for TabletSeatUserData +impl Dispatch for TabletSeatUserData where D: 'static, { diff --git a/src/wayland/tablet_manager/tablet_tool.rs b/src/wayland/tablet_manager/tablet_tool.rs index 2c508054d51a..f5104207ea52 100644 --- a/src/wayland/tablet_manager/tablet_tool.rs +++ b/src/wayland/tablet_manager/tablet_tool.rs @@ -16,10 +16,7 @@ use wayland_server::Weak; use wayland_server::protocol::wl_surface::WlSurface; use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, Resource, backend::ClientId}; -use crate::{ - utils::Serial, - wayland::{Dispatch2, compositor}, -}; +use crate::{utils::Serial, wayland::compositor}; use super::tablet::TabletHandle; use super::tablet_seat::TabletSeatHandler; @@ -258,9 +255,7 @@ impl TabletToolHandle { seat: &ZwpTabletSeatV2, tool: &TabletToolDescriptor, ) where - D: Dispatch, D: TabletSeatHandler + 'static, - D: CompositorHandler, { let desc = tool.clone(); @@ -470,7 +465,7 @@ impl fmt::Debug for TabletToolUserData { } } -impl Dispatch2 for TabletToolUserData +impl Dispatch for TabletToolUserData where D: TabletSeatHandler + 'static, { diff --git a/src/wayland/text_input/mod.rs b/src/wayland/text_input/mod.rs index 1780c0870762..397a9b1ce7fe 100644 --- a/src/wayland/text_input/mod.rs +++ b/src/wayland/text_input/mod.rs @@ -52,7 +52,7 @@ use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, use crate::{ input::{Seat, SeatHandler}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, + wayland::GlobalData, }; pub use text_input_handle::TextInputHandle; @@ -88,10 +88,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); @@ -104,11 +101,9 @@ impl TextInputManagerState { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, - D: Dispatch, - D: 'static, + D: SeatHandler + 'static, { fn bind( &self, @@ -122,11 +117,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 2525301045ed..79b3be528885 100644 --- a/src/wayland/text_input/text_input_handle.rs +++ b/src/wayland/text_input/text_input_handle.rs @@ -10,7 +10,7 @@ use wayland_server::{Resource, protocol::wl_surface::WlSurface}; use crate::input::SeatHandler; use crate::utils::{Logical, Rectangle}; -use crate::wayland::{Dispatch2, input_method::InputMethodHandle}; +use crate::wayland::{Dispatch, input_method::InputMethodHandle}; #[derive(Default, Debug)] pub(crate) struct TextInput { @@ -186,7 +186,7 @@ pub struct TextInputUserData { pub(crate) input_method_handle: InputMethodHandle, } -impl Dispatch2 for TextInputUserData +impl Dispatch for TextInputUserData where D: SeatHandler, D: 'static, diff --git a/src/wayland/viewporter/mod.rs b/src/wayland/viewporter/mod.rs index 4ff8834cb3e0..09bb678306ac 100644 --- a/src/wayland/viewporter/mod.rs +++ b/src/wayland/viewporter/mod.rs @@ -59,7 +59,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 +79,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 +92,9 @@ impl ViewporterState { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, - D: Dispatch, + D: CompositorHandler, { fn bind( &self, @@ -112,9 +108,9 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, + D: CompositorHandler, { fn request( &self, @@ -184,7 +180,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 0ca8f09af0a5..05d957f9ce65 100644 --- a/src/wayland/virtual_keyboard/mod.rs +++ b/src/wayland/virtual_keyboard/mod.rs @@ -52,7 +52,7 @@ use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, use crate::{ input::{Seat, SeatHandler}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, + wayland::{GlobalData, seat::WaylandFocus}, }; use self::virtual_keyboard_handle::VirtualKeyboardHandle; @@ -77,7 +77,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 { @@ -91,11 +92,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); @@ -109,12 +107,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, @@ -132,11 +128,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..e3f28896efe5 100644 --- a/src/wayland/virtual_keyboard/virtual_keyboard_handle.rs +++ b/src/wayland/virtual_keyboard/virtual_keyboard_handle.rs @@ -20,7 +20,7 @@ use crate::{ input::{Seat, SeatHandler}, utils::SERIAL_COUNTER, wayland::{ - Dispatch2, + Dispatch, seat::{WaylandFocus, keyboard::for_each_focused_kbds}, }, }; @@ -71,7 +71,7 @@ impl fmt::Debug for VirtualKeyboardUserData { } } -impl Dispatch2 for VirtualKeyboardUserData +impl Dispatch for VirtualKeyboardUserData where D: SeatHandler + 'static, ::KeyboardFocus: WaylandFocus, diff --git a/src/wayland/xdg_activation/dispatch.rs b/src/wayland/xdg_activation/dispatch.rs index b9680590a41c..ae646448f71d 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, { diff --git a/src/wayland/xdg_activation/mod.rs b/src/wayland/xdg_activation/mod.rs index 37c213c3e444..4aa3e5a80603 100644 --- a/src/wayland/xdg_activation/mod.rs +++ b/src/wayland/xdg_activation/mod.rs @@ -179,10 +179,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..0b8782a5c5da 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, { @@ -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, { diff --git a/src/wayland/xdg_foreign/mod.rs b/src/wayland/xdg_foreign/mod.rs index 9ac99ba8202c..c991941905e5 100644 --- a/src/wayland/xdg_foreign/mod.rs +++ b/src/wayland/xdg_foreign/mod.rs @@ -40,12 +40,12 @@ use wayland_protocols::xdg::foreign::zv2::server::{ }; use wayland_server::{DisplayHandle, GlobalDispatch, 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..de3bb0497a05 100644 --- a/src/wayland/xdg_system_bell.rs +++ b/src/wayland/xdg_system_bell.rs @@ -31,7 +31,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 +49,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 +61,7 @@ impl XdgSystemBellState { } } -impl GlobalDispatch2 for GlobalData -where - D: Dispatch, -{ +impl GlobalDispatch for GlobalData { fn bind( &self, _state: &mut D, @@ -77,7 +74,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 be9a9f445b69..d65a40866ded 100644 --- a/src/wayland/xdg_toplevel_icon.rs +++ b/src/wayland/xdg_toplevel_icon.rs @@ -48,7 +48,7 @@ use wayland_server::{ use crate::{ utils::HookId, wayland::{ - Dispatch2, GlobalData, GlobalDispatch2, + GlobalData, compositor::{self, Cacheable}, shell::xdg::XdgShellSurfaceUserData, shm::ShmBufferUserData, @@ -235,7 +235,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 +267,8 @@ impl XdgToplevelIconManager { } } -impl GlobalDispatch2 +impl GlobalDispatch for XdgToplevelIconManagerUserData -where - D: Dispatch, { fn bind( &self, @@ -289,10 +287,7 @@ where } } -impl Dispatch2 for GlobalData -where - D: Dispatch, -{ +impl Dispatch for GlobalData { fn request( &self, state: &mut D, @@ -335,7 +330,7 @@ where } } -impl Dispatch2 for XdgToplevelIconUserData { +impl Dispatch for XdgToplevelIconUserData { fn request( &self, _state: &mut D, diff --git a/src/wayland/xdg_toplevel_tag.rs b/src/wayland/xdg_toplevel_tag.rs index 707e9e15f8de..cd0ba6aeb5b2 100644 --- a/src/wayland/xdg_toplevel_tag.rs +++ b/src/wayland/xdg_toplevel_tag.rs @@ -41,9 +41,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 +104,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 +116,9 @@ impl XdgToplevelTagManager { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, + D: XdgToplevelTagHandler, { fn bind( &self, @@ -134,7 +132,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 dda0f6513572..3af57a569f11 100644 --- a/src/wayland/xwayland_keyboard_grab.rs +++ b/src/wayland/xwayland_keyboard_grab.rs @@ -52,7 +52,7 @@ use crate::{ keyboard::{self, KeyboardGrab, KeyboardInnerHandle}, }, utils::{SERIAL_COUNTER, Serial}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, + wayland::GlobalData, xwayland::XWaylandClientData, }; @@ -153,9 +153,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 = @@ -170,9 +168,9 @@ impl XWaylandKeyboardGrabState { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch + 'static, + D: XWaylandKeyboardGrabHandler + 'static, { fn bind( &self, @@ -190,10 +188,9 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch + 'static, - D: XWaylandKeyboardGrabHandler, + D: XWaylandKeyboardGrabHandler + 'static, { fn request( &self, @@ -222,7 +219,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 3d650e31c250..9a885ae7591d 100644 --- a/src/wayland/xwayland_shell.rs +++ b/src/wayland/xwayland_shell.rs @@ -138,7 +138,7 @@ use wayland_server::{ use crate::{ input::SeatHandler, - wayland::{Dispatch2, GlobalData, GlobalDispatch2, compositor}, + wayland::{GlobalData, compositor}, xwayland::{X11Surface, XWaylandClientData, XwmHandler, xwm::XwmId}, }; @@ -159,9 +159,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); @@ -189,7 +187,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; @@ -218,9 +216,9 @@ impl compositor::Cacheable for XWaylandShellCachedState { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, + D: XWaylandShellHandler, D: 'static, { fn bind( @@ -239,10 +237,9 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, - D: XWaylandShellHandler + XwmHandler + SeatHandler, + D: XWaylandShellHandler, D: 'static, { fn request( @@ -274,11 +271,10 @@ where } } -impl Dispatch2 for XWaylandSurfaceUserData +impl Dispatch for XWaylandSurfaceUserData where D: XWaylandShellHandler, D: 'static, - D: XwmHandler, { fn request( &self, @@ -312,7 +308,7 @@ where } } -fn serial_commit_hook( +fn serial_commit_hook( state: &mut D, _dh: &DisplayHandle, surface: &WlSurface,