From 03dbbf79ffc48342d71e2c8577ea0a0e5641977a Mon Sep 17 00:00:00 2001 From: Thomas Jaeger Date: Sun, 23 Sep 2012 03:46:42 -0400 Subject: [PATCH] have users enable the whitelist behavior explicitly Also, always use the default options when recording strokes --- actions.cc | 8 ++++---- grabber.cc | 31 +++++++++++++++---------------- gui.glade | 30 +++++++++++++++++++++++++----- prefdb.cc | 5 ++++- prefdb.h | 3 ++- prefs.cc | 1 + 6 files changed, 51 insertions(+), 27 deletions(-) diff --git a/actions.cc b/actions.cc index c17857cb..8e6f1260 100644 --- a/actions.cc +++ b/actions.cc @@ -760,7 +760,7 @@ void Actions::update_row(const Gtk::TreeRow &row) { } extern boost::shared_ptr > stroke_action; -Source stroke_app(NULL); +Source recording(false); class Actions::OnStroke { Actions *parent; @@ -796,7 +796,7 @@ class Actions::OnStroke { stroke = stroke_; Glib::signal_idle().connect(sigc::mem_fun(*this, &OnStroke::run)); stroke_action.reset(); - stroke_app.set(NULL); + recording.set(false); } }; @@ -824,14 +824,14 @@ void Actions::on_row_activated(const Gtk::TreeModel::Path& path, Gtk::TreeViewCo OnStroke ps(this, dialog, row); stroke_action.reset(new sigc::slot(sigc::mem_fun(ps, &OnStroke::delayed_run))); - stroke_app.set(action_list); + recording.set(true); dialog->show(); cancel->grab_focus(); int response = dialog->run(); dialog->hide(); stroke_action.reset(); - stroke_app.set(NULL); + recording.set(false); if (response != 1) return; diff --git a/grabber.cc b/grabber.cc index 434861de..90b4b865 100644 --- a/grabber.cc +++ b/grabber.cc @@ -27,7 +27,7 @@ extern Window get_window(Window w, Atom prop); extern Source disabled; extern Source current_app_window; -extern Source stroke_app; +extern Source recording; extern bool in_proximity; Grabber *grabber = 0; @@ -189,9 +189,7 @@ void activate(Window w, Time t) { XSendEvent(dpy, ROOT, False, SubstructureNotifyMask | SubstructureRedirectMask, (XEvent *)&ev); } -std::string get_wm_class(Window w, ActionListDiff *actions) { - if (actions && actions->app) - return actions->name; +std::string get_wm_class(Window w) { if (!w) return ""; XClassHint ch; @@ -236,8 +234,9 @@ Grabber::Grabber() : children(ROOT) { init_xi(); prefs.excluded_devices.connect(new IdleNotifier(sigc::mem_fun(*this, &Grabber::update))); prefs.button.connect(new IdleNotifier(sigc::mem_fun(*this, &Grabber::update))); - current_class = fun2(&get_wm_class, current_app_window, stroke_app); + current_class = fun(&get_wm_class, current_app_window); current_class->connect(new IdleNotifier(sigc::mem_fun(*this, &Grabber::update))); + recording.connect(new IdleNotifier(sigc::mem_fun(*this, &Grabber::update))); disabled.connect(new IdleNotifier(sigc::mem_fun(*this, &Grabber::set))); update(); resume(); @@ -511,20 +510,20 @@ guint Grabber::get_default_mods(guint button) { } void Grabber::update() { - std::map::const_iterator i = prefs.exceptions.ref().find(current_class->get()); - active = true; ButtonInfo bi = prefs.button.ref(); - if (i != prefs.exceptions.ref().end()) { - if (i->second) - bi = *i->second; - else + active = true; + if (!recording.get()) { + std::map::const_iterator i = prefs.exceptions.ref().find(current_class->get()); + if (i != prefs.exceptions.ref().end()) { + if (i->second) + bi = *i->second; + else + active = false; + } + + if (prefs.whitelist.get() && !actions.apps.count(current_class->get())) active = false; } - const ActionListDiff *a = stroke_app.get(); - if (!a) - a = actions.get_action_list(current_class->get()); - if (active && actions.get_root()->size_rec() && !a->count_actions()) - active = false; const std::vector &extra = prefs.extra_buttons.ref(); if (grabbed_button == bi && buttons.size() == extra.size() + 1 && std::equal(extra.begin(), extra.end(), ++buttons.begin())) { diff --git a/gui.glade b/gui.glade index b3b288e2..95291938 100644 --- a/gui.glade +++ b/gui.glade @@ -971,6 +971,9 @@ Van Diep Duong (Vietnamese) 120 True True + + + @@ -1501,6 +1504,23 @@ Van Diep Duong (Vietnamese) True False 6 + + + Only enable easystroke for applications listed on 'Actions' tab + False + True + True + False + False + 0 + True + + + False + False + 0 + + Timeout Gestures @@ -1513,7 +1533,7 @@ Van Diep Duong (Vietnamese) False False - 0 + 1 @@ -1555,7 +1575,7 @@ Van Diep Duong (Vietnamese) False True - 1 + 2 @@ -1597,7 +1617,7 @@ Van Diep Duong (Vietnamese) True True - 2 + 3 @@ -1650,7 +1670,7 @@ Van Diep Duong (Vietnamese) True True 6 - 3 + 4 @@ -1665,7 +1685,7 @@ Van Diep Duong (Vietnamese) True True - 4 + 5 diff --git a/prefdb.cc b/prefdb.cc index a9e37268..0c924f57 100644 --- a/prefdb.cc +++ b/prefdb.cc @@ -51,7 +51,8 @@ PrefDB::PrefDB() : scroll_speed(2.0), tray_feedback(false), show_osd(true), - move_back(false) + move_back(false), + whitelist(false) {} template void PrefDB::serialize(Archive & ar, const unsigned int version) { @@ -132,6 +133,8 @@ template void PrefDB::serialize(Archive & ar, const unsigned int ar & move_back.unsafe_ref(); if (version < 17) return; ar & device_timeout.unsafe_ref(); + if (version < 18) return; + ar & whitelist.unsafe_ref(); } void PrefDB::timeout() { diff --git a/prefdb.h b/prefdb.h index aaf3f814..4a325f87 100644 --- a/prefdb.h +++ b/prefdb.h @@ -132,12 +132,13 @@ class PrefDB : public TimeoutWatcher { PrefSource show_osd; PrefSource move_back; PrefSource > device_timeout; + PrefSource whitelist; void init(); virtual void timeout(); }; -BOOST_CLASS_VERSION(PrefDB, 17) +BOOST_CLASS_VERSION(PrefDB, 18) extern PrefDB prefs; diff --git a/prefs.cc b/prefs.cc index dca328a3..efbf0916 100644 --- a/prefs.cc +++ b/prefs.cc @@ -257,6 +257,7 @@ Prefs::Prefs() { new Adjustment(prefs.trace_width, "adjustment_trace_width"); new Combo(prefs.timeout_profile, "box_timeout", experimental ? timeout_info_exp : timeout_info); + new Check(prefs.whitelist, "check_whitelist"); new Check(prefs.timeout_gestures, "check_timeout_gestures"); new Check(prefs.scroll_invert, "check_scroll_invert");