diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2014-09-26 23:58:05 +0000 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2014-09-26 23:58:05 +0000 |
| commit | eb1af07952d3cfbe8d00037c481e30ad72160c12 (patch) | |
| tree | 212c01562a5bef43f95f85926273055af632787c /src/Fl_Window.cxx | |
| parent | 5899b2cc6d024b311b89a36d810dc246fd778be4 (diff) | |
Add Fl_Window::wait_for_expose() and test program (STR #3124).
Also modified .gitignore, svn-properties, Makefile and CMake-Files.
Todo: test/twowin.cxx and test/windowfocus.cxx need to be added to ide files
(MS VC++ and Xcode).
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10339 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Window.cxx')
| -rw-r--r-- | src/Fl_Window.cxx | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/Fl_Window.cxx b/src/Fl_Window.cxx index 5c2f5d6d7..ba9f7fef3 100644 --- a/src/Fl_Window.cxx +++ b/src/Fl_Window.cxx @@ -397,6 +397,58 @@ void Fl_Window::free_icons() { #endif } +/** + Waits for the window to be fully displayed after calling show(). + + Fl_Window::show() is not guaranteed to show and draw the window on + all platforms immediately. Instead this is done in the background; + particularly on X11 this will take a few messages (client server + roundtrips) to display the window. + + Usually this small delay doesn't matter, but in some cases you may + want to have the window instantiated and displayed synchronously. + + Currently (as of FLTK 1.3.3) this method only has an effect on X11. + On Windows and Mac OS X show() is always synchronous. If you want to + write portable code and need this synchronous show() feature, add + win->wait_for_expose() on all platforms, FLTK will just do the + right thing. + + This method can be used for displaying splash screens before + calling Fl::run() or for having exact control over which window + has focus after calling show(). + + If the window is not shown(), this method does nothing. + + \see virtual void Fl_Window::show() + + Example code for displaying a window before calling Fl::run() + + \code + Fl_Double_Window win = new Fl_Double_Window(...); + + // do more window initialization here ... + + win->show(); // show window + win->wait_for_expose(); // wait, until displayed + Fl::flush(); // make sure everything gets drawn + + // do more initialization work that needs some time here ... + + Fl::run(); // start FLTK event loop + \endcode + + Note that the window will not be responsive until the event loop + is started with Fl::run(). +*/ + +void Fl_Window::wait_for_expose() { + if (!shown()) return; + while (!i || i->wait_for_expose) { + Fl::wait(); + } +} + // // End of "$Id$". // |
