@@ -8,33 +8,27 @@ use tracing::warn;
88
99use sctk:: reexports:: client:: delegate_dispatch;
1010use sctk:: reexports:: client:: protocol:: wl_pointer:: WlPointer ;
11- use sctk:: reexports:: client:: protocol:: wl_seat:: WlSeat ;
1211use sctk:: reexports:: client:: protocol:: wl_surface:: WlSurface ;
1312use sctk:: reexports:: client:: { Connection , Proxy , QueueHandle , Dispatch } ;
1413use sctk:: reexports:: protocols:: wp:: pointer_constraints:: zv1:: client:: zwp_confined_pointer_v1:: ZwpConfinedPointerV1 ;
1514use sctk:: reexports:: protocols:: wp:: pointer_constraints:: zv1:: client:: zwp_locked_pointer_v1:: ZwpLockedPointerV1 ;
16- use sctk:: reexports:: protocols:: wp:: cursor_shape:: v1:: client:: wp_cursor_shape_device_v1:: WpCursorShapeDeviceV1 ;
17- use sctk:: reexports:: protocols:: wp:: cursor_shape:: v1:: client:: wp_cursor_shape_manager_v1:: WpCursorShapeManagerV1 ;
1815use sctk:: reexports:: protocols:: wp:: pointer_constraints:: zv1:: client:: zwp_pointer_constraints_v1:: { Lifetime , ZwpPointerConstraintsV1 } ;
1916use sctk:: reexports:: client:: globals:: { BindError , GlobalList } ;
2017use sctk:: reexports:: csd_frame:: FrameClick ;
2118use sctk:: reexports:: protocols:: wp:: viewporter:: client:: wp_viewport:: WpViewport ;
2219
2320use sctk:: compositor:: SurfaceData ;
2421use sctk:: globals:: GlobalData ;
25- use sctk:: seat:: pointer:: {
26- PointerData , PointerDataExt , PointerEvent , PointerEventKind , PointerHandler ,
27- } ;
28- use sctk:: seat:: SeatState ;
22+ use sctk:: seat:: pointer:: { PointerData , PointerEvent , PointerEventKind , PointerHandler } ;
2923
3024use dpi:: { LogicalPosition , PhysicalPosition } ;
3125use winit_core:: event:: {
32- ElementState , MouseButton , MouseScrollDelta , PointerKind , PointerSource , TouchPhase ,
33- WindowEvent , ButtonSource ,
26+ ButtonSource , ElementState , MouseButton , MouseScrollDelta , PointerKind , PointerSource ,
27+ TouchPhase , WindowEvent ,
3428} ;
3529
36- use crate :: state:: WinitState ;
3730use crate :: WindowId ;
31+ use crate :: state:: WinitState ;
3832
3933pub mod pointer_gesture;
4034pub mod relative_pointer;
@@ -68,7 +62,7 @@ impl PointerHandler for WinitState {
6862 let surface = & event. surface ;
6963
7064 // The parent surface.
71- let parent_surface = match event. surface . data :: < SurfaceData > ( ) {
65+ let parent_surface = match event. surface . data :: < SurfaceData < ( ) > > ( ) {
7266 Some ( data) => data. parent_surface ( ) . unwrap_or ( surface) ,
7367 None => continue ,
7468 } ;
@@ -140,13 +134,13 @@ impl PointerHandler for WinitState {
140134 window. pointer_entered ( Arc :: downgrade ( themed_pointer) ) ;
141135
142136 // Set the currently focused surface.
143- pointer. winit_data ( ) . inner . lock ( ) . unwrap ( ) . surface = Some ( window_id) ;
137+ pointer. winit_data ( ) . data ( ) . inner . lock ( ) . unwrap ( ) . surface = Some ( window_id) ;
144138 } ,
145139 PointerEventKind :: Leave { .. } => {
146140 window. pointer_left ( Arc :: downgrade ( themed_pointer) ) ;
147141
148142 // Remove the active surface.
149- pointer. winit_data ( ) . inner . lock ( ) . unwrap ( ) . surface = None ;
143+ pointer. winit_data ( ) . data ( ) . inner . lock ( ) . unwrap ( ) . surface = None ;
150144
151145 self . events_sink . push_window_event (
152146 WindowEvent :: PointerLeft {
@@ -172,7 +166,7 @@ impl PointerHandler for WinitState {
172166 ref kind @ PointerEventKind :: Press { button, serial, .. }
173167 | ref kind @ PointerEventKind :: Release { button, serial, .. } => {
174168 // Update the last button serial.
175- pointer. winit_data ( ) . inner . lock ( ) . unwrap ( ) . latest_button_serial = serial;
169+ pointer. winit_data ( ) . data ( ) . inner . lock ( ) . unwrap ( ) . latest_button_serial = serial;
176170
177171 let button = wayland_button_to_winit ( button) ;
178172 let state = if matches ! ( kind, PointerEventKind :: Press { .. } ) {
@@ -193,7 +187,7 @@ impl PointerHandler for WinitState {
193187 } ,
194188 PointerEventKind :: Axis { horizontal, vertical, .. } => {
195189 // Get the current phase.
196- let mut pointer_data = pointer. winit_data ( ) . inner . lock ( ) . unwrap ( ) ;
190+ let mut pointer_data = pointer. winit_data ( ) . data ( ) . inner . lock ( ) . unwrap ( ) ;
197191
198192 let has_value120_scroll = horizontal. value120 != 0 || vertical. value120 != 0 ;
199193 let has_discrete_scroll = horizontal. discrete != 0 || vertical. discrete != 0 ;
@@ -253,20 +247,13 @@ pub struct WinitPointerData {
253247 /// The inner winit data associated with the pointer.
254248 inner : Mutex < WinitPointerDataInner > ,
255249
256- /// The data required by the sctk.
257- sctk_data : PointerData ,
258-
259250 /// Viewport for fractional cursor.
260251 viewport : Option < WpViewport > ,
261252}
262253
263254impl WinitPointerData {
264- pub fn new ( seat : WlSeat , viewport : Option < WpViewport > ) -> Self {
265- Self {
266- inner : Mutex :: new ( WinitPointerDataInner :: default ( ) ) ,
267- sctk_data : PointerData :: new ( seat) ,
268- viewport,
269- }
255+ pub fn new ( viewport : Option < WpViewport > ) -> Self {
256+ Self { inner : Mutex :: new ( WinitPointerDataInner :: default ( ) ) , viewport }
270257 }
271258
272259 pub fn lock_pointer (
@@ -320,26 +307,11 @@ impl WinitPointerData {
320307 }
321308 }
322309
323- /// Seat associated with this pointer.
324- pub fn seat ( & self ) -> & WlSeat {
325- self . sctk_data . seat ( )
326- }
327-
328310 /// Active window.
329311 pub fn focused_window ( & self ) -> Option < WindowId > {
330312 self . inner . lock ( ) . unwrap ( ) . surface
331313 }
332314
333- /// Last button serial.
334- pub fn latest_button_serial ( & self ) -> u32 {
335- self . sctk_data . latest_button_serial ( ) . unwrap_or_default ( )
336- }
337-
338- /// Last enter serial.
339- pub fn latest_enter_serial ( & self ) -> u32 {
340- self . sctk_data . latest_enter_serial ( ) . unwrap_or_default ( )
341- }
342-
343315 pub fn set_locked_cursor_position ( & self , surface_x : f64 , surface_y : f64 ) {
344316 let inner = self . inner . lock ( ) . unwrap ( ) ;
345317 if let Some ( locked_pointer) = inner. locked_pointer . as_ref ( ) {
@@ -360,12 +332,6 @@ impl Drop for WinitPointerData {
360332 }
361333}
362334
363- impl PointerDataExt for WinitPointerData {
364- fn pointer_data ( & self ) -> & PointerData {
365- & self . sctk_data
366- }
367- }
368-
369335#[ derive( Debug ) ]
370336pub struct WinitPointerDataInner {
371337 /// The associated locked pointer.
@@ -423,12 +389,12 @@ fn wayland_button_to_winit(button: u32) -> ButtonSource {
423389}
424390
425391pub trait WinitPointerDataExt {
426- fn winit_data ( & self ) -> & WinitPointerData ;
392+ fn winit_data ( & self ) -> & PointerData < WinitPointerData > ;
427393}
428394
429395impl WinitPointerDataExt for WlPointer {
430- fn winit_data ( & self ) -> & WinitPointerData {
431- self . data :: < WinitPointerData > ( ) . expect ( "failed to get pointer data." )
396+ fn winit_data ( & self ) -> & PointerData < WinitPointerData > {
397+ self . data :: < PointerData < WinitPointerData > > ( ) . expect ( "failed to get pointer data." )
432398 }
433399}
434400
@@ -491,35 +457,6 @@ impl Dispatch<ZwpConfinedPointerV1, GlobalData, WinitState> for PointerConstrain
491457 }
492458}
493459
494- impl Dispatch < WpCursorShapeDeviceV1 , GlobalData , WinitState > for SeatState {
495- fn event (
496- _: & mut WinitState ,
497- _: & WpCursorShapeDeviceV1 ,
498- _: <WpCursorShapeDeviceV1 as Proxy >:: Event ,
499- _: & GlobalData ,
500- _: & Connection ,
501- _: & QueueHandle < WinitState > ,
502- ) {
503- unreachable ! ( "wp_cursor_shape_manager has no events" )
504- }
505- }
506-
507- impl Dispatch < WpCursorShapeManagerV1 , GlobalData , WinitState > for SeatState {
508- fn event (
509- _: & mut WinitState ,
510- _: & WpCursorShapeManagerV1 ,
511- _: <WpCursorShapeManagerV1 as Proxy >:: Event ,
512- _: & GlobalData ,
513- _: & Connection ,
514- _: & QueueHandle < WinitState > ,
515- ) {
516- unreachable ! ( "wp_cursor_device_manager has no events" )
517- }
518- }
519-
520- delegate_dispatch ! ( WinitState : [ WlPointer : WinitPointerData ] => SeatState ) ;
521- delegate_dispatch ! ( WinitState : [ WpCursorShapeManagerV1 : GlobalData ] => SeatState ) ;
522- delegate_dispatch ! ( WinitState : [ WpCursorShapeDeviceV1 : GlobalData ] => SeatState ) ;
523460delegate_dispatch ! ( WinitState : [ ZwpPointerConstraintsV1 : GlobalData ] => PointerConstraintsState ) ;
524461delegate_dispatch ! ( WinitState : [ ZwpLockedPointerV1 : GlobalData ] => PointerConstraintsState ) ;
525462delegate_dispatch ! ( WinitState : [ ZwpConfinedPointerV1 : GlobalData ] => PointerConstraintsState ) ;
0 commit comments