From 425ab2e8bc4905959ecc5d38e042ee0e1c3e1771 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Tue, 6 Feb 2018 17:26:11 +0000 Subject: Add support for detection and processing of clean program termination request. The default handling of cmd-Q/Quit program under MacOS was to terminate the program if all its windows are closed without returning from FLTK's event loop. This was running against a strong design feature of FLTK that programs should always complete their event loop and return from main() when cleanly terminating. In the new code for the MacOS platform, cmd-Q/Quit program no longer terminates the program. Instead, the event loop is interrupted and a call to Fl::program_should_quit() allows to detect that program termination has been requested, if necessary. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12647 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl.cxx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/Fl.cxx') diff --git a/src/Fl.cxx b/src/Fl.cxx index ca629ab94..e6af1297b 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -589,6 +589,22 @@ int Fl::ready() return screen_driver()->ready(); } +/** Run the event loop even without any mapped window if the platform supports it. + \return zero indicates the event loop has been terminated. + */ +int Fl::run_also_windowless() { + return Fl::system_driver()->run_also_windowless(); +} + +/** Wait for \p delay seconds or until an event occurs, even without any mapped window if the platform supports it. + \return non zero indicates the event loop should be terminated + */ +int Fl::wait_also_windowless(double delay) { + return Fl::system_driver()->wait_also_windowless(delay); +} + +int Fl::program_should_quit_ = 0; + //////////////////////////////////////////////////////////////// // Window list management: -- cgit v1.2.3