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) {
SCROLL_DIR dir{SCROLL_DIR::NONE};
if (e->direction == GDK_SCROLL_UP) {
dir = SCROLL_DIR::UP;
} else if (e->direction == GDK_SCROLL_DOWN) {
dir = SCROLL_DIR::DOWN;
} else if (e->direction == GDK_SCROLL_LEFT) {
dir = SCROLL_DIR::LEFT;
} 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;
switch (e -> direction) {
case GDK_SCROLL_UP: return SCROLL_DIR::UP;
case GDK_SCROLL_DOWN: return SCROLL_DIR::DOWN;
case GDK_SCROLL_LEFT: return SCROLL_DIR::LEFT;
case GDK_SCROLL_RIGHT: return SCROLL_DIR::RIGHT;
case GDK_SCROLL_SMOOTH: {
SCROLL_DIR dir{SCROLL_DIR::NONE};
gdouble threshold = 0;
if (config_["smooth-scrolling-threshold"].isNumeric()) {
threshold = config_["smooth-scrolling-threshold"].asDouble();
}
distance_scrolled_y_ += e->delta_y;
distance_scrolled_x_ += e->delta_x;
if (distance_scrolled_y_ < -threshold) {
dir = SCROLL_DIR::UP;
} else if (distance_scrolled_y_ > threshold) {
dir = SCROLL_DIR::DOWN;
} else if (distance_scrolled_x_ > threshold) {
dir = SCROLL_DIR::RIGHT;
} else if (distance_scrolled_x_ < -threshold) {
dir = SCROLL_DIR::LEFT;
}
gdouble threshold = 0;
if (config_["smooth-scrolling-threshold"].isNumeric()) {
threshold = config_["smooth-scrolling-threshold"].asDouble();
}
if (dir == SCROLL_DIR::UP || dir == SCROLL_DIR::DOWN) {
distance_scrolled_y_ = 0;
} else if (dir == SCROLL_DIR::LEFT || dir == SCROLL_DIR::RIGHT) {
distance_scrolled_x_ = 0;
if (distance_scrolled_y_ < -threshold) {
dir = SCROLL_DIR::UP;
} else if (distance_scrolled_y_ > threshold) {
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) {