#include "pbd/unknown_type.h"
#include "pbd/unwind.h"
#include "pbd/stacktrace.h"
+#include "pbd/timersub.h"
#include <glibmm/miscutils.h>
#include <glibmm/uriutils.h>
{
Window::on_realize ();
Realized ();
+
+ start_lock_event_timing ();
+ signal_event().connect (sigc::mem_fun (*this, &Editor::generic_event_handler));
+}
+
+void
+Editor::start_lock_event_timing ()
+{
+ /* check if we should lock the GUI every 30 seconds */
+
+ Glib::signal_timeout().connect (sigc::mem_fun (*this, &Editor::lock_timeout_callback), 30 * 1000);
+}
+
+bool
+Editor::generic_event_handler (GdkEvent* ev)
+{
+ switch (ev->type) {
+ case GDK_BUTTON_PRESS:
+ case GDK_BUTTON_RELEASE:
+ case GDK_MOTION_NOTIFY:
+ case GDK_KEY_PRESS:
+ case GDK_KEY_RELEASE:
+ gettimeofday (&last_event_time, 0);
+ break;
+ default:
+ break;
+ }
+ return false;
+}
+
+bool
+Editor::lock_timeout_callback ()
+{
+ struct timeval now, delta;
+ const uint32_t lock_timeout_secs = 5; /* 2 minutes */
+
+ gettimeofday (&now, 0);
+
+ timersub (&now, &last_event_time, &delta);
+
+ if (delta.tv_sec > lock_timeout_secs) {
+ lock ();
+ /* don't call again. Returning false will effectively
+ disconnect us from the timer callback.
+
+ unlock() will call start_lock_event_timing() to get things
+ started again.
+ */
+ return false;
+ }
+
+ return true;
}
void
void unlock ();
ArdourDialog* lock_dialog;
+ struct timeval last_event_time;
+ bool generic_event_handler (GdkEvent*);
+ bool lock_timeout_callback ();
+ void start_lock_event_timing ();
+
Gtk::Menu fade_context_menu;
Gtk::Menu xfade_in_context_menu;
lock_dialog->set_size_request (200, 200);
}
+#ifdef __APPLE__
+ /* The global menu bar continues to be accessible to applications
+ with modal dialogs, which means that we need to desensitize
+ all items in the menu bar. Since those items are really just
+ proxies for actions, that means disabling all actions.
+ */
ActionManager::disable_all_actions ();
+#endif
lock_dialog->present ();
}
Editor::unlock ()
{
lock_dialog->hide ();
+
+#ifdef __APPLE__
ActionManager::pop_action_state ();
+#endif
+
+ start_lock_event_timing ();
+
}