@@ -34,6 +34,7 @@ pub(crate) struct App {
3434 window_fullscreen : bool ,
3535 pointer_position : PhysicalPosition < f64 > ,
3636 pointer_lock_position : Option < PhysicalPosition < f64 > > ,
37+ pending_drag : bool ,
3738 ui_scale : f64 ,
3839 app_event_receiver : Receiver < AppEvent > ,
3940 app_event_scheduler : AppEventScheduler ,
@@ -107,6 +108,7 @@ impl App {
107108 window_fullscreen : false ,
108109 pointer_position : Default :: default ( ) ,
109110 pointer_lock_position : Default :: default ( ) ,
111+ pending_drag : false ,
110112 ui_scale : 1. ,
111113 app_event_receiver,
112114 app_event_scheduler,
@@ -399,9 +401,7 @@ impl App {
399401 }
400402 }
401403 DesktopFrontendMessage :: WindowDrag => {
402- if let Some ( window) = & self . window {
403- window. start_drag ( ) ;
404- }
404+ self . pending_drag = true ;
405405 }
406406 DesktopFrontendMessage :: WindowHide => {
407407 if let Some ( window) = & self . window {
@@ -575,6 +575,13 @@ impl ApplicationHandler for App {
575575 WindowEvent :: SurfaceResized ( _) | WindowEvent :: ScaleFactorChanged { .. } => {
576576 self . resize ( ) ;
577577 }
578+ WindowEvent :: PointerButton {
579+ button : ButtonSource :: Mouse ( MouseButton :: Left ) ,
580+ state : ElementState :: Released ,
581+ ..
582+ } => {
583+ self . pending_drag = false ;
584+ }
578585 WindowEvent :: RedrawRequested => {
579586 #[ cfg( target_os = "macos" ) ]
580587 self . resize ( ) ;
@@ -657,6 +664,13 @@ impl ApplicationHandler for App {
657664 if self . pointer_lock_position . is_none ( ) =>
658665 {
659666 self . pointer_position = position;
667+
668+ if self . pending_drag {
669+ self . pending_drag = false ;
670+ if let Some ( window) = & self . window {
671+ window. start_drag ( ) ;
672+ }
673+ }
660674 }
661675
662676 _ => { }
0 commit comments