FLTK logo

[master] 05e3745 - Fix: Unexpected FL_ENTER after FL_LEAVE when a subwindow is hidden (#1295)

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

[master] 05e3745 - Fix: Unexpected FL_ENTER after FL_LEAVE when a subwindow is hidden (#1295) "ManoloFLTK" Aug 18, 2025  
 
commit 05e37453de4d28a0737628ba361647f1a1e4f0a8
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Mon Aug 18 16:07:59 2025 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Mon Aug 18 16:07:59 2025 +0200

    Fix: Unexpected FL_ENTER after FL_LEAVE when a subwindow is hidden (#1295)

 src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx | 18 +++++++++++++-----
 src/drivers/X11/Fl_X11_Window_Driver.cxx         |  2 ++
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
index 76a0a5b..5225392 100644
--- src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
+++ src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
@@ -196,6 +196,7 @@ static Fl_Window *event_coords_from_surface(struct wl_surface *surface,
   return win;
 }
 
+static Fl_Window *need_leave = NULL;
 
 static void pointer_enter(void *data, struct wl_pointer *wl_pointer, uint32_t serial,
         struct wl_surface *surface, wl_fixed_t surface_x, wl_fixed_t surface_y) {
@@ -217,6 +218,7 @@ static void pointer_enter(void *data, struct wl_pointer *wl_pointer, uint32_t se
     }
   }
   if (!win) return;
+  //fprintf(stderr, "pointer_enter window=%p\n", win);
   // use custom cursor if present
   struct wl_cursor *cursor =
     fl_wl_xid(win)->custom_cursor ? fl_wl_xid(win)->custom_cursor->wl_cursor : NULL;
@@ -224,8 +226,9 @@ static void pointer_enter(void *data, struct wl_pointer *wl_pointer, uint32_t se
   seat->serial = serial;
   seat->pointer_enter_serial = serial;
   set_event_xy(win);
-  Fl::handle(FL_ENTER, win);
-  //fprintf(stderr, "pointer_enter window=%p\n", win);
+  need_leave = NULL;
+  win = Fl_Wayland_Window_Driver::surface_to_window(surface);
+  if (!win->parent()) Fl::handle(FL_ENTER, win);
   seat->pointer_focus = surface;
 }
 
@@ -237,11 +240,16 @@ static void pointer_leave(void *data, struct wl_pointer *wl_pointer,
   Fl_Window *win = Fl_Wayland_Window_Driver::surface_to_window(surface);
   gtk_shell_surface = NULL;
   if (win) {
-    Fl::belowmouse(0);
+    //fprintf(stderr, "pointer_leave surface=%p window=%p\n", surface, win);
     set_event_xy(win);
-    Fl::handle(FL_LEAVE, win->top_window());
+    if (!win->parent()) {
+      need_leave = win;
+      wl_display_roundtrip(fl_wl_display()); // pointer_enter to new subwin will run
+      if (need_leave) { // we really leave the window: we don't enter a subwin of it
+        Fl::handle(FL_LEAVE, need_leave);
+      }
+    }
   }
-//fprintf(stderr, "pointer_leave surface=%p window=%p\n", surface, win);
 }
 
 
diff --git src/drivers/X11/Fl_X11_Window_Driver.cxx src/drivers/X11/Fl_X11_Window_Driver.cxx
index 96f43ce..354c5a8 100644
--- src/drivers/X11/Fl_X11_Window_Driver.cxx
+++ src/drivers/X11/Fl_X11_Window_Driver.cxx
@@ -434,6 +434,8 @@ void Fl_X11_Window_Driver::make_current() {
 
 void Fl_X11_Window_Driver::hide() {
   Fl_X* ip = Fl_X::flx(pWindow);
+  extern Fl_Window *fl_xmousewin;
+  fl_xmousewin = 0;
   if (hide_common()) return;
   if (ip->region) Fl_Graphics_Driver::default_driver().XDestroyRegion(ip->region);
 # if USE_XFT && ! FLTK_USE_CAIRO
[ Direct Link to Message ]
 
     
[ Previous Message ] [ Next Message ]
 
 

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