diff --git a/Cargo.toml b/Cargo.toml index 47bb4c151dda..badec37450a0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -147,3 +147,16 @@ harness = false [profile.release-with-debug] inherits = "release" debug = true + +[patch.crates-io] +wayland-sys = { git = "https://github.com/smithay/wayland-rs" } +wayland-egl = { git = "https://github.com/smithay/wayland-rs" } +wayland-backend = { git = "https://github.com/smithay/wayland-rs" } +wayland-server = { git = "https://github.com/smithay/wayland-rs" } +wayland-scanner = { git = "https://github.com/smithay/wayland-rs" } +wayland-client = { git = "https://github.com/smithay/wayland-rs" } +wayland-protocols = { git = "https://github.com/smithay/wayland-rs" } +wayland-protocols-wlr = { git = "https://github.com/smithay/wayland-rs" } +wayland-cursor = { git = "https://github.com/smithay/wayland-rs" } +winit = { git = "https://github.com/ids1024/winit", branch = "dispatch2" } +gbm = { git = "https://github.com/ids1024/gbm.rs", branch = "wayland-rs" } diff --git a/anvil/src/shell/grabs.rs b/anvil/src/shell/grabs.rs index ca2b17dd6a58..ca0ab2700983 100644 --- a/anvil/src/shell/grabs.rs +++ b/anvil/src/shell/grabs.rs @@ -279,7 +279,7 @@ bitflags::bitflags! { impl From for ResizeEdge { #[inline] fn from(x: xdg_toplevel::ResizeEdge) -> Self { - Self::from_bits(x as u32).unwrap() + Self::from_bits(u32::from(x)).unwrap() } } diff --git a/anvil/src/state.rs b/anvil/src/state.rs index b006e79f3cdf..2eddf3845c09 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, @@ -617,8 +616,6 @@ impl ImageCopyCaptureHandler for AnvilState { } } -delegate_dispatch2!(@ AnvilState); - impl AnvilState { pub fn init( display: Display>, diff --git a/src/backend/egl/display.rs b/src/backend/egl/display.rs index 0b0ce91f7b73..453ef6f67ad7 100644 --- a/src/backend/egl/display.rs +++ b/src/backend/egl/display.rs @@ -865,7 +865,7 @@ impl EGLDisplay { ffi::egl::BindWaylandDisplayWL(**self.display, display_ptr as *mut _) }) .map_err(Error::OtherEGLDisplayAlreadyBound)?; - let reader = EGLBufferReader::new(self.display.clone(), display_ptr); + let reader = EGLBufferReader::new(self.display.clone(), display_ptr as _); let mut global = BUFFER_READER.lock().unwrap(); if global.as_ref().and_then(|x| x.upgrade()).is_some() { warn!("Double bind_wl_display, smithay does not support this, please report"); @@ -1065,7 +1065,7 @@ impl EGLBufferReader { let query = wrap_egl_call_bool(|| unsafe { ffi::egl::QueryWaylandBufferWL( **self.display, - buffer.id().as_ptr() as _, + buffer.id().as_ptr().unwrap().as_ptr(), ffi::egl::EGL_TEXTURE_FORMAT, &mut format, ) @@ -1095,7 +1095,7 @@ impl EGLBufferReader { wrap_egl_call_bool(|| unsafe { ffi::egl::QueryWaylandBufferWL( **self.display, - buffer.id().as_ptr() as _, + buffer.id().as_ptr().unwrap().as_ptr(), ffi::egl::WIDTH as i32, &mut width, ) @@ -1106,7 +1106,7 @@ impl EGLBufferReader { wrap_egl_call_bool(|| unsafe { ffi::egl::QueryWaylandBufferWL( **self.display, - buffer.id().as_ptr() as _, + buffer.id().as_ptr().unwrap().as_ptr(), ffi::egl::HEIGHT as i32, &mut height, ) @@ -1128,7 +1128,7 @@ impl EGLBufferReader { unsafe { ffi::egl::QueryWaylandBufferWL( **self.display, - buffer.id().as_ptr() as _, + buffer.id().as_ptr().unwrap().as_ptr(), ffi::egl::WAYLAND_Y_INVERTED_WL, &mut inverted, ) @@ -1152,7 +1152,7 @@ impl EGLBufferReader { **self.display, ffi::egl::NO_CONTEXT, ffi::egl::WAYLAND_BUFFER_WL, - buffer.id().as_ptr() as *mut _, + buffer.id().as_ptr().unwrap().as_ptr(), out.as_ptr(), ) }) @@ -1188,7 +1188,7 @@ impl EGLBufferReader { if unsafe { ffi::egl::QueryWaylandBufferWL( **self.display, - buffer.id().as_ptr() as _, + buffer.id().as_ptr().unwrap().as_ptr(), ffi::egl::WIDTH as _, &mut width, ) == 0 @@ -1200,7 +1200,7 @@ impl EGLBufferReader { if unsafe { ffi::egl::QueryWaylandBufferWL( **self.display, - buffer.id().as_ptr() as _, + buffer.id().as_ptr().unwrap().as_ptr(), ffi::egl::HEIGHT as _, &mut height, ) == 0 diff --git a/src/backend/egl/native.rs b/src/backend/egl/native.rs index b98b94f72096..c1754ee33b91 100644 --- a/src/backend/egl/native.rs +++ b/src/backend/egl/native.rs @@ -408,7 +408,7 @@ unsafe impl EGLNativeSurface for wegl::WlEglSurface { ffi::egl::CreatePlatformWindowSurfaceEXT( display.handle, config_id, - self.ptr() as *mut _, + self.ptr().as_ptr(), WINIT_SURFACE_ATTRIBUTES.as_ptr(), ) }) diff --git a/src/backend/winit/mod.rs b/src/backend/winit/mod.rs index 1c3729b5a56c..0702aaded48c 100644 --- a/src/backend/winit/mod.rs +++ b/src/backend/winit/mod.rs @@ -236,7 +236,7 @@ where let size = window.surface_size(); let surface = unsafe { wegl::WlEglSurface::new_from_raw( - handle.surface.as_ptr() as *mut _, + std::ptr::NonNull::new(handle.surface.as_ptr() as *mut _).unwrap(), size.width as i32, size.height as i32, ) @@ -663,6 +663,7 @@ impl ApplicationHandler for WinitEventLoopApp<'_, F> { | WindowEvent::TouchpadPressure { .. } | WindowEvent::RotationGesture { .. } | WindowEvent::PanGesture { .. } + | WindowEvent::HoldGesture { .. } | WindowEvent::ActivationTokenDone { .. } => (), } } 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..84719b13a9e4 100644 --- a/src/wayland/alpha_modifier/mod.rs +++ b/src/wayland/alpha_modifier/mod.rs @@ -54,13 +54,8 @@ use std::sync::{ atomic::{self, AtomicBool}, }; -use wayland_protocols::wp::alpha_modifier::v1::server::{ - wp_alpha_modifier_surface_v1::WpAlphaModifierSurfaceV1, wp_alpha_modifier_v1::WpAlphaModifierV1, -}; -use wayland_server::{ - Dispatch, DisplayHandle, GlobalDispatch, Resource, Weak, backend::GlobalId, - protocol::wl_surface::WlSurface, -}; +use wayland_protocols::wp::alpha_modifier::v1::server::wp_alpha_modifier_v1::WpAlphaModifierV1; +use wayland_server::{DisplayHandle, Resource, Weak, backend::GlobalId, protocol::wl_surface::WlSurface}; use super::compositor::Cacheable; @@ -161,10 +156,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..1593eeb573b3 100644 --- a/src/wayland/background_effect/mod.rs +++ b/src/wayland/background_effect/mod.rs @@ -41,9 +41,7 @@ use crate::wayland::{ use wayland_protocols::ext::background_effect::v1::server::ext_background_effect_manager_v1::{ self, ExtBackgroundEffectManagerV1, }; -use wayland_server::{ - DisplayHandle, GlobalDispatch, Resource, Weak, backend::GlobalId, protocol::wl_surface::WlSurface, -}; +use wayland_server::{DisplayHandle, Resource, Weak, backend::GlobalId, protocol::wl_surface::WlSurface}; pub use ext_background_effect_manager_v1::Capability; @@ -144,7 +142,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 57cb97bcee23..73f0e51ac3df 100644 --- a/src/wayland/compositor/mod.rs +++ b/src/wayland/compositor/mod.rs @@ -131,7 +131,7 @@ use wayland_server::backend::GlobalId; use wayland_server::protocol::wl_compositor::WlCompositor; use wayland_server::protocol::wl_subcompositor::WlSubcompositor; use wayland_server::protocol::{wl_buffer, wl_callback, wl_output, wl_region, wl_surface::WlSurface}; -use wayland_server::{Client, DisplayHandle, GlobalDispatch, Resource}; +use wayland_server::{Client, DisplayHandle, Resource}; /// The role of a subsurface surface. pub const SUBSURFACE_ROLE: &str = "subsurface"; @@ -695,7 +695,7 @@ impl CompositorState { /// [`wl_subcompositor`]: wayland_server::protocol::wl_subcompositor pub fn new(display: &DisplayHandle) -> Self where - D: GlobalDispatch + GlobalDispatch + 'static, + D: CompositorHandler + 'static, { Self::new_with_version::(display, 5) } @@ -709,14 +709,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..9603675a2121 100644 --- a/src/wayland/content_type/mod.rs +++ b/src/wayland/content_type/mod.rs @@ -55,9 +55,7 @@ use std::sync::{ use wayland_protocols::wp::content_type::v1::server::{ wp_content_type_manager_v1::WpContentTypeManagerV1, wp_content_type_v1, }; -use wayland_server::{ - DisplayHandle, GlobalDispatch, Resource, Weak, backend::GlobalId, protocol::wl_surface::WlSurface, -}; +use wayland_server::{DisplayHandle, Resource, Weak, backend::GlobalId, protocol::wl_surface::WlSurface}; use super::compositor::Cacheable; @@ -156,7 +154,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 b33ab7260ec6..8102cd8b7602 100644 --- a/src/wayland/cursor_shape.rs +++ b/src/wayland/cursor_shape.rs @@ -104,18 +104,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}; @@ -130,9 +128,8 @@ impl CursorShapeManagerState { /// Register new [CursorShapeManager] global. pub fn new(display: &DisplayHandle) -> Self where - D: GlobalDispatch, - D: Dispatch, - D: SeatHandler, + D: TabletSeatHandler, + ::PointerFocus: WaylandFocus, D: 'static, { let global = display.create_global::(2, GlobalData); @@ -145,10 +142,10 @@ impl CursorShapeManagerState { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, - D: SeatHandler, + D: TabletSeatHandler, + ::PointerFocus: WaylandFocus, D: 'static, { fn bind( @@ -163,10 +160,10 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch>, - D: SeatHandler, + D: TabletSeatHandler, + ::PointerFocus: WaylandFocus, D: 'static, { fn request( @@ -235,7 +232,7 @@ pub(crate) enum CursorShapeDeviceUserDataInner { Tablet(Weak), } -impl Dispatch2 for CursorShapeDeviceUserData +impl Dispatch for CursorShapeDeviceUserData where D: SeatHandler + TabletSeatHandler, ::PointerFocus: WaylandFocus, @@ -251,10 +248,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 { @@ -303,9 +297,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 6eebeac317f0..686b8a0c353a 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 013d13b0ea58..d5b06a52c161 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, DisplayHandle, Resource, backend::{GlobalId, InvalidId}, protocol::{ wl_buffer::{self, WlBuffer}, @@ -579,10 +579,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) } @@ -602,10 +599,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::>(); @@ -626,10 +620,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) } @@ -648,10 +639,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::( @@ -670,10 +658,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(); @@ -858,11 +843,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(); @@ -1035,7 +1016,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 db09f695fa3a..e24dfa4377ce 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)] @@ -384,9 +381,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) } @@ -400,9 +395,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 @@ -433,9 +426,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; @@ -531,18 +522,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 @@ -576,9 +563,7 @@ impl DrmLeaseState { fn remove_lease(&mut self, id: u32) -> Option where - D: DrmLeaseHandler - + Dispatch - + 'static, + D: DrmLeaseHandler + 'static, { let lease_ref = { { @@ -637,9 +622,7 @@ impl DrmLeaseConnector { client: &Client, ) -> Option where - D: DrmLeaseHandler - + Dispatch - + 'static, + D: DrmLeaseHandler + 'static, { if let Ok(lease_connector) = client .create_resource::( @@ -664,12 +647,9 @@ impl DrmLeaseConnector { } } -impl GlobalDispatch2 for DrmLeaseDeviceGlobalData +impl GlobalDispatch for DrmLeaseDeviceGlobalData where - D: DrmLeaseHandler - + Dispatch - + Dispatch - + 'static, + D: DrmLeaseHandler + 'static, { fn bind( &self, @@ -711,11 +691,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, @@ -754,7 +732,7 @@ pub struct DrmLeaseConnectorData { node: DrmNode, } -impl Dispatch2 for DrmLeaseConnectorData +impl Dispatch for DrmLeaseConnectorData where D: DrmLeaseHandler + 'static, { @@ -782,9 +760,9 @@ where } } -impl Dispatch2 for DrmLeaseRequestData +impl Dispatch for DrmLeaseRequestData where - D: DrmLeaseHandler + Dispatch + 'static, + D: DrmLeaseHandler + 'static, { fn request( &self, @@ -897,11 +875,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..1049cc7fddd5 100644 --- a/src/wayland/idle_inhibit/inhibitor.rs +++ b/src/wayland/idle_inhibit/inhibitor.rs @@ -3,9 +3,8 @@ use _idle_inhibit::zwp_idle_inhibitor_v1::{Request, ZwpIdleInhibitorV1}; use wayland_protocols::wp::idle_inhibit::zv1::server as _idle_inhibit; use wayland_server::protocol::wl_surface::WlSurface; -use wayland_server::{Client, DataInit, DisplayHandle}; +use wayland_server::{Client, DataInit, Dispatch, DisplayHandle}; -use crate::wayland::Dispatch2; use crate::wayland::idle_inhibit::IdleInhibitHandler; /// State of zwp_idle_inhibitor_v1. @@ -21,7 +20,7 @@ impl IdleInhibitorState { } } -impl Dispatch2 for IdleInhibitorState +impl Dispatch for IdleInhibitorState where D: IdleInhibitHandler, D: 'static, diff --git a/src/wayland/idle_inhibit/mod.rs b/src/wayland/idle_inhibit/mod.rs index 6ea1cb0b9d8a..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 621f01d4c4fd..c78996894c5a 100644 --- a/src/wayland/idle_notify/mod.rs +++ b/src/wayland/idle_notify/mod.rs @@ -67,7 +67,7 @@ use wayland_server::{ use crate::{ input::{Seat, SeatHandler}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, + wayland::GlobalData, }; /// Handler trait for ext-idle-notify @@ -119,7 +119,6 @@ impl IdleNotifierState { /// Create new [`ExtIdleNotifierV1`] global. pub fn new(display: &DisplayHandle, loop_handle: LoopHandle<'static, D>) -> Self where - D: GlobalDispatch, D: IdleNotifierHandler, D: 'static, { @@ -242,9 +241,8 @@ impl IdleNotifierState { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, D: IdleNotifierHandler, D: 'static, { @@ -260,9 +258,8 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, D: IdleNotifierHandler, D: 'static, { @@ -332,7 +329,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..b3291e19db56 100644 --- a/src/wayland/input_method/input_method_keyboard_grab.rs +++ b/src/wayland/input_method/input_method_keyboard_grab.rs @@ -6,7 +6,7 @@ use std::{ use wayland_protocols_misc::zwp_input_method_v2::server::zwp_input_method_keyboard_grab_v2::{ self, ZwpInputMethodKeyboardGrabV2, }; -use wayland_server::backend::ClientId; +use wayland_server::{Dispatch, backend::ClientId}; use crate::input::{ SeatHandler, @@ -19,7 +19,6 @@ use crate::wayland::text_input::TextInputHandle; use crate::{ backend::input::{KeyState, Keycode}, utils::Serial, - wayland::Dispatch2, }; #[derive(Default, Debug)] @@ -98,7 +97,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..4c58d07af46a 100644 --- a/src/wayland/input_method/input_method_popup_surface.rs +++ b/src/wayland/input_method/input_method_popup_surface.rs @@ -3,14 +3,11 @@ use std::sync::{Arc, Mutex}; use wayland_protocols_misc::zwp_input_method_v2::server::zwp_input_popup_surface_v2::{ self, ZwpInputPopupSurfaceV2, }; -use wayland_server::{Resource, backend::ClientId, protocol::wl_surface::WlSurface}; - -use crate::{ - utils::{ - Logical, Point, Rectangle, - alive_tracker::{AliveTracker, IsAlive}, - }, - wayland::Dispatch2, +use wayland_server::{Dispatch, Resource, backend::ClientId, protocol::wl_surface::WlSurface}; + +use crate::utils::{ + Logical, Point, Rectangle, + alive_tracker::{AliveTracker, IsAlive}, }; /// Handle to a popup surface @@ -130,7 +127,7 @@ pub struct InputMethodPopupSurfaceUserData { pub(super) alive_tracker: AliveTracker, } -impl Dispatch2 for InputMethodPopupSurfaceUserData { +impl Dispatch for InputMethodPopupSurfaceUserData { fn request( &self, _state: &mut D, diff --git a/src/wayland/input_method/mod.rs b/src/wayland/input_method/mod.rs index a9135a37b701..3b24afe4a9de 100644 --- a/src/wayland/input_method/mod.rs +++ b/src/wayland/input_method/mod.rs @@ -60,15 +60,14 @@ use wayland_server::{ protocol::wl_surface::WlSurface, }; -use wayland_protocols_misc::zwp_input_method_v2::server::{ - zwp_input_method_manager_v2::{self, ZwpInputMethodManagerV2}, - zwp_input_method_v2::ZwpInputMethodV2, +use wayland_protocols_misc::zwp_input_method_v2::server::zwp_input_method_manager_v2::{ + self, ZwpInputMethodManagerV2, }; use crate::{ input::{Seat, SeatHandler}, utils::{Logical, Rectangle}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, + wayland::{GlobalData, seat::WaylandFocus}, }; pub use input_method_handle::{InputMethodHandle, InputMethodUserData}; @@ -88,7 +87,7 @@ mod input_method_popup_surface; pub use input_method_popup_surface::{PopupParent, PopupSurface}; /// Adds input method popup to compositor state -pub trait InputMethodHandler { +pub trait InputMethodHandler: SeatHandler { /// Add a popup surface to compositor state. fn new_popup(&mut self, surface: PopupSurface); @@ -132,11 +131,8 @@ impl InputMethodManagerState { /// Initialize a text input manager global. pub fn new(display: &DisplayHandle, filter: F) -> Self where - D: GlobalDispatch, - D: Dispatch, - D: Dispatch>, - D: SeatHandler, - D: 'static, + D: InputMethodHandler + 'static, + ::KeyboardFocus: WaylandFocus, F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, { let data = InputMethodManagerGlobalData { @@ -153,12 +149,10 @@ impl InputMethodManagerState { } } -impl GlobalDispatch2 for InputMethodManagerGlobalData +impl GlobalDispatch for InputMethodManagerGlobalData where - D: Dispatch, - D: Dispatch>, - D: SeatHandler, - D: 'static, + D: InputMethodHandler + 'static, + ::KeyboardFocus: WaylandFocus, { fn bind( &self, @@ -176,11 +170,10 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch>, - D: SeatHandler + InputMethodHandler, - D: 'static, + D: InputMethodHandler + 'static, + ::KeyboardFocus: WaylandFocus, { fn request( &self, diff --git a/src/wayland/keyboard_shortcuts_inhibit/dispatch.rs b/src/wayland/keyboard_shortcuts_inhibit/dispatch.rs index b29d883826dd..c69780b1ec80 100644 --- a/src/wayland/keyboard_shortcuts_inhibit/dispatch.rs +++ b/src/wayland/keyboard_shortcuts_inhibit/dispatch.rs @@ -8,15 +8,12 @@ use wayland_protocols::wp::keyboard_shortcuts_inhibit::zv1::server::{ zwp_keyboard_shortcuts_inhibitor_v1::{self, ZwpKeyboardShortcutsInhibitorV1}, }; use wayland_server::{ - Dispatch, Resource, + Dispatch, GlobalDispatch, Resource, backend::{ClientId, ObjectId}, protocol::wl_surface::WlSurface, }; -use crate::{ - input::{Seat, SeatHandler}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, -}; +use crate::{input::Seat, wayland::GlobalData}; use super::KeyboardShortcutsInhibitHandler; @@ -30,11 +27,9 @@ pub struct KeyboardShortcutsInhibitorUserData { pub(crate) is_active: AtomicBool, } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where D: KeyboardShortcutsInhibitHandler, - D: Dispatch, - D: Dispatch, { fn bind( &self, @@ -48,11 +43,9 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where D: KeyboardShortcutsInhibitHandler, - D: SeatHandler, - D: Dispatch, { fn request( &self, @@ -111,7 +104,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 048163f1f00a..0d454ba46ab1 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); @@ -233,7 +230,7 @@ where /// WP Keyboard shortcuts inhibit handler #[allow(unused_variables)] -pub trait KeyboardShortcutsInhibitHandler { +pub trait KeyboardShortcutsInhibitHandler: SeatHandler { /// [KeyboardShortcutsInhibitState] getter fn keyboard_shortcuts_inhibit_state(&mut self) -> &mut KeyboardShortcutsInhibitState; diff --git a/src/wayland/mod.rs b/src/wayland/mod.rs index 5bc9f0bc4cbe..bafbb4b782b7 100644 --- a/src/wayland/mod.rs +++ b/src/wayland/mod.rs @@ -54,8 +54,6 @@ pub mod commit_timing; pub mod compositor; pub mod content_type; pub mod cursor_shape; -mod dispatch2; -pub use dispatch2::{Dispatch2, GlobalDispatch2}; pub mod dmabuf; #[cfg(feature = "backend_drm")] pub mod drm_lease; diff --git a/src/wayland/output/handlers.rs b/src/wayland/output/handlers.rs index 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..b8f17577aca5 100644 --- a/src/wayland/output/mod.rs +++ b/src/wayland/output/mod.rs @@ -83,7 +83,7 @@ use atomic_float::AtomicF64; use tracing::info; use wayland_protocols::xdg::xdg_output::zv1::server::zxdg_output_manager_v1::ZxdgOutputManagerV1; use wayland_server::{ - Client, DisplayHandle, GlobalDispatch, Resource, + Client, DisplayHandle, Resource, backend::{ClientId, GlobalId}, protocol::{ wl_output::{Mode as WMode, Subpixel as WlSubpixel, Transform, WlOutput}, @@ -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 f0c1200e6cdd..2bc3352f7c19 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; @@ -61,7 +61,7 @@ pub struct ConfinedPointer { handle: zwp_confined_pointer_v1::ZwpConfinedPointerV1, region: Option, pending_region: Option, - lifetime: WEnum, + lifetime: Lifetime, active: AtomicBool, } @@ -78,7 +78,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, @@ -167,7 +167,7 @@ impl PointerConstraintRef<'_, D> { } }; - if deactivated && self.lifetime() == WEnum::Value(Lifetime::Oneshot) { + if deactivated && self.lifetime() == Lifetime::Oneshot { self.entry.remove_entry(); } } @@ -191,7 +191,7 @@ impl PointerConstraint { } } - fn lifetime(&self) -> WEnum { + fn lifetime(&self) -> Lifetime { match self { PointerConstraint::Confined(confined) => confined.lifetime, PointerConstraint::Locked(locked) => locked.lifetime, @@ -225,12 +225,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); @@ -368,13 +363,9 @@ fn remove_constraint( } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch>, - D: Dispatch>, - D: SeatHandler, - D: PointerConstraintsHandler, - D: 'static, + D: PointerConstraintsHandler + 'static, { fn request( &self, @@ -458,9 +449,9 @@ where } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch + SeatHandler + 'static, + D: PointerConstraintsHandler + 'static, { fn bind( &self, @@ -474,10 +465,9 @@ where } } -impl Dispatch2 for PointerConstraintUserData +impl Dispatch for PointerConstraintUserData where - D: SeatHandler + PointerConstraintsHandler, - D: 'static, + D: SeatHandler + PointerConstraintsHandler + 'static, { fn request( &self, @@ -521,10 +511,9 @@ where } } -impl Dispatch2 for PointerConstraintUserData +impl Dispatch for PointerConstraintUserData where - D: SeatHandler + PointerConstraintsHandler, - D: 'static, + D: SeatHandler + PointerConstraintsHandler + 'static, { fn request( &self, diff --git a/src/wayland/pointer_gestures.rs b/src/wayland/pointer_gestures.rs index 3cae342fbd9c..cfb7e08929b3 100644 --- a/src/wayland/pointer_gestures.rs +++ b/src/wayland/pointer_gestures.rs @@ -121,7 +121,7 @@ use crate::{ }, }, utils::{SERIAL_COUNTER, Serial}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2, seat::PointerUserData}, + wayland::{GlobalData, seat::PointerUserData}, }; const MANAGER_VERSION: u32 = 3; @@ -379,11 +379,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, { @@ -398,11 +393,8 @@ impl PointerGesturesState { } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch>, - D: Dispatch>, - D: Dispatch>, D: SeatHandler, D: 'static, { @@ -458,9 +450,9 @@ where } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch + SeatHandler + 'static, + D: SeatHandler + 'static, { fn bind( &self, @@ -474,7 +466,7 @@ where } } -impl Dispatch2 for PointerGestureUserData +impl Dispatch for PointerGestureUserData where D: SeatHandler, D: 'static, @@ -506,7 +498,7 @@ where } } -impl Dispatch2 for PointerGestureUserData +impl Dispatch for PointerGestureUserData where D: SeatHandler, D: 'static, @@ -538,7 +530,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 6d3c31de3e8f..8e19b0de552c 100644 --- a/src/wayland/relative_pointer.rs +++ b/src/wayland/relative_pointer.rs @@ -102,7 +102,7 @@ use crate::{ SeatHandler, pointer::{PointerHandle, RelativeMotionEvent}, }, - wayland::{Dispatch2, GlobalData, GlobalDispatch2, seat::PointerUserData}, + wayland::{GlobalData, seat::PointerUserData}, }; const MANAGER_VERSION: u32 = 1; @@ -171,9 +171,6 @@ impl RelativePointerManagerState { /// Register new [ZwpRelativePointerV1] global pub fn new(display: &DisplayHandle) -> Self where - D: GlobalDispatch, - D: Dispatch, - D: Dispatch>, D: SeatHandler, D: 'static, { @@ -188,9 +185,8 @@ impl RelativePointerManagerState { } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch>, D: SeatHandler, D: 'static, { @@ -221,9 +217,9 @@ where } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch + SeatHandler + 'static, + D: SeatHandler + 'static, { fn bind( &self, @@ -237,7 +233,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..3324a4460273 100644 --- a/src/wayland/seat/keyboard.rs +++ b/src/wayland/seat/keyboard.rs @@ -2,7 +2,7 @@ use std::{cell::RefCell, fmt}; use tracing::{instrument, trace, warn}; use wayland_server::{ - Client, DisplayHandle, Resource, + Client, Dispatch, DisplayHandle, Resource, backend::{ClientId, ObjectId}, protocol::{ wl_keyboard::{self, KeyState as WlKeyState, WlKeyboard}, @@ -19,7 +19,6 @@ use crate::{ }, utils::{HookId, Serial, iter::new_locked_obj_iter_from_vec}, wayland::{ - Dispatch2, compositor::{add_destruction_hook, remove_destruction_hook, with_states}, input_method::InputMethodSeat, text_input::TextInputSeat, @@ -117,7 +116,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..638cf9f80c58 100644 --- a/src/wayland/seat/pointer.rs +++ b/src/wayland/seat/pointer.rs @@ -2,7 +2,7 @@ use std::sync::{Arc, Mutex, atomic::Ordering}; use atomic_float::AtomicF64; use wayland_server::{ - Client, DisplayHandle, Resource, Weak, + Client, Dispatch, DisplayHandle, Resource, Weak, backend::{ClientId, ObjectId}, protocol::{ wl_pointer::{ @@ -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::{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 6edc6c0490a6..857afc0e32cd 100644 --- a/src/wayland/seat/touch.rs +++ b/src/wayland/seat/touch.rs @@ -2,7 +2,7 @@ use std::sync::{Arc, atomic::Ordering}; use atomic_float::AtomicF64; use wayland_server::{ - Client, DisplayHandle, Resource, + Client, Dispatch, DisplayHandle, Resource, backend::ClientId, protocol::wl_touch::{self, WlTouch}, }; @@ -10,7 +10,6 @@ use wayland_server::{ use super::SeatHandler; use crate::input::touch::TouchHandle; use crate::input::touch::TouchTarget; -use crate::wayland::Dispatch2; use crate::wayland::compositor::CompositorHandler; use crate::wayland::seat::wl_surface::WlSurface; use crate::{ @@ -165,7 +164,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..1d6f4560b333 100644 --- a/src/wayland/selection/data_device/device.rs +++ b/src/wayland/selection/data_device/device.rs @@ -2,7 +2,7 @@ use std::cell::RefCell; use tracing::debug; use wayland_server::{ - Client, DataInit, DisplayHandle, Resource, + Client, DataInit, Dispatch, DisplayHandle, Resource, protocol::{ wl_data_device::{self, WlDataDevice}, wl_seat::WlSeat, @@ -13,7 +13,7 @@ use crate::{ input::{Seat, SeatHandler, dnd::DndFocus}, utils::Serial, wayland::{ - Dispatch2, compositor, + compositor, seat::WaylandFocus, selection::{ SelectionTarget, @@ -36,10 +36,9 @@ pub struct DataDeviceUserData { pub(crate) wl_seat: WlSeat, } -impl Dispatch2 for DataDeviceUserData +impl Dispatch for DataDeviceUserData where D: DataDeviceHandler, - D: SeatHandler, ::PointerFocus: DndFocus, ::TouchFocus: DndFocus, ::KeyboardFocus: WaylandFocus, diff --git a/src/wayland/selection/data_device/mod.rs b/src/wayland/selection/data_device/mod.rs index d35a243cec1b..1194efe5c669 100644 --- a/src/wayland/selection/data_device/mod.rs +++ b/src/wayland/selection/data_device/mod.rs @@ -83,7 +83,7 @@ use std::{ use smallvec::SmallVec; use tracing::instrument; use wayland_server::{ - Client, DisplayHandle, GlobalDispatch, Resource, + Client, DisplayHandle, Resource, backend::{ClientId, GlobalId, Handle, ObjectData, ObjectId, protocol::Message}, protocol::{ wl_data_device_manager::{DndAction as WlDndAction, WlDataDeviceManager}, @@ -100,7 +100,7 @@ use crate::{ dnd::{DndAction, DndFocus, GrabType, OfferData, Source}, }, utils::{Logical, Point, Serial}, - wayland::GlobalData, + wayland::{GlobalData, seat::WaylandFocus}, }; mod device; @@ -321,9 +321,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, @@ -579,8 +576,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); @@ -758,29 +757,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( @@ -795,11 +793,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..c26a31ddeadc 100644 --- a/src/wayland/selection/data_device/source.rs +++ b/src/wayland/selection/data_device/source.rs @@ -4,10 +4,10 @@ use std::{ os::fd::{AsFd, OwnedFd}, sync::Mutex, }; -use tracing::{debug, error}; +use tracing::debug; use wayland_server::{ - DisplayHandle, Resource, + Dispatch, DisplayHandle, Resource, backend::ClientId, protocol::{ wl_data_source::{self, WlDataSource}, @@ -20,7 +20,6 @@ use crate::input::{ dnd::{DndAction, Source, SourceMetadata}, }; use crate::utils::{IsAlive, alive_tracker::AliveTracker}; -use crate::wayland::Dispatch2; use crate::wayland::selection::offer::OfferReplySource; use crate::wayland::selection::seat_data::SeatData; use crate::wayland::selection::source::SelectionSourceProvider; @@ -45,7 +44,7 @@ impl DataSourceUserData { } } -impl Dispatch2 for DataSourceUserData +impl Dispatch for DataSourceUserData where D: DataDeviceHandler, D: 'static, @@ -65,14 +64,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..728b968b3830 100644 --- a/src/wayland/selection/ext_data_control/device.rs +++ b/src/wayland/selection/ext_data_control/device.rs @@ -5,10 +5,9 @@ use wayland_protocols::ext::data_control::v1::server::ext_data_control_device_v1 }; use wayland_server::Resource; use wayland_server::protocol::wl_seat::WlSeat; -use wayland_server::{Client, DisplayHandle}; +use wayland_server::{Client, Dispatch, DisplayHandle}; use crate::input::Seat; -use crate::wayland::Dispatch2; use crate::wayland::selection::device::SelectionDevice; use crate::wayland::selection::offer::OfferReplySource; use crate::wayland::selection::seat_data::SeatData; @@ -24,7 +23,7 @@ pub struct ExtDataControlDeviceUserData { pub(crate) wl_seat: WlSeat, } -impl Dispatch2 for ExtDataControlDeviceUserData +impl Dispatch for ExtDataControlDeviceUserData where D: DataControlHandler, D: 'static, diff --git a/src/wayland/selection/ext_data_control/mod.rs b/src/wayland/selection/ext_data_control/mod.rs index bf0520e9244d..1818f71682fe 100644 --- a/src/wayland/selection/ext_data_control/mod.rs +++ b/src/wayland/selection/ext_data_control/mod.rs @@ -60,7 +60,7 @@ use wayland_protocols::ext::data_control::v1::server::ext_data_control_manager_v use wayland_protocols::ext::data_control::v1::server::ext_data_control_source_v1::ExtDataControlSourceV1; use wayland_server::backend::GlobalId; use wayland_server::protocol::wl_seat::WlSeat; -use wayland_server::{Client, DisplayHandle, GlobalDispatch}; +use wayland_server::{Client, DisplayHandle}; mod device; mod source; @@ -98,7 +98,7 @@ impl DataControlState { filter: F, ) -> Self where - D: GlobalDispatch + 'static, + D: DataControlHandler + 'static, F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, { let data = ExtDataControlManagerGlobalData { @@ -139,18 +139,15 @@ mod handlers { use std::cell::RefCell; use tracing::error; - use wayland_protocols::ext::data_control::v1::server::{ - ext_data_control_device_v1::ExtDataControlDeviceV1, - ext_data_control_manager_v1::{self, ExtDataControlManagerV1}, - ext_data_control_source_v1::ExtDataControlSourceV1, + use wayland_protocols::ext::data_control::v1::server::ext_data_control_manager_v1::{ + self, ExtDataControlManagerV1, }; - use wayland_server::{Client, Dispatch, DisplayHandle}; + use wayland_server::{Client, Dispatch, DisplayHandle, GlobalDispatch}; use crate::input::Seat; use crate::wayland::selection::SelectionTarget; use crate::wayland::selection::device::SelectionDevice; use crate::wayland::selection::seat_data::SeatData; - use crate::wayland::{Dispatch2, GlobalDispatch2}; use super::DataControlHandler; use super::ExtDataControlDeviceUserData; @@ -158,9 +155,8 @@ mod handlers { use super::ExtDataControlManagerUserData; use super::ExtDataControlSourceUserData; - impl GlobalDispatch2 for ExtDataControlManagerGlobalData + impl GlobalDispatch for ExtDataControlManagerGlobalData where - D: Dispatch, D: DataControlHandler, D: 'static, { @@ -185,10 +181,8 @@ mod handlers { } } - impl Dispatch2 for ExtDataControlManagerUserData + impl Dispatch for ExtDataControlManagerUserData where - D: Dispatch, - D: Dispatch, D: DataControlHandler, D: 'static, { diff --git a/src/wayland/selection/ext_data_control/source.rs b/src/wayland/selection/ext_data_control/source.rs index 4c05b1199d9b..a9ea2ed56b1c 100644 --- a/src/wayland/selection/ext_data_control/source.rs +++ b/src/wayland/selection/ext_data_control/source.rs @@ -1,11 +1,10 @@ use std::cell::RefCell; use std::sync::Mutex; -use wayland_server::DisplayHandle; use wayland_server::backend::ClientId; +use wayland_server::{Dispatch, DisplayHandle}; use crate::input::Seat; -use crate::wayland::Dispatch2; use crate::wayland::selection::SelectionTarget; use crate::wayland::selection::offer::OfferReplySource; use crate::wayland::selection::seat_data::SeatData; @@ -40,7 +39,7 @@ pub struct SourceMetadata { pub mime_types: Vec, } -impl Dispatch2 for ExtDataControlSourceUserData +impl Dispatch for ExtDataControlSourceUserData where D: DataControlHandler, D: 'static, diff --git a/src/wayland/selection/primary_selection/device.rs b/src/wayland/selection/primary_selection/device.rs index 5d10d16258d8..5b3147032cf2 100644 --- a/src/wayland/selection/primary_selection/device.rs +++ b/src/wayland/selection/primary_selection/device.rs @@ -4,12 +4,11 @@ use tracing::debug; use wayland_protocols::wp::primary_selection::zv1::server::zwp_primary_selection_device_v1::{ self as primary_device, ZwpPrimarySelectionDeviceV1 as PrimaryDevice, }; -use wayland_server::{Client, DataInit, DisplayHandle, Resource, protocol::wl_seat::WlSeat}; +use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, Resource, protocol::wl_seat::WlSeat}; use crate::{ input::{Seat, SeatHandler}, wayland::{ - Dispatch2, seat::WaylandFocus, selection::{ SelectionHandler, SelectionTarget, @@ -29,7 +28,7 @@ pub struct PrimaryDeviceUserData { pub(crate) wl_seat: WlSeat, } -impl Dispatch2 for PrimaryDeviceUserData +impl Dispatch for PrimaryDeviceUserData where D: PrimarySelectionHandler, D: SelectionHandler, diff --git a/src/wayland/selection/primary_selection/mod.rs b/src/wayland/selection/primary_selection/mod.rs index e120a976db44..2960b8b034fd 100644 --- a/src/wayland/selection/primary_selection/mod.rs +++ b/src/wayland/selection/primary_selection/mod.rs @@ -81,11 +81,11 @@ use wayland_protocols::wp::primary_selection::zv1::{ }; use wayland_server::backend::GlobalId; use wayland_server::protocol::wl_seat::WlSeat; -use wayland_server::{Client, DisplayHandle, GlobalDispatch}; +use wayland_server::{Client, DisplayHandle}; use crate::{ input::{Seat, SeatHandler}, - wayland::selection::SelectionTarget, + wayland::{seat::WaylandFocus, selection::SelectionTarget}, }; mod device; @@ -127,8 +127,9 @@ impl PrimarySelectionState { /// Register new [`PrimaryDeviceManager`] global pub fn new(display: &DisplayHandle) -> Self where - D: GlobalDispatch + 'static, - D: PrimarySelectionHandler, + D: PrimarySelectionHandler + 'static, + ::PointerFocus: WaylandFocus, + ::KeyboardFocus: WaylandFocus, { Self::new_with_filter::(display, |_| true) } @@ -138,8 +139,9 @@ impl PrimarySelectionState { /// Filters can be used to limit visibility of a global to certain clients. pub fn new_with_filter(display: &DisplayHandle, filter: F) -> Self where - D: GlobalDispatch + 'static, - D: PrimarySelectionHandler, + D: PrimarySelectionHandler + 'static, + ::PointerFocus: WaylandFocus, + ::KeyboardFocus: WaylandFocus, F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, { let data = PrimaryDeviceManagerGlobalData { @@ -305,19 +307,16 @@ mod handlers { use std::cell::RefCell; use tracing::error; - use wayland_protocols::wp::primary_selection::zv1::server::{ - zwp_primary_selection_device_manager_v1::{ - self as primary_device_manager, ZwpPrimarySelectionDeviceManagerV1 as PrimaryDeviceManager, - }, - zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1 as PrimaryDevice, - zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1 as PrimarySource, + use wayland_protocols::wp::primary_selection::zv1::server::zwp_primary_selection_device_manager_v1::{ + self as primary_device_manager, ZwpPrimarySelectionDeviceManagerV1 as PrimaryDeviceManager, }; - use wayland_server::{Dispatch, DisplayHandle}; + use wayland_server::{Dispatch, DisplayHandle, GlobalDispatch}; use crate::{ input::{Seat, SeatHandler}, wayland::{ - Dispatch2, GlobalData, GlobalDispatch2, + GlobalData, + seat::WaylandFocus, selection::{device::SelectionDevice, seat_data::SeatData}, }, }; @@ -327,12 +326,10 @@ mod handlers { PrimaryDeviceManagerGlobalData, device::PrimaryDeviceUserData, source::PrimarySourceUserData, }; - impl GlobalDispatch2 for PrimaryDeviceManagerGlobalData + impl GlobalDispatch for PrimaryDeviceManagerGlobalData where - D: Dispatch, - D: Dispatch, - D: Dispatch, D: PrimarySelectionHandler, + ::KeyboardFocus: WaylandFocus, D: 'static, { fn bind( @@ -351,12 +348,11 @@ mod handlers { } } - impl Dispatch2 for GlobalData + impl Dispatch for GlobalData where - D: Dispatch, - D: Dispatch, D: PrimarySelectionHandler, D: SeatHandler, + ::KeyboardFocus: WaylandFocus, D: 'static, { fn request( diff --git a/src/wayland/selection/primary_selection/source.rs b/src/wayland/selection/primary_selection/source.rs index cb0fbcbd770f..44e2c951ab62 100644 --- a/src/wayland/selection/primary_selection/source.rs +++ b/src/wayland/selection/primary_selection/source.rs @@ -3,14 +3,11 @@ use std::{cell::RefCell, sync::Mutex}; use wayland_protocols::wp::primary_selection::zv1::server::zwp_primary_selection_source_v1::{ self as primary_source, ZwpPrimarySelectionSourceV1 as PrimarySource, }; -use wayland_server::{DisplayHandle, backend::ClientId}; +use wayland_server::{Dispatch, DisplayHandle, backend::ClientId}; use crate::{ input::Seat, - wayland::{ - Dispatch2, - selection::{offer::OfferReplySource, seat_data::SeatData, source::SelectionSourceProvider}, - }, + wayland::selection::{offer::OfferReplySource, seat_data::SeatData, source::SelectionSourceProvider}, }; use super::PrimarySelectionHandler; @@ -38,7 +35,7 @@ impl PrimarySourceUserData { } } -impl Dispatch2 for PrimarySourceUserData +impl Dispatch for PrimarySourceUserData where D: PrimarySelectionHandler, D: 'static, diff --git a/src/wayland/selection/wlr_data_control/device.rs b/src/wayland/selection/wlr_data_control/device.rs index 6048dd19b9f9..eb91fd69fb09 100644 --- a/src/wayland/selection/wlr_data_control/device.rs +++ b/src/wayland/selection/wlr_data_control/device.rs @@ -5,10 +5,9 @@ use wayland_protocols_wlr::data_control::v1::server::zwlr_data_control_device_v1 self, ZwlrDataControlDeviceV1, }; use wayland_server::protocol::wl_seat::WlSeat; -use wayland_server::{Client, DisplayHandle, Resource}; +use wayland_server::{Client, Dispatch, DisplayHandle, Resource}; use crate::input::Seat; -use crate::wayland::Dispatch2; use crate::wayland::selection::device::SelectionDevice; use crate::wayland::selection::offer::OfferReplySource; use crate::wayland::selection::seat_data::SeatData; @@ -24,7 +23,7 @@ pub struct DataControlDeviceUserData { pub(crate) wl_seat: WlSeat, } -impl Dispatch2 for DataControlDeviceUserData +impl Dispatch for DataControlDeviceUserData where D: DataControlHandler, D: 'static, diff --git a/src/wayland/selection/wlr_data_control/mod.rs b/src/wayland/selection/wlr_data_control/mod.rs index dd0574c6a9ee..3c64e1f2d893 100644 --- a/src/wayland/selection/wlr_data_control/mod.rs +++ b/src/wayland/selection/wlr_data_control/mod.rs @@ -61,7 +61,7 @@ use wayland_protocols_wlr::data_control::v1::server::zwlr_data_control_manager_v use wayland_protocols_wlr::data_control::v1::server::zwlr_data_control_source_v1::ZwlrDataControlSourceV1; use wayland_server::backend::GlobalId; use wayland_server::protocol::wl_seat::WlSeat; -use wayland_server::{Client, DisplayHandle, GlobalDispatch}; +use wayland_server::{Client, DisplayHandle}; mod device; mod source; @@ -99,7 +99,7 @@ impl DataControlState { filter: F, ) -> Self where - D: GlobalDispatch + 'static, + D: DataControlHandler + 'static, F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, { let data = DataControlManagerGlobalData { @@ -144,17 +144,16 @@ mod handlers { use std::sync::Arc; use tracing::error; - use wayland_protocols_wlr::data_control::v1::server::zwlr_data_control_device_v1::ZwlrDataControlDeviceV1; + use wayland_protocols_wlr::data_control::v1::server::zwlr_data_control_manager_v1; use wayland_protocols_wlr::data_control::v1::server::zwlr_data_control_manager_v1::ZwlrDataControlManagerV1; - use wayland_protocols_wlr::data_control::v1::server::zwlr_data_control_source_v1::ZwlrDataControlSourceV1; - use wayland_server::{Client, Dispatch, DisplayHandle}; + + use wayland_server::{Client, Dispatch, DisplayHandle, GlobalDispatch}; use crate::input::Seat; use crate::wayland::selection::SelectionTarget; use crate::wayland::selection::device::SelectionDevice; use crate::wayland::selection::seat_data::SeatData; - use crate::wayland::{Dispatch2, GlobalDispatch2}; use super::DataControlDeviceUserData; use super::DataControlHandler; @@ -162,11 +161,8 @@ mod handlers { use super::DataControlManagerUserData; use super::DataControlSourceUserData; - impl GlobalDispatch2 for DataControlManagerGlobalData + impl GlobalDispatch for DataControlManagerGlobalData where - D: Dispatch, - D: Dispatch, - D: Dispatch, D: DataControlHandler, D: 'static, { @@ -191,10 +187,8 @@ mod handlers { } } - impl Dispatch2 for DataControlManagerUserData + impl Dispatch for DataControlManagerUserData where - D: Dispatch, - D: Dispatch, D: DataControlHandler, D: 'static, { diff --git a/src/wayland/selection/wlr_data_control/source.rs b/src/wayland/selection/wlr_data_control/source.rs index b9fbeb0fb207..530a227cca5f 100644 --- a/src/wayland/selection/wlr_data_control/source.rs +++ b/src/wayland/selection/wlr_data_control/source.rs @@ -4,11 +4,10 @@ use std::sync::Mutex; use wayland_protocols_wlr::data_control::v1::server::zwlr_data_control_source_v1::{ self, ZwlrDataControlSourceV1, }; -use wayland_server::DisplayHandle; use wayland_server::backend::ClientId; +use wayland_server::{Dispatch, DisplayHandle}; use crate::input::Seat; -use crate::wayland::Dispatch2; use crate::wayland::selection::SelectionTarget; use crate::wayland::selection::offer::OfferReplySource; use crate::wayland::selection::seat_data::SeatData; @@ -39,7 +38,7 @@ pub struct SourceMetadata { pub mime_types: Vec, } -impl Dispatch2 for DataControlSourceUserData +impl Dispatch for DataControlSourceUserData where D: DataControlHandler, D: 'static, 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..7bac325f5336 100644 --- a/src/wayland/session_lock/surface.rs +++ b/src/wayland/session_lock/surface.rs @@ -10,9 +10,8 @@ use _session_lock::ext_session_lock_surface_v1::{Error, ExtSessionLockSurfaceV1, use tracing::trace_span; use wayland_protocols::ext::session_lock::v1::server::{self as _session_lock, ext_session_lock_surface_v1}; use wayland_server::protocol::wl_surface::WlSurface; -use wayland_server::{Client, DataInit, DisplayHandle, Resource, Weak}; +use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, Resource, Weak}; -use crate::wayland::Dispatch2; use crate::wayland::session_lock::SessionLockHandler; /// User data for ext-session-lock surfaces. @@ -24,7 +23,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..365376ef3207 100644 --- a/src/wayland/shell/kde/decoration.rs +++ b/src/wayland/shell/kde/decoration.rs @@ -38,9 +38,7 @@ use wayland_protocols_misc::server_decoration::server::org_kde_kwin_server_decor }; use wayland_server::backend::GlobalId; use wayland_server::protocol::wl_surface::WlSurface; -use wayland_server::{Client, Dispatch, DisplayHandle, GlobalDispatch, WEnum}; - -use crate::wayland::GlobalData; +use wayland_server::{Client, DisplayHandle}; /// KDE server decoration handler. pub trait KdeDecorationHandler { @@ -61,15 +59,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 +89,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 +99,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..87c308efb911 100644 --- a/src/wayland/shell/wlr_layer/mod.rs +++ b/src/wayland/shell/wlr_layer/mod.rs @@ -51,7 +51,7 @@ use wayland_protocols_wlr::layer_shell::v1::server::{ zwlr_layer_shell_v1::ZwlrLayerShellV1, zwlr_layer_surface_v1, }; use wayland_server::{ - Client, DisplayHandle, GlobalDispatch, Resource as _, + Client, DisplayHandle, Resource as _, backend::GlobalId, protocol::{wl_output::WlOutput, wl_surface}, }; @@ -216,8 +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 481606d05336..b08bd1284333 100644 --- a/src/wayland/shell/xdg/decoration.rs +++ b/src/wayland/shell/xdg/decoration.rs @@ -97,11 +97,11 @@ use wayland_protocols::xdg::decoration::zv1::server::{ zxdg_toplevel_decoration_v1::{self, Mode}, }; use wayland_server::{ - Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, WEnum, backend::GlobalId, + Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, backend::GlobalId, }; use super::{ToplevelSurface, XdgShellHandler}; -use crate::wayland::{Dispatch2, GlobalData, GlobalDispatch2, shell::xdg::XdgShellSurfaceUserData}; +use crate::wayland::{GlobalData, shell::xdg::XdgShellSurfaceUserData}; /// Delegate type for handling xdg decoration events. #[derive(Debug)] @@ -121,11 +121,7 @@ impl XdgDecorationState { /// A global id is also returned to allow destroying the global in the future. pub fn new(display: &DisplayHandle) -> XdgDecorationState where - D: GlobalDispatch< - zxdg_decoration_manager_v1::ZxdgDecorationManagerV1, - XdgDecorationManagerGlobalData, - > + Dispatch - + 'static, + D: XdgDecorationHandler + 'static, { Self::new_with_filter::(display, |_| true) } @@ -137,11 +133,7 @@ impl XdgDecorationState { /// A global id is also returned to allow destroying the global in the future. pub fn new_with_filter(display: &DisplayHandle, filter: F) -> XdgDecorationState where - D: GlobalDispatch< - zxdg_decoration_manager_v1::ZxdgDecorationManagerV1, - XdgDecorationManagerGlobalData, - > + Dispatch - + 'static, + D: XdgDecorationHandler + 'static, F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, { let data = XdgDecorationManagerGlobalData { @@ -160,7 +152,7 @@ impl XdgDecorationState { } /// Handler trait for xdg decoration events. -pub trait XdgDecorationHandler { +pub trait XdgDecorationHandler: XdgShellHandler { /// Notification the client supports server side decoration on the toplevel. fn new_decoration(&mut self, toplevel: ToplevelSurface); @@ -178,14 +170,10 @@ pub(super) fn send_decoration_configure( id.configure(mode) } -impl GlobalDispatch2 +impl GlobalDispatch for XdgDecorationManagerGlobalData where - D: Dispatch - + Dispatch - + XdgShellHandler - + XdgDecorationHandler - + 'static, + D: XdgDecorationHandler + 'static, { fn bind( &self, @@ -203,12 +191,9 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch - + XdgShellHandler - + XdgDecorationHandler - + 'static, + D: XdgDecorationHandler + 'static, { fn request( &self, @@ -261,7 +246,7 @@ where // zxdg_toplevel_decoration_v1 -impl Dispatch2 for ToplevelSurface +impl Dispatch for ToplevelSurface where D: XdgDecorationHandler, { @@ -278,9 +263,7 @@ where match request { Request::SetMode { mode } => { - if let WEnum::Value(mode) = mode { - state.request_mode(self.clone(), mode); - } + state.request_mode(self.clone(), mode); } Request::UnsetMode => { diff --git a/src/wayland/shell/xdg/dialog.rs b/src/wayland/shell/xdg/dialog.rs index 6f0205a5849d..515de130b0b7 100644 --- a/src/wayland/shell/xdg/dialog.rs +++ b/src/wayland/shell/xdg/dialog.rs @@ -90,7 +90,7 @@ use wayland_server::{ use super::{ToplevelSurface, XdgShellHandler}; use crate::wayland::{ - Dispatch2, GlobalData, GlobalDispatch2, compositor, + GlobalData, compositor, shell::xdg::{XdgShellSurfaceUserData, XdgToplevelSurfaceData}, }; @@ -106,7 +106,7 @@ impl XdgDialogState { /// A global id is also returned to allow destroying the global in the future. pub fn new(display: &DisplayHandle) -> XdgDialogState where - D: GlobalDispatch + Dispatch + 'static, + D: XdgDialogHandler + 'static, { let global = display.create_global::(1, GlobalData); XdgDialogState { global } @@ -129,10 +129,7 @@ pub trait XdgDialogHandler: XdgShellHandler { // xdg_wm_dialog_v1 -impl GlobalDispatch2 for GlobalData -where - D: Dispatch, -{ +impl GlobalDispatch for GlobalData { fn bind( &self, _: &mut D, @@ -145,10 +142,7 @@ where } } -impl Dispatch2 for GlobalData -where - D: Dispatch, -{ +impl Dispatch for GlobalData { fn request( &self, state: &mut D, @@ -194,7 +188,7 @@ where // xdg_dialog_v1 -impl Dispatch2 for ToplevelSurface { +impl Dispatch for ToplevelSurface { fn request( &self, state: &mut D, diff --git a/src/wayland/shell/xdg/handlers/positioner.rs b/src/wayland/shell/xdg/handlers/positioner.rs index b8cfa10cbb1d..e54a8eb7f8bc 100644 --- a/src/wayland/shell/xdg/handlers/positioner.rs +++ b/src/wayland/shell/xdg/handlers/positioner.rs @@ -1,10 +1,10 @@ use std::sync::Mutex; -use crate::{utils::Rectangle, utils::Serial, wayland::Dispatch2}; +use crate::{utils::Rectangle, utils::Serial}; use wayland_protocols::xdg::shell::server::{xdg_positioner, xdg_positioner::XdgPositioner}; -use wayland_server::{DataInit, DisplayHandle, Resource, WEnum}; +use wayland_server::{DataInit, Dispatch, DisplayHandle, Resource}; use super::{PositionerState, XdgShellHandler}; @@ -18,7 +18,7 @@ pub struct XdgPositionerUserData { pub(crate) inner: Mutex, } -impl Dispatch2 for XdgPositionerUserData +impl Dispatch for XdgPositionerUserData where D: XdgShellHandler, D: 'static, @@ -55,21 +55,15 @@ where } } xdg_positioner::Request::SetAnchor { anchor } => { - if let WEnum::Value(anchor) = anchor { - state.anchor_edges = anchor; - } + state.anchor_edges = anchor; } xdg_positioner::Request::SetGravity { gravity } => { - if let WEnum::Value(gravity) = gravity { - state.gravity = gravity; - } + state.gravity = gravity; } xdg_positioner::Request::SetConstraintAdjustment { constraint_adjustment, } => { - if let WEnum::Value(constraint_adjustment) = constraint_adjustment { - state.constraint_adjustment = constraint_adjustment; - } + state.constraint_adjustment = constraint_adjustment; } xdg_positioner::Request::SetOffset { x, y } => { state.offset = (x, y).into(); diff --git a/src/wayland/shell/xdg/handlers/surface.rs b/src/wayland/shell/xdg/handlers/surface.rs index f046222dd918..bdafe5c81285 100644 --- a/src/wayland/shell/xdg/handlers/surface.rs +++ b/src/wayland/shell/xdg/handlers/surface.rs @@ -9,7 +9,7 @@ use crate::wayland::shell::xdg::{XdgPopupSurfaceData, XdgToplevelSurfaceData}; use crate::{ utils::{Rectangle, Serial}, wayland::{ - Dispatch2, compositor, + compositor, shell::xdg::{PopupState, XDG_POPUP_ROLE, XDG_TOPLEVEL_ROLE}, }, }; @@ -45,10 +45,8 @@ pub struct XdgSurfaceUserData { pub(crate) has_active_role: AtomicBool, } -impl Dispatch2 for XdgSurfaceUserData +impl Dispatch for XdgSurfaceUserData where - D: Dispatch, - D: Dispatch, D: XdgShellHandler, D: 'static, { diff --git a/src/wayland/shell/xdg/handlers/surface/popup.rs b/src/wayland/shell/xdg/handlers/surface/popup.rs index eb2cb5566e1d..6f46f9ece293 100644 --- a/src/wayland/shell/xdg/handlers/surface/popup.rs +++ b/src/wayland/shell/xdg/handlers/surface/popup.rs @@ -3,7 +3,6 @@ use std::sync::atomic::Ordering; use crate::{ utils::Serial, wayland::{ - Dispatch2, compositor::{self, with_states}, shell::xdg::{PopupCachedState, SurfaceCachedState, XdgPopupSurfaceData, XdgPositionerUserData}, }, @@ -11,11 +10,11 @@ use crate::{ use wayland_protocols::xdg::shell::server::xdg_popup::{self, XdgPopup}; -use wayland_server::{DataInit, DisplayHandle, Resource, backend::ClientId}; +use wayland_server::{DataInit, Dispatch, DisplayHandle, Resource, backend::ClientId}; use super::{PopupConfigure, XdgShellHandler, XdgShellSurfaceUserData, XdgSurfaceUserData}; -impl Dispatch2 for XdgShellSurfaceUserData +impl Dispatch for XdgShellSurfaceUserData where D: XdgShellHandler, D: 'static, diff --git a/src/wayland/shell/xdg/handlers/surface/toplevel.rs b/src/wayland/shell/xdg/handlers/surface/toplevel.rs index 41576b119fc2..1a9ff2877342 100644 --- a/src/wayland/shell/xdg/handlers/surface/toplevel.rs +++ b/src/wayland/shell/xdg/handlers/surface/toplevel.rs @@ -3,7 +3,7 @@ use std::sync::atomic::Ordering; use crate::{ utils::Serial, wayland::{ - Dispatch2, compositor, + compositor, shell::{ is_valid_parent, xdg::{ToplevelCachedState, XdgToplevelSurfaceData}, @@ -16,14 +16,14 @@ use wayland_protocols::xdg::{ shell::server::xdg_toplevel::{self, XdgToplevel}, }; -use wayland_server::{DataInit, DisplayHandle, Resource, WEnum, backend::ClientId, protocol::wl_surface}; +use wayland_server::{DataInit, Dispatch, DisplayHandle, Resource, backend::ClientId, protocol::wl_surface}; use super::{ SurfaceCachedState, ToplevelConfigure, XdgShellHandler, XdgShellSurfaceUserData, XdgSurfaceUserData, XdgToplevelSurfaceRoleAttributes, }; -impl Dispatch2 for XdgShellSurfaceUserData +impl Dispatch for XdgShellSurfaceUserData where D: XdgShellHandler, D: 'static, @@ -119,13 +119,11 @@ where XdgShellHandler::move_request(state, handle, seat, serial); } xdg_toplevel::Request::Resize { seat, serial, edges } => { - if let WEnum::Value(edges) = edges { - // This has to be handled by the compositor - let handle = make_toplevel_handle(toplevel); - let serial = Serial::from(serial); + // This has to be handled by the compositor + let handle = make_toplevel_handle(toplevel); + let serial = Serial::from(serial); - XdgShellHandler::resize_request(state, handle, seat, serial, edges); - } + XdgShellHandler::resize_request(state, handle, seat, serial, edges); } xdg_toplevel::Request::SetMaxSize { width, height } => { with_toplevel_pending_state(self, |toplevel_data| { diff --git a/src/wayland/shell/xdg/handlers/wm_base.rs b/src/wayland/shell/xdg/handlers/wm_base.rs index 01dd898765f7..6b711a96d895 100644 --- a/src/wayland/shell/xdg/handlers/wm_base.rs +++ b/src/wayland/shell/xdg/handlers/wm_base.rs @@ -4,22 +4,19 @@ use indexmap::IndexSet; use crate::{ utils::{IsAlive, Serial, alive_tracker::AliveTracker}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, + wayland::GlobalData, }; -use wayland_protocols::xdg::shell::server::{ - xdg_positioner::XdgPositioner, xdg_surface, xdg_surface::XdgSurface, xdg_wm_base, xdg_wm_base::XdgWmBase, -}; +use wayland_protocols::xdg::shell::server::{xdg_surface, xdg_wm_base, xdg_wm_base::XdgWmBase}; -use wayland_server::{DataInit, Dispatch, DisplayHandle, New, Resource, Weak, backend::ClientId}; +use wayland_server::{ + DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, Weak, backend::ClientId, +}; use super::{ShellClient, ShellClientData, XdgPositionerUserData, XdgShellHandler, XdgSurfaceUserData}; -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, - D: Dispatch, - D: Dispatch, D: XdgShellHandler, D: 'static, { @@ -37,10 +34,8 @@ where } } -impl Dispatch2 for XdgWmBaseUserData +impl Dispatch for XdgWmBaseUserData where - D: Dispatch, - D: Dispatch, D: XdgShellHandler, D: 'static, { diff --git a/src/wayland/shell/xdg/mod.rs b/src/wayland/shell/xdg/mod.rs index d4ca36ab0cbb..136fcd0ff057 100644 --- a/src/wayland/shell/xdg/mod.rs +++ b/src/wayland/shell/xdg/mod.rs @@ -142,7 +142,7 @@ use wayland_protocols::xdg::shell::server::xdg_wm_base::XdgWmBase; use wayland_protocols::xdg::shell::server::{xdg_popup, xdg_positioner, xdg_toplevel, xdg_wm_base}; use wayland_server::backend::GlobalId; use wayland_server::{ - DisplayHandle, GlobalDispatch, Resource, + DisplayHandle, Resource, protocol::{wl_output, wl_seat, wl_surface}, }; @@ -952,7 +952,7 @@ impl ToplevelStateSet { } fn version_needed_for_state(state: &xdg_toplevel::State) -> u32 { - match state { + match *state { xdg_toplevel::State::TiledLeft | xdg_toplevel::State::TiledRight | xdg_toplevel::State::TiledTop @@ -1224,7 +1224,7 @@ impl XdgShellState { /// Create a new `xdg_shell` global with all [`WmCapabilities`](xdg_toplevel::WmCapabilities) pub fn new(display: &DisplayHandle) -> XdgShellState where - D: GlobalDispatch + 'static, + D: XdgShellHandler + 'static, { Self::new_with_capabilities::( display, @@ -1243,7 +1243,7 @@ impl XdgShellState { capabilities: impl Into, ) -> XdgShellState where - D: GlobalDispatch + 'static, + D: XdgShellHandler + 'static, { let global = display.create_global::(7, GlobalData); diff --git a/src/wayland/shm/handlers.rs b/src/wayland/shm/handlers.rs index 7de3c66c3c9d..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..0d175346bce6 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, + DisplayHandle, 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..66c658d9c72a 100644 --- a/src/wayland/single_pixel_buffer/mod.rs +++ b/src/wayland/single_pixel_buffer/mod.rs @@ -46,11 +46,9 @@ //! ``` use wayland_protocols::wp::single_pixel_buffer::v1::server::wp_single_pixel_buffer_manager_v1::WpSinglePixelBufferManagerV1; -use wayland_server::{ - Dispatch, DisplayHandle, GlobalDispatch, Resource, backend::GlobalId, protocol::wl_buffer::WlBuffer, -}; +use wayland_server::{DisplayHandle, Resource, backend::GlobalId, protocol::wl_buffer::WlBuffer}; -use crate::wayland::GlobalData; +use crate::wayland::{GlobalData, buffer::BufferHandler}; mod handlers; @@ -67,9 +65,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..a6976ebe0aac 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,8 +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 { /// Get tablet seat associated with this seat @@ -141,11 +134,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 +147,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 +163,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..31fe1f98bb13 100644 --- a/src/wayland/tablet_manager/tablet_tool.rs +++ b/src/wayland/tablet_manager/tablet_tool.rs @@ -5,7 +5,6 @@ use std::sync::{Arc, Mutex}; use crate::backend::input::{ButtonState, TabletToolCapabilities, TabletToolDescriptor, TabletToolType}; use crate::input::pointer::{CursorImageAttributes, CursorImageStatus}; use crate::utils::{Client as ClientCoords, Logical, Point}; -use crate::wayland::compositor::CompositorHandler; use crate::wayland::seat::CURSOR_IMAGE_ROLE; use atomic_float::AtomicF64; use wayland_protocols::wp::tablet::zv2::server::{ @@ -16,10 +15,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 +254,7 @@ impl TabletToolHandle { seat: &ZwpTabletSeatV2, tool: &TabletToolDescriptor, ) where - D: Dispatch, D: TabletSeatHandler + 'static, - D: CompositorHandler, { let desc = tool.clone(); @@ -470,7 +464,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..61d781712f70 100644 --- a/src/wayland/text_input/mod.rs +++ b/src/wayland/text_input/mod.rs @@ -44,15 +44,14 @@ //! ``` //! -use wayland_protocols::wp::text_input::zv3::server::{ - zwp_text_input_manager_v3::{self, ZwpTextInputManagerV3}, - zwp_text_input_v3::ZwpTextInputV3, +use wayland_protocols::wp::text_input::zv3::server::zwp_text_input_manager_v3::{ + self, ZwpTextInputManagerV3, }; use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, backend::GlobalId}; use crate::{ input::{Seat, SeatHandler}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, + wayland::GlobalData, }; pub use text_input_handle::TextInputHandle; @@ -88,10 +87,7 @@ impl TextInputManagerState { /// Initialize a text input manager global. pub fn new(display: &DisplayHandle) -> Self where - D: GlobalDispatch, - D: Dispatch, - D: Dispatch, - D: 'static, + D: SeatHandler + 'static, { let global = display.create_global::(MANAGER_VERSION, GlobalData); @@ -104,11 +100,9 @@ impl TextInputManagerState { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, - D: Dispatch, - D: 'static, + D: SeatHandler + 'static, { fn bind( &self, @@ -122,11 +116,9 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, - D: SeatHandler, - D: 'static, + D: SeatHandler + 'static, { fn request( &self, diff --git a/src/wayland/text_input/text_input_handle.rs b/src/wayland/text_input/text_input_handle.rs index 2525301045ed..627d6944b30e 100644 --- a/src/wayland/text_input/text_input_handle.rs +++ b/src/wayland/text_input/text_input_handle.rs @@ -6,11 +6,11 @@ use wayland_protocols::wp::text_input::zv3::server::zwp_text_input_v3::{ self, ChangeCause, ContentHint, ContentPurpose, ZwpTextInputV3, }; use wayland_server::backend::{ClientId, ObjectId}; -use wayland_server::{Resource, protocol::wl_surface::WlSurface}; +use wayland_server::{Dispatch, Resource, protocol::wl_surface::WlSurface}; use crate::input::SeatHandler; use crate::utils::{Logical, Rectangle}; -use crate::wayland::{Dispatch2, input_method::InputMethodHandle}; +use crate::wayland::input_method::InputMethodHandle; #[derive(Default, Debug)] pub(crate) struct TextInput { @@ -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, @@ -244,15 +244,19 @@ where zwp_text_input_v3::Request::SetSurroundingText { text, cursor, anchor } => { pending_state.surrounding_text = Some((text, cursor as u32, anchor as u32)); } - zwp_text_input_v3::Request::SetTextChangeCause { cause } => { + zwp_text_input_v3::Request::SetTextChangeCause { mut cause } => { // Guard against clients sending us unknown values from future versions. - let cause = cause.into_result().unwrap_or(ChangeCause::Other); + if cause.available_since().is_some_and(|v| v > resource.version()) { + cause = ChangeCause::Other; + } pending_state.text_change_cause = Some(cause); } - zwp_text_input_v3::Request::SetContentType { hint, purpose } => { + zwp_text_input_v3::Request::SetContentType { hint, mut purpose } => { // Guard against clients sending us unknown values from future versions. let hint = ContentHint::from_bits_truncate(u32::from(hint)); - let purpose = purpose.into_result().unwrap_or(ContentPurpose::Normal); + if purpose.available_since().is_some_and(|v| v > resource.version()) { + purpose = ContentPurpose::Normal; + } pending_state.content_type = Some((hint, purpose)); } zwp_text_input_v3::Request::SetCursorRectangle { x, y, width, height } => { 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..12d01446b668 100644 --- a/src/wayland/virtual_keyboard/mod.rs +++ b/src/wayland/virtual_keyboard/mod.rs @@ -44,15 +44,14 @@ //! ``` //! -use wayland_protocols_misc::zwp_virtual_keyboard_v1::server::{ - zwp_virtual_keyboard_manager_v1::{self, ZwpVirtualKeyboardManagerV1}, - zwp_virtual_keyboard_v1::ZwpVirtualKeyboardV1, +use wayland_protocols_misc::zwp_virtual_keyboard_v1::server::zwp_virtual_keyboard_manager_v1::{ + self, ZwpVirtualKeyboardManagerV1, }; use wayland_server::{Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, backend::GlobalId}; use crate::{ input::{Seat, SeatHandler}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, + wayland::{GlobalData, seat::WaylandFocus}, }; use self::virtual_keyboard_handle::VirtualKeyboardHandle; @@ -77,7 +76,8 @@ pub struct VirtualKeyboardManagerGlobalData { fn create_global_with_filter(display: &DisplayHandle, filter: F) -> GlobalId where - D: GlobalDispatch + 'static, + D: SeatHandler + 'static, + ::KeyboardFocus: WaylandFocus, F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, { let data = VirtualKeyboardManagerGlobalData { @@ -91,11 +91,8 @@ impl VirtualKeyboardManagerState { /// Initialize a virtual keyboard manager global. pub fn new(display: &DisplayHandle, filter: F) -> Self where - D: GlobalDispatch, - D: Dispatch, - D: Dispatch>, - D: SeatHandler, - D: 'static, + D: SeatHandler + 'static, + ::KeyboardFocus: WaylandFocus, F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, { let global = create_global_with_filter::(display, filter); @@ -109,12 +106,10 @@ impl VirtualKeyboardManagerState { } } -impl GlobalDispatch2 for VirtualKeyboardManagerGlobalData +impl GlobalDispatch for VirtualKeyboardManagerGlobalData where - D: Dispatch, - D: Dispatch>, - D: SeatHandler, - D: 'static, + D: SeatHandler + 'static, + ::KeyboardFocus: WaylandFocus, { fn bind( &self, @@ -132,11 +127,10 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch>, - D: SeatHandler, - D: 'static, + D: SeatHandler + 'static, + ::KeyboardFocus: WaylandFocus, { fn request( &self, diff --git a/src/wayland/virtual_keyboard/virtual_keyboard_handle.rs b/src/wayland/virtual_keyboard/virtual_keyboard_handle.rs index 40e3ee45d8c2..dda43d1386db 100644 --- a/src/wayland/virtual_keyboard/virtual_keyboard_handle.rs +++ b/src/wayland/virtual_keyboard/virtual_keyboard_handle.rs @@ -5,12 +5,11 @@ use std::{ }; use tracing::debug; -use wayland_protocols_misc::zwp_virtual_keyboard_v1::server::zwp_virtual_keyboard_v1::Error::NoKeymap; use wayland_protocols_misc::zwp_virtual_keyboard_v1::server::zwp_virtual_keyboard_v1::{ self, ZwpVirtualKeyboardV1, }; use wayland_server::{ - Client, DataInit, DisplayHandle, Resource, + Client, DataInit, Dispatch, DisplayHandle, Resource, protocol::wl_keyboard::{KeyState, KeymapFormat}, }; use xkbcommon::xkb; @@ -19,10 +18,7 @@ use crate::input::keyboard::{KeyboardTarget, KeymapFile, ModifiersState}; use crate::{ input::{Seat, SeatHandler}, utils::SERIAL_COUNTER, - wayland::{ - Dispatch2, - seat::{WaylandFocus, keyboard::for_each_focused_kbds}, - }, + wayland::seat::{WaylandFocus, keyboard::for_each_focused_kbds}, }; #[derive(Debug, Default)] @@ -71,7 +67,7 @@ impl fmt::Debug for VirtualKeyboardUserData { } } -impl Dispatch2 for VirtualKeyboardUserData +impl Dispatch for VirtualKeyboardUserData where D: SeatHandler + 'static, ::KeyboardFocus: WaylandFocus, @@ -95,7 +91,10 @@ where let vk_state = match virtual_data.state.as_mut() { Some(vk_state) => vk_state, None => { - virtual_keyboard.post_error(NoKeymap, "`key` sent before keymap."); + virtual_keyboard.post_error( + zwp_virtual_keyboard_v1::Error::NoKeymap, + "`key` sent before keymap.", + ); return; } }; @@ -131,7 +130,10 @@ where let state = match virtual_data.state.as_mut() { Some(state) => state, None => { - virtual_keyboard.post_error(NoKeymap, "`modifiers` sent before keymap."); + virtual_keyboard.post_error( + zwp_virtual_keyboard_v1::Error::NoKeymap, + "`modifiers` sent before keymap.", + ); return; } }; @@ -172,7 +174,7 @@ where D: SeatHandler + 'static, { // Only libxkbcommon compatible keymaps are supported. - if format != KeymapFormat::XkbV1 as u32 { + if format != u32::from(KeymapFormat::XkbV1) { debug!("Unsupported keymap format: {format:?}"); return; } diff --git a/src/wayland/xdg_activation/dispatch.rs b/src/wayland/xdg_activation/dispatch.rs index b9680590a41c..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..9f067cd873f9 100644 --- a/src/wayland/xdg_activation/mod.rs +++ b/src/wayland/xdg_activation/mod.rs @@ -52,7 +52,7 @@ use std::{ use wayland_protocols::xdg::activation::v1::server::xdg_activation_v1; use wayland_server::{ - Dispatch, DisplayHandle, GlobalDispatch, + DisplayHandle, backend::{ClientId, GlobalId}, protocol::{wl_seat::WlSeat, wl_surface::WlSurface}, }; @@ -179,10 +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 4e12c4377979..1158408b9357 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 adaf4da83f11..92974db4bc0b 100644 --- a/src/wayland/xwayland_keyboard_grab.rs +++ b/src/wayland/xwayland_keyboard_grab.rs @@ -58,7 +58,7 @@ use crate::{ keyboard::{self, KeyboardGrab, KeyboardInnerHandle}, }, utils::{SERIAL_COUNTER, Serial}, - wayland::{Dispatch2, GlobalData, GlobalDispatch2}, + wayland::GlobalData, xwayland::XWaylandClientData, }; @@ -159,9 +159,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 = @@ -176,9 +174,9 @@ impl XWaylandKeyboardGrabState { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch + 'static, + D: XWaylandKeyboardGrabHandler + 'static, { fn bind( &self, @@ -196,10 +194,9 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch + 'static, - D: XWaylandKeyboardGrabHandler, + D: XWaylandKeyboardGrabHandler + 'static, { fn request( &self, @@ -228,7 +225,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 19411ee67e91..502587d44656 100644 --- a/src/wayland/xwayland_shell.rs +++ b/src/wayland/xwayland_shell.rs @@ -139,7 +139,7 @@ use wayland_server::{ use crate::{ input::SeatHandler, - wayland::{Dispatch2, GlobalData, GlobalDispatch2, compositor}, + wayland::{GlobalData, compositor}, xwayland::{X11Surface, XWaylandClientData, XwmHandler, xwm::XwmId}, }; @@ -160,9 +160,7 @@ impl XWaylandShellState { /// able to bind it. pub fn new(display: &DisplayHandle) -> Self where - D: GlobalDispatch, - D: Dispatch, - D: Dispatch, + D: XWaylandShellHandler, D: 'static, { let global = display.create_global::(VERSION, GlobalData); @@ -190,7 +188,7 @@ pub struct XWaylandSurfaceUserData { } /// Handler for the xwayland shell protocol. -pub trait XWaylandShellHandler { +pub trait XWaylandShellHandler: XwmHandler + SeatHandler { /// Retrieves the global state. fn xwayland_shell_state(&mut self) -> &mut XWaylandShellState; @@ -219,9 +217,9 @@ impl compositor::Cacheable for XWaylandShellCachedState { } } -impl GlobalDispatch2 for GlobalData +impl GlobalDispatch for GlobalData where - D: Dispatch, + D: XWaylandShellHandler, D: 'static, { fn bind( @@ -240,10 +238,9 @@ where } } -impl Dispatch2 for GlobalData +impl Dispatch for GlobalData where - D: Dispatch, - D: XWaylandShellHandler + XwmHandler + SeatHandler, + D: XWaylandShellHandler, D: 'static, { fn request( @@ -275,11 +272,10 @@ where } } -impl Dispatch2 for XWaylandSurfaceUserData +impl Dispatch for XWaylandSurfaceUserData where D: XWaylandShellHandler, D: 'static, - D: XwmHandler, { fn request( &self, @@ -313,7 +309,7 @@ where } } -fn serial_commit_hook( +fn serial_commit_hook( state: &mut D, _dh: &DisplayHandle, surface: &WlSurface,