diff --git a/CHANGES b/CHANGES index 95be66cf2..6d42cfb35 100644 --- a/CHANGES +++ b/CHANGES @@ -22,12 +22,13 @@ Changes in FLTK 1.4.0 Released: ??? ?? 2017 hardware support is present (a backup mechanism is available in absence of this support). Thus, all text drawable in Fl_Window's can be drawn in Fl_GL_Window's (STR#3450). - - New member functions FL::run_also_windowless(), - and FL::wait_also_windowless(double secnds) to run the event - loop even without any mapped window if the platform supports it. - New member functions Fl::program_should_quit(void), and Fl::program_should_quit(int) to support detection by the library of a request to terminate cleanly the program. + - MacOS platform: the processing of the application menu's "Quit" item + has been changed. With FLTK 1.3.x, the application terminated when all + windows were closed even before Fl::run() of Fl::wait() could return. + With FLTK 1.4, Fl::run() returns so the app follows its normal termination path. - MacOS platform: Added support for rescaling the GUI of any app at run-time using the command/+/-/0/ keystrokes. - MSWindows platform: Added optional support for rescaling the GUI of any app diff --git a/FL/Fl.H b/FL/Fl.H index 07d87ec7d..17bdd0aa1 100644 --- a/FL/Fl.H +++ b/FL/Fl.H @@ -414,8 +414,6 @@ public: static int check(); static int ready(); static int run(); - static int run_also_windowless(); - static int wait_also_windowless(double delay = 1e20); /** Returns non-zero when a request for program termination was received and accepted. On the MacOS platform, the "Quit xxx" item of the application menu is such a request, that is considered accepted when all windows are closed. On other platforms, this function diff --git a/FL/Fl_Screen_Driver.H b/FL/Fl_Screen_Driver.H index 564b77754..de40ce47b 100644 --- a/FL/Fl_Screen_Driver.H +++ b/FL/Fl_Screen_Driver.H @@ -178,9 +178,6 @@ public: /* Number of pixels per drawing unit for the display. The default implementation may be enough. */ virtual float retina_factor() { return 1; } - // The default implementation of the next 2 functions may be enough. - virtual int run_also_windowless(); - virtual int wait_also_windowless(double delay); }; diff --git a/documentation/src/osissues.dox b/documentation/src/osissues.dox index f2383445e..5c187155c 100644 --- a/documentation/src/osissues.dox +++ b/documentation/src/osissues.dox @@ -738,15 +738,12 @@ Apple "Quit" Event \par When the user presses Cmd-Q or requests a termination of the -application, FLTK reacts sending an \c FL_CLOSE event to all open +application, FLTK sends an \c FL_CLOSE event to all open windows. If any window remains open, the termination request aborts. If all windows close, the application's event loop terminates, that is, Fl::run() returns. The application can then follow FLTK's normal termination path executing cleanup code that may be programmed after termination of the event loop, and returning from main(). -Function Fl::run_also_windowless() can be used instead of Fl::run() to keep -the event loop running also after all windows are closed, a feature the MacOS platform supports. -This function also returns after a successful Cmd-Q. Function Fl::program_should_quit() allows to detect whether the event loop terminated because of a program termination request. diff --git a/src/Fl.cxx b/src/Fl.cxx index 0e1f63fc7..25b6b696f 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -516,6 +516,13 @@ double Fl::wait(double time_to_wait) { (supposedly it would return non-zero on any errors, but FLTK calls exit directly for these). A normal program will end main() with return Fl::run();. + + \note Fl::run() and Fl::wait() (but not Fl::wait(double)) both + return when all FLTK windows are closed. Therefore, a MacOS FLTK + application possessing Fl_Sys_Menu_Bar items able to create new windows + and expected to keep running without any open window cannot use + these two functions. One solution is to run the event loop as follows: + \code while (!Fl::program_should_quit()) Fl::wait(1e20); \endcode */ int Fl::run() { while (Fl_X::first) wait(FOREVER); @@ -588,26 +595,6 @@ int Fl::ready() return screen_driver()->ready(); } -/** Run the event loop even without any mapped window if the platform supports it. - Identical to Fl::run() for platforms that don't support running windowless. - The MacOS platform supports it. - \return zero indicates the event loop has been terminated. - \version 1.4.0 - */ -int Fl::run_also_windowless() { - return Fl::screen_driver()->run_also_windowless(); -} - -/** Wait for \p delay seconds or until an event occurs, even without any mapped window if the platform supports it. - Identical to Fl::wait(delay) for platforms that don't support running windowless. - The MacOS platform supports it. - \return non zero indicates the event loop should be terminated - \version 1.4.0 - */ -int Fl::wait_also_windowless(double delay) { - return Fl::screen_driver()->wait_also_windowless(delay); -} - int Fl::program_should_quit_ = 0; //////////////////////////////////////////////////////////////// diff --git a/src/Fl_Screen_Driver.cxx b/src/Fl_Screen_Driver.cxx index 2dffcd7a5..9891721a7 100644 --- a/src/Fl_Screen_Driver.cxx +++ b/src/Fl_Screen_Driver.cxx @@ -483,15 +483,6 @@ int Fl_Screen_Driver::parse_color(const char* p, uchar& r, uchar& g, uchar& b) return 1; } -int Fl_Screen_Driver::run_also_windowless() { - return Fl::run(); -} - -int Fl_Screen_Driver::wait_also_windowless(double delay) { - Fl::wait(delay); - return Fl::first_window() != NULL; -} - // // End of "$Id$". // diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index e83f8af4c..12e9a7bd9 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -1719,18 +1719,6 @@ static void drain_dropped_files_list() { free(fname); } -int Fl_Cocoa_Screen_Driver::run_also_windowless() { - while (!Fl::program_should_quit()) { - Fl::wait(1e20); - } - return 0; -} - -int Fl_Cocoa_Screen_Driver::wait_also_windowless(double delay) { - if (!Fl::program_should_quit()) Fl::wait(delay); - return !Fl::program_should_quit(); -} - /* * Install an open documents event handler... */ diff --git a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H index 077416823..16cd246d3 100644 --- a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H +++ b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H @@ -101,8 +101,6 @@ public: virtual float scale(int n) {return scale_;} virtual void scale(int n, float f) { scale_ = f;} virtual Fl_RGB_Image *read_win_rectangle(int X, int Y, int w, int h); - virtual int run_also_windowless(); - virtual int wait_also_windowless(double delay); private: float scale_; };