Skip to content

Commit

Permalink
have users enable the whitelist behavior explicitly
Browse files Browse the repository at this point in the history
Also, always use the default options when recording strokes
  • Loading branch information
thjaeger committed Sep 27, 2012
1 parent d0fbdbb commit 03dbbf7
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 27 deletions.
8 changes: 4 additions & 4 deletions actions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ void Actions::update_row(const Gtk::TreeRow &row) {
}

extern boost::shared_ptr<sigc::slot<void, RStroke> > stroke_action;
Source<ActionListDiff *> stroke_app(NULL);
Source<bool> recording(false);

class Actions::OnStroke {
Actions *parent;
Expand Down Expand Up @@ -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);
}
};

Expand Down Expand Up @@ -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<void, RStroke>(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;

Expand Down
31 changes: 15 additions & 16 deletions grabber.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
extern Window get_window(Window w, Atom prop);
extern Source<bool> disabled;
extern Source<Window> current_app_window;
extern Source<ActionListDiff *> stroke_app;
extern Source<bool> recording;
extern bool in_proximity;

Grabber *grabber = 0;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -511,20 +510,20 @@ guint Grabber::get_default_mods(guint button) {
}

void Grabber::update() {
std::map<std::string, RButtonInfo>::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<std::string, RButtonInfo>::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<ButtonInfo> &extra = prefs.extra_buttons.ref();
if (grabbed_button == bi && buttons.size() == extra.size() + 1 &&
std::equal(extra.begin(), extra.end(), ++buttons.begin())) {
Expand Down
30 changes: 25 additions & 5 deletions gui.glade
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,9 @@ Van Diep Duong (Vietnamese)</property>
<property name="height_request">120</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection2"/>
</child>
</object>
</child>
</object>
Expand Down Expand Up @@ -1501,6 +1504,23 @@ Van Diep Duong (Vietnamese)</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkCheckButton" id="check_whitelist">
<property name="label" translatable="yes">Only enable easystroke for applications listed on 'Actions' tab</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="check_timeout_gestures">
<property name="label" translatable="yes">Timeout Gestures</property>
Expand All @@ -1513,7 +1533,7 @@ Van Diep Duong (Vietnamese)</property>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
<property name="position">1</property>
</packing>
</child>
<child>
Expand Down Expand Up @@ -1555,7 +1575,7 @@ Van Diep Duong (Vietnamese)</property>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
<child>
Expand Down Expand Up @@ -1597,7 +1617,7 @@ Van Diep Duong (Vietnamese)</property>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="position">3</property>
</packing>
</child>
<child>
Expand Down Expand Up @@ -1650,7 +1670,7 @@ Van Diep Duong (Vietnamese)</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="padding">6</property>
<property name="position">3</property>
<property name="position">4</property>
</packing>
</child>
<child>
Expand All @@ -1665,7 +1685,7 @@ Van Diep Duong (Vietnamese)</property>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">4</property>
<property name="position">5</property>
</packing>
</child>
</object>
Expand Down
5 changes: 4 additions & 1 deletion prefdb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<class Archive> void PrefDB::serialize(Archive & ar, const unsigned int version) {
Expand Down Expand Up @@ -132,6 +133,8 @@ template<class Archive> 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() {
Expand Down
3 changes: 2 additions & 1 deletion prefdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,13 @@ class PrefDB : public TimeoutWatcher {
PrefSource<bool> show_osd;
PrefSource<bool> move_back;
PrefSource<std::map<std::string, TimeoutType> > device_timeout;
PrefSource<bool> whitelist;

void init();
virtual void timeout();
};

BOOST_CLASS_VERSION(PrefDB, 17)
BOOST_CLASS_VERSION(PrefDB, 18)

extern PrefDB prefs;

Expand Down
1 change: 1 addition & 0 deletions prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ Prefs::Prefs() {
new Adjustment<int>(prefs.trace_width, "adjustment_trace_width");
new Combo<TimeoutType>(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");
Expand Down

0 comments on commit 03dbbf7

Please sign in to comment.