Browse Source

fl_wait() didn't handle the case when timeout == 0 and nfds > 0.

As a result, you had to wiggle the mouse in order for fds to be
polled on a regular basis.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@583 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
branch-1.0
Michael R Sweet 26 years ago
parent
commit
d4bcbf5be3
  1. 31
      src/Fl_win32.cxx

31
src/Fl_win32.cxx

@ -1,5 +1,5 @@
// //
// "$Id: Fl_win32.cxx,v 1.33.2.8 1999/04/23 06:55:53 bill Exp $" // "$Id: Fl_win32.cxx,v 1.33.2.9 1999/05/09 14:49:14 mike Exp $"
// //
// WIN32-specific code for the Fast Light Tool Kit (FLTK). // WIN32-specific code for the Fast Light Tool Kit (FLTK).
// //
@ -129,7 +129,10 @@ int fl_ready() {
} }
double fl_wait(int timeout_flag, double time) { double fl_wait(int timeout_flag, double time) {
int have_message; int have_message = 0;
int timerid;
if (nfds) { if (nfds) {
// For WIN32 we need to poll for socket input FIRST, since // For WIN32 we need to poll for socket input FIRST, since
// the event queue is not something we can select() on... // the event queue is not something we can select() on...
@ -157,18 +160,32 @@ double fl_wait(int timeout_flag, double time) {
// get the first message by waiting the correct amount of time: // get the first message by waiting the correct amount of time:
if (!timeout_flag) { if (!timeout_flag) {
// If we are monitoring sockets we need to check them periodically,
// so set a timer in this case...
if (nfds) {
// First see if there is a message waiting...
have_message = PeekMessage(&fl_msg, NULL, 0, 0, PM_REMOVE);
if (!have_message) {
// If not then set a 1ms timer...
timerid = SetTimer(NULL, 0, 1, NULL);
GetMessage(&fl_msg, NULL, 0, 0); GetMessage(&fl_msg, NULL, 0, 0);
KillTimer(NULL, timerid);
}
} else
// Wait for a message...
GetMessage(&fl_msg, NULL, 0, 0);
have_message = 1; have_message = 1;
} else { } else {
if (time > 0.0) { // Perform the requested timeout...
have_message = PeekMessage(&fl_msg, NULL, 0, 0, PM_REMOVE);
if (!have_message && time > 0.0) {
int t = (int)(time * 1000.0); int t = (int)(time * 1000.0);
if (t <= 0) t = 1; if (t <= 0) t = 1;
int timerid = SetTimer(NULL, 0, t, NULL); timerid = SetTimer(NULL, 0, t, NULL);
GetMessage(&fl_msg, NULL, 0, 0); GetMessage(&fl_msg, NULL, 0, 0);
KillTimer(NULL, timerid); KillTimer(NULL, timerid);
have_message = 1; have_message = 1;
} else {
have_message = PeekMessage(&fl_msg, NULL, 0, 0, PM_REMOVE);
} }
} }
@ -922,5 +939,5 @@ void Fl_Window::make_current() {
} }
// //
// End of "$Id: Fl_win32.cxx,v 1.33.2.8 1999/04/23 06:55:53 bill Exp $". // End of "$Id: Fl_win32.cxx,v 1.33.2.9 1999/05/09 14:49:14 mike Exp $".
// //

Loading…
Cancel
Save