mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 14:54:56 +01:00
Replace gettimeofday with monotonic time
let's be independent of NTP updates, daylight savings time and syscalls.
This commit is contained in:
parent
4e032f7469
commit
ecaeea94e5
2 changed files with 6 additions and 9 deletions
|
|
@ -323,7 +323,7 @@ Editor::Editor ()
|
|||
, pending_keyboard_selection_start (0)
|
||||
, ignore_gui_changes (false)
|
||||
, lock_dialog (0)
|
||||
, last_event_time { 0, 0 }
|
||||
, _last_event_time (g_get_monotonic_time ())
|
||||
, _dragging_playhead (false)
|
||||
, ignore_map_change (false)
|
||||
, _stationary_playhead (false)
|
||||
|
|
@ -1047,7 +1047,7 @@ Editor::generic_event_handler (GdkEvent* ev)
|
|||
case GDK_KEY_PRESS:
|
||||
case GDK_KEY_RELEASE:
|
||||
if (contents().get_mapped()) {
|
||||
gettimeofday (&last_event_time, 0);
|
||||
_last_event_time = g_get_monotonic_time ();
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -1078,13 +1078,9 @@ Editor::generic_event_handler (GdkEvent* ev)
|
|||
bool
|
||||
Editor::lock_timeout_callback ()
|
||||
{
|
||||
struct timeval now, delta;
|
||||
int64_t dt = g_get_monotonic_time () - _last_event_time;
|
||||
|
||||
gettimeofday (&now, 0);
|
||||
|
||||
timersub (&now, &last_event_time, &delta);
|
||||
|
||||
if (delta.tv_sec > (time_t) UIConfiguration::instance().get_lock_gui_after_seconds()) {
|
||||
if (dt * 1e-6 > UIConfiguration::instance().get_lock_gui_after_seconds()) {
|
||||
lock ();
|
||||
/* don't call again. Returning false will effectively
|
||||
disconnect us from the timer callback.
|
||||
|
|
|
|||
|
|
@ -1453,7 +1453,8 @@ private:
|
|||
void unlock ();
|
||||
Gtk::Dialog* lock_dialog;
|
||||
|
||||
struct timeval last_event_time;
|
||||
int64_t _last_event_time;
|
||||
|
||||
bool generic_event_handler (GdkEvent*);
|
||||
bool lock_timeout_callback ();
|
||||
void start_lock_event_timing ();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue