sites

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 4efc44794e029875f0d1dda1cc7bddbeff2a8b84
parent d08a10a4a1e3d70206dd35a2f2a61061d71abfad
Author: Quentin Rameau <quinq@fifth.space>
Date:   Mon, 24 Apr 2017 10:58:58 +0200

[surf] Update keycodes patch for surf-webkit2

Diffstat:
Msurf.suckless.org/patches/keycodes.md | 7++++---
Dsurf.suckless.org/patches/surf-git_keycodes.patch | 202-------------------------------------------------------------------------------
Asurf.suckless.org/patches/surf-webkit2-keycodes-20170424-5c52733.patch | 135+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 139 insertions(+), 205 deletions(-)

diff --git a/surf.suckless.org/patches/keycodes.md b/surf.suckless.org/patches/keycodes.md @@ -1,11 +1,12 @@ Keycodes ======== -With this patch, handling key input is done with keycodes instead of keysyms. -This way, input is keyboard layout independant (adapt config.h to your keyboard using for exemple xev). +With this patch, key input handling is done with keycodes instead of keysyms. +This way, input is independand from keyboard layout. +You can adapt config.h to your keyboard by looking up keycodes with, for exemple, xev. Download -------- -* [surf-git_keycodes.patch](surf-git_keycodes.patch) +* [surf-webkit2-keycodes-20170424-5c52733.patch](surf-webkit2-keycodes-20170424-5c52733.patch) Author ------ diff --git a/surf.suckless.org/patches/surf-git_keycodes.patch b/surf.suckless.org/patches/surf-git_keycodes.patch @@ -1,202 +0,0 @@ -From e012b0b35acd3ca68ee2992bee87ca018226d5d3 Mon Sep 17 00:00:00 2001 -From: Quentin Rameau <quinq@fifth.space> -Date: Thu, 2 Jul 2015 16:32:19 +0200 -Subject: [PATCH] Use keycodes instead of keyval - -Using keybard keycodes permits to have keyboard layout independant -key mapping. ---- - config.def.h | 88 ++++++++++++++++++++++++++++++------------------------------ - surf.c | 37 +++++++------------------ - 2 files changed, 54 insertions(+), 71 deletions(-) - -diff --git a/config.def.h b/config.def.h -index a1ab211..55e318e 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -81,50 +81,50 @@ static SiteStyle styles[] = { - * edit the CLEANMASK() macro. - */ - static Key keys[] = { -- /* modifier keyval function arg Focus */ -- { MODKEY|GDK_SHIFT_MASK,GDK_r, reload, { .b = TRUE } }, -- { MODKEY, GDK_r, reload, { .b = FALSE } }, -- { MODKEY|GDK_SHIFT_MASK,GDK_p, print, { 0 } }, -- -- { MODKEY, GDK_p, clipboard, { .b = TRUE } }, -- { MODKEY, GDK_y, clipboard, { .b = FALSE } }, -- -- { MODKEY|GDK_SHIFT_MASK,GDK_j, zoom, { .i = -1 } }, -- { MODKEY|GDK_SHIFT_MASK,GDK_k, zoom, { .i = +1 } }, -- { MODKEY|GDK_SHIFT_MASK,GDK_q, zoom, { .i = 0 } }, -- { MODKEY, GDK_minus, zoom, { .i = -1 } }, -- { MODKEY, GDK_plus, zoom, { .i = +1 } }, -- -- { MODKEY, GDK_l, navigate, { .i = +1 } }, -- { MODKEY, GDK_h, navigate, { .i = -1 } }, -- -- { MODKEY, GDK_j, scroll_v, { .i = +1 } }, -- { MODKEY, GDK_k, scroll_v, { .i = -1 } }, -- { MODKEY, GDK_b, scroll_v, { .i = -10000 } }, -- { MODKEY, GDK_space, scroll_v, { .i = +10000 } }, -- { MODKEY, GDK_i, scroll_h, { .i = +1 } }, -- { MODKEY, GDK_u, scroll_h, { .i = -1 } }, -- -- { 0, GDK_F11, fullscreen, { 0 } }, -- { 0, GDK_Escape, stop, { 0 } }, -- { MODKEY, GDK_o, source, { 0 } }, -- { MODKEY|GDK_SHIFT_MASK,GDK_o, inspector, { 0 } }, -- -- { MODKEY, GDK_g, spawn, SETPROP("_SURF_URI", "_SURF_GO") }, -- { MODKEY, GDK_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") }, -- { MODKEY, GDK_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") }, -- -- { MODKEY, GDK_n, find, { .b = TRUE } }, -- { MODKEY|GDK_SHIFT_MASK,GDK_n, find, { .b = FALSE } }, -- -- { MODKEY|GDK_SHIFT_MASK,GDK_c, toggle, { .v = "enable-caret-browsing" } }, -- { MODKEY|GDK_SHIFT_MASK,GDK_i, toggle, { .v = "auto-load-images" } }, -- { MODKEY|GDK_SHIFT_MASK,GDK_s, toggle, { .v = "enable-scripts" } }, -- { MODKEY|GDK_SHIFT_MASK,GDK_v, toggle, { .v = "enable-plugins" } }, -- { MODKEY|GDK_SHIFT_MASK,GDK_a, togglecookiepolicy, { 0 } }, -- { MODKEY|GDK_SHIFT_MASK,GDK_m, togglestyle, { 0 } }, -- { MODKEY|GDK_SHIFT_MASK,GDK_b, togglescrollbars, { 0 } }, -- { MODKEY|GDK_SHIFT_MASK,GDK_g, togglegeolocation, { 0 } }, -+ /* modifier keycode function arg Focus */ -+ { MODKEY|GDK_SHIFT_MASK, 27, reload, { .b = TRUE } }, // r -+ { MODKEY, 27, reload, { .b = FALSE } }, // r -+ { MODKEY|GDK_SHIFT_MASK, 33, print, { 0 } }, // p -+ -+ { MODKEY, 33, clipboard, { .b = TRUE } }, // p -+ { MODKEY, 29, clipboard, { .b = FALSE } }, // y -+ -+ { MODKEY|GDK_SHIFT_MASK, 44, zoom, { .i = -1 } }, // j -+ { MODKEY|GDK_SHIFT_MASK, 45, zoom, { .i = +1 } }, // k -+ { MODKEY|GDK_SHIFT_MASK, 24, zoom, { .i = 0 } }, // q -+ { MODKEY, 20, zoom, { .i = -1 } }, // - -+ { MODKEY, 21, zoom, { .i = +1 } }, // + -+ -+ { MODKEY, 46, navigate, { .i = +1 } }, // l -+ { MODKEY, 43, navigate, { .i = -1 } }, // h -+ -+ { MODKEY, 44, scroll_v, { .i = +1 } }, // j -+ { MODKEY, 45, scroll_v, { .i = -1 } }, // k -+ { MODKEY, 56, scroll_v, { .i = -1000 } }, // b -+ { MODKEY, 65, scroll_v, { .i = +1000 } }, // Space -+ { MODKEY, 31, scroll_h, { .i = +1 } }, // i -+ { MODKEY, 30, scroll_h, { .i = -1 } }, // u -+ -+ { 0, 95, fullscreen, { 0 } }, // F11 -+ { 0, 9, stop, { 0 } }, // Escape -+ { MODKEY, 32, source, { 0 } }, // o -+ { MODKEY|GDK_SHIFT_MASK, 32, inspector, { 0 } }, // o -+ -+ { MODKEY, 42, spawn, SETPROP("_SURF_URI", "_SURF_GO") }, // g -+ { MODKEY, 41, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") }, // f -+ { MODKEY, 61, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") }, // / -+ -+ { MODKEY, 57, find, { .b = TRUE } }, // n -+ { MODKEY|GDK_SHIFT_MASK, 57, find, { .b = FALSE } }, // n -+ -+ { MODKEY|GDK_SHIFT_MASK, 54, toggle, { .v = "enable-caret-browsing" } }, // c -+ { MODKEY|GDK_SHIFT_MASK, 31, toggle, { .v = "auto-load-images" } }, // i -+ { MODKEY|GDK_SHIFT_MASK, 39, toggle, { .v = "enable-scripts" } }, // s -+ { MODKEY|GDK_SHIFT_MASK, 55, toggle, { .v = "enable-plugins" } }, // v -+ { MODKEY|GDK_SHIFT_MASK, 38, togglecookiepolicy,{ 0 } }, // a -+ { MODKEY|GDK_SHIFT_MASK, 58, togglestyle,{ 0 } }, // m -+ { MODKEY|GDK_SHIFT_MASK, 56, togglescrollbars,{ 0 } }, // b -+ { MODKEY|GDK_SHIFT_MASK, 42, togglegeolocation,{ 0 } }, // g - }; - - /* button definitions */ -diff --git a/surf.c b/surf.c -index 87c10ef..f84c216 100644 ---- a/surf.c -+++ b/surf.c -@@ -65,7 +65,7 @@ typedef struct Client { - - typedef struct { - guint mod; -- guint keyval; -+ guint16 keycode; - void (*func)(Client *c, const Arg *arg); - const Arg arg; - } Key; -@@ -109,7 +109,6 @@ static int policysel = 0; - static char *stylefile = NULL; - static SoupCache *diskcache = NULL; - --static void addaccelgroup(Client *c); - static void beforerequest(WebKitWebView *w, WebKitWebFrame *f, - WebKitWebResource *r, WebKitNetworkRequest *req, - WebKitNetworkResponse *resp, Client *c); -@@ -165,9 +164,7 @@ static gboolean inspector_show(WebKitWebInspector *i, Client *c); - static gboolean inspector_close(WebKitWebInspector *i, Client *c); - static void inspector_finished(WebKitWebInspector *i, Client *c); - --static gboolean keypress(GtkAccelGroup *group, -- GObject *obj, guint key, GdkModifierType mods, -- Client *c); -+static gboolean keypress(GtkWidget *w, GdkEventKey *ev, Client *c); - static void linkhover(WebKitWebView *v, const char* t, const char* l, - Client *c); - static void loadstatuschange(WebKitWebView *view, GParamSpec *pspec, -@@ -214,20 +211,6 @@ static void zoom(Client *c, const Arg *arg); - #include "config.h" - - static void --addaccelgroup(Client *c) { -- int i; -- GtkAccelGroup *group = gtk_accel_group_new(); -- GClosure *closure; -- -- for(i = 0; i < LENGTH(keys); i++) { -- closure = g_cclosure_new(G_CALLBACK(keypress), c, NULL); -- gtk_accel_group_connect(group, keys[i].keyval, keys[i].mod, -- 0, closure); -- } -- gtk_window_add_accel_group(GTK_WINDOW(c->win), group); --} -- --static void - beforerequest(WebKitWebView *w, WebKitWebFrame *f, WebKitWebResource *r, - WebKitNetworkRequest *req, WebKitNetworkResponse *resp, - Client *c) { -@@ -674,17 +657,14 @@ inspector_finished(WebKitWebInspector *i, Client *c) { - } - - static gboolean --keypress(GtkAccelGroup *group, GObject *obj, -- guint key, GdkModifierType mods, Client *c) { -+keypress(GtkWidget *w, GdkEventKey *ev, Client *c) { - guint i; - gboolean processed = FALSE; - -- mods = CLEANMASK(mods); -- key = gdk_keyval_to_lower(key); - updatewinid(c); - for(i = 0; i < LENGTH(keys); i++) { -- if(key == keys[i].keyval -- && mods == keys[i].mod -+ if(ev->hardware_keycode == keys[i].keycode -+ && CLEANMASK(ev->state) == keys[i].mod - && keys[i].func) { - keys[i].func(c, &(keys[i].arg)); - processed = TRUE; -@@ -829,8 +809,11 @@ newclient(void) { - "leave_notify_event", - G_CALLBACK(titlechangeleave), c); - -- if(!kioskmode) -- addaccelgroup(c); -+ if(!kioskmode) { -+ g_signal_connect(G_OBJECT(c->win), -+ "key-press-event", -+ G_CALLBACK(keypress), c); -+ } - - /* Pane */ - c->pane = gtk_vpaned_new(); --- -2.4.5 - diff --git a/surf.suckless.org/patches/surf-webkit2-keycodes-20170424-5c52733.patch b/surf.suckless.org/patches/surf-webkit2-keycodes-20170424-5c52733.patch @@ -0,0 +1,135 @@ +diff --git a/config.def.h b/config.def.h +index dce76f8..c63f57e 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -103,58 +103,58 @@ static SiteStyle styles[] = { + * edit the CLEANMASK() macro. + */ + static Key keys[] = { +- /* modifier keyval function arg */ +- { MODKEY, GDK_KEY_g, spawn, SETPROP("_SURF_URI", "_SURF_GO") }, +- { MODKEY, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") }, +- { MODKEY, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") }, ++ /* modifier keycode function arg */ ++ { MODKEY, 42, spawn, SETPROP("_SURF_URI", "_SURF_GO") }, ++ { MODKEY, 41, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") }, ++ { MODKEY, 61, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") }, + +- { 0, GDK_KEY_Escape, stop, { 0 } }, +- { MODKEY, GDK_KEY_c, stop, { 0 } }, ++ { 0, 9, stop, { 0 } }, ++ { MODKEY, 54, stop, { 0 } }, + +- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_r, reload, { .b = 1 } }, +- { MODKEY, GDK_KEY_r, reload, { .b = 0 } }, ++ { MODKEY|GDK_SHIFT_MASK, 27, reload, { .b = 1 } }, ++ { MODKEY, 27, reload, { .b = 0 } }, + +- { MODKEY, GDK_KEY_l, navigate, { .i = +1 } }, +- { MODKEY, GDK_KEY_h, navigate, { .i = -1 } }, ++ { MODKEY, 46, navigate, { .i = +1 } }, ++ { MODKEY, 43, navigate, { .i = -1 } }, + + /* Currently we have to use scrolling steps that WebKit2GTK+ gives us + * d: step down, u: step up, r: step right, l:step left + * D: page down, U: page up */ +- { MODKEY, GDK_KEY_j, scroll, { .i = 'd' } }, +- { MODKEY, GDK_KEY_k, scroll, { .i = 'u' } }, +- { MODKEY, GDK_KEY_b, scroll, { .i = 'U' } }, +- { MODKEY, GDK_KEY_space, scroll, { .i = 'D' } }, +- { MODKEY, GDK_KEY_i, scroll, { .i = 'r' } }, +- { MODKEY, GDK_KEY_u, scroll, { .i = 'l' } }, +- +- +- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } }, +- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_k, zoom, { .i = +1 } }, +- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_q, zoom, { .i = 0 } }, +- { MODKEY, GDK_KEY_minus, zoom, { .i = -1 } }, +- { MODKEY, GDK_KEY_plus, zoom, { .i = +1 } }, +- +- { MODKEY, GDK_KEY_p, clipboard, { .b = 1 } }, +- { MODKEY, GDK_KEY_y, clipboard, { .b = 0 } }, +- +- { MODKEY, GDK_KEY_n, find, { .i = +1 } }, +- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } }, +- +- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_p, print, { 0 } }, +- +- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_a, togglecookiepolicy, { 0 } }, +- { 0, GDK_KEY_F11, togglefullscreen, { 0 } }, +- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_o, toggleinspector, { 0 } }, +- +- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_c, toggle, { .i = CaretBrowsing } }, +- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_f, toggle, { .i = FrameFlattening } }, +- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_g, toggle, { .i = Geolocation } }, +- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_s, toggle, { .i = JavaScript } }, +- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_i, toggle, { .i = LoadImages } }, +- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_v, toggle, { .i = Plugins } }, +- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_b, toggle, { .i = ScrollBars } }, +- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_t, toggle, { .i = StrictTLS } }, +- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_m, toggle, { .i = Style } }, ++ { MODKEY, 44, scroll, { .i = 'd' } }, ++ { MODKEY, 45, scroll, { .i = 'u' } }, ++ { MODKEY, 56, scroll, { .i = 'U' } }, ++ { MODKEY, 65, scroll, { .i = 'D' } }, ++ { MODKEY, 31, scroll, { .i = 'r' } }, ++ { MODKEY, 30, scroll, { .i = 'l' } }, ++ ++ ++ { MODKEY|GDK_SHIFT_MASK, 44, zoom, { .i = -1 } }, ++ { MODKEY|GDK_SHIFT_MASK, 45, zoom, { .i = +1 } }, ++ { MODKEY|GDK_SHIFT_MASK, 24, zoom, { .i = 0 } }, ++ { MODKEY, 20, zoom, { .i = -1 } }, ++ { MODKEY, 21, zoom, { .i = +1 } }, ++ ++ { MODKEY, 33, clipboard, { .b = 1 } }, ++ { MODKEY, 29, clipboard, { .b = 0 } }, ++ ++ { MODKEY, 57, find, { .i = +1 } }, ++ { MODKEY|GDK_SHIFT_MASK, 57, find, { .i = -1 } }, ++ ++ { MODKEY|GDK_SHIFT_MASK, 33, print, { 0 } }, ++ ++ { MODKEY|GDK_SHIFT_MASK, 38, togglecookiepolicy, { 0 } }, ++ { 0, 95, togglefullscreen, { 0 } }, ++ { MODKEY|GDK_SHIFT_MASK, 32, toggleinspector, { 0 } }, ++ ++ { MODKEY|GDK_SHIFT_MASK, 54, toggle, { .i = CaretBrowsing } }, ++ { MODKEY|GDK_SHIFT_MASK, 41, toggle, { .i = FrameFlattening } }, ++ { MODKEY|GDK_SHIFT_MASK, 42, toggle, { .i = Geolocation } }, ++ { MODKEY|GDK_SHIFT_MASK, 39, toggle, { .i = JavaScript } }, ++ { MODKEY|GDK_SHIFT_MASK, 31, toggle, { .i = LoadImages } }, ++ { MODKEY|GDK_SHIFT_MASK, 55, toggle, { .i = Plugins } }, ++ { MODKEY|GDK_SHIFT_MASK, 56, toggle, { .i = ScrollBars } }, ++ { MODKEY|GDK_SHIFT_MASK, 28, toggle, { .i = StrictTLS } }, ++ { MODKEY|GDK_SHIFT_MASK, 58, toggle, { .i = Style } }, + }; + + /* button definitions */ +diff --git a/surf.c b/surf.c +index 9f0c8a1..07a362c 100644 +--- a/surf.c ++++ b/surf.c +@@ -114,7 +114,7 @@ typedef struct Client { + + typedef struct { + guint mod; +- guint keyval; ++ guint16 keycode; + void (*func)(Client *c, const Arg *a); + const Arg arg; + } Key; +@@ -1118,10 +1118,9 @@ winevent(GtkWidget *w, GdkEvent *e, Client *c) + case GDK_KEY_PRESS: + if (!curconfig[KioskMode].val.b) { + for (i = 0; i < LENGTH(keys); ++i) { +- if (gdk_keyval_to_lower(e->key.keyval) == +- keys[i].keyval && +- CLEANMASK(e->key.state) == keys[i].mod && +- keys[i].func) { ++ if (e->key.hardware_keycode == keys[i].keycode ++ && CLEANMASK(e->key.state) == keys[i].mod ++ && keys[i].func) { + updatewinid(c); + keys[i].func(c, &(keys[i].arg)); + return TRUE;