Skip to content

Commit

Permalink
In smooth scrolling mode for buttons 4-7 allow movement only in one a…
Browse files Browse the repository at this point in the history
…xis at time.

Don't emit h-scroll events during v-scroll.
Fixes github #19.
  • Loading branch information
p2rkw committed Jan 30, 2017
1 parent eb3b9c3 commit bbecd2d
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/gestures.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,21 @@ static int trigger_swipe_unsafe(struct Gestures* gs,
/* Special case for smooth scrolling */
if(cfg->scroll_smooth && button >= 4 && button <= 7){
/* Calculate speed vector */
gs->scroll_speed_x = avg_move_x /(double)timertoms(&gs->dt);
gs->scroll_speed_y = avg_move_y /(double)timertoms(&gs->dt);
/* Forbid perpendicular movement: this conditions will disable h-scroll
* while v-scroll is active. See Github #19 */
if(dir == TR_DIR_UP || dir == TR_DIR_DN){
gs->scroll_speed_x = 0.0;
gs->scroll_speed_y = avg_move_y / (double)timertoms(&gs->dt);
}
else if(dir == TR_DIR_LT || dir == TR_DIR_RT){
gs->scroll_speed_x = avg_move_x / (double)timertoms(&gs->dt);
gs->scroll_speed_y = 0.0;
}
else{
xf86Msg(X_INFO, "smooth scrolling: 'dir' not generalized or TR_NONE\n");
gs->scroll_speed_y = gs->scroll_speed_x = 0.0;
}

gs->scroll_speed_valid = 1;
LOG_DEBUG_GESTURES("smooth scrolling: speed: x: %lf, y: %lf\n", gs->scroll_speed_x, gs->scroll_speed_y);
/* Reset coasting duration 'to go' ticks. */
Expand Down

0 comments on commit bbecd2d

Please sign in to comment.