FLTK logo

[master] 617dc2c - Fix for issue #450: Fl_Counter slips into infinite loop.

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] 617dc2c - Fix for issue #450: Fl_Counter slips into infinite loop. "ManoloFLTK" Jun 23, 2022  
 
commit 617dc2ce12eb6183b4ae3d3fe73572e43629c825
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Thu Jun 23 19:12:35 2022 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Thu Jun 23 19:12:35 2022 +0200

    Fix for issue #450:  Fl_Counter slips into infinite loop.
    
    This issue revealed that the macOS and Wayland platform processed events slightly differently
    from other platforms.
    Under X11 and Windows, Fl::wait() processes one event if one is present, and also all other events
    present in the event queue immediately after the processing of that event.
    Under macOS and Wayland, Fl::wait() processes one event if one is present and returns.
    
    This commits makes the macOS and Wayland platforms behave as other platforms.

 src/Fl_cocoa.mm                                  | 8 +++++---
 src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx | 2 ++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git src/Fl_cocoa.mm src/Fl_cocoa.mm
index 1fe7f68..889b5c3 100644
--- src/Fl_cocoa.mm
+++ src/Fl_cocoa.mm
@@ -768,12 +768,14 @@ static int do_queued_events( double time = 0.0 )
   time = Fl_Timeout::time_to_wait(time);
 
   fl_unlock_function();
-  NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask
+  NSEvent *event;
+  while ( (event = [NSApp nextEventMatchingMask:NSAnyEventMask
                                       untilDate:[NSDate dateWithTimeIntervalSinceNow:time]
-                                         inMode:NSDefaultRunLoopMode dequeue:YES];
-  if (event != nil) {
+                                         inMode:NSDefaultRunLoopMode
+                                        dequeue:YES]) != nil ) {
     got_events = 1;
     [FLApplication sendEvent:event]; // will then call [NSApplication sendevent:]
+    time = 0;
   }
   fl_lock_function();
 
diff --git src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
index 81f6b92..dad143c 100644
--- src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
+++ src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
@@ -1058,6 +1058,8 @@ static const struct wl_registry_listener registry_listener = {
 
 static void fd_callback(int unused, struct wl_display *display) {
   wl_display_dispatch(display);
+  static Fl_Wayland_System_Driver *sys_dr = (Fl_Wayland_System_Driver*)Fl::system_driver();
+  while (sys_dr->poll_or_select() > 0) wl_display_dispatch(display);
 }
 
 
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.