Skip to content

Commit

Permalink
refactor(cursor): Include double clicks and fix scroll to click changes
Browse files Browse the repository at this point in the history
  • Loading branch information
NBonaparte committed Sep 17, 2017
1 parent 81c83c4 commit f91df60
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/components/bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,20 +616,15 @@ void bar::handle(const evt::motion_notify& evt) {
// scroll cursor is less important than click cursor, so we shouldn't return until we are sure there is no click action
bool found_scroll = false;
const auto find_click_area = [&](const action& action) {
if (!m_opts.cursor_click.empty() &&
(action.button == mousebtn::LEFT || action.button == mousebtn::MIDDLE || action.button == mousebtn::RIGHT)) {
if (!m_opts.cursor_click.empty() && !(action.button == mousebtn::SCROLL_UP || action.button == mousebtn::SCROLL_DOWN || action.button == mousebtn::NONE)) {
if (!string_util::compare(m_opts.cursor, m_opts.cursor_click)) {
m_opts.cursor = m_opts.cursor_click;
m_sig.emit(cursor_change{string{m_opts.cursor}});
}
return true;
} else if (!m_opts.cursor_scroll.empty() && (action.button == mousebtn::SCROLL_UP || action.button == mousebtn::SCROLL_DOWN)) {
} else if (!m_opts.cursor_scroll.empty() && action.button != mousebtn::NONE) {
if (!found_scroll) {
if (!string_util::compare(m_opts.cursor, m_opts.cursor_scroll)) {
found_scroll = true;
} else {
return true;
}
}
}
return false;
Expand All @@ -643,8 +638,10 @@ void bar::handle(const evt::motion_notify& evt) {
}
}
if(found_scroll) {
m_opts.cursor = m_opts.cursor_scroll;
m_sig.emit(cursor_change{string{m_opts.cursor}});
if (!string_util::compare(m_opts.cursor, m_opts.cursor_scroll)) {
m_opts.cursor = m_opts.cursor_scroll;
m_sig.emit(cursor_change{string{m_opts.cursor}});
}
return;
}
for (auto&& action : m_opts.actions) {
Expand All @@ -655,8 +652,10 @@ void bar::handle(const evt::motion_notify& evt) {
}
}
if(found_scroll) {
m_opts.cursor = m_opts.cursor_scroll;
m_sig.emit(cursor_change{string{m_opts.cursor}});
if (!string_util::compare(m_opts.cursor, m_opts.cursor_scroll)) {
m_opts.cursor = m_opts.cursor_scroll;
m_sig.emit(cursor_change{string{m_opts.cursor}});
}
return;
}
if (!string_util::compare(m_opts.cursor, "default")) {
Expand Down

0 comments on commit f91df60

Please sign in to comment.