From 50184f994699a19185a2c3e73861bb13f5579d23 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Sun, 3 Aug 2025 09:03:12 +0200 Subject: Fix "Callback or event on minimize of the main window" for X11 platform (#1288) --- src/Fl_x.cxx | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index 81a6916d0..fed46a638 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -202,6 +202,7 @@ static Atom fl_NET_WM_STATE; static Atom fl_NET_WM_STATE_FULLSCREEN; static Atom fl_NET_WM_STATE_MAXIMIZED_VERT; static Atom fl_NET_WM_STATE_MAXIMIZED_HORZ; +static Atom fl_NET_WM_STATE_HIDDEN; static Atom fl_NET_WM_FULLSCREEN_MONITORS; Atom fl_NET_WORKAREA; static Atom fl_NET_WM_ICON; @@ -602,6 +603,7 @@ void open_display_i(Display* d) { fl_NET_WM_STATE_FULLSCREEN = XInternAtom(d, "_NET_WM_STATE_FULLSCREEN", 0); fl_NET_WM_STATE_MAXIMIZED_VERT = XInternAtom(d, "_NET_WM_STATE_MAXIMIZED_VERT", 0); fl_NET_WM_STATE_MAXIMIZED_HORZ = XInternAtom(d, "_NET_WM_STATE_MAXIMIZED_HORZ", 0); + fl_NET_WM_STATE_HIDDEN = XInternAtom(d, "_NET_WM_STATE_HIDDEN", 0); fl_NET_WM_FULLSCREEN_MONITORS = XInternAtom(d, "_NET_WM_FULLSCREEN_MONITORS", 0); fl_NET_WORKAREA = XInternAtom(d, "_NET_WORKAREA", 0); fl_NET_WM_ICON = XInternAtom(d, "_NET_WM_ICON", 0); @@ -2125,6 +2127,7 @@ int fl_handle(const XEvent& thisevent) if (xevent.xproperty.atom == fl_NET_WM_STATE) { int fullscreen_state = 0; int maximize_state = 0; + int minimize_state = 0; if (xevent.xproperty.state != PropertyDelete) { unsigned long nitems; unsigned long *words = 0; @@ -2136,6 +2139,9 @@ int fl_handle(const XEvent& thisevent) if (words[item] == fl_NET_WM_STATE_MAXIMIZED_HORZ) { maximize_state = 1; } + if (words[item] == fl_NET_WM_STATE_HIDDEN) { + minimize_state = 1; + } } } if ( words ) { XFree(words); words = 0; } @@ -2149,6 +2155,13 @@ int fl_handle(const XEvent& thisevent) window->_set_fullscreen(); event = FL_FULLSCREEN; } + if (!event) { + if (minimize_state) { + event = FL_HIDE; + } else if (!window->visible()) { + event = FL_SHOW; + } + } } break; -- cgit v1.2.3