diff --git a/anvil/src/state.rs b/anvil/src/state.rs index 62b868d23a46..1ea5371f5bf4 100644 --- a/anvil/src/state.rs +++ b/anvil/src/state.rs @@ -64,7 +64,9 @@ use smithay::{ KeyboardShortcutsInhibitHandler, KeyboardShortcutsInhibitState, KeyboardShortcutsInhibitor, }, output::{OutputHandler, OutputManagerState}, - pointer_constraints::{PointerConstraintsHandler, PointerConstraintsState, with_pointer_constraint}, + pointer_constraints::{ + PointerConstraint, PointerConstraintsHandler, PointerConstraintsState, with_pointer_constraint, + }, pointer_gestures::PointerGesturesState, presentation::PresentationState, relative_pointer::RelativePointerManagerState, @@ -380,23 +382,26 @@ impl PointerConstraintsHandler for AnvilState } } - fn remove_constraint(&mut self, surface: &WlSurface, pointer: &PointerHandle) { - if with_pointer_constraint(surface, pointer, |constraint| constraint.is_none()) { - if let Some((hint_surface, hint_location)) = &self.cursor_position_hint { - let origin = self - .space - .elements() - .find_map(|window| { - (window.wl_surface().as_deref() == Some(hint_surface)).then(|| window.geometry()) - }) - .unwrap_or_default() - .loc - .to_f64(); - - pointer.set_location(origin + *hint_location); - } - self.cursor_position_hint = None; + fn remove_constraint( + &mut self, + _surface: &WlSurface, + pointer: &PointerHandle, + _constraint: Option<&PointerConstraint>, + ) { + if let Some((hint_surface, hint_location)) = &self.cursor_position_hint { + let origin = self + .space + .elements() + .find_map(|window| { + (window.wl_surface().as_deref() == Some(hint_surface)).then(|| window.geometry()) + }) + .unwrap_or_default() + .loc + .to_f64(); + + pointer.set_location(origin + *hint_location); } + self.cursor_position_hint = None; } fn cursor_position_hint( diff --git a/examples/minimal.rs b/examples/minimal.rs index b8ab4d2e101a..927b95b4bf26 100644 --- a/examples/minimal.rs +++ b/examples/minimal.rs @@ -24,6 +24,7 @@ use smithay::{ CompositorClientState, CompositorHandler, CompositorState, SurfaceAttributes, TraversalAction, with_surface_tree_downward, }, + pointer_constraints::PointerConstraintsHandler, selection::{ SelectionHandler, data_device::{DataDeviceHandler, DataDeviceState, WaylandDndGrabHandler}, @@ -116,6 +117,8 @@ impl SeatHandler for App { fn cursor_image(&mut self, _seat: &Seat, _image: smithay::input::pointer::CursorImageStatus) {} } +impl PointerConstraintsHandler for App {} + struct App { compositor_state: CompositorState, xdg_shell_state: XdgShellState, diff --git a/examples/seat.rs b/examples/seat.rs index 725c2a9066c2..58fb0a38f2c0 100644 --- a/examples/seat.rs +++ b/examples/seat.rs @@ -7,6 +7,7 @@ use smithay::reexports::wayland_server::{ protocol::wl_surface::WlSurface, }; use smithay::wayland::compositor::{CompositorClientState, CompositorHandler, CompositorState}; +use smithay::wayland::pointer_constraints::PointerConstraintsHandler; struct App { compositor_state: CompositorState, @@ -27,6 +28,8 @@ impl SeatHandler for App { fn cursor_image(&mut self, _seat: &Seat, _image: smithay::input::pointer::CursorImageStatus) {} } +impl PointerConstraintsHandler for App {} + fn main() -> Result<(), Box> { let mut display: Display = Display::new()?; let dh = display.handle(); diff --git a/smallvil/src/handlers/mod.rs b/smallvil/src/handlers/mod.rs index 40398eb9f7cf..fafba61e79ff 100644 --- a/smallvil/src/handlers/mod.rs +++ b/smallvil/src/handlers/mod.rs @@ -14,6 +14,7 @@ use smithay::reexports::wayland_server::Resource; use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; use smithay::utils::Serial; use smithay::wayland::output::OutputHandler; +use smithay::wayland::pointer_constraints::PointerConstraintsHandler; use smithay::wayland::selection::SelectionHandler; use smithay::wayland::selection::data_device::{ DataDeviceHandler, DataDeviceState, WaylandDndGrabHandler, set_data_device_focus, @@ -37,6 +38,8 @@ impl SeatHandler for Smallvil { } } +impl PointerConstraintsHandler for Smallvil {} + // // Wl Data Device // diff --git a/src/input/mod.rs b/src/input/mod.rs index bb10fd07f72a..c3902352e503 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -655,6 +655,7 @@ impl Seat { /// /// ```no_run /// # use smithay::wayland::compositor::{CompositorHandler, CompositorState, CompositorClientState}; + /// # use smithay::wayland::pointer_constraints::PointerConstraintsHandler; /// # use smithay::input::{Seat, SeatState, SeatHandler, pointer::CursorImageStatus}; /// # use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; /// # @@ -672,6 +673,7 @@ impl Seat { /// # fn focus_changed(&mut self, seat: &Seat, focused: Option<&WlSurface>) { unimplemented!() } /// # fn cursor_image(&mut self, seat: &Seat, image: CursorImageStatus) { unimplemented!() } /// # } + /// # impl PointerConstraintsHandler for State {} /// # let mut seat: Seat = unimplemented!(); /// let touch_handle = seat.add_touch(); /// ``` diff --git a/src/wayland/idle_notify/mod.rs b/src/wayland/idle_notify/mod.rs index 621f01d4c4fd..f15f6b8db16e 100644 --- a/src/wayland/idle_notify/mod.rs +++ b/src/wayland/idle_notify/mod.rs @@ -7,6 +7,7 @@ //! use smithay::wayland::idle_notify::{IdleNotifierState, IdleNotifierHandler}; //! # use smithay::input::{Seat, SeatHandler, SeatState, pointer::CursorImageStatus}; //! # use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; +//! # use smithay::wayland::pointer_constraints::PointerConstraintsHandler; //! //! struct State { idle_notifier: IdleNotifierState } //! # let mut event_loop = smithay::reexports::calloop::EventLoop::::try_new().unwrap(); @@ -33,6 +34,7 @@ //! # fn focus_changed(&mut self, seat: &Seat, focused: Option<&WlSurface>) { unimplemented!() } //! # fn cursor_image(&mut self, seat: &Seat, image: CursorImageStatus) { unimplemented!() } //! # } +//! # impl PointerConstraintsHandler for State {} //! impl IdleNotifierHandler for State { //! fn idle_notifier_state(&mut self) -> &mut IdleNotifierState { //! &mut self.idle_notifier diff --git a/src/wayland/input_method/mod.rs b/src/wayland/input_method/mod.rs index a9135a37b701..297eebf46e4a 100644 --- a/src/wayland/input_method/mod.rs +++ b/src/wayland/input_method/mod.rs @@ -9,6 +9,7 @@ //! use smithay::wayland::input_method::{InputMethodManagerState, InputMethodHandler, PopupSurface}; //! use smithay::wayland::text_input::TextInputManagerState; //! use smithay::reexports::wayland_server::{Display, protocol::wl_surface::WlSurface}; +//! # use smithay::wayland::pointer_constraints::PointerConstraintsHandler; //! # use smithay::reexports::wayland_server::Client; //! use smithay::utils::{Rectangle, Logical}; //! @@ -41,6 +42,7 @@ //! fn focus_changed(&mut self, seat: &Seat, focused: Option<&WlSurface>) { unimplemented!() } //! fn cursor_image(&mut self, seat: &Seat, image: CursorImageStatus) { unimplemented!() } //! } +//! # impl PointerConstraintsHandler for State {} //! //! # impl CompositorHandler for State { //! # fn compositor_state(&mut self) -> &mut CompositorState { unimplemented!() } diff --git a/src/wayland/keyboard_shortcuts_inhibit/mod.rs b/src/wayland/keyboard_shortcuts_inhibit/mod.rs index 048163f1f00a..92fcf6f0aaab 100644 --- a/src/wayland/keyboard_shortcuts_inhibit/mod.rs +++ b/src/wayland/keyboard_shortcuts_inhibit/mod.rs @@ -185,6 +185,7 @@ pub trait KeyboardShortcutsInhibitorSeat { /// use smithay::wayland::keyboard_shortcuts_inhibit::KeyboardShortcutsInhibitorSeat; /// # use smithay::input::{SeatHandler, SeatState, pointer::CursorImageStatus}; /// # use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; + /// # use smithay::wayland::pointer_constraints::PointerConstraintsHandler; /// # struct State; /// # impl CompositorHandler for State { /// # fn compositor_state(&mut self) -> &mut CompositorState { unimplemented!() } @@ -199,6 +200,7 @@ pub trait KeyboardShortcutsInhibitorSeat { /// # fn focus_changed(&mut self, seat: &Seat, focused: Option<&WlSurface>) { unimplemented!() } /// # fn cursor_image(&mut self, seat: &Seat, image: CursorImageStatus) { unimplemented!() } /// # } + /// # impl PointerConstraintsHandler for State {} /// /// # let wl_surface: WlSurface = todo!(); /// diff --git a/src/wayland/pointer_constraints.rs b/src/wayland/pointer_constraints.rs index f0c1200e6cdd..1a04ef6ca352 100644 --- a/src/wayland/pointer_constraints.rs +++ b/src/wayland/pointer_constraints.rs @@ -35,12 +35,18 @@ pub trait PointerConstraintsHandler: SeatHandler { /// Pointer lock or confinement constraint created for `pointer` on `surface` /// /// Use [`with_pointer_constraint`] to access the constraint. - fn new_constraint(&mut self, surface: &WlSurface, pointer: &PointerHandle); + fn new_constraint(&mut self, _surface: &WlSurface, _pointer: &PointerHandle) {} - /// Constraint removed for `pointer` on `surface` + /// Pointer constraint removed for `pointer` on `surface` /// - /// Use [`with_pointer_constraint`] to access the constraint. - fn remove_constraint(&mut self, surface: &WlSurface, pointer: &PointerHandle); + /// Don't use [`with_pointer_constraint`] to access the constraint + fn remove_constraint( + &mut self, + _surface: &WlSurface, + _pointer: &PointerHandle, + _constraint: Option<&PointerConstraint>, + ) { + } /// The client holding a LockedPointer has committed a cursor position hint. /// @@ -49,10 +55,11 @@ pub trait PointerConstraintsHandler: SeatHandler { /// Use [`with_pointer_constraint`] to access the constraint and check if it is active. fn cursor_position_hint( &mut self, - surface: &WlSurface, - pointer: &PointerHandle, - location: Point, - ); + _surface: &WlSurface, + _pointer: &PointerHandle, + _location: Point, + ) { + } } /// Constraint confining pointer to a region of the surface @@ -121,7 +128,7 @@ impl ops::Deref for PointerConstraintRef<'_, D> { } } -impl PointerConstraintRef<'_, D> { +impl PointerConstraintRef<'_, D> { /// Send `locked`/`unlocked` /// /// This is not sent automatically since compositors may have different @@ -147,7 +154,7 @@ impl PointerConstraintRef<'_, D> { /// /// This is sent automatically when the surface loses pointer focus, but /// may also be invoked while the surface is focused. - pub fn deactivate(self) { + pub fn deactivate(self, state: &mut D, surface: &WlSurface, pointer: &PointerHandle) { let deactivated = match self.entry.get() { PointerConstraint::Confined(confined) => { if confined.active.swap(false, Ordering::SeqCst) { @@ -167,6 +174,11 @@ impl PointerConstraintRef<'_, D> { } }; + if deactivated { + let constraint = self.entry.get(); + state.remove_constraint(surface, pointer, Some(constraint)); + } + if deactivated && self.lifetime() == WEnum::Value(Lifetime::Oneshot) { self.entry.remove_entry(); } @@ -354,17 +366,19 @@ fn remove_constraint( surface: &WlSurface, pointer: &PointerHandle, ) { - let is_removed = with_constraint_data::(surface, |data| { + let (is_removed, constraint) = with_constraint_data::(surface, |data| { if let Some(data) = data { - if let Some(_constraint) = data.constraints.remove(pointer) { - return true; + if let Some(constraint) = data.constraints.remove(pointer) { + return (true, Some(constraint)); } } - false + (false, None) }); if is_removed { - state.remove_constraint(surface, pointer); + if let Some(constraint) = constraint { + state.remove_constraint(surface, pointer, Some(&constraint)); + } } } @@ -476,7 +490,8 @@ where impl Dispatch2 for PointerConstraintUserData where - D: SeatHandler + PointerConstraintsHandler, + D: SeatHandler, + D: PointerConstraintsHandler, D: 'static, { fn request( @@ -523,7 +538,8 @@ where impl Dispatch2 for PointerConstraintUserData where - D: SeatHandler + PointerConstraintsHandler, + D: SeatHandler, + D: PointerConstraintsHandler, D: 'static, { fn request( diff --git a/src/wayland/pointer_warp.rs b/src/wayland/pointer_warp.rs index c3a658c837a9..d3271b892f64 100644 --- a/src/wayland/pointer_warp.rs +++ b/src/wayland/pointer_warp.rs @@ -15,6 +15,7 @@ //! # let mut display = wayland_server::Display::::new().unwrap(); //! # //! # use smithay::wayland::compositor::{CompositorHandler, CompositorState, CompositorClientState}; +//! # use smithay::wayland::pointer_constraints::PointerConstraintsHandler; //! # use smithay::reexports::wayland_server::Client; //! # impl CompositorHandler for State { //! # fn compositor_state(&mut self) -> &mut CompositorState { unimplemented!() } @@ -30,6 +31,7 @@ //! # todo!() //! # } //! # } +//! # impl PointerConstraintsHandler for State {} //! //! PointerWarpManager::new::( //! &display.handle(), diff --git a/src/wayland/seat/mod.rs b/src/wayland/seat/mod.rs index 5ce48d0924a4..6c1bbf78dc37 100644 --- a/src/wayland/seat/mod.rs +++ b/src/wayland/seat/mod.rs @@ -11,6 +11,7 @@ //! use smithay::input::{Seat, SeatState, SeatHandler, pointer::CursorImageStatus}; //! use smithay::reexports::wayland_server::{Display, protocol::wl_surface::WlSurface}; //! # use smithay::wayland::compositor::{CompositorHandler, CompositorState, CompositorClientState}; +//! # use smithay::wayland::pointer_constraints::PointerConstraintsHandler; //! # use smithay::reexports::wayland_server::Client; //! //! # struct State { seat_state: SeatState }; @@ -42,6 +43,7 @@ //! // ... //! } //! } +//! # impl PointerConstraintsHandler for State {} //! //! smithay::delegate_dispatch2!(State); //! diff --git a/src/wayland/seat/pointer.rs b/src/wayland/seat/pointer.rs index 1a0ae20f88f1..81ef92c97752 100644 --- a/src/wayland/seat/pointer.rs +++ b/src/wayland/seat/pointer.rs @@ -25,7 +25,10 @@ use crate::{ }, }, utils::{Client as ClientCoords, Point, Serial, iter::new_locked_obj_iter_from_vec}, - wayland::{Dispatch2, compositor, pointer_constraints::with_pointer_constraint}, + wayland::{ + Dispatch2, compositor, + pointer_constraints::{PointerConstraintsHandler, with_pointer_constraint}, + }, }; use super::{SeatHandler, WaylandFocus}; @@ -235,7 +238,9 @@ impl WlPointerHandle { impl PointerTarget for WlSurface where - D: SeatHandler + 'static, + D: SeatHandler, + D: PointerConstraintsHandler, + D: 'static, { fn enter(&self, seat: &Seat, _data: &mut D, event: &MotionEvent) { if let Some(pointer) = seat.get_pointer() { @@ -243,14 +248,14 @@ where } } - fn leave(&self, seat: &Seat, _data: &mut D, serial: Serial, time: u32) { + fn leave(&self, seat: &Seat, data: &mut D, serial: Serial, time: u32) { if let Some(pointer) = seat.get_pointer() { pointer.wp_pointer_gestures.leave::(self, serial, time); pointer.wl_pointer.leave(self, serial, time); with_pointer_constraint(self, &pointer, |constraint| { if let Some(constraint) = constraint { - constraint.deactivate(); + constraint.deactivate(data, self, &pointer); } }); } diff --git a/src/wayland/selection/data_device/mod.rs b/src/wayland/selection/data_device/mod.rs index d35a243cec1b..0f63e25d1e34 100644 --- a/src/wayland/selection/data_device/mod.rs +++ b/src/wayland/selection/data_device/mod.rs @@ -32,6 +32,7 @@ //! use smithay::wayland::selection::data_device::{WaylandDndGrabHandler, DataDeviceState, DataDeviceHandler}; //! # use smithay::input::{Seat, SeatState, SeatHandler, pointer::CursorImageStatus}; //! # use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; +//! # use smithay::wayland::pointer_constraints::PointerConstraintsHandler; //! //! # struct State { data_device_state: DataDeviceState } //! # let mut display = wayland_server::Display::::new().unwrap(); @@ -57,6 +58,7 @@ //! # fn focus_changed(&mut self, seat: &Seat, focused: Option<&WlSurface>) { unimplemented!() } //! # fn cursor_image(&mut self, seat: &Seat, image: CursorImageStatus) { unimplemented!() } //! # } +//! # impl PointerConstraintsHandler for State {} //! impl WaylandDndGrabHandler for State { //! // ... implement `dnd_requested` to handle drag&drop operations //! } diff --git a/src/wayland/selection/ext_data_control/mod.rs b/src/wayland/selection/ext_data_control/mod.rs index bf0520e9244d..2d4905e3e825 100644 --- a/src/wayland/selection/ext_data_control/mod.rs +++ b/src/wayland/selection/ext_data_control/mod.rs @@ -13,6 +13,7 @@ //! use smithay::wayland::selection::ext_data_control::{DataControlState, DataControlHandler}; //! # use smithay::input::{Seat, SeatHandler, SeatState, pointer::CursorImageStatus}; //! # use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; +//! # use smithay::wayland::pointer_constraints::PointerConstraintsHandler; //! //! # struct State { data_control_state: DataControlState } //! # let mut display = wayland_server::Display::::new().unwrap(); @@ -38,6 +39,7 @@ //! # fn focus_changed(&mut self, seat: &Seat, focused: Option<&WlSurface>) { unimplemented!() } //! # fn cursor_image(&mut self, seat: &Seat, image: CursorImageStatus) { unimplemented!() } //! # } +//! # impl PointerConstraintsHandler for State {} //! impl SelectionHandler for State { //! type SelectionUserData = (); //! } diff --git a/src/wayland/selection/primary_selection/mod.rs b/src/wayland/selection/primary_selection/mod.rs index e120a976db44..73a3b03b3c02 100644 --- a/src/wayland/selection/primary_selection/mod.rs +++ b/src/wayland/selection/primary_selection/mod.rs @@ -31,6 +31,7 @@ //! use smithay::wayland::selection::primary_selection::{PrimarySelectionState, PrimarySelectionHandler}; //! # use smithay::input::{Seat, SeatHandler, SeatState, pointer::CursorImageStatus}; //! # use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; +//! # use smithay::wayland::pointer_constraints::PointerConstraintsHandler; //! //! # struct State { primary_selection_state: PrimarySelectionState } //! # let mut display = wayland_server::Display::::new().unwrap(); @@ -56,6 +57,7 @@ //! # fn focus_changed(&mut self, seat: &Seat, focused: Option<&WlSurface>) { unimplemented!() } //! # fn cursor_image(&mut self, seat: &Seat, image: CursorImageStatus) { unimplemented!() } //! # } +//! # impl PointerConstraintsHandler for State {} //! impl SelectionHandler for State { //! type SelectionUserData = (); //! } diff --git a/src/wayland/selection/wlr_data_control/mod.rs b/src/wayland/selection/wlr_data_control/mod.rs index dd0574c6a9ee..00748892f05a 100644 --- a/src/wayland/selection/wlr_data_control/mod.rs +++ b/src/wayland/selection/wlr_data_control/mod.rs @@ -13,6 +13,7 @@ //! use smithay::wayland::selection::wlr_data_control::{DataControlState, DataControlHandler}; //! # use smithay::input::{Seat, SeatHandler, SeatState, pointer::CursorImageStatus}; //! # use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; +//! # use smithay::wayland::pointer_constraints::PointerConstraintsHandler; //! //! # struct State { data_control_state: DataControlState } //! # let mut display = wayland_server::Display::::new().unwrap(); @@ -38,6 +39,7 @@ //! # fn focus_changed(&mut self, seat: &Seat, focused: Option<&WlSurface>) { unimplemented!() } //! # fn cursor_image(&mut self, seat: &Seat, image: CursorImageStatus) { unimplemented!() } //! # } +//! # impl PointerConstraintsHandler for State {} //! impl SelectionHandler for State { //! type SelectionUserData = (); //! } diff --git a/src/wayland/shell/xdg/decoration.rs b/src/wayland/shell/xdg/decoration.rs index 481606d05336..941a075a95cf 100644 --- a/src/wayland/shell/xdg/decoration.rs +++ b/src/wayland/shell/xdg/decoration.rs @@ -63,6 +63,7 @@ //! //! # use smithay::wayland::compositor::{CompositorHandler, CompositorState, CompositorClientState}; //! use smithay::input::{Seat, SeatState, SeatHandler, pointer::CursorImageStatus}; +//! # use smithay::wayland::pointer_constraints::PointerConstraintsHandler; //! //! # impl CompositorHandler for State { //! # fn compositor_state(&mut self) -> &mut CompositorState { unimplemented!() } @@ -86,6 +87,7 @@ //! // handle new images for the cursor ... //! } //! } +//! # impl PointerConstraintsHandler for State {} //! //! smithay::delegate_dispatch2!(State); //! diff --git a/src/wayland/shell/xdg/dialog.rs b/src/wayland/shell/xdg/dialog.rs index 6f0205a5849d..a845ac5e18e1 100644 --- a/src/wayland/shell/xdg/dialog.rs +++ b/src/wayland/shell/xdg/dialog.rs @@ -51,6 +51,7 @@ //! //! # use smithay::wayland::compositor::{CompositorHandler, CompositorState, CompositorClientState}; //! use smithay::input::{Seat, SeatState, SeatHandler, pointer::CursorImageStatus}; +//! # use smithay::wayland::pointer_constraints::PointerConstraintsHandler; //! //! # impl CompositorHandler for State { //! # fn compositor_state(&mut self) -> &mut CompositorState { unimplemented!() } @@ -74,6 +75,7 @@ //! // handle new images for the cursor ... //! } //! } +//! # impl PointerConstraintsHandler for State {} //! //! smithay::delegate_dispatch2!(State); //! diff --git a/src/wayland/shell/xdg/mod.rs b/src/wayland/shell/xdg/mod.rs index d4ca36ab0cbb..f9d78627125f 100644 --- a/src/wayland/shell/xdg/mod.rs +++ b/src/wayland/shell/xdg/mod.rs @@ -76,6 +76,7 @@ //! //! # use smithay::wayland::compositor::{CompositorHandler, CompositorState, CompositorClientState}; //! use smithay::input::{Seat, SeatState, SeatHandler, pointer::CursorImageStatus}; +//! # use smithay::wayland::pointer_constraints::PointerConstraintsHandler; //! //! # impl CompositorHandler for State { //! # fn compositor_state(&mut self) -> &mut CompositorState { unimplemented!() } @@ -99,6 +100,7 @@ //! // handle new images for the cursor ... //! } //! } +//! # impl PointerConstraintsHandler for State {} //! //! smithay::delegate_dispatch2!(State); //! diff --git a/src/wayland/tablet_manager/mod.rs b/src/wayland/tablet_manager/mod.rs index 4969fee17be6..2e8da0e94b8f 100644 --- a/src/wayland/tablet_manager/mod.rs +++ b/src/wayland/tablet_manager/mod.rs @@ -14,6 +14,7 @@ //! use smithay::wayland::tablet_manager::{TabletManagerState}; //! use smithay::reexports::wayland_server::{Display, protocol::wl_surface::WlSurface}; //! # use smithay::wayland::compositor::{CompositorHandler, CompositorState, CompositorClientState}; +//! # use smithay::wayland::pointer_constraints::PointerConstraintsHandler; //! # use smithay::reexports::wayland_server::Client; //! //! # struct State { seat_state: SeatState }; @@ -50,6 +51,7 @@ //! // handle new images for the cursor ... //! } //! } +//! # impl PointerConstraintsHandler for State {} //! //! impl TabletSeatHandler for State { //! type ToolFocus = WlSurface; diff --git a/src/wayland/text_input/mod.rs b/src/wayland/text_input/mod.rs index 1780c0870762..b03ceca1d920 100644 --- a/src/wayland/text_input/mod.rs +++ b/src/wayland/text_input/mod.rs @@ -10,6 +10,7 @@ //! # use smithay::wayland::compositor::{CompositorHandler, CompositorState, CompositorClientState}; //! use smithay::wayland::text_input::TextInputManagerState; //! use smithay::reexports::wayland_server::{Display, protocol::wl_surface::WlSurface}; +//! # use smithay::wayland::pointer_constraints::PointerConstraintsHandler; //! # use smithay::reexports::wayland_server::Client; //! //! # struct State { seat_state: SeatState }; @@ -32,6 +33,7 @@ //! fn focus_changed(&mut self, seat: &Seat, focused: Option<&WlSurface>) { unimplemented!() } //! fn cursor_image(&mut self, seat: &Seat, image: CursorImageStatus) { unimplemented!() } //! } +//! # impl PointerConstraintsHandler for State {} //! //! // Add the seat state to your state and create manager global //! TextInputManagerState::new::(&display_handle); diff --git a/src/wayland/virtual_keyboard/mod.rs b/src/wayland/virtual_keyboard/mod.rs index 0ca8f09af0a5..a8039004c180 100644 --- a/src/wayland/virtual_keyboard/mod.rs +++ b/src/wayland/virtual_keyboard/mod.rs @@ -9,6 +9,7 @@ //! # use smithay::wayland::compositor::{CompositorHandler, CompositorState, CompositorClientState}; //! use smithay::wayland::virtual_keyboard::VirtualKeyboardManagerState; //! use smithay::reexports::wayland_server::{Display, protocol::wl_surface::WlSurface}; +//! # use smithay::wayland::pointer_constraints::PointerConstraintsHandler; //! # use smithay::reexports::wayland_server::Client; //! //! # struct State { seat_state: SeatState }; @@ -31,6 +32,7 @@ //! fn focus_changed(&mut self, seat: &Seat, focused: Option<&WlSurface>) { unimplemented!() } //! fn cursor_image(&mut self, seat: &Seat, image: CursorImageStatus) { unimplemented!() } //! } +//! # impl PointerConstraintsHandler for State {} //! //! // Add the seat state to your state, create manager global and add client filter //! // to avoid untrusted clients requesting a new keyboard diff --git a/src/wayland/xwayland_keyboard_grab.rs b/src/wayland/xwayland_keyboard_grab.rs index adaf4da83f11..3c6b54b9baf8 100644 --- a/src/wayland/xwayland_keyboard_grab.rs +++ b/src/wayland/xwayland_keyboard_grab.rs @@ -16,6 +16,7 @@ //! # use smithay::wayland::compositor::{CompositorHandler, CompositorState, CompositorClientState}; //! # use smithay::input::{Seat, SeatHandler, SeatState, pointer::CursorImageStatus}; //! # use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; +//! # use smithay::wayland::pointer_constraints::PointerConstraintsHandler; //! # impl CompositorHandler for State { //! # fn compositor_state(&mut self) -> &mut CompositorState { unimplemented!() } //! # fn client_compositor_state<'a>(&self, client: &'a wayland_server::Client) -> &'a CompositorClientState { unimplemented!() } @@ -29,6 +30,7 @@ //! # fn focus_changed(&mut self, seat: &Seat, focused: Option<&WlSurface>) { unimplemented!() } //! # fn cursor_image(&mut self, seat: &Seat, image: CursorImageStatus) { unimplemented!() } //! # } +//! # impl PointerConstraintsHandler for State {} //! //! impl XWaylandKeyboardGrabHandler for State { //! fn keyboard_focus_for_xsurface(&self, _: &WlSurface) -> Option { diff --git a/src/xwayland/xwm/mod.rs b/src/xwayland/xwm/mod.rs index b92654c6100a..a04187355b83 100644 --- a/src/xwayland/xwm/mod.rs +++ b/src/xwayland/xwm/mod.rs @@ -42,6 +42,7 @@ //! # } //! # } //! # use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; +//! # use smithay::wayland::pointer_constraints::PointerConstraintsHandler; //! # use smithay::input::{Seat, SeatState, SeatHandler, pointer::CursorImageStatus, dnd::DndGrabHandler}; //! # use smithay::backend::input::KeyState; //! # use smithay::input::{ @@ -69,6 +70,7 @@ //! # fn focus_changed(&mut self, seat: &Seat, focused: Option<&Target>) {} //! # fn cursor_image(&mut self, seat: &Seat, image: CursorImageStatus) {} //! # } +//! # impl PointerConstraintsHandler for State {} //! # impl DndGrabHandler for State {} //! # impl DataDeviceHandler for State { //! # fn data_device_state(&mut self) -> &mut DataDeviceState { unreachable!() } diff --git a/src/xwayland/xwm/surface.rs b/src/xwayland/xwm/surface.rs index 7c27cf18ad89..eee5d9a5bce1 100644 --- a/src/xwayland/xwm/surface.rs +++ b/src/xwayland/xwm/surface.rs @@ -17,6 +17,7 @@ use crate::{ }, wayland::{ compositor::{self, CompositorHandler, RectangleKind, RegionAttributes, SurfaceAttributes}, + pointer_constraints::PointerConstraintsHandler, seat::{WaylandFocus, keyboard::enter_internal}, }, }; @@ -2239,7 +2240,7 @@ impl KeyboardTarget for X11Surface { } } -impl PointerTarget for X11Surface { +impl PointerTarget for X11Surface { fn enter(&self, seat: &Seat, data: &mut D, event: &MotionEvent) { if let Some(surface) = self.state.lock().unwrap().wl_surface.as_ref() { PointerTarget::enter(surface, seat, data, event);