From a114e3ab4d9fa408061003c04a95b293b3842f24 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Wed, 23 Mar 2016 13:13:00 +0000 Subject: Rewrite Fl_Window::handle(int) under the driver model. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11403 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Window.cxx | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src/Fl_Window.cxx') diff --git a/src/Fl_Window.cxx b/src/Fl_Window.cxx index df6f97259..8cf091427 100644 --- a/src/Fl_Window.cxx +++ b/src/Fl_Window.cxx @@ -514,6 +514,46 @@ void Fl_Window::hide() { pWindowDriver->hide(); } + +// FL_SHOW and FL_HIDE are called whenever the visibility of this widget +// or any parent changes. We must correctly map/unmap the system's window. + +// For top-level windows it is assumed the window has already been +// mapped or unmapped!!! This is because this should only happen when +// Fl_Window::show() or Fl_Window::hide() is called, or in response to +// iconize/deiconize events from the system. +int Fl_Window::handle(int ev) +{ + if (parent()) { + switch (ev) { + case FL_SHOW: + if (!shown()) show(); + else { + pWindowDriver->map(); + } + break; + case FL_HIDE: + if (shown()) { + // Find what really turned invisible, if it was a parent window + // we do nothing. We need to avoid unnecessary unmap calls + // because they cause the display to blink when the parent is + // remapped. However if this or any intermediate non-window + // widget has really had hide() called directly on it, we must + // unmap because when the parent window is remapped we don't + // want to reappear. + if (visible()) { + Fl_Widget* p = parent(); for (;p->visible();p = p->parent()) {} + if (p->type() >= FL_WINDOW) break; // don't do the unmap + } + pWindowDriver->unmap(); + } + break; + } + } + + return Fl_Group::handle(ev); +} + // // End of "$Id$". // -- cgit v1.2.3