Cleanup on clean branch (#391)

Cleanup on clean branch
This commit is contained in:
Alex 2019-06-18 09:43:34 +02:00 committed by GitHub
commit bcf4725349
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 39 additions and 32 deletions

View File

@ -53,43 +53,50 @@ bool AModule::handleToggle(GdkEventButton* const& e) {
} }
AModule::SCROLL_DIR AModule::getScrollDir(GdkEventScroll* e) { AModule::SCROLL_DIR AModule::getScrollDir(GdkEventScroll* e) {
SCROLL_DIR dir{SCROLL_DIR::NONE}; switch (e -> direction) {
if (e->direction == GDK_SCROLL_UP) { case GDK_SCROLL_UP: return SCROLL_DIR::UP;
dir = SCROLL_DIR::UP; case GDK_SCROLL_DOWN: return SCROLL_DIR::DOWN;
} else if (e->direction == GDK_SCROLL_DOWN) { case GDK_SCROLL_LEFT: return SCROLL_DIR::LEFT;
dir = SCROLL_DIR::DOWN; case GDK_SCROLL_RIGHT: return SCROLL_DIR::RIGHT;
} else if (e->direction == GDK_SCROLL_LEFT) { case GDK_SCROLL_SMOOTH: {
dir = SCROLL_DIR::LEFT; SCROLL_DIR dir{SCROLL_DIR::NONE};
} else if (e->direction == GDK_SCROLL_RIGHT) {
dir = SCROLL_DIR::RIGHT;
} else if (e->direction == GDK_SCROLL_SMOOTH) {
gdouble delta_x, delta_y;
gdk_event_get_scroll_deltas(reinterpret_cast<const GdkEvent*>(e), &delta_x, &delta_y);
distance_scrolled_y_ += delta_y;
distance_scrolled_x_ += delta_x;
gdouble threshold = 0; distance_scrolled_y_ += e->delta_y;
if (config_["smooth-scrolling-threshold"].isNumeric()) { distance_scrolled_x_ += e->delta_x;
threshold = config_["smooth-scrolling-threshold"].asDouble();
}
if (distance_scrolled_y_ < -threshold) { gdouble threshold = 0;
dir = SCROLL_DIR::UP; if (config_["smooth-scrolling-threshold"].isNumeric()) {
} else if (distance_scrolled_y_ > threshold) { threshold = config_["smooth-scrolling-threshold"].asDouble();
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 (dir == SCROLL_DIR::UP || dir == SCROLL_DIR::DOWN) { if (distance_scrolled_y_ < -threshold) {
distance_scrolled_y_ = 0; dir = SCROLL_DIR::UP;
} else if (dir == SCROLL_DIR::LEFT || dir == SCROLL_DIR::RIGHT) { } else if (distance_scrolled_y_ > threshold) {
distance_scrolled_x_ = 0; dir = SCROLL_DIR::DOWN;
} else if (distance_scrolled_x_ > threshold) {
dir = SCROLL_DIR::RIGHT;
} else if (distance_scrolled_x_ < -threshold) {
dir = SCROLL_DIR::LEFT;
}
switch (dir) {
case SCROLL_DIR::UP:
case SCROLL_DIR::DOWN:
distance_scrolled_y_ = 0;
break;
case SCROLL_DIR::LEFT:
case SCROLL_DIR::RIGHT:
distance_scrolled_x_ = 0;
break;
case SCROLL_DIR::NONE:
break;
}
return dir;
} }
// Silence -Wreturn-type:
default: return SCROLL_DIR::NONE;
} }
return dir;
} }
bool AModule::handleScroll(GdkEventScroll* e) { bool AModule::handleScroll(GdkEventScroll* e) {