@@ -3,6 +3,11 @@ use std::{fmt, sync::Arc};
33#[ cfg( feature = "wayland_frontend" ) ]
44use wayland_server:: DisplayHandle ;
55
6+ #[ cfg( feature = "xwayland" ) ]
7+ use crate :: { wayland:: seat:: WaylandFocus , xwayland:: XWaylandClientData } ;
8+ #[ cfg( feature = "xwayland" ) ]
9+ use wayland_server:: Resource ;
10+
611use crate :: {
712 input:: {
813 dnd:: OfferData ,
@@ -323,12 +328,7 @@ where
323328 focus : Option < ( <D as SeatHandler >:: PointerFocus , Point < f64 , Logical > ) > ,
324329 event : & PointerMotionEvent ,
325330 ) {
326- // While the grab is active, we still honor the implicit grab target
327- handle. motion (
328- data,
329- self . pointer_start_data . as_ref ( ) . unwrap ( ) . focus . clone ( ) ,
330- event,
331- ) ;
331+ handle. motion ( data, self . ptr_focus ( ) , event) ;
332332
333333 self . last_position = event. location ;
334334
@@ -342,26 +342,13 @@ where
342342 _focus : Option < ( <D as SeatHandler >:: PointerFocus , Point < f64 , Logical > ) > ,
343343 event : & RelativeMotionEvent ,
344344 ) {
345- handle. relative_motion (
346- data,
347- self . pointer_start_data . as_ref ( ) . unwrap ( ) . focus . clone ( ) ,
348- event,
349- ) ;
345+ handle. relative_motion ( data, self . ptr_focus ( ) , event) ;
350346 }
351347
352348 fn button ( & mut self , data : & mut D , handle : & mut PointerInnerHandle < ' _ , D > , event : & ButtonEvent ) {
353349 handle. button ( data, event) ;
354350
355351 if handle. current_pressed ( ) . is_empty ( ) {
356- handle. motion (
357- data,
358- None ,
359- & PointerMotionEvent {
360- location : self . last_position ,
361- serial : event. serial ,
362- time : event. time ,
363- } ,
364- ) ;
365352 // the user dropped, proceed to the drop
366353 handle. unset_grab ( self , data, event. serial , event. time , true ) ;
367354 }
@@ -496,6 +483,8 @@ where
496483 return ;
497484 }
498485
486+ handle. motion ( data, self . touch_focus ( ) , event, seq) ;
487+
499488 self . last_position = event. location ;
500489
501490 self . update_focus (
@@ -505,13 +494,6 @@ where
505494 SERIAL_COUNTER . next_serial ( ) ,
506495 event. time ,
507496 ) ;
508-
509- handle. motion (
510- data,
511- self . touch_start_data . as_ref ( ) . unwrap ( ) . focus . clone ( ) ,
512- event,
513- seq,
514- ) ;
515497 }
516498
517499 fn frame ( & mut self , data : & mut D , handle : & mut TouchInnerHandle < ' _ , D > , seq : Serial ) {
@@ -549,3 +531,79 @@ where
549531 self . drop ( data, DndTarget :: Touch ) ;
550532 }
551533}
534+
535+ #[ cfg( not( feature = "xwayland" ) ) ]
536+ impl < D , S > DnDGrab < D , S , D :: PointerFocus >
537+ where
538+ D : DndGrabHandler ,
539+ D : SeatHandler ,
540+ <D as SeatHandler >:: PointerFocus : DndFocus < D > + ' static ,
541+ D : ' static ,
542+ S : Source ,
543+ {
544+ fn ptr_focus ( & self ) -> Option < ( <D as SeatHandler >:: PointerFocus , Point < f64 , Logical > ) > {
545+ None
546+ }
547+ }
548+
549+ #[ cfg( not( feature = "xwayland" ) ) ]
550+ impl < D , S > DnDGrab < D , S , D :: TouchFocus >
551+ where
552+ D : DndGrabHandler ,
553+ D : SeatHandler ,
554+ <D as SeatHandler >:: TouchFocus : DndFocus < D > + ' static ,
555+ D : ' static ,
556+ S : Source ,
557+ {
558+ fn touch_focus ( & self ) -> Option < ( <D as SeatHandler >:: TouchFocus , Point < f64 , Logical > ) > {
559+ None
560+ }
561+ }
562+
563+ #[ cfg( feature = "xwayland" ) ]
564+ impl < D , S > DnDGrab < D , S , D :: PointerFocus >
565+ where
566+ D : DndGrabHandler ,
567+ D : SeatHandler ,
568+ <D as SeatHandler >:: PointerFocus : DndFocus < D > + ' static ,
569+ D : ' static ,
570+ S : Source ,
571+ {
572+ fn ptr_focus ( & self ) -> Option < ( <D as SeatHandler >:: PointerFocus , Point < f64 , Logical > ) > {
573+ // While the grab is active, we don't want any focus except for xwayland
574+ self . pointer_start_data
575+ . as_ref ( ) ?
576+ . focus
577+ . clone ( )
578+ . filter ( |( focus, _) | {
579+ focus. wl_surface ( ) . is_some_and ( |s| {
580+ s. client ( )
581+ . is_some_and ( |c| c. get_data :: < XWaylandClientData > ( ) . is_some ( ) )
582+ } )
583+ } )
584+ }
585+ }
586+
587+ #[ cfg( feature = "xwayland" ) ]
588+ impl < D , S > DnDGrab < D , S , D :: TouchFocus >
589+ where
590+ D : DndGrabHandler ,
591+ D : SeatHandler ,
592+ <D as SeatHandler >:: TouchFocus : DndFocus < D > + ' static ,
593+ D : ' static ,
594+ S : Source ,
595+ {
596+ fn touch_focus ( & self ) -> Option < ( <D as SeatHandler >:: TouchFocus , Point < f64 , Logical > ) > {
597+ // While the grab is active, we don't want any focus except for xwayland
598+ self . touch_start_data
599+ . as_ref ( ) ?
600+ . focus
601+ . clone ( )
602+ . filter ( |( focus, _) | {
603+ focus. wl_surface ( ) . is_some_and ( |s| {
604+ s. client ( )
605+ . is_some_and ( |c| c. get_data :: < XWaylandClientData > ( ) . is_some ( ) )
606+ } )
607+ } )
608+ }
609+ }
0 commit comments