]> source.dussan.org Git - tigervnc.git/commitdiff
Consolidate how to run the FLTK loop in one place
authorPierre Ossman <ossman@cendio.se>
Wed, 18 Nov 2015 15:23:21 +0000 (16:23 +0100)
committerPierre Ossman <ossman@cendio.se>
Fri, 27 Nov 2015 10:15:19 +0000 (11:15 +0100)
vncviewer/CConn.cxx
vncviewer/vncviewer.cxx
vncviewer/vncviewer.h

index 78eadb545e8f60232e5de9050def0f37b493b3ae..fb136b5fe09b620cfd82ac9f86509e849480d14c 100644 (file)
@@ -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");
index a2bc02979230fbfa28790cec9557936cd67f1641..d71cb7f90624e1d3030ff7c2d8675417b0abc034 100644 (file)
@@ -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;
 
index 4d0566bb73faa4eeb474a49dfc47f06cba7a8ba3..c98c2e94b8d2490feb954033ce447b33e5d3d1ab 100644 (file)
@@ -24,5 +24,6 @@
 void exit_vncviewer(const char *error = NULL);
 bool should_exit();
 void about_vncviewer();
+void run_mainloop();
 
 #endif