Allow to set scroll-multiplier #602.
authorDaniel Carl <danielcarl@gmx.de>
Sat, 29 Feb 2020 00:03:31 +0000 (01:03 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Sat, 29 Feb 2020 00:03:31 +0000 (01:03 +0100)
doc/vimb.1
src/main.c
src/main.h
src/setting.c

index 9861af4..1534d4d 100644 (file)
@@ -1416,6 +1416,10 @@ Determines whether or not JavaScript executes within a page.
 .B scroll-step (int)
 Number of pixel vimb scrolls if 'j' or 'k' is used.
 .TP
+.B scroll-multiplier (int)
+Multiplier to increase the scroll distance if window is scrolled by mouse
+wheel.
+.TP
 .B serif-font (string)
 The font family used as the default for content using serif font.
 .TP
index 9fdae1a..384ff3c 100644 (file)
@@ -116,6 +116,7 @@ static WebKitWebView *webview_new(Client *c, WebKitWebView *webview);
 static void on_counted_matches(WebKitFindController *finder, guint count, Client *c);
 static gboolean on_permission_request(WebKitWebView *webview,
         WebKitPermissionRequest *request, Client *c);
+static gboolean on_scroll(WebKitWebView *webview, GdkEvent *event, Client *c);
 static void on_script_message_focus(WebKitUserContentManager *manager,
         WebKitJavascriptResult *res, gpointer data);
 static gboolean profileOptionArgFunc(const gchar *option_name,
@@ -1999,6 +2000,7 @@ static WebKitWebView *webview_new(Client *c, WebKitWebView *webview)
         "signal::notify::title", G_CALLBACK(on_webview_notify_title), c,
         "signal::notify::uri", G_CALLBACK(on_webview_notify_uri), c,
         "signal::permission-request", G_CALLBACK(on_permission_request), c,
+        "signal::scroll-event", G_CALLBACK(on_scroll), c,
         "signal::ready-to-show", G_CALLBACK(on_webview_ready_to_show), c,
         "signal::web-process-crashed", G_CALLBACK(on_webview_web_process_crashed), c,
         "signal::authenticate", G_CALLBACK(on_webview_authenticate), c,
@@ -2067,6 +2069,12 @@ static gboolean on_permission_request(WebKitWebView *webview,
     return TRUE;
 }
 
+static gboolean on_scroll(WebKitWebView *webview, GdkEvent *event, Client *c)
+{
+    event->scroll.delta_y *= c->config.scrollmultiplier;
+    return FALSE;
+}
+
 static void on_script_message_focus(WebKitUserContentManager *manager,
         WebKitJavascriptResult *res, gpointer data)
 {
index 1c04e3a..739bd39 100644 (file)
@@ -248,6 +248,7 @@ struct Client {
          * client base. */
         GHashTable              *settings;
         guint                   scrollstep;
+        guint                   scrollmultiplier;
         gboolean                input_autohide;
         gboolean                incsearch;
         gboolean                prevent_newwindow;
index 6228417..e5f517e 100644 (file)
@@ -139,6 +139,8 @@ void setting_init(Client *c)
     setting_add(c, "cookie-accept", TYPE_CHAR, &"always", cookie_accept, 0, NULL);
     i = 40;
     setting_add(c, "scroll-step", TYPE_INTEGER, &i, internal, 0, &c->config.scrollstep);
+    i = 1;
+    setting_add(c, "scroll-multiplier", TYPE_INTEGER, &i, internal, 0, &c->config.scrollmultiplier);
     setting_add(c, "home-page", TYPE_CHAR, &SETTING_HOME_PAGE, NULL, 0, NULL);
     i = 2000;
     /* TODO should be global and not overwritten by a new client */