mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
AModule: handle X axis scrolling
This commit is contained in:
parent
90a9c0e25f
commit
7f13478396
@ -33,7 +33,8 @@ class AModule : public IModule {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<int> pid_;
|
std::vector<int> pid_;
|
||||||
gdouble distance_scrolled_;
|
gdouble distance_scrolled_y_;
|
||||||
|
gdouble distance_scrolled_x_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace waybar
|
} // namespace waybar
|
||||||
|
@ -65,23 +65,28 @@ AModule::SCROLL_DIR AModule::getScrollDir(GdkEventScroll* e) {
|
|||||||
} else if (e->direction == GDK_SCROLL_SMOOTH) {
|
} else if (e->direction == GDK_SCROLL_SMOOTH) {
|
||||||
gdouble delta_x, delta_y;
|
gdouble delta_x, delta_y;
|
||||||
gdk_event_get_scroll_deltas(reinterpret_cast<const GdkEvent*>(e), &delta_x, &delta_y);
|
gdk_event_get_scroll_deltas(reinterpret_cast<const GdkEvent*>(e), &delta_x, &delta_y);
|
||||||
distance_scrolled_ += delta_y;
|
distance_scrolled_y_ += delta_y;
|
||||||
// TODO: handle X axis
|
distance_scrolled_x_ += delta_x;
|
||||||
|
|
||||||
gdouble threshold = 0;
|
gdouble threshold = 0;
|
||||||
if (config_["smooth-scrolling-threshold"].isNumeric()) {
|
if (config_["smooth-scrolling-threshold"].isNumeric()) {
|
||||||
threshold = config_["smooth-scrolling-threshold"].asDouble();
|
threshold = config_["smooth-scrolling-threshold"].asDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (distance_scrolled_ < -threshold) {
|
if (distance_scrolled_y_ < -threshold) {
|
||||||
dir = SCROLL_DIR::UP;
|
dir = SCROLL_DIR::UP;
|
||||||
} else if (distance_scrolled_ > threshold) {
|
} else if (distance_scrolled_y_ > threshold) {
|
||||||
dir = SCROLL_DIR::DOWN;
|
dir = SCROLL_DIR::DOWN;
|
||||||
|
} else if (distance_scrolled_x_ > threshold) {
|
||||||
|
dir = SCROLL_DIR::RIGHT;
|
||||||
|
} else if (distance_scrolled_x_ < -threshold) {
|
||||||
|
dir = SCROLL_DIR::LEFT;
|
||||||
}
|
}
|
||||||
if (abs(distance_scrolled_) > threshold) {
|
|
||||||
distance_scrolled_ = 0;
|
if (dir == SCROLL_DIR::UP || dir == SCROLL_DIR::DOWN) {
|
||||||
} else {
|
distance_scrolled_y_ = 0;
|
||||||
// Don't execute the action if we haven't met the threshold!
|
} else if (dir == SCROLL_DIR::LEFT || dir == SCROLL_DIR::RIGHT) {
|
||||||
return SCROLL_DIR::NONE;
|
distance_scrolled_x_ = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return dir;
|
return dir;
|
||||||
|
Loading…
Reference in New Issue
Block a user