diff --git a/Cargo.toml b/Cargo.toml index aef1b55c1f67..3e658923be62 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -87,7 +87,8 @@ pkg-config = { version = "0.3.17", optional = true } cc = { version = "1.0.79", optional = true } [features] -default = ["backend_drm", "backend_gbm", "backend_libinput", "backend_udev", "backend_session_libseat", "backend_x11", "backend_winit", "desktop", "renderer_gl", "renderer_pixman", "renderer_multi", "xwayland", "wayland_frontend", "backend_vulkan"] +# default = ["backend_drm", "backend_gbm", "backend_libinput", "backend_udev", "backend_session_libseat", "backend_x11", "backend_winit", "desktop", "renderer_gl", "renderer_pixman", "renderer_multi", "xwayland", "wayland_frontend", "backend_vulkan"] +default = ["backend_drm", "backend_gbm", "backend_libinput", "backend_udev", "backend_session_libseat", "backend_x11", "desktop", "renderer_gl", "renderer_pixman", "renderer_multi", "xwayland", "wayland_frontend", "backend_vulkan"] backend_winit = ["winit", "backend_egl", "wayland-client", "wayland-cursor", "wayland-egl", "renderer_gl"] backend_x11 = ["x11rb", "x11rb/dri3", "x11rb/xfixes", "x11rb/xinput", "x11rb/present", "x11rb_event_source", "backend_gbm", "backend_drm", "backend_egl"] backend_drm = ["drm", "drm-ffi"] @@ -145,3 +146,14 @@ harness = false [profile.release-with-debug] inherits = "release" debug = true + +[patch.crates-io] +wayland-sys = { git = "https://github.com/smithay/wayland-rs" } +wayland-egl = { git = "https://github.com/smithay/wayland-rs" } +wayland-backend = { git = "https://github.com/smithay/wayland-rs" } +wayland-server = { git = "https://github.com/smithay/wayland-rs" } +wayland-scanner = { git = "https://github.com/smithay/wayland-rs" } +wayland-client = { git = "https://github.com/smithay/wayland-rs" } +wayland-protocols = { git = "https://github.com/smithay/wayland-rs" } +wayland-protocols-wlr = { git = "https://github.com/smithay/wayland-rs" } +wayland-cursor = { git = "https://github.com/smithay/wayland-rs" } 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..10d028c2f8d0 100644 --- a/src/wayland/alpha_modifier/mod.rs +++ b/src/wayland/alpha_modifier/mod.rs @@ -54,9 +54,7 @@ use std::sync::{ atomic::{self, AtomicBool}, }; -use wayland_protocols::wp::alpha_modifier::v1::server::{ - wp_alpha_modifier_surface_v1::WpAlphaModifierSurfaceV1, wp_alpha_modifier_v1::WpAlphaModifierV1, -}; +use wayland_protocols::wp::alpha_modifier::v1::server::wp_alpha_modifier_v1::WpAlphaModifierV1; use wayland_server::{ Dispatch, DisplayHandle, GlobalDispatch, Resource, Weak, backend::GlobalId, protocol::wl_surface::WlSurface, @@ -161,10 +159,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 6cd6f2caea73..87dfdef3556f 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..49c5e074894a 100644 --- a/src/wayland/compositor/handlers.rs +++ b/src/wayland/compositor/handlers.rs @@ -4,7 +4,7 @@ use std::sync::{ }; use wayland_server::{ - DataInit, Dispatch, DisplayHandle, New, Resource, WEnum, + DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, protocol::{ wl_callback::{self, WlCallback}, wl_compositor::{self, WlCompositor}, @@ -20,7 +20,7 @@ use crate::utils::{ alive_tracker::{AliveTracker, IsAlive}, }; -use crate::wayland::{Dispatch2, GlobalData, GlobalDispatch2}; +use crate::wayland::GlobalData; use super::{ AlreadyHasRole, BufferAssignment, CompositorHandler, Damage, Rectangle, RectangleKind, RegionAttributes, @@ -35,11 +35,8 @@ use tracing::trace; * wl_compositor */ -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, - D: Dispatch, - D: Dispatch, D: CompositorHandler, D: 'static, { @@ -55,10 +52,8 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, - D: Dispatch, D: CompositorHandler, D: 'static, { @@ -156,9 +151,8 @@ pub struct SurfaceUserData { pub(super) user_state_type: (std::any::TypeId, &'static str), } -impl Dispatch2 for SurfaceUserData +impl Dispatch for SurfaceUserData where - D: Dispatch, D: CompositorHandler, D: 'static, { @@ -278,15 +272,13 @@ where PrivateSurfaceData::commit(surface, handle, state); } wl_surface::Request::SetBufferTransform { transform } => { - if let WEnum::Value(transform) = transform { - PrivateSurfaceData::with_states(surface, |states| { - states - .cached_state - .get::() - .pending() - .buffer_transform = transform; - }); - } + PrivateSurfaceData::with_states(surface, |states| { + states + .cached_state + .get::() + .pending() + .buffer_transform = transform; + }); } wl_surface::Request::SetBufferScale { scale } => { if scale >= 1 { @@ -373,7 +365,7 @@ pub struct RegionUserData { pub(crate) inner: Mutex, } -impl Dispatch2 for RegionUserData +impl Dispatch for RegionUserData where D: CompositorHandler, { @@ -416,10 +408,8 @@ where * wl_subcompositor */ -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, - D: Dispatch, D: CompositorHandler, D: 'static, { @@ -435,9 +425,8 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, D: CompositorHandler, D: 'static, { @@ -552,7 +541,7 @@ pub fn is_effectively_sync(surface: &wl_surface::WlSurface) -> bool { } } -impl Dispatch2 for SubsurfaceUserData +impl Dispatch for SubsurfaceUserData where D: CompositorHandler, D: 'static, @@ -641,7 +630,7 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where D: CompositorHandler, D: 'static, diff --git a/src/wayland/compositor/mod.rs b/src/wayland/compositor/mod.rs index 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..fc82a8723714 100644 --- a/src/wayland/content_type/dispatch.rs +++ b/src/wayland/content_type/dispatch.rs @@ -2,14 +2,15 @@ use wayland_protocols::wp::content_type::v1::server::{ wp_content_type_manager_v1::{self, WpContentTypeManagerV1}, wp_content_type_v1::{self, WpContentTypeV1}, }; -use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, New, Resource, backend::ClientId}; +use wayland_server::{ + Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, backend::ClientId, +}; use super::{ContentTypeSurfaceCachedState, ContentTypeSurfaceData, ContentTypeUserData}; -use crate::wayland::{Dispatch2, GlobalData, GlobalDispatch2, compositor}; +use crate::wayland::{GlobalData, compositor}; -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, D: 'static, { fn bind( @@ -24,9 +25,8 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, D: 'static, { fn request( @@ -71,7 +71,7 @@ where } } -impl Dispatch2 for ContentTypeUserData { +impl Dispatch for ContentTypeUserData { fn request( &self, _state: &mut D, @@ -83,9 +83,6 @@ impl Dispatch2 for ContentTypeUserData { ) { match request { wp_content_type_v1::Request::SetContentType { content_type } => { - let wayland_server::WEnum::Value(content_type) = content_type else { - return; - }; let Some(surface) = self.wl_surface() else { return; }; diff --git a/src/wayland/content_type/mod.rs b/src/wayland/content_type/mod.rs index da99a7ad68a5..efccc3b0b2a2 100644 --- a/src/wayland/content_type/mod.rs +++ b/src/wayland/content_type/mod.rs @@ -56,7 +56,7 @@ use wayland_protocols::wp::content_type::v1::server::{ wp_content_type_manager_v1::WpContentTypeManagerV1, wp_content_type_v1, }; use wayland_server::{ - DisplayHandle, GlobalDispatch, Resource, Weak, backend::GlobalId, protocol::wl_surface::WlSurface, + DisplayHandle, Resource, Weak, backend::GlobalId, protocol::wl_surface::WlSurface, }; use super::compositor::Cacheable; @@ -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..3e7743571e9e 100644 --- a/src/wayland/cursor_shape.rs +++ b/src/wayland/cursor_shape.rs @@ -103,18 +103,16 @@ 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 +127,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 +141,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 +159,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 +231,7 @@ pub(crate) enum CursorShapeDeviceUserDataInner { Tablet(Weak), } -impl Dispatch2 for CursorShapeDeviceUserData +impl Dispatch for CursorShapeDeviceUserData where D: SeatHandler + TabletSeatHandler, ::PointerFocus: WaylandFocus, @@ -250,10 +247,7 @@ where _data_init: &mut wayland_server::DataInit<'_, D>, ) { match request { - ShapeRequest::SetShape { - serial, - shape: WEnum::Value(shape), - } => { + ShapeRequest::SetShape { serial, shape } => { match &self.0 { CursorShapeDeviceUserDataInner::Pointer { seat } => { let Some(seat) = seat.upgrade() else { @@ -302,9 +296,6 @@ where } } } - ShapeRequest::SetShape { .. } => { - // Ignore unknown shapes. - } ShapeRequest::Destroy => {} _ => unreachable!(), } diff --git a/src/wayland/dispatch2.rs b/src/wayland/dispatch2.rs deleted file mode 100644 index be4bc7060b17..000000000000 --- a/src/wayland/dispatch2.rs +++ /dev/null @@ -1,91 +0,0 @@ -use wayland_server::{Client, DataInit, DisplayHandle, New, Resource, backend::ClientId}; - -/// A simplified version of [`wayland_server::Dispatch`] -/// -/// A future version of `wayland-server` will replace `Dispatch` with this. -pub trait Dispatch2 { - /// Called when a request from a client is processed. - fn request( - &self, - state: &mut State, - client: &Client, - resource: &I, - request: I::Request, - dhandle: &DisplayHandle, - data_init: &mut DataInit<'_, State>, - ); - - /// Called when the object this user data is associated with has been destroyed. - fn destroyed(&self, _state: &mut State, _client: ClientId, _resource: &I) {} -} - -/// A simplified version of [`wayland_server::GlobalDispatch`] -/// -/// A future version of `wayland-server` will replace `GlobalDispatch` with this. -pub trait GlobalDispatch2 { - /// Called when a client has bound this global. - fn bind( - &self, - state: &mut State, - handle: &DisplayHandle, - client: &Client, - resource: New, - data_init: &mut DataInit<'_, State>, - ); - - /// Checks if the global should be advertised to some client. - fn can_view(&self, _client: &Client) -> bool { - true - } -} - -/// Implement `Dispatch` and `GlobalDispatch` for every implementation of [`Dispatch2`] and -/// [`GlobalDispatch2`]. -#[macro_export] -macro_rules! delegate_dispatch2 { - ($(@< $( $lt:tt $( : $clt:tt $(+ $dlt:tt )* )? ),+ >)? $ty:ty) => { - impl<$( $( $lt $( : $clt $(+ $dlt )* )? ),+, )? I, UserData> $crate::reexports::wayland_server::Dispatch for $ty - where - I: $crate::reexports::wayland_server::Resource, - UserData: $crate::wayland::Dispatch2 { - fn request( - state: &mut Self, - client: &$crate::reexports::wayland_server::Client, - resource: &I, - request: ::Request, - data: &UserData, - dhandle: &$crate::reexports::wayland_server::DisplayHandle, - data_init: &mut $crate::reexports::wayland_server::DataInit<'_, Self>, - ) { - data.request(state, client, resource, request, dhandle, data_init); - } - - fn destroyed(state: &mut Self, client: $crate::reexports::wayland_server::backend::ClientId, resource: &I, data: &UserData) { - data.destroyed(state, client, resource); - } - } - - impl<$( $( $lt $( : $clt $(+ $dlt )* )? ),+, )? I, UserData> $crate::reexports::wayland_server::GlobalDispatch for $ty - where - I: $crate::reexports::wayland_server::Resource, - UserData: $crate::wayland::GlobalDispatch2 { - fn bind( - state: &mut Self, - dhandle: &$crate::reexports::wayland_server::DisplayHandle, - client: &$crate::reexports::wayland_server::Client, - resource: $crate::reexports::wayland_server::New, - data: &UserData, - data_init: &mut $crate::reexports::wayland_server::DataInit<'_, Self>, - ) { - data.bind(state, dhandle, client, resource, data_init); - } - - fn can_view( - client: $crate::reexports::wayland_server::Client, - data: &UserData - ) -> bool { - data.can_view(&client) - } - } - }; -} diff --git a/src/wayland/dmabuf/dispatch.rs b/src/wayland/dmabuf/dispatch.rs index 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 1f2c64436e41..8742f9ad8b9b 100644 --- a/src/wayland/dmabuf/mod.rs +++ b/src/wayland/dmabuf/mod.rs @@ -202,7 +202,7 @@ use wayland_protocols::wp::linux_dmabuf::zv1::server::{ zwp_linux_dmabuf_feedback_v1, zwp_linux_dmabuf_v1, }; use wayland_server::{ - Client, Dispatch, DisplayHandle, GlobalDispatch, Resource, WEnum, + Client, Dispatch, DisplayHandle, GlobalDispatch, Resource, backend::{GlobalId, InvalidId}, protocol::{ wl_buffer::{self, WlBuffer}, @@ -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(); @@ -1031,7 +1012,7 @@ impl DmabufParamsData { width: i32, height: i32, format: u32, - flags: WEnum, + flags: zwp_linux_buffer_params_v1::Flags, _node: Option, ) -> Option { // We cannot create a dmabuf if the parameters have already been used. diff --git a/src/wayland/drm_lease/mod.rs b/src/wayland/drm_lease/mod.rs index 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 7340c18e9d0e..85312306bd2f 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 9e6b7ef48c61..81724358e773 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 3429bd46c578..48975b03e606 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..cedc632cda6c 100644 --- a/src/wayland/idle_inhibit/mod.rs +++ b/src/wayland/idle_inhibit/mod.rs @@ -33,14 +33,13 @@ //! ``` use _idle_inhibit::zwp_idle_inhibit_manager_v1::{Request, ZwpIdleInhibitManagerV1}; -use _idle_inhibit::zwp_idle_inhibitor_v1::ZwpIdleInhibitorV1; use wayland_protocols::wp::idle_inhibit::zv1::server as _idle_inhibit; use wayland_server::backend::GlobalId; use wayland_server::protocol::wl_surface::WlSurface; use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New}; +use crate::wayland::GlobalData; use crate::wayland::idle_inhibit::inhibitor::IdleInhibitorState; -use crate::wayland::{Dispatch2, GlobalData, GlobalDispatch2}; pub mod inhibitor; @@ -56,7 +55,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 +69,8 @@ impl IdleInhibitManagerState { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, D: IdleInhibitHandler, D: 'static, { @@ -89,9 +86,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..2fba5b8e3150 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, { @@ -1000,10 +992,7 @@ where return; }; - let draw_cursors = options - .into_result() - .map(|o| o.contains(ext_image_copy_capture_manager_v1::Options::PaintCursors)) - .unwrap_or(false); + let draw_cursors = options.contains(ext_image_copy_capture_manager_v1::Options::PaintCursors); let inner = Arc::new(Mutex::new(SessionInner::new( capture_source.clone(), draw_cursors, @@ -1093,7 +1082,7 @@ where } } -impl Dispatch2 for SessionData +impl Dispatch for SessionData where D: ImageCopyCaptureHandler, { @@ -1138,7 +1127,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 +1157,7 @@ where } } -impl Dispatch2 for CursorSessionData +impl Dispatch for CursorSessionData where D: ImageCopyCaptureHandler, { @@ -1242,7 +1231,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..1ced4997ce67 100644 --- a/src/wayland/input_method/input_method_handle.rs +++ b/src/wayland/input_method/input_method_handle.rs @@ -4,11 +4,7 @@ use std::{ }; use tracing::warn; -use wayland_protocols_misc::zwp_input_method_v2::server::{ - zwp_input_method_keyboard_grab_v2::ZwpInputMethodKeyboardGrabV2, - zwp_input_method_v2::{self, ZwpInputMethodV2}, - zwp_input_popup_surface_v2::ZwpInputPopupSurfaceV2, -}; +use wayland_protocols_misc::zwp_input_method_v2::server::zwp_input_method_v2::{self, ZwpInputMethodV2}; use wayland_server::{ Client, DataInit, Dispatch, DisplayHandle, Resource, protocol::wl_keyboard::KeymapFormat, }; @@ -17,7 +13,7 @@ use wayland_server::{backend::ClientId, protocol::wl_surface::WlSurface}; use crate::{ input::{SeatHandler, keyboard::KeyboardHandle}, utils::{Logical, Rectangle, SERIAL_COUNTER, alive_tracker::AliveTracker}, - wayland::{Dispatch2, compositor, seat::WaylandFocus, text_input::TextInputHandle}, + wayland::{compositor, seat::WaylandFocus, text_input::TextInputHandle}, }; use super::{ @@ -185,10 +181,8 @@ impl fmt::Debug for InputMethodUserData { } } -impl Dispatch2 for InputMethodUserData +impl Dispatch for InputMethodUserData where - D: Dispatch, - D: Dispatch>, D: SeatHandler, D: InputMethodHandler, ::KeyboardFocus: WaylandFocus, 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..2d0b76252169 100644 --- a/src/wayland/input_method/mod.rs +++ b/src/wayland/input_method/mod.rs @@ -60,15 +60,12 @@ use wayland_server::{ protocol::wl_surface::WlSurface, }; -use wayland_protocols_misc::zwp_input_method_v2::server::{ - zwp_input_method_manager_v2::{self, ZwpInputMethodManagerV2}, - zwp_input_method_v2::ZwpInputMethodV2, -}; +use wayland_protocols_misc::zwp_input_method_v2::server::zwp_input_method_manager_v2::{self, ZwpInputMethodManagerV2}; use crate::{ input::{Seat, SeatHandler}, utils::{Logical, Rectangle}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, + wayland::{GlobalData, seat::WaylandFocus}, }; pub use input_method_handle::{InputMethodHandle, InputMethodUserData}; @@ -88,7 +85,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 +129,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 +147,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 +168,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..0e0f3a9dac4f 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}, + input::Seat, + 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..dd848501a089 100644 --- a/src/wayland/keyboard_shortcuts_inhibit/mod.rs +++ b/src/wayland/keyboard_shortcuts_inhibit/mod.rs @@ -10,7 +10,7 @@ use wayland_protocols::wp::keyboard_shortcuts_inhibit::zv1::server::{ zwp_keyboard_shortcuts_inhibitor_v1::ZwpKeyboardShortcutsInhibitorV1, }; use wayland_server::{ - Dispatch, DisplayHandle, GlobalDispatch, Resource, + DisplayHandle, Resource, backend::{GlobalId, ObjectId}, protocol::{wl_seat::WlSeat, wl_surface::WlSurface}, }; @@ -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..ec857d0a8df1 100644 --- a/src/wayland/pointer_constraints.rs +++ b/src/wayland/pointer_constraints.rs @@ -17,7 +17,7 @@ use wayland_protocols::wp::pointer_constraints::zv1::server::{ zwp_pointer_constraints_v1::{self, Lifetime, ZwpPointerConstraintsV1}, }; use wayland_server::{ - Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, WEnum, backend::GlobalId, + Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, backend::GlobalId, protocol::wl_surface::WlSurface, }; @@ -25,7 +25,7 @@ use super::compositor::{self, RegionAttributes}; use crate::{ input::{SeatHandler, pointer::PointerHandle}, utils::{Logical, Point}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2, seat::PointerUserData}, + wayland::{GlobalData, seat::PointerUserData}, }; const VERSION: u32 = 1; @@ -56,7 +56,7 @@ pub struct ConfinedPointer { handle: zwp_confined_pointer_v1::ZwpConfinedPointerV1, region: Option, pending_region: Option, - lifetime: WEnum, + lifetime: Lifetime, active: AtomicBool, } @@ -73,7 +73,7 @@ pub struct LockedPointer { handle: zwp_locked_pointer_v1::ZwpLockedPointerV1, region: Option, pending_region: Option, - lifetime: WEnum, + lifetime: Lifetime, cursor_position_hint: Option>, pending_cursor_position_hint: Option>, active: AtomicBool, @@ -162,7 +162,7 @@ impl PointerConstraintRef<'_, D> { } }; - if deactivated && self.lifetime() == WEnum::Value(Lifetime::Oneshot) { + if deactivated && self.lifetime() == Lifetime::Oneshot { self.entry.remove_entry(); } } @@ -186,7 +186,7 @@ impl PointerConstraint { } } - fn lifetime(&self) -> WEnum { + fn lifetime(&self) -> Lifetime { match self { PointerConstraint::Confined(confined) => confined.lifetime, PointerConstraint::Locked(locked) => locked.lifetime, @@ -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..655f8edf1230 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, @@ -83,11 +82,8 @@ use wayland_server::{ Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, backend::{ClientId, GlobalId, ObjectId}, protocol::{ - wl_keyboard::WlKeyboard, - wl_pointer::WlPointer, wl_seat::{self, WlSeat}, wl_surface, - wl_touch::WlTouch, }, }; @@ -165,7 +161,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 +219,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 +305,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..9b3852d7ced3 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; @@ -315,9 +315,6 @@ fn handle_dnd( preferred_action, } => { if let Some(source) = source.as_ref() { - let dnd_actions = dnd_actions.into_result().unwrap_or(WlDndAction::None); - let preferred_action = preferred_action.into_result().unwrap_or(WlDndAction::None); - // preferred_action must only contain one bitflag at the same time if ![ WlDndAction::None, @@ -573,8 +570,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,29 +751,28 @@ mod handlers { use tracing::error; use wayland_server::{ - Dispatch, DisplayHandle, - protocol::{ - wl_data_device::WlDataDevice, - wl_data_device_manager::{self, WlDataDeviceManager}, - wl_data_source::WlDataSource, - }, + Dispatch, DisplayHandle, GlobalDispatch, + protocol::wl_data_device_manager::{self, WlDataDeviceManager}, }; use crate::{ - input::Seat, - wayland::selection::{device::SelectionDevice, seat_data::SeatData}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, + input::{Seat, SeatHandler, dnd::DndFocus}, + wayland::{ + GlobalData, + seat::WaylandFocus, + selection::{device::SelectionDevice, seat_data::SeatData}, + }, }; use super::DataDeviceHandler; use super::{device::DataDeviceUserData, source::DataSourceUserData}; - impl GlobalDispatch2 for GlobalData + impl GlobalDispatch for GlobalData where - D: Dispatch, - D: Dispatch, - D: Dispatch, D: DataDeviceHandler, + ::PointerFocus: DndFocus, + ::TouchFocus: DndFocus, + ::KeyboardFocus: WaylandFocus, D: 'static, { fn bind( @@ -789,11 +787,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..a82f570f6385 100644 --- a/src/wayland/selection/data_device/source.rs +++ b/src/wayland/selection/data_device/source.rs @@ -4,7 +4,7 @@ use std::{ os::fd::{AsFd, OwnedFd}, sync::Mutex, }; -use tracing::{debug, error}; +use tracing::debug; use wayland_server::{ DisplayHandle, Resource, @@ -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, @@ -65,14 +65,9 @@ where wl_data_source::Request::Offer { mime_type } => { data.mime_types.push(mime_type); } - wl_data_source::Request::SetActions { dnd_actions } => match dnd_actions { - wayland_server::WEnum::Value(dnd_actions) => { - data.dnd_actions = DndAction::vec_from_wl(dnd_actions); - } - wayland_server::WEnum::Unknown(action) => { - error!("Unknown dnd_action: {:?}", action); - } - }, + wl_data_source::Request::SetActions { dnd_actions } => { + data.dnd_actions = DndAction::vec_from_wl(dnd_actions); + } wl_data_source::Request::Destroy => {} _ => unreachable!(), } 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..67ee44b60a52 100644 --- a/src/wayland/selection/ext_data_control/mod.rs +++ b/src/wayland/selection/ext_data_control/mod.rs @@ -54,7 +54,7 @@ use wayland_protocols::ext::data_control::v1::server::ext_data_control_manager_v use wayland_protocols::ext::data_control::v1::server::ext_data_control_source_v1::ExtDataControlSourceV1; use wayland_server::backend::GlobalId; use wayland_server::protocol::wl_seat::WlSeat; -use wayland_server::{Client, DisplayHandle, GlobalDispatch}; +use wayland_server::{Client, DisplayHandle}; mod device; mod source; @@ -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 { @@ -133,18 +133,13 @@ mod handlers { use std::cell::RefCell; use tracing::error; - use wayland_protocols::ext::data_control::v1::server::{ - ext_data_control_device_v1::ExtDataControlDeviceV1, - ext_data_control_manager_v1::{self, ExtDataControlManagerV1}, - ext_data_control_source_v1::ExtDataControlSourceV1, - }; - use wayland_server::{Client, Dispatch, DisplayHandle}; + use wayland_protocols::ext::data_control::v1::server::ext_data_control_manager_v1::{self, ExtDataControlManagerV1}; + 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 +147,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 +173,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..cdffde087e35 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 { @@ -299,19 +301,16 @@ mod handlers { use std::cell::RefCell; use tracing::error; - use wayland_protocols::wp::primary_selection::zv1::server::{ - zwp_primary_selection_device_manager_v1::{ + use wayland_protocols::wp::primary_selection::zv1::server::zwp_primary_selection_device_manager_v1::{ self as primary_device_manager, ZwpPrimarySelectionDeviceManagerV1 as PrimaryDeviceManager, - }, - zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1 as PrimaryDevice, - zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1 as PrimarySource, - }; - use wayland_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 +320,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 +342,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..a24cf95e7114 100644 --- a/src/wayland/selection/wlr_data_control/mod.rs +++ b/src/wayland/selection/wlr_data_control/mod.rs @@ -55,7 +55,7 @@ use wayland_protocols_wlr::data_control::v1::server::zwlr_data_control_manager_v use wayland_protocols_wlr::data_control::v1::server::zwlr_data_control_source_v1::ZwlrDataControlSourceV1; use wayland_server::backend::GlobalId; use wayland_server::protocol::wl_seat::WlSeat; -use wayland_server::{Client, DisplayHandle, GlobalDispatch}; +use wayland_server::{Client, DisplayHandle}; mod device; mod source; @@ -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 { @@ -138,17 +138,16 @@ mod handlers { use std::sync::Arc; use tracing::error; - use wayland_protocols_wlr::data_control::v1::server::zwlr_data_control_device_v1::ZwlrDataControlDeviceV1; + use wayland_protocols_wlr::data_control::v1::server::zwlr_data_control_manager_v1; use wayland_protocols_wlr::data_control::v1::server::zwlr_data_control_manager_v1::ZwlrDataControlManagerV1; - use wayland_protocols_wlr::data_control::v1::server::zwlr_data_control_source_v1::ZwlrDataControlSourceV1; - use wayland_server::{Client, Dispatch, DisplayHandle}; + + use wayland_server::{Client, Dispatch, DisplayHandle, GlobalDispatch}; use crate::input::Seat; use crate::wayland::selection::SelectionTarget; use crate::wayland::selection::device::SelectionDevice; use crate::wayland::selection::seat_data::SeatData; - use crate::wayland::{Dispatch2, GlobalDispatch2}; use super::DataControlDeviceUserData; use super::DataControlHandler; @@ -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..c4a6a83ce5b8 100644 --- a/src/wayland/session_lock/lock.rs +++ b/src/wayland/session_lock/lock.rs @@ -5,12 +5,10 @@ use std::sync::{Arc, Mutex}; use crate::wayland::compositor::SurfaceAttributes; use crate::wayland::compositor::{self, BufferAssignment}; -use _session_lock::ext_session_lock_surface_v1::ExtSessionLockSurfaceV1; use _session_lock::ext_session_lock_v1::{Error, ExtSessionLockV1, Request}; use wayland_protocols::ext::session_lock::v1::server::{self as _session_lock}; use wayland_server::{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 +29,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..e476215fa303 100644 --- a/src/wayland/shell/kde/decoration.rs +++ b/src/wayland/shell/kde/decoration.rs @@ -38,9 +38,8 @@ use wayland_protocols_misc::server_decoration::server::org_kde_kwin_server_decor }; use wayland_server::backend::GlobalId; use wayland_server::protocol::wl_surface::WlSurface; -use wayland_server::{Client, Dispatch, DisplayHandle, GlobalDispatch, WEnum}; +use wayland_server::{Client, Dispatch, DisplayHandle, GlobalDispatch}; -use crate::wayland::GlobalData; /// KDE server decoration handler. pub trait KdeDecorationHandler { @@ -61,15 +60,8 @@ pub trait KdeDecorationHandler { /// **It is up to the compositor to prevent feedback loops**, a client is free to ignore modes /// suggested by [`OrgKdeKwinServerDecoration::mode`] and instead request their preferred mode /// instead. - fn request_mode( - &mut self, - _surface: &WlSurface, - decoration: &OrgKdeKwinServerDecoration, - mode: WEnum, - ) { - if let WEnum::Value(mode) = mode { - decoration.mode(mode); - } + fn request_mode(&mut self, _surface: &WlSurface, decoration: &OrgKdeKwinServerDecoration, mode: Mode) { + decoration.mode(mode); } /// Handle decoration object removal for a surface. @@ -98,11 +90,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 +100,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/wlr_layer/types.rs b/src/wayland/shell/wlr_layer/types.rs index 6847012a551d..7fe8643d3b1b 100644 --- a/src/wayland/shell/wlr_layer/types.rs +++ b/src/wayland/shell/wlr_layer/types.rs @@ -1,7 +1,6 @@ use std::cmp::Ordering; use wayland_protocols_wlr::layer_shell::v1::server::{zwlr_layer_shell_v1, zwlr_layer_surface_v1}; -use wayland_server::WEnum; /// Available layers for surfaces /// @@ -22,18 +21,18 @@ pub enum Layer { Overlay, } -impl TryFrom> for Layer { +impl TryFrom for Layer { type Error = (zwlr_layer_shell_v1::Error, String); #[inline] - fn try_from(layer: WEnum) -> Result { + fn try_from(layer: zwlr_layer_shell_v1::Layer) -> Result { use zwlr_layer_shell_v1::Layer; match layer { - WEnum::Value(Layer::Background) => Ok(Self::Background), - WEnum::Value(Layer::Bottom) => Ok(Self::Bottom), - WEnum::Value(Layer::Top) => Ok(Self::Top), - WEnum::Value(Layer::Overlay) => Ok(Self::Overlay), + Layer::Background => Ok(Self::Background), + Layer::Bottom => Ok(Self::Bottom), + Layer::Top => Ok(Self::Top), + Layer::Overlay => Ok(Self::Overlay), layer => Err(( zwlr_layer_shell_v1::Error::InvalidLayer, format!("invalid layer: {layer:?}"), @@ -100,17 +99,17 @@ impl Default for KeyboardInteractivity { } } -impl TryFrom> for KeyboardInteractivity { +impl TryFrom for KeyboardInteractivity { type Error = (zwlr_layer_surface_v1::Error, String); #[inline] - fn try_from(ki: WEnum) -> Result { + fn try_from(ki: zwlr_layer_surface_v1::KeyboardInteractivity) -> Result { use zwlr_layer_surface_v1::KeyboardInteractivity; match ki { - WEnum::Value(KeyboardInteractivity::None) => Ok(Self::None), - WEnum::Value(KeyboardInteractivity::Exclusive) => Ok(Self::Exclusive), - WEnum::Value(KeyboardInteractivity::OnDemand) => Ok(Self::OnDemand), + KeyboardInteractivity::None => Ok(Self::None), + KeyboardInteractivity::Exclusive => Ok(Self::Exclusive), + KeyboardInteractivity::OnDemand => Ok(Self::OnDemand), ki => Err(( zwlr_layer_surface_v1::Error::InvalidKeyboardInteractivity, format!("wrong keyboard interactivity value: {ki:?}"), @@ -158,17 +157,12 @@ impl Default for Anchor { } } -impl TryFrom> for Anchor { +impl TryFrom for Anchor { type Error = (zwlr_layer_surface_v1::Error, String); #[inline] - fn try_from(anchor: WEnum) -> Result { - let a = if let WEnum::Value(anchor) = anchor { - Anchor::from_bits(anchor.bits()) - } else { - None - }; - + fn try_from(anchor: zwlr_layer_surface_v1::Anchor) -> Result { + let a = Anchor::from_bits(anchor.bits()); a.ok_or(( zwlr_layer_surface_v1::Error::InvalidAnchor, format!("invalid anchor {anchor:?}"), diff --git a/src/wayland/shell/xdg/decoration.rs b/src/wayland/shell/xdg/decoration.rs index bb66b1f725e6..2d191e92c76a 100644 --- a/src/wayland/shell/xdg/decoration.rs +++ b/src/wayland/shell/xdg/decoration.rs @@ -91,11 +91,11 @@ use wayland_protocols::xdg::decoration::zv1::server::{ zxdg_toplevel_decoration_v1::{self, Mode}, }; use wayland_server::{ - Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, WEnum, backend::GlobalId, + Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, backend::GlobalId, }; use super::{ToplevelSurface, XdgShellHandler}; -use crate::wayland::{Dispatch2, GlobalData, GlobalDispatch2, shell::xdg::XdgShellSurfaceUserData}; +use crate::wayland::{GlobalData, shell::xdg::XdgShellSurfaceUserData}; /// Delegate type for handling xdg decoration events. #[derive(Debug)] @@ -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, { @@ -272,9 +257,7 @@ where match request { Request::SetMode { mode } => { - if let WEnum::Value(mode) = mode { - state.request_mode(self.clone(), mode); - } + state.request_mode(self.clone(), mode); } Request::UnsetMode => { diff --git a/src/wayland/shell/xdg/dialog.rs b/src/wayland/shell/xdg/dialog.rs index 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..b9e3a4eeb96b 100644 --- a/src/wayland/shell/xdg/handlers/positioner.rs +++ b/src/wayland/shell/xdg/handlers/positioner.rs @@ -1,10 +1,10 @@ use std::sync::Mutex; -use crate::{utils::Rectangle, utils::Serial, wayland::Dispatch2}; +use crate::{utils::Rectangle, utils::Serial, wayland::Dispatch}; use wayland_protocols::xdg::shell::server::{xdg_positioner, xdg_positioner::XdgPositioner}; -use wayland_server::{DataInit, DisplayHandle, Resource, WEnum}; +use wayland_server::{DataInit, DisplayHandle, Resource}; use super::{PositionerState, XdgShellHandler}; @@ -18,7 +18,7 @@ pub struct XdgPositionerUserData { pub(crate) inner: Mutex, } -impl Dispatch2 for XdgPositionerUserData +impl Dispatch for XdgPositionerUserData where D: XdgShellHandler, D: 'static, @@ -55,21 +55,15 @@ where } } xdg_positioner::Request::SetAnchor { anchor } => { - if let WEnum::Value(anchor) = anchor { - state.anchor_edges = anchor; - } + state.anchor_edges = anchor; } xdg_positioner::Request::SetGravity { gravity } => { - if let WEnum::Value(gravity) = gravity { - state.gravity = gravity; - } + state.gravity = gravity; } xdg_positioner::Request::SetConstraintAdjustment { constraint_adjustment, } => { - if let WEnum::Value(constraint_adjustment) = constraint_adjustment { - state.constraint_adjustment = constraint_adjustment; - } + state.constraint_adjustment = constraint_adjustment; } xdg_positioner::Request::SetOffset { x, y } => { state.offset = (x, y).into(); diff --git a/src/wayland/shell/xdg/handlers/surface.rs b/src/wayland/shell/xdg/handlers/surface.rs index f046222dd918..bdafe5c81285 100644 --- a/src/wayland/shell/xdg/handlers/surface.rs +++ b/src/wayland/shell/xdg/handlers/surface.rs @@ -9,7 +9,7 @@ use crate::wayland::shell::xdg::{XdgPopupSurfaceData, XdgToplevelSurfaceData}; use crate::{ utils::{Rectangle, Serial}, wayland::{ - Dispatch2, compositor, + compositor, shell::xdg::{PopupState, XDG_POPUP_ROLE, XDG_TOPLEVEL_ROLE}, }, }; @@ -45,10 +45,8 @@ pub struct XdgSurfaceUserData { pub(crate) has_active_role: AtomicBool, } -impl Dispatch2 for XdgSurfaceUserData +impl Dispatch for XdgSurfaceUserData where - D: Dispatch, - D: Dispatch, D: XdgShellHandler, D: 'static, { diff --git a/src/wayland/shell/xdg/handlers/surface/popup.rs b/src/wayland/shell/xdg/handlers/surface/popup.rs index eb2cb5566e1d..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..5abfe58599ec 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}, @@ -16,14 +16,14 @@ use wayland_protocols::xdg::{ shell::server::xdg_toplevel::{self, XdgToplevel}, }; -use wayland_server::{DataInit, DisplayHandle, Resource, WEnum, backend::ClientId, protocol::wl_surface}; +use wayland_server::{DataInit, DisplayHandle, Resource, backend::ClientId, protocol::wl_surface}; use super::{ SurfaceCachedState, ToplevelConfigure, XdgShellHandler, XdgShellSurfaceUserData, XdgSurfaceUserData, XdgToplevelSurfaceRoleAttributes, }; -impl Dispatch2 for XdgShellSurfaceUserData +impl Dispatch for XdgShellSurfaceUserData where D: XdgShellHandler, D: 'static, @@ -119,13 +119,11 @@ where XdgShellHandler::move_request(state, handle, seat, serial); } xdg_toplevel::Request::Resize { seat, serial, edges } => { - if let WEnum::Value(edges) = edges { - // This has to be handled by the compositor - let handle = make_toplevel_handle(toplevel); - let serial = Serial::from(serial); + // This has to be handled by the compositor + let handle = make_toplevel_handle(toplevel); + let serial = Serial::from(serial); - XdgShellHandler::resize_request(state, handle, seat, serial, edges); - } + XdgShellHandler::resize_request(state, handle, seat, serial, edges); } xdg_toplevel::Request::SetMaxSize { width, height } => { with_toplevel_pending_state(self, |toplevel_data| { diff --git a/src/wayland/shell/xdg/handlers/wm_base.rs b/src/wayland/shell/xdg/handlers/wm_base.rs index 01dd898765f7..553c230cf567 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, + xdg_surface, xdg_wm_base, xdg_wm_base::XdgWmBase, }; -use wayland_server::{DataInit, Dispatch, DisplayHandle, New, Resource, Weak, backend::ClientId}; +use wayland_server::{ + DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, Weak, backend::ClientId, +}; use super::{ShellClient, ShellClientData, XdgPositionerUserData, XdgShellHandler, XdgSurfaceUserData}; -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, - D: Dispatch, - D: Dispatch, D: XdgShellHandler, D: 'static, { @@ -37,10 +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..af35c072adf9 100644 --- a/src/wayland/shell/xdg/mod.rs +++ b/src/wayland/shell/xdg/mod.rs @@ -946,7 +946,7 @@ impl ToplevelStateSet { } fn version_needed_for_state(state: &xdg_toplevel::State) -> u32 { - match state { + match *state { xdg_toplevel::State::TiledLeft | xdg_toplevel::State::TiledRight | xdg_toplevel::State::TiledTop @@ -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..9720e055ca43 100644 --- a/src/wayland/shm/handlers.rs +++ b/src/wayland/shm/handlers.rs @@ -1,5 +1,5 @@ use crate::wayland::{ - Dispatch2, GlobalData, GlobalDispatch2, + GlobalData, buffer::BufferHandler, shm::{ShmBufferUserData, wl_bytes_per_pixel}, }; @@ -11,7 +11,7 @@ use super::{ use std::{num::NonZeroUsize, os::unix::io::AsRawFd, sync::Arc}; use wayland_server::{ - DataInit, Dispatch, DisplayHandle, New, Resource, WEnum, + DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, backend::ClientId, protocol::{ wl_buffer, @@ -20,10 +20,8 @@ use wayland_server::{ }, }; -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, - D: Dispatch, D: ShmHandler, D: 'static, { @@ -44,9 +42,9 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch + ShmHandler + 'static, + D: ShmHandler + 'static, { fn request( &self, @@ -94,9 +92,9 @@ where * wl_shm_pool */ -impl Dispatch2 for ShmPoolUserData +impl Dispatch for ShmPoolUserData where - D: Dispatch + BufferHandler + ShmHandler + 'static, + D: ShmHandler + 'static, { fn request( &self, @@ -147,39 +145,28 @@ where return; } - match format { - WEnum::Value(format) => { - if !state.shm_state().formats.contains(&format) { - pool.post_error( - wl_shm::Error::InvalidFormat, - format!("format {format:?} not supported"), - ); + if !state.shm_state().formats.contains(&format) { + pool.post_error( + wl_shm::Error::InvalidFormat, + format!("format {format:?} not supported"), + ); - return; - } + return; + } - let data = ShmBufferUserData { - pool: arc_pool.clone(), - data: BufferData { - offset, - width, - height, - stride, - format, - }, - destruction_hooks: Default::default(), - }; - - data_init.init(buffer, data); - } + let data = ShmBufferUserData { + pool: arc_pool.clone(), + data: BufferData { + offset, + width, + height, + stride, + format, + }, + destruction_hooks: Default::default(), + }; - WEnum::Unknown(unknown) => { - pool.post_error( - wl_shm::Error::InvalidFormat, - format!("unknown format 0x{unknown:x}"), - ); - } - } + data_init.init(buffer, data); } Request::Resize { size } => { @@ -207,7 +194,7 @@ where } } -impl Dispatch2 for ShmBufferUserData +impl Dispatch for ShmBufferUserData where D: BufferHandler, D: 'static, diff --git a/src/wayland/shm/mod.rs b/src/wayland/shm/mod.rs index aee6f96799cb..5954b4ada514 100644 --- a/src/wayland/shm/mod.rs +++ b/src/wayland/shm/mod.rs @@ -102,12 +102,11 @@ use std::{ }; use wayland_server::{ - Dispatch, DisplayHandle, GlobalDispatch, Resource, WEnum, + Dispatch, DisplayHandle, GlobalDispatch, Resource, backend::GlobalId, protocol::{ wl_buffer, wl_shm::{self, WlShm}, - wl_shm_pool::WlShmPool, }, }; @@ -142,12 +141,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 +176,7 @@ impl ShmState { } /// Shm global handler -pub trait ShmHandler { +pub trait ShmHandler: BufferHandler { /// Return the Shm global state fn shm_state(&self) -> &ShmState; } @@ -298,15 +292,11 @@ where /// Returns the bpp of the format /// /// Note: This will return 0 for formats that don't have a specified width. -pub fn wl_bytes_per_pixel(format: WEnum) -> i32 { - match format { - WEnum::Value(f) => { - shm_format_to_fourcc(f).map_or(0, |fourcc| get_bpp(fourcc).map_or(0, |bpp| bpp / 8)) - } - WEnum::Unknown(_) => 0, - } - .try_into() - .unwrap() +pub fn wl_bytes_per_pixel(format: wl_shm::Format) -> i32 { + shm_format_to_fourcc(format) + .map_or(0, |fourcc| get_bpp(fourcc).map_or(0, |bpp| bpp / 8)) + .try_into() + .unwrap() } macro_rules! shm_format_table { diff --git a/src/wayland/single_pixel_buffer/handlers.rs b/src/wayland/single_pixel_buffer/handlers.rs index e9127198a2e4..41013c91a7c7 100644 --- a/src/wayland/single_pixel_buffer/handlers.rs +++ b/src/wayland/single_pixel_buffer/handlers.rs @@ -1,18 +1,17 @@ -use crate::wayland::{Dispatch2, GlobalData, GlobalDispatch2, buffer::BufferHandler}; +use crate::wayland::{GlobalData, buffer::BufferHandler}; use super::SinglePixelBufferUserData; use wayland_protocols::wp::single_pixel_buffer::v1::server::wp_single_pixel_buffer_manager_v1::{ self, WpSinglePixelBufferManagerV1, }; use wayland_server::{ - DataInit, Dispatch, DisplayHandle, New, + DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, protocol::wl_buffer::{self, WlBuffer}, }; -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, - D: 'static, + D: BufferHandler, { fn bind( &self, @@ -26,10 +25,9 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, - D: 'static, + D: BufferHandler, { fn request( &self, @@ -56,7 +54,7 @@ where } } -impl Dispatch2 for SinglePixelBufferUserData +impl Dispatch for SinglePixelBufferUserData where D: BufferHandler, { diff --git a/src/wayland/single_pixel_buffer/mod.rs b/src/wayland/single_pixel_buffer/mod.rs index 737c132d7cb1..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..110ef8e9a560 100644 --- a/src/wayland/tablet_manager/mod.rs +++ b/src/wayland/tablet_manager/mod.rs @@ -95,14 +95,9 @@ use crate::{ input::{Seat, SeatHandler}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, -}; -use wayland_protocols::wp::tablet::zv2::server::{ - zwp_tablet_manager_v2::{self, ZwpTabletManagerV2}, - zwp_tablet_seat_v2::ZwpTabletSeatV2, - zwp_tablet_tool_v2::ZwpTabletToolV2, - zwp_tablet_v2::ZwpTabletV2, + wayland::GlobalData, }; +use wayland_protocols::wp::tablet::zv2::server::zwp_tablet_manager_v2::{self, ZwpTabletManagerV2}; use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, backend::GlobalId}; const MANAGER_VERSION: u32 = 1; @@ -115,7 +110,6 @@ pub use tablet::{TabletDescriptor, TabletHandle, TabletUserData}; pub use tablet_seat::{TabletSeatHandle, TabletSeatHandler, TabletSeatUserData}; pub use tablet_tool::{TabletToolHandle, TabletToolUserData}; -use super::compositor::CompositorHandler; /// Extends [Seat] with graphic tablet specific functionality pub trait TabletSeatTrait { @@ -141,11 +135,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 +148,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 +164,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..afee1604ef2e 100644 --- a/src/wayland/tablet_manager/tablet_seat.rs +++ b/src/wayland/tablet_manager/tablet_seat.rs @@ -1,21 +1,14 @@ -use wayland_protocols::wp::tablet::zv2::server::{ - zwp_tablet_seat_v2::{self, ZwpTabletSeatV2}, - zwp_tablet_tool_v2::ZwpTabletToolV2, - zwp_tablet_v2::ZwpTabletV2, -}; +use wayland_protocols::wp::tablet::zv2::server::zwp_tablet_seat_v2::{self, ZwpTabletSeatV2}; use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, Resource, Weak, backend::ClientId}; 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}; -use super::{ - tablet::TabletUserData, - tablet_tool::{TabletToolHandle, TabletToolUserData}, -}; +use super::tablet_tool::TabletToolHandle; use std::collections::HashMap; use std::fmt; @@ -39,7 +32,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 +58,6 @@ impl TabletSeatHandle { seat: &ZwpTabletSeatV2, client: &Client, ) where - D: Dispatch, - D: Dispatch, D: TabletSeatHandler + 'static, D: CompositorHandler, { @@ -93,8 +84,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 +145,7 @@ impl TabletSeatHandle { tool_desc: &TabletToolDescriptor, ) -> TabletToolHandle where - D: Dispatch, D: TabletSeatHandler + 'static, - D: CompositorHandler, { let inner = &mut *self.inner.lock().unwrap(); @@ -213,7 +201,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..2cb8a741943f 100644 --- a/src/wayland/text_input/mod.rs +++ b/src/wayland/text_input/mod.rs @@ -44,15 +44,12 @@ //! ``` //! -use wayland_protocols::wp::text_input::zv3::server::{ - zwp_text_input_manager_v3::{self, ZwpTextInputManagerV3}, - zwp_text_input_v3::ZwpTextInputV3, -}; +use wayland_protocols::wp::text_input::zv3::server::zwp_text_input_manager_v3::{self, ZwpTextInputManagerV3}; use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, backend::GlobalId}; use crate::{ input::{Seat, SeatHandler}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, + wayland::GlobalData, }; pub use text_input_handle::TextInputHandle; @@ -88,10 +85,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 +98,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 +114,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..7c847f163c7a 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, @@ -246,13 +246,15 @@ where } zwp_text_input_v3::Request::SetTextChangeCause { cause } => { // Guard against clients sending us unknown values from future versions. - let cause = cause.into_result().unwrap_or(ChangeCause::Other); + // TODO check if enum variant in version? + // let cause = cause.into_result().unwrap_or(ChangeCause::Other); pending_state.text_change_cause = Some(cause); } zwp_text_input_v3::Request::SetContentType { hint, purpose } => { // Guard against clients sending us unknown values from future versions. let hint = ContentHint::from_bits_truncate(u32::from(hint)); - let purpose = purpose.into_result().unwrap_or(ContentPurpose::Normal); + // TODO check if enum variant in version? + // let purpose = purpose.into_result().unwrap_or(ContentPurpose::Normal); pending_state.content_type = Some((hint, purpose)); } zwp_text_input_v3::Request::SetCursorRectangle { x, y, width, height } => { diff --git a/src/wayland/viewporter/mod.rs b/src/wayland/viewporter/mod.rs index a9e32c5ca177..9b1cadf916cf 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..3f19fce6c0d8 100644 --- a/src/wayland/virtual_keyboard/mod.rs +++ b/src/wayland/virtual_keyboard/mod.rs @@ -44,15 +44,12 @@ //! ``` //! -use wayland_protocols_misc::zwp_virtual_keyboard_v1::server::{ - zwp_virtual_keyboard_manager_v1::{self, ZwpVirtualKeyboardManagerV1}, - zwp_virtual_keyboard_v1::ZwpVirtualKeyboardV1, -}; +use wayland_protocols_misc::zwp_virtual_keyboard_v1::server::zwp_virtual_keyboard_manager_v1::{self, ZwpVirtualKeyboardManagerV1}; use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, backend::GlobalId}; use crate::{ input::{Seat, SeatHandler}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, + wayland::{GlobalData, seat::WaylandFocus}, }; use self::virtual_keyboard_handle::VirtualKeyboardHandle; @@ -77,7 +74,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 +89,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 +104,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 +125,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..f22048c4266d 100644 --- a/src/wayland/virtual_keyboard/virtual_keyboard_handle.rs +++ b/src/wayland/virtual_keyboard/virtual_keyboard_handle.rs @@ -5,7 +5,6 @@ use std::{ }; use tracing::debug; -use wayland_protocols_misc::zwp_virtual_keyboard_v1::server::zwp_virtual_keyboard_v1::Error::NoKeymap; use wayland_protocols_misc::zwp_virtual_keyboard_v1::server::zwp_virtual_keyboard_v1::{ self, ZwpVirtualKeyboardV1, }; @@ -20,7 +19,7 @@ use crate::{ input::{Seat, SeatHandler}, utils::SERIAL_COUNTER, wayland::{ - Dispatch2, + Dispatch, seat::{WaylandFocus, keyboard::for_each_focused_kbds}, }, }; @@ -71,7 +70,7 @@ impl fmt::Debug for VirtualKeyboardUserData { } } -impl Dispatch2 for VirtualKeyboardUserData +impl Dispatch for VirtualKeyboardUserData where D: SeatHandler + 'static, ::KeyboardFocus: WaylandFocus, @@ -95,7 +94,10 @@ where let vk_state = match virtual_data.state.as_mut() { Some(vk_state) => vk_state, None => { - virtual_keyboard.post_error(NoKeymap, "`key` sent before keymap."); + virtual_keyboard.post_error( + zwp_virtual_keyboard_v1::Error::NoKeymap, + "`key` sent before keymap.", + ); return; } }; @@ -131,7 +133,10 @@ where let state = match virtual_data.state.as_mut() { Some(state) => state, None => { - virtual_keyboard.post_error(NoKeymap, "`modifiers` sent before keymap."); + virtual_keyboard.post_error( + zwp_virtual_keyboard_v1::Error::NoKeymap, + "`modifiers` sent before keymap.", + ); return; } }; @@ -172,7 +177,7 @@ where D: SeatHandler + 'static, { // Only libxkbcommon compatible keymaps are supported. - if format != KeymapFormat::XkbV1 as u32 { + if format != u32::from(KeymapFormat::XkbV1) { debug!("Unsupported keymap format: {format:?}"); return; } diff --git a/src/wayland/xdg_activation/dispatch.rs b/src/wayland/xdg_activation/dispatch.rs index b9680590a41c..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..c493a41d1a61 100644 --- a/src/wayland/xdg_foreign/mod.rs +++ b/src/wayland/xdg_foreign/mod.rs @@ -38,14 +38,14 @@ use rand::distr::{Alphanumeric, SampleString}; use wayland_protocols::xdg::foreign::zv2::server::{ zxdg_exporter_v2::ZxdgExporterV2, zxdg_imported_v2::ZxdgImportedV2, zxdg_importer_v2::ZxdgImporterV2, }; -use wayland_server::{DisplayHandle, GlobalDispatch, backend::GlobalId, protocol::wl_surface::WlSurface}; +use wayland_server::{DisplayHandle, backend::GlobalId, protocol::wl_surface::WlSurface}; -use crate::wayland::GlobalData; +use crate::wayland::{GlobalData, shell::xdg::XdgShellHandler}; mod handlers; /// A trait implemented to be notified of activation requests using the xdg foreign protocol. -pub trait XdgForeignHandler: 'static { +pub trait XdgForeignHandler: XdgShellHandler + 'static { /// Returns the xdg foreign state. fn xdg_foreign_state(&mut self) -> &mut XdgForeignState; } @@ -107,8 +107,6 @@ impl XdgForeignState { pub fn new(display: &DisplayHandle) -> Self where D: XdgForeignHandler, - D: GlobalDispatch, - D: GlobalDispatch, { let exporter = display.create_global::(1, GlobalData); let importer = display.create_global::(1, GlobalData); diff --git a/src/wayland/xdg_system_bell.rs b/src/wayland/xdg_system_bell.rs index 5006003fee2e..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 2a22b1e4b37a..590e7a4c684c 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,