From: Pierre Ossman Date: Wed, 18 Nov 2015 15:23:21 +0000 (+0100) Subject: Consolidate how to run the FLTK loop in one place X-Git-Tag: v1.6.90~95^2~4 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5102fa96876907adca3d0897d67108c60a2545b0;p=tigervnc.git Consolidate how to run the FLTK loop in one place --- diff --git a/vncviewer/CConn.cxx b/vncviewer/CConn.cxx index 78eadb54..fb136b5f 100644 --- a/vncviewer/CConn.cxx +++ b/vncviewer/CConn.cxx @@ -228,13 +228,7 @@ const char *CConn::connectionInfo() void CConn::blockCallback() { - int next_timer; - - next_timer = Timer::checkTimeouts(); - if (next_timer == 0) - next_timer = INT_MAX; - - Fl::wait((double)next_timer / 1000.0); + run_mainloop(); if (should_exit()) throw rdr::Exception("Termination requested"); diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx index a2bc0297..d71cb7f9 100644 --- a/vncviewer/vncviewer.cxx +++ b/vncviewer/vncviewer.cxx @@ -128,6 +128,20 @@ void about_vncviewer() fl_message("%s", about_text()); } +void run_mainloop() +{ + int next_timer; + + next_timer = Timer::checkTimeouts(); + if (next_timer == 0) + next_timer = INT_MAX; + + if (Fl::wait((double)next_timer / 1000.0) < 0.0) { + vlog.error(_("Internal FLTK error. Exiting.")); + exit(-1); + } +} + #ifdef __APPLE__ static void about_callback(Fl_Widget *widget, void *data) { @@ -590,18 +604,8 @@ int main(int argc, char** argv) CConn *cc = new CConn(vncServerName, sock); - while (!exitMainloop) { - int next_timer; - - next_timer = Timer::checkTimeouts(); - if (next_timer == 0) - next_timer = INT_MAX; - - if (Fl::wait((double)next_timer / 1000.0) < 0.0) { - vlog.error(_("Internal FLTK error. Exiting.")); - break; - } - } + while (!exitMainloop) + run_mainloop(); delete cc; diff --git a/vncviewer/vncviewer.h b/vncviewer/vncviewer.h index 4d0566bb..c98c2e94 100644 --- a/vncviewer/vncviewer.h +++ b/vncviewer/vncviewer.h @@ -24,5 +24,6 @@ void exit_vncviewer(const char *error = NULL); bool should_exit(); void about_vncviewer(); +void run_mainloop(); #endif