sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

surf-webkit1-keycodes-20170424-9ba143b.diff (8155B)


      1 diff --git a/config.def.h b/config.def.h
      2 index 5996854..0b55189 100644
      3 --- a/config.def.h
      4 +++ b/config.def.h
      5 @@ -83,51 +83,51 @@ static SiteStyle styles[] = {
      6   * edit the CLEANMASK() macro.
      7   */
      8  static Key keys[] = {
      9 -	/* modifier             keyval      function    arg             Focus */
     10 -	{ MODKEY|GDK_SHIFT_MASK,GDK_r,      reload,     { .b = TRUE } },
     11 -	{ MODKEY,               GDK_r,      reload,     { .b = FALSE } },
     12 -	{ MODKEY|GDK_SHIFT_MASK,GDK_p,      print,      { 0 } },
     13 -
     14 -	{ MODKEY,               GDK_p,      clipboard,  { .b = TRUE } },
     15 -	{ MODKEY,               GDK_y,      clipboard,  { .b = FALSE } },
     16 -
     17 -	{ MODKEY|GDK_SHIFT_MASK,GDK_j,      zoom,       { .i = -1 } },
     18 -	{ MODKEY|GDK_SHIFT_MASK,GDK_k,      zoom,       { .i = +1 } },
     19 -	{ MODKEY|GDK_SHIFT_MASK,GDK_q,      zoom,       { .i = 0  } },
     20 -	{ MODKEY,               GDK_minus,  zoom,       { .i = -1 } },
     21 -	{ MODKEY,               GDK_plus,   zoom,       { .i = +1 } },
     22 -
     23 -	{ MODKEY,               GDK_l,      navigate,   { .i = +1 } },
     24 -	{ MODKEY,               GDK_h,      navigate,   { .i = -1 } },
     25 -
     26 -	{ MODKEY,               GDK_j,      scroll_v,   { .i = +1 } },
     27 -	{ MODKEY,               GDK_k,      scroll_v,   { .i = -1 } },
     28 -	{ MODKEY,               GDK_b,      scroll_v,   { .i = -10000 } },
     29 -	{ MODKEY,               GDK_space,  scroll_v,   { .i = +10000 } },
     30 -	{ MODKEY,               GDK_i,      scroll_h,   { .i = +1 } },
     31 -	{ MODKEY,               GDK_u,      scroll_h,   { .i = -1 } },
     32 -
     33 -	{ 0,                    GDK_F11,    fullscreen, { 0 } },
     34 -	{ 0,                    GDK_Escape, stop,       { 0 } },
     35 -	{ MODKEY,               GDK_o,      source,     { 0 } },
     36 -	{ MODKEY|GDK_SHIFT_MASK,GDK_o,      inspector,  { 0 } },
     37 -
     38 -	{ MODKEY,               GDK_g,      spawn,      SETPROP("_SURF_URI", "_SURF_GO") },
     39 -	{ MODKEY,               GDK_f,      spawn,      SETPROP("_SURF_FIND", "_SURF_FIND") },
     40 -	{ MODKEY,               GDK_slash,  spawn,      SETPROP("_SURF_FIND", "_SURF_FIND") },
     41 -
     42 -	{ MODKEY,               GDK_n,      find,       { .b = TRUE } },
     43 -	{ MODKEY|GDK_SHIFT_MASK,GDK_n,      find,       { .b = FALSE } },
     44 -
     45 -	{ MODKEY|GDK_SHIFT_MASK,GDK_c,      toggle,     { .v = "enable-caret-browsing" } },
     46 -	{ MODKEY|GDK_SHIFT_MASK,GDK_i,      toggle,     { .v = "auto-load-images" } },
     47 -	{ MODKEY|GDK_SHIFT_MASK,GDK_s,      toggle,     { .v = "enable-scripts" } },
     48 -	{ MODKEY|GDK_SHIFT_MASK,GDK_v,      toggle,     { .v = "enable-plugins" } },
     49 -	{ MODKEY|GDK_SHIFT_MASK,GDK_a,      togglecookiepolicy, { 0 } },
     50 -	{ MODKEY|GDK_SHIFT_MASK,GDK_m,      togglestyle, { 0 } },
     51 -	{ MODKEY|GDK_SHIFT_MASK,GDK_b,      togglescrollbars, { 0 } },
     52 -	{ MODKEY|GDK_SHIFT_MASK,GDK_g,      togglegeolocation, { 0 } },
     53 -	{ MODKEY|GDK_SHIFT_MASK,GDK_y,      toggleproxy, { 0 } },
     54 +	/* modifier              keyval   function    arg           Focus */
     55 +	{ MODKEY|GDK_SHIFT_MASK, 27,      reload,     { .b = TRUE } },
     56 +	{ MODKEY,                27,      reload,     { .b = FALSE } },
     57 +	{ MODKEY|GDK_SHIFT_MASK, 33,      print,      { 0 } },
     58 +
     59 +	{ MODKEY,                33,      clipboard,  { .b = TRUE } },
     60 +	{ MODKEY,                29,      clipboard,  { .b = FALSE } },
     61 +
     62 +	{ MODKEY|GDK_SHIFT_MASK, 44,      zoom,       { .i = -1 } },
     63 +	{ MODKEY|GDK_SHIFT_MASK, 45,      zoom,       { .i = +1 } },
     64 +	{ MODKEY|GDK_SHIFT_MASK, 24,      zoom,       { .i = 0  } },
     65 +	{ MODKEY,                20,      zoom,       { .i = -1 } },
     66 +	{ MODKEY,                21,      zoom,       { .i = +1 } },
     67 +
     68 +	{ MODKEY,                46,      navigate,   { .i = +1 } },
     69 +	{ MODKEY,                43,      navigate,   { .i = -1 } },
     70 +
     71 +	{ MODKEY,                44,      scroll_v,   { .i = +1 } },
     72 +	{ MODKEY,                45,      scroll_v,   { .i = -1 } },
     73 +	{ MODKEY,                56,      scroll_v,   { .i = -10000 } },
     74 +	{ MODKEY,                65,      scroll_v,   { .i = +10000 } },
     75 +	{ MODKEY,                31,      scroll_h,   { .i = +1 } },
     76 +	{ MODKEY,                30,      scroll_h,   { .i = -1 } },
     77 +
     78 +	{ 0,                     95,      fullscreen, { 0 } },
     79 +	{ 0,                     9,       stop,       { 0 } },
     80 +	{ MODKEY,                32,      source,     { 0 } },
     81 +	{ MODKEY|GDK_SHIFT_MASK, 32,      inspector,  { 0 } },
     82 +
     83 +	{ MODKEY,                42,      spawn,      SETPROP("_SURF_URI", "_SURF_GO") },
     84 +	{ MODKEY,                41,      spawn,      SETPROP("_SURF_FIND", "_SURF_FIND") },
     85 +	{ MODKEY,                61,      spawn,      SETPROP("_SURF_FIND", "_SURF_FIND") },
     86 +
     87 +	{ MODKEY,                57,      find,       { .b = TRUE } },
     88 +	{ MODKEY|GDK_SHIFT_MASK, 57,      find,       { .b = FALSE } },
     89 +
     90 +	{ MODKEY|GDK_SHIFT_MASK, 54,      toggle,     { .v = "enable-caret-browsing" } },
     91 +	{ MODKEY|GDK_SHIFT_MASK, 31,      toggle,     { .v = "auto-load-images" } },
     92 +	{ MODKEY|GDK_SHIFT_MASK, 39,      toggle,     { .v = "enable-scripts" } },
     93 +	{ MODKEY|GDK_SHIFT_MASK, 55,      toggle,     { .v = "enable-plugins" } },
     94 +	{ MODKEY|GDK_SHIFT_MASK, 38,      togglecookiepolicy, { 0 } },
     95 +	{ MODKEY|GDK_SHIFT_MASK, 58,      togglestyle, { 0 } },
     96 +	{ MODKEY|GDK_SHIFT_MASK, 56,      togglescrollbars, { 0 } },
     97 +	{ MODKEY|GDK_SHIFT_MASK, 42,      togglegeolocation, { 0 } },
     98 +	{ MODKEY|GDK_SHIFT_MASK, 29,      toggleproxy, { 0 } },
     99  };
    100  
    101  /* button definitions */
    102 diff --git a/surf.c b/surf.c
    103 index d75e589..8c0ad10 100644
    104 --- a/surf.c
    105 +++ b/surf.c
    106 @@ -67,7 +67,7 @@ typedef struct Client {
    107  
    108  typedef struct {
    109  	guint mod;
    110 -	guint keyval;
    111 +	guint16 keycode;
    112  	void (*func)(Client *c, const Arg *arg);
    113  	const Arg arg;
    114  } Key;
    115 @@ -111,7 +111,6 @@ static int policysel = 0;
    116  static char *stylefile = NULL;
    117  static SoupCache *diskcache = NULL;
    118  
    119 -static void addaccelgroup(Client *c);
    120  static void beforerequest(WebKitWebView *w, WebKitWebFrame *f,
    121                            WebKitWebResource *r, WebKitNetworkRequest *req,
    122                            WebKitNetworkResponse *resp, Client *c);
    123 @@ -171,8 +170,7 @@ static gboolean inspector_show(WebKitWebInspector *i, Client *c);
    124  static gboolean inspector_close(WebKitWebInspector *i, Client *c);
    125  static void inspector_finished(WebKitWebInspector *i, Client *c);
    126  
    127 -static gboolean keypress(GtkAccelGroup *group, GObject *obj, guint key,
    128 -                         GdkModifierType mods, Client *c);
    129 +static gboolean keypress(GtkWidget *w, GdkEventKey *e, Client *c);
    130  static void linkhover(WebKitWebView *v, const char* t, const char* l,
    131                        Client *c);
    132  static void loadstatuschange(WebKitWebView *view, GParamSpec *pspec,
    133 @@ -222,21 +220,6 @@ static void zoom(Client *c, const Arg *arg);
    134  #include "config.h"
    135  
    136  void
    137 -addaccelgroup(Client *c)
    138 -{
    139 -	int i;
    140 -	GtkAccelGroup *group = gtk_accel_group_new();
    141 -	GClosure *closure;
    142 -
    143 -	for (i = 0; i < LENGTH(keys); i++) {
    144 -		closure = g_cclosure_new(G_CALLBACK(keypress), c, NULL);
    145 -		gtk_accel_group_connect(group, keys[i].keyval, keys[i].mod, 0,
    146 -		                        closure);
    147 -	}
    148 -	gtk_window_add_accel_group(GTK_WINDOW(c->win), group);
    149 -}
    150 -
    151 -void
    152  beforerequest(WebKitWebView *w, WebKitWebFrame *f, WebKitWebResource *r,
    153                WebKitNetworkRequest *req, WebKitNetworkResponse *resp,
    154                Client *c)
    155 @@ -785,18 +768,15 @@ inspector_finished(WebKitWebInspector *i, Client *c)
    156  }
    157  
    158  gboolean
    159 -keypress(GtkAccelGroup *group, GObject *obj, guint key, GdkModifierType mods,
    160 -         Client *c)
    161 +keypress(GtkWidget *w, GdkEventKey *e, Client *c)
    162  {
    163  	guint i;
    164  	gboolean processed = FALSE;
    165  
    166 -	mods = CLEANMASK(mods);
    167 -	key = gdk_keyval_to_lower(key);
    168  	updatewinid(c);
    169  	for (i = 0; i < LENGTH(keys); i++) {
    170 -		if (key == keys[i].keyval
    171 -		    && mods == keys[i].mod
    172 +		if(e->hardware_keycode == keys[i].keycode
    173 +		    && CLEANMASK(e->state) == keys[i].mod
    174  		    && keys[i].func) {
    175  			keys[i].func(c, &(keys[i].arg));
    176  			processed = TRUE;
    177 @@ -944,8 +924,11 @@ newclient(void)
    178  	                 "leave_notify_event",
    179  	                 G_CALLBACK(titlechangeleave), c);
    180  
    181 -	if (!kioskmode)
    182 -		addaccelgroup(c);
    183 +	if (!kioskmode) {
    184 +		g_signal_connect(G_OBJECT(c->win),
    185 +		                 "key-press-event",
    186 +		                 G_CALLBACK(keypress), c);
    187 +	}
    188  
    189  	/* Pane */
    190  	c->pane = gtk_vpaned_new();