FLTK logo

[master] 5becf68 - Fix "Callback or event on minimize of the main window " for Wayland (#1288)

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] 5becf68 - Fix "Callback or event on minimize of the main window " for Wayland (#1288) "ManoloFLTK" Aug 04, 2025  
 
commit 5becf68c18a41247cee27fc1ae08f274f5cc8a4c
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Mon Aug 4 15:54:14 2025 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Mon Aug 4 15:54:14 2025 +0200

    Fix "Callback or event on minimize of the main window " for Wayland (#1288)

 FL/Enumerations.H                                |  5 ++---
 src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx | 12 +++++++-----
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git FL/Enumerations.H FL/Enumerations.H
index 5a39c2a..404a3d9 100644
--- FL/Enumerations.H
+++ FL/Enumerations.H
@@ -256,9 +256,8 @@ enum Fl_Event { // events
 
   /** This widget is no longer visible, due to Fl_Widget::hide() being
       called on it or one of its parents, or due to a parent window being
-      minimized (under Wayland, minimized toplevel windows don't receive
-      the FL_HIDE event, except if minimized programmatically calling
-      Fl_Window::iconize()).
+      minimized (old Wayland versions may not send the FL_HIDE
+      event to minimized toplevel windows).
       Fl_Widget::visible() may still be true after this, but the
       widget is visible only if visible() is true for it and all its
       parents (use Fl_Widget::visible_r() to check this).
diff --git src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
index ba96102..6e3deea 100644
--- src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
+++ src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
@@ -581,7 +581,9 @@ void Fl_Wayland_Window_Driver::iconize() {
   struct wld_window *wl_win = (struct wld_window*)ip->xid;
   if (wl_win->kind == DECORATED) {
     libdecor_frame_set_minimized(wl_win->frame);
-    Fl::handle(FL_HIDE, pWindow);
+    if (xdg_toplevel_get_version(xdg_toplevel()) < 6) {
+      Fl::handle(FL_HIDE, pWindow);
+    }
   }
   else if (wl_win->kind == UNFRAMED && wl_win->xdg_toplevel) xdg_toplevel_set_minimized(wl_win->xdg_toplevel);
 }
@@ -961,10 +963,6 @@ static void handle_configure(struct libdecor_frame *frame,
   if (is_2nd_run) driver->wait_for_expose_value = 0;
 //fprintf(stderr, "handle_configure fl_win=%p size:%dx%d state=%x wait_for_expose_value=%d is_2nd_run=%d\n", window->fl_win, width,height,window_state,driver->wait_for_expose_value, is_2nd_run);
 
-/* We would like to do FL_HIDE when window is minimized but :
- "There is no way to know if the surface is currently minimized, nor is there any way to
- unset minimization on this surface. If you are looking to throttle redrawing when minimized,
- please instead use the wl_surface.frame event" */
   if (window_state & LIBDECOR_WINDOW_STATE_ACTIVE) {
     if (Fl_Wayland_Screen_Driver::compositor == Fl_Wayland_Screen_Driver::WESTON) {
       // After click on titlebar, weston calls wl_keyboard_enter() for a
@@ -974,7 +972,11 @@ static void handle_configure(struct libdecor_frame *frame,
     if (!window->fl_win->border()) libdecor_frame_set_visibility(window->frame, false);
     else if (!libdecor_frame_is_visible(window->frame)) {
       libdecor_frame_set_visibility(window->frame, true);
+    } else if (!window->fl_win->visible()) {
+      Fl::handle(FL_SHOW, window->fl_win); // useful when un-minimizing
     }
+  } else if (window_state & LIBDECOR_WINDOW_STATE_SUSPENDED) { // window is minimized
+    Fl::handle(FL_HIDE, window->fl_win);
   }
 
   if (window->fl_win->border())
[ 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'.