13
0

new timer-based GUI locking code

This commit is contained in:
Paul Davis 2014-06-25 08:28:36 -04:00
parent 1945260cd6
commit d5ef8f5f1e
3 changed files with 71 additions and 0 deletions

View File

@ -45,6 +45,7 @@
#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>
@ -1108,6 +1109,58 @@ Editor::on_realize ()
{
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

View File

@ -1360,6 +1360,11 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
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;

View File

@ -7137,7 +7137,14 @@ Editor::lock ()
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 ();
}
@ -7145,5 +7152,11 @@ void
Editor::unlock ()
{
lock_dialog->hide ();
#ifdef __APPLE__
ActionManager::pop_action_state ();
#endif
start_lock_event_timing ();
}