summaryrefslogtreecommitdiff
path: root/FL/Fl.H
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2018-02-06 17:26:11 +0000
committerManolo Gouy <Manolo>2018-02-06 17:26:11 +0000
commit425ab2e8bc4905959ecc5d38e042ee0e1c3e1771 (patch)
tree7e20118535dae2870bc2fb7c4a3b83d12d054af9 /FL/Fl.H
parent4ebaee0f40e30c4da671a9351676e1c9051abbef (diff)
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
Diffstat (limited to 'FL/Fl.H')
-rw-r--r--FL/Fl.H16
1 files changed, 15 insertions, 1 deletions
diff --git a/FL/Fl.H b/FL/Fl.H
index 966e20ee1..8cfed7f05 100644
--- a/FL/Fl.H
+++ b/FL/Fl.H
@@ -259,7 +259,8 @@ public:
private:
static unsigned char options_[OPTION_LAST];
static unsigned char options_read_;
-
+ static int program_should_quit_; // non-zero means the program was asked to cleanly terminate
+
public:
/*
Return a global setting for all FLTK applications, possibly overridden
@@ -412,6 +413,19 @@ 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
+ returns 0 until \p Fl::program_should_quit(1) is called.
+ */
+ static int program_should_quit() {return program_should_quit_;}
+ /** Indicate to the FLTK library whether a program termination request was received and accepted.
+ A program may set this to 1, for example, while performing a platform-independent command asking the program to cleanly
+ terminate, similarly to the "Quit xxx" item of the application menu under MacOS. */
+ static void program_should_quit(int should_i) { program_should_quit_ = should_i; }
+
static Fl_Widget* readqueue();
/**
Adds a one-shot timeout callback. The function will be called by