Skip to content

Commit

Permalink
Clean up Win32 message pump. The logic was a bit overly complex
Browse files Browse the repository at this point in the history
with the double calls to PeekMessage() and the extra if clause.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10309 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
CendioOssman committed Sep 15, 2014
1 parent 0356bd2 commit 321fb4e
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions src/Fl_win32.cxx
Expand Up @@ -401,26 +401,22 @@ int fl_wait(double time_to_wait) {

// Execute the message we got, and all other pending messages:
// have_message = PeekMessage(&fl_msg, NULL, 0, 0, PM_REMOVE);
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;
Fl_Awake_Handler func;
void *data;
while (Fl::get_awake_handler_(func, data)==0) {
func(data);
}
}

TranslateMessage(&fl_msg);
DispatchMessageW(&fl_msg);
have_message = PeekMessageW(&fl_msg, NULL, 0, 0, PM_REMOVE);
while ((have_message = PeekMessageW(&fl_msg, NULL, 0, 0, PM_REMOVE)) > 0) {
// 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;
Fl_Awake_Handler func;
void *data;
while (Fl::get_awake_handler_(func, data)==0)
func(data);
}

TranslateMessage(&fl_msg);
DispatchMessageW(&fl_msg);
}
Fl::flush();

Expand Down

0 comments on commit 321fb4e

Please sign in to comment.