From: Daniel Carl Date: Sat, 29 Feb 2020 00:03:31 +0000 (+0100) Subject: Allow to set scroll-multiplier #602. X-Git-Url: https://git.owens.tech/rss.xml/rss.xml/git?a=commitdiff_plain;h=a212b513c7354ec2a41acb680e30d085fe7f3347;p=vimb.git Allow to set scroll-multiplier #602. --- diff --git a/doc/vimb.1 b/doc/vimb.1 index 9861af4..1534d4d 100644 --- a/doc/vimb.1 +++ b/doc/vimb.1 @@ -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 diff --git a/src/main.c b/src/main.c index 9fdae1a..384ff3c 100644 --- a/src/main.c +++ b/src/main.c @@ -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) { diff --git a/src/main.h b/src/main.h index 1c04e3a..739bd39 100644 --- a/src/main.h +++ b/src/main.h @@ -248,6 +248,7 @@ struct Client { * client base. */ GHashTable *settings; guint scrollstep; + guint scrollmultiplier; gboolean input_autohide; gboolean incsearch; gboolean prevent_newwindow; diff --git a/src/setting.c b/src/setting.c index 6228417..e5f517e 100644 --- a/src/setting.c +++ b/src/setting.c @@ -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 */