diff options
| -rw-r--r-- | documentation/src/osissues.dox | 9 | ||||
| -rw-r--r-- | src/Fl_win32.cxx | 4 |
2 files changed, 13 insertions, 0 deletions
diff --git a/documentation/src/osissues.dox b/documentation/src/osissues.dox index 18232c670..07fd508bf 100644 --- a/documentation/src/osissues.dox +++ b/documentation/src/osissues.dox @@ -479,6 +479,15 @@ In FLTK, all strings, including filenames, are UTF-8 encoded. The utility functi fl_fopen() and fl_open() allow to open files potentially having non-ASCII names in a cross-platform fashion, whereas the standard fopen()/open() functions fail to do so. +\subsection osissues_wm_quit Responding to WM_QUIT + +FLTK will intercept WM_QUIT messages that are directed towards the +thread that runs the main loop. These are converted to SIGTERM signals +via \c raise(). This allows you to deal with outside termination +requests with the same code on both Windows and UNIX systems. +Other processes can send this message via \c PostThreadMessage() in +order to request, rather than force your application to terminate. + \subsection osissues_win32_messages Handling Other WIN32 Messages By default a single WNDCLASSEX called "FLTK" is diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx index ce480b5d7..ea4f5f390 100644 --- a/src/Fl_win32.cxx +++ b/src/Fl_win32.cxx @@ -36,6 +36,7 @@ #include <stdlib.h> #include <sys/types.h> #include <time.h> +#include <signal.h> #ifdef __CYGWIN__ # include <sys/time.h> # include <unistd.h> @@ -403,6 +404,9 @@ int fl_wait(double time_to_wait) { have_message = PeekMessageW(&fl_msg, NULL, 0, 0, PM_REMOVE); if (have_message > 0) { while (have_message != 0 && have_message != -1) { + // Let applications treat WM_QUIT identical to SIGTERM on *nix + if (fl_msg.message == WM_QUIT) + raise(SIGTERM); if (fl_msg.message == fl_wake_msg) { // Used for awaking wait() from another thread thread_message_ = (void*)fl_msg.wParam; |
