From 35a3e7cc16f8312c5a750041adf67d2e086d059b Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Thu, 26 Dec 2019 17:19:05 +0100 Subject: Fix Fl::add_timeout() under Linux (STR 3516) See comment 14 (excerpt): "The current implementation basically handles add_timeout() the same way as repeat_timeout(), i.e. add_timeout() *calls* repeat_timeout(). However, repeat_timeout() intentionally *corrects* the timeout value by the value found in the global variable 'missed_timeout_by' which is set when the timer expires, directly before the timer callback is called. This variable is never reset." This commit resets the variable as necessary in Fl::add_timeout(). --- src/drivers/X11/Fl_X11_Screen_Driver.cxx | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/drivers/X11/Fl_X11_Screen_Driver.cxx b/src/drivers/X11/Fl_X11_Screen_Driver.cxx index 75467b71b..b93d22ac6 100644 --- a/src/drivers/X11/Fl_X11_Screen_Driver.cxx +++ b/src/drivers/X11/Fl_X11_Screen_Driver.cxx @@ -635,6 +635,7 @@ const char *Fl_X11_Screen_Driver::get_system_scheme() void Fl_X11_Screen_Driver::add_timeout(double time, Fl_Timeout_Handler cb, void *argp) { elapse_timeouts(); + missed_timeout_by = 0; repeat_timeout(time, cb, argp); } -- cgit v1.2.3 From 3701950a90e0b57d4a64e9ca26c1616cbc386c39 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Thu, 26 Dec 2019 18:13:03 +0100 Subject: Fix rare early timeouts in Fl_Clock (STR 3516). This is the main patch for Fl_Clock discussed in STR 3516. Although the root cause under Linux (in Fl::add_timeout()) has been fixed in a previous commit (35a3e7cc1) early timeouts may still occur, e.g. under Windows in a Virtualbox environment. This commit reverts bab61a93d and replaces it with the patch proposed by Manolo and further discussed in STR 3516. --- src/Fl_Clock.cxx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Fl_Clock.cxx b/src/Fl_Clock.cxx index ca7237212..4d7f21e47 100644 --- a/src/Fl_Clock.cxx +++ b/src/Fl_Clock.cxx @@ -212,11 +212,16 @@ static void tick(void *v) { time_t sec; int usec; Fl::system_driver()->gettime(&sec, &usec); + double delta = (1000000 - usec)/1000000.; // time till next second + // if current time is just before full second, show that full second + // and wait one more second (STR 3516) + if (delta < 0.1) { + delta += 1.0; + sec++; + } ((Fl_Clock*)v)->value((ulong)sec); - // schedule timer event slightly later than the next second (+25 ms) - // to prevent multiple timer events if triggered too early (STR 3516) - Fl::add_timeout((1025000 - usec)/1000000., tick, v); + Fl::add_timeout(delta, tick, v); } int Fl_Clock::handle(int event) { -- cgit v1.2.3 From 07c2ba56da4e9ca3ad8d7eb02da9faa180183a99 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Fri, 27 Dec 2019 12:14:26 +0100 Subject: Have Fl_Pack::draw() call Fl_Group::init_sizes() on its parent group. Fl_Pack::draw() sometimes resizes itself. This must be followed by a call to Fl_Group::init_sizes() as indicated in that function's doc: "If you rearrange the widgets in your group, call this method to register the new arrangement with the Fl_Group that contains them." --- src/Fl_Pack.cxx | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/Fl_Pack.cxx b/src/Fl_Pack.cxx index 5935079ce..55ad2c385 100644 --- a/src/Fl_Pack.cxx +++ b/src/Fl_Pack.cxx @@ -135,6 +135,8 @@ void Fl_Pack::draw() { th += Fl::box_dh(box()); if (th <= 0) th = 1; if (tw != w() || th != h()) { Fl_Widget::resize(x(),y(),tw,th); + Fl_Group *parent = this->parent(); + if (parent) parent->init_sizes(); d = FL_DAMAGE_ALL; } if (d&FL_DAMAGE_ALL) { -- cgit v1.2.3