logo

badwolf

minimalist and privacy-oriented web browser based on WebKitGTK git clone https://hacktivis.me/git/badwolf.git
commit: 9c5a0d2b96d928364621cdd6eec7b93b10afec7c
parent 9e8324381a639d0a2c85d7590dd5cf1bb84f8f4f
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue,  9 Apr 2019 15:11:22 +0200

badwolf.c: Add zoom on ctrl+scroll

Diffstat:

Mbadwolf.110+++++++++-
Mbadwolf.c21+++++++++++++++++++++
2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/badwolf.1 b/badwolf.1 @@ -18,7 +18,15 @@ Runtime configuration specific to .Nm will probably get added at a later release. .Sh KEYBINDINGS -For now it only has the default Webkit/GTK keybindings, which notably are (C for Control, S for Shift): +The following section lists the keybinding by their action, each item is described by the widget the focus is on or +.Aq any +if it works for the whole window, followed by the keybind it grabs. C is short for Control, S is short for Shift. +.Bl -width Ds -tag +.It webview C-Scroll +Zooms the webpage in/out. +.El +.Ss DEFAULT ONES +Here is a incomplete list of the default Webkit/GTK keybindings: .Bl -width Ds -tag .It any C-PageUp / C-PageDown Go to the previous/next tab diff --git a/badwolf.c b/badwolf.c @@ -322,6 +322,26 @@ WebViewCb_mouse_target_changed(WebKitWebView *webView, return TRUE; } +static gboolean +WebViewCb_scroll_event(GtkWidget *widget, GdkEvent *event, gpointer data) +{ + (void)widget; + struct Client *browser = (struct Client *)data; + gdouble delta_x, delta_y; + gfloat zoom; + + if(((GdkEventScroll *)event)->state & GDK_CONTROL_MASK) + { + gdk_event_get_scroll_deltas(event, &delta_x, &delta_y); + zoom = webkit_web_view_get_zoom_level(WEBKIT_WEB_VIEW(browser->webView)); + zoom -= delta_y * 0.1; + webkit_web_view_set_zoom_level(WEBKIT_WEB_VIEW(browser->webView), zoom); + return TRUE; + } + + return FALSE; +} + static WebKitWebView * WebViewCb_create(WebKitWebView *related_web_view, WebKitNavigationAction *navigation_action, @@ -517,6 +537,7 @@ new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web g_signal_connect(browser->webView, "close", G_CALLBACK(WebViewCb_close), browser); g_signal_connect( browser->webView, "key-press-event", G_CALLBACK(WebViewCb_key_press_event), browser); + g_signal_connect(browser->webView, "scroll-event", G_CALLBACK(WebViewCb_scroll_event), browser); g_signal_connect(browser->search, "next-match", G_CALLBACK(SearchEntryCb_next__match), browser); g_signal_connect(