From 9c5a0d2b96d928364621cdd6eec7b93b10afec7c Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Tue, 9 Apr 2019 15:11:22 +0200 Subject: badwolf.c: Add zoom on ctrl+scroll --- badwolf.1 | 10 +++++++++- badwolf.c | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/badwolf.1 b/badwolf.1 index e996fd1..76dab96 100644 --- 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 index 1fef34e..e8cd46a 100644 --- 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( -- cgit v1.3.1-23-gd82d From f57a127d718c116f0e11cb543fbcad2359df9c86 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 13 Apr 2019 20:57:35 +0200 Subject: badwolf.1: Add "search Escape" default binding --- badwolf.1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/badwolf.1 b/badwolf.1 index 76dab96..f039518 100644 --- a/badwolf.1 +++ b/badwolf.1 @@ -44,6 +44,8 @@ Reloads the current tab (with/without clearing cache) Go back/forward in current tab’s history .It search C-g / C-S-g When the search box is focused it goes to the Next/Previous search term. +.It search Escape +Cancels current search .El .Sh BUGS You can submit contributions or tickets to -- cgit v1.3.1-23-gd82d From 459d50c30cd1b14946ed16267b8417625d6246a9 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 11 May 2019 03:57:01 +0200 Subject: badwolf.c: C-0 resets zoom --- badwolf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/badwolf.c b/badwolf.c index e8cd46a..aac360b 100644 --- a/badwolf.c +++ b/badwolf.c @@ -116,6 +116,7 @@ commonCb_key_press_event(struct Window *window, GdkEvent *event, struct Client * case GDK_KEY_l: gtk_widget_grab_focus(browser->location); return TRUE; case GDK_KEY_bracketleft: webkit_web_view_go_back(browser->webView); return TRUE; case GDK_KEY_bracketright: webkit_web_view_go_forward(browser->webView); return TRUE; + case GDK_KEY_0: webkit_web_view_set_zoom_level(WEBKIT_WEB_VIEW(browser->webView), 1); return TRUE; } } else -- cgit v1.3.1-23-gd82d From 30a0219b792593e0c6a51d9659041ce9fcc005e8 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 27 Apr 2019 19:38:13 +0200 Subject: badwolf.c: Add Alt+{Left,Right} for history, Add F5 --- badwolf.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/badwolf.c b/badwolf.c index aac360b..35ce0eb 100644 --- a/badwolf.c +++ b/badwolf.c @@ -93,6 +93,15 @@ WebViewCb_close(WebKitWebView *webView, gpointer user_data) return TRUE; } +/* commonCb_key_press_event: Global callback for keybindings + * + * Theses shortcuts should be avoided as much as possible: + * - Single key shortcuts (ie. backspace and space) + * - Triple key shortcuts (except for Ctrl+Shift) + * - Unix Terminal shortcuts (specially Ctrl-W) + * + * loosely follows https://developer.gnome.org/hig/stable/keyboard-input.html + */ static gboolean commonCb_key_press_event(struct Window *window, GdkEvent *event, struct Client *browser) { @@ -129,6 +138,23 @@ commonCb_key_press_event(struct Window *window, GdkEvent *event, struct Client * } } } + if((((GdkEventKey *)event)->state & GDK_MOD1_MASK) && brower != NULL) + ) + { + switch(((GdkEventKey *)event)->keyval) + { + case GDK_KEY_Left: gtk_notebook_prev_page(notebook); return TRUE; + case GDK_KEY_Right: gtk_notebook_next_page(notebook); return TRUE; + } + } + + if(browser != NULL) + { + switch(((GdkEventKey *)event)->keyval) + { + case GDK_KEY_F5: webkit_web_view_reload(browser->webView); return TRUE; + } + } return FALSE; } -- cgit v1.3.1-23-gd82d