@@ -108,7 +108,7 @@ impl<'a, Message, Renderer> DndSource<'a, Message, Renderer> {
108
108
on_finished : None ,
109
109
on_dropped : None ,
110
110
on_selection_action : None ,
111
- drag_threshold : 5 .0,
111
+ drag_threshold : 25 .0,
112
112
handle_captured_events : true ,
113
113
}
114
114
}
@@ -249,6 +249,22 @@ where
249
249
}
250
250
251
251
let mut state = tree. state . downcast_mut :: < State > ( ) ;
252
+
253
+ if matches ! (
254
+ event,
255
+ Event :: PlatformSpecific ( event:: PlatformSpecific :: Wayland (
256
+ event:: wayland:: Event :: Seat (
257
+ event:: wayland:: SeatEvent :: Leave ,
258
+ _
259
+ )
260
+ ) ) | Event :: Mouse ( mouse:: Event :: ButtonReleased (
261
+ mouse:: Button :: Left
262
+ ) ) | Event :: Touch ( touch:: Event :: FingerLifted { .. } )
263
+ | Event :: Touch ( touch:: Event :: FingerLost { .. } )
264
+ ) {
265
+ state. left_pressed_position = None ;
266
+ return event:: Status :: Captured ;
267
+ }
252
268
253
269
if state. is_dragging {
254
270
if let Event :: PlatformSpecific ( event:: PlatformSpecific :: Wayland (
@@ -302,7 +318,10 @@ where
302
318
}
303
319
}
304
320
305
- if !layout. bounds ( ) . contains ( cursor_position) {
321
+ if cursor_position. x > 0.0
322
+ && cursor_position. y > 0.0
323
+ && !layout. bounds ( ) . contains ( cursor_position)
324
+ {
306
325
// XXX if the widget is not hovered but the mouse is pressed,
307
326
// we are triggering on_drag
308
327
if let ( Some ( on_drag) , Some ( _) ) =
@@ -319,6 +338,9 @@ where
319
338
if let ( Some ( on_drag) , Some ( pressed_pos) ) =
320
339
( self . on_drag . clone ( ) , state. left_pressed_position . clone ( ) )
321
340
{
341
+ if cursor_position. x < 0.0 || cursor_position. y < 0.0 {
342
+ return captured;
343
+ }
322
344
let distance = ( cursor_position. x - pressed_pos. x ) . powi ( 2 )
323
345
+ ( cursor_position. y - pressed_pos. y ) . powi ( 2 ) ;
324
346
if distance > self . drag_threshold {
0 commit comments