From 55a4b2cef4baafd3a30d98c9f1bda42c6b2f72d6 Mon Sep 17 00:00:00 2001
From: Cedric Roux <cedric.roux@eurecom.fr>
Date: Thu, 19 May 2016 18:01:06 +0200
Subject: [PATCH] scroll view/time.c if control+mouse wheel

---
 common/utils/T/tracer/view/time.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/common/utils/T/tracer/view/time.c b/common/utils/T/tracer/view/time.c
index 546491edab..b307d3a592 100644
--- a/common/utils/T/tracer/view/time.c
+++ b/common/utils/T/tracer/view/time.c
@@ -159,15 +159,34 @@ static void scroll(void *private, gui *g,
   struct time *this = private;
   int *d = notification_data;
   int x = d[0];
+  int key_modifiers = d[2];
   double mul = 1.2;
   double pixel_length;
   int64_t old_px_len_rounded;
   struct timespec t;
+  int scroll_px;
+  int width;
 
   if (pthread_mutex_lock(&this->lock)) abort();
 
   old_px_len_rounded = this->pixel_length;
 
+  /* scroll if control+wheel, zoom otherwise */
+
+  if (key_modifiers & KEY_CONTROL) {
+    timeline_get_width(this->g, this->w, &width);
+    if (width < 2) width = 2;
+    scroll_px = 100;
+    if (scroll_px > width - 1) scroll_px = width - 1;
+    if (!strcmp(notification, "scrolldown"))
+      this->start_time = time_add(this->start_time,
+          nano_to_time(scroll_px * old_px_len_rounded));
+    else
+      this->start_time = time_sub(this->start_time,
+          nano_to_time(scroll_px * old_px_len_rounded));
+    goto end;
+  }
+
   if (!strcmp(notification, "scrollup")) mul = 1 / mul;
 
 again:
@@ -191,6 +210,7 @@ again:
   t = time_add(this->start_time, nano_to_time(x * old_px_len_rounded));
   this->start_time = time_sub(t, nano_to_time(x * (int64_t)pixel_length));
 
+end:
   if (pthread_mutex_unlock(&this->lock)) abort();
 }
 
-- 
GitLab